@astrojs/db 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +29 -29
- package/dist/types.d.ts +18 -18
- package/dist/types.js +3 -2
- package/package.json +2 -1
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BooleanField, type DBFieldInput, type DateFieldInput, type JsonField, type NumberField, type TextField, type collectionSchema } from './types.js';
|
|
1
|
+
import { type BooleanField, type DBFieldInput, type DateFieldInput, type JsonField, type NumberField, type TextField, type collectionSchema, type MaybePromise } from './types.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare const dbConfigSchema: z.ZodObject<{
|
|
4
4
|
studio: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -97,7 +97,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
97
97
|
unique?: boolean | undefined;
|
|
98
98
|
default?: unknown;
|
|
99
99
|
}>]>>;
|
|
100
|
-
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
100
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
101
101
|
writable: z.ZodLiteral<false>;
|
|
102
102
|
}, "strip", z.ZodTypeAny, {
|
|
103
103
|
fields: Record<string, {
|
|
@@ -133,7 +133,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
133
133
|
default?: unknown;
|
|
134
134
|
}>;
|
|
135
135
|
writable: false;
|
|
136
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
136
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
137
137
|
}, {
|
|
138
138
|
fields: Record<string, {
|
|
139
139
|
type: "boolean";
|
|
@@ -168,7 +168,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
168
168
|
default?: unknown;
|
|
169
169
|
}>;
|
|
170
170
|
writable: false;
|
|
171
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
171
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
172
172
|
}>, z.ZodObject<{
|
|
173
173
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
174
174
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -264,7 +264,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
264
264
|
unique?: boolean | undefined;
|
|
265
265
|
default?: unknown;
|
|
266
266
|
}>]>>;
|
|
267
|
-
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
267
|
+
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
268
268
|
writable: z.ZodLiteral<true>;
|
|
269
269
|
}, "strip", z.ZodTypeAny, {
|
|
270
270
|
fields: Record<string, {
|
|
@@ -300,7 +300,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
300
300
|
default?: unknown;
|
|
301
301
|
}>;
|
|
302
302
|
writable: true;
|
|
303
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
303
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
304
304
|
}, {
|
|
305
305
|
fields: Record<string, {
|
|
306
306
|
type: "boolean";
|
|
@@ -335,7 +335,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
335
335
|
default?: unknown;
|
|
336
336
|
}>;
|
|
337
337
|
writable: true;
|
|
338
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
338
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
339
339
|
}>]>>>;
|
|
340
340
|
}, "strip", z.ZodTypeAny, {
|
|
341
341
|
studio?: boolean | undefined;
|
|
@@ -373,7 +373,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
373
373
|
default?: unknown;
|
|
374
374
|
}>;
|
|
375
375
|
writable: false;
|
|
376
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
376
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
377
377
|
} | {
|
|
378
378
|
fields: Record<string, {
|
|
379
379
|
type: "boolean";
|
|
@@ -408,7 +408,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
408
408
|
default?: unknown;
|
|
409
409
|
}>;
|
|
410
410
|
writable: true;
|
|
411
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
411
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
412
412
|
}> | undefined;
|
|
413
413
|
}, {
|
|
414
414
|
studio?: boolean | undefined;
|
|
@@ -446,7 +446,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
446
446
|
default?: unknown;
|
|
447
447
|
}>;
|
|
448
448
|
writable: false;
|
|
449
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
449
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
450
450
|
} | {
|
|
451
451
|
fields: Record<string, {
|
|
452
452
|
type: "boolean";
|
|
@@ -481,7 +481,7 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
481
481
|
default?: unknown;
|
|
482
482
|
}>;
|
|
483
483
|
writable: true;
|
|
484
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
484
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
485
485
|
}> | undefined;
|
|
486
486
|
}>;
|
|
487
487
|
export type DBUserConfig = z.input<typeof dbConfigSchema>;
|
|
@@ -583,7 +583,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
583
583
|
unique?: boolean | undefined;
|
|
584
584
|
default?: unknown;
|
|
585
585
|
}>]>>;
|
|
586
|
-
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
586
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
587
587
|
writable: z.ZodLiteral<false>;
|
|
588
588
|
}, "strip", z.ZodTypeAny, {
|
|
589
589
|
fields: Record<string, {
|
|
@@ -619,7 +619,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
619
619
|
default?: unknown;
|
|
620
620
|
}>;
|
|
621
621
|
writable: false;
|
|
622
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
622
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
623
623
|
}, {
|
|
624
624
|
fields: Record<string, {
|
|
625
625
|
type: "boolean";
|
|
@@ -654,7 +654,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
654
654
|
default?: unknown;
|
|
655
655
|
}>;
|
|
656
656
|
writable: false;
|
|
657
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
657
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
658
658
|
}>, z.ZodObject<{
|
|
659
659
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
660
660
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -750,7 +750,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
750
750
|
unique?: boolean | undefined;
|
|
751
751
|
default?: unknown;
|
|
752
752
|
}>]>>;
|
|
753
|
-
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
753
|
+
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
754
754
|
writable: z.ZodLiteral<true>;
|
|
755
755
|
}, "strip", z.ZodTypeAny, {
|
|
756
756
|
fields: Record<string, {
|
|
@@ -786,7 +786,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
786
786
|
default?: unknown;
|
|
787
787
|
}>;
|
|
788
788
|
writable: true;
|
|
789
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
789
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
790
790
|
}, {
|
|
791
791
|
fields: Record<string, {
|
|
792
792
|
type: "boolean";
|
|
@@ -821,7 +821,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
821
821
|
default?: unknown;
|
|
822
822
|
}>;
|
|
823
823
|
writable: true;
|
|
824
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
824
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
825
825
|
}>]>>>;
|
|
826
826
|
}, "strip", z.ZodTypeAny, {
|
|
827
827
|
studio?: boolean | undefined;
|
|
@@ -859,7 +859,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
859
859
|
default?: unknown;
|
|
860
860
|
}>;
|
|
861
861
|
writable: false;
|
|
862
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
862
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
863
863
|
} | {
|
|
864
864
|
fields: Record<string, {
|
|
865
865
|
type: "boolean";
|
|
@@ -894,7 +894,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
894
894
|
default?: unknown;
|
|
895
895
|
}>;
|
|
896
896
|
writable: true;
|
|
897
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
897
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
898
898
|
}> | undefined;
|
|
899
899
|
}, {
|
|
900
900
|
studio?: boolean | undefined;
|
|
@@ -932,7 +932,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
932
932
|
default?: unknown;
|
|
933
933
|
}>;
|
|
934
934
|
writable: false;
|
|
935
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
935
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
936
936
|
} | {
|
|
937
937
|
fields: Record<string, {
|
|
938
938
|
type: "boolean";
|
|
@@ -967,7 +967,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
967
967
|
default?: unknown;
|
|
968
968
|
}>;
|
|
969
969
|
writable: true;
|
|
970
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
970
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
971
971
|
}> | undefined;
|
|
972
972
|
}>>;
|
|
973
973
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1007,7 +1007,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1007
1007
|
default?: unknown;
|
|
1008
1008
|
}>;
|
|
1009
1009
|
writable: false;
|
|
1010
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1010
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1011
1011
|
} | {
|
|
1012
1012
|
fields: Record<string, {
|
|
1013
1013
|
type: "boolean";
|
|
@@ -1042,7 +1042,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1042
1042
|
default?: unknown;
|
|
1043
1043
|
}>;
|
|
1044
1044
|
writable: true;
|
|
1045
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1045
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1046
1046
|
}> | undefined;
|
|
1047
1047
|
} | undefined;
|
|
1048
1048
|
}, {
|
|
@@ -1082,7 +1082,7 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1082
1082
|
default?: unknown;
|
|
1083
1083
|
}>;
|
|
1084
1084
|
writable: false;
|
|
1085
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1085
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1086
1086
|
} | {
|
|
1087
1087
|
fields: Record<string, {
|
|
1088
1088
|
type: "boolean";
|
|
@@ -1117,20 +1117,20 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1117
1117
|
default?: unknown;
|
|
1118
1118
|
}>;
|
|
1119
1119
|
writable: true;
|
|
1120
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1120
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1121
1121
|
}> | undefined;
|
|
1122
1122
|
} | undefined;
|
|
1123
1123
|
}>;
|
|
1124
1124
|
type CollectionConfig<TFields extends z.input<typeof collectionSchema>['fields'], Writable extends boolean> = Writable extends true ? {
|
|
1125
1125
|
fields: TFields;
|
|
1126
|
-
seed?: Writable extends false ? never : () => Array<Record<keyof TFields, any> & {
|
|
1126
|
+
seed?: Writable extends false ? never : () => MaybePromise<Array<Record<keyof TFields, any> & {
|
|
1127
1127
|
id?: string;
|
|
1128
|
-
}
|
|
1128
|
+
}>>;
|
|
1129
1129
|
} : {
|
|
1130
1130
|
fields: TFields;
|
|
1131
|
-
data?: Writable extends true ? never : () => Array<Record<keyof TFields, any> & {
|
|
1131
|
+
data?: Writable extends true ? never : () => MaybePromise<Array<Record<keyof TFields, any> & {
|
|
1132
1132
|
id?: string;
|
|
1133
|
-
}
|
|
1133
|
+
}>>;
|
|
1134
1134
|
};
|
|
1135
1135
|
type ResolvedCollectionConfig<TFields extends z.input<typeof collectionSchema>['fields'], Writable extends boolean> = CollectionConfig<TFields, Writable> & {
|
|
1136
1136
|
writable: Writable;
|
package/dist/types.d.ts
CHANGED
|
@@ -382,7 +382,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
382
382
|
unique?: boolean | undefined;
|
|
383
383
|
default?: unknown;
|
|
384
384
|
}>]>>;
|
|
385
|
-
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
385
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
386
386
|
writable: z.ZodLiteral<false>;
|
|
387
387
|
}, "strip", z.ZodTypeAny, {
|
|
388
388
|
fields: Record<string, {
|
|
@@ -418,7 +418,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
418
418
|
default?: unknown;
|
|
419
419
|
}>;
|
|
420
420
|
writable: false;
|
|
421
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
421
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
422
422
|
}, {
|
|
423
423
|
fields: Record<string, {
|
|
424
424
|
type: "boolean";
|
|
@@ -453,7 +453,7 @@ export declare const readableCollectionSchema: z.ZodObject<{
|
|
|
453
453
|
default?: unknown;
|
|
454
454
|
}>;
|
|
455
455
|
writable: false;
|
|
456
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
456
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
457
457
|
}>;
|
|
458
458
|
export declare const writableCollectionSchema: z.ZodObject<{
|
|
459
459
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
@@ -550,7 +550,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
550
550
|
unique?: boolean | undefined;
|
|
551
551
|
default?: unknown;
|
|
552
552
|
}>]>>;
|
|
553
|
-
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
553
|
+
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
554
554
|
writable: z.ZodLiteral<true>;
|
|
555
555
|
}, "strip", z.ZodTypeAny, {
|
|
556
556
|
fields: Record<string, {
|
|
@@ -586,7 +586,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
586
586
|
default?: unknown;
|
|
587
587
|
}>;
|
|
588
588
|
writable: true;
|
|
589
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
589
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
590
590
|
}, {
|
|
591
591
|
fields: Record<string, {
|
|
592
592
|
type: "boolean";
|
|
@@ -621,7 +621,7 @@ export declare const writableCollectionSchema: z.ZodObject<{
|
|
|
621
621
|
default?: unknown;
|
|
622
622
|
}>;
|
|
623
623
|
writable: true;
|
|
624
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
624
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
625
625
|
}>;
|
|
626
626
|
export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
627
627
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
@@ -718,7 +718,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
718
718
|
unique?: boolean | undefined;
|
|
719
719
|
default?: unknown;
|
|
720
720
|
}>]>>;
|
|
721
|
-
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
721
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
722
722
|
writable: z.ZodLiteral<false>;
|
|
723
723
|
}, "strip", z.ZodTypeAny, {
|
|
724
724
|
fields: Record<string, {
|
|
@@ -754,7 +754,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
754
754
|
default?: unknown;
|
|
755
755
|
}>;
|
|
756
756
|
writable: false;
|
|
757
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
757
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
758
758
|
}, {
|
|
759
759
|
fields: Record<string, {
|
|
760
760
|
type: "boolean";
|
|
@@ -789,7 +789,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
789
789
|
default?: unknown;
|
|
790
790
|
}>;
|
|
791
791
|
writable: false;
|
|
792
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
792
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
793
793
|
}>, z.ZodObject<{
|
|
794
794
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
795
795
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -885,7 +885,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
885
885
|
unique?: boolean | undefined;
|
|
886
886
|
default?: unknown;
|
|
887
887
|
}>]>>;
|
|
888
|
-
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
888
|
+
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
889
889
|
writable: z.ZodLiteral<true>;
|
|
890
890
|
}, "strip", z.ZodTypeAny, {
|
|
891
891
|
fields: Record<string, {
|
|
@@ -921,7 +921,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
921
921
|
default?: unknown;
|
|
922
922
|
}>;
|
|
923
923
|
writable: true;
|
|
924
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
924
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
925
925
|
}, {
|
|
926
926
|
fields: Record<string, {
|
|
927
927
|
type: "boolean";
|
|
@@ -956,7 +956,7 @@ export declare const collectionSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
956
956
|
default?: unknown;
|
|
957
957
|
}>;
|
|
958
958
|
writable: true;
|
|
959
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
959
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
960
960
|
}>]>;
|
|
961
961
|
export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
962
962
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
@@ -1053,7 +1053,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1053
1053
|
unique?: boolean | undefined;
|
|
1054
1054
|
default?: unknown;
|
|
1055
1055
|
}>]>>;
|
|
1056
|
-
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
1056
|
+
data: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
1057
1057
|
writable: z.ZodLiteral<false>;
|
|
1058
1058
|
}, "strip", z.ZodTypeAny, {
|
|
1059
1059
|
fields: Record<string, {
|
|
@@ -1089,7 +1089,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1089
1089
|
default?: unknown;
|
|
1090
1090
|
}>;
|
|
1091
1091
|
writable: false;
|
|
1092
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1092
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1093
1093
|
}, {
|
|
1094
1094
|
fields: Record<string, {
|
|
1095
1095
|
type: "boolean";
|
|
@@ -1124,7 +1124,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1124
1124
|
default?: unknown;
|
|
1125
1125
|
}>;
|
|
1126
1126
|
writable: false;
|
|
1127
|
-
data?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1127
|
+
data?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1128
1128
|
}>, z.ZodObject<{
|
|
1129
1129
|
fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
1130
1130
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -1220,7 +1220,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1220
1220
|
unique?: boolean | undefined;
|
|
1221
1221
|
default?: unknown;
|
|
1222
1222
|
}>]>>;
|
|
1223
|
-
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>>;
|
|
1223
|
+
seed: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">, z.ZodPromise<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>]>>>;
|
|
1224
1224
|
writable: z.ZodLiteral<true>;
|
|
1225
1225
|
}, "strip", z.ZodTypeAny, {
|
|
1226
1226
|
fields: Record<string, {
|
|
@@ -1256,7 +1256,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1256
1256
|
default?: unknown;
|
|
1257
1257
|
}>;
|
|
1258
1258
|
writable: true;
|
|
1259
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1259
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1260
1260
|
}, {
|
|
1261
1261
|
fields: Record<string, {
|
|
1262
1262
|
type: "boolean";
|
|
@@ -1291,7 +1291,7 @@ export declare const collectionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.Z
|
|
|
1291
1291
|
default?: unknown;
|
|
1292
1292
|
}>;
|
|
1293
1293
|
writable: true;
|
|
1294
|
-
seed?: ((...args: unknown[]) => Record<string, unknown>[]) | undefined;
|
|
1294
|
+
seed?: ((...args: unknown[]) => Record<string, unknown>[] | Promise<Record<string, unknown>[]>) | undefined;
|
|
1295
1295
|
}>]>>;
|
|
1296
1296
|
export type BooleanField = z.infer<typeof booleanFieldSchema>;
|
|
1297
1297
|
export type NumberField = z.infer<typeof numberFieldSchema>;
|
package/dist/types.js
CHANGED
|
@@ -38,14 +38,15 @@ const fieldSchema = z.union([
|
|
|
38
38
|
jsonFieldSchema
|
|
39
39
|
]);
|
|
40
40
|
const fieldsSchema = z.record(fieldSchema);
|
|
41
|
+
const dataResponse = z.array(z.record(z.unknown()));
|
|
41
42
|
const readableCollectionSchema = z.object({
|
|
42
43
|
fields: fieldsSchema,
|
|
43
|
-
data: z.function().returns(z.
|
|
44
|
+
data: z.function().returns(z.union([dataResponse, z.promise(dataResponse)])).optional(),
|
|
44
45
|
writable: z.literal(false)
|
|
45
46
|
});
|
|
46
47
|
const writableCollectionSchema = z.object({
|
|
47
48
|
fields: fieldsSchema,
|
|
48
|
-
seed: z.function().returns(z.
|
|
49
|
+
seed: z.function().returns(z.union([dataResponse, z.promise(dataResponse)])).optional(),
|
|
49
50
|
writable: z.literal(true)
|
|
50
51
|
});
|
|
51
52
|
const collectionSchema = z.union([readableCollectionSchema, writableCollectionSchema]);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"author": "withastro",
|
|
9
|
+
"main": "./dist/index.js",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./index.d.ts",
|