@verdict-ai/db 0.0.0-stage → 0.1.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 (47) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +21 -2
  3. package/dist/auth.d.ts +34 -0
  4. package/dist/auth.js +80 -0
  5. package/dist/auth.js.map +1 -0
  6. package/dist/d1.d.ts +1034 -0
  7. package/dist/d1.js +21 -0
  8. package/dist/d1.js.map +1 -0
  9. package/dist/dialects.d.ts +14 -0
  10. package/dist/dialects.js +66 -0
  11. package/dist/dialects.js.map +1 -0
  12. package/dist/documents.d.ts +87 -0
  13. package/dist/documents.js +45 -0
  14. package/dist/documents.js.map +1 -0
  15. package/dist/errors.d.ts +7 -0
  16. package/dist/errors.js +21 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/index.d.ts +9 -0
  19. package/dist/index.js +12 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/postgres.d.ts +1925 -0
  22. package/dist/postgres.js +63 -0
  23. package/dist/postgres.js.map +1 -0
  24. package/dist/queries.d.ts +31 -0
  25. package/dist/queries.js +68 -0
  26. package/dist/queries.js.map +1 -0
  27. package/dist/schema/pg.d.ts +1892 -0
  28. package/dist/schema/pg.js +90 -0
  29. package/dist/schema/pg.js.map +1 -0
  30. package/dist/schema/sqlite.d.ts +2050 -0
  31. package/dist/schema/sqlite.js +90 -0
  32. package/dist/schema/sqlite.js.map +1 -0
  33. package/dist/sqlite.d.ts +25 -0
  34. package/dist/sqlite.js +64 -0
  35. package/dist/sqlite.js.map +1 -0
  36. package/dist/store.d.ts +47 -0
  37. package/dist/store.js +149 -0
  38. package/dist/store.js.map +1 -0
  39. package/drizzle/0000_init.sql +66 -0
  40. package/drizzle/0001_idempotency.sql +12 -0
  41. package/drizzle/meta/0000_snapshot.json +452 -0
  42. package/drizzle/meta/0001_snapshot.json +527 -0
  43. package/drizzle/meta/_journal.json +20 -0
  44. package/drizzle/pg/0000_init.sql +78 -0
  45. package/drizzle/pg/meta/0000_snapshot.json +605 -0
  46. package/drizzle/pg/meta/_journal.json +13 -0
  47. package/package.json +81 -3
