@typesql/kysely 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @typesql/kysely
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - npm package pages link to the documentation site and the issue tracker, and list keywords.
8
+
9
+ - READMEs link to an example in the TypeScript Playground.
10
+
11
+ - Updated dependencies:
12
+ - @typesql/core@0.1.2
13
+
14
+ ## 0.1.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Docs, package descriptions and error messages spell the project name TypeSQL.
19
+
20
+ - Updated dependencies:
21
+ - @typesql/core@0.1.1
22
+
3
23
  ## 0.1.0
4
24
 
5
25
  ### Minor Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @typesql/kysely
2
2
 
3
- Use the `DB` interface you already have for [Kysely](https://kysely.dev) as a typesql schema:
3
+ Use the `DB` interface you already have for [Kysely](https://kysely.dev) as a TypeSQL schema:
4
4
  the one generated by [kysely-codegen](https://github.com/RobinBlomberg/kysely-codegen), by
5
5
  [prisma-kysely](https://github.com/valtyr/prisma-kysely), or written by hand. The conversion is
6
6
  type-level only; nothing is generated and no database is contacted.
@@ -9,6 +9,8 @@ type-level only; nothing is generated and no database is contacted.
9
9
  pnpm add @typesql/core @typesql/kysely kysely
10
10
  ```
11
11
 
12
+ [Open an example in the TypeScript Playground](https://www.typescriptlang.org/play/#code/PTAEBUE8AcFMGUCKAZUB3AlgFwBagNKQDOsANpKABQACWMsRAjqcANbFmQCUAdKAJoB7AK4AnAh3KgAIgCFQGAHZZYogGYBDAMawq7EuQC0WwQBNYAc1iLQIrNGFZbogFAhQODYtOG0o7CqKXApEoLi6RFo4sAC2GgA0oF6moKIaaKBIqKLCiqGCNpAi4oQGFEpEWF46fAASggBuqmHRqQzCpFhEPC4YMdCCok4A3hJliQAKgpUWogzSGBqksFpYiXRw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IHuJhIIChOFgCcxBgXU6lppA6Uk3iZCgoCqaoGCBS4VvRTw5qh9of4FHxDu9SolAaEQkCKFoVDml1wQ8paZ5JGgUV0l1PDCNApjIuAGgBbV0xpRlsDsaMAsNWO5pqSClXVf1rws6+ojvpmhUtYkCudY7zsKcWZcQ0iKjSaQsmUJ3XBzcDy3gFLON43ToTi5LSQvjZrLRWoBua82ph9Nay9oL61AKfeuTtG4KQEoNGa80lorTWuzL++NSyqF-hLX6UsZbOkVrAneEpRDJiEqAdwqgniiE-IIJwgcGhLHXoINQ3lhyjlANYfYLggA) <!-- playground:kysely --> to hover the types and edit the SQL, with nothing to install.
13
+
12
14
  ```ts
13
15
  import { createSql } from "@typesql/kysely";
14
16
  import type { DB } from "./db"; // kysely-codegen output
@@ -58,7 +60,7 @@ const same = createCoreSql<FromKysely<DB>, PgTypeMap>(); // types only, no clien
58
60
  ```
59
61
 
60
62
  Queries are sent as `CompiledQuery.raw(q.text, q.values)` through
61
- `db.withoutPlugins().executeQuery(...)`. Plugins are bypassed on purpose: typesql's row types
63
+ `db.withoutPlugins().executeQuery(...)`. Plugins are bypassed on purpose: TypeSQL's row types
62
64
  describe what Postgres returns (`created_at`), and a result transformer such as
63
65
  `CamelCasePlugin` would rename the keys (use `{ rowKeys: "camelCase" }` for camelCase rows).
64
66
  Logging, the dialect and the connection pool are unaffected. Inside a Kysely transaction,
@@ -66,7 +68,7 @@ Logging, the dialect and the connection pool are unaffected. Inside a Kysely tra
66
68
 
67
69
  ## How columns are converted
68
70
 
69
- Kysely describes a column by its TS type; typesql needs a Postgres type name. The TS shape
71
+ Kysely describes a column by its TS type; TypeSQL needs a Postgres type name. The TS shape
70
72
  is read back as follows (for `ColumnType<S, I, U>` the select type `S` decides, the insert type
71
73
  `I` breaks ties):
72
74
 
@@ -187,7 +189,7 @@ const post = await sql("SELECT author_id, created_at FROM blog_posts WHERE id =
187
189
  `unknown` either way; only `INSERT` stops requiring the column. Override with
188
190
  `{ nullable: false }` to get the not-null check back.
189
191
  - **JSON shapes are not kept.** `JSONColumnType<{ a: number }>` becomes `jsonb`, read as
190
- `unknown` (the type map decides; typesql has no per-column TS types).
192
+ `unknown` (the type map decides; TypeSQL has no per-column TS types).
191
193
  - **Views look like tables.** Kysely interfaces do not mark views; mark them with `$view: true`
192
194
  to have writes rejected.
193
195
  - **Defaults come from `Generated`/`GeneratedAlways` only.** A column with a default that the
package/dist/client.d.ts CHANGED
@@ -2,7 +2,7 @@ import { CompiledQuery, type QueryResult } from "kysely";
2
2
  import { type Executor, type SqlDriver } from "@typesql/core";
3
3
  /**
4
4
  * What the adapter uses from a `Kysely<DB>` or `Transaction<DB>`. Queries run through
5
- * `withoutPlugins()`: typesql's row types describe what the driver returns, so result
5
+ * `withoutPlugins()`: TypeSQL's row types describe what the driver returns, so result
6
6
  * transformers such as `CamelCasePlugin` must not rename the columns (`createSql(db,
7
7
  * { rowKeys: "camelCase" })` renames the top-level keys instead, in the types too).
8
8
  */
@@ -1,7 +1,7 @@
1
1
  import type { ColDesc, PgScalarName, View } from "@typesql/core";
2
2
  /**
3
3
  * Converting a Kysely `DB` interface (kysely-codegen, prisma-kysely or hand-written) into a
4
- * typesql schema. Kysely describes columns with TS types, typesql with Postgres type names, so
4
+ * TypeSQL schema. Kysely describes columns with TS types, TypeSQL with Postgres type names, so
5
5
  * the conversion reads the TS shape back into a type name. That is lossy (`number` may be
6
6
  * `int4` or `float8`); `Overrides` pins the exact type per column.
7
7
  *
@@ -46,10 +46,10 @@ export type KyselyOptions = {
46
46
  readonly camelCase?: boolean;
47
47
  };
48
48
  /**
49
- * A typesql schema from a Kysely `DB` interface.
49
+ * A TypeSQL schema from a Kysely `DB` interface.
50
50
  *
51
51
  * type Schema = FromKysely<DB, { users: { id: "int8" } }>;
52
- * const sql = createSql<Schema>(); // typesql's createSql
52
+ * const sql = createSql<Schema>(); // TypeSQL's createSql
53
53
  *
54
54
  * `"auth.users"` becomes `Schema["auth"]["users"]`; `"public.users"` becomes `Schema["users"]`.
55
55
  * String-literal unions become enums registered in `Schema["$types"]` (see `KyselyOverrides`).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@typesql/kysely",
3
- "version": "0.1.0",
4
- "description": "Use Kysely database interfaces (kysely-codegen, prisma-kysely) as a typesql schema.",
3
+ "version": "0.1.2",
4
+ "description": "Use Kysely database interfaces (kysely-codegen, prisma-kysely) as a TypeSQL schema.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@typesql/core": "0.1.0"
31
+ "@typesql/core": "0.1.2"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "kysely": ">=0.27"
@@ -40,6 +40,24 @@
40
40
  "typescript": "7.0.2",
41
41
  "vitest": "^5.0.4"
42
42
  },
43
+ "homepage": "https://typesql.karsli.net/adapters/kysely",
44
+ "bugs": {
45
+ "url": "https://github.com/ismailkarsli/typesql/issues"
46
+ },
47
+ "author": "İsmail Karslı",
48
+ "keywords": [
49
+ "sql",
50
+ "postgres",
51
+ "postgresql",
52
+ "typescript",
53
+ "type-safe",
54
+ "type-level",
55
+ "raw-sql",
56
+ "no-codegen",
57
+ "kysely",
58
+ "kysely-codegen",
59
+ "orm"
60
+ ],
43
61
  "scripts": {
44
62
  "build": "tsc -p tsconfig.build.json",
45
63
  "typecheck": "tsc -p tsconfig.json --noEmit",
package/src/client.ts CHANGED
@@ -3,7 +3,7 @@ import { runTransaction, type Executor, type SqlDriver } from "@typesql/core";
3
3
 
4
4
  /**
5
5
  * What the adapter uses from a `Kysely<DB>` or `Transaction<DB>`. Queries run through
6
- * `withoutPlugins()`: typesql's row types describe what the driver returns, so result
6
+ * `withoutPlugins()`: TypeSQL's row types describe what the driver returns, so result
7
7
  * transformers such as `CamelCasePlugin` must not rename the columns (`createSql(db,
8
8
  * { rowKeys: "camelCase" })` renames the top-level keys instead, in the types too).
9
9
  */
@@ -2,7 +2,7 @@ import type { ColDesc, PgScalarName, View } from "@typesql/core";
2
2
 
3
3
  /**
4
4
  * Converting a Kysely `DB` interface (kysely-codegen, prisma-kysely or hand-written) into a
5
- * typesql schema. Kysely describes columns with TS types, typesql with Postgres type names, so
5
+ * TypeSQL schema. Kysely describes columns with TS types, TypeSQL with Postgres type names, so
6
6
  * the conversion reads the TS shape back into a type name. That is lossy (`number` may be
7
7
  * `int4` or `float8`); `Overrides` pins the exact type per column.
8
8
  *
@@ -48,10 +48,10 @@ export type KyselyOverrides = { readonly [table: string]: TableOverride };
48
48
  export type KyselyOptions = { readonly camelCase?: boolean };
49
49
 
50
50
  /**
51
- * A typesql schema from a Kysely `DB` interface.
51
+ * A TypeSQL schema from a Kysely `DB` interface.
52
52
  *
53
53
  * type Schema = FromKysely<DB, { users: { id: "int8" } }>;
54
- * const sql = createSql<Schema>(); // typesql's createSql
54
+ * const sql = createSql<Schema>(); // TypeSQL's createSql
55
55
  *
56
56
  * `"auth.users"` becomes `Schema["auth"]["users"]`; `"public.users"` becomes `Schema["users"]`.
57
57
  * String-literal unions become enums registered in `Schema["$types"]` (see `KyselyOverrides`).