@astrojs/db 0.21.1 → 0.21.2
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/print-help.js +1 -1
- package/package.json +6 -9
- package/virtual.d.ts +1 -1
- package/dist/_internal/core/integration/error-map.d.ts +0 -2
- package/dist/_internal/core/schemas.d.ts +0 -1444
- package/dist/_internal/core/types.d.ts +0 -60
- package/dist/_internal/core/utils.d.ts +0 -19
- package/dist/_internal/runtime/types.d.ts +0 -92
- package/dist/_internal/runtime/utils.d.ts +0 -10
- /package/dist/{_internal/runtime → runtime}/virtual.d.ts +0 -0
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type * as z from 'zod/v4';
|
|
2
|
-
import type { booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, MaybeArray, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
|
|
3
|
-
export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
|
|
4
|
-
export type BooleanColumn = z.infer<typeof booleanColumnSchema>;
|
|
5
|
-
export type BooleanColumnInput = z.input<typeof booleanColumnSchema>;
|
|
6
|
-
export type NumberColumn = z.infer<typeof numberColumnSchema>;
|
|
7
|
-
export type NumberColumnInput = z.input<typeof numberColumnSchema>;
|
|
8
|
-
export type TextColumn = z.infer<typeof textColumnSchema>;
|
|
9
|
-
export type TextColumnInput = z.input<typeof textColumnSchema>;
|
|
10
|
-
export type DateColumn = z.infer<typeof dateColumnSchema>;
|
|
11
|
-
export type DateColumnInput = z.input<typeof dateColumnSchema>;
|
|
12
|
-
export type JsonColumn = z.infer<typeof jsonColumnSchema>;
|
|
13
|
-
export type JsonColumnInput = z.input<typeof jsonColumnSchema>;
|
|
14
|
-
export type ColumnType = BooleanColumn['type'] | NumberColumn['type'] | TextColumn['type'] | DateColumn['type'] | JsonColumn['type'];
|
|
15
|
-
export type DBColumn = z.infer<typeof columnSchema>;
|
|
16
|
-
export type DBColumnInput = DateColumnInput | BooleanColumnInput | NumberColumnInput | TextColumnInput | JsonColumnInput;
|
|
17
|
-
export type DBColumns = z.infer<typeof columnsSchema>;
|
|
18
|
-
export type DBTable = z.infer<typeof tableSchema>;
|
|
19
|
-
export type DBTables = Record<string, DBTable>;
|
|
20
|
-
export type ResolvedDBTables = z.output<typeof dbConfigSchema>['tables'];
|
|
21
|
-
export type ResolvedDBTable = z.output<typeof dbConfigSchema>['tables'][string];
|
|
22
|
-
export type DBSnapshot = {
|
|
23
|
-
schema: Record<string, ResolvedDBTable>;
|
|
24
|
-
version: string;
|
|
25
|
-
};
|
|
26
|
-
export type DBConfigInput = z.input<typeof dbConfigSchema>;
|
|
27
|
-
export type DBConfig = z.infer<typeof dbConfigSchema>;
|
|
28
|
-
export type ColumnsConfig = z.input<typeof tableSchema>['columns'];
|
|
29
|
-
export type OutputColumnsConfig = z.output<typeof tableSchema>['columns'];
|
|
30
|
-
export interface TableConfig<TColumns extends ColumnsConfig = ColumnsConfig> extends Pick<z.input<typeof tableSchema>, 'columns' | 'indexes' | 'foreignKeys'> {
|
|
31
|
-
columns: TColumns;
|
|
32
|
-
foreignKeys?: Array<{
|
|
33
|
-
columns: MaybeArray<Extract<keyof TColumns, string>>;
|
|
34
|
-
references: () => MaybeArray<z.input<typeof referenceableColumnSchema>>;
|
|
35
|
-
}>;
|
|
36
|
-
indexes?: Array<IndexConfig<TColumns>> | Record<string, LegacyIndexConfig<TColumns>>;
|
|
37
|
-
deprecated?: boolean;
|
|
38
|
-
}
|
|
39
|
-
interface IndexConfig<TColumns extends ColumnsConfig> extends z.input<typeof indexSchema> {
|
|
40
|
-
on: MaybeArray<Extract<keyof TColumns, string>>;
|
|
41
|
-
}
|
|
42
|
-
/** @deprecated */
|
|
43
|
-
interface LegacyIndexConfig<TColumns extends ColumnsConfig> extends z.input<typeof resolvedIndexSchema> {
|
|
44
|
-
on: MaybeArray<Extract<keyof TColumns, string>>;
|
|
45
|
-
}
|
|
46
|
-
export type NumberColumnOpts = z.input<typeof numberColumnOptsSchema>;
|
|
47
|
-
export type TextColumnOpts = z.input<typeof textColumnOptsSchema>;
|
|
48
|
-
declare global {
|
|
49
|
-
namespace Astro {
|
|
50
|
-
interface IntegrationHooks {
|
|
51
|
-
'astro:db:setup'?: (options: {
|
|
52
|
-
extendDb: (options: {
|
|
53
|
-
configEntrypoint?: URL | string;
|
|
54
|
-
seedEntrypoint?: URL | string;
|
|
55
|
-
}) => void;
|
|
56
|
-
}) => void | Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AstroConfig, AstroIntegration } from 'astro';
|
|
2
|
-
import type { Arguments } from 'yargs-parser';
|
|
3
|
-
import './types.js';
|
|
4
|
-
export type VitePlugin = Required<AstroConfig['vite']>['plugins'][number];
|
|
5
|
-
export declare function getAstroEnv(envMode?: string): Record<`ASTRO_${string}`, string>;
|
|
6
|
-
export type RemoteDatabaseInfo = {
|
|
7
|
-
url: string;
|
|
8
|
-
token: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function getRemoteDatabaseInfo(): RemoteDatabaseInfo;
|
|
11
|
-
export declare function resolveDbAppToken(flags: Arguments, envToken: string): string;
|
|
12
|
-
export declare function resolveDbAppToken(flags: Arguments, envToken: string | undefined): string | undefined;
|
|
13
|
-
export declare function getDbDirectoryUrl(root: URL | string): URL;
|
|
14
|
-
export declare function defineDbIntegration(integration: AstroIntegration): AstroIntegration;
|
|
15
|
-
/**
|
|
16
|
-
* Map an object's values to a new set of values
|
|
17
|
-
* while preserving types.
|
|
18
|
-
*/
|
|
19
|
-
export declare function mapObject<T, U = T>(item: Record<string, T>, callback: (key: string, value: T) => U): Record<string, U>;
|
|
@@ -1,92 +0,0 @@
|
|
|
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' | 'hasRuntimeDefault' | 'isPrimaryKey'>;
|
|
5
|
-
type AstroText<T extends GeneratedConfig<'string'>, E extends readonly [string, ...string[]] | string> = SQLiteColumn<T & {
|
|
6
|
-
data: E extends readonly (infer U)[] ? U : string;
|
|
7
|
-
dataType: 'string';
|
|
8
|
-
columnType: 'SQLiteText';
|
|
9
|
-
driverParam: string;
|
|
10
|
-
enumValues: E extends [string, ...string[]] ? E : never;
|
|
11
|
-
baseColumn: never;
|
|
12
|
-
isAutoincrement: boolean;
|
|
13
|
-
identity: undefined;
|
|
14
|
-
generated: undefined;
|
|
15
|
-
}>;
|
|
16
|
-
type AstroDate<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
|
17
|
-
data: Date;
|
|
18
|
-
dataType: 'custom';
|
|
19
|
-
columnType: 'SQLiteCustomColumn';
|
|
20
|
-
driverParam: string;
|
|
21
|
-
enumValues: never;
|
|
22
|
-
baseColumn: never;
|
|
23
|
-
isAutoincrement: boolean;
|
|
24
|
-
identity: undefined;
|
|
25
|
-
generated: undefined;
|
|
26
|
-
}>;
|
|
27
|
-
type AstroBoolean<T extends GeneratedConfig<'boolean'>> = SQLiteColumn<T & {
|
|
28
|
-
data: boolean;
|
|
29
|
-
dataType: 'boolean';
|
|
30
|
-
columnType: 'SQLiteBoolean';
|
|
31
|
-
driverParam: number;
|
|
32
|
-
enumValues: never;
|
|
33
|
-
baseColumn: never;
|
|
34
|
-
isAutoincrement: boolean;
|
|
35
|
-
identity: undefined;
|
|
36
|
-
generated: undefined;
|
|
37
|
-
}>;
|
|
38
|
-
type AstroNumber<T extends GeneratedConfig<'number'>> = SQLiteColumn<T & {
|
|
39
|
-
data: number;
|
|
40
|
-
dataType: 'number';
|
|
41
|
-
columnType: 'SQLiteInteger';
|
|
42
|
-
driverParam: number;
|
|
43
|
-
enumValues: never;
|
|
44
|
-
baseColumn: never;
|
|
45
|
-
isAutoincrement: boolean;
|
|
46
|
-
identity: undefined;
|
|
47
|
-
generated: undefined;
|
|
48
|
-
}>;
|
|
49
|
-
type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
|
|
50
|
-
data: unknown;
|
|
51
|
-
dataType: 'custom';
|
|
52
|
-
columnType: 'SQLiteCustomColumn';
|
|
53
|
-
driverParam: string;
|
|
54
|
-
enumValues: never;
|
|
55
|
-
baseColumn: never;
|
|
56
|
-
isAutoincrement: boolean;
|
|
57
|
-
identity: undefined;
|
|
58
|
-
generated: undefined;
|
|
59
|
-
}>;
|
|
60
|
-
type Column<T extends DBColumn['type'], E extends readonly [string, ...string[]] | string, S extends GeneratedConfig> = T extends 'boolean' ? AstroBoolean<S> : T extends 'number' ? AstroNumber<S> : T extends 'text' ? AstroText<S, E> : T extends 'date' ? AstroDate<S> : T extends 'json' ? AstroJson<S> : never;
|
|
61
|
-
export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
|
|
62
|
-
name: TTableName;
|
|
63
|
-
schema: undefined;
|
|
64
|
-
dialect: 'sqlite';
|
|
65
|
-
columns: {
|
|
66
|
-
[K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
|
|
67
|
-
enum: infer E;
|
|
68
|
-
} ? E extends readonly [string, ...string[]] ? E : string : string, {
|
|
69
|
-
tableName: TTableName;
|
|
70
|
-
name: K;
|
|
71
|
-
isPrimaryKey: TColumns[K]['schema'] extends {
|
|
72
|
-
primaryKey: true;
|
|
73
|
-
} ? true : false;
|
|
74
|
-
hasDefault: TColumns[K]['schema'] extends {
|
|
75
|
-
default: NonNullable<unknown>;
|
|
76
|
-
} ? true : TColumns[K]['schema'] extends {
|
|
77
|
-
primaryKey: true;
|
|
78
|
-
} ? true : false;
|
|
79
|
-
hasRuntimeDefault: TColumns[K]['schema'] extends {
|
|
80
|
-
default: NonNullable<unknown>;
|
|
81
|
-
} ? true : false;
|
|
82
|
-
notNull: TColumns[K]['schema']['optional'] extends true ? false : true;
|
|
83
|
-
}>;
|
|
84
|
-
};
|
|
85
|
-
}>;
|
|
86
|
-
export declare const SERIALIZED_SQL_KEY = "__serializedSQL";
|
|
87
|
-
export type SerializedSQL = {
|
|
88
|
-
[SERIALIZED_SQL_KEY]: true;
|
|
89
|
-
sql: string;
|
|
90
|
-
};
|
|
91
|
-
export declare function isSerializedSQL(value: any): value is SerializedSQL;
|
|
92
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LibsqlError } from '@libsql/client';
|
|
2
|
-
import { AstroError } from 'astro/errors';
|
|
3
|
-
import type { DBColumn } from '../core/types.js';
|
|
4
|
-
export declare function hasPrimaryKey(column: DBColumn): boolean;
|
|
5
|
-
export declare class AstroDbError extends AstroError {
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function getDbError(err: unknown): LibsqlError | undefined;
|
|
9
|
-
export declare function isDbError(err: unknown): boolean;
|
|
10
|
-
export declare function pathToFileURL(path: string): URL;
|
|
File without changes
|