@astrojs/db 0.0.0-db-export-bug-20240307130354
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/LICENSE +59 -0
- package/README.md +38 -0
- package/dist/core/cli/commands/execute/index.d.ts +8 -0
- package/dist/core/cli/commands/execute/index.js +32 -0
- package/dist/core/cli/commands/link/index.d.ts +20 -0
- package/dist/core/cli/commands/link/index.js +238 -0
- package/dist/core/cli/commands/login/index.d.ts +8 -0
- package/dist/core/cli/commands/login/index.js +55 -0
- package/dist/core/cli/commands/logout/index.d.ts +1 -0
- package/dist/core/cli/commands/logout/index.js +9 -0
- package/dist/core/cli/commands/push/index.d.ts +8 -0
- package/dist/core/cli/commands/push/index.js +77 -0
- package/dist/core/cli/commands/shell/index.d.ts +8 -0
- package/dist/core/cli/commands/shell/index.js +17 -0
- package/dist/core/cli/commands/verify/index.d.ts +8 -0
- package/dist/core/cli/commands/verify/index.js +46 -0
- package/dist/core/cli/index.d.ts +6 -0
- package/dist/core/cli/index.js +77 -0
- package/dist/core/cli/migration-queries.d.ts +22 -0
- package/dist/core/cli/migration-queries.js +366 -0
- package/dist/core/consts.d.ts +7 -0
- package/dist/core/consts.js +19 -0
- package/dist/core/errors.d.ts +11 -0
- package/dist/core/errors.js +65 -0
- package/dist/core/integration/error-map.d.ts +6 -0
- package/dist/core/integration/error-map.js +79 -0
- package/dist/core/integration/file-url.d.ts +2 -0
- package/dist/core/integration/file-url.js +81 -0
- package/dist/core/integration/index.d.ts +2 -0
- package/dist/core/integration/index.js +112 -0
- package/dist/core/integration/typegen.d.ts +5 -0
- package/dist/core/integration/typegen.js +31 -0
- package/dist/core/integration/vite-plugin-db.d.ts +29 -0
- package/dist/core/integration/vite-plugin-db.js +111 -0
- package/dist/core/integration/vite-plugin-inject-env-ts.d.ts +11 -0
- package/dist/core/integration/vite-plugin-inject-env-ts.js +53 -0
- package/dist/core/load-file.d.ts +31 -0
- package/dist/core/load-file.js +98 -0
- package/dist/core/tokens.d.ts +11 -0
- package/dist/core/tokens.js +131 -0
- package/dist/core/types.d.ts +3901 -0
- package/dist/core/types.js +143 -0
- package/dist/core/utils.d.ts +6 -0
- package/dist/core/utils.js +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/runtime/config.d.ts +148 -0
- package/dist/runtime/config.js +87 -0
- package/dist/runtime/db-client.d.ts +5 -0
- package/dist/runtime/db-client.js +64 -0
- package/dist/runtime/drizzle.d.ts +1 -0
- package/dist/runtime/drizzle.js +48 -0
- package/dist/runtime/index.d.ts +31 -0
- package/dist/runtime/index.js +126 -0
- package/dist/runtime/queries.d.ts +81 -0
- package/dist/runtime/queries.js +206 -0
- package/dist/runtime/types.d.ts +69 -0
- package/dist/runtime/types.js +8 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +4 -0
- package/index.d.ts +3 -0
- package/package.json +90 -0
- package/virtual.d.ts +9 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { BooleanColumn, ColumnType, DBColumn, DBTable, DBTables, DateColumn, JsonColumn, NumberColumn, TextColumn } from '../core/types.js';
|
|
2
|
+
import { type SqliteDB } from './index.js';
|
|
3
|
+
export declare const SEED_DEV_FILE_NAME: string[];
|
|
4
|
+
export declare function seedLocal({ db, tables, fileGlob, }: {
|
|
5
|
+
db: SqliteDB;
|
|
6
|
+
tables: DBTables;
|
|
7
|
+
fileGlob: Record<string, () => Promise<void>>;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function recreateTables({ db, tables }: {
|
|
10
|
+
db: SqliteDB;
|
|
11
|
+
tables: DBTables;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function getDropTableIfExistsQuery(tableName: string): string;
|
|
14
|
+
export declare function getCreateTableQuery(tableName: string, table: DBTable): string;
|
|
15
|
+
export declare function getCreateIndexQueries(tableName: string, table: Pick<DBTable, 'indexes'>): string[];
|
|
16
|
+
export declare function getCreateForeignKeyQueries(tableName: string, table: DBTable): string[];
|
|
17
|
+
export declare function schemaTypeToSqlType(type: ColumnType): 'text' | 'integer';
|
|
18
|
+
export declare function getModifiers(columnName: string, column: DBColumn): string;
|
|
19
|
+
export declare function getReferencesConfig(column: DBColumn): {
|
|
20
|
+
type: "number";
|
|
21
|
+
schema: ({
|
|
22
|
+
unique: boolean;
|
|
23
|
+
deprecated: boolean;
|
|
24
|
+
name?: string | undefined;
|
|
25
|
+
label?: string | undefined;
|
|
26
|
+
collection?: string | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
optional: boolean;
|
|
29
|
+
primaryKey: false;
|
|
30
|
+
default?: number | import("./types.js").SerializedSQL | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
references?: any | undefined;
|
|
33
|
+
}) | ({
|
|
34
|
+
unique: boolean;
|
|
35
|
+
deprecated: boolean;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
label?: string | undefined;
|
|
38
|
+
collection?: string | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
primaryKey: true;
|
|
41
|
+
optional?: false | undefined;
|
|
42
|
+
default?: undefined;
|
|
43
|
+
} & {
|
|
44
|
+
references?: any | undefined;
|
|
45
|
+
});
|
|
46
|
+
} | {
|
|
47
|
+
type: "text";
|
|
48
|
+
schema: ({
|
|
49
|
+
unique: boolean;
|
|
50
|
+
deprecated: boolean;
|
|
51
|
+
name?: string | undefined;
|
|
52
|
+
label?: string | undefined;
|
|
53
|
+
collection?: string | undefined;
|
|
54
|
+
default?: string | import("./types.js").SerializedSQL | undefined;
|
|
55
|
+
multiline?: boolean | undefined;
|
|
56
|
+
} & {
|
|
57
|
+
optional: boolean;
|
|
58
|
+
primaryKey: false;
|
|
59
|
+
} & {
|
|
60
|
+
references?: any | undefined;
|
|
61
|
+
}) | ({
|
|
62
|
+
unique: boolean;
|
|
63
|
+
deprecated: boolean;
|
|
64
|
+
name?: string | undefined;
|
|
65
|
+
label?: string | undefined;
|
|
66
|
+
collection?: string | undefined;
|
|
67
|
+
default?: string | import("./types.js").SerializedSQL | undefined;
|
|
68
|
+
multiline?: boolean | undefined;
|
|
69
|
+
} & {
|
|
70
|
+
primaryKey: true;
|
|
71
|
+
optional?: false | undefined;
|
|
72
|
+
} & {
|
|
73
|
+
references?: any | undefined;
|
|
74
|
+
});
|
|
75
|
+
} | undefined;
|
|
76
|
+
type WithDefaultDefined<T extends DBColumn> = T & {
|
|
77
|
+
schema: Required<Pick<T['schema'], 'default'>>;
|
|
78
|
+
};
|
|
79
|
+
type DBColumnWithDefault = WithDefaultDefined<TextColumn> | WithDefaultDefined<DateColumn> | WithDefaultDefined<NumberColumn> | WithDefaultDefined<BooleanColumn> | WithDefaultDefined<JsonColumn>;
|
|
80
|
+
export declare function hasDefault(column: DBColumn): column is DBColumnWithDefault;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { LibsqlError } from "@libsql/client";
|
|
2
|
+
import { sql } from "drizzle-orm";
|
|
3
|
+
import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
|
|
4
|
+
import { bold } from "kleur/colors";
|
|
5
|
+
import {
|
|
6
|
+
FOREIGN_KEY_DNE_ERROR,
|
|
7
|
+
FOREIGN_KEY_REFERENCES_EMPTY_ERROR,
|
|
8
|
+
FOREIGN_KEY_REFERENCES_LENGTH_ERROR,
|
|
9
|
+
REFERENCE_DNE_ERROR,
|
|
10
|
+
SEED_ERROR
|
|
11
|
+
} from "../core/errors.js";
|
|
12
|
+
import { hasPrimaryKey } from "./index.js";
|
|
13
|
+
import { isSerializedSQL } from "./types.js";
|
|
14
|
+
const sqlite = new SQLiteAsyncDialect();
|
|
15
|
+
const SEED_DEV_FILE_NAME = ["seed.ts", "seed.js", "seed.mjs", "seed.mts"];
|
|
16
|
+
async function seedLocal({
|
|
17
|
+
db,
|
|
18
|
+
tables,
|
|
19
|
+
// Glob all potential seed files to catch renames and deletions.
|
|
20
|
+
fileGlob
|
|
21
|
+
}) {
|
|
22
|
+
await recreateTables({ db, tables });
|
|
23
|
+
for (const fileName of SEED_DEV_FILE_NAME) {
|
|
24
|
+
const key = Object.keys(fileGlob).find((f) => f.endsWith(fileName));
|
|
25
|
+
if (key) {
|
|
26
|
+
await fileGlob[key]().catch((e) => {
|
|
27
|
+
if (e instanceof LibsqlError) {
|
|
28
|
+
throw new Error(SEED_ERROR(e.message));
|
|
29
|
+
}
|
|
30
|
+
throw e;
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function recreateTables({ db, tables }) {
|
|
37
|
+
const setupQueries = [];
|
|
38
|
+
for (const [name, table] of Object.entries(tables)) {
|
|
39
|
+
const dropQuery = sql.raw(`DROP TABLE IF EXISTS ${sqlite.escapeName(name)}`);
|
|
40
|
+
const createQuery = sql.raw(getCreateTableQuery(name, table));
|
|
41
|
+
const indexQueries = getCreateIndexQueries(name, table);
|
|
42
|
+
setupQueries.push(dropQuery, createQuery, ...indexQueries.map((s) => sql.raw(s)));
|
|
43
|
+
}
|
|
44
|
+
await db.batch([
|
|
45
|
+
db.run(sql`pragma defer_foreign_keys=true;`),
|
|
46
|
+
...setupQueries.map((q) => db.run(q))
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
function getDropTableIfExistsQuery(tableName) {
|
|
50
|
+
return `DROP TABLE IF EXISTS ${sqlite.escapeName(tableName)}`;
|
|
51
|
+
}
|
|
52
|
+
function getCreateTableQuery(tableName, table) {
|
|
53
|
+
let query = `CREATE TABLE ${sqlite.escapeName(tableName)} (`;
|
|
54
|
+
const colQueries = [];
|
|
55
|
+
const colHasPrimaryKey = Object.entries(table.columns).find(
|
|
56
|
+
([, column]) => hasPrimaryKey(column)
|
|
57
|
+
);
|
|
58
|
+
if (!colHasPrimaryKey) {
|
|
59
|
+
colQueries.push("_id INTEGER PRIMARY KEY");
|
|
60
|
+
}
|
|
61
|
+
for (const [columnName, column] of Object.entries(table.columns)) {
|
|
62
|
+
const colQuery = `${sqlite.escapeName(columnName)} ${schemaTypeToSqlType(
|
|
63
|
+
column.type
|
|
64
|
+
)}${getModifiers(columnName, column)}`;
|
|
65
|
+
colQueries.push(colQuery);
|
|
66
|
+
}
|
|
67
|
+
colQueries.push(...getCreateForeignKeyQueries(tableName, table));
|
|
68
|
+
query += colQueries.join(", ") + ")";
|
|
69
|
+
return query;
|
|
70
|
+
}
|
|
71
|
+
function getCreateIndexQueries(tableName, table) {
|
|
72
|
+
let queries = [];
|
|
73
|
+
for (const [indexName, indexProps] of Object.entries(table.indexes ?? {})) {
|
|
74
|
+
const onColNames = asArray(indexProps.on);
|
|
75
|
+
const onCols = onColNames.map((colName) => sqlite.escapeName(colName));
|
|
76
|
+
const unique = indexProps.unique ? "UNIQUE " : "";
|
|
77
|
+
const indexQuery = `CREATE ${unique}INDEX ${sqlite.escapeName(
|
|
78
|
+
indexName
|
|
79
|
+
)} ON ${sqlite.escapeName(tableName)} (${onCols.join(", ")})`;
|
|
80
|
+
queries.push(indexQuery);
|
|
81
|
+
}
|
|
82
|
+
return queries;
|
|
83
|
+
}
|
|
84
|
+
function getCreateForeignKeyQueries(tableName, table) {
|
|
85
|
+
let queries = [];
|
|
86
|
+
for (const foreignKey of table.foreignKeys ?? []) {
|
|
87
|
+
const columns = asArray(foreignKey.columns);
|
|
88
|
+
const references = asArray(foreignKey.references);
|
|
89
|
+
if (columns.length !== references.length) {
|
|
90
|
+
throw new Error(FOREIGN_KEY_REFERENCES_LENGTH_ERROR(tableName));
|
|
91
|
+
}
|
|
92
|
+
const firstReference = references[0];
|
|
93
|
+
if (!firstReference) {
|
|
94
|
+
throw new Error(FOREIGN_KEY_REFERENCES_EMPTY_ERROR(tableName));
|
|
95
|
+
}
|
|
96
|
+
const referencedTable = firstReference.schema.collection;
|
|
97
|
+
if (!referencedTable) {
|
|
98
|
+
throw new Error(FOREIGN_KEY_DNE_ERROR(tableName));
|
|
99
|
+
}
|
|
100
|
+
const query = `FOREIGN KEY (${columns.map((f) => sqlite.escapeName(f)).join(", ")}) REFERENCES ${sqlite.escapeName(referencedTable)}(${references.map((r) => sqlite.escapeName(r.schema.name)).join(", ")})`;
|
|
101
|
+
queries.push(query);
|
|
102
|
+
}
|
|
103
|
+
return queries;
|
|
104
|
+
}
|
|
105
|
+
function asArray(value) {
|
|
106
|
+
return Array.isArray(value) ? value : [value];
|
|
107
|
+
}
|
|
108
|
+
function schemaTypeToSqlType(type) {
|
|
109
|
+
switch (type) {
|
|
110
|
+
case "date":
|
|
111
|
+
case "text":
|
|
112
|
+
case "json":
|
|
113
|
+
return "text";
|
|
114
|
+
case "number":
|
|
115
|
+
case "boolean":
|
|
116
|
+
return "integer";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function getModifiers(columnName, column) {
|
|
120
|
+
let modifiers = "";
|
|
121
|
+
if (hasPrimaryKey(column)) {
|
|
122
|
+
return " PRIMARY KEY";
|
|
123
|
+
}
|
|
124
|
+
if (!column.schema.optional) {
|
|
125
|
+
modifiers += " NOT NULL";
|
|
126
|
+
}
|
|
127
|
+
if (column.schema.unique) {
|
|
128
|
+
modifiers += " UNIQUE";
|
|
129
|
+
}
|
|
130
|
+
if (hasDefault(column)) {
|
|
131
|
+
modifiers += ` DEFAULT ${getDefaultValueSql(columnName, column)}`;
|
|
132
|
+
}
|
|
133
|
+
const references = getReferencesConfig(column);
|
|
134
|
+
if (references) {
|
|
135
|
+
const { collection: tableName, name } = references.schema;
|
|
136
|
+
if (!tableName || !name) {
|
|
137
|
+
throw new Error(REFERENCE_DNE_ERROR(columnName));
|
|
138
|
+
}
|
|
139
|
+
modifiers += ` REFERENCES ${sqlite.escapeName(tableName)} (${sqlite.escapeName(name)})`;
|
|
140
|
+
}
|
|
141
|
+
return modifiers;
|
|
142
|
+
}
|
|
143
|
+
function getReferencesConfig(column) {
|
|
144
|
+
const canHaveReferences = column.type === "number" || column.type === "text";
|
|
145
|
+
if (!canHaveReferences)
|
|
146
|
+
return void 0;
|
|
147
|
+
return column.schema.references;
|
|
148
|
+
}
|
|
149
|
+
function hasDefault(column) {
|
|
150
|
+
if (column.schema.default !== void 0) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
if (hasPrimaryKey(column) && column.type === "number") {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
function toDefault(def) {
|
|
159
|
+
const type = typeof def;
|
|
160
|
+
if (type === "string") {
|
|
161
|
+
return sqlite.escapeString(def);
|
|
162
|
+
} else if (type === "boolean") {
|
|
163
|
+
return def ? "TRUE" : "FALSE";
|
|
164
|
+
} else {
|
|
165
|
+
return def + "";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function getDefaultValueSql(columnName, column) {
|
|
169
|
+
if (isSerializedSQL(column.schema.default)) {
|
|
170
|
+
return column.schema.default.sql;
|
|
171
|
+
}
|
|
172
|
+
switch (column.type) {
|
|
173
|
+
case "boolean":
|
|
174
|
+
case "number":
|
|
175
|
+
case "text":
|
|
176
|
+
case "date":
|
|
177
|
+
return toDefault(column.schema.default);
|
|
178
|
+
case "json": {
|
|
179
|
+
let stringified = "";
|
|
180
|
+
try {
|
|
181
|
+
stringified = JSON.stringify(column.schema.default);
|
|
182
|
+
} catch (e) {
|
|
183
|
+
console.log(
|
|
184
|
+
`Invalid default value for column ${bold(
|
|
185
|
+
columnName
|
|
186
|
+
)}. Defaults must be valid JSON when using the \`json()\` type.`
|
|
187
|
+
);
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
return sqlite.escapeString(stringified);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
SEED_DEV_FILE_NAME,
|
|
196
|
+
getCreateForeignKeyQueries,
|
|
197
|
+
getCreateIndexQueries,
|
|
198
|
+
getCreateTableQuery,
|
|
199
|
+
getDropTableIfExistsQuery,
|
|
200
|
+
getModifiers,
|
|
201
|
+
getReferencesConfig,
|
|
202
|
+
hasDefault,
|
|
203
|
+
recreateTables,
|
|
204
|
+
schemaTypeToSqlType,
|
|
205
|
+
seedLocal
|
|
206
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
|
|
2
|
+
import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
|
|
3
|
+
import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
|
|
4
|
+
type GeneratedConfig<T extends ColumnDataType = ColumnDataType> = Pick<ColumnBaseConfig<T, string>, 'name' | 'tableName' | 'notNull' | 'hasDefault'>;
|
|
5
|
+
export type AstroText<T extends GeneratedConfig<'string'>> = SQLiteColumn<T & {
|
|
6
|
+
data: string;
|
|
7
|
+
dataType: 'string';
|
|
8
|
+
columnType: 'SQLiteText';
|
|
9
|
+
driverParam: string;
|
|
10
|
+
enumValues: never;
|
|
11
|
+
baseColumn: never;
|
|
12
|
+
}>;
|
|
13
|
+
export type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
|
14
|
+
data: Date;
|
|
15
|
+
dataType: 'custom';
|
|
16
|
+
columnType: 'SQLiteCustomColumn';
|
|
17
|
+
driverParam: string;
|
|
18
|
+
enumValues: never;
|
|
19
|
+
baseColumn: never;
|
|
20
|
+
}>;
|
|
21
|
+
export type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn<T & {
|
|
22
|
+
data: boolean;
|
|
23
|
+
dataType: 'boolean';
|
|
24
|
+
columnType: 'SQLiteBoolean';
|
|
25
|
+
driverParam: number;
|
|
26
|
+
enumValues: never;
|
|
27
|
+
baseColumn: never;
|
|
28
|
+
}>;
|
|
29
|
+
export type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn<T & {
|
|
30
|
+
data: number;
|
|
31
|
+
dataType: 'number';
|
|
32
|
+
columnType: 'SQLiteInteger';
|
|
33
|
+
driverParam: number;
|
|
34
|
+
enumValues: never;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
}>;
|
|
37
|
+
export type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
|
38
|
+
data: unknown;
|
|
39
|
+
dataType: 'custom';
|
|
40
|
+
columnType: 'SQLiteCustomColumn';
|
|
41
|
+
driverParam: string;
|
|
42
|
+
enumValues: never;
|
|
43
|
+
baseColumn: never;
|
|
44
|
+
}>;
|
|
45
|
+
export type Column<T extends DBColumn['type'], S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
|
|
46
|
+
export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
|
|
47
|
+
name: TTableName;
|
|
48
|
+
schema: undefined;
|
|
49
|
+
dialect: 'sqlite';
|
|
50
|
+
columns: {
|
|
51
|
+
[K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], {
|
|
52
|
+
tableName: TTableName;
|
|
53
|
+
name: K;
|
|
54
|
+
hasDefault: TColumns[K]['schema'] extends {
|
|
55
|
+
default: NonNullable<unknown>;
|
|
56
|
+
} ? true : TColumns[K]['schema'] extends {
|
|
57
|
+
primaryKey: true;
|
|
58
|
+
} ? true : false;
|
|
59
|
+
notNull: TColumns[K]['schema']['optional'] extends true ? false : true;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
export declare const SERIALIZED_SQL_KEY = "__serializedSQL";
|
|
64
|
+
export type SerializedSQL = {
|
|
65
|
+
[SERIALIZED_SQL_KEY]: true;
|
|
66
|
+
sql: string;
|
|
67
|
+
};
|
|
68
|
+
export declare function isSerializedSQL(value: any): value is SerializedSQL;
|
|
69
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { asDrizzleTable } from './runtime/index.js';
|
package/dist/utils.js
ADDED
package/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@astrojs/db",
|
|
3
|
+
"version": "0.0.0-db-export-bug-20240307130354",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "withastro",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./utils": {
|
|
16
|
+
"types": "./dist/utils.d.ts",
|
|
17
|
+
"import": "./dist/utils.js"
|
|
18
|
+
},
|
|
19
|
+
"./runtime": {
|
|
20
|
+
"types": "./dist/runtime/index.d.ts",
|
|
21
|
+
"import": "./dist/runtime/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./runtime/config": {
|
|
24
|
+
"types": "./dist/runtime/config.d.ts",
|
|
25
|
+
"import": "./dist/runtime/config.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
".": [
|
|
32
|
+
"./index.d.ts"
|
|
33
|
+
],
|
|
34
|
+
"utils": [
|
|
35
|
+
"./dist/utils.d.ts"
|
|
36
|
+
],
|
|
37
|
+
"runtime": [
|
|
38
|
+
"./dist/runtime/index.d.ts"
|
|
39
|
+
],
|
|
40
|
+
"runtime/config": [
|
|
41
|
+
"./dist/runtime/config.d.ts"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"index.d.ts",
|
|
47
|
+
"virtual.d.ts",
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
50
|
+
"keywords": [
|
|
51
|
+
"withastro",
|
|
52
|
+
"astro-integration"
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@libsql/client": "^0.4.3",
|
|
56
|
+
"async-listen": "^3.0.1",
|
|
57
|
+
"deep-diff": "^1.0.2",
|
|
58
|
+
"drizzle-orm": "^0.28.6",
|
|
59
|
+
"kleur": "^4.1.5",
|
|
60
|
+
"nanoid": "^5.0.1",
|
|
61
|
+
"open": "^10.0.3",
|
|
62
|
+
"ora": "^7.0.1",
|
|
63
|
+
"prompts": "^2.4.2",
|
|
64
|
+
"strip-ansi": "^7.1.0",
|
|
65
|
+
"yargs-parser": "^21.1.1",
|
|
66
|
+
"zod": "^3.22.4"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/chai": "^4.3.6",
|
|
70
|
+
"@types/deep-diff": "^1.0.5",
|
|
71
|
+
"@types/diff": "^5.0.8",
|
|
72
|
+
"@types/mocha": "^10.0.2",
|
|
73
|
+
"@types/prompts": "^2.4.8",
|
|
74
|
+
"@types/yargs-parser": "^21.0.3",
|
|
75
|
+
"chai": "^4.3.10",
|
|
76
|
+
"cheerio": "1.0.0-rc.12",
|
|
77
|
+
"mocha": "^10.2.0",
|
|
78
|
+
"typescript": "^5.2.2",
|
|
79
|
+
"vite": "^5.1.4",
|
|
80
|
+
"astro": "0.0.0-db-export-bug-20240307130354",
|
|
81
|
+
"astro-scripts": "0.0.14"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
|
85
|
+
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
86
|
+
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
87
|
+
"test": "mocha --exit --timeout 20000 \"test/*.js\" \"test/unit/**/*.js\"",
|
|
88
|
+
"test:match": "mocha --timeout 20000 \"test/*.js\" \"test/unit/*.js\" -g"
|
|
89
|
+
}
|
|
90
|
+
}
|
package/virtual.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'astro:db' {
|
|
2
|
+
export const sql: typeof import('./dist/runtime/config.js').sql;
|
|
3
|
+
export const NOW: typeof import('./dist/runtime/config.js').NOW;
|
|
4
|
+
export const TRUE: typeof import('./dist/runtime/config.js').TRUE;
|
|
5
|
+
export const FALSE: typeof import('./dist/runtime/config.js').FALSE;
|
|
6
|
+
export const column: typeof import('./dist/runtime/config.js').column;
|
|
7
|
+
export const defineDB: typeof import('./dist/runtime/config.js').defineDB;
|
|
8
|
+
export const defineTable: typeof import('./dist/runtime/config.js').defineTable;
|
|
9
|
+
}
|