@astrojs/db 0.9.10 → 0.10.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/core/cli/commands/execute/index.js +2 -1
- package/dist/core/cli/print-help.js +1 -1
- package/dist/core/consts.d.ts +1 -1
- package/dist/core/consts.js +2 -2
- package/dist/core/integration/index.js +4 -2
- package/dist/core/integration/vite-plugin-db.d.ts +5 -1
- package/dist/core/integration/vite-plugin-db.js +13 -7
- package/package.json +6 -6
- package/virtual.d.ts +2 -2
- /package/dist/_internal/runtime/{config.d.ts → virtual.d.ts} +0 -0
- /package/dist/runtime/{config.js → virtual.js} +0 -0
|
@@ -35,7 +35,8 @@ async function cmd({
|
|
|
35
35
|
virtualModContents = getStudioVirtualModContents({
|
|
36
36
|
tables: dbConfig.tables ?? {},
|
|
37
37
|
appToken: appToken.token,
|
|
38
|
-
isBuild: false
|
|
38
|
+
isBuild: false,
|
|
39
|
+
output: "server"
|
|
39
40
|
});
|
|
40
41
|
} else {
|
|
41
42
|
virtualModContents = getLocalVirtualModContents({
|
package/dist/core/consts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const PACKAGE_NAME: any;
|
|
2
2
|
export declare const RUNTIME_IMPORT: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const RUNTIME_VIRTUAL_IMPORT: string;
|
|
4
4
|
export declare const DB_TYPES_FILE = "db-types.d.ts";
|
|
5
5
|
export declare const VIRTUAL_MODULE_ID = "astro:db";
|
|
6
6
|
export declare const DB_PATH = ".astro/content.db";
|
package/dist/core/consts.js
CHANGED
|
@@ -3,7 +3,7 @@ const PACKAGE_NAME = JSON.parse(
|
|
|
3
3
|
readFileSync(new URL("../../package.json", import.meta.url), "utf8")
|
|
4
4
|
).name;
|
|
5
5
|
const RUNTIME_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime`);
|
|
6
|
-
const
|
|
6
|
+
const RUNTIME_VIRTUAL_IMPORT = JSON.stringify(`${PACKAGE_NAME}/dist/runtime/virtual.js`);
|
|
7
7
|
const DB_TYPES_FILE = "db-types.d.ts";
|
|
8
8
|
const VIRTUAL_MODULE_ID = "astro:db";
|
|
9
9
|
const DB_PATH = ".astro/content.db";
|
|
@@ -15,7 +15,7 @@ export {
|
|
|
15
15
|
DB_TYPES_FILE,
|
|
16
16
|
MIGRATION_VERSION,
|
|
17
17
|
PACKAGE_NAME,
|
|
18
|
-
RUNTIME_CONFIG_IMPORT,
|
|
19
18
|
RUNTIME_IMPORT,
|
|
19
|
+
RUNTIME_VIRTUAL_IMPORT,
|
|
20
20
|
VIRTUAL_MODULE_ID
|
|
21
21
|
};
|
|
@@ -51,7 +51,8 @@ function astroDBIntegration() {
|
|
|
51
51
|
appToken: appToken.token,
|
|
52
52
|
tables,
|
|
53
53
|
root: config.root,
|
|
54
|
-
srcDir: config.srcDir
|
|
54
|
+
srcDir: config.srcDir,
|
|
55
|
+
output: config.output
|
|
55
56
|
});
|
|
56
57
|
} else {
|
|
57
58
|
dbPlugin = vitePluginDb({
|
|
@@ -59,7 +60,8 @@ function astroDBIntegration() {
|
|
|
59
60
|
tables,
|
|
60
61
|
seedFiles,
|
|
61
62
|
root: config.root,
|
|
62
|
-
srcDir: config.srcDir
|
|
63
|
+
srcDir: config.srcDir,
|
|
64
|
+
output: config.output
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
updateConfig({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AstroConfig } from 'astro';
|
|
1
2
|
import type { DBTables } from '../types.js';
|
|
2
3
|
import { type VitePlugin } from '../utils.js';
|
|
3
4
|
export declare const resolved: {
|
|
@@ -16,12 +17,14 @@ type VitePluginDBParams = {
|
|
|
16
17
|
seedFiles: LateSeedFiles;
|
|
17
18
|
srcDir: URL;
|
|
18
19
|
root: URL;
|
|
20
|
+
output: AstroConfig['output'];
|
|
19
21
|
} | {
|
|
20
22
|
connectToStudio: true;
|
|
21
23
|
tables: LateTables;
|
|
22
24
|
appToken: string;
|
|
23
25
|
srcDir: URL;
|
|
24
26
|
root: URL;
|
|
27
|
+
output: AstroConfig['output'];
|
|
25
28
|
};
|
|
26
29
|
export declare function vitePluginDb(params: VitePluginDBParams): VitePlugin;
|
|
27
30
|
export declare function getConfigVirtualModContents(): string;
|
|
@@ -31,9 +34,10 @@ export declare function getLocalVirtualModContents({ tables, root, seedFiles, sh
|
|
|
31
34
|
root: URL;
|
|
32
35
|
shouldSeed: boolean;
|
|
33
36
|
}): string;
|
|
34
|
-
export declare function getStudioVirtualModContents({ tables, appToken, isBuild, }: {
|
|
37
|
+
export declare function getStudioVirtualModContents({ tables, appToken, isBuild, output, }: {
|
|
35
38
|
tables: DBTables;
|
|
36
39
|
appToken: string;
|
|
37
40
|
isBuild: boolean;
|
|
41
|
+
output: AstroConfig['output'];
|
|
38
42
|
}): string;
|
|
39
43
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
3
|
import { SEED_DEV_FILE_NAME } from "../../runtime/queries.js";
|
|
4
|
-
import { DB_PATH,
|
|
4
|
+
import { DB_PATH, RUNTIME_IMPORT, RUNTIME_VIRTUAL_IMPORT, VIRTUAL_MODULE_ID } from "../consts.js";
|
|
5
5
|
import { getDbDirectoryUrl, getRemoteDatabaseUrl } from "../utils.js";
|
|
6
6
|
const WITH_SEED_VIRTUAL_MODULE_ID = "astro:db:seed";
|
|
7
7
|
const resolved = {
|
|
@@ -37,7 +37,8 @@ function vitePluginDb(params) {
|
|
|
37
37
|
return getStudioVirtualModContents({
|
|
38
38
|
appToken: params.appToken,
|
|
39
39
|
tables: params.tables.get(),
|
|
40
|
-
isBuild: command === "build"
|
|
40
|
+
isBuild: command === "build",
|
|
41
|
+
output: params.output
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
return getLocalVirtualModContents({
|
|
@@ -50,7 +51,7 @@ function vitePluginDb(params) {
|
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
function getConfigVirtualModContents() {
|
|
53
|
-
return `export * from ${
|
|
54
|
+
return `export * from ${RUNTIME_VIRTUAL_IMPORT}`;
|
|
54
55
|
}
|
|
55
56
|
function getLocalVirtualModContents({
|
|
56
57
|
tables,
|
|
@@ -88,18 +89,23 @@ ${shouldSeed ? `await seedLocal({
|
|
|
88
89
|
integrationSeedFunctions: [${integrationSeedImportNames.join(",")}],
|
|
89
90
|
});` : ""}
|
|
90
91
|
|
|
91
|
-
export * from ${
|
|
92
|
+
export * from ${RUNTIME_VIRTUAL_IMPORT};
|
|
92
93
|
|
|
93
94
|
${getStringifiedTableExports(tables)}`;
|
|
94
95
|
}
|
|
95
96
|
function getStudioVirtualModContents({
|
|
96
97
|
tables,
|
|
97
98
|
appToken,
|
|
98
|
-
isBuild
|
|
99
|
+
isBuild,
|
|
100
|
+
output
|
|
99
101
|
}) {
|
|
100
102
|
function appTokenArg() {
|
|
101
103
|
if (isBuild) {
|
|
102
|
-
|
|
104
|
+
if (output === "server") {
|
|
105
|
+
return "process.env.ASTRO_STUDIO_APP_TOKEN";
|
|
106
|
+
} else {
|
|
107
|
+
return `process.env.ASTRO_STUDIO_APP_TOKEN ?? ${JSON.stringify(appToken)}`;
|
|
108
|
+
}
|
|
103
109
|
} else {
|
|
104
110
|
return JSON.stringify(appToken);
|
|
105
111
|
}
|
|
@@ -113,7 +119,7 @@ import {asDrizzleTable, createRemoteDatabaseClient} from ${RUNTIME_IMPORT};
|
|
|
113
119
|
|
|
114
120
|
export const db = await createRemoteDatabaseClient(${appTokenArg()}, ${dbUrlArg()});
|
|
115
121
|
|
|
116
|
-
export * from ${
|
|
122
|
+
export * from ${RUNTIME_VIRTUAL_IMPORT};
|
|
117
123
|
|
|
118
124
|
${getStringifiedTableExports(tables)}
|
|
119
125
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"types": "./dist/runtime/index.d.ts",
|
|
21
21
|
"import": "./dist/runtime/index.js"
|
|
22
22
|
},
|
|
23
|
-
"./dist/runtime/
|
|
24
|
-
"import": "./dist/runtime/
|
|
23
|
+
"./dist/runtime/virtual.js": {
|
|
24
|
+
"import": "./dist/runtime/virtual.js"
|
|
25
25
|
},
|
|
26
26
|
"./types": {
|
|
27
27
|
"types": "./dist/core/types.d.ts",
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"mocha": "^10.2.0",
|
|
82
82
|
"typescript": "^5.2.2",
|
|
83
83
|
"vite": "^5.1.4",
|
|
84
|
-
"astro": "4.5.
|
|
84
|
+
"astro": "4.5.15",
|
|
85
85
|
"astro-scripts": "0.0.14"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"types:
|
|
89
|
-
"build": "astro-scripts build \"src/**/*.ts\" && tsc && pnpm types:
|
|
88
|
+
"types:virtual": "tsc -p ./tsconfig.virtual.json",
|
|
89
|
+
"build": "astro-scripts build \"src/**/*.ts\" && tsc && pnpm types:virtual",
|
|
90
90
|
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
91
91
|
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
92
92
|
"test": "mocha --exit --timeout 20000 \"test/*.js\" \"test/unit/**/*.js\"",
|
package/virtual.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare module 'astro:db' {
|
|
2
|
-
type RuntimeConfig = typeof import('./dist/_internal/runtime/
|
|
2
|
+
type RuntimeConfig = typeof import('./dist/_internal/runtime/virtual.js');
|
|
3
3
|
|
|
4
|
-
export const db: import('./dist/_internal/runtime/
|
|
4
|
+
export const db: import('./dist/_internal/runtime/virtual.js').Database;
|
|
5
5
|
export const dbUrl: string;
|
|
6
6
|
|
|
7
7
|
export const sql: RuntimeConfig['sql'];
|
|
File without changes
|
|
File without changes
|