@astrojs/db 0.19.0 → 0.20.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.
@@ -1,6 +1,6 @@
1
1
  import { SQL } from "drizzle-orm";
2
2
  import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
3
- import { z } from "zod";
3
+ import * as z from "zod/v4";
4
4
  import { SERIALIZED_SQL_KEY } from "../runtime/types.js";
5
5
  import { errorMap } from "./integration/error-map.js";
6
6
  import { mapObject } from "./utils.js";
@@ -46,7 +46,7 @@ const numberColumnBaseSchema = baseColumnSchema.omit({ optional: true }).and(
46
46
  );
47
47
  const numberColumnOptsSchema = numberColumnBaseSchema.and(
48
48
  z.object({
49
- references: z.function().returns(z.lazy(() => numberColumnSchema)).optional().transform((fn) => fn?.())
49
+ references: z.function({ output: z.lazy(() => numberColumnSchema) }).optional().transform((fn) => fn?.())
50
50
  })
51
51
  );
52
52
  const numberColumnSchema = z.object({
@@ -76,7 +76,7 @@ const textColumnBaseSchema = baseColumnSchema.omit({ optional: true }).extend({
76
76
  );
77
77
  const textColumnOptsSchema = textColumnBaseSchema.and(
78
78
  z.object({
79
- references: z.function().returns(z.lazy(() => textColumnSchema)).optional().transform((fn) => fn?.())
79
+ references: z.function({ output: z.lazy(() => textColumnSchema) }).optional().transform((fn) => fn?.())
80
80
  })
81
81
  );
82
82
  const textColumnSchema = z.object({
@@ -107,16 +107,18 @@ const columnSchema = z.discriminatedUnion("type", [
107
107
  jsonColumnSchema
108
108
  ]);
109
109
  const referenceableColumnSchema = z.union([textColumnSchema, numberColumnSchema]);
110
- const columnsSchema = z.record(columnSchema);
110
+ const columnsSchema = z.record(z.string(), columnSchema);
111
111
  const foreignKeysSchema = z.object({
112
112
  columns: z.string().or(z.array(z.string())),
113
- references: z.function().returns(z.lazy(() => referenceableColumnSchema.or(z.array(referenceableColumnSchema)))).transform((fn) => fn())
113
+ references: z.function({
114
+ output: z.lazy(() => referenceableColumnSchema.or(z.array(referenceableColumnSchema)))
115
+ }).transform((fn) => fn())
114
116
  });
115
117
  const resolvedIndexSchema = z.object({
116
118
  on: z.string().or(z.array(z.string())),
117
119
  unique: z.boolean().optional()
118
120
  });
119
- const legacyIndexesSchema = z.record(resolvedIndexSchema);
121
+ const legacyIndexesSchema = z.record(z.string(), resolvedIndexSchema);
120
122
  const indexSchema = z.object({
121
123
  on: z.string().or(z.array(z.string())),
122
124
  unique: z.boolean().optional(),
@@ -129,18 +131,21 @@ const tableSchema = z.object({
129
131
  foreignKeys: z.array(foreignKeysSchema).optional(),
130
132
  deprecated: z.boolean().optional().default(false)
131
133
  });
132
- const tablesSchema = z.preprocess((rawTables) => {
133
- const tables = z.record(z.any()).parse(rawTables, { errorMap });
134
- for (const [tableName, table] of Object.entries(tables)) {
135
- table.getName = () => tableName;
136
- const { columns } = z.object({ columns: z.record(z.any()) }).parse(table, { errorMap });
137
- for (const [columnName, column] of Object.entries(columns)) {
138
- column.schema.name = columnName;
139
- column.schema.collection = tableName;
134
+ const tablesSchema = z.preprocess(
135
+ (rawTables) => {
136
+ const tables = z.record(z.string(), z.any()).parse(rawTables, { error: errorMap });
137
+ for (const [tableName, table] of Object.entries(tables)) {
138
+ table.getName = () => tableName;
139
+ const { columns } = z.object({ columns: z.record(z.string(), z.any()) }).parse(table, { error: errorMap });
140
+ for (const [columnName, column] of Object.entries(columns)) {
141
+ column.schema.name = columnName;
142
+ column.schema.collection = tableName;
143
+ }
140
144
  }
141
- }
142
- return rawTables;
143
- }, z.record(tableSchema));
145
+ return rawTables;
146
+ },
147
+ z.record(z.string(), tableSchema)
148
+ );
144
149
  const dbConfigSchema = z.object({
145
150
  tables: tablesSchema.optional()
146
151
  }).transform(({ tables = {}, ...config }) => {
@@ -1,4 +1,4 @@
1
- import type { z } from 'zod';
1
+ import type * as z from 'zod/v4';
2
2
  import type { booleanColumnSchema, columnSchema, columnsSchema, dateColumnSchema, dbConfigSchema, indexSchema, jsonColumnSchema, MaybeArray, numberColumnOptsSchema, numberColumnSchema, referenceableColumnSchema, resolvedIndexSchema, tableSchema, textColumnOptsSchema, textColumnSchema } from './schemas.js';
3
3
  export type ResolvedIndexes = z.output<typeof dbConfigSchema>['tables'][string]['indexes'];
4
4
  export type BooleanColumn = z.infer<typeof booleanColumnSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/db",
3
- "version": "0.19.0",
3
+ "version": "0.20.1",
4
4
  "description": "Add libSQL support to your Astro site",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -63,24 +63,22 @@
63
63
  "astro-integration"
64
64
  ],
65
65
  "dependencies": {
66
+ "@clack/prompts": "^1.0.1",
66
67
  "@libsql/client": "^0.17.0",
67
- "deep-diff": "^1.0.2",
68
68
  "drizzle-orm": "^0.42.0",
69
+ "microdiff": "^1.5.0",
69
70
  "nanoid": "^5.1.6",
70
71
  "piccolore": "^0.1.3",
71
- "prompts": "^2.4.2",
72
- "yargs-parser": "^21.1.1",
73
- "zod": "^3.25.76"
72
+ "yargs-parser": "^22.0.0",
73
+ "zod": "^4.3.6"
74
74
  },
75
75
  "devDependencies": {
76
- "@types/deep-diff": "^1.0.5",
77
- "@types/prompts": "^2.4.9",
78
76
  "@types/yargs-parser": "^21.0.3",
79
- "cheerio": "1.1.2",
77
+ "cheerio": "1.2.0",
80
78
  "expect-type": "^1.3.0",
81
79
  "typescript": "^5.9.3",
82
- "vite": "^6.4.1",
83
- "astro": "5.16.13",
80
+ "vite": "^7.3.1",
81
+ "astro": "6.0.6",
84
82
  "astro-scripts": "0.0.14"
85
83
  },
86
84
  "scripts": {