@storyshelf/db-sqlite 0.6.2 → 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.
Files changed (66) hide show
  1. package/README.md +9 -9
  2. package/dist/better-sqlite3.mjs +7 -2
  3. package/dist/better-sqlite3.mjs.map +1 -1
  4. package/dist/bun-sqlite.mjs +7 -2
  5. package/dist/bun-sqlite.mjs.map +1 -1
  6. package/dist/d1.mjs +5 -3
  7. package/dist/d1.mjs.map +1 -1
  8. package/dist/ddl.d.mts +10 -2
  9. package/dist/ddl.mjs +226 -14
  10. package/dist/ddl.mjs.map +1 -1
  11. package/dist/index.mjs +7 -2
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/schema/baseline.d.mts +57 -0
  14. package/dist/schema/baseline.mjs +4 -1
  15. package/dist/schema/baseline.mjs.map +1 -1
  16. package/dist/schema/{status-config.d.mts → build-component.d.mts} +40 -33
  17. package/dist/schema/build-component.mjs +22 -0
  18. package/dist/schema/build-component.mjs.map +1 -0
  19. package/dist/schema/build-review.d.mts +129 -0
  20. package/dist/schema/build-review.mjs +20 -0
  21. package/dist/schema/build-review.mjs.map +1 -0
  22. package/dist/schema/build.d.mts +40 -2
  23. package/dist/schema/build.mjs +3 -0
  24. package/dist/schema/build.mjs.map +1 -1
  25. package/dist/schema/capture-job.d.mts +359 -0
  26. package/dist/schema/capture-job.mjs +38 -0
  27. package/dist/schema/capture-job.mjs.map +1 -0
  28. package/dist/schema/capture-shard.d.mts +281 -0
  29. package/dist/schema/capture-shard.mjs +28 -0
  30. package/dist/schema/capture-shard.mjs.map +1 -0
  31. package/dist/schema/comment.d.mts +20 -0
  32. package/dist/schema/comment.mjs +3 -2
  33. package/dist/schema/comment.mjs.map +1 -1
  34. package/dist/schema/connection.d.mts +191 -0
  35. package/dist/schema/connection.mjs +26 -0
  36. package/dist/schema/connection.mjs.map +1 -0
  37. package/dist/schema/design.d.mts +649 -0
  38. package/dist/schema/design.mjs +49 -0
  39. package/dist/schema/design.mjs.map +1 -0
  40. package/dist/schema/insight.d.mts +689 -0
  41. package/dist/schema/insight.mjs +53 -0
  42. package/dist/schema/insight.mjs.map +1 -0
  43. package/dist/schema/notification.d.mts +40 -0
  44. package/dist/schema/notification.mjs +2 -0
  45. package/dist/schema/notification.mjs.map +1 -1
  46. package/dist/schema/project.d.mts +132 -0
  47. package/dist/schema/project.mjs +8 -1
  48. package/dist/schema/project.mjs.map +1 -1
  49. package/dist/schema/site-setting.d.mts +109 -0
  50. package/dist/schema/site-setting.mjs +17 -0
  51. package/dist/schema/site-setting.mjs.map +1 -0
  52. package/dist/schema/snapshot.d.mts +118 -0
  53. package/dist/schema/snapshot.mjs +11 -1
  54. package/dist/schema/snapshot.mjs.map +1 -1
  55. package/dist/schema/usage.d.mts +293 -0
  56. package/dist/schema/usage.mjs +30 -0
  57. package/dist/schema/usage.mjs.map +1 -0
  58. package/dist/schema.d.mts +24 -3
  59. package/dist/schema.mjs +25 -4
  60. package/dist/schema.mjs.map +1 -1
  61. package/dist/turso.d.mts +2 -2
  62. package/dist/turso.mjs +19 -6
  63. package/dist/turso.mjs.map +1 -1
  64. package/package.json +5 -5
  65. package/dist/schema/status-config.mjs +0 -20
  66. package/dist/schema/status-config.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.mjs","names":[],"sources":["../../src/schema/snapshot.ts"],"sourcesContent":["import type { SnapshotStatus } from \"@storyshelf/core/types\";\nimport { index, integer, real, sqliteTable, text, uniqueIndex } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\n\n/** Narrow `snapshots` table definition. */\nexport const snapshots = sqliteTable(\n \"snapshots\",\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 storyId: text(\"story_id\").notNull(),\n storyName: text(\"story_name\").notNull(),\n storyTitle: text(\"story_title\").notNull(),\n storyImportPath: text(\"story_import_path\"),\n viewportName: text(\"viewport_name\").notNull().default(\"desktop\"),\n viewportWidth: integer(\"viewport_width\").notNull().default(1280),\n viewportHeight: integer(\"viewport_height\").notNull().default(720),\n screenshotPath: text(\"screenshot_path\").notNull(),\n diffPath: text(\"diff_path\"),\n diffPixels: integer(\"diff_pixels\"),\n diffRatio: real(\"diff_ratio\"),\n diffPassed: integer(\"diff_passed\", { mode: \"boolean\" }),\n status: text(\"status\").$type<SnapshotStatus>().notNull().default(\"pending\"),\n reviewedBy: text(\"reviewed_by\"),\n reviewedAt: text(\"reviewed_at\"),\n infraHash: text(\"infra_hash\"),\n inherited: integer(\"inherited\", { mode: \"boolean\" }).notNull().default(false),\n baselineId: text(\"baseline_id\"),\n baselineVersion: text(\"baseline_version\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (t) => [\n uniqueIndex(\"snapshots_build_story_viewport_idx\").on(t.buildId, t.storyId, t.viewportName),\n index(\"snapshots_build_id_idx\").on(t.buildId),\n ],\n);\n\n/** A snapshot row. */\nexport interface Snapshot {\n id: string;\n projectId: string;\n buildId: string;\n storyId: string;\n storyName: string;\n storyTitle: string;\n storyImportPath: string | null;\n viewportName: string;\n viewportWidth: number;\n viewportHeight: number;\n screenshotPath: string;\n diffPath: string | null;\n diffPixels: number | null;\n diffRatio: number | null;\n diffPassed: boolean | null;\n status: SnapshotStatus;\n reviewedBy: string | null;\n reviewedAt: string | null;\n infraHash: string | null;\n inherited: boolean;\n baselineId: string | null;\n baselineVersion: string | null;\n createdAt: string;\n updatedAt: string;\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,YAAY,YACvB,aACA;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,SAAS,KAAK,UAAU,CAAC,CAAC,QAAQ;CAClC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,YAAY,KAAK,aAAa,CAAC,CAAC,QAAQ;CACxC,iBAAiB,KAAK,mBAAmB;CACzC,cAAc,KAAK,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,SAAS;CAC/D,eAAe,QAAQ,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,IAAI;CAC/D,gBAAgB,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,GAAG;CAChE,gBAAgB,KAAK,iBAAiB,CAAC,CAAC,QAAQ;CAChD,UAAU,KAAK,WAAW;CAC1B,YAAY,QAAQ,aAAa;CACjC,WAAW,KAAK,YAAY;CAC5B,YAAY,QAAQ,eAAe,EAAE,MAAM,UAAU,CAAC;CACtD,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,SAAS;CAC1E,YAAY,KAAK,aAAa;CAC9B,YAAY,KAAK,aAAa;CAC9B,WAAW,KAAK,YAAY;CAC5B,WAAW,QAAQ,aAAa,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK;CAC5E,YAAY,KAAK,aAAa;CAC9B,iBAAiB,KAAK,kBAAkB;CACxC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM,CACL,YAAY,oCAAoC,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,GACzF,MAAM,wBAAwB,CAAC,CAAC,GAAG,EAAE,OAAO,CAC9C,CACF"}
