@llmops/core 0.1.0-beta.8 → 0.1.1-beta.1

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.
@@ -0,0 +1,883 @@
1
+ import { ColumnType, Generated, Kysely, MssqlDialect, MysqlDialect, PostgresDialect, SqliteDialect } from "kysely";
2
+ import * as zod0 from "zod";
3
+ import { z } from "zod";
4
+
5
+ //#region src/db/schema.d.ts
6
+ declare const configsSchema: z.ZodObject<{
7
+ slug: z.ZodString;
8
+ name: z.ZodOptional<z.ZodString>;
9
+ id: z.ZodString;
10
+ createdAt: z.ZodDate;
11
+ updatedAt: z.ZodDate;
12
+ }, z.core.$strip>;
13
+ declare const variantsSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ id: z.ZodString;
16
+ createdAt: z.ZodDate;
17
+ updatedAt: z.ZodDate;
18
+ }, z.core.$strip>;
19
+ declare const variantVersionsSchema: z.ZodObject<{
20
+ variantId: z.ZodString;
21
+ version: z.ZodNumber;
22
+ provider: z.ZodString;
23
+ modelName: z.ZodString;
24
+ jsonData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
25
+ id: z.ZodString;
26
+ createdAt: z.ZodDate;
27
+ updatedAt: z.ZodDate;
28
+ }, z.core.$strip>;
29
+ declare const environmentsSchema: z.ZodObject<{
30
+ name: z.ZodString;
31
+ slug: z.ZodString;
32
+ isProd: z.ZodDefault<z.ZodBoolean>;
33
+ id: z.ZodString;
34
+ createdAt: z.ZodDate;
35
+ updatedAt: z.ZodDate;
36
+ }, z.core.$strip>;
37
+ declare const environmentSecretsSchema: z.ZodObject<{
38
+ environmentId: z.ZodString;
39
+ keyName: z.ZodString;
40
+ keyValue: z.ZodString;
41
+ id: z.ZodString;
42
+ createdAt: z.ZodDate;
43
+ updatedAt: z.ZodDate;
44
+ }, z.core.$strip>;
45
+ declare const configVariantsSchema: z.ZodObject<{
46
+ configId: z.ZodString;
47
+ variantId: z.ZodString;
48
+ id: z.ZodString;
49
+ createdAt: z.ZodDate;
50
+ updatedAt: z.ZodDate;
51
+ }, z.core.$strip>;
52
+ declare const targetingRulesSchema: z.ZodObject<{
53
+ environmentId: z.ZodString;
54
+ configId: z.ZodString;
55
+ configVariantId: z.ZodString;
56
+ variantVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ weight: z.ZodDefault<z.ZodNumber>;
58
+ priority: z.ZodDefault<z.ZodNumber>;
59
+ enabled: z.ZodDefault<z.ZodBoolean>;
60
+ conditions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
61
+ id: z.ZodString;
62
+ createdAt: z.ZodDate;
63
+ updatedAt: z.ZodDate;
64
+ }, z.core.$strip>;
65
+ /**
66
+ * Zod inferred types (for runtime validation)
67
+ */
68
+ type Config = z.infer<typeof configsSchema>;
69
+ type Variant = z.infer<typeof variantsSchema>;
70
+ type VariantVersion = z.infer<typeof variantVersionsSchema>;
71
+ type Environment = z.infer<typeof environmentsSchema>;
72
+ type EnvironmentSecret = z.infer<typeof environmentSecretsSchema>;
73
+ type ConfigVariant = z.infer<typeof configVariantsSchema>;
74
+ type TargetingRule = z.infer<typeof targetingRulesSchema>;
75
+ /**
76
+ * Kysely Table Interfaces
77
+ * Derived from Zod schemas with proper column types
78
+ */
79
+ interface BaseTable {
80
+ id: Generated<string>;
81
+ createdAt: ColumnType<Date, string | undefined, string | undefined>;
82
+ updatedAt: ColumnType<Date, string | undefined, string | undefined>;
83
+ }
84
+ interface ConfigsTable extends BaseTable {
85
+ slug: string;
86
+ name?: string;
87
+ }
88
+ interface VariantsTable extends BaseTable {
89
+ name: string;
90
+ }
91
+ interface VariantVersionsTable extends BaseTable {
92
+ variantId: string;
93
+ version: number;
94
+ provider: string;
95
+ modelName: string;
96
+ jsonData: ColumnType<Record<string, unknown>, string, string>;
97
+ }
98
+ interface EnvironmentsTable extends BaseTable {
99
+ name: string;
100
+ slug: string;
101
+ isProd: ColumnType<boolean, boolean | undefined, boolean | undefined>;
102
+ }
103
+ interface EnvironmentSecretsTable extends BaseTable {
104
+ environmentId: string;
105
+ keyName: string;
106
+ keyValue: string;
107
+ }
108
+ interface ConfigVariantsTable extends BaseTable {
109
+ configId: string;
110
+ variantId: string;
111
+ }
112
+ interface TargetingRulesTable extends BaseTable {
113
+ environmentId: string;
114
+ configId: string;
115
+ configVariantId: string;
116
+ variantVersionId: string | null;
117
+ weight: ColumnType<number, number | undefined, number | undefined>;
118
+ priority: ColumnType<number, number | undefined, number | undefined>;
119
+ enabled: ColumnType<boolean, boolean | undefined, boolean | undefined>;
120
+ conditions: ColumnType<Record<string, unknown>, string, string>;
121
+ }
122
+ /**
123
+ * Main Kysely Database interface
124
+ */
125
+ interface Database {
126
+ configs: ConfigsTable;
127
+ variants: VariantsTable;
128
+ variant_versions: VariantVersionsTable;
129
+ environments: EnvironmentsTable;
130
+ environment_secrets: EnvironmentSecretsTable;
131
+ config_variants: ConfigVariantsTable;
132
+ targeting_rules: TargetingRulesTable;
133
+ }
134
+ /**
135
+ * Table names as a union type
136
+ */
137
+ type TableName = keyof Database;
138
+ /**
139
+ * Utility types for type-safe operations
140
+ */
141
+ type Insertable<T extends TableName> = { [K in keyof Database[T]]: Database[T][K] extends ColumnType<infer _SelectType, infer InsertType, infer _UpdateType> ? InsertType : Database[T][K] extends Generated<infer _GeneratedType> ? never : Database[T][K] };
142
+ type Selectable<T extends TableName> = { [K in keyof Database[T]]: Database[T][K] extends ColumnType<infer SelectType, infer _InsertType, infer _UpdateType> ? SelectType : Database[T][K] extends Generated<infer GeneratedType> ? GeneratedType : Database[T][K] };
143
+ type Updateable<T extends TableName> = { [K in keyof Database[T]]?: Database[T][K] extends ColumnType<infer _SelectType, infer _InsertType, infer UpdateType> ? UpdateType : Database[T][K] extends Generated<infer _GeneratedType> ? never : Database[T][K] };
144
+ /**
145
+ * Schema metadata for migrations
146
+ * Derived from Zod schemas
147
+ */
148
+ declare const SCHEMA_METADATA: {
149
+ readonly tables: {
150
+ readonly configs: {
151
+ readonly order: 1;
152
+ readonly schema: z.ZodObject<{
153
+ slug: z.ZodString;
154
+ name: z.ZodOptional<z.ZodString>;
155
+ id: z.ZodString;
156
+ createdAt: z.ZodDate;
157
+ updatedAt: z.ZodDate;
158
+ }, z.core.$strip>;
159
+ readonly fields: {
160
+ readonly id: {
161
+ readonly type: "uuid";
162
+ readonly primaryKey: true;
163
+ };
164
+ readonly slug: {
165
+ readonly type: "text";
166
+ readonly unique: true;
167
+ };
168
+ readonly name: {
169
+ readonly type: "text";
170
+ readonly nullable: true;
171
+ };
172
+ readonly createdAt: {
173
+ readonly type: "timestamp";
174
+ readonly default: "now()";
175
+ };
176
+ readonly updatedAt: {
177
+ readonly type: "timestamp";
178
+ readonly default: "now()";
179
+ readonly onUpdate: "now()";
180
+ };
181
+ };
182
+ };
183
+ readonly variants: {
184
+ readonly order: 2;
185
+ readonly schema: z.ZodObject<{
186
+ name: z.ZodString;
187
+ id: z.ZodString;
188
+ createdAt: z.ZodDate;
189
+ updatedAt: z.ZodDate;
190
+ }, z.core.$strip>;
191
+ readonly fields: {
192
+ readonly id: {
193
+ readonly type: "uuid";
194
+ readonly primaryKey: true;
195
+ };
196
+ readonly name: {
197
+ readonly type: "text";
198
+ };
199
+ readonly createdAt: {
200
+ readonly type: "timestamp";
201
+ readonly default: "now()";
202
+ };
203
+ readonly updatedAt: {
204
+ readonly type: "timestamp";
205
+ readonly default: "now()";
206
+ readonly onUpdate: "now()";
207
+ };
208
+ };
209
+ };
210
+ readonly variant_versions: {
211
+ readonly order: 3;
212
+ readonly schema: z.ZodObject<{
213
+ variantId: z.ZodString;
214
+ version: z.ZodNumber;
215
+ provider: z.ZodString;
216
+ modelName: z.ZodString;
217
+ jsonData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
218
+ id: z.ZodString;
219
+ createdAt: z.ZodDate;
220
+ updatedAt: z.ZodDate;
221
+ }, z.core.$strip>;
222
+ readonly fields: {
223
+ readonly id: {
224
+ readonly type: "uuid";
225
+ readonly primaryKey: true;
226
+ };
227
+ readonly variantId: {
228
+ readonly type: "uuid";
229
+ readonly references: {
230
+ readonly table: "variants";
231
+ readonly column: "id";
232
+ };
233
+ };
234
+ readonly version: {
235
+ readonly type: "integer";
236
+ };
237
+ readonly provider: {
238
+ readonly type: "text";
239
+ };
240
+ readonly modelName: {
241
+ readonly type: "text";
242
+ };
243
+ readonly jsonData: {
244
+ readonly type: "jsonb";
245
+ };
246
+ readonly createdAt: {
247
+ readonly type: "timestamp";
248
+ readonly default: "now()";
249
+ };
250
+ readonly updatedAt: {
251
+ readonly type: "timestamp";
252
+ readonly default: "now()";
253
+ readonly onUpdate: "now()";
254
+ };
255
+ };
256
+ readonly uniqueConstraints: readonly [{
257
+ readonly columns: readonly ["variantId", "version"];
258
+ }];
259
+ };
260
+ readonly environments: {
261
+ readonly order: 4;
262
+ readonly schema: z.ZodObject<{
263
+ name: z.ZodString;
264
+ slug: z.ZodString;
265
+ isProd: z.ZodDefault<z.ZodBoolean>;
266
+ id: z.ZodString;
267
+ createdAt: z.ZodDate;
268
+ updatedAt: z.ZodDate;
269
+ }, z.core.$strip>;
270
+ readonly fields: {
271
+ readonly id: {
272
+ readonly type: "uuid";
273
+ readonly primaryKey: true;
274
+ };
275
+ readonly name: {
276
+ readonly type: "text";
277
+ };
278
+ readonly slug: {
279
+ readonly type: "text";
280
+ readonly unique: true;
281
+ };
282
+ readonly isProd: {
283
+ readonly type: "boolean";
284
+ readonly default: false;
285
+ };
286
+ readonly createdAt: {
287
+ readonly type: "timestamp";
288
+ readonly default: "now()";
289
+ };
290
+ readonly updatedAt: {
291
+ readonly type: "timestamp";
292
+ readonly default: "now()";
293
+ readonly onUpdate: "now()";
294
+ };
295
+ };
296
+ };
297
+ readonly environment_secrets: {
298
+ readonly order: 5;
299
+ readonly schema: z.ZodObject<{
300
+ environmentId: z.ZodString;
301
+ keyName: z.ZodString;
302
+ keyValue: z.ZodString;
303
+ id: z.ZodString;
304
+ createdAt: z.ZodDate;
305
+ updatedAt: z.ZodDate;
306
+ }, z.core.$strip>;
307
+ readonly fields: {
308
+ readonly id: {
309
+ readonly type: "uuid";
310
+ readonly primaryKey: true;
311
+ };
312
+ readonly environmentId: {
313
+ readonly type: "uuid";
314
+ readonly references: {
315
+ readonly table: "environments";
316
+ readonly column: "id";
317
+ };
318
+ };
319
+ readonly keyName: {
320
+ readonly type: "text";
321
+ };
322
+ readonly keyValue: {
323
+ readonly type: "text";
324
+ };
325
+ readonly createdAt: {
326
+ readonly type: "timestamp";
327
+ readonly default: "now()";
328
+ };
329
+ readonly updatedAt: {
330
+ readonly type: "timestamp";
331
+ readonly default: "now()";
332
+ readonly onUpdate: "now()";
333
+ };
334
+ };
335
+ };
336
+ readonly config_variants: {
337
+ readonly order: 6;
338
+ readonly schema: z.ZodObject<{
339
+ configId: z.ZodString;
340
+ variantId: z.ZodString;
341
+ id: z.ZodString;
342
+ createdAt: z.ZodDate;
343
+ updatedAt: z.ZodDate;
344
+ }, z.core.$strip>;
345
+ readonly fields: {
346
+ readonly id: {
347
+ readonly type: "uuid";
348
+ readonly primaryKey: true;
349
+ };
350
+ readonly configId: {
351
+ readonly type: "uuid";
352
+ readonly references: {
353
+ readonly table: "configs";
354
+ readonly column: "id";
355
+ };
356
+ };
357
+ readonly variantId: {
358
+ readonly type: "uuid";
359
+ readonly references: {
360
+ readonly table: "variants";
361
+ readonly column: "id";
362
+ };
363
+ };
364
+ readonly createdAt: {
365
+ readonly type: "timestamp";
366
+ readonly default: "now()";
367
+ };
368
+ readonly updatedAt: {
369
+ readonly type: "timestamp";
370
+ readonly default: "now()";
371
+ readonly onUpdate: "now()";
372
+ };
373
+ };
374
+ };
375
+ readonly targeting_rules: {
376
+ readonly order: 7;
377
+ readonly schema: z.ZodObject<{
378
+ environmentId: z.ZodString;
379
+ configId: z.ZodString;
380
+ configVariantId: z.ZodString;
381
+ variantVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
382
+ weight: z.ZodDefault<z.ZodNumber>;
383
+ priority: z.ZodDefault<z.ZodNumber>;
384
+ enabled: z.ZodDefault<z.ZodBoolean>;
385
+ conditions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
386
+ id: z.ZodString;
387
+ createdAt: z.ZodDate;
388
+ updatedAt: z.ZodDate;
389
+ }, z.core.$strip>;
390
+ readonly fields: {
391
+ readonly id: {
392
+ readonly type: "uuid";
393
+ readonly primaryKey: true;
394
+ };
395
+ readonly environmentId: {
396
+ readonly type: "uuid";
397
+ readonly references: {
398
+ readonly table: "environments";
399
+ readonly column: "id";
400
+ };
401
+ };
402
+ readonly configId: {
403
+ readonly type: "uuid";
404
+ readonly references: {
405
+ readonly table: "configs";
406
+ readonly column: "id";
407
+ };
408
+ };
409
+ readonly configVariantId: {
410
+ readonly type: "uuid";
411
+ readonly references: {
412
+ readonly table: "config_variants";
413
+ readonly column: "id";
414
+ };
415
+ };
416
+ readonly variantVersionId: {
417
+ readonly type: "uuid";
418
+ readonly nullable: true;
419
+ readonly references: {
420
+ readonly table: "variant_versions";
421
+ readonly column: "id";
422
+ };
423
+ };
424
+ readonly weight: {
425
+ readonly type: "integer";
426
+ readonly default: 10000;
427
+ };
428
+ readonly priority: {
429
+ readonly type: "integer";
430
+ readonly default: 0;
431
+ };
432
+ readonly enabled: {
433
+ readonly type: "boolean";
434
+ readonly default: true;
435
+ };
436
+ readonly conditions: {
437
+ readonly type: "jsonb";
438
+ readonly default: "{}";
439
+ };
440
+ readonly createdAt: {
441
+ readonly type: "timestamp";
442
+ readonly default: "now()";
443
+ };
444
+ readonly updatedAt: {
445
+ readonly type: "timestamp";
446
+ readonly default: "now()";
447
+ readonly onUpdate: "now()";
448
+ };
449
+ };
450
+ };
451
+ };
452
+ };
453
+ /**
454
+ * Export all Zod schemas for runtime validation
455
+ */
456
+ declare const schemas: {
457
+ readonly configs: z.ZodObject<{
458
+ slug: z.ZodString;
459
+ name: z.ZodOptional<z.ZodString>;
460
+ id: z.ZodString;
461
+ createdAt: z.ZodDate;
462
+ updatedAt: z.ZodDate;
463
+ }, z.core.$strip>;
464
+ readonly variants: z.ZodObject<{
465
+ name: z.ZodString;
466
+ id: z.ZodString;
467
+ createdAt: z.ZodDate;
468
+ updatedAt: z.ZodDate;
469
+ }, z.core.$strip>;
470
+ readonly variant_versions: z.ZodObject<{
471
+ variantId: z.ZodString;
472
+ version: z.ZodNumber;
473
+ provider: z.ZodString;
474
+ modelName: z.ZodString;
475
+ jsonData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
476
+ id: z.ZodString;
477
+ createdAt: z.ZodDate;
478
+ updatedAt: z.ZodDate;
479
+ }, z.core.$strip>;
480
+ readonly environments: z.ZodObject<{
481
+ name: z.ZodString;
482
+ slug: z.ZodString;
483
+ isProd: z.ZodDefault<z.ZodBoolean>;
484
+ id: z.ZodString;
485
+ createdAt: z.ZodDate;
486
+ updatedAt: z.ZodDate;
487
+ }, z.core.$strip>;
488
+ readonly environment_secrets: z.ZodObject<{
489
+ environmentId: z.ZodString;
490
+ keyName: z.ZodString;
491
+ keyValue: z.ZodString;
492
+ id: z.ZodString;
493
+ createdAt: z.ZodDate;
494
+ updatedAt: z.ZodDate;
495
+ }, z.core.$strip>;
496
+ readonly config_variants: z.ZodObject<{
497
+ configId: z.ZodString;
498
+ variantId: z.ZodString;
499
+ id: z.ZodString;
500
+ createdAt: z.ZodDate;
501
+ updatedAt: z.ZodDate;
502
+ }, z.core.$strip>;
503
+ readonly targeting_rules: z.ZodObject<{
504
+ environmentId: z.ZodString;
505
+ configId: z.ZodString;
506
+ configVariantId: z.ZodString;
507
+ variantVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
508
+ weight: z.ZodDefault<z.ZodNumber>;
509
+ priority: z.ZodDefault<z.ZodNumber>;
510
+ enabled: z.ZodDefault<z.ZodBoolean>;
511
+ conditions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
512
+ id: z.ZodString;
513
+ createdAt: z.ZodDate;
514
+ updatedAt: z.ZodDate;
515
+ }, z.core.$strip>;
516
+ };
517
+ //#endregion
518
+ //#region src/db/validation.d.ts
519
+ /**
520
+ * Validate data against table schema
521
+ * Useful for runtime validation before inserting/updating
522
+ */
523
+ declare function validateTableData<T extends TableName>(table: T, data: unknown): zod0.ZodSafeParseSuccess<{
524
+ slug: string;
525
+ id: string;
526
+ createdAt: Date;
527
+ updatedAt: Date;
528
+ name?: string | undefined;
529
+ }> | zod0.ZodSafeParseError<{
530
+ slug: string;
531
+ id: string;
532
+ createdAt: Date;
533
+ updatedAt: Date;
534
+ name?: string | undefined;
535
+ }> | zod0.ZodSafeParseSuccess<{
536
+ name: string;
537
+ id: string;
538
+ createdAt: Date;
539
+ updatedAt: Date;
540
+ }> | zod0.ZodSafeParseError<{
541
+ name: string;
542
+ id: string;
543
+ createdAt: Date;
544
+ updatedAt: Date;
545
+ }> | zod0.ZodSafeParseSuccess<{
546
+ variantId: string;
547
+ version: number;
548
+ provider: string;
549
+ modelName: string;
550
+ jsonData: Record<string, unknown>;
551
+ id: string;
552
+ createdAt: Date;
553
+ updatedAt: Date;
554
+ }> | zod0.ZodSafeParseError<{
555
+ variantId: string;
556
+ version: number;
557
+ provider: string;
558
+ modelName: string;
559
+ jsonData: Record<string, unknown>;
560
+ id: string;
561
+ createdAt: Date;
562
+ updatedAt: Date;
563
+ }> | zod0.ZodSafeParseSuccess<{
564
+ environmentId: string;
565
+ keyName: string;
566
+ keyValue: string;
567
+ id: string;
568
+ createdAt: Date;
569
+ updatedAt: Date;
570
+ }> | zod0.ZodSafeParseError<{
571
+ environmentId: string;
572
+ keyName: string;
573
+ keyValue: string;
574
+ id: string;
575
+ createdAt: Date;
576
+ updatedAt: Date;
577
+ }> | zod0.ZodSafeParseSuccess<{
578
+ configId: string;
579
+ variantId: string;
580
+ id: string;
581
+ createdAt: Date;
582
+ updatedAt: Date;
583
+ }> | zod0.ZodSafeParseError<{
584
+ configId: string;
585
+ variantId: string;
586
+ id: string;
587
+ createdAt: Date;
588
+ updatedAt: Date;
589
+ }> | zod0.ZodSafeParseSuccess<{
590
+ environmentId: string;
591
+ configId: string;
592
+ configVariantId: string;
593
+ weight: number;
594
+ priority: number;
595
+ enabled: boolean;
596
+ conditions: Record<string, unknown>;
597
+ id: string;
598
+ createdAt: Date;
599
+ updatedAt: Date;
600
+ variantVersionId?: string | null | undefined;
601
+ }> | zod0.ZodSafeParseError<{
602
+ environmentId: string;
603
+ configId: string;
604
+ configVariantId: string;
605
+ weight: number;
606
+ priority: number;
607
+ enabled: boolean;
608
+ conditions: Record<string, unknown>;
609
+ id: string;
610
+ createdAt: Date;
611
+ updatedAt: Date;
612
+ variantVersionId?: string | null | undefined;
613
+ }>;
614
+ /**
615
+ * Validate partial data (for updates)
616
+ */
617
+ declare function validatePartialTableData<T extends TableName>(table: T, data: unknown): zod0.ZodSafeParseSuccess<{
618
+ name?: string | undefined;
619
+ id?: string | undefined;
620
+ createdAt?: Date | undefined;
621
+ updatedAt?: Date | undefined;
622
+ }> | zod0.ZodSafeParseError<{
623
+ name?: string | undefined;
624
+ id?: string | undefined;
625
+ createdAt?: Date | undefined;
626
+ updatedAt?: Date | undefined;
627
+ }> | zod0.ZodSafeParseSuccess<{
628
+ variantId?: string | undefined;
629
+ version?: number | undefined;
630
+ provider?: string | undefined;
631
+ modelName?: string | undefined;
632
+ jsonData?: Record<string, unknown> | undefined;
633
+ id?: string | undefined;
634
+ createdAt?: Date | undefined;
635
+ updatedAt?: Date | undefined;
636
+ }> | zod0.ZodSafeParseError<{
637
+ variantId?: string | undefined;
638
+ version?: number | undefined;
639
+ provider?: string | undefined;
640
+ modelName?: string | undefined;
641
+ jsonData?: Record<string, unknown> | undefined;
642
+ id?: string | undefined;
643
+ createdAt?: Date | undefined;
644
+ updatedAt?: Date | undefined;
645
+ }> | zod0.ZodSafeParseSuccess<{
646
+ environmentId?: string | undefined;
647
+ keyName?: string | undefined;
648
+ keyValue?: string | undefined;
649
+ id?: string | undefined;
650
+ createdAt?: Date | undefined;
651
+ updatedAt?: Date | undefined;
652
+ }> | zod0.ZodSafeParseError<{
653
+ environmentId?: string | undefined;
654
+ keyName?: string | undefined;
655
+ keyValue?: string | undefined;
656
+ id?: string | undefined;
657
+ createdAt?: Date | undefined;
658
+ updatedAt?: Date | undefined;
659
+ }> | zod0.ZodSafeParseSuccess<{
660
+ configId?: string | undefined;
661
+ variantId?: string | undefined;
662
+ id?: string | undefined;
663
+ createdAt?: Date | undefined;
664
+ updatedAt?: Date | undefined;
665
+ }> | zod0.ZodSafeParseError<{
666
+ configId?: string | undefined;
667
+ variantId?: string | undefined;
668
+ id?: string | undefined;
669
+ createdAt?: Date | undefined;
670
+ updatedAt?: Date | undefined;
671
+ }> | zod0.ZodSafeParseSuccess<{
672
+ environmentId?: string | undefined;
673
+ configId?: string | undefined;
674
+ configVariantId?: string | undefined;
675
+ variantVersionId?: string | null | undefined;
676
+ weight?: number | undefined;
677
+ priority?: number | undefined;
678
+ enabled?: boolean | undefined;
679
+ conditions?: Record<string, unknown> | undefined;
680
+ id?: string | undefined;
681
+ createdAt?: Date | undefined;
682
+ updatedAt?: Date | undefined;
683
+ }> | zod0.ZodSafeParseError<{
684
+ environmentId?: string | undefined;
685
+ configId?: string | undefined;
686
+ configVariantId?: string | undefined;
687
+ variantVersionId?: string | null | undefined;
688
+ weight?: number | undefined;
689
+ priority?: number | undefined;
690
+ enabled?: boolean | undefined;
691
+ conditions?: Record<string, unknown> | undefined;
692
+ id?: string | undefined;
693
+ createdAt?: Date | undefined;
694
+ updatedAt?: Date | undefined;
695
+ }>;
696
+ /**
697
+ * Parse and validate data, throws on error
698
+ */
699
+ declare function parseTableData<T extends TableName>(table: T, data: unknown): {
700
+ slug: string;
701
+ id: string;
702
+ createdAt: Date;
703
+ updatedAt: Date;
704
+ name?: string | undefined;
705
+ } | {
706
+ name: string;
707
+ id: string;
708
+ createdAt: Date;
709
+ updatedAt: Date;
710
+ } | {
711
+ variantId: string;
712
+ version: number;
713
+ provider: string;
714
+ modelName: string;
715
+ jsonData: Record<string, unknown>;
716
+ id: string;
717
+ createdAt: Date;
718
+ updatedAt: Date;
719
+ } | {
720
+ environmentId: string;
721
+ keyName: string;
722
+ keyValue: string;
723
+ id: string;
724
+ createdAt: Date;
725
+ updatedAt: Date;
726
+ } | {
727
+ configId: string;
728
+ variantId: string;
729
+ id: string;
730
+ createdAt: Date;
731
+ updatedAt: Date;
732
+ } | {
733
+ environmentId: string;
734
+ configId: string;
735
+ configVariantId: string;
736
+ weight: number;
737
+ priority: number;
738
+ enabled: boolean;
739
+ conditions: Record<string, unknown>;
740
+ id: string;
741
+ createdAt: Date;
742
+ updatedAt: Date;
743
+ variantVersionId?: string | null | undefined;
744
+ };
745
+ /**
746
+ * Parse partial data, throws on error
747
+ */
748
+ declare function parsePartialTableData<T extends TableName>(table: T, data: unknown): {
749
+ name?: string | undefined;
750
+ id?: string | undefined;
751
+ createdAt?: Date | undefined;
752
+ updatedAt?: Date | undefined;
753
+ } | {
754
+ variantId?: string | undefined;
755
+ version?: number | undefined;
756
+ provider?: string | undefined;
757
+ modelName?: string | undefined;
758
+ jsonData?: Record<string, unknown> | undefined;
759
+ id?: string | undefined;
760
+ createdAt?: Date | undefined;
761
+ updatedAt?: Date | undefined;
762
+ } | {
763
+ environmentId?: string | undefined;
764
+ keyName?: string | undefined;
765
+ keyValue?: string | undefined;
766
+ id?: string | undefined;
767
+ createdAt?: Date | undefined;
768
+ updatedAt?: Date | undefined;
769
+ } | {
770
+ configId?: string | undefined;
771
+ variantId?: string | undefined;
772
+ id?: string | undefined;
773
+ createdAt?: Date | undefined;
774
+ updatedAt?: Date | undefined;
775
+ } | {
776
+ environmentId?: string | undefined;
777
+ configId?: string | undefined;
778
+ configVariantId?: string | undefined;
779
+ variantVersionId?: string | null | undefined;
780
+ weight?: number | undefined;
781
+ priority?: number | undefined;
782
+ enabled?: boolean | undefined;
783
+ conditions?: Record<string, unknown> | undefined;
784
+ id?: string | undefined;
785
+ createdAt?: Date | undefined;
786
+ updatedAt?: Date | undefined;
787
+ };
788
+ //#endregion
789
+ //#region src/db/migrations.d.ts
790
+ type DatabaseType$1 = 'postgres' | 'mysql' | 'sqlite' | 'mssql';
791
+ /**
792
+ * Options for migration operations
793
+ */
794
+ interface MigrationOptions {
795
+ /**
796
+ * PostgreSQL schema name to use.
797
+ * If provided, the schema will be created if it doesn't exist.
798
+ */
799
+ schema?: string;
800
+ }
801
+ declare function matchType(columnDataType: string, fieldType: string, dbType: DatabaseType$1): boolean;
802
+ interface MigrationResult {
803
+ toBeCreated: Array<{
804
+ table: string;
805
+ fields: Record<string, any>;
806
+ order: number;
807
+ }>;
808
+ toBeAdded: Array<{
809
+ table: string;
810
+ fields: Record<string, any>;
811
+ order: number;
812
+ }>;
813
+ runMigrations: () => Promise<void>;
814
+ compileMigrations: () => Promise<string>;
815
+ migrations: any[];
816
+ needsMigration: boolean;
817
+ }
818
+ declare function getMigrations(db: Kysely<Database>, dbType: DatabaseType$1, options?: MigrationOptions): Promise<MigrationResult>;
819
+ /**
820
+ * Run migrations if needed based on autoMigrate config
821
+ * @param db - Kysely database instance
822
+ * @param dbType - Database type
823
+ * @param autoMigrate - Auto-migrate configuration
824
+ * @param options - Migration options (schema, etc.)
825
+ * @returns true if migrations were run, false otherwise
826
+ */
827
+ declare function runAutoMigrations(db: Kysely<Database>, dbType: DatabaseType$1, autoMigrate: boolean | 'development', options?: MigrationOptions): Promise<{
828
+ ran: boolean;
829
+ tables: string[];
830
+ fields: string[];
831
+ }>;
832
+ //#endregion
833
+ //#region src/db/index.d.ts
834
+ /**
835
+ * Supported database types
836
+ */
837
+ type DatabaseType = 'postgres' | 'mysql' | 'sqlite' | 'mssql';
838
+ /**
839
+ * Options for creating a database connection
840
+ */
841
+ interface DatabaseOptions {
842
+ /**
843
+ * PostgreSQL schema name (sets search_path).
844
+ * Defaults to 'llmops'.
845
+ */
846
+ schema?: string;
847
+ }
848
+ /**
849
+ * Database connection options
850
+ */
851
+ type DatabaseConnection = {
852
+ type: 'postgres';
853
+ dialect: PostgresDialect;
854
+ } | {
855
+ type: 'mysql';
856
+ dialect: MysqlDialect;
857
+ } | {
858
+ type: 'sqlite';
859
+ dialect: SqliteDialect;
860
+ } | {
861
+ type: 'mssql';
862
+ dialect: MssqlDialect;
863
+ } | {
864
+ type: DatabaseType;
865
+ kysely: Kysely<Database>;
866
+ };
867
+ /**
868
+ * Create a Kysely database instance with type safety
869
+ */
870
+ declare function createDatabase(connection: DatabaseConnection): Kysely<Database>;
871
+ /**
872
+ * Auto-detect database type from connection object
873
+ */
874
+ declare function detectDatabaseType(db: unknown): DatabaseType | null;
875
+ /**
876
+ * Create database from raw connection
877
+ *
878
+ * @param rawConnection - The raw database connection (pg Pool, sqlite Database, etc.)
879
+ * @param options - Optional configuration (schema for PostgreSQL)
880
+ */
881
+ declare function createDatabaseFromConnection(rawConnection: any, options?: DatabaseOptions): Promise<Kysely<Database> | null>;
882
+ //#endregion
883
+ export { TargetingRulesTable as A, schemas as B, EnvironmentSecretsTable as C, Selectable as D, SCHEMA_METADATA as E, VariantsTable as F, variantVersionsSchema as H, configVariantsSchema as I, configsSchema as L, Variant as M, VariantVersion as N, TableName as O, VariantVersionsTable as P, environmentSecretsSchema as R, EnvironmentSecret as S, Insertable as T, variantsSchema as U, targetingRulesSchema as V, ConfigVariant as _, createDatabaseFromConnection as a, Database as b, MigrationResult as c, runAutoMigrations as d, parsePartialTableData as f, Config as g, validateTableData as h, createDatabase as i, Updateable as j, TargetingRule as k, getMigrations as l, validatePartialTableData as m, DatabaseOptions as n, detectDatabaseType as o, parseTableData as p, DatabaseType as r, MigrationOptions as s, DatabaseConnection as t, matchType as u, ConfigVariantsTable as v, EnvironmentsTable as w, Environment as x, ConfigsTable as y, environmentsSchema as z };