@astrojs/db 0.3.4 → 0.3.6-nightly-01234567890
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/bin.d.ts +2 -0
- package/dist/cli/commands/deploy/index.d.ts +1 -0
- package/dist/cli/commands/diff/index.d.ts +4 -0
- package/dist/cli/commands/run/index.d.ts +1 -0
- package/dist/cli/commands/snapshot/index.d.ts +4 -0
- package/dist/cli/util.d.ts +34 -0
- package/dist/config.d.ts +13 -137
- package/dist/core/cli/commands/gen/index.d.ts +6 -0
- package/dist/core/cli/commands/link/index.js +7 -3
- package/dist/core/cli/commands/push/index.js +3 -3
- package/dist/core/cli/commands/verify/index.js +6 -1
- package/dist/core/cli/index.js +8 -6
- package/dist/core/cli/migration-queries.d.ts +4 -4
- package/dist/core/cli/migration-queries.js +78 -77
- package/dist/core/cli/migrations.js +15 -7
- package/dist/core/errors.d.ts +2 -0
- package/dist/core/errors.js +26 -9
- package/dist/core/integration/file-url.js +2 -1
- package/dist/core/integration/index.js +106 -53
- package/dist/core/integration/typegen.d.ts +3 -3
- package/dist/core/integration/typegen.js +8 -8
- package/dist/core/integration/vite-plugin-db.d.ts +14 -9
- package/dist/core/integration/vite-plugin-db.js +15 -12
- package/dist/core/integration/vite-plugin-inject-env-ts.d.ts +4 -2
- package/dist/core/integration/vite-plugin-inject-env-ts.js +8 -4
- package/dist/core/queries.d.ts +20 -20
- package/dist/core/queries.js +50 -32
- package/dist/core/types.d.ts +1162 -1153
- package/dist/core/types.js +63 -61
- package/dist/core/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/integration.d.ts +1 -1
- package/dist/internal.d.ts +4 -4
- package/dist/runtime/db-client.d.ts +9 -4
- package/dist/runtime/db-client.js +11 -7
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +29 -43
- package/dist/runtime/types.d.ts +7 -7
- package/dist/types.d.ts +6 -124
- package/dist/utils-runtime.d.ts +1 -0
- package/dist/vite-plugin-db.d.ts +3 -3
- package/package.json +13 -15
- package/LICENSE +0 -59
- package/components/Renderer.astro +0 -14
- package/components/astro-env.d.ts +0 -1
- package/components/index.ts +0 -2
- package/components/tsconfig.json +0 -7
- package/dist/cli/seed.d.ts +0 -6
- package/dist/file-url-integration.d.ts +0 -2
- package/dist/root.d.ts +0 -3
- /package/dist/core/cli/commands/{sync → gen}/index.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cmd(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cmd(): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function createRemoteDbClient(appToken: string): import("drizzle-orm/sqlite-proxy").SqliteRemoteDatabase<Record<string, never>>;
|
|
2
|
+
export declare const STUDIO_ADMIN_TABLE = "ReservedAstroStudioAdmin";
|
|
3
|
+
export declare const STUDIO_ADMIN_TABLE_ROW_ID = "admin";
|
|
4
|
+
export declare const adminTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
5
|
+
name: "ReservedAstroStudioAdmin";
|
|
6
|
+
schema: undefined;
|
|
7
|
+
columns: {
|
|
8
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
9
|
+
name: "id";
|
|
10
|
+
tableName: "ReservedAstroStudioAdmin";
|
|
11
|
+
dataType: "string";
|
|
12
|
+
columnType: "SQLiteText";
|
|
13
|
+
data: string;
|
|
14
|
+
driverParam: string;
|
|
15
|
+
notNull: true;
|
|
16
|
+
hasDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
}, object>;
|
|
20
|
+
collections: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
21
|
+
name: "collections";
|
|
22
|
+
tableName: "ReservedAstroStudioAdmin";
|
|
23
|
+
dataType: "string";
|
|
24
|
+
columnType: "SQLiteText";
|
|
25
|
+
data: string;
|
|
26
|
+
driverParam: string;
|
|
27
|
+
notNull: true;
|
|
28
|
+
hasDefault: false;
|
|
29
|
+
enumValues: [string, ...string[]];
|
|
30
|
+
baseColumn: never;
|
|
31
|
+
}, object>;
|
|
32
|
+
};
|
|
33
|
+
dialect: "sqlite";
|
|
34
|
+
}>;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { SQLiteInsertValue } from 'drizzle-orm/sqlite-core';
|
|
2
2
|
import type { SqliteDB, Table } from './internal.js';
|
|
3
3
|
import type { MaybeArray, collectionSchema } from './types.js';
|
|
4
|
-
import { type BooleanField, type DBFieldInput, type DateFieldInput, type JsonField, type NumberField, type TextField, type
|
|
4
|
+
import { type BooleanField, type DBFieldInput, type DateFieldInput, type JsonField, type NumberField, type TextField, type MaybePromise } from './types.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
export type DBFieldsConfig = z.input<typeof collectionSchema>['fields'];
|
|
6
7
|
export type DBDataContext = {
|
|
7
8
|
db: SqliteDB;
|
|
8
|
-
seed<TFields extends
|
|
9
|
-
/** TODO: true type inference */ Record<Extract<keyof TFields, string>,
|
|
9
|
+
seed<TFields extends DBFieldsConfig>(collection: ResolvedCollectionConfig<TFields>, data: MaybeArray<SQLiteInsertValue<Table<string,
|
|
10
|
+
/** TODO: true type inference */ Record<Extract<keyof TFields, string>, DBFieldsConfig[number]>>>>): Promise<any> /** TODO: type output */;
|
|
10
11
|
mode: 'dev' | 'build';
|
|
11
12
|
};
|
|
12
13
|
export declare const dbConfigSchema: z.ZodObject<{
|
|
@@ -112,19 +113,9 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
112
113
|
unique?: boolean | undefined;
|
|
113
114
|
default?: unknown;
|
|
114
115
|
}>]>>;
|
|
115
|
-
|
|
116
|
-
on: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
117
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
-
}, "strip", z.ZodTypeAny, {
|
|
119
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
120
|
-
unique?: boolean | undefined;
|
|
121
|
-
}, {
|
|
122
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
123
|
-
unique?: boolean | undefined;
|
|
124
|
-
}>>>;
|
|
116
|
+
writable: z.ZodLiteral<false>;
|
|
125
117
|
table: z.ZodAny;
|
|
126
118
|
_setMeta: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
127
|
-
writable: z.ZodLiteral<false>;
|
|
128
119
|
}, "strip", z.ZodTypeAny, {
|
|
129
120
|
fields: Record<string, {
|
|
130
121
|
type: "boolean";
|
|
@@ -161,10 +152,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
161
152
|
default?: unknown;
|
|
162
153
|
}>;
|
|
163
154
|
writable: false;
|
|
164
|
-
indexes?: Record<string, {
|
|
165
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
166
|
-
unique?: boolean | undefined;
|
|
167
|
-
}> | undefined;
|
|
168
155
|
table?: any;
|
|
169
156
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
170
157
|
}, {
|
|
@@ -203,10 +190,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
203
190
|
default?: unknown;
|
|
204
191
|
}>;
|
|
205
192
|
writable: false;
|
|
206
|
-
indexes?: Record<string, {
|
|
207
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
208
|
-
unique?: boolean | undefined;
|
|
209
|
-
}> | undefined;
|
|
210
193
|
table?: any;
|
|
211
194
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
212
195
|
}>, z.ZodObject<{
|
|
@@ -310,19 +293,9 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
310
293
|
unique?: boolean | undefined;
|
|
311
294
|
default?: unknown;
|
|
312
295
|
}>]>>;
|
|
313
|
-
|
|
314
|
-
on: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
315
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
316
|
-
}, "strip", z.ZodTypeAny, {
|
|
317
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
318
|
-
unique?: boolean | undefined;
|
|
319
|
-
}, {
|
|
320
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
321
|
-
unique?: boolean | undefined;
|
|
322
|
-
}>>>;
|
|
296
|
+
writable: z.ZodLiteral<true>;
|
|
323
297
|
table: z.ZodAny;
|
|
324
298
|
_setMeta: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
325
|
-
writable: z.ZodLiteral<true>;
|
|
326
299
|
}, "strip", z.ZodTypeAny, {
|
|
327
300
|
fields: Record<string, {
|
|
328
301
|
type: "boolean";
|
|
@@ -359,10 +332,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
359
332
|
default?: unknown;
|
|
360
333
|
}>;
|
|
361
334
|
writable: true;
|
|
362
|
-
indexes?: Record<string, {
|
|
363
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
364
|
-
unique?: boolean | undefined;
|
|
365
|
-
}> | undefined;
|
|
366
335
|
table?: any;
|
|
367
336
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
368
337
|
}, {
|
|
@@ -401,10 +370,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
401
370
|
default?: unknown;
|
|
402
371
|
}>;
|
|
403
372
|
writable: true;
|
|
404
|
-
indexes?: Record<string, {
|
|
405
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
406
|
-
unique?: boolean | undefined;
|
|
407
|
-
}> | undefined;
|
|
408
373
|
table?: any;
|
|
409
374
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
410
375
|
}>]>>>;
|
|
@@ -447,10 +412,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
447
412
|
default?: unknown;
|
|
448
413
|
}>;
|
|
449
414
|
writable: false;
|
|
450
|
-
indexes?: Record<string, {
|
|
451
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
452
|
-
unique?: boolean | undefined;
|
|
453
|
-
}> | undefined;
|
|
454
415
|
table?: any;
|
|
455
416
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
456
417
|
} | {
|
|
@@ -489,10 +450,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
489
450
|
default?: unknown;
|
|
490
451
|
}>;
|
|
491
452
|
writable: true;
|
|
492
|
-
indexes?: Record<string, {
|
|
493
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
494
|
-
unique?: boolean | undefined;
|
|
495
|
-
}> | undefined;
|
|
496
453
|
table?: any;
|
|
497
454
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
498
455
|
}> | undefined;
|
|
@@ -535,10 +492,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
535
492
|
default?: unknown;
|
|
536
493
|
}>;
|
|
537
494
|
writable: false;
|
|
538
|
-
indexes?: Record<string, {
|
|
539
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
540
|
-
unique?: boolean | undefined;
|
|
541
|
-
}> | undefined;
|
|
542
495
|
table?: any;
|
|
543
496
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
544
497
|
} | {
|
|
@@ -577,10 +530,6 @@ export declare const dbConfigSchema: z.ZodObject<{
|
|
|
577
530
|
default?: unknown;
|
|
578
531
|
}>;
|
|
579
532
|
writable: true;
|
|
580
|
-
indexes?: Record<string, {
|
|
581
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
582
|
-
unique?: boolean | undefined;
|
|
583
|
-
}> | undefined;
|
|
584
533
|
table?: any;
|
|
585
534
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
586
535
|
}> | undefined;
|
|
@@ -693,19 +642,9 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
693
642
|
unique?: boolean | undefined;
|
|
694
643
|
default?: unknown;
|
|
695
644
|
}>]>>;
|
|
696
|
-
|
|
697
|
-
on: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
698
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
699
|
-
}, "strip", z.ZodTypeAny, {
|
|
700
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
701
|
-
unique?: boolean | undefined;
|
|
702
|
-
}, {
|
|
703
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
704
|
-
unique?: boolean | undefined;
|
|
705
|
-
}>>>;
|
|
645
|
+
writable: z.ZodLiteral<false>;
|
|
706
646
|
table: z.ZodAny;
|
|
707
647
|
_setMeta: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
708
|
-
writable: z.ZodLiteral<false>;
|
|
709
648
|
}, "strip", z.ZodTypeAny, {
|
|
710
649
|
fields: Record<string, {
|
|
711
650
|
type: "boolean";
|
|
@@ -742,10 +681,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
742
681
|
default?: unknown;
|
|
743
682
|
}>;
|
|
744
683
|
writable: false;
|
|
745
|
-
indexes?: Record<string, {
|
|
746
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
747
|
-
unique?: boolean | undefined;
|
|
748
|
-
}> | undefined;
|
|
749
684
|
table?: any;
|
|
750
685
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
751
686
|
}, {
|
|
@@ -784,10 +719,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
784
719
|
default?: unknown;
|
|
785
720
|
}>;
|
|
786
721
|
writable: false;
|
|
787
|
-
indexes?: Record<string, {
|
|
788
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
789
|
-
unique?: boolean | undefined;
|
|
790
|
-
}> | undefined;
|
|
791
722
|
table?: any;
|
|
792
723
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
793
724
|
}>, z.ZodObject<{
|
|
@@ -891,19 +822,9 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
891
822
|
unique?: boolean | undefined;
|
|
892
823
|
default?: unknown;
|
|
893
824
|
}>]>>;
|
|
894
|
-
|
|
895
|
-
on: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
896
|
-
unique: z.ZodOptional<z.ZodBoolean>;
|
|
897
|
-
}, "strip", z.ZodTypeAny, {
|
|
898
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
899
|
-
unique?: boolean | undefined;
|
|
900
|
-
}, {
|
|
901
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
902
|
-
unique?: boolean | undefined;
|
|
903
|
-
}>>>;
|
|
825
|
+
writable: z.ZodLiteral<true>;
|
|
904
826
|
table: z.ZodAny;
|
|
905
827
|
_setMeta: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
906
|
-
writable: z.ZodLiteral<true>;
|
|
907
828
|
}, "strip", z.ZodTypeAny, {
|
|
908
829
|
fields: Record<string, {
|
|
909
830
|
type: "boolean";
|
|
@@ -940,10 +861,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
940
861
|
default?: unknown;
|
|
941
862
|
}>;
|
|
942
863
|
writable: true;
|
|
943
|
-
indexes?: Record<string, {
|
|
944
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
945
|
-
unique?: boolean | undefined;
|
|
946
|
-
}> | undefined;
|
|
947
864
|
table?: any;
|
|
948
865
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
949
866
|
}, {
|
|
@@ -982,10 +899,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
982
899
|
default?: unknown;
|
|
983
900
|
}>;
|
|
984
901
|
writable: true;
|
|
985
|
-
indexes?: Record<string, {
|
|
986
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
987
|
-
unique?: boolean | undefined;
|
|
988
|
-
}> | undefined;
|
|
989
902
|
table?: any;
|
|
990
903
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
991
904
|
}>]>>>;
|
|
@@ -1028,10 +941,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1028
941
|
default?: unknown;
|
|
1029
942
|
}>;
|
|
1030
943
|
writable: false;
|
|
1031
|
-
indexes?: Record<string, {
|
|
1032
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1033
|
-
unique?: boolean | undefined;
|
|
1034
|
-
}> | undefined;
|
|
1035
944
|
table?: any;
|
|
1036
945
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1037
946
|
} | {
|
|
@@ -1070,10 +979,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1070
979
|
default?: unknown;
|
|
1071
980
|
}>;
|
|
1072
981
|
writable: true;
|
|
1073
|
-
indexes?: Record<string, {
|
|
1074
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1075
|
-
unique?: boolean | undefined;
|
|
1076
|
-
}> | undefined;
|
|
1077
982
|
table?: any;
|
|
1078
983
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1079
984
|
}> | undefined;
|
|
@@ -1116,10 +1021,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1116
1021
|
default?: unknown;
|
|
1117
1022
|
}>;
|
|
1118
1023
|
writable: false;
|
|
1119
|
-
indexes?: Record<string, {
|
|
1120
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1121
|
-
unique?: boolean | undefined;
|
|
1122
|
-
}> | undefined;
|
|
1123
1024
|
table?: any;
|
|
1124
1025
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1125
1026
|
} | {
|
|
@@ -1158,10 +1059,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1158
1059
|
default?: unknown;
|
|
1159
1060
|
}>;
|
|
1160
1061
|
writable: true;
|
|
1161
|
-
indexes?: Record<string, {
|
|
1162
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1163
|
-
unique?: boolean | undefined;
|
|
1164
|
-
}> | undefined;
|
|
1165
1062
|
table?: any;
|
|
1166
1063
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1167
1064
|
}> | undefined;
|
|
@@ -1206,10 +1103,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1206
1103
|
default?: unknown;
|
|
1207
1104
|
}>;
|
|
1208
1105
|
writable: false;
|
|
1209
|
-
indexes?: Record<string, {
|
|
1210
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1211
|
-
unique?: boolean | undefined;
|
|
1212
|
-
}> | undefined;
|
|
1213
1106
|
table?: any;
|
|
1214
1107
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1215
1108
|
} | {
|
|
@@ -1248,10 +1141,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1248
1141
|
default?: unknown;
|
|
1249
1142
|
}>;
|
|
1250
1143
|
writable: true;
|
|
1251
|
-
indexes?: Record<string, {
|
|
1252
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1253
|
-
unique?: boolean | undefined;
|
|
1254
|
-
}> | undefined;
|
|
1255
1144
|
table?: any;
|
|
1256
1145
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1257
1146
|
}> | undefined;
|
|
@@ -1296,10 +1185,6 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1296
1185
|
default?: unknown;
|
|
1297
1186
|
}>;
|
|
1298
1187
|
writable: false;
|
|
1299
|
-
indexes?: Record<string, {
|
|
1300
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1301
|
-
unique?: boolean | undefined;
|
|
1302
|
-
}> | undefined;
|
|
1303
1188
|
table?: any;
|
|
1304
1189
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1305
1190
|
} | {
|
|
@@ -1338,30 +1223,21 @@ export declare const astroConfigWithDbSchema: z.ZodObject<{
|
|
|
1338
1223
|
default?: unknown;
|
|
1339
1224
|
}>;
|
|
1340
1225
|
writable: true;
|
|
1341
|
-
indexes?: Record<string, {
|
|
1342
|
-
on: (string | string[]) & (string | string[] | undefined);
|
|
1343
|
-
unique?: boolean | undefined;
|
|
1344
|
-
}> | undefined;
|
|
1345
1226
|
table?: any;
|
|
1346
1227
|
_setMeta?: ((...args: unknown[]) => unknown) | undefined;
|
|
1347
1228
|
}> | undefined;
|
|
1348
1229
|
data?: ((...args: unknown[]) => void | Promise<void>) | undefined;
|
|
1349
1230
|
} | undefined;
|
|
1350
1231
|
}>;
|
|
1351
|
-
|
|
1352
|
-
interface CollectionConfig<TFields extends FieldsConfig> extends Pick<z.input<typeof collectionSchema>, 'fields' | 'indexes'> {
|
|
1232
|
+
type CollectionConfig<TFields extends DBFieldsConfig> = {
|
|
1353
1233
|
fields: TFields;
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
interface IndexConfig<TFields extends FieldsConfig> extends z.input<typeof indexSchema> {
|
|
1357
|
-
on: MaybeArray<Extract<keyof TFields, string>>;
|
|
1358
|
-
}
|
|
1359
|
-
export type ResolvedCollectionConfig<TFields extends FieldsConfig = FieldsConfig, Writable extends boolean = boolean> = CollectionConfig<TFields> & {
|
|
1234
|
+
};
|
|
1235
|
+
export type ResolvedCollectionConfig<TFields extends DBFieldsConfig = DBFieldsConfig, Writable extends boolean = boolean> = CollectionConfig<TFields> & {
|
|
1360
1236
|
writable: Writable;
|
|
1361
1237
|
table: Table<string, TFields>;
|
|
1362
1238
|
};
|
|
1363
|
-
export declare function defineCollection<TFields extends
|
|
1364
|
-
export declare function defineWritableCollection<TFields extends
|
|
1239
|
+
export declare function defineCollection<TFields extends DBFieldsConfig>(userConfig: CollectionConfig<TFields>): ResolvedCollectionConfig<TFields, false>;
|
|
1240
|
+
export declare function defineWritableCollection<TFields extends DBFieldsConfig>(userConfig: CollectionConfig<TFields>): ResolvedCollectionConfig<TFields, true>;
|
|
1365
1241
|
export type AstroConfigWithDB = z.infer<typeof astroConfigWithDbSchema>;
|
|
1366
1242
|
type FieldOpts<T extends DBFieldInput> = Omit<T, 'type'>;
|
|
1367
1243
|
export declare const field: {
|
|
@@ -27,12 +27,16 @@ async function cmd({ flags }) {
|
|
|
27
27
|
});
|
|
28
28
|
if (!response.ok) {
|
|
29
29
|
if (response.status === 401) {
|
|
30
|
-
console.error(
|
|
30
|
+
console.error(
|
|
31
|
+
`${bgRed("Unauthorized")}
|
|
31
32
|
|
|
32
33
|
Are you logged in?
|
|
33
|
-
Run ${cyan(
|
|
34
|
+
Run ${cyan(
|
|
35
|
+
"astro db login"
|
|
36
|
+
)} to authenticate and then try linking again.
|
|
34
37
|
|
|
35
|
-
`
|
|
38
|
+
`
|
|
39
|
+
);
|
|
36
40
|
process.exit(1);
|
|
37
41
|
}
|
|
38
42
|
console.error(`Failed to link project: ${response.status} ${response.statusText}`);
|
|
@@ -6,7 +6,7 @@ import { red } from "kleur/colors";
|
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
import { recreateTables, seedData } from "../../../queries.js";
|
|
8
8
|
import { getManagedAppTokenOrExit } from "../../../tokens.js";
|
|
9
|
-
import {
|
|
9
|
+
import { tablesSchema } from "../../../types.js";
|
|
10
10
|
import { getRemoteDatabaseUrl } from "../../../utils.js";
|
|
11
11
|
import { getMigrationQueries } from "../../migration-queries.js";
|
|
12
12
|
import {
|
|
@@ -112,9 +112,9 @@ async function pushData({
|
|
|
112
112
|
const libsqlClient = createClient({ url: ":memory:" });
|
|
113
113
|
await recreateTables({
|
|
114
114
|
db: drizzleLibsql(libsqlClient),
|
|
115
|
-
|
|
115
|
+
tables: tablesSchema.parse(config.db.tables ?? {})
|
|
116
116
|
});
|
|
117
|
-
for (const [collectionName, { writable }] of Object.entries(config.db.
|
|
117
|
+
for (const [collectionName, { writable }] of Object.entries(config.db.tables ?? {})) {
|
|
118
118
|
if (!writable) {
|
|
119
119
|
queries.push({
|
|
120
120
|
sql: `DELETE FROM ${sqlite.escapeName(collectionName)}`,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getMigrationStatus,
|
|
3
|
+
MIGRATION_NEEDED,
|
|
4
|
+
MIGRATIONS_NOT_INITIALIZED,
|
|
5
|
+
MIGRATIONS_UP_TO_DATE
|
|
6
|
+
} from "../../migrations.js";
|
|
2
7
|
import { getMigrationQueries } from "../../migration-queries.js";
|
|
3
8
|
async function cmd({ config, flags }) {
|
|
4
9
|
const status = await getMigrationStatus(config);
|
package/dist/core/cli/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { STUDIO_CONFIG_MISSING_CLI_ERROR } from "../errors.js";
|
|
2
2
|
async function cli({ flags, config }) {
|
|
3
|
-
const
|
|
3
|
+
const args = flags._;
|
|
4
|
+
const command = args[2] === "db" ? args[3] : args[2];
|
|
4
5
|
if (!config.db?.studio) {
|
|
5
6
|
console.log(STUDIO_CONFIG_MISSING_CLI_ERROR);
|
|
6
7
|
process.exit(1);
|
|
@@ -10,8 +11,9 @@ async function cli({ flags, config }) {
|
|
|
10
11
|
const { cmd } = await import("./commands/shell/index.js");
|
|
11
12
|
return await cmd({ config, flags });
|
|
12
13
|
}
|
|
14
|
+
case "gen":
|
|
13
15
|
case "sync": {
|
|
14
|
-
const { cmd } = await import("./commands/
|
|
16
|
+
const { cmd } = await import("./commands/gen/index.js");
|
|
15
17
|
return await cmd({ config, flags });
|
|
16
18
|
}
|
|
17
19
|
case "push": {
|
|
@@ -52,11 +54,11 @@ ${showHelp()}`);
|
|
|
52
54
|
|
|
53
55
|
Usage:
|
|
54
56
|
|
|
55
|
-
astro
|
|
56
|
-
astro
|
|
57
|
-
astro
|
|
57
|
+
astro login Authenticate your machine with Astro Studio
|
|
58
|
+
astro logout End your authenticated session with Astro Studio
|
|
59
|
+
astro link Link this directory to an Astro Studio project
|
|
58
60
|
|
|
59
|
-
astro db
|
|
61
|
+
astro db gen Creates snapshot based on your schema
|
|
60
62
|
astro db push Pushes migrations to Astro Studio
|
|
61
63
|
astro db verify Verifies migrations have been pushed and errors if not`;
|
|
62
64
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DBTable, type DBSnapshot } from '../types.js';
|
|
2
2
|
/** Dependency injected for unit testing */
|
|
3
3
|
type AmbiguityResponses = {
|
|
4
4
|
collectionRenames: Record<string, string>;
|
|
5
|
-
|
|
5
|
+
columnRenames: {
|
|
6
6
|
[collectionName: string]: Record<string, string>;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
@@ -16,8 +16,8 @@ export declare function getMigrationQueries({ oldSnapshot, newSnapshot, ambiguit
|
|
|
16
16
|
}>;
|
|
17
17
|
export declare function getCollectionChangeQueries({ collectionName, oldCollection, newCollection, ambiguityResponses, }: {
|
|
18
18
|
collectionName: string;
|
|
19
|
-
oldCollection:
|
|
20
|
-
newCollection:
|
|
19
|
+
oldCollection: DBTable;
|
|
20
|
+
newCollection: DBTable;
|
|
21
21
|
ambiguityResponses?: AmbiguityResponses;
|
|
22
22
|
}): Promise<{
|
|
23
23
|
queries: string[];
|