@storyshelf/db-sqlite 0.6.1 → 0.7.0
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 +9 -9
- package/dist/better-sqlite3.mjs +14 -3
- package/dist/better-sqlite3.mjs.map +1 -1
- package/dist/bun-sqlite.mjs +14 -3
- package/dist/bun-sqlite.mjs.map +1 -1
- package/dist/d1.mjs +5 -3
- package/dist/d1.mjs.map +1 -1
- package/dist/ddl.d.mts +10 -2
- package/dist/ddl.mjs +226 -14
- package/dist/ddl.mjs.map +1 -1
- package/dist/ensure-db-dir.mjs +19 -0
- package/dist/ensure-db-dir.mjs.map +1 -0
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/dist/schema/baseline.d.mts +57 -0
- package/dist/schema/baseline.mjs +4 -1
- package/dist/schema/baseline.mjs.map +1 -1
- package/dist/schema/{status-config.d.mts → build-component.d.mts} +40 -33
- package/dist/schema/build-component.mjs +22 -0
- package/dist/schema/build-component.mjs.map +1 -0
- package/dist/schema/build-review.d.mts +129 -0
- package/dist/schema/build-review.mjs +20 -0
- package/dist/schema/build-review.mjs.map +1 -0
- package/dist/schema/build.d.mts +40 -2
- package/dist/schema/build.mjs +3 -0
- package/dist/schema/build.mjs.map +1 -1
- package/dist/schema/capture-job.d.mts +359 -0
- package/dist/schema/capture-job.mjs +38 -0
- package/dist/schema/capture-job.mjs.map +1 -0
- package/dist/schema/capture-shard.d.mts +281 -0
- package/dist/schema/capture-shard.mjs +28 -0
- package/dist/schema/capture-shard.mjs.map +1 -0
- package/dist/schema/comment.d.mts +20 -0
- package/dist/schema/comment.mjs +3 -2
- package/dist/schema/comment.mjs.map +1 -1
- package/dist/schema/connection.d.mts +191 -0
- package/dist/schema/connection.mjs +26 -0
- package/dist/schema/connection.mjs.map +1 -0
- package/dist/schema/design.d.mts +649 -0
- package/dist/schema/design.mjs +49 -0
- package/dist/schema/design.mjs.map +1 -0
- package/dist/schema/insight.d.mts +689 -0
- package/dist/schema/insight.mjs +53 -0
- package/dist/schema/insight.mjs.map +1 -0
- package/dist/schema/notification.d.mts +40 -0
- package/dist/schema/notification.mjs +2 -0
- package/dist/schema/notification.mjs.map +1 -1
- package/dist/schema/project.d.mts +132 -0
- package/dist/schema/project.mjs +8 -1
- package/dist/schema/project.mjs.map +1 -1
- package/dist/schema/site-setting.d.mts +109 -0
- package/dist/schema/site-setting.mjs +17 -0
- package/dist/schema/site-setting.mjs.map +1 -0
- package/dist/schema/snapshot.d.mts +118 -0
- package/dist/schema/snapshot.mjs +11 -1
- package/dist/schema/snapshot.mjs.map +1 -1
- package/dist/schema/usage.d.mts +293 -0
- package/dist/schema/usage.mjs +30 -0
- package/dist/schema/usage.mjs.map +1 -0
- package/dist/schema.d.mts +24 -3
- package/dist/schema.mjs +25 -4
- package/dist/schema.mjs.map +1 -1
- package/dist/turso.d.mts +2 -2
- package/dist/turso.mjs +19 -6
- package/dist/turso.mjs.map +1 -1
- package/package.json +5 -2
- package/dist/schema/status-config.mjs +0 -20
- package/dist/schema/status-config.mjs.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { projects } from "./project.mjs";
|
|
5
|
+
import { builds } from "./build.mjs";
|
|
6
|
+
import { index, integer, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
7
|
+
//#region src/schema/capture-shard.ts
|
|
8
|
+
/** Narrow `capture_shards` table definition: the stages of a sharded capture and its finalize claim. */
|
|
9
|
+
const captureShards = sqliteTable("capture_shards", {
|
|
10
|
+
id: text("id").primaryKey(),
|
|
11
|
+
projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
|
|
12
|
+
buildId: text("build_id").notNull().references(() => builds.id, { onDelete: "cascade" }),
|
|
13
|
+
kind: text("kind").$type().notNull(),
|
|
14
|
+
ordinal: integer("ordinal").notNull(),
|
|
15
|
+
status: text("status").$type().notNull().default("pending"),
|
|
16
|
+
attemptId: text("attempt_id"),
|
|
17
|
+
payload: text("payload"),
|
|
18
|
+
result: text("result"),
|
|
19
|
+
error: text("error"),
|
|
20
|
+
startedAt: text("started_at"),
|
|
21
|
+
finishedAt: text("finished_at"),
|
|
22
|
+
createdAt: text("created_at").notNull(),
|
|
23
|
+
updatedAt: text("updated_at").notNull()
|
|
24
|
+
}, (t) => [uniqueIndex("capture_shards_build_kind_ordinal_idx").on(t.buildId, t.kind, t.ordinal), index("capture_shards_build_id_idx").on(t.buildId)]);
|
|
25
|
+
//#endregion
|
|
26
|
+
export { captureShards };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=capture-shard.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-shard.mjs","names":[],"sources":["../../src/schema/capture-shard.ts"],"sourcesContent":["import type { CaptureShardKind, CaptureShardStatus } from \"@storyshelf/core/schema\";\nimport { index, integer, sqliteTable, text, uniqueIndex } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\n\n/** Narrow `capture_shards` table definition: the stages of a sharded capture and its finalize claim. */\nexport const captureShards = sqliteTable(\n \"capture_shards\",\n {\n id: text(\"id\").primaryKey(),\n projectId: text(\"project_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n buildId: text(\"build_id\")\n .notNull()\n .references(() => builds.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\").$type<CaptureShardKind>().notNull(),\n ordinal: integer(\"ordinal\").notNull(),\n status: text(\"status\").$type<CaptureShardStatus>().notNull().default(\"pending\"),\n attemptId: text(\"attempt_id\"),\n payload: text(\"payload\"),\n result: text(\"result\"),\n error: text(\"error\"),\n startedAt: text(\"started_at\"),\n finishedAt: text(\"finished_at\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (t) => [\n uniqueIndex(\"capture_shards_build_kind_ordinal_idx\").on(t.buildId, t.kind, t.ordinal),\n index(\"capture_shards_build_id_idx\").on(t.buildId),\n ],\n);\n"],"mappings":";;;;;;;;AAMA,MAAa,gBAAgB,YAC3B,kBACA;CACE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,WAAW,KAAK,YAAY,CAAC,CAC1B,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,SAAS,KAAK,UAAU,CAAC,CACtB,QAAQ,CAAC,CACT,iBAAiB,OAAO,IAAI,EAAE,UAAU,UAAU,CAAC;CACtD,MAAM,KAAK,MAAM,CAAC,CAAC,MAAwB,CAAC,CAAC,QAAQ;CACrD,SAAS,QAAQ,SAAS,CAAC,CAAC,QAAQ;CACpC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAA0B,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,SAAS;CAC9E,WAAW,KAAK,YAAY;CAC5B,SAAS,KAAK,SAAS;CACvB,QAAQ,KAAK,QAAQ;CACrB,OAAO,KAAK,OAAO;CACnB,WAAW,KAAK,YAAY;CAC5B,YAAY,KAAK,aAAa;CAC9B,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM,CACL,YAAY,uCAAuC,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GACpF,MAAM,6BAA6B,CAAC,CAAC,GAAG,EAAE,OAAO,CACnD,CACF"}
|
|
@@ -194,6 +194,25 @@ declare const comments: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns
|
|
|
194
194
|
}, {}, {
|
|
195
195
|
length: number | undefined;
|
|
196
196
|
}>;
|
|
197
|
+
storyId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
198
|
+
name: "story_id";
|
|
199
|
+
tableName: "comments";
|
|
200
|
+
dataType: "string";
|
|
201
|
+
columnType: "SQLiteText";
|
|
202
|
+
data: string;
|
|
203
|
+
driverParam: string;
|
|
204
|
+
notNull: false;
|
|
205
|
+
hasDefault: false;
|
|
206
|
+
isPrimaryKey: false;
|
|
207
|
+
isAutoincrement: false;
|
|
208
|
+
hasRuntimeDefault: false;
|
|
209
|
+
enumValues: [string, ...string[]];
|
|
210
|
+
baseColumn: never;
|
|
211
|
+
identity: undefined;
|
|
212
|
+
generated: undefined;
|
|
213
|
+
}, {}, {
|
|
214
|
+
length: number | undefined;
|
|
215
|
+
}>;
|
|
197
216
|
};
|
|
198
217
|
dialect: 'sqlite';
|
|
199
218
|
}>;
|
|
@@ -209,6 +228,7 @@ interface Comment {
|
|
|
209
228
|
resolved: boolean;
|
|
210
229
|
createdAt: string;
|
|
211
230
|
updatedAt: string;
|
|
231
|
+
storyId: string | null;
|
|
212
232
|
}
|
|
213
233
|
//#endregion
|
|
214
234
|
export { Comment, comments };
|
package/dist/schema/comment.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import "node:url";
|
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import { projects } from "./project.mjs";
|
|
5
5
|
import { builds } from "./build.mjs";
|
|
6
|
-
import { snapshots } from "./snapshot.mjs";
|
|
7
6
|
import { users } from "./user.mjs";
|
|
7
|
+
import { snapshots } from "./snapshot.mjs";
|
|
8
8
|
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
9
9
|
//#region src/schema/comment.ts
|
|
10
10
|
/** Narrow `comments` table definition. */
|
|
@@ -18,7 +18,8 @@ const comments = sqliteTable("comments", {
|
|
|
18
18
|
parentId: text("parent_id"),
|
|
19
19
|
resolved: integer("resolved", { mode: "boolean" }).notNull().default(false),
|
|
20
20
|
createdAt: text("created_at").notNull(),
|
|
21
|
-
updatedAt: text("updated_at").notNull()
|
|
21
|
+
updatedAt: text("updated_at").notNull(),
|
|
22
|
+
storyId: text("story_id")
|
|
22
23
|
}, (t) => [index("comments_build_id_idx").on(t.buildId)]);
|
|
23
24
|
//#endregion
|
|
24
25
|
export { comments };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.mjs","names":[],"sources":["../../src/schema/comment.ts"],"sourcesContent":["import { index, integer, sqliteTable, text } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\nimport { snapshots } from \"./snapshot.ts\";\nimport { users } from \"./user.ts\";\n\n/** Narrow `comments` table definition. */\nexport const comments = sqliteTable(\n \"comments\",\n {\n id: text(\"id\").primaryKey(),\n projectId: text(\"project_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n buildId: text(\"build_id\")\n .notNull()\n .references(() => builds.id, { onDelete: \"cascade\" }),\n snapshotId: text(\"snapshot_id\").references(() => snapshots.id, { onDelete: \"cascade\" }),\n userId: text(\"user_id\").references(() => users.id, { onDelete: \"cascade\" }),\n body: text(\"body\").notNull(),\n parentId: text(\"parent_id\"),\n resolved: integer(\"resolved\", { mode: \"boolean\" }).notNull().default(false),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (t) => [index(\"comments_build_id_idx\").on(t.buildId)],\n);\n\n/** A comment row. */\nexport interface Comment {\n id: string;\n projectId: string;\n buildId: string;\n snapshotId: string | null;\n userId: string | null;\n body: string;\n parentId: string | null;\n resolved: boolean;\n createdAt: string;\n updatedAt: string;\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,WAAW,YACtB,YACA;CACE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,WAAW,KAAK,YAAY,CAAC,CAC1B,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,SAAS,KAAK,UAAU,CAAC,CACtB,QAAQ,CAAC,CACT,iBAAiB,OAAO,IAAI,EAAE,UAAU,UAAU,CAAC;CACtD,YAAY,KAAK,aAAa,CAAC,CAAC,iBAAiB,UAAU,IAAI,EAAE,UAAU,UAAU,CAAC;CACtF,QAAQ,KAAK,SAAS,CAAC,CAAC,iBAAiB,MAAM,IAAI,EAAE,UAAU,UAAU,CAAC;CAC1E,MAAM,KAAK,MAAM,CAAC,CAAC,QAAQ;CAC3B,UAAU,KAAK,WAAW;CAC1B,UAAU,QAAQ,YAAY,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK;CAC1E,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;
|
|
1
|
+
{"version":3,"file":"comment.mjs","names":[],"sources":["../../src/schema/comment.ts"],"sourcesContent":["import { index, integer, sqliteTable, text } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\nimport { snapshots } from \"./snapshot.ts\";\nimport { users } from \"./user.ts\";\n\n/** Narrow `comments` table definition. */\nexport const comments = sqliteTable(\n \"comments\",\n {\n id: text(\"id\").primaryKey(),\n projectId: text(\"project_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n buildId: text(\"build_id\")\n .notNull()\n .references(() => builds.id, { onDelete: \"cascade\" }),\n snapshotId: text(\"snapshot_id\").references(() => snapshots.id, { onDelete: \"cascade\" }),\n userId: text(\"user_id\").references(() => users.id, { onDelete: \"cascade\" }),\n body: text(\"body\").notNull(),\n parentId: text(\"parent_id\"),\n resolved: integer(\"resolved\", { mode: \"boolean\" }).notNull().default(false),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n storyId: text(\"story_id\"),\n },\n (t) => [index(\"comments_build_id_idx\").on(t.buildId)],\n);\n\n/** A comment row. */\nexport interface Comment {\n id: string;\n projectId: string;\n buildId: string;\n snapshotId: string | null;\n userId: string | null;\n body: string;\n parentId: string | null;\n resolved: boolean;\n createdAt: string;\n updatedAt: string;\n storyId: string | null;\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,WAAW,YACtB,YACA;CACE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,WAAW,KAAK,YAAY,CAAC,CAC1B,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,SAAS,KAAK,UAAU,CAAC,CACtB,QAAQ,CAAC,CACT,iBAAiB,OAAO,IAAI,EAAE,UAAU,UAAU,CAAC;CACtD,YAAY,KAAK,aAAa,CAAC,CAAC,iBAAiB,UAAU,IAAI,EAAE,UAAU,UAAU,CAAC;CACtF,QAAQ,KAAK,SAAS,CAAC,CAAC,iBAAiB,MAAM,IAAI,EAAE,UAAU,UAAU,CAAC;CAC1E,MAAM,KAAK,MAAM,CAAC,CAAC,QAAQ;CAC3B,UAAU,KAAK,WAAW;CAC1B,UAAU,QAAQ,YAAY,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK;CAC1E,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,SAAS,KAAK,UAAU;AAC1B,IACC,MAAM,CAAC,MAAM,uBAAuB,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CACtD"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region src/schema/connection.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A user's own OAuth connection to an external service (Figma, later Jira/Linear/…),
|
|
6
|
+
* one per user and service. `tokenEncrypted` is the access token; the refresh token
|
|
7
|
+
* is encrypted too. `status` is `ok` or `expired` (needs reconnecting).
|
|
8
|
+
*/
|
|
9
|
+
declare const userConnections: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
10
|
+
name: "user_connections";
|
|
11
|
+
schema: undefined;
|
|
12
|
+
columns: {
|
|
13
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14
|
+
name: "id";
|
|
15
|
+
tableName: "user_connections";
|
|
16
|
+
dataType: "string";
|
|
17
|
+
columnType: "SQLiteText";
|
|
18
|
+
data: string;
|
|
19
|
+
driverParam: string;
|
|
20
|
+
notNull: true;
|
|
21
|
+
hasDefault: false;
|
|
22
|
+
isPrimaryKey: true;
|
|
23
|
+
isAutoincrement: false;
|
|
24
|
+
hasRuntimeDefault: false;
|
|
25
|
+
enumValues: [string, ...string[]];
|
|
26
|
+
baseColumn: never;
|
|
27
|
+
identity: undefined;
|
|
28
|
+
generated: undefined;
|
|
29
|
+
}, {}, {
|
|
30
|
+
length: number | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
userId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
33
|
+
name: "user_id";
|
|
34
|
+
tableName: "user_connections";
|
|
35
|
+
dataType: "string";
|
|
36
|
+
columnType: "SQLiteText";
|
|
37
|
+
data: string;
|
|
38
|
+
driverParam: string;
|
|
39
|
+
notNull: true;
|
|
40
|
+
hasDefault: false;
|
|
41
|
+
isPrimaryKey: false;
|
|
42
|
+
isAutoincrement: false;
|
|
43
|
+
hasRuntimeDefault: false;
|
|
44
|
+
enumValues: [string, ...string[]];
|
|
45
|
+
baseColumn: never;
|
|
46
|
+
identity: undefined;
|
|
47
|
+
generated: undefined;
|
|
48
|
+
}, {}, {
|
|
49
|
+
length: number | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
service: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
52
|
+
name: "service";
|
|
53
|
+
tableName: "user_connections";
|
|
54
|
+
dataType: "string";
|
|
55
|
+
columnType: "SQLiteText";
|
|
56
|
+
data: string;
|
|
57
|
+
driverParam: string;
|
|
58
|
+
notNull: true;
|
|
59
|
+
hasDefault: false;
|
|
60
|
+
isPrimaryKey: false;
|
|
61
|
+
isAutoincrement: false;
|
|
62
|
+
hasRuntimeDefault: false;
|
|
63
|
+
enumValues: [string, ...string[]];
|
|
64
|
+
baseColumn: never;
|
|
65
|
+
identity: undefined;
|
|
66
|
+
generated: undefined;
|
|
67
|
+
}, {}, {
|
|
68
|
+
length: number | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
tokenEncrypted: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
71
|
+
name: "token_encrypted";
|
|
72
|
+
tableName: "user_connections";
|
|
73
|
+
dataType: "string";
|
|
74
|
+
columnType: "SQLiteText";
|
|
75
|
+
data: string;
|
|
76
|
+
driverParam: string;
|
|
77
|
+
notNull: true;
|
|
78
|
+
hasDefault: false;
|
|
79
|
+
isPrimaryKey: false;
|
|
80
|
+
isAutoincrement: false;
|
|
81
|
+
hasRuntimeDefault: false;
|
|
82
|
+
enumValues: [string, ...string[]];
|
|
83
|
+
baseColumn: never;
|
|
84
|
+
identity: undefined;
|
|
85
|
+
generated: undefined;
|
|
86
|
+
}, {}, {
|
|
87
|
+
length: number | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
refreshTokenEncrypted: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
90
|
+
name: "refresh_token_encrypted";
|
|
91
|
+
tableName: "user_connections";
|
|
92
|
+
dataType: "string";
|
|
93
|
+
columnType: "SQLiteText";
|
|
94
|
+
data: string;
|
|
95
|
+
driverParam: string;
|
|
96
|
+
notNull: false;
|
|
97
|
+
hasDefault: false;
|
|
98
|
+
isPrimaryKey: false;
|
|
99
|
+
isAutoincrement: false;
|
|
100
|
+
hasRuntimeDefault: false;
|
|
101
|
+
enumValues: [string, ...string[]];
|
|
102
|
+
baseColumn: never;
|
|
103
|
+
identity: undefined;
|
|
104
|
+
generated: undefined;
|
|
105
|
+
}, {}, {
|
|
106
|
+
length: number | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
expiresAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
109
|
+
name: "expires_at";
|
|
110
|
+
tableName: "user_connections";
|
|
111
|
+
dataType: "string";
|
|
112
|
+
columnType: "SQLiteText";
|
|
113
|
+
data: string;
|
|
114
|
+
driverParam: string;
|
|
115
|
+
notNull: false;
|
|
116
|
+
hasDefault: false;
|
|
117
|
+
isPrimaryKey: false;
|
|
118
|
+
isAutoincrement: false;
|
|
119
|
+
hasRuntimeDefault: false;
|
|
120
|
+
enumValues: [string, ...string[]];
|
|
121
|
+
baseColumn: never;
|
|
122
|
+
identity: undefined;
|
|
123
|
+
generated: undefined;
|
|
124
|
+
}, {}, {
|
|
125
|
+
length: number | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
128
|
+
name: "status";
|
|
129
|
+
tableName: "user_connections";
|
|
130
|
+
dataType: "string";
|
|
131
|
+
columnType: "SQLiteText";
|
|
132
|
+
data: string;
|
|
133
|
+
driverParam: string;
|
|
134
|
+
notNull: true;
|
|
135
|
+
hasDefault: true;
|
|
136
|
+
isPrimaryKey: false;
|
|
137
|
+
isAutoincrement: false;
|
|
138
|
+
hasRuntimeDefault: false;
|
|
139
|
+
enumValues: [string, ...string[]];
|
|
140
|
+
baseColumn: never;
|
|
141
|
+
identity: undefined;
|
|
142
|
+
generated: undefined;
|
|
143
|
+
}, {}, {
|
|
144
|
+
length: number | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
147
|
+
name: "created_at";
|
|
148
|
+
tableName: "user_connections";
|
|
149
|
+
dataType: "string";
|
|
150
|
+
columnType: "SQLiteText";
|
|
151
|
+
data: string;
|
|
152
|
+
driverParam: string;
|
|
153
|
+
notNull: true;
|
|
154
|
+
hasDefault: false;
|
|
155
|
+
isPrimaryKey: false;
|
|
156
|
+
isAutoincrement: false;
|
|
157
|
+
hasRuntimeDefault: false;
|
|
158
|
+
enumValues: [string, ...string[]];
|
|
159
|
+
baseColumn: never;
|
|
160
|
+
identity: undefined;
|
|
161
|
+
generated: undefined;
|
|
162
|
+
}, {}, {
|
|
163
|
+
length: number | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
166
|
+
name: "updated_at";
|
|
167
|
+
tableName: "user_connections";
|
|
168
|
+
dataType: "string";
|
|
169
|
+
columnType: "SQLiteText";
|
|
170
|
+
data: string;
|
|
171
|
+
driverParam: string;
|
|
172
|
+
notNull: true;
|
|
173
|
+
hasDefault: false;
|
|
174
|
+
isPrimaryKey: false;
|
|
175
|
+
isAutoincrement: false;
|
|
176
|
+
hasRuntimeDefault: false;
|
|
177
|
+
enumValues: [string, ...string[]];
|
|
178
|
+
baseColumn: never;
|
|
179
|
+
identity: undefined;
|
|
180
|
+
generated: undefined;
|
|
181
|
+
}, {}, {
|
|
182
|
+
length: number | undefined;
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
dialect: 'sqlite';
|
|
186
|
+
}>;
|
|
187
|
+
/** Row type of `user_connections`. */
|
|
188
|
+
type UserConnection = typeof userConnections.$inferSelect;
|
|
189
|
+
//#endregion
|
|
190
|
+
export { UserConnection, userConnections };
|
|
191
|
+
//# sourceMappingURL=connection.d.mts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { users } from "./user.mjs";
|
|
5
|
+
import { sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
6
|
+
//#region src/schema/connection.ts
|
|
7
|
+
/**
|
|
8
|
+
* A user's own OAuth connection to an external service (Figma, later Jira/Linear/…),
|
|
9
|
+
* one per user and service. `tokenEncrypted` is the access token; the refresh token
|
|
10
|
+
* is encrypted too. `status` is `ok` or `expired` (needs reconnecting).
|
|
11
|
+
*/
|
|
12
|
+
const userConnections = sqliteTable("user_connections", {
|
|
13
|
+
id: text("id").primaryKey(),
|
|
14
|
+
userId: text("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
15
|
+
service: text("service").notNull(),
|
|
16
|
+
tokenEncrypted: text("token_encrypted").notNull(),
|
|
17
|
+
refreshTokenEncrypted: text("refresh_token_encrypted"),
|
|
18
|
+
expiresAt: text("expires_at"),
|
|
19
|
+
status: text("status").notNull().default("ok"),
|
|
20
|
+
createdAt: text("created_at").notNull(),
|
|
21
|
+
updatedAt: text("updated_at").notNull()
|
|
22
|
+
}, (t) => [uniqueIndex("user_connections_user_service_idx").on(t.userId, t.service)]);
|
|
23
|
+
//#endregion
|
|
24
|
+
export { userConnections };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=connection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.mjs","names":[],"sources":["../../src/schema/connection.ts"],"sourcesContent":["import { sqliteTable, text, uniqueIndex } from \"drizzle-orm/sqlite-core\";\nimport { users } from \"./user.ts\";\n\n/**\n * A user's own OAuth connection to an external service (Figma, later Jira/Linear/…),\n * one per user and service. `tokenEncrypted` is the access token; the refresh token\n * is encrypted too. `status` is `ok` or `expired` (needs reconnecting).\n */\nexport const userConnections = sqliteTable(\n \"user_connections\",\n {\n id: text(\"id\").primaryKey(),\n userId: text(\"user_id\")\n .notNull()\n .references(() => users.id, { onDelete: \"cascade\" }),\n service: text(\"service\").notNull(),\n tokenEncrypted: text(\"token_encrypted\").notNull(),\n refreshTokenEncrypted: text(\"refresh_token_encrypted\"),\n expiresAt: text(\"expires_at\"),\n status: text(\"status\").notNull().default(\"ok\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (t) => [uniqueIndex(\"user_connections_user_service_idx\").on(t.userId, t.service)],\n);\n\n/** Row type of `user_connections`. */\nexport type UserConnection = typeof userConnections.$inferSelect;\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBAAkB,YAC7B,oBACA;CACE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,QAAQ,KAAK,SAAS,CAAC,CACpB,QAAQ,CAAC,CACT,iBAAiB,MAAM,IAAI,EAAE,UAAU,UAAU,CAAC;CACrD,SAAS,KAAK,SAAS,CAAC,CAAC,QAAQ;CACjC,gBAAgB,KAAK,iBAAiB,CAAC,CAAC,QAAQ;CAChD,uBAAuB,KAAK,yBAAyB;CACrD,WAAW,KAAK,YAAY;CAC5B,QAAQ,KAAK,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,IAAI;CAC7C,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM,CAAC,YAAY,mCAAmC,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAClF"}
|