@@ -0,0 +1,527 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "b973008b-216b-42d8-88dd-ff7d6c876e93",
5
+ "prevId": "94b3e522-db6f-42ac-943a-ebacf304d669",
6
+ "tables": {
7
+ "api_keys": {
8
+ "name": "api_keys",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "tenant_id": {
18
+ "name": "tenant_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "name": {
25
+ "name": "name",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "key_hash": {
32
+ "name": "key_hash",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "prefix": {
39
+ "name": "prefix",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": true,
43
+ "autoincrement": false
44
+ },
45
+ "created_at": {
46
+ "name": "created_at",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": true,
50
+ "autoincrement": false
51
+ },
52
+ "last_used_at": {
53
+ "name": "last_used_at",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": false,
57
+ "autoincrement": false
58
+ },
59
+ "revoked_at": {
60
+ "name": "revoked_at",
61
+ "type": "text",
62
+ "primaryKey": false,
63
+ "notNull": false,
64
+ "autoincrement": false
65
+ }
66
+ },
67
+ "indexes": {
68
+ "api_keys_hash": {
69
+ "name": "api_keys_hash",
70
+ "columns": [
71
+ "key_hash"
72
+ ],
73
+ "isUnique": true
74
+ },
75
+ "api_keys_tenant": {
76
+ "name": "api_keys_tenant",
77
+ "columns": [
78
+ "tenant_id"
79
+ ],
80
+ "isUnique": false
81
+ }
82
+ },
83
+ "foreignKeys": {},
84
+ "compositePrimaryKeys": {},
85
+ "uniqueConstraints": {},
86
+ "checkConstraints": {}
87
+ },
88
+ "evaluations": {
89
+ "name": "evaluations",
90
+ "columns": {
91
+ "id": {
92
+ "name": "id",
93
+ "type": "text",
94
+ "primaryKey": true,
95
+ "notNull": true,
96
+ "autoincrement": false
97
+ },
98
+ "tenant_id": {
99
+ "name": "tenant_id",
100
+ "type": "text",
101
+ "primaryKey": false,
102
+ "notNull": false,
103
+ "autoincrement": false
104
+ },
105
+ "rubric_id": {
106
+ "name": "rubric_id",
107
+ "type": "text",
108
+ "primaryKey": false,
109
+ "notNull": false,
110
+ "autoincrement": false
111
+ },
112
+ "rubric_name": {
113
+ "name": "rubric_name",
114
+ "type": "text",
115
+ "primaryKey": false,
116
+ "notNull": true,
117
+ "autoincrement": false
118
+ },
119
+ "subject_name": {
120
+ "name": "subject_name",
121
+ "type": "text",
122
+ "primaryKey": false,
123
+ "notNull": false,
124
+ "autoincrement": false
125
+ },
126
+ "status": {
127
+ "name": "status",
128
+ "type": "text",
129
+ "primaryKey": false,
130
+ "notNull": true,
131
+ "autoincrement": false
132
+ },
133
+ "score": {
134
+ "name": "score",
135
+ "type": "real",
136
+ "primaryKey": false,
137
+ "notNull": false,
138
+ "autoincrement": false
139
+ },
140
+ "grade": {
141
+ "name": "grade",
142
+ "type": "text",
143
+ "primaryKey": false,
144
+ "notNull": false,
145
+ "autoincrement": false
146
+ },
147
+ "passed": {
148
+ "name": "passed",
149
+ "type": "integer",
150
+ "primaryKey": false,
151
+ "notNull": false,
152
+ "autoincrement": false
153
+ },
154
+ "pending_human": {
155
+ "name": "pending_human",
156
+ "type": "integer",
157
+ "primaryKey": false,
158
+ "notNull": true,
159
+ "autoincrement": false,
160
+ "default": 0
161
+ },
162
+ "decision_calls": {
163
+ "name": "decision_calls",
164
+ "type": "integer",
165
+ "primaryKey": false,
166
+ "notNull": true,
167
+ "autoincrement": false,
168
+ "default": 0
169
+ },
170
+ "llm_calls": {
171
+ "name": "llm_calls",
172
+ "type": "integer",
173
+ "primaryKey": false,
174
+ "notNull": true,
175
+ "autoincrement": false,
176
+ "default": 0
177
+ },
178
+ "input_tokens": {
179
+ "name": "input_tokens",
180
+ "type": "integer",
181
+ "primaryKey": false,
182
+ "notNull": true,
183
+ "autoincrement": false,
184
+ "default": 0
185
+ },
186
+ "duration_ms": {
187
+ "name": "duration_ms",
188
+ "type": "integer",
189
+ "primaryKey": false,
190
+ "notNull": true,
191
+ "autoincrement": false,
192
+ "default": 0
193
+ },
194
+ "doc": {
195
+ "name": "doc",
196
+ "type": "text",
197
+ "primaryKey": false,
198
+ "notNull": true,
199
+ "autoincrement": false
200
+ },
201
+ "created_at": {
202
+ "name": "created_at",
203
+ "type": "text",
204
+ "primaryKey": false,
205
+ "notNull": true,
206
+ "autoincrement": false
207
+ },
208
+ "updated_at": {
209
+ "name": "updated_at",
210
+ "type": "text",
211
+ "primaryKey": false,
212
+ "notNull": true,
213
+ "autoincrement": false
214
+ }
215
+ },
216
+ "indexes": {
217
+ "evaluations_tenant_created": {
218
+ "name": "evaluations_tenant_created",
219
+ "columns": [
220
+ "tenant_id",
221
+ "created_at"
222
+ ],
223
+ "isUnique": false
224
+ },
225
+ "evaluations_rubric_created": {
226
+ "name": "evaluations_rubric_created",
227
+ "columns": [
228
+ "rubric_id",
229
+ "created_at"
230
+ ],
231
+ "isUnique": false
232
+ },
233
+ "evaluations_tenant_status": {
234
+ "name": "evaluations_tenant_status",
235
+ "columns": [
236
+ "tenant_id",
237
+ "status"
238
+ ],
239
+ "isUnique": false
240
+ }
241
+ },
242
+ "foreignKeys": {},
243
+ "compositePrimaryKeys": {},
244
+ "uniqueConstraints": {},
245
+ "checkConstraints": {}
246
+ },
247
+ "idempotency_keys": {
248
+ "name": "idempotency_keys",
249
+ "columns": {
250
+ "tenant_id": {
251
+ "name": "tenant_id",
252
+ "type": "text",
253
+ "primaryKey": false,
254
+ "notNull": false,
255
+ "autoincrement": false
256
+ },
257
+ "key": {
258
+ "name": "key",
259
+ "type": "text",
260
+ "primaryKey": false,
261
+ "notNull": true,
262
+ "autoincrement": false
263
+ },
264
+ "fingerprint": {
265
+ "name": "fingerprint",
266
+ "type": "text",
267
+ "primaryKey": false,
268
+ "notNull": true,
269
+ "autoincrement": false
270
+ },
271
+ "target_type": {
272
+ "name": "target_type",
273
+ "type": "text",
274
+ "primaryKey": false,
275
+ "notNull": true,
276
+ "autoincrement": false
277
+ },
278
+ "target_id": {
279
+ "name": "target_id",
280
+ "type": "text",
281
+ "primaryKey": false,
282
+ "notNull": false,
283
+ "autoincrement": false
284
+ },
285
+ "target_ids": {
286
+ "name": "target_ids",
287
+ "type": "text",
288
+ "primaryKey": false,
289
+ "notNull": false,
290
+ "autoincrement": false
291
+ },
292
+ "created_at": {
293
+ "name": "created_at",
294
+ "type": "text",
295
+ "primaryKey": false,
296
+ "notNull": true,
297
+ "autoincrement": false
298
+ },
299
+ "expires_at": {
300
+ "name": "expires_at",
301
+ "type": "text",
302
+ "primaryKey": false,
303
+ "notNull": true,
304
+ "autoincrement": false
305
+ }
306
+ },
307
+ "indexes": {
308
+ "idempotency_keys_tenant_key": {
309
+ "name": "idempotency_keys_tenant_key",
310
+ "columns": [
311
+ "tenant_id",
312
+ "key"
313
+ ],
314
+ "isUnique": true
315
+ }
316
+ },
317
+ "foreignKeys": {},
318
+ "compositePrimaryKeys": {},
319
+ "uniqueConstraints": {},
320
+ "checkConstraints": {}
321
+ },
322
+ "ratings": {
323
+ "name": "ratings",
324
+ "columns": {
325
+ "id": {
326
+ "name": "id",
327
+ "type": "text",
328
+ "primaryKey": true,
329
+ "notNull": true,
330
+ "autoincrement": false
331
+ },
332
+ "evaluation_id": {
333
+ "name": "evaluation_id",
334
+ "type": "text",
335
+ "primaryKey": false,
336
+ "notNull": true,
337
+ "autoincrement": false
338
+ },
339
+ "tenant_id": {
340
+ "name": "tenant_id",
341
+ "type": "text",
342
+ "primaryKey": false,
343
+ "notNull": false,
344
+ "autoincrement": false
345
+ },
346
+ "rubric_id": {
347
+ "name": "rubric_id",
348
+ "type": "text",
349
+ "primaryKey": false,
350
+ "notNull": false,
351
+ "autoincrement": false
352
+ },
353
+ "criterion_id": {
354
+ "name": "criterion_id",
355
+ "type": "text",
356
+ "primaryKey": false,
357
+ "notNull": true,
358
+ "autoincrement": false
359
+ },
360
+ "rater_id": {
361
+ "name": "rater_id",
362
+ "type": "text",
363
+ "primaryKey": false,
364
+ "notNull": true,
365
+ "autoincrement": false
366
+ },
367
+ "judge_type": {
368
+ "name": "judge_type",
369
+ "type": "text",
370
+ "primaryKey": false,
371
+ "notNull": true,
372
+ "autoincrement": false
373
+ },
374
+ "status": {
375
+ "name": "status",
376
+ "type": "text",
377
+ "primaryKey": false,
378
+ "notNull": true,
379
+ "autoincrement": false
380
+ },
381
+ "score": {
382
+ "name": "score",
383
+ "type": "real",
384
+ "primaryKey": false,
385
+ "notNull": false,
386
+ "autoincrement": false
387
+ },
388
+ "normalized": {
389
+ "name": "normalized",
390
+ "type": "real",
391
+ "primaryKey": false,
392
+ "notNull": false,
393
+ "autoincrement": false
394
+ },
395
+ "confidence": {
396
+ "name": "confidence",
397
+ "type": "real",
398
+ "primaryKey": false,
399
+ "notNull": false,
400
+ "autoincrement": false
401
+ },
402
+ "model": {
403
+ "name": "model",
404
+ "type": "text",
405
+ "primaryKey": false,
406
+ "notNull": false,
407
+ "autoincrement": false
408
+ },
409
+ "created_at": {
410
+ "name": "created_at",
411
+ "type": "text",
412
+ "primaryKey": false,
413
+ "notNull": true,
414
+ "autoincrement": false
415
+ }
416
+ },
417
+ "indexes": {
418
+ "ratings_evaluation": {
419
+ "name": "ratings_evaluation",
420
+ "columns": [
421
+ "evaluation_id"
422
+ ],
423
+ "isUnique": false
424
+ },
425
+ "ratings_rubric_criterion": {
426
+ "name": "ratings_rubric_criterion",
427
+ "columns": [
428
+ "rubric_id",
429
+ "criterion_id"
430
+ ],
431
+ "isUnique": false
432
+ },
433
+ "ratings_tenant_judge": {
434
+ "name": "ratings_tenant_judge",
435
+ "columns": [
436
+ "tenant_id",
437
+ "judge_type"
438
+ ],
439
+ "isUnique": false
440
+ }
441
+ },
442
+ "foreignKeys": {},
443
+ "compositePrimaryKeys": {},
444
+ "uniqueConstraints": {},
445
+ "checkConstraints": {}
446
+ },
447
+ "rubrics": {
448
+ "name": "rubrics",
449
+ "columns": {
450
+ "id": {
451
+ "name": "id",
452
+ "type": "text",
453
+ "primaryKey": true,
454
+ "notNull": true,
455
+ "autoincrement": false
456
+ },
457
+ "tenant_id": {
458
+ "name": "tenant_id",
459
+ "type": "text",
460
+ "primaryKey": false,
461
+ "notNull": false,
462
+ "autoincrement": false
463
+ },
464
+ "name": {
465
+ "name": "name",
466
+ "type": "text",
467
+ "primaryKey": false,
468
+ "notNull": true,
469
+ "autoincrement": false
470
+ },
471
+ "version": {
472
+ "name": "version",
473
+ "type": "text",
474
+ "primaryKey": false,
475
+ "notNull": true,
476
+ "autoincrement": false,
477
+ "default": "'1'"
478
+ },
479
+ "doc": {
480
+ "name": "doc",
481
+ "type": "text",
482
+ "primaryKey": false,
483
+ "notNull": true,
484
+ "autoincrement": false
485
+ },
486
+ "created_at": {
487
+ "name": "created_at",
488
+ "type": "text",
489
+ "primaryKey": false,
490
+ "notNull": true,
491
+ "autoincrement": false
492
+ },
493
+ "updated_at": {
494
+ "name": "updated_at",
495
+ "type": "text",
496
+ "primaryKey": false,
497
+ "notNull": true,
498
+ "autoincrement": false
499
+ }
500
+ },
501
+ "indexes": {
502
+ "rubrics_tenant_created": {
503
+ "name": "rubrics_tenant_created",
504
+ "columns": [
505
+ "tenant_id",
506
+ "created_at"
507
+ ],
508
+ "isUnique": false
509
+ }
510
+ },
511
+ "foreignKeys": {},
512
+ "compositePrimaryKeys": {},
513
+ "uniqueConstraints": {},
514
+ "checkConstraints": {}
515
+ }
516
+ },
517
+ "views": {},
518
+ "enums": {},
519
+ "_meta": {
520
+ "schemas": {},
521
+ "tables": {},
522
+ "columns": {}
523
+ },
524
+ "internal": {
525
+ "indexes": {}
526
+ }
527
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1793866543098,
9
+ "tag": "0000_init",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1793873052971,
16
+ "tag": "0001_idempotency",
17
+ "breakpoints": true
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,78 @@
1
+ CREATE TABLE "api_keys" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "tenant_id" text NOT NULL,
4
+ "name" text NOT NULL,
5
+ "key_hash" text NOT NULL,
6
+ "prefix" text NOT NULL,
7
+ "created_at" text NOT NULL,
8
+ "last_used_at" text,
9
+ "revoked_at" text
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE TABLE "evaluations" (
13
+ "id" text PRIMARY KEY NOT NULL,
14
+ "tenant_id" text,
15
+ "rubric_id" text,
16
+ "rubric_name" text NOT NULL,
17
+ "subject_name" text,
18
+ "status" text NOT NULL,
19
+ "score" double precision,
20
+ "grade" text,
21
+ "passed" boolean,
22
+ "pending_human" integer DEFAULT 0 NOT NULL,
23
+ "decision_calls" integer DEFAULT 0 NOT NULL,
24
+ "llm_calls" integer DEFAULT 0 NOT NULL,
25
+ "input_tokens" integer DEFAULT 0 NOT NULL,
26
+ "duration_ms" integer DEFAULT 0 NOT NULL,
27
+ "doc" jsonb NOT NULL,
28
+ "created_at" text NOT NULL,
29
+ "updated_at" text NOT NULL
30
+ );
31
+ --> statement-breakpoint
32
+ CREATE TABLE "idempotency_keys" (
33
+ "tenant_id" text,
34
+ "key" text NOT NULL,
35
+ "fingerprint" text NOT NULL,
36
+ "target_type" text NOT NULL,
37
+ "target_id" text,
38
+ "target_ids" jsonb,
39
+ "created_at" text NOT NULL,
40
+ "expires_at" text NOT NULL
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE TABLE "ratings" (
44
+ "id" text PRIMARY KEY NOT NULL,
45
+ "evaluation_id" text NOT NULL,
46
+ "tenant_id" text,
47
+ "rubric_id" text,
48
+ "criterion_id" text NOT NULL,
49
+ "rater_id" text NOT NULL,
50
+ "judge_type" text NOT NULL,
51
+ "status" text NOT NULL,
52
+ "score" double precision,
53
+ "normalized" double precision,
54
+ "confidence" double precision,
55
+ "model" text,
56
+ "created_at" text NOT NULL
57
+ );
58
+ --> statement-breakpoint
59
+ CREATE TABLE "rubrics" (
60
+ "id" text PRIMARY KEY NOT NULL,
61
+ "tenant_id" text,
62
+ "name" text NOT NULL,
63
+ "version" text DEFAULT '1' NOT NULL,
64
+ "doc" jsonb NOT NULL,
65
+ "created_at" text NOT NULL,
66
+ "updated_at" text NOT NULL
67
+ );
68
+ --> statement-breakpoint
69
+ CREATE UNIQUE INDEX "api_keys_hash" ON "api_keys" USING btree ("key_hash");--> statement-breakpoint
70
+ CREATE INDEX "api_keys_tenant" ON "api_keys" USING btree ("tenant_id");--> statement-breakpoint
71
+ CREATE INDEX "evaluations_tenant_created" ON "evaluations" USING btree ("tenant_id","created_at");--> statement-breakpoint
72
+ CREATE INDEX "evaluations_rubric_created" ON "evaluations" USING btree ("rubric_id","created_at");--> statement-breakpoint
73
+ CREATE INDEX "evaluations_tenant_status" ON "evaluations" USING btree ("tenant_id","status");--> statement-breakpoint
74
+ CREATE UNIQUE INDEX "idempotency_keys_tenant_key" ON "idempotency_keys" USING btree ("tenant_id","key");--> statement-breakpoint
75
+ CREATE INDEX "ratings_evaluation" ON "ratings" USING btree ("evaluation_id");--> statement-breakpoint
76
+ CREATE INDEX "ratings_rubric_criterion" ON "ratings" USING btree ("rubric_id","criterion_id");--> statement-breakpoint
77
+ CREATE INDEX "ratings_tenant_judge" ON "ratings" USING btree ("tenant_id","judge_type");--> statement-breakpoint
78
+ CREATE INDEX "rubrics_tenant_created" ON "rubrics" USING btree ("tenant_id","created_at");