@duckdbfan/drizzle-duckdb 0.0.1 → 0.0.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/columns.d.ts +1 -0
- package/dist/dialect.d.ts +9 -0
- package/dist/driver.d.ts +59 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3497 -0
- package/dist/migrator.d.ts +3 -0
- package/dist/session.d.ts +51 -0
- package/dist/utils.d.ts +5 -0
- package/package.json +15 -6
- package/.prettierrc +0 -7
- package/bun.lockb +0 -0
- package/tsconfig.json +0 -25
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Connection, Database, RowData } from 'duckdb-async';
|
|
2
|
+
import { entityKind } from 'drizzle-orm/entity';
|
|
3
|
+
import { type Logger } from 'drizzle-orm/logger';
|
|
4
|
+
import { PgTransaction } from 'drizzle-orm/pg-core';
|
|
5
|
+
import type { SelectedFieldsOrdered } from 'drizzle-orm/pg-core/query-builders/select.types';
|
|
6
|
+
import type { PgTransactionConfig, PreparedQueryConfig, PgQueryResultHKT } from 'drizzle-orm/pg-core/session';
|
|
7
|
+
import { PgPreparedQuery, PgSession } from 'drizzle-orm/pg-core/session';
|
|
8
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from 'drizzle-orm/relations';
|
|
9
|
+
import { type Query, SQL } from 'drizzle-orm/sql/sql';
|
|
10
|
+
import type { Assume } from 'drizzle-orm/utils';
|
|
11
|
+
import type { DuckDBDialect } from './dialect';
|
|
12
|
+
export type DuckDBClient = Database;
|
|
13
|
+
export declare class DuckDBPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
14
|
+
private client;
|
|
15
|
+
private queryString;
|
|
16
|
+
private params;
|
|
17
|
+
private logger;
|
|
18
|
+
private fields;
|
|
19
|
+
private _isResponseInArrayMode;
|
|
20
|
+
private customResultMapper?;
|
|
21
|
+
static readonly [entityKind]: string;
|
|
22
|
+
constructor(client: DuckDBClient | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
23
|
+
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
24
|
+
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
25
|
+
isResponseInArrayMode(): boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface DuckDBSessionOptions {
|
|
28
|
+
logger?: Logger;
|
|
29
|
+
}
|
|
30
|
+
export declare class DuckDBSession<TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>> extends PgSession<DuckDBQueryResultHKT, TFullSchema, TSchema> {
|
|
31
|
+
private client;
|
|
32
|
+
private schema;
|
|
33
|
+
private options;
|
|
34
|
+
static readonly [entityKind]: string;
|
|
35
|
+
private logger;
|
|
36
|
+
constructor(client: DuckDBClient | Connection, dialect: DuckDBDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: DuckDBSessionOptions);
|
|
37
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
38
|
+
transaction<T>(transaction: (tx: DuckDBTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
39
|
+
}
|
|
40
|
+
export declare class DuckDBTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<DuckDBQueryResultHKT, TFullSchema, TSchema> {
|
|
41
|
+
static readonly [entityKind]: string;
|
|
42
|
+
rollback(): never;
|
|
43
|
+
getTransactionConfigSQL(config: PgTransactionConfig): SQL;
|
|
44
|
+
setTransaction(config: PgTransactionConfig): Promise<void>;
|
|
45
|
+
transaction<T>(transaction: (tx: DuckDBTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
46
|
+
}
|
|
47
|
+
export type GenericRowData<T extends RowData = RowData> = T;
|
|
48
|
+
export type GenericTableData<T = RowData> = T[];
|
|
49
|
+
export interface DuckDBQueryResultHKT extends PgQueryResultHKT {
|
|
50
|
+
type: GenericTableData<Assume<this['row'], RowData>>;
|
|
51
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SelectedFieldsOrdered, type AnyColumn } from 'drizzle-orm';
|
|
2
|
+
import { type SelectedFields } from 'drizzle-orm/pg-core';
|
|
3
|
+
export declare function mapResultRow<TResult>(columns: SelectedFieldsOrdered<AnyColumn>, row: unknown[], joinsNotNullableMap: Record<string, boolean> | undefined): TResult;
|
|
4
|
+
export declare function aliasFields(fields: SelectedFields, fullJoin?: boolean): SelectedFields;
|
|
5
|
+
export declare function queryAdapter(query: string): string;
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckdbfan/drizzle-duckdb",
|
|
3
|
-
"
|
|
3
|
+
"module": "index.ts",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"version": "0.0.2",
|
|
4
7
|
"description": "A drizzle ORM client for use with DuckDB. Based on drizzle's Postgres client.",
|
|
5
|
-
"
|
|
8
|
+
"type": "module",
|
|
6
9
|
"scripts": {
|
|
10
|
+
"build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declarations",
|
|
11
|
+
"build:declarations": "tsc --emitDeclarationOnly --project tsconfig.types.json",
|
|
7
12
|
"test": "vitest",
|
|
8
13
|
"t": "vitest --watch --ui"
|
|
9
14
|
},
|
|
@@ -15,12 +20,11 @@
|
|
|
15
20
|
"@types/bun": "^1.2.5",
|
|
16
21
|
"@types/uuid": "^10.0.0",
|
|
17
22
|
"@vitest/ui": "^1.6.0",
|
|
23
|
+
"prettier": "^3.5.3",
|
|
24
|
+
"typescript": "^5.8.2",
|
|
18
25
|
"uuid": "^10.0.0",
|
|
19
26
|
"vitest": "^1.6.0"
|
|
20
27
|
},
|
|
21
|
-
"directories": {
|
|
22
|
-
"test": "test"
|
|
23
|
-
},
|
|
24
28
|
"repository": {
|
|
25
29
|
"type": "git",
|
|
26
30
|
"url": "git+https://github.com/duckdbfan/drizzle-duckdb.git"
|
|
@@ -34,5 +38,10 @@
|
|
|
34
38
|
"bugs": {
|
|
35
39
|
"url": "https://github.com/duckdbfan/drizzle-duckdb/issues"
|
|
36
40
|
},
|
|
37
|
-
"homepage": "https://github.com/duckdbfan/drizzle-duckdb#readme"
|
|
41
|
+
"homepage": "https://github.com/duckdbfan/drizzle-duckdb#readme",
|
|
42
|
+
"files": [
|
|
43
|
+
"src/*.ts",
|
|
44
|
+
"dist/*.js",
|
|
45
|
+
"dist/*.d.ts"
|
|
46
|
+
]
|
|
38
47
|
}
|
package/.prettierrc
DELETED
package/bun.lockb
DELETED
|
Binary file
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": ["ESNext"],
|
|
4
|
-
"target": "ESNext",
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleDetection": "force",
|
|
7
|
-
"isolatedModules": true, // need?
|
|
8
|
-
"composite": false, // need?
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"allowImportingTsExtensions": true,
|
|
11
|
-
"verbatimModuleSyntax": true,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"noFallthroughCasesInSwitch": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"allowSyntheticDefaultImports": true,
|
|
18
|
-
"esModuleInterop": true,
|
|
19
|
-
"strictNullChecks": true,
|
|
20
|
-
"strictFunctionTypes": true,
|
|
21
|
-
"strictBindCallApply": true,
|
|
22
|
-
"strictPropertyInitialization": true,
|
|
23
|
-
"noImplicitThis": true
|
|
24
|
-
}
|
|
25
|
-
}
|