@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,605 @@
1
+ {
2
+ "id": "397b7de7-2624-49e7-8526-c171eb6ae8b4",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.api_keys": {
8
+ "name": "api_keys",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "tenant_id": {
18
+ "name": "tenant_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "name": {
24
+ "name": "name",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "key_hash": {
30
+ "name": "key_hash",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "prefix": {
36
+ "name": "prefix",
37
+ "type": "text",
38
+ "primaryKey": false,
39
+ "notNull": true
40
+ },
41
+ "created_at": {
42
+ "name": "created_at",
43
+ "type": "text",
44
+ "primaryKey": false,
45
+ "notNull": true
46
+ },
47
+ "last_used_at": {
48
+ "name": "last_used_at",
49
+ "type": "text",
50
+ "primaryKey": false,
51
+ "notNull": false
52
+ },
53
+ "revoked_at": {
54
+ "name": "revoked_at",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": false
58
+ }
59
+ },
60
+ "indexes": {
61
+ "api_keys_hash": {
62
+ "name": "api_keys_hash",
63
+ "columns": [
64
+ {
65
+ "expression": "key_hash",
66
+ "isExpression": false,
67
+ "asc": true,
68
+ "nulls": "last"
69
+ }
70
+ ],
71
+ "isUnique": true,
72
+ "concurrently": false,
73
+ "method": "btree",
74
+ "with": {}
75
+ },
76
+ "api_keys_tenant": {
77
+ "name": "api_keys_tenant",
78
+ "columns": [
79
+ {
80
+ "expression": "tenant_id",
81
+ "isExpression": false,
82
+ "asc": true,
83
+ "nulls": "last"
84
+ }
85
+ ],
86
+ "isUnique": false,
87
+ "concurrently": false,
88
+ "method": "btree",
89
+ "with": {}
90
+ }
91
+ },
92
+ "foreignKeys": {},
93
+ "compositePrimaryKeys": {},
94
+ "uniqueConstraints": {},
95
+ "policies": {},
96
+ "checkConstraints": {},
97
+ "isRLSEnabled": false
98
+ },
99
+ "public.evaluations": {
100
+ "name": "evaluations",
101
+ "schema": "",
102
+ "columns": {
103
+ "id": {
104
+ "name": "id",
105
+ "type": "text",
106
+ "primaryKey": true,
107
+ "notNull": true
108
+ },
109
+ "tenant_id": {
110
+ "name": "tenant_id",
111
+ "type": "text",
112
+ "primaryKey": false,
113
+ "notNull": false
114
+ },
115
+ "rubric_id": {
116
+ "name": "rubric_id",
117
+ "type": "text",
118
+ "primaryKey": false,
119
+ "notNull": false
120
+ },
121
+ "rubric_name": {
122
+ "name": "rubric_name",
123
+ "type": "text",
124
+ "primaryKey": false,
125
+ "notNull": true
126
+ },
127
+ "subject_name": {
128
+ "name": "subject_name",
129
+ "type": "text",
130
+ "primaryKey": false,
131
+ "notNull": false
132
+ },
133
+ "status": {
134
+ "name": "status",
135
+ "type": "text",
136
+ "primaryKey": false,
137
+ "notNull": true
138
+ },
139
+ "score": {
140
+ "name": "score",
141
+ "type": "double precision",
142
+ "primaryKey": false,
143
+ "notNull": false
144
+ },
145
+ "grade": {
146
+ "name": "grade",
147
+ "type": "text",
148
+ "primaryKey": false,
149
+ "notNull": false
150
+ },
151
+ "passed": {
152
+ "name": "passed",
153
+ "type": "boolean",
154
+ "primaryKey": false,
155
+ "notNull": false
156
+ },
157
+ "pending_human": {
158
+ "name": "pending_human",
159
+ "type": "integer",
160
+ "primaryKey": false,
161
+ "notNull": true,
162
+ "default": 0
163
+ },
164
+ "decision_calls": {
165
+ "name": "decision_calls",
166
+ "type": "integer",
167
+ "primaryKey": false,
168
+ "notNull": true,
169
+ "default": 0
170
+ },
171
+ "llm_calls": {
172
+ "name": "llm_calls",
173
+ "type": "integer",
174
+ "primaryKey": false,
175
+ "notNull": true,
176
+ "default": 0
177
+ },
178
+ "input_tokens": {
179
+ "name": "input_tokens",
180
+ "type": "integer",
181
+ "primaryKey": false,
182
+ "notNull": true,
183
+ "default": 0
184
+ },
185
+ "duration_ms": {
186
+ "name": "duration_ms",
187
+ "type": "integer",
188
+ "primaryKey": false,
189
+ "notNull": true,
190
+ "default": 0
191
+ },
192
+ "doc": {
193
+ "name": "doc",
194
+ "type": "jsonb",
195
+ "primaryKey": false,
196
+ "notNull": true
197
+ },
198
+ "created_at": {
199
+ "name": "created_at",
200
+ "type": "text",
201
+ "primaryKey": false,
202
+ "notNull": true
203
+ },
204
+ "updated_at": {
205
+ "name": "updated_at",
206
+ "type": "text",
207
+ "primaryKey": false,
208
+ "notNull": true
209
+ }
210
+ },
211
+ "indexes": {
212
+ "evaluations_tenant_created": {
213
+ "name": "evaluations_tenant_created",
214
+ "columns": [
215
+ {
216
+ "expression": "tenant_id",
217
+ "isExpression": false,
218
+ "asc": true,
219
+ "nulls": "last"
220
+ },
221
+ {
222
+ "expression": "created_at",
223
+ "isExpression": false,
224
+ "asc": true,
225
+ "nulls": "last"
226
+ }
227
+ ],
228
+ "isUnique": false,
229
+ "concurrently": false,
230
+ "method": "btree",
231
+ "with": {}
232
+ },
233
+ "evaluations_rubric_created": {
234
+ "name": "evaluations_rubric_created",
235
+ "columns": [
236
+ {
237
+ "expression": "rubric_id",
238
+ "isExpression": false,
239
+ "asc": true,
240
+ "nulls": "last"
241
+ },
242
+ {
243
+ "expression": "created_at",
244
+ "isExpression": false,
245
+ "asc": true,
246
+ "nulls": "last"
247
+ }
248
+ ],
249
+ "isUnique": false,
250
+ "concurrently": false,
251
+ "method": "btree",
252
+ "with": {}
253
+ },
254
+ "evaluations_tenant_status": {
255
+ "name": "evaluations_tenant_status",
256
+ "columns": [
257
+ {
258
+ "expression": "tenant_id",
259
+ "isExpression": false,
260
+ "asc": true,
261
+ "nulls": "last"
262
+ },
263
+ {
264
+ "expression": "status",
265
+ "isExpression": false,
266
+ "asc": true,
267
+ "nulls": "last"
268
+ }
269
+ ],
270
+ "isUnique": false,
271
+ "concurrently": false,
272
+ "method": "btree",
273
+ "with": {}
274
+ }
275
+ },
276
+ "foreignKeys": {},
277
+ "compositePrimaryKeys": {},
278
+ "uniqueConstraints": {},
279
+ "policies": {},
280
+ "checkConstraints": {},
281
+ "isRLSEnabled": false
282
+ },
283
+ "public.idempotency_keys": {
284
+ "name": "idempotency_keys",
285
+ "schema": "",
286
+ "columns": {
287
+ "tenant_id": {
288
+ "name": "tenant_id",
289
+ "type": "text",
290
+ "primaryKey": false,
291
+ "notNull": false
292
+ },
293
+ "key": {
294
+ "name": "key",
295
+ "type": "text",
296
+ "primaryKey": false,
297
+ "notNull": true
298
+ },
299
+ "fingerprint": {
300
+ "name": "fingerprint",
301
+ "type": "text",
302
+ "primaryKey": false,
303
+ "notNull": true
304
+ },
305
+ "target_type": {
306
+ "name": "target_type",
307
+ "type": "text",
308
+ "primaryKey": false,
309
+ "notNull": true
310
+ },
311
+ "target_id": {
312
+ "name": "target_id",
313
+ "type": "text",
314
+ "primaryKey": false,
315
+ "notNull": false
316
+ },
317
+ "target_ids": {
318
+ "name": "target_ids",
319
+ "type": "jsonb",
320
+ "primaryKey": false,
321
+ "notNull": false
322
+ },
323
+ "created_at": {
324
+ "name": "created_at",
325
+ "type": "text",
326
+ "primaryKey": false,
327
+ "notNull": true
328
+ },
329
+ "expires_at": {
330
+ "name": "expires_at",
331
+ "type": "text",
332
+ "primaryKey": false,
333
+ "notNull": true
334
+ }
335
+ },
336
+ "indexes": {
337
+ "idempotency_keys_tenant_key": {
338
+ "name": "idempotency_keys_tenant_key",
339
+ "columns": [
340
+ {
341
+ "expression": "tenant_id",
342
+ "isExpression": false,
343
+ "asc": true,
344
+ "nulls": "last"
345
+ },
346
+ {
347
+ "expression": "key",
348
+ "isExpression": false,
349
+ "asc": true,
350
+ "nulls": "last"
351
+ }
352
+ ],
353
+ "isUnique": true,
354
+ "concurrently": false,
355
+ "method": "btree",
356
+ "with": {}
357
+ }
358
+ },
359
+ "foreignKeys": {},
360
+ "compositePrimaryKeys": {},
361
+ "uniqueConstraints": {},
362
+ "policies": {},
363
+ "checkConstraints": {},
364
+ "isRLSEnabled": false
365
+ },
366
+ "public.ratings": {
367
+ "name": "ratings",
368
+ "schema": "",
369
+ "columns": {
370
+ "id": {
371
+ "name": "id",
372
+ "type": "text",
373
+ "primaryKey": true,
374
+ "notNull": true
375
+ },
376
+ "evaluation_id": {
377
+ "name": "evaluation_id",
378
+ "type": "text",
379
+ "primaryKey": false,
380
+ "notNull": true
381
+ },
382
+ "tenant_id": {
383
+ "name": "tenant_id",
384
+ "type": "text",
385
+ "primaryKey": false,
386
+ "notNull": false
387
+ },
388
+ "rubric_id": {
389
+ "name": "rubric_id",
390
+ "type": "text",
391
+ "primaryKey": false,
392
+ "notNull": false
393
+ },
394
+ "criterion_id": {
395
+ "name": "criterion_id",
396
+ "type": "text",
397
+ "primaryKey": false,
398
+ "notNull": true
399
+ },
400
+ "rater_id": {
401
+ "name": "rater_id",
402
+ "type": "text",
403
+ "primaryKey": false,
404
+ "notNull": true
405
+ },
406
+ "judge_type": {
407
+ "name": "judge_type",
408
+ "type": "text",
409
+ "primaryKey": false,
410
+ "notNull": true
411
+ },
412
+ "status": {
413
+ "name": "status",
414
+ "type": "text",
415
+ "primaryKey": false,
416
+ "notNull": true
417
+ },
418
+ "score": {
419
+ "name": "score",
420
+ "type": "double precision",
421
+ "primaryKey": false,
422
+ "notNull": false
423
+ },
424
+ "normalized": {
425
+ "name": "normalized",
426
+ "type": "double precision",
427
+ "primaryKey": false,
428
+ "notNull": false
429
+ },
430
+ "confidence": {
431
+ "name": "confidence",
432
+ "type": "double precision",
433
+ "primaryKey": false,
434
+ "notNull": false
435
+ },
436
+ "model": {
437
+ "name": "model",
438
+ "type": "text",
439
+ "primaryKey": false,
440
+ "notNull": false
441
+ },
442
+ "created_at": {
443
+ "name": "created_at",
444
+ "type": "text",
445
+ "primaryKey": false,
446
+ "notNull": true
447
+ }
448
+ },
449
+ "indexes": {
450
+ "ratings_evaluation": {
451
+ "name": "ratings_evaluation",
452
+ "columns": [
453
+ {
454
+ "expression": "evaluation_id",
455
+ "isExpression": false,
456
+ "asc": true,
457
+ "nulls": "last"
458
+ }
459
+ ],
460
+ "isUnique": false,
461
+ "concurrently": false,
462
+ "method": "btree",
463
+ "with": {}
464
+ },
465
+ "ratings_rubric_criterion": {
466
+ "name": "ratings_rubric_criterion",
467
+ "columns": [
468
+ {
469
+ "expression": "rubric_id",
470
+ "isExpression": false,
471
+ "asc": true,
472
+ "nulls": "last"
473
+ },
474
+ {
475
+ "expression": "criterion_id",
476
+ "isExpression": false,
477
+ "asc": true,
478
+ "nulls": "last"
479
+ }
480
+ ],
481
+ "isUnique": false,
482
+ "concurrently": false,
483
+ "method": "btree",
484
+ "with": {}
485
+ },
486
+ "ratings_tenant_judge": {
487
+ "name": "ratings_tenant_judge",
488
+ "columns": [
489
+ {
490
+ "expression": "tenant_id",
491
+ "isExpression": false,
492
+ "asc": true,
493
+ "nulls": "last"
494
+ },
495
+ {
496
+ "expression": "judge_type",
497
+ "isExpression": false,
498
+ "asc": true,
499
+ "nulls": "last"
500
+ }
501
+ ],
502
+ "isUnique": false,
503
+ "concurrently": false,
504
+ "method": "btree",
505
+ "with": {}
506
+ }
507
+ },
508
+ "foreignKeys": {},
509
+ "compositePrimaryKeys": {},
510
+ "uniqueConstraints": {},
511
+ "policies": {},
512
+ "checkConstraints": {},
513
+ "isRLSEnabled": false
514
+ },
515
+ "public.rubrics": {
516
+ "name": "rubrics",
517
+ "schema": "",
518
+ "columns": {
519
+ "id": {
520
+ "name": "id",
521
+ "type": "text",
522
+ "primaryKey": true,
523
+ "notNull": true
524
+ },
525
+ "tenant_id": {
526
+ "name": "tenant_id",
527
+ "type": "text",
528
+ "primaryKey": false,
529
+ "notNull": false
530
+ },
531
+ "name": {
532
+ "name": "name",
533
+ "type": "text",
534
+ "primaryKey": false,
535
+ "notNull": true
536
+ },
537
+ "version": {
538
+ "name": "version",
539
+ "type": "text",
540
+ "primaryKey": false,
541
+ "notNull": true,
542
+ "default": "'1'"
543
+ },
544
+ "doc": {
545
+ "name": "doc",
546
+ "type": "jsonb",
547
+ "primaryKey": false,
548
+ "notNull": true
549
+ },
550
+ "created_at": {
551
+ "name": "created_at",
552
+ "type": "text",
553
+ "primaryKey": false,
554
+ "notNull": true
555
+ },
556
+ "updated_at": {
557
+ "name": "updated_at",
558
+ "type": "text",
559
+ "primaryKey": false,
560
+ "notNull": true
561
+ }
562
+ },
563
+ "indexes": {
564
+ "rubrics_tenant_created": {
565
+ "name": "rubrics_tenant_created",
566
+ "columns": [
567
+ {
568
+ "expression": "tenant_id",
569
+ "isExpression": false,
570
+ "asc": true,
571
+ "nulls": "last"
572
+ },
573
+ {
574
+ "expression": "created_at",
575
+ "isExpression": false,
576
+ "asc": true,
577
+ "nulls": "last"
578
+ }
579
+ ],
580
+ "isUnique": false,
581
+ "concurrently": false,
582
+ "method": "btree",
583
+ "with": {}
584
+ }
585
+ },
586
+ "foreignKeys": {},
587
+ "compositePrimaryKeys": {},
588
+ "uniqueConstraints": {},
589
+ "policies": {},
590
+ "checkConstraints": {},
591
+ "isRLSEnabled": false
592
+ }
593
+ },
594
+ "enums": {},
595
+ "schemas": {},
596
+ "sequences": {},
597
+ "roles": {},
598
+ "policies": {},
599
+ "views": {},
600
+ "_meta": {
601
+ "columns": {},
602
+ "schemas": {},
603
+ "tables": {}
604
+ }
605
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1793875635058,
9
+ "tag": "0000_init",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,84 @@
1
1
  {
2
2
  "name": "@verdict-ai/db",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Verdict persistence on Drizzle ORM — SQLite, Cloudflare D1 and Postgres.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./schema": {
14
+ "types": "./dist/schema/sqlite.d.ts",
15
+ "import": "./dist/schema/sqlite.js"
16
+ },
17
+ "./sqlite": {
18
+ "types": "./dist/sqlite.d.ts",
19
+ "import": "./dist/sqlite.js"
20
+ },
21
+ "./postgres": {
22
+ "types": "./dist/postgres.d.ts",
23
+ "import": "./dist/postgres.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE",
30
+ "drizzle/"
31
+ ],
32
+ "dependencies": {
33
+ "drizzle-orm": "^0.45.4",
34
+ "@verdict-ai/core": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "@cloudflare/workers-types": "^5.20261104.1",
38
+ "@electric-sql/pglite": "^0.5.15",
39
+ "@types/better-sqlite3": "^7.6.13",
40
+ "@types/pg": "^8.23.1",
41
+ "drizzle-kit": "^0.31.11"
42
+ },
43
+ "optionalDependencies": {
44
+ "better-sqlite3": "^13.0.3",
45
+ "pg": "^8.23.1"
46
+ },
47
+ "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/Ustay-coder/verdict.git",
51
+ "directory": "packages/db"
52
+ },
53
+ "homepage": "https://github.com/Ustay-coder/verdict#readme",
54
+ "bugs": {
55
+ "url": "https://github.com/Ustay-coder/verdict/issues"
56
+ },
57
+ "keywords": [
58
+ "evaluation",
59
+ "rubric",
60
+ "decision-model",
61
+ "jev",
62
+ "clef",
63
+ "scoring",
64
+ "llm-judge",
65
+ "mcp"
66
+ ],
67
+ "engines": {
68
+ "node": ">=20"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "sideEffects": false,
74
+ "scripts": {
75
+ "build": "tsc -p tsconfig.json",
76
+ "typecheck": "tsc -p tsconfig.json --noEmit",
77
+ "test": "vitest run",
78
+ "db:generate": "drizzle-kit generate",
79
+ "db:migrate:local": "wrangler d1 migrations apply verdict --local",
80
+ "db:migrate:remote": "wrangler d1 migrations apply verdict --remote",
81
+ "db:generate:pg": "drizzle-kit generate --config drizzle.pg.config.ts",
82
+ "db:migrate:pg": "node --input-type=module -e 'const { fromPostgres } = await import(\"./dist/postgres.js\"); const h = await fromPostgres(process.env.DATABASE_URL); await h.close();'"
83
+ }
6
84
  }