@astrojs/db 0.17.0 → 0.17.1

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.
@@ -2,8 +2,8 @@ import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
2
2
  import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
3
3
  import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
4
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 [string, ...string[]] | never> = SQLiteColumn<T & {
6
- data: E extends infer EnumValues ? EnumValues extends [string, ...string[]] ? EnumValues[number] : never : string;
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
7
  dataType: 'string';
8
8
  columnType: 'SQLiteText';
9
9
  driverParam: string;
@@ -57,15 +57,15 @@ type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
57
57
  identity: undefined;
58
58
  generated: undefined;
59
59
  }>;
60
- type Column<T extends DBColumn['type'], E extends [string, ...string[]] | never, 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;
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
61
  export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
62
62
  name: TTableName;
63
63
  schema: undefined;
64
64
  dialect: 'sqlite';
65
65
  columns: {
66
66
  [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
67
- enum: [string, ...string[]];
68
- } ? TColumns[K]['schema']['enum'] : never, {
67
+ enum: infer E;
68
+ } ? E extends readonly [string, ...string[]] ? E : string : string, {
69
69
  tableName: TTableName;
70
70
  name: K;
71
71
  isPrimaryKey: TColumns[K]['schema'] extends {
@@ -14,12 +14,12 @@ export declare const column: {
14
14
  */
15
15
  schema: T;
16
16
  };
17
- text: <T extends TextColumnOpts>(opts?: T) => {
17
+ text: <T extends TextColumnOpts, const E extends T["enum"] extends readonly [string, ...string[]] ? Omit<T, "enum"> & T["enum"] : T>(opts?: E) => {
18
18
  type: "text";
19
19
  /**
20
20
  * @internal
21
21
  */
22
- schema: T;
22
+ schema: E;
23
23
  };
24
24
  date<T extends DateColumnInput["schema"]>(opts?: T): {
25
25
  type: "date";
@@ -27,7 +27,7 @@ function printHelp({
27
27
  message.push(
28
28
  linebreak(),
29
29
  ` ${bgGreen(black(` ${commandName} `))} ${green(
30
- `v${"0.17.0"}`
30
+ `v${"0.17.1"}`
31
31
  )} ${headline}`
32
32
  );
33
33
  }
@@ -2,8 +2,8 @@ import type { ColumnBaseConfig, ColumnDataType } from 'drizzle-orm';
2
2
  import type { SQLiteColumn, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
3
3
  import type { ColumnsConfig, DBColumn, OutputColumnsConfig } from '../core/types.js';
4
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 [string, ...string[]] | never> = SQLiteColumn<T & {
6
- data: E extends infer EnumValues ? EnumValues extends [string, ...string[]] ? EnumValues[number] : never : string;
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
7
  dataType: 'string';
8
8
  columnType: 'SQLiteText';
9
9
  driverParam: string;
@@ -57,15 +57,15 @@ type AstroJson<T extends GeneratedConfig<'custom'>> = SQLiteColumn<T & {
57
57
  identity: undefined;
58
58
  generated: undefined;
59
59
  }>;
60
- type Column<T extends DBColumn['type'], E extends [string, ...string[]] | never, 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;
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
61
  export type Table<TTableName extends string, TColumns extends OutputColumnsConfig | ColumnsConfig> = SQLiteTableWithColumns<{
62
62
  name: TTableName;
63
63
  schema: undefined;
64
64
  dialect: 'sqlite';
65
65
  columns: {
66
66
  [K in Extract<keyof TColumns, string>]: Column<TColumns[K]['type'], TColumns[K]['schema'] extends {
67
- enum: [string, ...string[]];
68
- } ? TColumns[K]['schema']['enum'] : never, {
67
+ enum: infer E;
68
+ } ? E extends readonly [string, ...string[]] ? E : string : string, {
69
69
  tableName: TTableName;
70
70
  name: K;
71
71
  isPrimaryKey: TColumns[K]['schema'] extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Add libSQL support to your Astro site",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -76,16 +76,19 @@
76
76
  "@types/prompts": "^2.4.9",
77
77
  "@types/yargs-parser": "^21.0.3",
78
78
  "cheerio": "1.0.0",
79
+ "expect-type": "^1.2.0",
79
80
  "typescript": "^5.8.3",
80
81
  "vite": "^6.3.4",
81
- "astro-scripts": "0.0.14",
82
- "astro": "5.12.9"
82
+ "astro": "5.12.9",
83
+ "astro-scripts": "0.0.14"
83
84
  },
84
85
  "scripts": {
85
86
  "types:virtual": "tsc -p ./tsconfig.virtual.json",
86
87
  "build": "astro-scripts build \"src/**/*.ts\" && tsc && pnpm types:virtual",
87
88
  "build:ci": "astro-scripts build \"src/**/*.ts\"",
88
89
  "dev": "astro-scripts dev \"src/**/*.ts\"",
89
- "test": "astro-scripts test \"test/**/*.test.js\""
90
+ "test": "pnpm run test:integration && pnpm run test:types",
91
+ "test:integration": "astro-scripts test \"test/**/*.test.js\"",
92
+ "test:types": "tsc --project test/types/tsconfig.json"
90
93
  }
91
94
  }