1+ import { id } from "@steebchen/id" ;
12import { sql } from "drizzle-orm" ;
23import {
34 boolean ,
@@ -12,11 +13,12 @@ import {
1213 timestamp ,
1314 unique ,
1415} from "drizzle-orm/pg-core" ;
15- import { customAlphabet } from "nanoid" ;
1616
1717import type { errorDetails , tools , toolChoice , toolResults } from "./types.js" ;
1818import type z from "zod" ;
1919
20+ export { id , random } from "@steebchen/id" ;
21+
2022export const UnifiedFinishReason = {
2123 COMPLETED : "completed" ,
2224 LENGTH_LIMIT : "length_limit" ,
@@ -32,14 +34,8 @@ export const UnifiedFinishReason = {
3234export type UnifiedFinishReason =
3335 ( typeof UnifiedFinishReason ) [ keyof typeof UnifiedFinishReason ] ;
3436
35- const generate = customAlphabet (
36- "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ,
37- ) ;
38-
39- export const shortid = ( size = 20 ) => generate ( size ) ;
40-
4137export const user = pgTable ( "user" , {
42- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
38+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
4339 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
4440 updatedAt : timestamp ( )
4541 . notNull ( )
@@ -55,7 +51,7 @@ export const user = pgTable("user", {
5551export const session = pgTable (
5652 "session" ,
5753 {
58- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
54+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
5955 expiresAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
6056 token : text ( ) . notNull ( ) . unique ( ) ,
6157 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
@@ -75,7 +71,7 @@ export const session = pgTable(
7571export const account = pgTable (
7672 "account" ,
7773 {
78- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
74+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
7975 accountId : text ( ) . notNull ( ) ,
8076 providerId : text ( ) . notNull ( ) ,
8177 userId : text ( )
@@ -98,7 +94,7 @@ export const account = pgTable(
9894) ;
9995
10096export const verification = pgTable ( "verification" , {
101- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
97+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
10298 identifier : text ( ) . notNull ( ) ,
10399 value : text ( ) . notNull ( ) ,
104100 expiresAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
@@ -107,7 +103,7 @@ export const verification = pgTable("verification", {
107103} ) ;
108104
109105export const organization = pgTable ( "organization" , {
110- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
106+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
111107 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
112108 updatedAt : timestamp ( )
113109 . notNull ( )
@@ -148,7 +144,7 @@ export const organization = pgTable("organization", {
148144export const transaction = pgTable (
149145 "transaction" ,
150146 {
151- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
147+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
152148 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
153149 updatedAt : timestamp ( )
154150 . notNull ( )
@@ -185,7 +181,7 @@ export const transaction = pgTable(
185181export const userOrganization = pgTable (
186182 "user_organization" ,
187183 {
188- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
184+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
189185 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
190186 updatedAt : timestamp ( )
191187 . notNull ( )
@@ -212,7 +208,7 @@ export const userOrganization = pgTable(
212208export const project = pgTable (
213209 "project" ,
214210 {
215- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
211+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
216212 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
217213 updatedAt : timestamp ( )
218214 . notNull ( )
@@ -239,7 +235,7 @@ export const project = pgTable(
239235export const apiKey = pgTable (
240236 "api_key" ,
241237 {
242- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
238+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
243239 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
244240 updatedAt : timestamp ( )
245241 . notNull ( )
@@ -268,7 +264,7 @@ export const apiKey = pgTable(
268264export const apiKeyIamRule = pgTable (
269265 "api_key_iam_rule" ,
270266 {
271- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
267+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
272268 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
273269 updatedAt : timestamp ( )
274270 . notNull ( )
@@ -323,7 +319,7 @@ export interface ProviderKeyOptions {
323319export const providerKey = pgTable (
324320 "provider_key" ,
325321 {
326- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
322+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
327323 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
328324 updatedAt : timestamp ( )
329325 . notNull ( )
@@ -350,7 +346,7 @@ export const providerKey = pgTable(
350346export const log = pgTable (
351347 "log" ,
352348 {
353- id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( shortid ) ,
349+ id : text ( ) . primaryKey ( ) . notNull ( ) . $defaultFn ( id ) ,
354350 requestId : text ( ) . notNull ( ) ,
355351 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
356352 updatedAt : timestamp ( )
@@ -453,7 +449,7 @@ export const log = pgTable(
453449export const passkey = pgTable (
454450 "passkey" ,
455451 {
456- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
452+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
457453 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
458454 updatedAt : timestamp ( )
459455 . notNull ( )
@@ -476,7 +472,7 @@ export const passkey = pgTable(
476472export const paymentMethod = pgTable (
477473 "payment_method" ,
478474 {
479- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
475+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
480476 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
481477 updatedAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
482478 stripePaymentMethodId : text ( ) . notNull ( ) ,
@@ -494,7 +490,7 @@ export const paymentMethod = pgTable(
494490export const organizationAction = pgTable (
495491 "organization_action" ,
496492 {
497- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
493+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
498494 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
499495 updatedAt : timestamp ( )
500496 . notNull ( )
@@ -515,7 +511,7 @@ export const organizationAction = pgTable(
515511) ;
516512
517513export const lock = pgTable ( "lock" , {
518- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
514+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
519515 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
520516 updatedAt : timestamp ( )
521517 . notNull ( )
@@ -527,7 +523,7 @@ export const lock = pgTable("lock", {
527523export const chat = pgTable (
528524 "chat" ,
529525 {
530- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
526+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
531527 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
532528 updatedAt : timestamp ( )
533529 . notNull ( )
@@ -548,7 +544,7 @@ export const chat = pgTable(
548544export const message = pgTable (
549545 "message" ,
550546 {
551- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
547+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
552548 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
553549 updatedAt : timestamp ( )
554550 . notNull ( )
@@ -570,7 +566,7 @@ export const message = pgTable(
570566) ;
571567
572568export const installation = pgTable ( "installation" , {
573- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
569+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
574570 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
575571 updatedAt : timestamp ( )
576572 . notNull ( )
@@ -648,7 +644,7 @@ export const model = pgTable(
648644export const modelProviderMapping = pgTable (
649645 "model_provider_mapping" ,
650646 {
651- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
647+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
652648 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
653649 updatedAt : timestamp ( )
654650 . notNull ( )
@@ -703,7 +699,7 @@ export const modelProviderMapping = pgTable(
703699export const modelProviderMappingHistory = pgTable (
704700 "model_provider_mapping_history" ,
705701 {
706- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
702+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
707703 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
708704 updatedAt : timestamp ( )
709705 . notNull ( )
@@ -752,7 +748,7 @@ export const modelProviderMappingHistory = pgTable(
752748export const modelHistory = pgTable (
753749 "model_history" ,
754750 {
755- id : text ( ) . primaryKey ( ) . $defaultFn ( shortid ) ,
751+ id : text ( ) . primaryKey ( ) . $defaultFn ( id ) ,
756752 createdAt : timestamp ( ) . notNull ( ) . defaultNow ( ) ,
757753 updatedAt : timestamp ( )
758754 . notNull ( )
0 commit comments