Skip to content

Commit b457872

Browse files
authored
refactor: remove importMap and reexport kysely and postgres (#3)
1 parent 7cccdf4 commit b457872

6 files changed

Lines changed: 19 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

deno.jsonc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"exclude": [
99
".git"
1010
],
11-
"imports": {
12-
"kysely": "https://esm.sh/kysely@0.26.3",
13-
"postgres": "https://deno.land/x/postgres@v0.17.0/mod.ts"
14-
},
1511
"tasks": {
1612
"test": "deno test -A",
1713
"check:types": "deno check **/*.ts",

deps.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ export {
1212
type QueryCompiler,
1313
type QueryResult,
1414
type TransactionSettings,
15-
} from "kysely";
16-
export { Pool, PoolClient } from "postgres";
15+
} from "https://esm.sh/kysely@0.26.3";
16+
export { Pool, PoolClient } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
17+
18+
export * as kysely from "https://esm.sh/kysely@0.26.3";
19+
export * as postgres from "https://deno.land/x/postgres@v0.17.0/mod.ts";

tests/integration_test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
it,
77
} from "https://deno.land/std@0.210.0/testing/bdd.ts";
88

9-
import { sql } from "kysely";
9+
import { kysely } from "../deps.ts";
1010
import { db } from "./support/database.ts";
1111
import * as PersonRepository from "./support/person-repository.ts";
1212

13+
const sql = kysely.sql;
14+
1315
describe("PersonRepository", () => {
1416
beforeAll(async () => {
1517
await db.schema.createTable("person")

tests/support/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { Kysely } from "../../deps.ts";
12
import { Database } from "./types.ts"; // this is the Database interface we defined earlier
2-
import { Kysely } from "kysely";
33
import { KyselyDenoPostgresDialect, Pool } from "../../mod.ts";
44

55
const dialect = new KyselyDenoPostgresDialect({

tests/support/types.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
ColumnType,
3-
Generated,
4-
Insertable,
5-
Selectable,
6-
Updateable,
7-
} from "kysely";
1+
import { kysely } from "../../deps.ts";
82

93
export interface Database {
104
person: PersonTable;
@@ -15,7 +9,7 @@ export interface PersonTable {
159
// Columns that are generated by the database should be marked
1610
// using the `Generated` type. This way they are automatically
1711
// made optional in inserts and updates.
18-
id: Generated<number>;
12+
id: kysely.Generated<number>;
1913

2014
first_name: string;
2115
gender: "man" | "woman" | "other";
@@ -30,23 +24,23 @@ export interface PersonTable {
3024
// wrapper. Here we define a column `created_at` that is selected as
3125
// a `Date`, can optionally be provided as a `string` in inserts and
3226
// can never be updated:
33-
created_at: ColumnType<Date, string | undefined, never>;
27+
created_at: kysely.ColumnType<Date, string | undefined, never>;
3428
}
3529

3630
// You should not use the table schema interfaces directly. Instead, you should
3731
// use the `Selectable`, `Insertable` and `Updateable` wrappers. These wrappers
3832
// make sure that the correct types are used in each operation.
39-
export type Person = Selectable<PersonTable>;
40-
export type NewPerson = Insertable<PersonTable>;
41-
export type PersonUpdate = Updateable<PersonTable>;
33+
export type Person = kysely.Selectable<PersonTable>;
34+
export type NewPerson = kysely.Insertable<PersonTable>;
35+
export type PersonUpdate = kysely.Updateable<PersonTable>;
4236

4337
export interface PetTable {
44-
id: Generated<number>;
38+
id: kysely.Generated<number>;
4539
name: string;
4640
owner_id: number;
4741
species: "dog" | "cat";
4842
}
4943

50-
export type Pet = Selectable<PetTable>;
51-
export type NewPet = Insertable<PetTable>;
52-
export type PetUpdate = Updateable<PetTable>;
44+
export type Pet = kysely.Selectable<PetTable>;
45+
export type NewPet = kysely.Insertable<PetTable>;
46+
export type PetUpdate = kysely.Updateable<PetTable>;

0 commit comments

Comments
 (0)