@astrojs/db 0.1.2 → 0.1.4
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 +12 -16
- package/dist/internal.js +52 -22
- 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/dist/utils-runtime.d.ts +1 -0
- package/dist/utils-runtime.js +52 -0
- package/dist/utils.js +3 -48
- package/dist/vite-plugin-db.js +1 -3
- package/package.json +2 -2
- package/dist/cli/sync/index.js +0 -0
- package/dist/cli/sync/migrate.js +0 -0
package/dist/config.d.ts
CHANGED
|
@@ -27,18 +27,21 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
27
27
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
28
28
|
type: z.ZodLiteral<"number">;
|
|
29
29
|
default: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
30
31
|
}, "strip", z.ZodTypeAny, {
|
|
31
32
|
type: "number";
|
|
32
33
|
label?: string | undefined;
|
|
33
34
|
optional?: boolean | undefined;
|
|
34
35
|
unique?: boolean | undefined;
|
|
35
36
|
default?: number | undefined;
|
|
37
|
+
primaryKey?: boolean | undefined;
|
|
36
38
|
}, {
|
|
37
39
|
type: "number";
|
|
38
40
|
label?: string | undefined;
|
|
39
41
|
optional?: boolean | undefined;
|
|
40
42
|
unique?: boolean | undefined;
|
|
41
43
|
default?: number | undefined;
|
|
44
|
+
primaryKey?: boolean | undefined;
|
|
42
45
|
}>, z.ZodObject<{
|
|
43
46
|
label: z.ZodOptional<z.ZodString>;
|
|
44
47
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -46,6 +49,7 @@ export declare const dbConfigSchema: 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 @@ export declare const dbConfigSchema: 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 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
60
65
|
unique?: boolean | undefined;
|
|
61
66
|
multiline?: boolean | undefined;
|
|
62
67
|
default?: string | undefined;
|
|
68
|
+
primaryKey?: boolean | undefined;
|
|
63
69
|
}>, z.ZodObject<{
|
|
64
70
|
label: z.ZodOptional<z.ZodString>;
|
|
65
71
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -112,6 +118,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
112
118
|
optional?: boolean | undefined;
|
|
113
119
|
unique?: boolean | undefined;
|
|
114
120
|
default?: number | undefined;
|
|
121
|
+
primaryKey?: boolean | undefined;
|
|
115
122
|
} | {
|
|
116
123
|
type: "text";
|
|
117
124
|
label?: string | undefined;
|
|
@@ -119,6 +126,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
119
126
|
unique?: boolean | undefined;
|
|
120
127
|
multiline?: boolean | undefined;
|
|
121
128
|
default?: string | undefined;
|
|
129
|
+
primaryKey?: boolean | undefined;
|
|
122
130
|
} | {
|
|
123
131
|
type: "date";
|
|
124
132
|
label?: string | undefined;
|
|
@@ -147,6 +155,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
147
155
|
optional?: boolean | undefined;
|
|
148
156
|
unique?: boolean | undefined;
|
|
149
157
|
default?: number | undefined;
|
|
158
|
+
primaryKey?: boolean | undefined;
|
|
150
159
|
} | {
|
|
151
160
|
type: "text";
|
|
152
161
|
label?: string | undefined;
|
|
@@ -154,6 +163,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
154
163
|
unique?: boolean | undefined;
|
|
155
164
|
multiline?: boolean | undefined;
|
|
156
165
|
default?: string | undefined;
|
|
166
|
+
primaryKey?: boolean | undefined;
|
|
157
167
|
} | {
|
|
158
168
|
type: "date";
|
|
159
169
|
label?: string | undefined;
|
|
@@ -194,18 +204,21 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
194
204
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
195
205
|
type: z.ZodLiteral<"number">;
|
|
196
206
|
default: z.ZodOptional<z.ZodNumber>;
|
|
207
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
197
208
|
}, "strip", z.ZodTypeAny, {
|
|
198
209
|
type: "number";
|
|
199
210
|
label?: string | undefined;
|
|
200
211
|
optional?: boolean | undefined;
|
|
201
212
|
unique?: boolean | undefined;
|
|
202
213
|
default?: number | undefined;
|
|
214
|
+
primaryKey?: boolean | undefined;
|
|
203
215
|
}, {
|
|
204
216
|
type: "number";
|
|
205
217
|
label?: string | undefined;
|
|
206
218
|
optional?: boolean | undefined;
|
|
207
219
|
unique?: boolean | undefined;
|
|
208
220
|
default?: number | undefined;
|
|
221
|
+
primaryKey?: boolean | undefined;
|
|
209
222
|
}>, z.ZodObject<{
|
|
210
223
|
label: z.ZodOptional<z.ZodString>;
|
|
211
224
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -213,6 +226,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
213
226
|
type: z.ZodLiteral<"text">;
|
|
214
227
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
215
228
|
default: z.ZodOptional<z.ZodString>;
|
|
229
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
216
230
|
}, "strip", z.ZodTypeAny, {
|
|
217
231
|
type: "text";
|
|
218
232
|
label?: string | undefined;
|
|
@@ -220,6 +234,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
220
234
|
unique?: boolean | undefined;
|
|
221
235
|
multiline?: boolean | undefined;
|
|
222
236
|
default?: string | undefined;
|
|
237
|
+
primaryKey?: boolean | undefined;
|
|
223
238
|
}, {
|
|
224
239
|
type: "text";
|
|
225
240
|
label?: string | undefined;
|
|
@@ -227,6 +242,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
227
242
|
unique?: boolean | undefined;
|
|
228
243
|
multiline?: boolean | undefined;
|
|
229
244
|
default?: string | undefined;
|
|
245
|
+
primaryKey?: boolean | undefined;
|
|
230
246
|
}>, z.ZodObject<{
|
|
231
247
|
label: z.ZodOptional<z.ZodString>;
|
|
232
248
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -279,6 +295,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
279
295
|
optional?: boolean | undefined;
|
|
280
296
|
unique?: boolean | undefined;
|
|
281
297
|
default?: number | undefined;
|
|
298
|
+
primaryKey?: boolean | undefined;
|
|
282
299
|
} | {
|
|
283
300
|
type: "text";
|
|
284
301
|
label?: string | undefined;
|
|
@@ -286,6 +303,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
286
303
|
unique?: boolean | undefined;
|
|
287
304
|
multiline?: boolean | undefined;
|
|
288
305
|
default?: string | undefined;
|
|
306
|
+
primaryKey?: boolean | undefined;
|
|
289
307
|
} | {
|
|
290
308
|
type: "date";
|
|
291
309
|
label?: string | undefined;
|
|
@@ -314,6 +332,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
314
332
|
optional?: boolean | undefined;
|
|
315
333
|
unique?: boolean | undefined;
|
|
316
334
|
default?: number | undefined;
|
|
335
|
+
primaryKey?: boolean | undefined;
|
|
317
336
|
} | {
|
|
318
337
|
type: "text";
|
|
319
338
|
label?: string | undefined;
|
|
@@ -321,6 +340,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
321
340
|
unique?: boolean | undefined;
|
|
322
341
|
multiline?: boolean | undefined;
|
|
323
342
|
default?: string | undefined;
|
|
343
|
+
primaryKey?: boolean | undefined;
|
|
324
344
|
} | {
|
|
325
345
|
type: "date";
|
|
326
346
|
label?: string | undefined;
|
|
@@ -337,6 +357,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
337
357
|
writable: true;
|
|
338
358
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
339
359
|
}>]>>>;
|
|
360
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodUnknown>>;
|
|
340
361
|
}, "strip", z.ZodTypeAny, {
|
|
341
362
|
studio?: boolean | undefined;
|
|
342
363
|
collections?: Record<string, {
|
|
@@ -352,6 +373,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
352
373
|
optional?: boolean | undefined;
|
|
353
374
|
unique?: boolean | undefined;
|
|
354
375
|
default?: number | undefined;
|
|
376
|
+
primaryKey?: boolean | undefined;
|
|
355
377
|
} | {
|
|
356
378
|
type: "text";
|
|
357
379
|
label?: string | undefined;
|
|
@@ -359,6 +381,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
359
381
|
unique?: boolean | undefined;
|
|
360
382
|
multiline?: boolean | undefined;
|
|
361
383
|
default?: string | undefined;
|
|
384
|
+
primaryKey?: boolean | undefined;
|
|
362
385
|
} | {
|
|
363
386
|
type: "date";
|
|
364
387
|
label?: string | undefined;
|
|
@@ -387,6 +410,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
387
410
|
optional?: boolean | undefined;
|
|
388
411
|
unique?: boolean | undefined;
|
|
389
412
|
default?: number | undefined;
|
|
413
|
+
primaryKey?: boolean | undefined;
|
|
390
414
|
} | {
|
|
391
415
|
type: "text";
|
|
392
416
|
label?: string | undefined;
|
|
@@ -394,6 +418,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
394
418
|
unique?: boolean | undefined;
|
|
395
419
|
multiline?: boolean | undefined;
|
|
396
420
|
default?: string | undefined;
|
|
421
|
+
primaryKey?: boolean | undefined;
|
|
397
422
|
} | {
|
|
398
423
|
type: "date";
|
|
399
424
|
label?: string | undefined;
|
|
@@ -410,6 +435,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
410
435
|
writable: true;
|
|
411
436
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
412
437
|
}> | undefined;
|
|
438
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
413
439
|
}, {
|
|
414
440
|
studio?: boolean | undefined;
|
|
415
441
|
collections?: Record<string, {
|
|
@@ -425,6 +451,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
425
451
|
optional?: boolean | undefined;
|
|
426
452
|
unique?: boolean | undefined;
|
|
427
453
|
default?: number | undefined;
|
|
454
|
+
primaryKey?: boolean | undefined;
|
|
428
455
|
} | {
|
|
429
456
|
type: "text";
|
|
430
457
|
label?: string | undefined;
|
|
@@ -432,6 +459,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
432
459
|
unique?: boolean | undefined;
|
|
433
460
|
multiline?: boolean | undefined;
|
|
434
461
|
default?: string | undefined;
|
|
462
|
+
primaryKey?: boolean | undefined;
|
|
435
463
|
} | {
|
|
436
464
|
type: "date";
|
|
437
465
|
label?: string | undefined;
|
|
@@ -460,6 +488,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
460
488
|
optional?: boolean | undefined;
|
|
461
489
|
unique?: boolean | undefined;
|
|
462
490
|
default?: number | undefined;
|
|
491
|
+
primaryKey?: boolean | undefined;
|
|
463
492
|
} | {
|
|
464
493
|
type: "text";
|
|
465
494
|
label?: string | undefined;
|
|
@@ -467,6 +496,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
467
496
|
unique?: boolean | undefined;
|
|
468
497
|
multiline?: boolean | undefined;
|
|
469
498
|
default?: string | undefined;
|
|
499
|
+
primaryKey?: boolean | undefined;
|
|
470
500
|
} | {
|
|
471
501
|
type: "date";
|
|
472
502
|
label?: string | undefined;
|
|
@@ -483,6 +513,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
483
513
|
writable: true;
|
|
484
514
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
485
515
|
}> | undefined;
|
|
516
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
486
517
|
}>;
|
|
487
518
|
export type DBUserConfig = z.input<typeof dbConfigSchema>;
|
|
488
519
|
export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
@@ -513,18 +544,21 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
513
544
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
514
545
|
type: z.ZodLiteral<"number">;
|
|
515
546
|
default: z.ZodOptional<z.ZodNumber>;
|
|
547
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
516
548
|
}, "strip", z.ZodTypeAny, {
|
|
517
549
|
type: "number";
|
|
518
550
|
label?: string | undefined;
|
|
519
551
|
optional?: boolean | undefined;
|
|
520
552
|
unique?: boolean | undefined;
|
|
521
553
|
default?: number | undefined;
|
|
554
|
+
primaryKey?: boolean | undefined;
|
|
522
555
|
}, {
|
|
523
556
|
type: "number";
|
|
524
557
|
label?: string | undefined;
|
|
525
558
|
optional?: boolean | undefined;
|
|
526
559
|
unique?: boolean | undefined;
|
|
527
560
|
default?: number | undefined;
|
|
561
|
+
primaryKey?: boolean | undefined;
|
|
528
562
|
}>, z.ZodObject<{
|
|
529
563
|
label: z.ZodOptional<z.ZodString>;
|
|
530
564
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -532,6 +566,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
532
566
|
type: z.ZodLiteral<"text">;
|
|
533
567
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
534
568
|
default: z.ZodOptional<z.ZodString>;
|
|
569
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
535
570
|
}, "strip", z.ZodTypeAny, {
|
|
536
571
|
type: "text";
|
|
537
572
|
label?: string | undefined;
|
|
@@ -539,6 +574,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
539
574
|
unique?: boolean | undefined;
|
|
540
575
|
multiline?: boolean | undefined;
|
|
541
576
|
default?: string | undefined;
|
|
577
|
+
primaryKey?: boolean | undefined;
|
|
542
578
|
}, {
|
|
543
579
|
type: "text";
|
|
544
580
|
label?: string | undefined;
|
|
@@ -546,6 +582,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
546
582
|
unique?: boolean | undefined;
|
|
547
583
|
multiline?: boolean | undefined;
|
|
548
584
|
default?: string | undefined;
|
|
585
|
+
primaryKey?: boolean | undefined;
|
|
549
586
|
}>, z.ZodObject<{
|
|
550
587
|
label: z.ZodOptional<z.ZodString>;
|
|
551
588
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -598,6 +635,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
598
635
|
optional?: boolean | undefined;
|
|
599
636
|
unique?: boolean | undefined;
|
|
600
637
|
default?: number | undefined;
|
|
638
|
+
primaryKey?: boolean | undefined;
|
|
601
639
|
} | {
|
|
602
640
|
type: "text";
|
|
603
641
|
label?: string | undefined;
|
|
@@ -605,6 +643,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
605
643
|
unique?: boolean | undefined;
|
|
606
644
|
multiline?: boolean | undefined;
|
|
607
645
|
default?: string | undefined;
|
|
646
|
+
primaryKey?: boolean | undefined;
|
|
608
647
|
} | {
|
|
609
648
|
type: "date";
|
|
610
649
|
label?: string | undefined;
|
|
@@ -633,6 +672,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
633
672
|
optional?: boolean | undefined;
|
|
634
673
|
unique?: boolean | undefined;
|
|
635
674
|
default?: number | undefined;
|
|
675
|
+
primaryKey?: boolean | undefined;
|
|
636
676
|
} | {
|
|
637
677
|
type: "text";
|
|
638
678
|
label?: string | undefined;
|
|
@@ -640,6 +680,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
640
680
|
unique?: boolean | undefined;
|
|
641
681
|
multiline?: boolean | undefined;
|
|
642
682
|
default?: string | undefined;
|
|
683
|
+
primaryKey?: boolean | undefined;
|
|
643
684
|
} | {
|
|
644
685
|
type: "date";
|
|
645
686
|
label?: string | undefined;
|
|
@@ -680,18 +721,21 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
680
721
|
unique: z.ZodOptional<z.ZodBoolean>;
|
|
681
722
|
type: z.ZodLiteral<"number">;
|
|
682
723
|
default: z.ZodOptional<z.ZodNumber>;
|
|
724
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
683
725
|
}, "strip", z.ZodTypeAny, {
|
|
684
726
|
type: "number";
|
|
685
727
|
label?: string | undefined;
|
|
686
728
|
optional?: boolean | undefined;
|
|
687
729
|
unique?: boolean | undefined;
|
|
688
730
|
default?: number | undefined;
|
|
731
|
+
primaryKey?: boolean | undefined;
|
|
689
732
|
}, {
|
|
690
733
|
type: "number";
|
|
691
734
|
label?: string | undefined;
|
|
692
735
|
optional?: boolean | undefined;
|
|
693
736
|
unique?: boolean | undefined;
|
|
694
737
|
default?: number | undefined;
|
|
738
|
+
primaryKey?: boolean | undefined;
|
|
695
739
|
}>, z.ZodObject<{
|
|
696
740
|
label: z.ZodOptional<z.ZodString>;
|
|
697
741
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -699,6 +743,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
699
743
|
type: z.ZodLiteral<"text">;
|
|
700
744
|
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
701
745
|
default: z.ZodOptional<z.ZodString>;
|
|
746
|
+
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
702
747
|
}, "strip", z.ZodTypeAny, {
|
|
703
748
|
type: "text";
|
|
704
749
|
label?: string | undefined;
|
|
@@ -706,6 +751,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
706
751
|
unique?: boolean | undefined;
|
|
707
752
|
multiline?: boolean | undefined;
|
|
708
753
|
default?: string | undefined;
|
|
754
|
+
primaryKey?: boolean | undefined;
|
|
709
755
|
}, {
|
|
710
756
|
type: "text";
|
|
711
757
|
label?: string | undefined;
|
|
@@ -713,6 +759,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
713
759
|
unique?: boolean | undefined;
|
|
714
760
|
multiline?: boolean | undefined;
|
|
715
761
|
default?: string | undefined;
|
|
762
|
+
primaryKey?: boolean | undefined;
|
|
716
763
|
}>, z.ZodObject<{
|
|
717
764
|
label: z.ZodOptional<z.ZodString>;
|
|
718
765
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -765,6 +812,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
765
812
|
optional?: boolean | undefined;
|
|
766
813
|
unique?: boolean | undefined;
|
|
767
814
|
default?: number | undefined;
|
|
815
|
+
primaryKey?: boolean | undefined;
|
|
768
816
|
} | {
|
|
769
817
|
type: "text";
|
|
770
818
|
label?: string | undefined;
|
|
@@ -772,6 +820,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
772
820
|
unique?: boolean | undefined;
|
|
773
821
|
multiline?: boolean | undefined;
|
|
774
822
|
default?: string | undefined;
|
|
823
|
+
primaryKey?: boolean | undefined;
|
|
775
824
|
} | {
|
|
776
825
|
type: "date";
|
|
777
826
|
label?: string | undefined;
|
|
@@ -800,6 +849,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
800
849
|
optional?: boolean | undefined;
|
|
801
850
|
unique?: boolean | undefined;
|
|
802
851
|
default?: number | undefined;
|
|
852
|
+
primaryKey?: boolean | undefined;
|
|
803
853
|
} | {
|
|
804
854
|
type: "text";
|
|
805
855
|
label?: string | undefined;
|
|
@@ -807,6 +857,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
807
857
|
unique?: boolean | undefined;
|
|
808
858
|
multiline?: boolean | undefined;
|
|
809
859
|
default?: string | undefined;
|
|
860
|
+
primaryKey?: boolean | undefined;
|
|
810
861
|
} | {
|
|
811
862
|
type: "date";
|
|
812
863
|
label?: string | undefined;
|
|
@@ -823,6 +874,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
823
874
|
writable: true;
|
|
824
875
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
825
876
|
}>]>>>;
|
|
877
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodUnknown>>;
|
|
826
878
|
}, "strip", z.ZodTypeAny, {
|
|
827
879
|
studio?: boolean | undefined;
|
|
828
880
|
collections?: Record<string, {
|
|
@@ -838,6 +890,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
838
890
|
optional?: boolean | undefined;
|
|
839
891
|
unique?: boolean | undefined;
|
|
840
892
|
default?: number | undefined;
|
|
893
|
+
primaryKey?: boolean | undefined;
|
|
841
894
|
} | {
|
|
842
895
|
type: "text";
|
|
843
896
|
label?: string | undefined;
|
|
@@ -845,6 +898,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
845
898
|
unique?: boolean | undefined;
|
|
846
899
|
multiline?: boolean | undefined;
|
|
847
900
|
default?: string | undefined;
|
|
901
|
+
primaryKey?: boolean | undefined;
|
|
848
902
|
} | {
|
|
849
903
|
type: "date";
|
|
850
904
|
label?: string | undefined;
|
|
@@ -873,6 +927,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
873
927
|
optional?: boolean | undefined;
|
|
874
928
|
unique?: boolean | undefined;
|
|
875
929
|
default?: number | undefined;
|
|
930
|
+
primaryKey?: boolean | undefined;
|
|
876
931
|
} | {
|
|
877
932
|
type: "text";
|
|
878
933
|
label?: string | undefined;
|
|
@@ -880,6 +935,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
880
935
|
unique?: boolean | undefined;
|
|
881
936
|
multiline?: boolean | undefined;
|
|
882
937
|
default?: string | undefined;
|
|
938
|
+
primaryKey?: boolean | undefined;
|
|
883
939
|
} | {
|
|
884
940
|
type: "date";
|
|
885
941
|
label?: string | undefined;
|
|
@@ -896,6 +952,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
896
952
|
writable: true;
|
|
897
953
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
898
954
|
}> | undefined;
|
|
955
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
899
956
|
}, {
|
|
900
957
|
studio?: boolean | undefined;
|
|
901
958
|
collections?: Record<string, {
|
|
@@ -911,6 +968,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
911
968
|
optional?: boolean | undefined;
|
|
912
969
|
unique?: boolean | undefined;
|
|
913
970
|
default?: number | undefined;
|
|
971
|
+
primaryKey?: boolean | undefined;
|
|
914
972
|
} | {
|
|
915
973
|
type: "text";
|
|
916
974
|
label?: string | undefined;
|
|
@@ -918,6 +976,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
918
976
|
unique?: boolean | undefined;
|
|
919
977
|
multiline?: boolean | undefined;
|
|
920
978
|
default?: string | undefined;
|
|
979
|
+
primaryKey?: boolean | undefined;
|
|
921
980
|
} | {
|
|
922
981
|
type: "date";
|
|
923
982
|
label?: string | undefined;
|
|
@@ -946,6 +1005,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
946
1005
|
optional?: boolean | undefined;
|
|
947
1006
|
unique?: boolean | undefined;
|
|
948
1007
|
default?: number | undefined;
|
|
1008
|
+
primaryKey?: boolean | undefined;
|
|
949
1009
|
} | {
|
|
950
1010
|
type: "text";
|
|
951
1011
|
label?: string | undefined;
|
|
@@ -953,6 +1013,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
953
1013
|
unique?: boolean | undefined;
|
|
954
1014
|
multiline?: boolean | undefined;
|
|
955
1015
|
default?: string | undefined;
|
|
1016
|
+
primaryKey?: boolean | undefined;
|
|
956
1017
|
} | {
|
|
957
1018
|
type: "date";
|
|
958
1019
|
label?: string | undefined;
|
|
@@ -969,6 +1030,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
969
1030
|
writable: true;
|
|
970
1031
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
971
1032
|
}> | undefined;
|
|
1033
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
972
1034
|
}>>;
|
|
973
1035
|
}, "strip", z.ZodTypeAny, {
|
|
974
1036
|
db?: {
|
|
@@ -986,6 +1048,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
986
1048
|
optional?: boolean | undefined;
|
|
987
1049
|
unique?: boolean | undefined;
|
|
988
1050
|
default?: number | undefined;
|
|
1051
|
+
primaryKey?: boolean | undefined;
|
|
989
1052
|
} | {
|
|
990
1053
|
type: "text";
|
|
991
1054
|
label?: string | undefined;
|
|
@@ -993,6 +1056,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
993
1056
|
unique?: boolean | undefined;
|
|
994
1057
|
multiline?: boolean | undefined;
|
|
995
1058
|
default?: string | undefined;
|
|
1059
|
+
primaryKey?: boolean | undefined;
|
|
996
1060
|
} | {
|
|
997
1061
|
type: "date";
|
|
998
1062
|
label?: string | undefined;
|
|
@@ -1021,6 +1085,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1021
1085
|
optional?: boolean | undefined;
|
|
1022
1086
|
unique?: boolean | undefined;
|
|
1023
1087
|
default?: number | undefined;
|
|
1088
|
+
primaryKey?: boolean | undefined;
|
|
1024
1089
|
} | {
|
|
1025
1090
|
type: "text";
|
|
1026
1091
|
label?: string | undefined;
|
|
@@ -1028,6 +1093,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1028
1093
|
unique?: boolean | undefined;
|
|
1029
1094
|
multiline?: boolean | undefined;
|
|
1030
1095
|
default?: string | undefined;
|
|
1096
|
+
primaryKey?: boolean | undefined;
|
|
1031
1097
|
} | {
|
|
1032
1098
|
type: "date";
|
|
1033
1099
|
label?: string | undefined;
|
|
@@ -1044,6 +1110,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1044
1110
|
writable: true;
|
|
1045
1111
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1046
1112
|
}> | undefined;
|
|
1113
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
1047
1114
|
} | undefined;
|
|
1048
1115
|
}, {
|
|
1049
1116
|
db?: {
|
|
@@ -1061,6 +1128,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1061
1128
|
optional?: boolean | undefined;
|
|
1062
1129
|
unique?: boolean | undefined;
|
|
1063
1130
|
default?: number | undefined;
|
|
1131
|
+
primaryKey?: boolean | undefined;
|
|
1064
1132
|
} | {
|
|
1065
1133
|
type: "text";
|
|
1066
1134
|
label?: string | undefined;
|
|
@@ -1068,6 +1136,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1068
1136
|
unique?: boolean | undefined;
|
|
1069
1137
|
multiline?: boolean | undefined;
|
|
1070
1138
|
default?: string | undefined;
|
|
1139
|
+
primaryKey?: boolean | undefined;
|
|
1071
1140
|
} | {
|
|
1072
1141
|
type: "date";
|
|
1073
1142
|
label?: string | undefined;
|
|
@@ -1096,6 +1165,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1096
1165
|
optional?: boolean | undefined;
|
|
1097
1166
|
unique?: boolean | undefined;
|
|
1098
1167
|
default?: number | undefined;
|
|
1168
|
+
primaryKey?: boolean | undefined;
|
|
1099
1169
|
} | {
|
|
1100
1170
|
type: "text";
|
|
1101
1171
|
label?: string | undefined;
|
|
@@ -1103,6 +1173,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1103
1173
|
unique?: boolean | undefined;
|
|
1104
1174
|
multiline?: boolean | undefined;
|
|
1105
1175
|
default?: string | undefined;
|
|
1176
|
+
primaryKey?: boolean | undefined;
|
|
1106
1177
|
} | {
|
|
1107
1178
|
type: "date";
|
|
1108
1179
|
label?: string | undefined;
|
|
@@ -1119,6 +1190,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1119
1190
|
writable: true;
|
|
1120
1191
|
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1121
1192
|
}> | undefined;
|
|
1193
|
+
data?: ((args_0: any, ...args_1: unknown[]) => unknown) | undefined;
|
|
1122
1194
|
} | undefined;
|
|
1123
1195
|
}>;
|
|
1124
1196
|
type CollectionConfig<TFields extends z.input<typeof collectionSchema>['fields'], Writable extends boolean> = Writable extends true ? {
|
package/dist/config.js
CHANGED
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
const dbConfigSchema = z.object({
|
|
6
6
|
studio: z.boolean().optional(),
|
|
7
|
-
collections: collectionsSchema.optional()
|
|
7
|
+
collections: collectionsSchema.optional(),
|
|
8
|
+
// TODO: strict types
|
|
9
|
+
data: z.function().args(z.any()).optional()
|
|
8
10
|
});
|
|
9
11
|
const astroConfigWithDbSchema = z.object({
|
|
10
12
|
db: dbConfigSchema.optional()
|
package/dist/integration.js
CHANGED
|
@@ -49,7 +49,13 @@ function integration() {
|
|
|
49
49
|
dbUrl: dbUrl.href,
|
|
50
50
|
seeding: true
|
|
51
51
|
});
|
|
52
|
-
await setupDbTables({
|
|
52
|
+
await setupDbTables({
|
|
53
|
+
db,
|
|
54
|
+
collections,
|
|
55
|
+
data: configWithDb.db?.data,
|
|
56
|
+
logger,
|
|
57
|
+
mode: command === "dev" ? "dev" : "build"
|
|
58
|
+
});
|
|
53
59
|
logger.info("Collections set up \u{1F680}");
|
|
54
60
|
dbPlugin = vitePluginDb({ connectToStudio: false, collections, dbUrl: dbUrl.href });
|
|
55
61
|
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import type { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
|
|
2
|
-
import { type DBCollection, type DBCollections } from './types.js';
|
|
2
|
+
import { type BooleanField, type DBCollection, type DBCollections, type DBField, type DateField, type FieldType, type JsonField, type NumberField, type TextField } from './types.js';
|
|
3
3
|
import { type LibSQLDatabase } from 'drizzle-orm/libsql';
|
|
4
4
|
import { type ColumnDataType } from 'drizzle-orm';
|
|
5
5
|
import type { AstroIntegrationLogger } from 'astro';
|
|
6
|
+
export { createRemoteDatabaseClient } from './utils-runtime.js';
|
|
6
7
|
export type SqliteDB = SqliteRemoteDatabase;
|
|
7
|
-
export type {
|
|
8
|
-
export
|
|
8
|
+
export type { Table } from './types.js';
|
|
9
|
+
export declare function hasPrimaryKey(field: DBField): boolean;
|
|
9
10
|
export declare function createLocalDatabaseClient({ collections, dbUrl, seeding, }: {
|
|
10
11
|
dbUrl: string;
|
|
11
12
|
collections: DBCollections;
|
|
12
13
|
seeding: boolean;
|
|
13
14
|
}): Promise<LibSQLDatabase<Record<string, never>>>;
|
|
14
|
-
export declare function setupDbTables({ db, collections, logger, }: {
|
|
15
|
+
export declare function setupDbTables({ db, data, collections, logger, mode, }: {
|
|
15
16
|
db: LibSQLDatabase;
|
|
17
|
+
data?: (...params: any) => any;
|
|
16
18
|
collections: DBCollections;
|
|
17
19
|
logger: AstroIntegrationLogger;
|
|
20
|
+
mode: 'dev' | 'build';
|
|
18
21
|
}): Promise<void>;
|
|
19
22
|
export declare function getCreateTableQuery(collectionName: string, collection: DBCollection): string;
|
|
23
|
+
export declare function schemaTypeToSqlType(type: FieldType): 'text' | 'integer';
|
|
24
|
+
export declare function getModifiers(fieldName: string, field: DBField): string;
|
|
25
|
+
type WithDefaultDefined<T extends DBField> = T & Required<Pick<T, 'default'>>;
|
|
26
|
+
type DBFieldWithDefault = WithDefaultDefined<TextField> | WithDefaultDefined<DateField> | WithDefaultDefined<NumberField> | WithDefaultDefined<BooleanField> | WithDefaultDefined<JsonField>;
|
|
27
|
+
export declare function hasDefault(field: DBField): field is DBFieldWithDefault;
|
|
20
28
|
export declare function collectionToTable(name: string, collection: DBCollection, isJsonSerializable?: boolean): import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
21
29
|
name: string;
|
|
22
30
|
schema: undefined;
|
|
@@ -33,18 +41,6 @@ export declare function collectionToTable(name: string, collection: DBCollection
|
|
|
33
41
|
enumValues: string[] | undefined;
|
|
34
42
|
baseColumn: never;
|
|
35
43
|
}, object>;
|
|
36
|
-
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
37
|
-
name: "id";
|
|
38
|
-
tableName: string;
|
|
39
|
-
dataType: "string";
|
|
40
|
-
columnType: "SQLiteText";
|
|
41
|
-
data: string;
|
|
42
|
-
driverParam: string;
|
|
43
|
-
notNull: true;
|
|
44
|
-
hasDefault: true;
|
|
45
|
-
enumValues: [string, ...string[]];
|
|
46
|
-
baseColumn: never;
|
|
47
|
-
}, object>;
|
|
48
44
|
};
|
|
49
45
|
dialect: "sqlite";
|
|
50
46
|
}>;
|