@astrojs/db 0.1.2 → 0.1.3
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.
- package/dist/cli/commands/push/index.js +11 -11
- package/dist/cli/commands/shell/index.d.ts +6 -0
- package/dist/cli/commands/shell/index.js +17 -0
- package/dist/cli/commands/sync/index.js +4 -3
- package/dist/cli/commands/verify/index.js +2 -5
- package/dist/cli/index.js +4 -0
- package/dist/cli/queries.d.ts +4 -5
- package/dist/cli/queries.js +66 -113
- package/dist/config.d.ts +72 -0
- package/dist/config.js +3 -1
- package/dist/integration.js +7 -1
- package/dist/internal.d.ts +11 -15
- package/dist/internal.js +51 -20
- package/dist/migrations.d.ts +7 -4
- package/dist/migrations.js +17 -1
- package/dist/typegen.js +16 -33
- package/dist/types.d.ts +106 -6
- package/dist/types.js +4 -2
- package/package.json +2 -2
- package/dist/cli/sync/index.js +0 -0
- package/dist/cli/sync/migrate.js +0 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColumnDataType, ColumnBaseConfig } from 'drizzle-orm';
|
|
2
|
-
import type { SQLiteColumn, SQLiteTableWithColumns
|
|
2
|
+
import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const booleanFieldSchema: z.ZodObject<{
|
|
5
5
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -26,18 +26,21 @@ declare const numberFieldSchema: z.ZodObject<{
|
|
|
26
26
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
27
27
|
type: z.ZodLiteral<"number">;
|
|
28
28
|
default: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
29
30
|
}, "strip", z.ZodTypeAny, {
|
|
30
31
|
type: "number";
|
|
31
32
|
label?: string | undefined;
|
|
32
33
|
optional?: boolean | undefined;
|
|
33
34
|
unique?: boolean | undefined;
|
|
34
35
|
default?: number | undefined;
|
|
36
|
+
primaryKey?: boolean | undefined;
|
|
35
37
|
}, {
|
|
36
38
|
type: "number";
|
|
37
39
|
label?: string | undefined;
|
|
38
40
|
optional?: boolean | undefined;
|
|
39
41
|
unique?: boolean | undefined;
|
|
40
42
|
default?: number | undefined;
|
|
43
|
+
primaryKey?: boolean | undefined;
|
|
41
44
|
}>;
|
|
42
45
|
declare const textFieldSchema: z.ZodObject<{
|
|
43
46
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -46,6 +49,7 @@ declare const textFieldSchema: z.ZodObject<{
|
|
|
46
49
|
type: z.ZodLiteral<"text">;
|
|
47
50
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
48
51
|
default: z.ZodOptional<z.ZodString>;
|
|
52
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
49
53
|
}, "strip", z.ZodTypeAny, {
|
|
50
54
|
type: "text";
|
|
51
55
|
label?: string | undefined;
|
|
@@ -53,6 +57,7 @@ declare const textFieldSchema: z.ZodObject<{
|
|
|
53
57
|
unique?: boolean | undefined;
|
|
54
58
|
multiline?: boolean | undefined;
|
|
55
59
|
default?: string | undefined;
|
|
60
|
+
primaryKey?: boolean | undefined;
|
|
56
61
|
}, {
|
|
57
62
|
type: "text";
|
|
58
63
|
label?: string | undefined;
|
|
@@ -60,6 +65,7 @@ declare const textFieldSchema: z.ZodObject<{
|
|
|
60
65
|
unique?: boolean | undefined;
|
|
61
66
|
multiline?: boolean | undefined;
|
|
62
67
|
default?: string | undefined;
|
|
68
|
+
primaryKey?: boolean | undefined;
|
|
63
69
|
}>;
|
|
64
70
|
declare const dateFieldSchema: z.ZodObject<{
|
|
65
71
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -123,18 +129,21 @@ declare const fieldSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
123
129
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
124
130
|
type: z.ZodLiteral<"number">;
|
|
125
131
|
default: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
126
133
|
}, "strip", z.ZodTypeAny, {
|
|
127
134
|
type: "number";
|
|
128
135
|
label?: string | undefined;
|
|
129
136
|
optional?: boolean | undefined;
|
|
130
137
|
unique?: boolean | undefined;
|
|
131
138
|
default?: number | undefined;
|
|
139
|
+
primaryKey?: boolean | undefined;
|
|
132
140
|
}, {
|
|
133
141
|
type: "number";
|
|
134
142
|
label?: string | undefined;
|
|
135
143
|
optional?: boolean | undefined;
|
|
136
144
|
unique?: boolean | undefined;
|
|
137
145
|
default?: number | undefined;
|
|
146
|
+
primaryKey?: boolean | undefined;
|
|
138
147
|
}>, z.ZodObject<{
|
|
139
148
|
label: z.ZodOptional<z.ZodString>;
|
|
140
149
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -142,6 +151,7 @@ declare const fieldSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
142
151
|
type: z.ZodLiteral<"text">;
|
|
143
152
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
144
153
|
default: z.ZodOptional<z.ZodString>;
|
|
154
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
145
155
|
}, "strip", z.ZodTypeAny, {
|
|
146
156
|
type: "text";
|
|
147
157
|
label?: string | undefined;
|
|
@@ -149,6 +159,7 @@ declare const fieldSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
149
159
|
unique?: boolean | undefined;
|
|
150
160
|
multiline?: boolean | undefined;
|
|
151
161
|
default?: string | undefined;
|
|
162
|
+
primaryKey?: boolean | undefined;
|
|
152
163
|
}, {
|
|
153
164
|
type: "text";
|
|
154
165
|
label?: string | undefined;
|
|
@@ -156,6 +167,7 @@ declare const fieldSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
156
167
|
unique?: boolean | undefined;
|
|
157
168
|
multiline?: boolean | undefined;
|
|
158
169
|
default?: string | undefined;
|
|
170
|
+
primaryKey?: boolean | undefined;
|
|
159
171
|
}>, z.ZodObject<{
|
|
160
172
|
label: z.ZodOptional<z.ZodString>;
|
|
161
173
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -217,18 +229,21 @@ declare const fieldsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
217
229
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
218
230
|
type: z.ZodLiteral<"number">;
|
|
219
231
|
default: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
220
233
|
}, "strip", z.ZodTypeAny, {
|
|
221
234
|
type: "number";
|
|
222
235
|
label?: string | undefined;
|
|
223
236
|
optional?: boolean | undefined;
|
|
224
237
|
unique?: boolean | undefined;
|
|
225
238
|
default?: number | undefined;
|
|
239
|
+
primaryKey?: boolean | undefined;
|
|
226
240
|
}, {
|
|
227
241
|
type: "number";
|
|
228
242
|
label?: string | undefined;
|
|
229
243
|
optional?: boolean | undefined;
|
|
230
244
|
unique?: boolean | undefined;
|
|
231
245
|
default?: number | undefined;
|
|
246
|
+
primaryKey?: boolean | undefined;
|
|
232
247
|
}>, z.ZodObject<{
|
|
233
248
|
label: z.ZodOptional<z.ZodString>;
|
|
234
249
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -236,6 +251,7 @@ declare const fieldsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
236
251
|
type: z.ZodLiteral<"text">;
|
|
237
252
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
238
253
|
default: z.ZodOptional<z.ZodString>;
|
|
254
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
239
255
|
}, "strip", z.ZodTypeAny, {
|
|
240
256
|
type: "text";
|
|
241
257
|
label?: string | undefined;
|
|
@@ -243,6 +259,7 @@ declare const fieldsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
243
259
|
unique?: boolean | undefined;
|
|
244
260
|
multiline?: boolean | undefined;
|
|
245
261
|
default?: string | undefined;
|
|
262
|
+
primaryKey?: boolean | undefined;
|
|
246
263
|
}, {
|
|
247
264
|
type: "text";
|
|
248
265
|
label?: string | undefined;
|
|
@@ -250,6 +267,7 @@ declare const fieldsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
|
250
267
|
unique?: boolean | undefined;
|
|
251
268
|
multiline?: boolean | undefined;
|
|
252
269
|
default?: string | undefined;
|
|
270
|
+
primaryKey?: boolean | undefined;
|
|
253
271
|
}>, z.ZodObject<{
|
|
254
272
|
label: z.ZodOptional<z.ZodString>;
|
|
255
273
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -312,18 +330,21 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
312
330
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
313
331
|
type: z.ZodLiteral<"number">;
|
|
314
332
|
default: z.ZodOptional<z.ZodNumber>;
|
|
333
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
315
334
|
}, "strip", z.ZodTypeAny, {
|
|
316
335
|
type: "number";
|
|
317
336
|
label?: string | undefined;
|
|
318
337
|
optional?: boolean | undefined;
|
|
319
338
|
unique?: boolean | undefined;
|
|
320
339
|
default?: number | undefined;
|
|
340
|
+
primaryKey?: boolean | undefined;
|
|
321
341
|
}, {
|
|
322
342
|
type: "number";
|
|
323
343
|
label?: string | undefined;
|
|
324
344
|
optional?: boolean | undefined;
|
|
325
345
|
unique?: boolean | undefined;
|
|
326
346
|
default?: number | undefined;
|
|
347
|
+
primaryKey?: boolean | undefined;
|
|
327
348
|
}>, z.ZodObject<{
|
|
328
349
|
label: z.ZodOptional<z.ZodString>;
|
|
329
350
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -331,6 +352,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
331
352
|
type: z.ZodLiteral<"text">;
|
|
332
353
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
333
354
|
default: z.ZodOptional<z.ZodString>;
|
|
355
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
334
356
|
}, "strip", z.ZodTypeAny, {
|
|
335
357
|
type: "text";
|
|
336
358
|
label?: string | undefined;
|
|
@@ -338,6 +360,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
338
360
|
unique?: boolean | undefined;
|
|
339
361
|
multiline?: boolean | undefined;
|
|
340
362
|
default?: string | undefined;
|
|
363
|
+
primaryKey?: boolean | undefined;
|
|
341
364
|
}, {
|
|
342
365
|
type: "text";
|
|
343
366
|
label?: string | undefined;
|
|
@@ -345,6 +368,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
345
368
|
unique?: boolean | undefined;
|
|
346
369
|
multiline?: boolean | undefined;
|
|
347
370
|
default?: string | undefined;
|
|
371
|
+
primaryKey?: boolean | undefined;
|
|
348
372
|
}>, z.ZodObject<{
|
|
349
373
|
label: z.ZodOptional<z.ZodString>;
|
|
350
374
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -397,6 +421,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
397
421
|
optional?: boolean | undefined;
|
|
398
422
|
unique?: boolean | undefined;
|
|
399
423
|
default?: number | undefined;
|
|
424
|
+
primaryKey?: boolean | undefined;
|
|
400
425
|
} | {
|
|
401
426
|
type: "text";
|
|
402
427
|
label?: string | undefined;
|
|
@@ -404,6 +429,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
404
429
|
unique?: boolean | undefined;
|
|
405
430
|
multiline?: boolean | undefined;
|
|
406
431
|
default?: string | undefined;
|
|
432
|
+
primaryKey?: boolean | undefined;
|
|
407
433
|
} | {
|
|
408
434
|
type: "date";
|
|
409
435
|
label?: string | undefined;
|
|
@@ -432,6 +458,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
432
458
|
optional?: boolean | undefined;
|
|
433
459
|
unique?: boolean | undefined;
|
|
434
460
|
default?: number | undefined;
|
|
461
|
+
primaryKey?: boolean | undefined;
|
|
435
462
|
} | {
|
|
436
463
|
type: "text";
|
|
437
464
|
label?: string | undefined;
|
|
@@ -439,6 +466,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
439
466
|
unique?: boolean | undefined;
|
|
440
467
|
multiline?: boolean | undefined;
|
|
441
468
|
default?: string | undefined;
|
|
469
|
+
primaryKey?: boolean | undefined;
|
|
442
470
|
} | {
|
|
443
471
|
type: "date";
|
|
444
472
|
label?: string | undefined;
|
|
@@ -480,18 +508,21 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
480
508
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
481
509
|
type: z.ZodLiteral<"number">;
|
|
482
510
|
default: z.ZodOptional<z.ZodNumber>;
|
|
511
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
483
512
|
}, "strip", z.ZodTypeAny, {
|
|
484
513
|
type: "number";
|
|
485
514
|
label?: string | undefined;
|
|
486
515
|
optional?: boolean | undefined;
|
|
487
516
|
unique?: boolean | undefined;
|
|
488
517
|
default?: number | undefined;
|
|
518
|
+
primaryKey?: boolean | undefined;
|
|
489
519
|
}, {
|
|
490
520
|
type: "number";
|
|
491
521
|
label?: string | undefined;
|
|
492
522
|
optional?: boolean | undefined;
|
|
493
523
|
unique?: boolean | undefined;
|
|
494
524
|
default?: number | undefined;
|
|
525
|
+
primaryKey?: boolean | undefined;
|
|
495
526
|
}>, z.ZodObject<{
|
|
496
527
|
label: z.ZodOptional<z.ZodString>;
|
|
497
528
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -499,6 +530,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
499
530
|
type: z.ZodLiteral<"text">;
|
|
500
531
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
501
532
|
default: z.ZodOptional<z.ZodString>;
|
|
533
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
502
534
|
}, "strip", z.ZodTypeAny, {
|
|
503
535
|
type: "text";
|
|
504
536
|
label?: string | undefined;
|
|
@@ -506,6 +538,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
506
538
|
unique?: boolean | undefined;
|
|
507
539
|
multiline?: boolean | undefined;
|
|
508
540
|
default?: string | undefined;
|
|
541
|
+
primaryKey?: boolean | undefined;
|
|
509
542
|
}, {
|
|
510
543
|
type: "text";
|
|
511
544
|
label?: string | undefined;
|
|
@@ -513,6 +546,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
513
546
|
unique?: boolean | undefined;
|
|
514
547
|
multiline?: boolean | undefined;
|
|
515
548
|
default?: string | undefined;
|
|
549
|
+
primaryKey?: boolean | undefined;
|
|
516
550
|
}>, z.ZodObject<{
|
|
517
551
|
label: z.ZodOptional<z.ZodString>;
|
|
518
552
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -565,6 +599,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
565
599
|
optional?: boolean | undefined;
|
|
566
600
|
unique?: boolean | undefined;
|
|
567
601
|
default?: number | undefined;
|
|
602
|
+
primaryKey?: boolean | undefined;
|
|
568
603
|
} | {
|
|
569
604
|
type: "text";
|
|
570
605
|
label?: string | undefined;
|
|
@@ -572,6 +607,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
572
607
|
unique?: boolean | undefined;
|
|
573
608
|
multiline?: boolean | undefined;
|
|
574
609
|
default?: string | undefined;
|
|
610
|
+
primaryKey?: boolean | undefined;
|
|
575
611
|
} | {
|
|
576
612
|
type: "date";
|
|
577
613
|
label?: string | undefined;
|
|
@@ -600,6 +636,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
600
636
|
optional?: boolean | undefined;
|
|
601
637
|
unique?: boolean | undefined;
|
|
602
638
|
default?: number | undefined;
|
|
639
|
+
primaryKey?: boolean | undefined;
|
|
603
640
|
} | {
|
|
604
641
|
type: "text";
|
|
605
642
|
label?: string | undefined;
|
|
@@ -607,6 +644,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
607
644
|
unique?: boolean | undefined;
|
|
608
645
|
multiline?: boolean | undefined;
|
|
609
646
|
default?: string | undefined;
|
|
647
|
+
primaryKey?: boolean | undefined;
|
|
610
648
|
} | {
|
|
611
649
|
type: "date";
|
|
612
650
|
label?: string | undefined;
|
|
@@ -648,18 +686,21 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
648
686
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
649
687
|
type: z.ZodLiteral<"number">;
|
|
650
688
|
default: z.ZodOptional<z.ZodNumber>;
|
|
689
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
651
690
|
}, "strip", z.ZodTypeAny, {
|
|
652
691
|
type: "number";
|
|
653
692
|
label?: string | undefined;
|
|
654
693
|
optional?: boolean | undefined;
|
|
655
694
|
unique?: boolean | undefined;
|
|
656
695
|
default?: number | undefined;
|
|
696
|
+
primaryKey?: boolean | undefined;
|
|
657
697
|
}, {
|
|
658
698
|
type: "number";
|
|
659
699
|
label?: string | undefined;
|
|
660
700
|
optional?: boolean | undefined;
|
|
661
701
|
unique?: boolean | undefined;
|
|
662
702
|
default?: number | undefined;
|
|
703
|
+
primaryKey?: boolean | undefined;
|
|
663
704
|
}>, z.ZodObject<{
|
|
664
705
|
label: z.ZodOptional<z.ZodString>;
|
|
665
706
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -667,6 +708,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
667
708
|
type: z.ZodLiteral<"text">;
|
|
668
709
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
669
710
|
default: z.ZodOptional<z.ZodString>;
|
|
711
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
670
712
|
}, "strip", z.ZodTypeAny, {
|
|
671
713
|
type: "text";
|
|
672
714
|
label?: string | undefined;
|
|
@@ -674,6 +716,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
674
716
|
unique?: boolean | undefined;
|
|
675
717
|
multiline?: boolean | undefined;
|
|
676
718
|
default?: string | undefined;
|
|
719
|
+
primaryKey?: boolean | undefined;
|
|
677
720
|
}, {
|
|
678
721
|
type: "text";
|
|
679
722
|
label?: string | undefined;
|
|
@@ -681,6 +724,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
681
724
|
unique?: boolean | undefined;
|
|
682
725
|
multiline?: boolean | undefined;
|
|
683
726
|
default?: string | undefined;
|
|
727
|
+
primaryKey?: boolean | undefined;
|
|
684
728
|
}>, z.ZodObject<{
|
|
685
729
|
label: z.ZodOptional<z.ZodString>;
|
|
686
730
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -733,6 +777,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
733
777
|
optional?: boolean | undefined;
|
|
734
778
|
unique?: boolean | undefined;
|
|
735
779
|
default?: number | undefined;
|
|
780
|
+
primaryKey?: boolean | undefined;
|
|
736
781
|
} | {
|
|
737
782
|
type: "text";
|
|
738
783
|
label?: string | undefined;
|
|
@@ -740,6 +785,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
740
785
|
unique?: boolean | undefined;
|
|
741
786
|
multiline?: boolean | undefined;
|
|
742
787
|
default?: string | undefined;
|
|
788
|
+
primaryKey?: boolean | undefined;
|
|
743
789
|
} | {
|
|
744
790
|
type: "date";
|
|
745
791
|
label?: string | undefined;
|
|
@@ -768,6 +814,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
768
814
|
optional?: boolean | undefined;
|
|
769
815
|
unique?: boolean | undefined;
|
|
770
816
|
default?: number | undefined;
|
|
817
|
+
primaryKey?: boolean | undefined;
|
|
771
818
|
} | {
|
|
772
819
|
type: "text";
|
|
773
820
|
label?: string | undefined;
|
|
@@ -775,6 +822,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
775
822
|
unique?: boolean | undefined;
|
|
776
823
|
multiline?: boolean | undefined;
|
|
777
824
|
default?: string | undefined;
|
|
825
|
+
primaryKey?: boolean | undefined;
|
|
778
826
|
} | {
|
|
779
827
|
type: "date";
|
|
780
828
|
label?: string | undefined;
|
|
@@ -815,18 +863,21 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
815
863
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
816
864
|
type: z.ZodLiteral<"number">;
|
|
817
865
|
default: z.ZodOptional<z.ZodNumber>;
|
|
866
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
818
867
|
}, "strip", z.ZodTypeAny, {
|
|
819
868
|
type: "number";
|
|
820
869
|
label?: string | undefined;
|
|
821
870
|
optional?: boolean | undefined;
|
|
822
871
|
unique?: boolean | undefined;
|
|
823
872
|
default?: number | undefined;
|
|
873
|
+
primaryKey?: boolean | undefined;
|
|
824
874
|
}, {
|
|
825
875
|
type: "number";
|
|
826
876
|
label?: string | undefined;
|
|
827
877
|
optional?: boolean | undefined;
|
|
828
878
|
unique?: boolean | undefined;
|
|
829
879
|
default?: number | undefined;
|
|
880
|
+
primaryKey?: boolean | undefined;
|
|
830
881
|
}>, z.ZodObject<{
|
|
831
882
|
label: z.ZodOptional<z.ZodString>;
|
|
832
883
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -834,6 +885,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
834
885
|
type: z.ZodLiteral<"text">;
|
|
835
886
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
836
887
|
default: z.ZodOptional<z.ZodString>;
|
|
888
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
837
889
|
}, "strip", z.ZodTypeAny, {
|
|
838
890
|
type: "text";
|
|
839
891
|
label?: string | undefined;
|
|
@@ -841,6 +893,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
841
893
|
unique?: boolean | undefined;
|
|
842
894
|
multiline?: boolean | undefined;
|
|
843
895
|
default?: string | undefined;
|
|
896
|
+
primaryKey?: boolean | undefined;
|
|
844
897
|
}, {
|
|
845
898
|
type: "text";
|
|
846
899
|
label?: string | undefined;
|
|
@@ -848,6 +901,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
848
901
|
unique?: boolean | undefined;
|
|
849
902
|
multiline?: boolean | undefined;
|
|
850
903
|
default?: string | undefined;
|
|
904
|
+
primaryKey?: boolean | undefined;
|
|
851
905
|
}>, z.ZodObject<{
|
|
852
906
|
label: z.ZodOptional<z.ZodString>;
|
|
853
907
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -900,6 +954,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
900
954
|
optional?: boolean | undefined;
|
|
901
955
|
unique?: boolean | undefined;
|
|
902
956
|
default?: number | undefined;
|
|
957
|
+
primaryKey?: boolean | undefined;
|
|
903
958
|
} | {
|
|
904
959
|
type: "text";
|
|
905
960
|
label?: string | undefined;
|
|
@@ -907,6 +962,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
907
962
|
unique?: boolean | undefined;
|
|
908
963
|
multiline?: boolean | undefined;
|
|
909
964
|
default?: string | undefined;
|
|
965
|
+
primaryKey?: boolean | undefined;
|
|
910
966
|
} | {
|
|
911
967
|
type: "date";
|
|
912
968
|
label?: string | undefined;
|
|
@@ -935,6 +991,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
935
991
|
optional?: boolean | undefined;
|
|
936
992
|
unique?: boolean | undefined;
|
|
937
993
|
default?: number | undefined;
|
|
994
|
+
primaryKey?: boolean | undefined;
|
|
938
995
|
} | {
|
|
939
996
|
type: "text";
|
|
940
997
|
label?: string | undefined;
|
|
@@ -942,6 +999,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
942
999
|
unique?: boolean | undefined;
|
|
943
1000
|
multiline?: boolean | undefined;
|
|
944
1001
|
default?: string | undefined;
|
|
1002
|
+
primaryKey?: boolean | undefined;
|
|
945
1003
|
} | {
|
|
946
1004
|
type: "date";
|
|
947
1005
|
label?: string | undefined;
|
|
@@ -983,18 +1041,21 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
983
1041
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
984
1042
|
type: z.ZodLiteral<"number">;
|
|
985
1043
|
default: z.ZodOptional<z.ZodNumber>;
|
|
1044
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
986
1045
|
}, "strip", z.ZodTypeAny, {
|
|
987
1046
|
type: "number";
|
|
988
1047
|
label?: string | undefined;
|
|
989
1048
|
optional?: boolean | undefined;
|
|
990
1049
|
unique?: boolean | undefined;
|
|
991
1050
|
default?: number | undefined;
|
|
1051
|
+
primaryKey?: boolean | undefined;
|
|
992
1052
|
}, {
|
|
993
1053
|
type: "number";
|
|
994
1054
|
label?: string | undefined;
|
|
995
1055
|
optional?: boolean | undefined;
|
|
996
1056
|
unique?: boolean | undefined;
|
|
997
1057
|
default?: number | undefined;
|
|
1058
|
+
primaryKey?: boolean | undefined;
|
|
998
1059
|
}>, z.ZodObject<{
|
|
999
1060
|
label: z.ZodOptional<z.ZodString>;
|
|
1000
1061
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1002,6 +1063,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1002
1063
|
type: z.ZodLiteral<"text">;
|
|
1003
1064
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
1004
1065
|
default: z.ZodOptional<z.ZodString>;
|
|
1066
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
1005
1067
|
}, "strip", z.ZodTypeAny, {
|
|
1006
1068
|
type: "text";
|
|
1007
1069
|
label?: string | undefined;
|
|
@@ -1009,6 +1071,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1009
1071
|
unique?: boolean | undefined;
|
|
1010
1072
|
multiline?: boolean | undefined;
|
|
1011
1073
|
default?: string | undefined;
|
|
1074
|
+
primaryKey?: boolean | undefined;
|
|
1012
1075
|
}, {
|
|
1013
1076
|
type: "text";
|
|
1014
1077
|
label?: string | undefined;
|
|
@@ -1016,6 +1079,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1016
1079
|
unique?: boolean | undefined;
|
|
1017
1080
|
multiline?: boolean | undefined;
|
|
1018
1081
|
default?: string | undefined;
|
|
1082
|
+
primaryKey?: boolean | undefined;
|
|
1019
1083
|
}>, z.ZodObject<{
|
|
1020
1084
|
label: z.ZodOptional<z.ZodString>;
|
|
1021
1085
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1068,6 +1132,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1068
1132
|
optional?: boolean | undefined;
|
|
1069
1133
|
unique?: boolean | undefined;
|
|
1070
1134
|
default?: number | undefined;
|
|
1135
|
+
primaryKey?: boolean | undefined;
|
|
1071
1136
|
} | {
|
|
1072
1137
|
type: "text";
|
|
1073
1138
|
label?: string | undefined;
|
|
@@ -1075,6 +1140,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1075
1140
|
unique?: boolean | undefined;
|
|
1076
1141
|
multiline?: boolean | undefined;
|
|
1077
1142
|
default?: string | undefined;
|
|
1143
|
+
primaryKey?: boolean | undefined;
|
|
1078
1144
|
} | {
|
|
1079
1145
|
type: "date";
|
|
1080
1146
|
label?: string | undefined;
|
|
@@ -1103,6 +1169,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1103
1169
|
optional?: boolean | undefined;
|
|
1104
1170
|
unique?: boolean | undefined;
|
|
1105
1171
|
default?: number | undefined;
|
|
1172
|
+
primaryKey?: boolean | undefined;
|
|
1106
1173
|
} | {
|
|
1107
1174
|
type: "text";
|
|
1108
1175
|
label?: string | undefined;
|
|
@@ -1110,6 +1177,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1110
1177
|
unique?: boolean | undefined;
|
|
1111
1178
|
multiline?: boolean | undefined;
|
|
1112
1179
|
default?: string | undefined;
|
|
1180
|
+
primaryKey?: boolean | undefined;
|
|
1113
1181
|
} | {
|
|
1114
1182
|
type: "date";
|
|
1115
1183
|
label?: string | undefined;
|
|
@@ -1150,18 +1218,21 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1150
1218
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
1151
1219
|
type: z.ZodLiteral<"number">;
|
|
1152
1220
|
default: z.ZodOptional<z.ZodNumber>;
|
|
1221
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
1153
1222
|
}, "strip", z.ZodTypeAny, {
|
|
1154
1223
|
type: "number";
|
|
1155
1224
|
label?: string | undefined;
|
|
1156
1225
|
optional?: boolean | undefined;
|
|
1157
1226
|
unique?: boolean | undefined;
|
|
1158
1227
|
default?: number | undefined;
|
|
1228
|
+
primaryKey?: boolean | undefined;
|
|
1159
1229
|
}, {
|
|
1160
1230
|
type: "number";
|
|
1161
1231
|
label?: string | undefined;
|
|
1162
1232
|
optional?: boolean | undefined;
|
|
1163
1233
|
unique?: boolean | undefined;
|
|
1164
1234
|
default?: number | undefined;
|
|
1235
|
+
primaryKey?: boolean | undefined;
|
|
1165
1236
|
}>, z.ZodObject<{
|
|
1166
1237
|
label: z.ZodOptional<z.ZodString>;
|
|
1167
1238
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1169,6 +1240,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1169
1240
|
type: z.ZodLiteral<"text">;
|
|
1170
1241
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
1171
1242
|
default: z.ZodOptional<z.ZodString>;
|
|
1243
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
1172
1244
|
}, "strip", z.ZodTypeAny, {
|
|
1173
1245
|
type: "text";
|
|
1174
1246
|
label?: string | undefined;
|
|
@@ -1176,6 +1248,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1176
1248
|
unique?: boolean | undefined;
|
|
1177
1249
|
multiline?: boolean | undefined;
|
|
1178
1250
|
default?: string | undefined;
|
|
1251
|
+
primaryKey?: boolean | undefined;
|
|
1179
1252
|
}, {
|
|
1180
1253
|
type: "text";
|
|
1181
1254
|
label?: string | undefined;
|
|
@@ -1183,6 +1256,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1183
1256
|
unique?: boolean | undefined;
|
|
1184
1257
|
multiline?: boolean | undefined;
|
|
1185
1258
|
default?: string | undefined;
|
|
1259
|
+
primaryKey?: boolean | undefined;
|
|
1186
1260
|
}>, z.ZodObject<{
|
|
1187
1261
|
label: z.ZodOptional<z.ZodString>;
|
|
1188
1262
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1235,6 +1309,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1235
1309
|
optional?: boolean | undefined;
|
|
1236
1310
|
unique?: boolean | undefined;
|
|
1237
1311
|
default?: number | undefined;
|
|
1312
|
+
primaryKey?: boolean | undefined;
|
|
1238
1313
|
} | {
|
|
1239
1314
|
type: "text";
|
|
1240
1315
|
label?: string | undefined;
|
|
@@ -1242,6 +1317,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1242
1317
|
unique?: boolean | undefined;
|
|
1243
1318
|
multiline?: boolean | undefined;
|
|
1244
1319
|
default?: string | undefined;
|
|
1320
|
+
primaryKey?: boolean | undefined;
|
|
1245
1321
|
} | {
|
|
1246
1322
|
type: "date";
|
|
1247
1323
|
label?: string | undefined;
|
|
@@ -1270,6 +1346,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1270
1346
|
optional?: boolean | undefined;
|
|
1271
1347
|
unique?: boolean | undefined;
|
|
1272
1348
|
default?: number | undefined;
|
|
1349
|
+
primaryKey?: boolean | undefined;
|
|
1273
1350
|
} | {
|
|
1274
1351
|
type: "text";
|
|
1275
1352
|
label?: string | undefined;
|
|
@@ -1277,6 +1354,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1277
1354
|
unique?: boolean | undefined;
|
|
1278
1355
|
multiline?: boolean | undefined;
|
|
1279
1356
|
default?: string | undefined;
|
|
1357
|
+
primaryKey?: boolean | undefined;
|
|
1280
1358
|
} | {
|
|
1281
1359
|
type: "date";
|
|
1282
1360
|
label?: string | undefined;
|
|
@@ -1305,13 +1383,17 @@ export type DBFieldInput = DateFieldInput | BooleanField | NumberField | TextFie
|
|
|
1305
1383
|
export type DBFields = z.infer<typeof fieldsSchema>;
|
|
1306
1384
|
export type DBCollection = z.infer<typeof readableCollectionSchema | typeof writableCollectionSchema>;
|
|
1307
1385
|
export type DBCollections = Record<string, DBCollection>;
|
|
1386
|
+
export type DBSnapshot = {
|
|
1387
|
+
schema: Record<string, DBCollection>;
|
|
1388
|
+
/**
|
|
1389
|
+
* Snapshot version. Breaking changes to the snapshot format increment this number.
|
|
1390
|
+
* @todo Rename to "version" once closer to release.
|
|
1391
|
+
*/
|
|
1392
|
+
experimentalVersion: number;
|
|
1393
|
+
};
|
|
1308
1394
|
export type ReadableDBCollection = z.infer<typeof readableCollectionSchema>;
|
|
1309
1395
|
export type WritableDBCollection = z.infer<typeof writableCollectionSchema>;
|
|
1310
|
-
|
|
1311
|
-
schema: undefined;
|
|
1312
|
-
dialect: 'sqlite';
|
|
1313
|
-
}>;
|
|
1314
|
-
type GeneratedConfig<T extends ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault'>;
|
|
1396
|
+
type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault'>;
|
|
1315
1397
|
export type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn<T & {
|
|
1316
1398
|
data: string;
|
|
1317
1399
|
dataType: 'string';
|
|
@@ -1364,4 +1446,22 @@ export type AstroId<T extends Pick<GeneratedConfig<'string'>, 'tableName'>> = SQ
|
|
|
1364
1446
|
baseColumn: never;
|
|
1365
1447
|
}>;
|
|
1366
1448
|
export type MaybePromise<T> = T | Promise<T>;
|
|
1449
|
+
export type Column<T extends DBField['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;
|
|
1450
|
+
export type Table<TTableName extends string, TFields extends Record<string, Pick<DBField, 'type' | 'default' | 'optional'>>> = SQLiteTableWithColumns<{
|
|
1451
|
+
name: TTableName;
|
|
1452
|
+
schema: undefined;
|
|
1453
|
+
dialect: 'sqlite';
|
|
1454
|
+
columns: {
|
|
1455
|
+
id: AstroId<{
|
|
1456
|
+
tableName: TTableName;
|
|
1457
|
+
}>;
|
|
1458
|
+
} & {
|
|
1459
|
+
[K in Extract<keyof TFields, string>]: Column<TFields[K]['type'], {
|
|
1460
|
+
tableName: TTableName;
|
|
1461
|
+
name: K;
|
|
1462
|
+
hasDefault: TFields[K]['default'] extends undefined ? false : true;
|
|
1463
|
+
notNull: TFields[K]['optional'] extends true ? false : true;
|
|
1464
|
+
}>;
|
|
1465
|
+
};
|
|
1466
|
+
}>;
|
|
1367
1467
|
export {};
|
package/dist/types.js
CHANGED
|
@@ -10,12 +10,14 @@ const booleanFieldSchema = baseFieldSchema.extend({
|
|
|
10
10
|
});
|
|
11
11
|
const numberFieldSchema = baseFieldSchema.extend({
|
|
12
12
|
type: z.literal("number"),
|
|
13
|
-
default: z.number().optional()
|
|
13
|
+
default: z.number().optional(),
|
|
14
|
+
primaryKey: z.boolean().optional()
|
|
14
15
|
});
|
|
15
16
|
const textFieldSchema = baseFieldSchema.extend({
|
|
16
17
|
type: z.literal("text"),
|
|
17
18
|
multiline: z.boolean().optional(),
|
|
18
|
-
default: z.string().optional()
|
|
19
|
+
default: z.string().optional(),
|
|
20
|
+
primaryKey: z.boolean().optional()
|
|
19
21
|
});
|
|
20
22
|
const dateFieldSchema = baseFieldSchema.extend({
|
|
21
23
|
type: z.literal("date"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"mocha": "^10.2.0",
|
|
62
62
|
"typescript": "^5.2.2",
|
|
63
63
|
"vite": "^4.4.11",
|
|
64
|
-
"astro": "4.2.
|
|
64
|
+
"astro": "4.2.4",
|
|
65
65
|
"astro-scripts": "0.0.14"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
package/dist/cli/sync/index.js
DELETED
|
File without changes
|
package/dist/cli/sync/migrate.js
DELETED
|
File without changes
|