1
+ {"version":3,"file":"snapshot.mjs","names":[],"sources":["../../src/schema/snapshot.ts"],"sourcesContent":["import type { SnapshotStatus } from \"@storyshelf/core/types\";\nimport { index, integer, real, sqliteTable, text, uniqueIndex } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\n\n/** Narrow `snapshots` table definition. */\nexport const snapshots = sqliteTable(\n \"snapshots\",\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 storyId: text(\"story_id\").notNull(),\n storyName: text(\"story_name\").notNull(),\n storyTitle: text(\"story_title\").notNull(),\n storyImportPath: text(\"story_import_path\"),\n designUrl: text(\"design_url\"),\n viewportName: text(\"viewport_name\").notNull().default(\"desktop\"),\n viewportWidth: integer(\"viewport_width\").notNull().default(1280),\n viewportHeight: integer(\"viewport_height\").notNull().default(720),\n screenshotPath: text(\"screenshot_path\").notNull(),\n diffPath: text(\"diff_path\"),\n diffPixels: integer(\"diff_pixels\"),\n diffRatio: real(\"diff_ratio\"),\n diffPassed: integer(\"diff_passed\", { mode: \"boolean\" }),\n status: text(\"status\").$type<SnapshotStatus>().notNull().default(\"pending\"),\n reviewedBy: text(\"reviewed_by\"),\n reviewedAt: text(\"reviewed_at\"),\n infraHash: text(\"infra_hash\"),\n envChange: text(\"env_change\"),\n inherited: integer(\"inherited\", { mode: \"boolean\" }).notNull().default(false),\n baselineId: text(\"baseline_id\"),\n baselineVersion: text(\"baseline_version\"),\n mode: text(\"mode\"),\n browser: text(\"browser\").notNull().default(\"chromium\"),\n durationMs: integer(\"duration_ms\"),\n a11yViolations: text(\"a11y_violations\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (t) => [\n uniqueIndex(\"snapshots_build_story_mode_browser_idx\").on(\n t.buildId,\n t.storyId,\n t.viewportName,\n t.browser,\n ),\n index(\"snapshots_build_id_idx\").on(t.buildId),\n index(\"snapshots_project_import_path_idx\").on(t.projectId, t.storyImportPath),\n ],\n);\n\n/** A snapshot row. */\nexport interface Snapshot {\n id: string;\n projectId: string;\n buildId: string;\n storyId: string;\n storyName: string;\n storyTitle: string;\n storyImportPath: string | null;\n designUrl: string | null;\n viewportName: string;\n viewportWidth: number;\n viewportHeight: number;\n screenshotPath: string;\n diffPath: string | null;\n diffPixels: number | null;\n diffRatio: number | null;\n diffPassed: boolean | null;\n status: SnapshotStatus;\n reviewedBy: string | null;\n reviewedAt: string | null;\n infraHash: string | null;\n envChange: string | null;\n inherited: boolean;\n baselineId: string | null;\n baselineVersion: string | null;\n mode: string | null;\n browser: string;\n durationMs: number | null;\n a11yViolations: string | null;\n createdAt: string;\n updatedAt: string;\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,YAAY,YACvB,aACA;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,SAAS,KAAK,UAAU,CAAC,CAAC,QAAQ;CAClC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,YAAY,KAAK,aAAa,CAAC,CAAC,QAAQ;CACxC,iBAAiB,KAAK,mBAAmB;CACzC,WAAW,KAAK,YAAY;CAC5B,cAAc,KAAK,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,SAAS;CAC/D,eAAe,QAAQ,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,IAAI;CAC/D,gBAAgB,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,GAAG;CAChE,gBAAgB,KAAK,iBAAiB,CAAC,CAAC,QAAQ;CAChD,UAAU,KAAK,WAAW;CAC1B,YAAY,QAAQ,aAAa;CACjC,WAAW,KAAK,YAAY;CAC5B,YAAY,QAAQ,eAAe,EAAE,MAAM,UAAU,CAAC;CACtD,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,SAAS;CAC1E,YAAY,KAAK,aAAa;CAC9B,YAAY,KAAK,aAAa;CAC9B,WAAW,KAAK,YAAY;CAC5B,WAAW,KAAK,YAAY;CAC5B,WAAW,QAAQ,aAAa,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK;CAC5E,YAAY,KAAK,aAAa;CAC9B,iBAAiB,KAAK,kBAAkB;CACxC,MAAM,KAAK,MAAM;CACjB,SAAS,KAAK,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,UAAU;CACrD,YAAY,QAAQ,aAAa;CACjC,gBAAgB,KAAK,iBAAiB;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;CACtC,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM;CACL,YAAY,wCAAwC,CAAC,CAAC,GACpD,EAAE,SACF,EAAE,SACF,EAAE,cACF,EAAE,OACJ;CACA,MAAM,wBAAwB,CAAC,CAAC,GAAG,EAAE,OAAO;CAC5C,MAAM,mCAAmC,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,eAAe;AAC9E,CACF"}
@@ -0,0 +1,293 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ //#region src/schema/usage.d.ts
4
+ /** Narrow `project_links` table definition. */
5
+ declare const projectLinks: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
6
+ name: "project_links";
7
+ schema: undefined;
8
+ columns: {
9
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
10
+ name: "id";
11
+ tableName: "project_links";
12
+ dataType: "string";
13
+ columnType: "SQLiteText";
14
+ data: string;
15
+ driverParam: string;
16
+ notNull: true;
17
+ hasDefault: false;
18
+ isPrimaryKey: true;
19
+ isAutoincrement: false;
20
+ hasRuntimeDefault: false;
21
+ enumValues: [string, ...string[]];
22
+ baseColumn: never;
23
+ identity: undefined;
24
+ generated: undefined;
25
+ }, {}, {
26
+ length: number | undefined;
27
+ }>;
28
+ downstreamId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
29
+ name: "downstream_id";
30
+ tableName: "project_links";
31
+ dataType: "string";
32
+ columnType: "SQLiteText";
33
+ data: string;
34
+ driverParam: string;
35
+ notNull: true;
36
+ hasDefault: false;
37
+ isPrimaryKey: false;
38
+ isAutoincrement: false;
39
+ hasRuntimeDefault: false;
40
+ enumValues: [string, ...string[]];
41
+ baseColumn: never;
42
+ identity: undefined;
43
+ generated: undefined;
44
+ }, {}, {
45
+ length: number | undefined;
46
+ }>;
47
+ upstreamId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
48
+ name: "upstream_id";
49
+ tableName: "project_links";
50
+ dataType: "string";
51
+ columnType: "SQLiteText";
52
+ data: string;
53
+ driverParam: string;
54
+ notNull: true;
55
+ hasDefault: false;
56
+ isPrimaryKey: false;
57
+ isAutoincrement: false;
58
+ hasRuntimeDefault: false;
59
+ enumValues: [string, ...string[]];
60
+ baseColumn: never;
61
+ identity: undefined;
62
+ generated: undefined;
63
+ }, {}, {
64
+ length: number | undefined;
65
+ }>;
66
+ packageName: import("drizzle-orm/sqlite-core").SQLiteColumn<{
67
+ name: "package_name";
68
+ tableName: "project_links";
69
+ dataType: "string";
70
+ columnType: "SQLiteText";
71
+ data: string;
72
+ driverParam: string;
73
+ notNull: true;
74
+ hasDefault: false;
75
+ isPrimaryKey: false;
76
+ isAutoincrement: false;
77
+ hasRuntimeDefault: false;
78
+ enumValues: [string, ...string[]];
79
+ baseColumn: never;
80
+ identity: undefined;
81
+ generated: undefined;
82
+ }, {}, {
83
+ length: number | undefined;
84
+ }>;
85
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
86
+ name: "created_at";
87
+ tableName: "project_links";
88
+ dataType: "string";
89
+ columnType: "SQLiteText";
90
+ data: string;
91
+ driverParam: string;
92
+ notNull: true;
93
+ hasDefault: false;
94
+ isPrimaryKey: false;
95
+ isAutoincrement: false;
96
+ hasRuntimeDefault: false;
97
+ enumValues: [string, ...string[]];
98
+ baseColumn: never;
99
+ identity: undefined;
100
+ generated: undefined;
101
+ }, {}, {
102
+ length: number | undefined;
103
+ }>;
104
+ };
105
+ dialect: 'sqlite';
106
+ }>;
107
+ /** Narrow `build_package_usage` table definition. */
108
+ declare const buildPackageUsage: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
109
+ name: "build_package_usage";
110
+ schema: undefined;
111
+ columns: {
112
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
113
+ name: "id";
114
+ tableName: "build_package_usage";
115
+ dataType: "string";
116
+ columnType: "SQLiteText";
117
+ data: string;
118
+ driverParam: string;
119
+ notNull: true;
120
+ hasDefault: false;
121
+ isPrimaryKey: true;
122
+ isAutoincrement: false;
123
+ hasRuntimeDefault: false;
124
+ enumValues: [string, ...string[]];
125
+ baseColumn: never;
126
+ identity: undefined;
127
+ generated: undefined;
128
+ }, {}, {
129
+ length: number | undefined;
130
+ }>;
131
+ projectId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
132
+ name: "project_id";
133
+ tableName: "build_package_usage";
134
+ dataType: "string";
135
+ columnType: "SQLiteText";
136
+ data: string;
137
+ driverParam: string;
138
+ notNull: true;
139
+ hasDefault: false;
140
+ isPrimaryKey: false;
141
+ isAutoincrement: false;
142
+ hasRuntimeDefault: false;
143
+ enumValues: [string, ...string[]];
144
+ baseColumn: never;
145
+ identity: undefined;
146
+ generated: undefined;
147
+ }, {}, {
148
+ length: number | undefined;
149
+ }>;
150
+ buildId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
151
+ name: "build_id";
152
+ tableName: "build_package_usage";
153
+ dataType: "string";
154
+ columnType: "SQLiteText";
155
+ data: string;
156
+ driverParam: string;
157
+ notNull: true;
158
+ hasDefault: false;
159
+ isPrimaryKey: false;
160
+ isAutoincrement: false;
161
+ hasRuntimeDefault: false;
162
+ enumValues: [string, ...string[]];
163
+ baseColumn: never;
164
+ identity: undefined;
165
+ generated: undefined;
166
+ }, {}, {
167
+ length: number | undefined;
168
+ }>;
169
+ storyImportPath: import("drizzle-orm/sqlite-core").SQLiteColumn<{
170
+ name: "story_import_path";
171
+ tableName: "build_package_usage";
172
+ dataType: "string";
173
+ columnType: "SQLiteText";
174
+ data: string;
175
+ driverParam: string;
176
+ notNull: true;
177
+ hasDefault: false;
178
+ isPrimaryKey: false;
179
+ isAutoincrement: false;
180
+ hasRuntimeDefault: false;
181
+ enumValues: [string, ...string[]];
182
+ baseColumn: never;
183
+ identity: undefined;
184
+ generated: undefined;
185
+ }, {}, {
186
+ length: number | undefined;
187
+ }>;
188
+ packageName: import("drizzle-orm/sqlite-core").SQLiteColumn<{
189
+ name: "package_name";
190
+ tableName: "build_package_usage";
191
+ dataType: "string";
192
+ columnType: "SQLiteText";
193
+ data: string;
194
+ driverParam: string;
195
+ notNull: true;
196
+ hasDefault: false;
197
+ isPrimaryKey: false;
198
+ isAutoincrement: false;
199
+ hasRuntimeDefault: false;
200
+ enumValues: [string, ...string[]];
201
+ baseColumn: never;
202
+ identity: undefined;
203
+ generated: undefined;
204
+ }, {}, {
205
+ length: number | undefined;
206
+ }>;
207
+ modulePath: import("drizzle-orm/sqlite-core").SQLiteColumn<{
208
+ name: "module_path";
209
+ tableName: "build_package_usage";
210
+ dataType: "string";
211
+ columnType: "SQLiteText";
212
+ data: string;
213
+ driverParam: string;
214
+ notNull: true;
215
+ hasDefault: false;
216
+ isPrimaryKey: false;
217
+ isAutoincrement: false;
218
+ hasRuntimeDefault: false;
219
+ enumValues: [string, ...string[]];
220
+ baseColumn: never;
221
+ identity: undefined;
222
+ generated: undefined;
223
+ }, {}, {
224
+ length: number | undefined;
225
+ }>;
226
+ version: import("drizzle-orm/sqlite-core").SQLiteColumn<{
227
+ name: "version";
228
+ tableName: "build_package_usage";
229
+ dataType: "string";
230
+ columnType: "SQLiteText";
231
+ data: string;
232
+ driverParam: string;
233
+ notNull: false;
234
+ hasDefault: false;
235
+ isPrimaryKey: false;
236
+ isAutoincrement: false;
237
+ hasRuntimeDefault: false;
238
+ enumValues: [string, ...string[]];
239
+ baseColumn: never;
240
+ identity: undefined;
241
+ generated: undefined;
242
+ }, {}, {
243
+ length: number | undefined;
244
+ }>;
245
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
246
+ name: "created_at";
247
+ tableName: "build_package_usage";
248
+ dataType: "string";
249
+ columnType: "SQLiteText";
250
+ data: string;
251
+ driverParam: string;
252
+ notNull: true;
253
+ hasDefault: false;
254
+ isPrimaryKey: false;
255
+ isAutoincrement: false;
256
+ hasRuntimeDefault: false;
257
+ enumValues: [string, ...string[]];
258
+ baseColumn: never;
259
+ identity: undefined;
260
+ generated: undefined;
261
+ }, {}, {
262
+ length: number | undefined;
263
+ }>;
264
+ };
265
+ dialect: 'sqlite';
266
+ }>;
267
+ /** A link from a downstream project to the upstream project that publishes a package it consumes. */
268
+ interface ProjectLink {
269
+ id: string;
270
+ /** Project that consumes the package (the app). */
271
+ downstreamId: string;
272
+ /** Project whose Storybook publishes the package's components (the design system). */
273
+ upstreamId: string;
274
+ packageName: string;
275
+ createdAt: string;
276
+ }
277
+ /** A dependency package a story file reaches in a build. */
278
+ interface BuildPackageUsage {
279
+ id: string;
280
+ projectId: string;
281
+ buildId: string;
282
+ /** Story import path, joined to `snapshots.storyImportPath` at read time. */
283
+ storyImportPath: string;
284
+ packageName: string;
285
+ /** First module inside the package the story reaches. */
286
+ modulePath: string;
287
+ /** Installed package version at upload time; null when it could not be resolved. */
288
+ version: string | null;
289
+ createdAt: string;
290
+ }
291
+ //#endregion
292
+ export { BuildPackageUsage, ProjectLink, buildPackageUsage, projectLinks };
293
+ //# sourceMappingURL=usage.d.mts.map
@@ -0,0 +1,30 @@
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, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
7
+ //#region src/schema/usage.ts
8
+ /** Narrow `project_links` table definition. */
9
+ const projectLinks = sqliteTable("project_links", {
10
+ id: text("id").primaryKey(),
11
+ downstreamId: text("downstream_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
12
+ upstreamId: text("upstream_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
13
+ packageName: text("package_name").notNull(),
14
+ createdAt: text("created_at").notNull()
15
+ }, (t) => [uniqueIndex("project_links_downstream_package_idx").on(t.downstreamId, t.packageName)]);
16
+ /** Narrow `build_package_usage` table definition. */
17
+ const buildPackageUsage = sqliteTable("build_package_usage", {
18
+ id: text("id").primaryKey(),
19
+ projectId: text("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
20
+ buildId: text("build_id").notNull().references(() => builds.id, { onDelete: "cascade" }),
21
+ storyImportPath: text("story_import_path").notNull(),
22
+ packageName: text("package_name").notNull(),
23
+ modulePath: text("module_path").notNull(),
24
+ version: text("version"),
25
+ createdAt: text("created_at").notNull()
26
+ }, (t) => [index("build_package_usage_build_id_idx").on(t.buildId)]);
27
+ //#endregion
28
+ export { buildPackageUsage, projectLinks };
29
+
30
+ //# sourceMappingURL=usage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.mjs","names":[],"sources":["../../src/schema/usage.ts"],"sourcesContent":["import { sqliteTable, text, uniqueIndex, index } from \"drizzle-orm/sqlite-core\";\nimport { builds } from \"./build.ts\";\nimport { projects } from \"./project.ts\";\n\n/** Narrow `project_links` table definition. */\nexport const projectLinks = sqliteTable(\n \"project_links\",\n {\n id: text(\"id\").primaryKey(),\n downstreamId: text(\"downstream_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n upstreamId: text(\"upstream_id\")\n .notNull()\n .references(() => projects.id, { onDelete: \"cascade\" }),\n packageName: text(\"package_name\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n },\n (t) => [uniqueIndex(\"project_links_downstream_package_idx\").on(t.downstreamId, t.packageName)],\n);\n\n/** Narrow `build_package_usage` table definition. */\nexport const buildPackageUsage = sqliteTable(\n \"build_package_usage\",\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 storyImportPath: text(\"story_import_path\").notNull(),\n packageName: text(\"package_name\").notNull(),\n modulePath: text(\"module_path\").notNull(),\n version: text(\"version\"),\n createdAt: text(\"created_at\").notNull(),\n },\n (t) => [index(\"build_package_usage_build_id_idx\").on(t.buildId)],\n);\n\n/** A link from a downstream project to the upstream project that publishes a package it consumes. */\nexport interface ProjectLink {\n id: string;\n /** Project that consumes the package (the app). */\n downstreamId: string;\n /** Project whose Storybook publishes the package's components (the design system). */\n upstreamId: string;\n packageName: string;\n createdAt: string;\n}\n\n/** A dependency package a story file reaches in a build. */\nexport interface BuildPackageUsage {\n id: string;\n projectId: string;\n buildId: string;\n /** Story import path, joined to `snapshots.storyImportPath` at read time. */\n storyImportPath: string;\n packageName: string;\n /** First module inside the package the story reaches. */\n modulePath: string;\n /** Installed package version at upload time; null when it could not be resolved. */\n version: string | null;\n createdAt: string;\n}\n"],"mappings":";;;;;;;;AAKA,MAAa,eAAe,YAC1B,iBACA;CACE,IAAI,KAAK,IAAI,CAAC,CAAC,WAAW;CAC1B,cAAc,KAAK,eAAe,CAAC,CAChC,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,YAAY,KAAK,aAAa,CAAC,CAC5B,QAAQ,CAAC,CACT,iBAAiB,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;CACxD,aAAa,KAAK,cAAc,CAAC,CAAC,QAAQ;CAC1C,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM,CAAC,YAAY,sCAAsC,CAAC,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,CAAC,CAC/F;;AAGA,MAAa,oBAAoB,YAC/B,uBACA;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,iBAAiB,KAAK,mBAAmB,CAAC,CAAC,QAAQ;CACnD,aAAa,KAAK,cAAc,CAAC,CAAC,QAAQ;CAC1C,YAAY,KAAK,aAAa,CAAC,CAAC,QAAQ;CACxC,SAAS,KAAK,SAAS;CACvB,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ;AACxC,IACC,MAAM,CAAC,MAAM,kCAAkC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CACjE"}
package/dist/schema.d.mts CHANGED
@@ -2,15 +2,23 @@ import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
3
  import { Build, builds } from "./schema/build.mjs";
4
4
  import { CaptureAttempt, CaptureLog, captureAttempts, captureLogs } from "./schema/capture-attempt.mjs";
5
+ import { captureJobs } from "./schema/capture-job.mjs";
6
+ import { buildComponents } from "./schema/build-component.mjs";
7
+ import { buildReviews } from "./schema/build-review.mjs";
8
+ import { siteSettings } from "./schema/site-setting.mjs";
9
+ import { captureShards } from "./schema/capture-shard.mjs";
5
10
  import { baselines } from "./schema/baseline.mjs";
6
11
  import { Comment, comments } from "./schema/comment.mjs";
7
12
  import { BuildLabel, LabelType, buildLabels, labelTypes } from "./schema/label.mjs";
8
13
  import { ProjectMember, projectMembers } from "./schema/member.mjs";
14
+ import { BuildPackageUsage, ProjectLink, buildPackageUsage, projectLinks } from "./schema/usage.mjs";
15
+ import { UserConnection, userConnections } from "./schema/connection.mjs";
16
+ import { DesignCredential, DesignLink, DesignNode, designCredentials, designLinks, designNodes } from "./schema/design.mjs";
17
+ import { AiBudgetAlert, AiUsage, Insight, aiBudgetAlerts, aiUsage, insights } from "./schema/insight.mjs";
9
18
  import { NotificationChannel, NotificationSubscription, notificationChannels, notificationSubscriptions } from "./schema/notification.mjs";
10
19
  import { ProjectGroupMapping, projectGroupMappings } from "./schema/project-group-mapping.mjs";
11
20
  import { Project, StorybookMeta, projects } from "./schema/project.mjs";
12
21
  import { Snapshot, snapshots } from "./schema/snapshot.mjs";
13
- import { ProjectStatusConfig, projectStatusConfigs } from "./schema/status-config.mjs";
14
22
  import { Token, tokens } from "./schema/token.mjs";
15
23
  import { User, users } from "./schema/user.mjs";
16
24
  import { UserInviteToken, userInviteTokens } from "./schema/user-invite.mjs";
@@ -21,17 +29,30 @@ import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
21
29
  /** Full Drizzle schema object passed to the database client. */
22
30
  declare const schema: {
23
31
  projects: AnySQLiteTable;
24
- projectStatusConfigs: AnySQLiteTable;
25
32
  builds: AnySQLiteTable;
26
33
  captureAttempts: AnySQLiteTable;
27
34
  captureLogs: AnySQLiteTable;
35
+ captureShards: AnySQLiteTable;
36
+ captureJobs: AnySQLiteTable;
37
+ buildComponents: AnySQLiteTable;
38
+ buildReviews: AnySQLiteTable;
39
+ siteSettings: AnySQLiteTable;
28
40
  snapshots: AnySQLiteTable;
29
41
  baselines: AnySQLiteTable;
30
42
  comments: AnySQLiteTable;
31
43
  labelTypes: AnySQLiteTable;
32
44
  buildLabels: AnySQLiteTable;
45
+ projectLinks: AnySQLiteTable;
46
+ designLinks: AnySQLiteTable;
47
+ designCredentials: AnySQLiteTable;
48
+ userConnections: AnySQLiteTable;
49
+ designNodes: AnySQLiteTable;
50
+ buildPackageUsage: AnySQLiteTable;
33
51
  tokens: AnySQLiteTable;
34
52
  webhooks: AnySQLiteTable;
53
+ insights: AnySQLiteTable;
54
+ aiUsage: AnySQLiteTable;
55
+ aiBudgetAlerts: AnySQLiteTable;
35
56
  notificationChannels: AnySQLiteTable;
36
57
  notificationSubscriptions: AnySQLiteTable;
37
58
  users: AnySQLiteTable;
@@ -43,5 +64,5 @@ declare const schema: {
43
64
  /** The full database schema type. */
44
65
  type Schema = typeof schema;
45
66
  //#endregion
46
- export { type Build, type BuildLabel, type CaptureAttempt, type CaptureLog, type Comment, type ContentRef, type LabelType, type NotificationChannel, type NotificationSubscription, type Project, type ProjectGroupMapping, type ProjectMember, type ProjectStatusConfig, Schema, type Snapshot, type StorybookMeta, type Token, type User, type UserInviteToken, type Webhook, baselines, buildLabels, builds, captureAttempts, captureLogs, comments, contentRefs, labelTypes, notificationChannels, notificationSubscriptions, projectGroupMappings, projectMembers, projectStatusConfigs, projects, schema, snapshots, tokens, userInviteTokens, users, webhooks };
67
+ export { type AiBudgetAlert, type AiUsage, type Build, type BuildLabel, type BuildPackageUsage, type CaptureAttempt, type CaptureLog, type Comment, type ContentRef, type DesignCredential, type DesignLink, type DesignNode, type Insight, type LabelType, type NotificationChannel, type NotificationSubscription, type Project, type ProjectGroupMapping, type ProjectLink, type ProjectMember, Schema, type Snapshot, type StorybookMeta, type Token, type User, type UserConnection, type UserInviteToken, type Webhook, aiBudgetAlerts, aiUsage, baselines, buildComponents, buildLabels, buildPackageUsage, buildReviews, builds, captureAttempts, captureJobs, captureLogs, captureShards, comments, contentRefs, designCredentials, designLinks, designNodes, insights, labelTypes, notificationChannels, notificationSubscriptions, projectGroupMappings, projectLinks, projectMembers, projects, schema, siteSettings, snapshots, tokens, userConnections, userInviteTokens, users, webhooks };
47
68
  //# sourceMappingURL=schema.d.mts.map
package/dist/schema.mjs CHANGED
@@ -4,34 +4,55 @@ import.meta.url;
4
4
  import { projects } from "./schema/project.mjs";
5
5
  import { baselines } from "./schema/baseline.mjs";
6
6
  import { builds } from "./schema/build.mjs";
7
+ import { buildComponents } from "./schema/build-component.mjs";
8
+ import { users } from "./schema/user.mjs";
9
+ import { buildReviews } from "./schema/build-review.mjs";
7
10
  import { captureAttempts, captureLogs } from "./schema/capture-attempt.mjs";
11
+ import { captureJobs } from "./schema/capture-job.mjs";
12
+ import { captureShards } from "./schema/capture-shard.mjs";
8
13
  import { snapshots } from "./schema/snapshot.mjs";
9
- import { users } from "./schema/user.mjs";
10
14
  import { comments } from "./schema/comment.mjs";
15
+ import { userConnections } from "./schema/connection.mjs";
11
16
  import { contentRefs } from "./schema/content-refs.mjs";
17
+ import { designCredentials, designLinks, designNodes } from "./schema/design.mjs";
18
+ import { aiBudgetAlerts, aiUsage, insights } from "./schema/insight.mjs";
12
19
  import { buildLabels, labelTypes } from "./schema/label.mjs";
13
20
  import { projectMembers } from "./schema/member.mjs";
14
21
  import { notificationChannels, notificationSubscriptions } from "./schema/notification.mjs";
15
22
  import { projectGroupMappings } from "./schema/project-group-mapping.mjs";
16
- import { projectStatusConfigs } from "./schema/status-config.mjs";
23
+ import { siteSettings } from "./schema/site-setting.mjs";
17
24
  import { tokens } from "./schema/token.mjs";
25
+ import { buildPackageUsage, projectLinks } from "./schema/usage.mjs";
18
26
  import { userInviteTokens } from "./schema/user-invite.mjs";
19
27
  import { webhooks } from "./schema/webhook.mjs";
20
28
  //#region src/schema/index.ts
21
29
  /** Full Drizzle schema object passed to the database client. */
22
30
  const schema = {
23
31
  projects,
24
- projectStatusConfigs,
25
32
  builds,
26
33
  captureAttempts,
27
34
  captureLogs,
35
+ captureShards,
36
+ captureJobs,
37
+ buildComponents,
38
+ buildReviews,
39
+ siteSettings,
28
40
  snapshots,
29
41
  baselines,
30
42
  comments,
31
43
  labelTypes,
32
44
  buildLabels,
45
+ projectLinks,
46
+ designLinks,
47
+ designCredentials,
48
+ userConnections,
49
+ designNodes,
50
+ buildPackageUsage,
33
51
  tokens,
34
52
  webhooks,
53
+ insights,
54
+ aiUsage,
55
+ aiBudgetAlerts,
35
56
  notificationChannels,
36
57
  notificationSubscriptions,
37
58
  users,
@@ -41,6 +62,6 @@ const schema = {
41
62
  contentRefs
42
63
  };
43
64
  //#endregion
44
- export { baselines, buildLabels, builds, captureAttempts, captureLogs, comments, contentRefs, labelTypes, notificationChannels, notificationSubscriptions, projectGroupMappings, projectMembers, projectStatusConfigs, projects, schema, snapshots, tokens, userInviteTokens, users, webhooks };
65
+ export { aiBudgetAlerts, aiUsage, baselines, buildComponents, buildLabels, buildPackageUsage, buildReviews, builds, captureAttempts, captureJobs, captureLogs, captureShards, comments, contentRefs, designCredentials, designLinks, designNodes, insights, labelTypes, notificationChannels, notificationSubscriptions, projectGroupMappings, projectLinks, projectMembers, projects, schema, siteSettings, snapshots, tokens, userConnections, userInviteTokens, users, webhooks };
45
66
 
46
67
  //# sourceMappingURL=schema.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","names":["projectsTable","projectStatusConfigsTable","buildsTable","captureAttemptsTable","captureLogsTable","snapshotsTable","baselinesTable","commentsTable","labelTypesTable","buildLabelsTable","tokensTable","webhooksTable","notificationChannelsTable","notificationSubscriptionsTable","usersTable","userInviteTokensTable","projectMembersTable","projectGroupMappingsTable","contentRefsTable"],"sources":["../src/schema/index.ts"],"sourcesContent":["/**\n * Database schema: table handles, row types, and the schema object passed\n * to the database client.\n *\n * Table handles are available on the `schema` object with full type\n * inference (`schema.builds`, …); exact column types live on the narrow\n * per-entity definitions, and the row interfaces are pinned to them by\n * `schema-types.test.ts`.\n */\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { baselines as baselinesTable } from \"./baseline.ts\";\nimport { builds as buildsTable } from \"./build.ts\";\nimport {\n captureAttempts as captureAttemptsTable,\n captureLogs as captureLogsTable,\n} from \"./capture-attempt.ts\";\nimport { comments as commentsTable } from \"./comment.ts\";\nimport { contentRefs as contentRefsTable } from \"./content-refs.ts\";\nimport { buildLabels as buildLabelsTable, labelTypes as labelTypesTable } from \"./label.ts\";\nimport { projectMembers as projectMembersTable } from \"./member.ts\";\nimport {\n notificationChannels as notificationChannelsTable,\n notificationSubscriptions as notificationSubscriptionsTable,\n} from \"./notification.ts\";\nimport { projectGroupMappings as projectGroupMappingsTable } from \"./project-group-mapping.ts\";\nimport { projects as projectsTable } from \"./project.ts\";\nimport { snapshots as snapshotsTable } from \"./snapshot.ts\";\nimport { projectStatusConfigs as projectStatusConfigsTable } from \"./status-config.ts\";\nimport { tokens as tokensTable } from \"./token.ts\";\nimport { userInviteTokens as userInviteTokensTable } from \"./user-invite.ts\";\nimport { users as usersTable } from \"./user.ts\";\nimport { webhooks as webhooksTable } from \"./webhook.ts\";\n\nexport { builds } from \"./build.ts\";\nexport { captureAttempts, captureLogs } from \"./capture-attempt.ts\";\nexport { baselines } from \"./baseline.ts\";\nexport { comments } from \"./comment.ts\";\nexport { buildLabels, labelTypes } from \"./label.ts\";\nexport { projectMembers } from \"./member.ts\";\nexport { notificationChannels, notificationSubscriptions } from \"./notification.ts\";\nexport { projectGroupMappings } from \"./project-group-mapping.ts\";\nexport { projects } from \"./project.ts\";\nexport { snapshots } from \"./snapshot.ts\";\nexport { projectStatusConfigs } from \"./status-config.ts\";\nexport { tokens } from \"./token.ts\";\nexport { users } from \"./user.ts\";\nexport { userInviteTokens } from \"./user-invite.ts\";\nexport { webhooks } from \"./webhook.ts\";\nexport { contentRefs } from \"./content-refs.ts\";\n\n/** A capture attempt and its log lines for a single build run. */\nexport type { CaptureAttempt, CaptureLog } from \"./capture-attempt.ts\";\n/** Build row as stored in the `builds` table. */\nexport type { Build } from \"./build.ts\";\n/** Review comment row as stored in the `comments` table. */\nexport type { Comment } from \"./comment.ts\";\n/** Build label and label type rows. */\nexport type { BuildLabel, LabelType } from \"./label.ts\";\n/** Project membership row linking a user to a project role. */\nexport type { ProjectMember } from \"./member.ts\";\n/** Identity-provider group to project-role mapping row. */\nexport type { ProjectGroupMapping } from \"./project-group-mapping.ts\";\n/** Project row and its embedded Storybook metadata. */\nexport type { Project, StorybookMeta } from \"./project.ts\";\n/** Per-project git provider status-check configuration row. */\nexport type { ProjectStatusConfig } from \"./status-config.ts\";\n/** Snapshot row capturing a single story at one viewport. */\nexport type { Snapshot } from \"./snapshot.ts\";\n/** CI token row (stores only the hash). */\nexport type { Token } from \"./token.ts\";\n/** User row for authenticated identities. */\nexport type { User } from \"./user.ts\";\n/** One-time invite token for local accounts. */\nexport type { UserInviteToken } from \"./user-invite.ts\";\n/** Webhook subscription row. */\nexport type { Webhook } from \"./webhook.ts\";\n/** Notification channel and subscription rows. */\nexport type { NotificationChannel, NotificationSubscription } from \"./notification.ts\";\n/** Content ref row for deduplicated assets. */\nexport type { ContentRef } from \"./content-refs.ts\";\n\n/** Full Drizzle schema object passed to the database client. */\nexport const schema: {\n projects: AnySQLiteTable;\n projectStatusConfigs: AnySQLiteTable;\n builds: AnySQLiteTable;\n captureAttempts: AnySQLiteTable;\n captureLogs: AnySQLiteTable;\n snapshots: AnySQLiteTable;\n baselines: AnySQLiteTable;\n comments: AnySQLiteTable;\n labelTypes: AnySQLiteTable;\n buildLabels: AnySQLiteTable;\n tokens: AnySQLiteTable;\n webhooks: AnySQLiteTable;\n notificationChannels: AnySQLiteTable;\n notificationSubscriptions: AnySQLiteTable;\n users: AnySQLiteTable;\n userInviteTokens: AnySQLiteTable;\n projectMembers: AnySQLiteTable;\n projectGroupMappings: AnySQLiteTable;\n contentRefs: AnySQLiteTable;\n} = {\n projects: projectsTable,\n projectStatusConfigs: projectStatusConfigsTable,\n builds: buildsTable,\n captureAttempts: captureAttemptsTable,\n captureLogs: captureLogsTable,\n snapshots: snapshotsTable,\n baselines: baselinesTable,\n comments: commentsTable,\n labelTypes: labelTypesTable,\n buildLabels: buildLabelsTable,\n tokens: tokensTable,\n webhooks: webhooksTable,\n notificationChannels: notificationChannelsTable,\n notificationSubscriptions: notificationSubscriptionsTable,\n users: usersTable,\n userInviteTokens: userInviteTokensTable,\n projectMembers: projectMembersTable,\n projectGroupMappings: projectGroupMappingsTable,\n contentRefs: contentRefsTable,\n};\n\n/** The full database schema type. */\nexport type Schema = typeof schema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkFA,MAAa,SAoBT;CACQA;CACYC;CACdC;CACSC;CACJC;CACFC;CACAC;CACDC;CACEC;CACCC;CACLC;CACEC;CACYC;CACKC;CACpBC;CACWC;CACFC;CACMC;CACTC;AACf"}
1
+ {"version":3,"file":"schema.mjs","names":["projectsTable","buildsTable","captureAttemptsTable","captureLogsTable","captureShardsTable","captureJobsTable","buildComponentsTable","buildReviewsTable","siteSettingsTable","snapshotsTable","baselinesTable","commentsTable","labelTypesTable","buildLabelsTable","projectLinksTable","designLinksTable","designCredentialsTable","userConnectionsTable","designNodesTable","buildPackageUsageTable","tokensTable","webhooksTable","insightsTable","aiUsageTable","aiBudgetAlertsTable","notificationChannelsTable","notificationSubscriptionsTable","usersTable","userInviteTokensTable","projectMembersTable","projectGroupMappingsTable","contentRefsTable"],"sources":["../src/schema/index.ts"],"sourcesContent":["/**\n * Database schema: table handles, row types, and the schema object passed\n * to the database client.\n *\n * Table handles are available on the `schema` object with full type\n * inference (`schema.builds`, …); exact column types live on the narrow\n * per-entity definitions, and the row interfaces are pinned to them by\n * `schema-types.test.ts`.\n */\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { baselines as baselinesTable } from \"./baseline.ts\";\nimport { buildComponents as buildComponentsTable } from \"./build-component.ts\";\nimport { buildReviews as buildReviewsTable } from \"./build-review.ts\";\nimport { builds as buildsTable } from \"./build.ts\";\nimport {\n captureAttempts as captureAttemptsTable,\n captureLogs as captureLogsTable,\n} from \"./capture-attempt.ts\";\nimport { captureJobs as captureJobsTable } from \"./capture-job.ts\";\nimport { captureShards as captureShardsTable } from \"./capture-shard.ts\";\nimport { comments as commentsTable } from \"./comment.ts\";\nimport { userConnections as userConnectionsTable } from \"./connection.ts\";\nimport { contentRefs as contentRefsTable } from \"./content-refs.ts\";\nimport {\n designLinks as designLinksTable,\n designCredentials as designCredentialsTable,\n designNodes as designNodesTable,\n} from \"./design.ts\";\nimport {\n aiBudgetAlerts as aiBudgetAlertsTable,\n aiUsage as aiUsageTable,\n insights as insightsTable,\n} from \"./insight.ts\";\nimport { buildLabels as buildLabelsTable, labelTypes as labelTypesTable } from \"./label.ts\";\nimport { projectMembers as projectMembersTable } from \"./member.ts\";\nimport {\n notificationChannels as notificationChannelsTable,\n notificationSubscriptions as notificationSubscriptionsTable,\n} from \"./notification.ts\";\nimport { projectGroupMappings as projectGroupMappingsTable } from \"./project-group-mapping.ts\";\nimport { projects as projectsTable } from \"./project.ts\";\nimport { siteSettings as siteSettingsTable } from \"./site-setting.ts\";\nimport { snapshots as snapshotsTable } from \"./snapshot.ts\";\nimport { tokens as tokensTable } from \"./token.ts\";\nimport {\n buildPackageUsage as buildPackageUsageTable,\n projectLinks as projectLinksTable,\n} from \"./usage.ts\";\nimport { userInviteTokens as userInviteTokensTable } from \"./user-invite.ts\";\nimport { users as usersTable } from \"./user.ts\";\nimport { webhooks as webhooksTable } from \"./webhook.ts\";\n\nexport { builds } from \"./build.ts\";\nexport { captureAttempts, captureLogs } from \"./capture-attempt.ts\";\nexport { captureJobs } from \"./capture-job.ts\";\nexport { buildComponents } from \"./build-component.ts\";\nexport { buildReviews } from \"./build-review.ts\";\nexport { siteSettings } from \"./site-setting.ts\";\nexport { captureShards } from \"./capture-shard.ts\";\nexport { baselines } from \"./baseline.ts\";\nexport { comments } from \"./comment.ts\";\nexport { buildLabels, labelTypes } from \"./label.ts\";\nexport { projectMembers } from \"./member.ts\";\nexport { buildPackageUsage, projectLinks } from \"./usage.ts\";\nexport { userConnections } from \"./connection.ts\";\nexport { designCredentials, designLinks, designNodes } from \"./design.ts\";\nexport { aiBudgetAlerts, aiUsage, insights } from \"./insight.ts\";\nexport { notificationChannels, notificationSubscriptions } from \"./notification.ts\";\nexport { projectGroupMappings } from \"./project-group-mapping.ts\";\nexport { projects } from \"./project.ts\";\nexport { snapshots } from \"./snapshot.ts\";\nexport { tokens } from \"./token.ts\";\nexport { users } from \"./user.ts\";\nexport { userInviteTokens } from \"./user-invite.ts\";\nexport { webhooks } from \"./webhook.ts\";\nexport { contentRefs } from \"./content-refs.ts\";\n\n/** A capture attempt and its log lines for a single build run. */\nexport type { CaptureAttempt, CaptureLog } from \"./capture-attempt.ts\";\n/** Build row as stored in the `builds` table. */\nexport type { Build } from \"./build.ts\";\n/** Review comment row as stored in the `comments` table. */\nexport type { Comment } from \"./comment.ts\";\n/** Build label and label type rows. */\nexport type { BuildLabel, LabelType } from \"./label.ts\";\n/** A user's OAuth connection to an external service. */\nexport type { UserConnection } from \"./connection.ts\";\n/** Design link, provider credential and cached design node rows. */\nexport type { DesignCredential, DesignLink, DesignNode } from \"./design.ts\";\n/** Project link and per-build package usage rows. */\nexport type { BuildPackageUsage, ProjectLink } from \"./usage.ts\";\n/** Project membership row linking a user to a project role. */\nexport type { ProjectMember } from \"./member.ts\";\n/** Identity-provider group to project-role mapping row. */\nexport type { ProjectGroupMapping } from \"./project-group-mapping.ts\";\n/** Project row and its embedded Storybook metadata. */\nexport type { Project, StorybookMeta } from \"./project.ts\";\n/** Per-project git provider status-check configuration row. */\n/** Snapshot row capturing a single story at one viewport. */\nexport type { Snapshot } from \"./snapshot.ts\";\n/** CI token row (stores only the hash). */\nexport type { Token } from \"./token.ts\";\n/** User row for authenticated identities. */\nexport type { User } from \"./user.ts\";\n/** One-time invite token for local accounts. */\nexport type { UserInviteToken } from \"./user-invite.ts\";\n/** Webhook subscription row. */\nexport type { Webhook } from \"./webhook.ts\";\n/** Insight, AI usage and budget-alert rows. */\nexport type { AiBudgetAlert, AiUsage, Insight } from \"./insight.ts\";\n/** Notification channel and subscription rows. */\nexport type { NotificationChannel, NotificationSubscription } from \"./notification.ts\";\n/** Content ref row for deduplicated assets. */\nexport type { ContentRef } from \"./content-refs.ts\";\n\n/** Full Drizzle schema object passed to the database client. */\nexport const schema: {\n projects: AnySQLiteTable;\n builds: AnySQLiteTable;\n captureAttempts: AnySQLiteTable;\n captureLogs: AnySQLiteTable;\n captureShards: AnySQLiteTable;\n captureJobs: AnySQLiteTable;\n buildComponents: AnySQLiteTable;\n buildReviews: AnySQLiteTable;\n siteSettings: AnySQLiteTable;\n snapshots: AnySQLiteTable;\n baselines: AnySQLiteTable;\n comments: AnySQLiteTable;\n labelTypes: AnySQLiteTable;\n buildLabels: AnySQLiteTable;\n projectLinks: AnySQLiteTable;\n designLinks: AnySQLiteTable;\n designCredentials: AnySQLiteTable;\n userConnections: AnySQLiteTable;\n designNodes: AnySQLiteTable;\n buildPackageUsage: AnySQLiteTable;\n tokens: AnySQLiteTable;\n webhooks: AnySQLiteTable;\n insights: AnySQLiteTable;\n aiUsage: AnySQLiteTable;\n aiBudgetAlerts: AnySQLiteTable;\n notificationChannels: AnySQLiteTable;\n notificationSubscriptions: AnySQLiteTable;\n users: AnySQLiteTable;\n userInviteTokens: AnySQLiteTable;\n projectMembers: AnySQLiteTable;\n projectGroupMappings: AnySQLiteTable;\n contentRefs: AnySQLiteTable;\n} = {\n projects: projectsTable,\n builds: buildsTable,\n captureAttempts: captureAttemptsTable,\n captureLogs: captureLogsTable,\n captureShards: captureShardsTable,\n captureJobs: captureJobsTable,\n buildComponents: buildComponentsTable,\n buildReviews: buildReviewsTable,\n siteSettings: siteSettingsTable,\n snapshots: snapshotsTable,\n baselines: baselinesTable,\n comments: commentsTable,\n labelTypes: labelTypesTable,\n buildLabels: buildLabelsTable,\n projectLinks: projectLinksTable,\n designLinks: designLinksTable,\n designCredentials: designCredentialsTable,\n userConnections: userConnectionsTable,\n designNodes: designNodesTable,\n buildPackageUsage: buildPackageUsageTable,\n tokens: tokensTable,\n webhooks: webhooksTable,\n insights: insightsTable,\n aiUsage: aiUsageTable,\n aiBudgetAlerts: aiBudgetAlertsTable,\n notificationChannels: notificationChannelsTable,\n notificationSubscriptions: notificationSubscriptionsTable,\n users: usersTable,\n userInviteTokens: userInviteTokensTable,\n projectMembers: projectMembersTable,\n projectGroupMappings: projectGroupMappingsTable,\n contentRefs: contentRefsTable,\n};\n\n/** The full database schema type. */\nexport type Schema = typeof schema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,SAiCT;CACQA;CACFC;CACSC;CACJC;CACEC;CACFC;CACIC;CACHC;CACAC;CACHC;CACAC;CACDC;CACEC;CACCC;CACCC;CACDC;CACMC;CACFC;CACJC;CACMC;CACXC;CACEC;CACAC;CACDC;CACOC;CACMC;CACKC;CACpBC;CACWC;CACFC;CACMC;CACTC;AACf"}
package/dist/turso.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
- import { createClient } from "@libsql/client";
4
3
  import { DatabaseAdapter } from "@storyshelf/core/adapter/database";
4
+ import { Client } from "@libsql/client";
5
5
  //#region src/turso.d.ts
6
- type LibsqlClient = ReturnType<typeof createClient>;
6
+ type LibsqlClient = Client;
7
7
  /**
8
8
  * Options for creating a Turso-backed DatabaseAdapter.
9
9
  *
package/dist/turso.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import "node:path";
2
2
  import "node:url";
3
3
  import.meta.url;
4
- import { DDL, tableColumns } from "./ddl.mjs";
4
+ import { DDL, IDENTITY_STATEMENTS, tableColumns } from "./ddl.mjs";
5
5
  import { createDrizzleAdapter } from "./drizzle-factory.mjs";
6
6
  import { schema } from "./schema.mjs";
7
- import { createClient } from "@libsql/client";
8
- import { drizzle } from "drizzle-orm/libsql";
7
+ import { createRequire } from "node:module";
8
+ import * as drizzleLibsqlCore from "drizzle-orm/libsql/driver-core";
9
9
  //#region src/turso.ts
10
10
  /**
11
11
  * Turso/libSQL preset for the SQLite database adapter.
@@ -15,6 +15,7 @@ import { drizzle } from "drizzle-orm/libsql";
15
15
  * `wss://`, or embedded replica via `syncUrl`). Requires the optional
16
16
  * `@libsql/client` peer (`nub add @libsql/client`).
17
17
  */
18
+ const construct = drizzleLibsqlCore.construct;
18
19
  /**
19
20
  * Create a Turso/libSQL-backed DatabaseAdapter using Drizzle ORM.
20
21
  *
@@ -24,11 +25,11 @@ import { drizzle } from "drizzle-orm/libsql";
24
25
  */
25
26
  function createTursoDatabase(options) {
26
27
  const { client, owned } = resolveClient(options);
27
- const db = drizzle(client, { schema });
28
+ const db = construct(client, { schema });
28
29
  return createDrizzleAdapter(db, {
29
30
  metadata: {
30
31
  name: "Turso",
31
- version: globalThis.__PKG_VERSION__ ?? "0.0.0",
32
+ version: "0.7.0",
32
33
  description: "Turso/libSQL database adapter",
33
34
  kind: "turso",
34
35
  category: "database"
@@ -59,7 +60,7 @@ function resolveClient(options) {
59
60
  if (!url) throw new Error("createTursoDatabase: provide `url` (or `syncUrl` with a `file:` url) or a preconfigured `client`");
60
61
  if (!isSupportedUrl(url)) throw new Error(`createTursoDatabase: unsupported url "${url}" (expected libsql://, https://, wss://, file:, or :memory:)`);
61
62
  return {
62
- client: createClient({
63
+ client: createNodeClient({
63
64
  url,
64
65
  authToken: options.authToken,
65
66
  syncUrl: options.syncUrl,
@@ -68,10 +69,22 @@ function resolveClient(options) {
68
69
  owned: true
69
70
  };
70
71
  }
72
+ /**
73
+ * Load the default Node client only when a URL is used. Importing
74
+ * `@libsql/client` at module load pulls in its native addon, which makes a
75
+ * process that only injects a `sqlite3` client (tests, embedded replicas)
76
+ * crash on teardown under some Node versions.
77
+ */
78
+ let nodeCreateClient;
79
+ function createNodeClient(config) {
80
+ nodeCreateClient ??= createRequire(import.meta.url)("@libsql/client").createClient;
81
+ return nodeCreateClient(config);
82
+ }
71
83
  const WEBHOOK_SECRET_DROP = "ALTER TABLE webhooks DROP COLUMN secret";
72
84
  async function runMigrations(client) {
73
85
  await client.executeMultiple(DDL);
74
86
  await ensureColumns(client, DDL);
87
+ for (const statement of IDENTITY_STATEMENTS) await execIgnore(client, statement);
75
88
  await execIgnore(client, WEBHOOK_SECRET_DROP);
76
89
  await migrateCommentsTable(client);
77
90
  }