@astrojs/db 0.16.1 → 0.17.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.
@@ -187,6 +187,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
187
187
  }, "optional"> & {
188
188
  default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodType<SQL<any>, ZodTypeDef, SQL<any>>, SerializedSQL, SQL<any>>]>>;
189
189
  multiline: z.ZodOptional<z.ZodBoolean>;
190
+ enum: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
190
191
  }, "strip", z.ZodTypeAny, {
191
192
  unique: boolean;
192
193
  deprecated: boolean;
@@ -195,6 +196,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
195
196
  collection?: string | undefined;
196
197
  default?: string | SerializedSQL | undefined;
197
198
  multiline?: boolean | undefined;
199
+ enum?: [string, ...string[]] | undefined;
198
200
  }, {
199
201
  name?: string | undefined;
200
202
  label?: string | undefined;
@@ -203,6 +205,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
203
205
  collection?: string | undefined;
204
206
  default?: string | SQL<any> | undefined;
205
207
  multiline?: boolean | undefined;
208
+ enum?: [string, ...string[]] | undefined;
206
209
  }>, z.ZodUnion<[z.ZodObject<{
207
210
  primaryKey: z.ZodDefault<z.ZodOptional<z.ZodLiteral<false>>>;
208
211
  optional: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -237,6 +240,7 @@ export declare const textColumnSchema: z.ZodObject<{
237
240
  collection?: string | undefined;
238
241
  default?: string | SerializedSQL | undefined;
239
242
  multiline?: boolean | undefined;
243
+ enum?: [string, ...string[]] | undefined;
240
244
  } & ({
241
245
  optional: boolean;
242
246
  primaryKey: false;
@@ -253,6 +257,7 @@ export declare const textColumnSchema: z.ZodObject<{
253
257
  collection?: string | undefined;
254
258
  default?: string | SQL<any> | undefined;
255
259
  multiline?: boolean | undefined;
260
+ enum?: [string, ...string[]] | undefined;
256
261
  } & ({
257
262
  optional?: boolean | undefined;
258
263
  primaryKey?: false | undefined;
@@ -272,6 +277,7 @@ export declare const textColumnSchema: z.ZodObject<{
272
277
  collection?: string | undefined;
273
278
  default?: string | SerializedSQL | undefined;
274
279
  multiline?: boolean | undefined;
280
+ enum?: [string, ...string[]] | undefined;
275
281
  } & ({
276
282
  optional: boolean;
277
283
  primaryKey: false;
@@ -291,6 +297,7 @@ export declare const textColumnSchema: z.ZodObject<{
291
297
  collection?: string | undefined;
292
298
  default?: string | SQL<any> | undefined;
293
299
  multiline?: boolean | undefined;
300
+ enum?: [string, ...string[]] | undefined;
294
301
  } & ({
295
302
  optional?: boolean | undefined;
296
303
  primaryKey?: false | undefined;
@@ -536,6 +543,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
536
543
  collection?: string | undefined;
537
544
  default?: string | SerializedSQL | undefined;
538
545
  multiline?: boolean | undefined;
546
+ enum?: [string, ...string[]] | undefined;
539
547
  } & ({
540
548
  optional: boolean;
541
549
  primaryKey: false;
@@ -552,6 +560,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
552
560
  collection?: string | undefined;
553
561
  default?: string | SQL<any> | undefined;
554
562
  multiline?: boolean | undefined;
563
+ enum?: [string, ...string[]] | undefined;
555
564
  } & ({
556
565
  optional?: boolean | undefined;
557
566
  primaryKey?: false | undefined;
@@ -571,6 +580,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
571
580
  collection?: string | undefined;
572
581
  default?: string | SerializedSQL | undefined;
573
582
  multiline?: boolean | undefined;
583
+ enum?: [string, ...string[]] | undefined;
574
584
  } & ({
575
585
  optional: boolean;
576
586
  primaryKey: false;
@@ -590,6 +600,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
590
600
  collection?: string | undefined;
591
601
  default?: string | SQL<any> | undefined;
592
602
  multiline?: boolean | undefined;
603
+ enum?: [string, ...string[]] | undefined;
593
604
  } & ({
594
605
  optional?: boolean | undefined;
595
606
  primaryKey?: false | undefined;
@@ -710,6 +721,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
710
721
  collection?: string | undefined;
711
722
  default?: string | SerializedSQL | undefined;
712
723
  multiline?: boolean | undefined;
724
+ enum?: [string, ...string[]] | undefined;
713
725
  } & ({
714
726
  optional: boolean;
715
727
  primaryKey: false;
@@ -726,6 +738,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
726
738
  collection?: string | undefined;
727
739
  default?: string | SQL<any> | undefined;
728
740
  multiline?: boolean | undefined;
741
+ enum?: [string, ...string[]] | undefined;
729
742
  } & ({
730
743
  optional?: boolean | undefined;
731
744
  primaryKey?: false | undefined;
@@ -745,6 +758,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
745
758
  collection?: string | undefined;
746
759
  default?: string | SerializedSQL | undefined;
747
760
  multiline?: boolean | undefined;
761
+ enum?: [string, ...string[]] | undefined;
748
762
  } & ({
749
763
  optional: boolean;
750
764
  primaryKey: false;
@@ -764,6 +778,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
764
778
  collection?: string | undefined;
765
779
  default?: string | SQL<any> | undefined;
766
780
  multiline?: boolean | undefined;
781
+ enum?: [string, ...string[]] | undefined;
767
782
  } & ({
768
783
  optional?: boolean | undefined;
769
784
  primaryKey?: false | undefined;
@@ -980,6 +995,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
980
995
  collection?: string | undefined;
981
996
  default?: string | SerializedSQL | undefined;
982
997
  multiline?: boolean | undefined;
998
+ enum?: [string, ...string[]] | undefined;
983
999
  } & ({
984
1000
  optional: boolean;
985
1001
  primaryKey: false;
@@ -996,6 +1012,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
996
1012
  collection?: string | undefined;
997
1013
  default?: string | SQL<any> | undefined;
998
1014
  multiline?: boolean | undefined;
1015
+ enum?: [string, ...string[]] | undefined;
999
1016
  } & ({
1000
1017
  optional?: boolean | undefined;
1001
1018
  primaryKey?: false | undefined;
@@ -1015,6 +1032,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
1015
1032
  collection?: string | undefined;
1016
1033
  default?: string | SerializedSQL | undefined;
1017
1034
  multiline?: boolean | undefined;
1035
+ enum?: [string, ...string[]] | undefined;
1018
1036
  } & ({
1019
1037
  optional: boolean;
1020
1038
  primaryKey: false;
@@ -1034,6 +1052,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
1034
1052
  collection?: string | undefined;
1035
1053
  default?: string | SQL<any> | undefined;
1036
1054
  multiline?: boolean | undefined;
1055
+ enum?: [string, ...string[]] | undefined;
1037
1056
  } & ({
1038
1057
  optional?: boolean | undefined;
1039
1058
  primaryKey?: false | undefined;
@@ -1308,6 +1327,7 @@ export declare const tableSchema: z.ZodObject<{
1308
1327
  collection?: string | undefined;
1309
1328
  default?: string | SerializedSQL | undefined;
1310
1329
  multiline?: boolean | undefined;
1330
+ enum?: [string, ...string[]] | undefined;
1311
1331
  } & ({
1312
1332
  optional: boolean;
1313
1333
  primaryKey: false;
@@ -1324,6 +1344,7 @@ export declare const tableSchema: z.ZodObject<{
1324
1344
  collection?: string | undefined;
1325
1345
  default?: string | SQL<any> | undefined;
1326
1346
  multiline?: boolean | undefined;
1347
+ enum?: [string, ...string[]] | undefined;
1327
1348
  } & ({
1328
1349
  optional?: boolean | undefined;
1329
1350
  primaryKey?: false | undefined;
@@ -1343,6 +1364,7 @@ export declare const tableSchema: z.ZodObject<{
1343
1364
  collection?: string | undefined;
1344
1365
  default?: string | SerializedSQL | undefined;
1345
1366
  multiline?: boolean | undefined;
1367
+ enum?: [string, ...string[]] | undefined;
1346
1368
  } & ({
1347
1369
  optional: boolean;
1348
1370
  primaryKey: false;
@@ -1362,6 +1384,7 @@ export declare const tableSchema: z.ZodObject<{
1362
1384
  collection?: string | undefined;
1363
1385
  default?: string | SQL<any> | undefined;
1364
1386
  multiline?: boolean | undefined;
1387
+ enum?: [string, ...string[]] | undefined;
1365
1388
  } & ({
1366
1389
  optional?: boolean | undefined;
1367
1390
  primaryKey?: false | undefined;
@@ -1538,6 +1561,7 @@ export declare const tableSchema: z.ZodObject<{
1538
1561
  collection?: string | undefined;
1539
1562
  default?: string | SerializedSQL | undefined;
1540
1563
  multiline?: boolean | undefined;
1564
+ enum?: [string, ...string[]] | undefined;
1541
1565
  } & ({
1542
1566
  optional: boolean;
1543
1567
  primaryKey: false;
@@ -1620,6 +1644,7 @@ export declare const tableSchema: z.ZodObject<{
1620
1644
  collection?: string | undefined;
1621
1645
  default?: string | SQL<any> | undefined;
1622
1646
  multiline?: boolean | undefined;
1647
+ enum?: [string, ...string[]] | undefined;
1623
1648
  } & ({
1624
1649
  optional?: boolean | undefined;
1625
1650
  primaryKey?: false | undefined;
@@ -1797,6 +1822,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1797
1822
  collection?: string | undefined;
1798
1823
  default?: string | SerializedSQL | undefined;
1799
1824
  multiline?: boolean | undefined;
1825
+ enum?: [string, ...string[]] | undefined;
1800
1826
  } & ({
1801
1827
  optional: boolean;
1802
1828
  primaryKey: false;
@@ -1813,6 +1839,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1813
1839
  collection?: string | undefined;
1814
1840
  default?: string | SQL<any> | undefined;
1815
1841
  multiline?: boolean | undefined;
1842
+ enum?: [string, ...string[]] | undefined;
1816
1843
  } & ({
1817
1844
  optional?: boolean | undefined;
1818
1845
  primaryKey?: false | undefined;
@@ -1832,6 +1859,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1832
1859
  collection?: string | undefined;
1833
1860
  default?: string | SerializedSQL | undefined;
1834
1861
  multiline?: boolean | undefined;
1862
+ enum?: [string, ...string[]] | undefined;
1835
1863
  } & ({
1836
1864
  optional: boolean;
1837
1865
  primaryKey: false;
@@ -1851,6 +1879,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1851
1879
  collection?: string | undefined;
1852
1880
  default?: string | SQL<any> | undefined;
1853
1881
  multiline?: boolean | undefined;
1882
+ enum?: [string, ...string[]] | undefined;
1854
1883
  } & ({
1855
1884
  optional?: boolean | undefined;
1856
1885
  primaryKey?: false | undefined;
@@ -2027,6 +2056,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2027
2056
  collection?: string | undefined;
2028
2057
  default?: string | SerializedSQL | undefined;
2029
2058
  multiline?: boolean | undefined;
2059
+ enum?: [string, ...string[]] | undefined;
2030
2060
  } & ({
2031
2061
  optional: boolean;
2032
2062
  primaryKey: false;
@@ -2109,6 +2139,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2109
2139
  collection?: string | undefined;
2110
2140
  default?: string | SQL<any> | undefined;
2111
2141
  multiline?: boolean | undefined;
2142
+ enum?: [string, ...string[]] | undefined;
2112
2143
  } & ({
2113
2144
  optional?: boolean | undefined;
2114
2145
  primaryKey?: false | undefined;
@@ -2193,6 +2224,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2193
2224
  collection?: string | undefined;
2194
2225
  default?: string | SerializedSQL | undefined;
2195
2226
  multiline?: boolean | undefined;
2227
+ enum?: [string, ...string[]] | undefined;
2196
2228
  } & ({
2197
2229
  optional: boolean;
2198
2230
  primaryKey: false;
@@ -2370,6 +2402,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2370
2402
  collection?: string | undefined;
2371
2403
  default?: string | SerializedSQL | undefined;
2372
2404
  multiline?: boolean | undefined;
2405
+ enum?: [string, ...string[]] | undefined;
2373
2406
  } & ({
2374
2407
  optional: boolean;
2375
2408
  primaryKey: false;
@@ -2386,6 +2419,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2386
2419
  collection?: string | undefined;
2387
2420
  default?: string | SQL<any> | undefined;
2388
2421
  multiline?: boolean | undefined;
2422
+ enum?: [string, ...string[]] | undefined;
2389
2423
  } & ({
2390
2424
  optional?: boolean | undefined;
2391
2425
  primaryKey?: false | undefined;
@@ -2405,6 +2439,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2405
2439
  collection?: string | undefined;
2406
2440
  default?: string | SerializedSQL | undefined;
2407
2441
  multiline?: boolean | undefined;
2442
+ enum?: [string, ...string[]] | undefined;
2408
2443
  } & ({
2409
2444
  optional: boolean;
2410
2445
  primaryKey: false;
@@ -2424,6 +2459,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2424
2459
  collection?: string | undefined;
2425
2460
  default?: string | SQL<any> | undefined;
2426
2461
  multiline?: boolean | undefined;
2462
+ enum?: [string, ...string[]] | undefined;
2427
2463
  } & ({
2428
2464
  optional?: boolean | undefined;
2429
2465
  primaryKey?: false | undefined;
@@ -2600,6 +2636,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2600
2636
  collection?: string | undefined;
2601
2637
  default?: string | SerializedSQL | undefined;
2602
2638
  multiline?: boolean | undefined;
2639
+ enum?: [string, ...string[]] | undefined;
2603
2640
  } & ({
2604
2641
  optional: boolean;
2605
2642
  primaryKey: false;
@@ -2682,6 +2719,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2682
2719
  collection?: string | undefined;
2683
2720
  default?: string | SQL<any> | undefined;
2684
2721
  multiline?: boolean | undefined;
2722
+ enum?: [string, ...string[]] | undefined;
2685
2723
  } & ({
2686
2724
  optional?: boolean | undefined;
2687
2725
  primaryKey?: false | undefined;
@@ -2766,6 +2804,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2766
2804
  collection?: string | undefined;
2767
2805
  default?: string | SerializedSQL | undefined;
2768
2806
  multiline?: boolean | undefined;
2807
+ enum?: [string, ...string[]] | undefined;
2769
2808
  } & ({
2770
2809
  optional: boolean;
2771
2810
  primaryKey: false;
@@ -2851,6 +2890,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2851
2890
  collection?: string | undefined;
2852
2891
  default?: string | SerializedSQL | undefined;
2853
2892
  multiline?: boolean | undefined;
2893
+ enum?: [string, ...string[]] | undefined;
2854
2894
  } & ({
2855
2895
  optional: boolean;
2856
2896
  primaryKey: false;
@@ -2942,6 +2982,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2942
2982
  collection?: string | undefined;
2943
2983
  default?: string | SerializedSQL | undefined;
2944
2984
  multiline?: boolean | undefined;
2985
+ enum?: [string, ...string[]] | undefined;
2945
2986
  } & ({
2946
2987
  optional: boolean;
2947
2988
  primaryKey: false;
@@ -2,12 +2,12 @@ import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
2
2
  import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
3
3
  import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
4
4
  type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault' | 'hasRuntimeDefault' | 'isPrimaryKey'>;
5
- type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn<T & {
6
- data: string;
5
+ type AstroText<T extends GeneratedConfig<'string'>, E extends [string, ...string[]] | never> = SQLiteColumn<T & {
6
+ data: E extends infer EnumValues ? EnumValues extends [string, ...string[]] ? EnumValues[number] : never : string;
7
7
  dataType: 'string';
8
8
  columnType: 'SQLiteText';
9
9
  driverParam: string;
10
- enumValues: never;
10
+ enumValues: E extends [string, ...string[]] ? E : never;
11
11
  baseColumn: never;
12
12
  isAutoincrement: boolean;
13
13
  identity: undefined;
@@ -57,13 +57,15 @@ type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
57
57
  identity: undefined;
58
58
  generated: undefined;
59
59
  }>;
60
- type Column<T extends DBColumn['type'], S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
60
+ type Column<T extends DBColumn['type'], E extends [string, ...string[]] | never, S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S, E> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
61
61
  export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
62
62
  name: TTableName;
63
63
  schema: undefined;
64
64
  dialect: 'sqlite';
65
65
  columns: {
66
- [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], {
66
+ [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
67
+ enum: [string, ...string[]];
68
+ } ? TColumns[K]['schema']['enum'] : never, {
67
69
  tableName: TTableName;
68
70
  name: K;
69
71
  isPrimaryKey: TColumns[K]['schema'] extends {
@@ -27,7 +27,7 @@ function printHelp({
27
27
  message.push(
28
28
  linebreak(),
29
29
  ` ${bgGreen(black(` ${commandName} `))} ${green(
30
- `v${"0.16.1"}`
30
+ `v${"0.17.0"}`
31
31
  )} ${headline}`
32
32
  );
33
33
  }
@@ -52,6 +52,7 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
52
52
  label?: string | undefined;
53
53
  collection?: string | undefined;
54
54
  multiline?: boolean | undefined;
55
+ enum?: [string, ...string[]] | undefined;
55
56
  } & ({
56
57
  optional: boolean;
57
58
  primaryKey: false;
@@ -34,6 +34,7 @@ export declare function getReferencesConfig(column: DBColumn): {
34
34
  label?: string | undefined;
35
35
  collection?: string | undefined;
36
36
  multiline?: boolean | undefined;
37
+ enum?: [string, ...string[]] | undefined;
37
38
  } & ({
38
39
  optional: boolean;
39
40
  primaryKey: false;
@@ -187,6 +187,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
187
187
  }, "optional"> & {
188
188
  default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodType<SQL<any>, ZodTypeDef, SQL<any>>, SerializedSQL, SQL<any>>]>>;
189
189
  multiline: z.ZodOptional<z.ZodBoolean>;
190
+ enum: z.ZodOptional<z.ZodTuple<[z.ZodString], z.ZodString>>;
190
191
  }, "strip", z.ZodTypeAny, {
191
192
  unique: boolean;
192
193
  deprecated: boolean;
@@ -195,6 +196,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
195
196
  label?: string | undefined;
196
197
  collection?: string | undefined;
197
198
  multiline?: boolean | undefined;
199
+ enum?: [string, ...string[]] | undefined;
198
200
  }, {
199
201
  default?: string | SQL<any> | undefined;
200
202
  name?: string | undefined;
@@ -203,6 +205,7 @@ declare const textColumnBaseSchema: z.ZodIntersection<z.ZodObject<Omit<{
203
205
  deprecated?: boolean | undefined;
204
206
  collection?: string | undefined;
205
207
  multiline?: boolean | undefined;
208
+ enum?: [string, ...string[]] | undefined;
206
209
  }>, z.ZodUnion<[z.ZodObject<{
207
210
  primaryKey: z.ZodDefault<z.ZodOptional<z.ZodLiteral<false>>>;
208
211
  optional: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
@@ -237,6 +240,7 @@ export declare const textColumnSchema: z.ZodObject<{
237
240
  label?: string | undefined;
238
241
  collection?: string | undefined;
239
242
  multiline?: boolean | undefined;
243
+ enum?: [string, ...string[]] | undefined;
240
244
  } & ({
241
245
  optional: boolean;
242
246
  primaryKey: false;
@@ -253,6 +257,7 @@ export declare const textColumnSchema: z.ZodObject<{
253
257
  deprecated?: boolean | undefined;
254
258
  collection?: string | undefined;
255
259
  multiline?: boolean | undefined;
260
+ enum?: [string, ...string[]] | undefined;
256
261
  } & ({
257
262
  optional?: boolean | undefined;
258
263
  primaryKey?: false | undefined;
@@ -272,6 +277,7 @@ export declare const textColumnSchema: z.ZodObject<{
272
277
  label?: string | undefined;
273
278
  collection?: string | undefined;
274
279
  multiline?: boolean | undefined;
280
+ enum?: [string, ...string[]] | undefined;
275
281
  } & ({
276
282
  optional: boolean;
277
283
  primaryKey: false;
@@ -291,6 +297,7 @@ export declare const textColumnSchema: z.ZodObject<{
291
297
  deprecated?: boolean | undefined;
292
298
  collection?: string | undefined;
293
299
  multiline?: boolean | undefined;
300
+ enum?: [string, ...string[]] | undefined;
294
301
  } & ({
295
302
  optional?: boolean | undefined;
296
303
  primaryKey?: false | undefined;
@@ -536,6 +543,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
536
543
  label?: string | undefined;
537
544
  collection?: string | undefined;
538
545
  multiline?: boolean | undefined;
546
+ enum?: [string, ...string[]] | undefined;
539
547
  } & ({
540
548
  optional: boolean;
541
549
  primaryKey: false;
@@ -552,6 +560,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
552
560
  deprecated?: boolean | undefined;
553
561
  collection?: string | undefined;
554
562
  multiline?: boolean | undefined;
563
+ enum?: [string, ...string[]] | undefined;
555
564
  } & ({
556
565
  optional?: boolean | undefined;
557
566
  primaryKey?: false | undefined;
@@ -571,6 +580,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
571
580
  label?: string | undefined;
572
581
  collection?: string | undefined;
573
582
  multiline?: boolean | undefined;
583
+ enum?: [string, ...string[]] | undefined;
574
584
  } & ({
575
585
  optional: boolean;
576
586
  primaryKey: false;
@@ -590,6 +600,7 @@ export declare const columnSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
590
600
  deprecated?: boolean | undefined;
591
601
  collection?: string | undefined;
592
602
  multiline?: boolean | undefined;
603
+ enum?: [string, ...string[]] | undefined;
593
604
  } & ({
594
605
  optional?: boolean | undefined;
595
606
  primaryKey?: false | undefined;
@@ -710,6 +721,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
710
721
  label?: string | undefined;
711
722
  collection?: string | undefined;
712
723
  multiline?: boolean | undefined;
724
+ enum?: [string, ...string[]] | undefined;
713
725
  } & ({
714
726
  optional: boolean;
715
727
  primaryKey: false;
@@ -726,6 +738,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
726
738
  deprecated?: boolean | undefined;
727
739
  collection?: string | undefined;
728
740
  multiline?: boolean | undefined;
741
+ enum?: [string, ...string[]] | undefined;
729
742
  } & ({
730
743
  optional?: boolean | undefined;
731
744
  primaryKey?: false | undefined;
@@ -745,6 +758,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
745
758
  label?: string | undefined;
746
759
  collection?: string | undefined;
747
760
  multiline?: boolean | undefined;
761
+ enum?: [string, ...string[]] | undefined;
748
762
  } & ({
749
763
  optional: boolean;
750
764
  primaryKey: false;
@@ -764,6 +778,7 @@ export declare const referenceableColumnSchema: z.ZodUnion<[z.ZodObject<{
764
778
  deprecated?: boolean | undefined;
765
779
  collection?: string | undefined;
766
780
  multiline?: boolean | undefined;
781
+ enum?: [string, ...string[]] | undefined;
767
782
  } & ({
768
783
  optional?: boolean | undefined;
769
784
  primaryKey?: false | undefined;
@@ -980,6 +995,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
980
995
  label?: string | undefined;
981
996
  collection?: string | undefined;
982
997
  multiline?: boolean | undefined;
998
+ enum?: [string, ...string[]] | undefined;
983
999
  } & ({
984
1000
  optional: boolean;
985
1001
  primaryKey: false;
@@ -996,6 +1012,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
996
1012
  deprecated?: boolean | undefined;
997
1013
  collection?: string | undefined;
998
1014
  multiline?: boolean | undefined;
1015
+ enum?: [string, ...string[]] | undefined;
999
1016
  } & ({
1000
1017
  optional?: boolean | undefined;
1001
1018
  primaryKey?: false | undefined;
@@ -1015,6 +1032,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
1015
1032
  label?: string | undefined;
1016
1033
  collection?: string | undefined;
1017
1034
  multiline?: boolean | undefined;
1035
+ enum?: [string, ...string[]] | undefined;
1018
1036
  } & ({
1019
1037
  optional: boolean;
1020
1038
  primaryKey: false;
@@ -1034,6 +1052,7 @@ export declare const columnsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedU
1034
1052
  deprecated?: boolean | undefined;
1035
1053
  collection?: string | undefined;
1036
1054
  multiline?: boolean | undefined;
1055
+ enum?: [string, ...string[]] | undefined;
1037
1056
  } & ({
1038
1057
  optional?: boolean | undefined;
1039
1058
  primaryKey?: false | undefined;
@@ -1308,6 +1327,7 @@ export declare const tableSchema: z.ZodObject<{
1308
1327
  label?: string | undefined;
1309
1328
  collection?: string | undefined;
1310
1329
  multiline?: boolean | undefined;
1330
+ enum?: [string, ...string[]] | undefined;
1311
1331
  } & ({
1312
1332
  optional: boolean;
1313
1333
  primaryKey: false;
@@ -1324,6 +1344,7 @@ export declare const tableSchema: z.ZodObject<{
1324
1344
  deprecated?: boolean | undefined;
1325
1345
  collection?: string | undefined;
1326
1346
  multiline?: boolean | undefined;
1347
+ enum?: [string, ...string[]] | undefined;
1327
1348
  } & ({
1328
1349
  optional?: boolean | undefined;
1329
1350
  primaryKey?: false | undefined;
@@ -1343,6 +1364,7 @@ export declare const tableSchema: z.ZodObject<{
1343
1364
  label?: string | undefined;
1344
1365
  collection?: string | undefined;
1345
1366
  multiline?: boolean | undefined;
1367
+ enum?: [string, ...string[]] | undefined;
1346
1368
  } & ({
1347
1369
  optional: boolean;
1348
1370
  primaryKey: false;
@@ -1362,6 +1384,7 @@ export declare const tableSchema: z.ZodObject<{
1362
1384
  deprecated?: boolean | undefined;
1363
1385
  collection?: string | undefined;
1364
1386
  multiline?: boolean | undefined;
1387
+ enum?: [string, ...string[]] | undefined;
1365
1388
  } & ({
1366
1389
  optional?: boolean | undefined;
1367
1390
  primaryKey?: false | undefined;
@@ -1538,6 +1561,7 @@ export declare const tableSchema: z.ZodObject<{
1538
1561
  label?: string | undefined;
1539
1562
  collection?: string | undefined;
1540
1563
  multiline?: boolean | undefined;
1564
+ enum?: [string, ...string[]] | undefined;
1541
1565
  } & ({
1542
1566
  optional: boolean;
1543
1567
  primaryKey: false;
@@ -1620,6 +1644,7 @@ export declare const tableSchema: z.ZodObject<{
1620
1644
  deprecated?: boolean | undefined;
1621
1645
  collection?: string | undefined;
1622
1646
  multiline?: boolean | undefined;
1647
+ enum?: [string, ...string[]] | undefined;
1623
1648
  } & ({
1624
1649
  optional?: boolean | undefined;
1625
1650
  primaryKey?: false | undefined;
@@ -1797,6 +1822,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1797
1822
  label?: string | undefined;
1798
1823
  collection?: string | undefined;
1799
1824
  multiline?: boolean | undefined;
1825
+ enum?: [string, ...string[]] | undefined;
1800
1826
  } & ({
1801
1827
  optional: boolean;
1802
1828
  primaryKey: false;
@@ -1813,6 +1839,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1813
1839
  deprecated?: boolean | undefined;
1814
1840
  collection?: string | undefined;
1815
1841
  multiline?: boolean | undefined;
1842
+ enum?: [string, ...string[]] | undefined;
1816
1843
  } & ({
1817
1844
  optional?: boolean | undefined;
1818
1845
  primaryKey?: false | undefined;
@@ -1832,6 +1859,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1832
1859
  label?: string | undefined;
1833
1860
  collection?: string | undefined;
1834
1861
  multiline?: boolean | undefined;
1862
+ enum?: [string, ...string[]] | undefined;
1835
1863
  } & ({
1836
1864
  optional: boolean;
1837
1865
  primaryKey: false;
@@ -1851,6 +1879,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
1851
1879
  deprecated?: boolean | undefined;
1852
1880
  collection?: string | undefined;
1853
1881
  multiline?: boolean | undefined;
1882
+ enum?: [string, ...string[]] | undefined;
1854
1883
  } & ({
1855
1884
  optional?: boolean | undefined;
1856
1885
  primaryKey?: false | undefined;
@@ -2027,6 +2056,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2027
2056
  label?: string | undefined;
2028
2057
  collection?: string | undefined;
2029
2058
  multiline?: boolean | undefined;
2059
+ enum?: [string, ...string[]] | undefined;
2030
2060
  } & ({
2031
2061
  optional: boolean;
2032
2062
  primaryKey: false;
@@ -2109,6 +2139,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2109
2139
  deprecated?: boolean | undefined;
2110
2140
  collection?: string | undefined;
2111
2141
  multiline?: boolean | undefined;
2142
+ enum?: [string, ...string[]] | undefined;
2112
2143
  } & ({
2113
2144
  optional?: boolean | undefined;
2114
2145
  primaryKey?: false | undefined;
@@ -2193,6 +2224,7 @@ export declare const tablesSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOb
2193
2224
  label?: string | undefined;
2194
2225
  collection?: string | undefined;
2195
2226
  multiline?: boolean | undefined;
2227
+ enum?: [string, ...string[]] | undefined;
2196
2228
  } & ({
2197
2229
  optional: boolean;
2198
2230
  primaryKey: false;
@@ -2370,6 +2402,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2370
2402
  label?: string | undefined;
2371
2403
  collection?: string | undefined;
2372
2404
  multiline?: boolean | undefined;
2405
+ enum?: [string, ...string[]] | undefined;
2373
2406
  } & ({
2374
2407
  optional: boolean;
2375
2408
  primaryKey: false;
@@ -2386,6 +2419,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2386
2419
  deprecated?: boolean | undefined;
2387
2420
  collection?: string | undefined;
2388
2421
  multiline?: boolean | undefined;
2422
+ enum?: [string, ...string[]] | undefined;
2389
2423
  } & ({
2390
2424
  optional?: boolean | undefined;
2391
2425
  primaryKey?: false | undefined;
@@ -2405,6 +2439,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2405
2439
  label?: string | undefined;
2406
2440
  collection?: string | undefined;
2407
2441
  multiline?: boolean | undefined;
2442
+ enum?: [string, ...string[]] | undefined;
2408
2443
  } & ({
2409
2444
  optional: boolean;
2410
2445
  primaryKey: false;
@@ -2424,6 +2459,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2424
2459
  deprecated?: boolean | undefined;
2425
2460
  collection?: string | undefined;
2426
2461
  multiline?: boolean | undefined;
2462
+ enum?: [string, ...string[]] | undefined;
2427
2463
  } & ({
2428
2464
  optional?: boolean | undefined;
2429
2465
  primaryKey?: false | undefined;
@@ -2600,6 +2636,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2600
2636
  label?: string | undefined;
2601
2637
  collection?: string | undefined;
2602
2638
  multiline?: boolean | undefined;
2639
+ enum?: [string, ...string[]] | undefined;
2603
2640
  } & ({
2604
2641
  optional: boolean;
2605
2642
  primaryKey: false;
@@ -2682,6 +2719,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2682
2719
  deprecated?: boolean | undefined;
2683
2720
  collection?: string | undefined;
2684
2721
  multiline?: boolean | undefined;
2722
+ enum?: [string, ...string[]] | undefined;
2685
2723
  } & ({
2686
2724
  optional?: boolean | undefined;
2687
2725
  primaryKey?: false | undefined;
@@ -2766,6 +2804,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2766
2804
  label?: string | undefined;
2767
2805
  collection?: string | undefined;
2768
2806
  multiline?: boolean | undefined;
2807
+ enum?: [string, ...string[]] | undefined;
2769
2808
  } & ({
2770
2809
  optional: boolean;
2771
2810
  primaryKey: false;
@@ -2851,6 +2890,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2851
2890
  label?: string | undefined;
2852
2891
  collection?: string | undefined;
2853
2892
  multiline?: boolean | undefined;
2893
+ enum?: [string, ...string[]] | undefined;
2854
2894
  } & ({
2855
2895
  optional: boolean;
2856
2896
  primaryKey: false;
@@ -2942,6 +2982,7 @@ export declare const dbConfigSchema: z.ZodEffects<z.ZodObject<{
2942
2982
  label?: string | undefined;
2943
2983
  collection?: string | undefined;
2944
2984
  multiline?: boolean | undefined;
2985
+ enum?: [string, ...string[]] | undefined;
2945
2986
  } & ({
2946
2987
  optional: boolean;
2947
2988
  primaryKey: false;
@@ -55,7 +55,9 @@ const numberColumnSchema = z.object({
55
55
  });
56
56
  const textColumnBaseSchema = baseColumnSchema.omit({ optional: true }).extend({
57
57
  default: z.union([z.string(), sqlSchema]).optional(),
58
- multiline: z.boolean().optional()
58
+ multiline: z.boolean().optional(),
59
+ enum: z.tuple([z.string()]).rest(z.string()).optional()
60
+ // At least one value required,
59
61
  }).and(
60
62
  z.union([
61
63
  z.object({
@@ -65,7 +65,7 @@ function columnMapper(columnName, column) {
65
65
  let c;
66
66
  switch (column.type) {
67
67
  case "text": {
68
- c = text(columnName);
68
+ c = text(columnName, { enum: column.schema.enum });
69
69
  if (column.schema.default !== void 0)
70
70
  c = c.default(handleSerializedSQL(column.schema.default));
71
71
  if (column.schema.primaryKey === true) c = c.primaryKey();
@@ -2,12 +2,12 @@ import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
2
2
  import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
3
3
  import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
4
4
  type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault' | 'hasRuntimeDefault' | 'isPrimaryKey'>;
5
- type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn<T & {
6
- data: string;
5
+ type AstroText<T extends GeneratedConfig<'string'>, E extends [string, ...string[]] | never> = SQLiteColumn<T & {
6
+ data: E extends infer EnumValues ? EnumValues extends [string, ...string[]] ? EnumValues[number] : never : string;
7
7
  dataType: 'string';
8
8
  columnType: 'SQLiteText';
9
9
  driverParam: string;
10
- enumValues: never;
10
+ enumValues: E extends [string, ...string[]] ? E : never;
11
11
  baseColumn: never;
12
12
  isAutoincrement: boolean;
13
13
  identity: undefined;
@@ -57,13 +57,15 @@ type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
57
57
  identity: undefined;
58
58
  generated: undefined;
59
59
  }>;
60
- type Column<T extends DBColumn['type'], S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
60
+ type Column<T extends DBColumn['type'], E extends [string, ...string[]] | never, S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S, E> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
61
61
  export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
62
62
  name: TTableName;
63
63
  schema: undefined;
64
64
  dialect: 'sqlite';
65
65
  columns: {
66
- [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], {
66
+ [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
67
+ enum: [string, ...string[]];
68
+ } ? TColumns[K]['schema']['enum'] : never, {
67
69
  tableName: TTableName;
68
70
  name: K;
69
71
  isPrimaryKey: TColumns[K]['schema'] extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Add libSQL support to your Astro site",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -78,8 +78,8 @@
78
78
  "cheerio": "1.0.0",
79
79
  "typescript": "^5.8.3",
80
80
  "vite": "^6.3.4",
81
- "astro": "5.12.8",
82
- "astro-scripts": "0.0.14"
81
+ "astro-scripts": "0.0.14",
82
+ "astro": "5.12.9"
83
83
  },
84
84
  "scripts": {
85
85
  "types:virtual": "tsc -p ./tsconfig.virtual.json",