@drzl/validation-core 3.1.0 → 3.2.0

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/index.d.cts CHANGED
@@ -239,6 +239,31 @@ interface FormatOptions {
239
239
  }
240
240
  interface ValidationGenerateOptions {
241
241
  outDir: string;
242
+ /**
243
+ * Path to the Drizzle schema module, as written in the config.
244
+ *
245
+ * Only needed by `typedJson`, which has to import the table back in order to reference the
246
+ * type Drizzle inferred for a column.
247
+ */
248
+ schemaPath?: string;
249
+ /**
250
+ * Type `json` and `jsonb` columns from the schema instead of leaving them wide.
251
+ *
252
+ * `.$type<T>()` is a compile-time cast: Drizzle's implementation is literally
253
+ * `$type() { return this }`, so the type exists only in TypeScript and nothing about it
254
+ * survives to runtime. Every runtime-derived validator is therefore blind to it, and
255
+ * `drizzle-orm/zod` types a json column as its generic `Json` no matter what you declared.
256
+ *
257
+ * A generator can do better without resolving any types itself, because Drizzle already did
258
+ * the work: `typeof users.$inferSelect['prefs']` *is* the declared type, resolved by
259
+ * TypeScript at the point of use. So the emitted schema references that rather than trying to
260
+ * reconstruct it, which is why this works for generics, unions and imported interfaces alike,
261
+ * the cases that defeat source-parsing approaches.
262
+ *
263
+ * Off by default: it makes the generated file import your schema module, and that coupling
264
+ * should be a choice rather than a surprise.
265
+ */
266
+ typedJson?: boolean;
242
267
  format?: FormatOptions;
243
268
  /**
244
269
  * What every generated file is called after the Drizzle export name, e.g. `.zod.ts`
package/dist/index.d.ts CHANGED
@@ -239,6 +239,31 @@ interface FormatOptions {
239
239
  }
240
240
  interface ValidationGenerateOptions {
241
241
  outDir: string;
242
+ /**
243
+ * Path to the Drizzle schema module, as written in the config.
244
+ *
245
+ * Only needed by `typedJson`, which has to import the table back in order to reference the
246
+ * type Drizzle inferred for a column.
247
+ */
248
+ schemaPath?: string;
249
+ /**
250
+ * Type `json` and `jsonb` columns from the schema instead of leaving them wide.
251
+ *
252
+ * `.$type<T>()` is a compile-time cast: Drizzle's implementation is literally
253
+ * `$type() { return this }`, so the type exists only in TypeScript and nothing about it
254
+ * survives to runtime. Every runtime-derived validator is therefore blind to it, and
255
+ * `drizzle-orm/zod` types a json column as its generic `Json` no matter what you declared.
256
+ *
257
+ * A generator can do better without resolving any types itself, because Drizzle already did
258
+ * the work: `typeof users.$inferSelect['prefs']` *is* the declared type, resolved by
259
+ * TypeScript at the point of use. So the emitted schema references that rather than trying to
260
+ * reconstruct it, which is why this works for generics, unions and imported interfaces alike,
261
+ * the cases that defeat source-parsing approaches.
262
+ *
263
+ * Off by default: it makes the generated file import your schema module, and that coupling
264
+ * should be a choice rather than a surprise.
265
+ */
266
+ typedJson?: boolean;
242
267
  format?: FormatOptions;
243
268
  /**
244
269
  * What every generated file is called after the Drizzle export name, e.g. `.zod.ts`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drzl/validation-core",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",