@astrojs/db 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/core/integration/error-map.d.ts +2 -6
- package/dist/_internal/core/schemas.d.ts +334 -1913
- package/dist/_internal/core/types.d.ts +1 -1
- package/dist/core/cli/commands/push/index.js +5 -6
- package/dist/core/cli/print-help.js +1 -1
- package/dist/core/db-client/utils.js +3 -3
- package/dist/core/integration/error-map.d.ts +2 -6
- package/dist/core/integration/error-map.js +67 -43
- package/dist/core/integration/file-url.js +5 -2
- package/dist/core/integration/index.d.ts +4 -15
- package/dist/core/integration/index.js +23 -23
- package/dist/core/integration/vite-plugin-db-client.js +19 -11
- package/dist/core/integration/vite-plugin-db.js +43 -35
- package/dist/core/load-file.d.ts +13 -13
- package/dist/core/load-file.js +2 -2
- package/dist/core/queries.d.ts +4 -4
- package/dist/core/schemas.d.ts +506 -2085
- package/dist/core/schemas.js +22 -17
- package/dist/core/types.d.ts +1 -1
- package/package.json +7 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as z from 'zod/v4';
|
|
2
2
|
import type { booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, MaybeArray, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
|
|
3
3
|
export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
|
|
4
4
|
export type BooleanColumn = z.infer<typeof booleanColumnSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import * as clack from "@clack/prompts";
|
|
1
2
|
import { sql } from "drizzle-orm";
|
|
2
|
-
import prompts from "prompts";
|
|
3
3
|
import { MIGRATION_VERSION } from "../../../consts.js";
|
|
4
4
|
import { createClient } from "../../../db-client/libsql-node.js";
|
|
5
5
|
import {
|
|
@@ -35,13 +35,12 @@ async function cmd({
|
|
|
35
35
|
console.log(`Database schema is out of date.`);
|
|
36
36
|
}
|
|
37
37
|
if (isForceReset) {
|
|
38
|
-
const
|
|
39
|
-
type: "confirm",
|
|
40
|
-
name: "begin",
|
|
38
|
+
const begin = await clack.confirm({
|
|
41
39
|
message: `Reset your database? All of your data will be erased and your schema created from scratch.`,
|
|
42
|
-
|
|
40
|
+
initialValue: false,
|
|
41
|
+
withGuide: false
|
|
43
42
|
});
|
|
44
|
-
if (
|
|
43
|
+
if (begin !== true) {
|
|
45
44
|
console.log("Canceled.");
|
|
46
45
|
process.exit(0);
|
|
47
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
const rawLibSQLOptions = z.record(z.string());
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
const rawLibSQLOptions = z.record(z.string(), z.string());
|
|
3
3
|
const parseNumber = (value) => z.coerce.number().parse(value);
|
|
4
4
|
const parseBoolean = (value) => z.coerce.boolean().parse(value);
|
|
5
5
|
const booleanValues = ["true", "false"];
|
|
@@ -36,7 +36,7 @@ const parseLibSQLConfig = (config) => {
|
|
|
36
36
|
return libSQLConfigTransformed.parse(config);
|
|
37
37
|
} catch (error) {
|
|
38
38
|
if (error instanceof z.ZodError) {
|
|
39
|
-
throw new Error(`Invalid LibSQL config: ${error.
|
|
39
|
+
throw new Error(`Invalid LibSQL config: ${error.issues.map((e) => e.message).join(", ")}`);
|
|
40
40
|
}
|
|
41
41
|
throw error;
|
|
42
42
|
}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* https://github.com/withastro/astro/blob/main/packages/astro/src/content/error-map.ts
|
|
4
|
-
*/
|
|
5
|
-
import type { z } from 'astro/zod';
|
|
6
|
-
export declare const errorMap: z.ZodErrorMap;
|
|
1
|
+
import type { $ZodErrorMap } from 'zod/v4/core';
|
|
2
|
+
export declare const errorMap: $ZodErrorMap;
|
|
@@ -1,77 +1,101 @@
|
|
|
1
|
-
const errorMap = (
|
|
2
|
-
const baseErrorPath = flattenErrorPath(
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
for (const unionError of
|
|
6
|
-
if (unionError.code === "invalid_type"
|
|
1
|
+
const errorMap = (issue) => {
|
|
2
|
+
const baseErrorPath = flattenErrorPath(issue.path ?? []);
|
|
3
|
+
if (issue.code === "invalid_union") {
|
|
4
|
+
let typeOrLiteralErrByPath = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const unionError of issue.errors.flat()) {
|
|
6
|
+
if (unionError.code === "invalid_type") {
|
|
7
7
|
const flattenedErrorPath = flattenErrorPath(unionError.path);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
typeOrLiteralErr.expected.push(unionError.expected);
|
|
8
|
+
if (typeOrLiteralErrByPath.has(flattenedErrorPath)) {
|
|
9
|
+
typeOrLiteralErrByPath.get(flattenedErrorPath).expected.push(unionError.expected);
|
|
11
10
|
} else {
|
|
12
11
|
typeOrLiteralErrByPath.set(flattenedErrorPath, {
|
|
13
12
|
code: unionError.code,
|
|
14
13
|
received: unionError.received,
|
|
15
|
-
expected: [unionError.expected]
|
|
14
|
+
expected: [unionError.expected],
|
|
15
|
+
message: unionError.message
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
const messages = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const messages = [prefix(baseErrorPath, "Did not match union.")];
|
|
21
|
+
const details = [...typeOrLiteralErrByPath.entries()].filter(([, error]) => error.expected.length === issue.errors.flat().length).map(
|
|
22
|
+
([key, error]) => key === baseErrorPath ? (
|
|
23
|
+
// Avoid printing the key again if it's a base error
|
|
24
|
+
`> ${getTypeOrLiteralMsg(error)}`
|
|
25
|
+
) : `> ${prefix(key, getTypeOrLiteralMsg(error))}`
|
|
26
|
+
);
|
|
27
|
+
if (details.length === 0) {
|
|
28
|
+
const expectedShapes = [];
|
|
29
|
+
for (const unionErrors of issue.errors) {
|
|
30
|
+
const expectedShape = [];
|
|
31
|
+
for (const _issue of unionErrors) {
|
|
32
|
+
if (_issue.code === "invalid_union") {
|
|
33
|
+
return errorMap(_issue);
|
|
34
|
+
}
|
|
35
|
+
const relativePath = flattenErrorPath(_issue.path).replace(baseErrorPath, "").replace(leadingPeriod, "");
|
|
36
|
+
if ("expected" in _issue && typeof _issue.expected === "string") {
|
|
37
|
+
expectedShape.push(
|
|
38
|
+
relativePath ? `${relativePath}: ${_issue.expected}` : _issue.expected
|
|
39
|
+
);
|
|
40
|
+
} else if ("values" in _issue) {
|
|
41
|
+
expectedShape.push(
|
|
42
|
+
..._issue.values.filter((v) => typeof v === "string").map((v) => `"${v}"`)
|
|
43
|
+
);
|
|
44
|
+
} else if (relativePath) {
|
|
45
|
+
expectedShape.push(relativePath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (expectedShape.length === 1 && !expectedShape[0]?.includes(":")) {
|
|
49
|
+
expectedShapes.push(expectedShape.join(""));
|
|
50
|
+
} else if (expectedShape.length > 0) {
|
|
51
|
+
expectedShapes.push(`{ ${expectedShape.join("; ")} }`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (expectedShapes.length) {
|
|
55
|
+
details.push("> Expected type `" + expectedShapes.join(" | ") + "`");
|
|
56
|
+
details.push("> Received `" + stringify(issue.input) + "`");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
26
59
|
return {
|
|
27
|
-
message: messages.concat(
|
|
28
|
-
[...typeOrLiteralErrByPath.entries()].filter(([, error]) => error.expected.length === baseError.unionErrors.length).map(
|
|
29
|
-
([key, error]) => (
|
|
30
|
-
// Avoid printing the key again if it's a base error
|
|
31
|
-
key === baseErrorPath ? `> ${getTypeOrLiteralMsg(error)}` : `> ${prefix(key, getTypeOrLiteralMsg(error))}`
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
).join("\n")
|
|
60
|
+
message: messages.concat(details).join("\n")
|
|
35
61
|
};
|
|
36
|
-
}
|
|
37
|
-
if (baseError.code === "invalid_literal" || baseError.code === "invalid_type") {
|
|
62
|
+
} else if (issue.code === "invalid_type") {
|
|
38
63
|
return {
|
|
39
64
|
message: prefix(
|
|
40
65
|
baseErrorPath,
|
|
41
66
|
getTypeOrLiteralMsg({
|
|
42
|
-
code:
|
|
43
|
-
received:
|
|
44
|
-
expected: [
|
|
67
|
+
code: issue.code,
|
|
68
|
+
received: typeof issue.input,
|
|
69
|
+
expected: [issue.expected],
|
|
70
|
+
message: issue.message
|
|
45
71
|
})
|
|
46
72
|
)
|
|
47
73
|
};
|
|
48
|
-
} else if (
|
|
49
|
-
return { message: prefix(baseErrorPath,
|
|
50
|
-
} else {
|
|
51
|
-
return { message: prefix(baseErrorPath, ctx.defaultError) };
|
|
74
|
+
} else if (issue.message) {
|
|
75
|
+
return { message: prefix(baseErrorPath, issue.message) };
|
|
52
76
|
}
|
|
53
77
|
};
|
|
54
78
|
const getTypeOrLiteralMsg = (error) => {
|
|
55
|
-
if (error.received === "undefined"
|
|
79
|
+
if (typeof error.received === "undefined" || error.received === "undefined")
|
|
80
|
+
return error.message ?? "Required";
|
|
56
81
|
const expectedDeduped = new Set(error.expected);
|
|
57
82
|
switch (error.code) {
|
|
58
83
|
case "invalid_type":
|
|
59
|
-
return `Expected type \`${unionExpectedVals(expectedDeduped)}\`, received
|
|
84
|
+
return `Expected type \`${unionExpectedVals(expectedDeduped)}\`, received \`${stringify(
|
|
60
85
|
error.received
|
|
61
|
-
)}
|
|
86
|
+
)}\``;
|
|
62
87
|
case "invalid_literal":
|
|
63
|
-
return `Expected \`${unionExpectedVals(expectedDeduped)}\`, received
|
|
88
|
+
return `Expected \`${unionExpectedVals(expectedDeduped)}\`, received \`${stringify(
|
|
64
89
|
error.received
|
|
65
|
-
)}
|
|
90
|
+
)}\``;
|
|
66
91
|
}
|
|
67
92
|
};
|
|
68
93
|
const prefix = (key, msg) => key.length ? `**${key}**: ${msg}` : msg;
|
|
69
|
-
const unionExpectedVals = (expectedVals) => [...expectedVals].map((expectedVal
|
|
70
|
-
if (idx === 0) return JSON.stringify(expectedVal);
|
|
71
|
-
const sep = " | ";
|
|
72
|
-
return `${sep}${JSON.stringify(expectedVal)}`;
|
|
73
|
-
}).join("");
|
|
94
|
+
const unionExpectedVals = (expectedVals) => [...expectedVals].map((expectedVal) => stringify(expectedVal)).join(" | ");
|
|
74
95
|
const flattenErrorPath = (errorPath) => errorPath.join(".");
|
|
96
|
+
const stringify = (val) => JSON.stringify(val, null, 1).split(newlinePlusWhitespace).join(" ");
|
|
97
|
+
const newlinePlusWhitespace = /\n\s*/;
|
|
98
|
+
const leadingPeriod = /^\./;
|
|
75
99
|
export {
|
|
76
100
|
errorMap
|
|
77
101
|
};
|
|
@@ -12,8 +12,11 @@ function fileURLIntegration() {
|
|
|
12
12
|
return {
|
|
13
13
|
name: "@astrojs/db/file-url",
|
|
14
14
|
enforce: "pre",
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
load: {
|
|
16
|
+
filter: {
|
|
17
|
+
id: /\?fileurl$/
|
|
18
|
+
},
|
|
19
|
+
async handler(id) {
|
|
17
20
|
const filePath = id.slice(0, id.indexOf("?"));
|
|
18
21
|
if (command === "build") {
|
|
19
22
|
const data = await fs.promises.readFile(filePath);
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
|
-
import
|
|
3
|
-
declare const astroDBConfigSchema: z.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* In most cases, the default 'node' mode is sufficient. On platforms like Cloudflare, or Deno, you may need to set this to 'web'.
|
|
8
|
-
*
|
|
9
|
-
* @default 'node'
|
|
10
|
-
*/
|
|
11
|
-
mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"node">, z.ZodLiteral<"web">]>>>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
mode: "node" | "web";
|
|
14
|
-
}, {
|
|
15
|
-
mode?: "node" | "web" | undefined;
|
|
16
|
-
}>>>;
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
|
+
declare const astroDBConfigSchema: z.ZodPrefault<z.ZodOptional<z.ZodObject<{
|
|
4
|
+
mode: z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"node">, z.ZodLiteral<"web">]>>>;
|
|
5
|
+
}, z.core.$strip>>>;
|
|
17
6
|
export type AstroDBConfig = z.infer<typeof astroDBConfigSchema>;
|
|
18
7
|
export declare function integration(options?: AstroDBConfig): AstroIntegration[];
|
|
19
8
|
export {};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
mergeConfig
|
|
10
10
|
} from "vite";
|
|
11
11
|
import parseArgs from "yargs-parser";
|
|
12
|
-
import
|
|
12
|
+
import * as z from "zod/v4";
|
|
13
13
|
import { AstroDbError, isDbError } from "../../runtime/utils.js";
|
|
14
14
|
import { CONFIG_FILE_NAMES, DB_PATH, VIRTUAL_MODULE_ID } from "../consts.js";
|
|
15
15
|
import { EXEC_DEFAULT_EXPORT_ERROR, EXEC_ERROR } from "../errors.js";
|
|
@@ -31,7 +31,7 @@ const astroDBConfigSchema = z.object({
|
|
|
31
31
|
* @default 'node'
|
|
32
32
|
*/
|
|
33
33
|
mode: z.union([z.literal("node"), z.literal("web")]).optional().default("node")
|
|
34
|
-
}).optional().
|
|
34
|
+
}).optional().prefault({});
|
|
35
35
|
function astroDBIntegration(options) {
|
|
36
36
|
const resolvedConfig = astroDBConfigSchema.parse(options);
|
|
37
37
|
let connectToRemote = false;
|
|
@@ -117,8 +117,9 @@ function astroDBIntegration(options) {
|
|
|
117
117
|
});
|
|
118
118
|
},
|
|
119
119
|
"astro:server:setup": async ({ server, logger }) => {
|
|
120
|
+
const environment = server.environments.ssr;
|
|
120
121
|
seedHandler.execute = async (fileUrl) => {
|
|
121
|
-
await executeSeedFile({ fileUrl,
|
|
122
|
+
await executeSeedFile({ fileUrl, environment });
|
|
122
123
|
};
|
|
123
124
|
const filesToWatch = [
|
|
124
125
|
...CONFIG_FILE_NAMES.map((c) => new URL(c, getDbDirectoryUrl(root))),
|
|
@@ -130,20 +131,18 @@ function astroDBIntegration(options) {
|
|
|
130
131
|
server.restart();
|
|
131
132
|
}
|
|
132
133
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}, 100);
|
|
134
|
+
logger.info(
|
|
135
|
+
connectToRemote ? "Connected to remote database." : "New local database created."
|
|
136
|
+
);
|
|
137
|
+
if (connectToRemote) return;
|
|
138
|
+
const localSeedPaths = SEED_DEV_FILE_NAME.map(
|
|
139
|
+
(name) => new URL(name, getDbDirectoryUrl(root))
|
|
140
|
+
);
|
|
141
|
+
if (seedFiles.get().length || localSeedPaths.find((path) => existsSync(path))) {
|
|
142
|
+
await environment.runner.import(VIRTUAL_MODULE_ID).catch((e) => {
|
|
143
|
+
logger.error(e instanceof Error ? e.message : String(e));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
147
146
|
},
|
|
148
147
|
"astro:build:start": async ({ logger }) => {
|
|
149
148
|
if (!connectToRemote && !databaseFileEnvDefined() && finalBuildOutput === "server") {
|
|
@@ -157,11 +156,12 @@ function astroDBIntegration(options) {
|
|
|
157
156
|
},
|
|
158
157
|
"astro:build:setup": async ({ vite }) => {
|
|
159
158
|
tempViteServer = await getTempViteServer({ viteConfig: vite });
|
|
159
|
+
const environment = tempViteServer.environments.ssr;
|
|
160
160
|
seedHandler.execute = async (fileUrl) => {
|
|
161
|
-
await executeSeedFile({ fileUrl,
|
|
161
|
+
await executeSeedFile({ fileUrl, environment });
|
|
162
162
|
};
|
|
163
163
|
},
|
|
164
|
-
"astro:build:done": async (
|
|
164
|
+
"astro:build:done": async () => {
|
|
165
165
|
await tempViteServer?.close();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -176,10 +176,10 @@ function integration(options) {
|
|
|
176
176
|
}
|
|
177
177
|
async function executeSeedFile({
|
|
178
178
|
fileUrl,
|
|
179
|
-
|
|
179
|
+
environment
|
|
180
180
|
}) {
|
|
181
181
|
const pathname = decodeURIComponent(fileUrl.pathname);
|
|
182
|
-
const mod = await
|
|
182
|
+
const mod = await environment.runner.import(pathname);
|
|
183
183
|
if (typeof mod.default !== "function") {
|
|
184
184
|
throw new AstroDbError(EXEC_DEFAULT_EXPORT_ERROR(fileURLToPath(fileUrl)));
|
|
185
185
|
}
|
|
@@ -201,8 +201,8 @@ async function getTempViteServer({ viteConfig }) {
|
|
|
201
201
|
logLevel: "silent"
|
|
202
202
|
})
|
|
203
203
|
);
|
|
204
|
-
const hotSend = tempViteServer.hot.send;
|
|
205
|
-
tempViteServer.hot.send = (payload) => {
|
|
204
|
+
const hotSend = tempViteServer.environments.client.hot.send;
|
|
205
|
+
tempViteServer.environments.client.hot.send = (payload) => {
|
|
206
206
|
if (payload.type === "error") {
|
|
207
207
|
throw payload.err;
|
|
208
208
|
}
|
|
@@ -21,18 +21,26 @@ function vitePluginDbClient(params) {
|
|
|
21
21
|
return {
|
|
22
22
|
name: "virtual:astro:db-client",
|
|
23
23
|
enforce: "pre",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
resolveId: {
|
|
25
|
+
filter: {
|
|
26
|
+
id: new RegExp(`^${VIRTUAL_CLIENT_MODULE_ID}$`)
|
|
27
|
+
},
|
|
28
|
+
handler() {
|
|
29
|
+
return resolved;
|
|
30
|
+
}
|
|
27
31
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
load: {
|
|
33
|
+
filter: {
|
|
34
|
+
id: new RegExp(`^${resolved}$`)
|
|
35
|
+
},
|
|
36
|
+
handler() {
|
|
37
|
+
switch (params.connectToRemote) {
|
|
38
|
+
case true:
|
|
39
|
+
return getRemoteClientModule(params.mode);
|
|
40
|
+
case false:
|
|
41
|
+
default:
|
|
42
|
+
return getLocalClientModule(params.mode);
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
};
|
|
@@ -31,49 +31,57 @@ function vitePluginDb(params) {
|
|
|
31
31
|
configResolved(resolvedConfig) {
|
|
32
32
|
command = resolvedConfig.command;
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
resolveId: {
|
|
35
|
+
filter: {
|
|
36
|
+
id: new RegExp(`^${VIRTUAL_MODULE_ID}$`)
|
|
37
|
+
},
|
|
38
|
+
handler() {
|
|
39
|
+
if (params.seedHandler.inProgress) {
|
|
40
|
+
return resolved.importedFromSeedFile;
|
|
41
|
+
}
|
|
42
|
+
return resolved.module;
|
|
38
43
|
}
|
|
39
|
-
return resolved.module;
|
|
40
44
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
load: {
|
|
46
|
+
filter: {
|
|
47
|
+
id: new RegExp(`^(${resolved.module}|${resolved.importedFromSeedFile})$`)
|
|
48
|
+
},
|
|
49
|
+
async handler(id) {
|
|
50
|
+
if (params.connectToRemote) {
|
|
51
|
+
return getRemoteVirtualModContents({
|
|
52
|
+
appToken: params.appToken,
|
|
53
|
+
tables: params.tables.get(),
|
|
54
|
+
isBuild: command === "build",
|
|
55
|
+
output: params.output,
|
|
56
|
+
localExecution: false
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (id === resolved.importedFromSeedFile) {
|
|
60
|
+
return getLocalVirtualModContents({
|
|
61
|
+
root: params.root,
|
|
62
|
+
tables: params.tables.get(),
|
|
63
|
+
localExecution: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
await recreateTables(params);
|
|
67
|
+
const seedFiles = getResolvedSeedFiles(params);
|
|
68
|
+
for await (const seedFile of seedFiles) {
|
|
69
|
+
this.addWatchFile(fileURLToPath(seedFile));
|
|
70
|
+
if (existsSync(seedFile)) {
|
|
71
|
+
params.seedHandler.inProgress = true;
|
|
72
|
+
await params.seedHandler.execute(seedFile);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (params.seedHandler.inProgress) {
|
|
76
|
+
(params.logger ?? console).info("Seeded database.");
|
|
77
|
+
params.seedHandler.inProgress = false;
|
|
78
|
+
}
|
|
53
79
|
return getLocalVirtualModContents({
|
|
54
80
|
root: params.root,
|
|
55
81
|
tables: params.tables.get(),
|
|
56
82
|
localExecution: false
|
|
57
83
|
});
|
|
58
84
|
}
|
|
59
|
-
await recreateTables(params);
|
|
60
|
-
const seedFiles = getResolvedSeedFiles(params);
|
|
61
|
-
for await (const seedFile of seedFiles) {
|
|
62
|
-
this.addWatchFile(fileURLToPath(seedFile));
|
|
63
|
-
if (existsSync(seedFile)) {
|
|
64
|
-
params.seedHandler.inProgress = true;
|
|
65
|
-
await params.seedHandler.execute(seedFile);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (params.seedHandler.inProgress) {
|
|
69
|
-
(params.logger ?? console).info("Seeded database.");
|
|
70
|
-
params.seedHandler.inProgress = false;
|
|
71
|
-
}
|
|
72
|
-
return getLocalVirtualModContents({
|
|
73
|
-
root: params.root,
|
|
74
|
-
tables: params.tables.get(),
|
|
75
|
-
localExecution: false
|
|
76
|
-
});
|
|
77
85
|
}
|
|
78
86
|
};
|
|
79
87
|
}
|
package/dist/core/load-file.d.ts
CHANGED
|
@@ -11,17 +11,16 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
|
|
|
11
11
|
on: string | string[];
|
|
12
12
|
unique?: boolean | undefined;
|
|
13
13
|
}>;
|
|
14
|
-
deprecated: boolean;
|
|
15
14
|
columns: Record<string, {
|
|
16
15
|
type: "boolean";
|
|
17
16
|
schema: {
|
|
18
17
|
optional: boolean;
|
|
19
18
|
unique: boolean;
|
|
20
19
|
deprecated: boolean;
|
|
21
|
-
default?: boolean | import("../runtime/types.js").SerializedSQL | undefined;
|
|
22
|
-
name?: string | undefined;
|
|
23
20
|
label?: string | undefined;
|
|
21
|
+
name?: string | undefined;
|
|
24
22
|
collection?: string | undefined;
|
|
23
|
+
default?: boolean | import("../runtime/types.js").SerializedSQL | undefined;
|
|
25
24
|
};
|
|
26
25
|
} | {
|
|
27
26
|
type: "number";
|
|
@@ -32,13 +31,13 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
|
|
|
32
31
|
label?: string | undefined;
|
|
33
32
|
collection?: string | undefined;
|
|
34
33
|
} & ({
|
|
35
|
-
optional: boolean;
|
|
36
34
|
primaryKey: false;
|
|
35
|
+
optional: boolean;
|
|
37
36
|
default?: number | import("../runtime/types.js").SerializedSQL | undefined;
|
|
38
37
|
} | {
|
|
39
38
|
primaryKey: true;
|
|
40
|
-
default?: undefined;
|
|
41
39
|
optional?: false | undefined;
|
|
40
|
+
default?: undefined;
|
|
42
41
|
})) & {
|
|
43
42
|
references?: import("./types.js").NumberColumn;
|
|
44
43
|
};
|
|
@@ -47,15 +46,15 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
|
|
|
47
46
|
schema: ({
|
|
48
47
|
unique: boolean;
|
|
49
48
|
deprecated: boolean;
|
|
50
|
-
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
51
49
|
name?: string | undefined;
|
|
52
50
|
label?: string | undefined;
|
|
53
51
|
collection?: string | undefined;
|
|
52
|
+
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
54
53
|
multiline?: boolean | undefined;
|
|
55
54
|
enum?: [string, ...string[]] | undefined;
|
|
56
55
|
} & ({
|
|
57
|
-
optional: boolean;
|
|
58
56
|
primaryKey: false;
|
|
57
|
+
optional: boolean;
|
|
59
58
|
} | {
|
|
60
59
|
primaryKey: true;
|
|
61
60
|
optional?: false | undefined;
|
|
@@ -68,10 +67,10 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
|
|
|
68
67
|
optional: boolean;
|
|
69
68
|
unique: boolean;
|
|
70
69
|
deprecated: boolean;
|
|
71
|
-
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
72
|
-
name?: string | undefined;
|
|
73
70
|
label?: string | undefined;
|
|
71
|
+
name?: string | undefined;
|
|
74
72
|
collection?: string | undefined;
|
|
73
|
+
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
75
74
|
};
|
|
76
75
|
} | {
|
|
77
76
|
type: "json";
|
|
@@ -79,17 +78,18 @@ export declare function resolveDbConfig({ root, integrations, }: Pick<AstroConfi
|
|
|
79
78
|
optional: boolean;
|
|
80
79
|
unique: boolean;
|
|
81
80
|
deprecated: boolean;
|
|
82
|
-
default?: unknown;
|
|
83
|
-
name?: string | undefined;
|
|
84
81
|
label?: string | undefined;
|
|
82
|
+
name?: string | undefined;
|
|
85
83
|
collection?: string | undefined;
|
|
84
|
+
default?: unknown;
|
|
86
85
|
};
|
|
87
86
|
}>;
|
|
87
|
+
deprecated: boolean;
|
|
88
88
|
foreignKeys?: (Omit<{
|
|
89
89
|
columns: import("./schemas.js").MaybeArray<string>;
|
|
90
|
-
references: () => import("./schemas.js").MaybeArray<Omit<import("zod").input<typeof import("./schemas.js").referenceableColumnSchema>, "references">>;
|
|
90
|
+
references: () => import("./schemas.js").MaybeArray<Omit<import("zod/v4").input<typeof import("./schemas.js").referenceableColumnSchema>, "references">>;
|
|
91
91
|
}, "references"> & {
|
|
92
|
-
references: import("./schemas.js").MaybeArray<Omit<import("zod").
|
|
92
|
+
references: import("./schemas.js").MaybeArray<Omit<import("zod/v4").infer<typeof import("./schemas.js").referenceableColumnSchema>, "references">>;
|
|
93
93
|
})[] | undefined;
|
|
94
94
|
}>;
|
|
95
95
|
};
|
package/dist/core/load-file.js
CHANGED
|
@@ -15,7 +15,7 @@ async function resolveDbConfig({
|
|
|
15
15
|
integrations
|
|
16
16
|
}) {
|
|
17
17
|
const { mod, dependencies } = await loadUserConfigFile(root);
|
|
18
|
-
const userDbConfig = dbConfigSchema.parse(mod?.default ?? {}, { errorMap });
|
|
18
|
+
const userDbConfig = dbConfigSchema.parse(mod?.default ?? {}, { error: errorMap });
|
|
19
19
|
const dbConfig = { tables: userDbConfig.tables ?? {} };
|
|
20
20
|
const integrationDbConfigPaths = [];
|
|
21
21
|
const integrationSeedPaths = [];
|
|
@@ -37,7 +37,7 @@ async function resolveDbConfig({
|
|
|
37
37
|
for (const { name, configEntrypoint } of integrationDbConfigPaths) {
|
|
38
38
|
const loadedConfig = await loadIntegrationConfigFile(root, configEntrypoint);
|
|
39
39
|
const integrationDbConfig = dbConfigSchema.parse(loadedConfig.mod?.default ?? {}, {
|
|
40
|
-
errorMap
|
|
40
|
+
error: errorMap
|
|
41
41
|
});
|
|
42
42
|
for (const key in integrationDbConfig.tables) {
|
|
43
43
|
if (key in dbConfig.tables) {
|
package/dist/core/queries.d.ts
CHANGED
|
@@ -14,13 +14,13 @@ export declare function getReferencesConfig(column: DBColumn): {
|
|
|
14
14
|
label?: string | undefined;
|
|
15
15
|
collection?: string | undefined;
|
|
16
16
|
} & ({
|
|
17
|
-
optional: boolean;
|
|
18
17
|
primaryKey: false;
|
|
18
|
+
optional: boolean;
|
|
19
19
|
default?: number | import("../runtime/types.js").SerializedSQL | undefined;
|
|
20
20
|
} | {
|
|
21
21
|
primaryKey: true;
|
|
22
|
-
default?: undefined;
|
|
23
22
|
optional?: false | undefined;
|
|
23
|
+
default?: undefined;
|
|
24
24
|
})) & {
|
|
25
25
|
references?: NumberColumn;
|
|
26
26
|
};
|
|
@@ -29,15 +29,15 @@ export declare function getReferencesConfig(column: DBColumn): {
|
|
|
29
29
|
schema: ({
|
|
30
30
|
unique: boolean;
|
|
31
31
|
deprecated: boolean;
|
|
32
|
-
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
33
32
|
name?: string | undefined;
|
|
34
33
|
label?: string | undefined;
|
|
35
34
|
collection?: string | undefined;
|
|
35
|
+
default?: string | import("../runtime/types.js").SerializedSQL | undefined;
|
|
36
36
|
multiline?: boolean | undefined;
|
|
37
37
|
enum?: [string, ...string[]] | undefined;
|
|
38
38
|
} & ({
|
|
39
|
-
optional: boolean;
|
|
40
39
|
primaryKey: false;
|
|
40
|
+
optional: boolean;
|
|
41
41
|
} | {
|
|
42
42
|
primaryKey: true;
|
|
43
43
|
optional?: false | undefined;
|