@flowblade/sqlduck 0.31.0 → 0.33.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.
@@ -1,5 +1,4 @@
1
1
  import { Logger } from "@logtape/logtape";
2
-
3
2
  //#region src/filesystem/file-system-utils.d.ts
4
3
  declare class FileSystemUtils {
5
4
  #private;
@@ -0,0 +1,261 @@
1
+ import * as z from "zod";
2
+ //#region src/validation/zod/duck-connection-params-zod-schema.d.ts
3
+ declare const duckAllConnectionOptionsZodSchema: z.ZodObject<{
4
+ accessMode: z.ZodOptional<z.ZodEnum<{
5
+ READ_ONLY: "READ_ONLY";
6
+ READ_WRITE: "READ_WRITE";
7
+ }>>;
8
+ compress: z.ZodOptional<z.ZodBoolean>;
9
+ type: z.ZodOptional<z.ZodEnum<{
10
+ DUCKDB: "DUCKDB";
11
+ SQLITE: "SQLITE";
12
+ MYSQL: "MYSQL";
13
+ PostgreSQL: "PostgreSQL";
14
+ }>>;
15
+ blockSize: z.ZodOptional<z.ZodInt32>;
16
+ rowGroupSize: z.ZodOptional<z.ZodInt32>;
17
+ storageVersion: z.ZodOptional<z.ZodString>;
18
+ encryptionKey: z.ZodOptional<z.ZodString>;
19
+ encryptionCipher: z.ZodOptional<z.ZodEnum<{
20
+ CBC: "CBC";
21
+ CTR: "CTR";
22
+ GCM: "GCM";
23
+ }>>;
24
+ recoveryMode: z.ZodOptional<z.ZodEnum<{
25
+ no_wal_writes: "no_wal_writes";
26
+ }>>;
27
+ }, z.core.$strict>;
28
+ declare const duckConnectionParamsZodSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ type: z.ZodLiteral<"memory">;
30
+ alias: z.ZodString;
31
+ options: z.ZodOptional<z.ZodObject<{
32
+ accessMode: z.ZodOptional<z.ZodEnum<{
33
+ READ_ONLY: "READ_ONLY";
34
+ READ_WRITE: "READ_WRITE";
35
+ }>>;
36
+ compress: z.ZodOptional<z.ZodBoolean>;
37
+ type: z.ZodOptional<z.ZodEnum<{
38
+ DUCKDB: "DUCKDB";
39
+ SQLITE: "SQLITE";
40
+ MYSQL: "MYSQL";
41
+ PostgreSQL: "PostgreSQL";
42
+ }>>;
43
+ blockSize: z.ZodOptional<z.ZodInt32>;
44
+ rowGroupSize: z.ZodOptional<z.ZodInt32>;
45
+ storageVersion: z.ZodOptional<z.ZodString>;
46
+ encryptionKey: z.ZodOptional<z.ZodString>;
47
+ encryptionCipher: z.ZodOptional<z.ZodEnum<{
48
+ CBC: "CBC";
49
+ CTR: "CTR";
50
+ GCM: "GCM";
51
+ }>>;
52
+ recoveryMode: z.ZodOptional<z.ZodEnum<{
53
+ no_wal_writes: "no_wal_writes";
54
+ }>>;
55
+ }, z.core.$strict>>;
56
+ }, z.core.$strict>, z.ZodObject<{
57
+ type: z.ZodLiteral<"filesystem">;
58
+ path: z.ZodString;
59
+ alias: z.ZodString;
60
+ options: z.ZodOptional<z.ZodObject<{
61
+ accessMode: z.ZodOptional<z.ZodEnum<{
62
+ READ_ONLY: "READ_ONLY";
63
+ READ_WRITE: "READ_WRITE";
64
+ }>>;
65
+ compress: z.ZodOptional<z.ZodBoolean>;
66
+ type: z.ZodOptional<z.ZodEnum<{
67
+ DUCKDB: "DUCKDB";
68
+ SQLITE: "SQLITE";
69
+ MYSQL: "MYSQL";
70
+ PostgreSQL: "PostgreSQL";
71
+ }>>;
72
+ blockSize: z.ZodOptional<z.ZodInt32>;
73
+ rowGroupSize: z.ZodOptional<z.ZodInt32>;
74
+ storageVersion: z.ZodOptional<z.ZodString>;
75
+ encryptionKey: z.ZodOptional<z.ZodString>;
76
+ encryptionCipher: z.ZodOptional<z.ZodEnum<{
77
+ CBC: "CBC";
78
+ CTR: "CTR";
79
+ GCM: "GCM";
80
+ }>>;
81
+ recoveryMode: z.ZodOptional<z.ZodEnum<{
82
+ no_wal_writes: "no_wal_writes";
83
+ }>>;
84
+ }, z.core.$strict>>;
85
+ }, z.core.$strict>], "type">;
86
+ type DuckConnectionParamsZodSchema = z.infer<typeof duckConnectionParamsZodSchema>;
87
+ //#endregion
88
+ //#region src/validation/core/types.d.ts
89
+ type DuckAliasName = string;
90
+ type DuckTableName = string;
91
+ type DuckSchemaName = string;
92
+ type DuckConnectionParams = DuckConnectionParamsZodSchema;
93
+ //#endregion
94
+ //#region src/validation/zod/duck-asserts-zod.d.ts
95
+ declare function assertValidAliasName(aliasName: string): asserts aliasName is DuckAliasName;
96
+ declare function assertValidSchemaName(schemaName: string): asserts schemaName is DuckSchemaName;
97
+ declare function assertValidTableName(tableName: string): asserts tableName is DuckTableName;
98
+ //#endregion
99
+ //#region src/validation/zod/duck-dsn-zod-schema.d.ts
100
+ declare const duckDsnZodSchema: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<{
101
+ type: "memory";
102
+ alias: string;
103
+ options?: {
104
+ accessMode?: "READ_ONLY" | "READ_WRITE" | undefined;
105
+ compress?: boolean | undefined;
106
+ type?: "DUCKDB" | "SQLITE" | "MYSQL" | "PostgreSQL" | undefined;
107
+ blockSize?: number | undefined;
108
+ rowGroupSize?: number | undefined;
109
+ storageVersion?: string | undefined;
110
+ encryptionKey?: string | undefined;
111
+ encryptionCipher?: "CBC" | "CTR" | "GCM" | undefined;
112
+ recoveryMode?: "no_wal_writes" | undefined;
113
+ } | undefined;
114
+ } | {
115
+ type: "filesystem";
116
+ path: string;
117
+ alias: string;
118
+ options?: {
119
+ accessMode?: "READ_ONLY" | "READ_WRITE" | undefined;
120
+ compress?: boolean | undefined;
121
+ type?: "DUCKDB" | "SQLITE" | "MYSQL" | "PostgreSQL" | undefined;
122
+ blockSize?: number | undefined;
123
+ rowGroupSize?: number | undefined;
124
+ storageVersion?: string | undefined;
125
+ encryptionKey?: string | undefined;
126
+ encryptionCipher?: "CBC" | "CTR" | "GCM" | undefined;
127
+ recoveryMode?: "no_wal_writes" | undefined;
128
+ } | undefined;
129
+ }, string>>, z.ZodDiscriminatedUnion<[z.ZodObject<{
130
+ type: z.ZodLiteral<"memory">;
131
+ alias: z.ZodString;
132
+ options: z.ZodOptional<z.ZodObject<{
133
+ accessMode: z.ZodOptional<z.ZodEnum<{
134
+ READ_ONLY: "READ_ONLY";
135
+ READ_WRITE: "READ_WRITE";
136
+ }>>;
137
+ compress: z.ZodOptional<z.ZodBoolean>;
138
+ type: z.ZodOptional<z.ZodEnum<{
139
+ DUCKDB: "DUCKDB";
140
+ SQLITE: "SQLITE";
141
+ MYSQL: "MYSQL";
142
+ PostgreSQL: "PostgreSQL";
143
+ }>>;
144
+ blockSize: z.ZodOptional<z.ZodInt32>;
145
+ rowGroupSize: z.ZodOptional<z.ZodInt32>;
146
+ storageVersion: z.ZodOptional<z.ZodString>;
147
+ encryptionKey: z.ZodOptional<z.ZodString>;
148
+ encryptionCipher: z.ZodOptional<z.ZodEnum<{
149
+ CBC: "CBC";
150
+ CTR: "CTR";
151
+ GCM: "GCM";
152
+ }>>;
153
+ recoveryMode: z.ZodOptional<z.ZodEnum<{
154
+ no_wal_writes: "no_wal_writes";
155
+ }>>;
156
+ }, z.core.$strict>>;
157
+ }, z.core.$strict>, z.ZodObject<{
158
+ type: z.ZodLiteral<"filesystem">;
159
+ path: z.ZodString;
160
+ alias: z.ZodString;
161
+ options: z.ZodOptional<z.ZodObject<{
162
+ accessMode: z.ZodOptional<z.ZodEnum<{
163
+ READ_ONLY: "READ_ONLY";
164
+ READ_WRITE: "READ_WRITE";
165
+ }>>;
166
+ compress: z.ZodOptional<z.ZodBoolean>;
167
+ type: z.ZodOptional<z.ZodEnum<{
168
+ DUCKDB: "DUCKDB";
169
+ SQLITE: "SQLITE";
170
+ MYSQL: "MYSQL";
171
+ PostgreSQL: "PostgreSQL";
172
+ }>>;
173
+ blockSize: z.ZodOptional<z.ZodInt32>;
174
+ rowGroupSize: z.ZodOptional<z.ZodInt32>;
175
+ storageVersion: z.ZodOptional<z.ZodString>;
176
+ encryptionKey: z.ZodOptional<z.ZodString>;
177
+ encryptionCipher: z.ZodOptional<z.ZodEnum<{
178
+ CBC: "CBC";
179
+ CTR: "CTR";
180
+ GCM: "GCM";
181
+ }>>;
182
+ recoveryMode: z.ZodOptional<z.ZodEnum<{
183
+ no_wal_writes: "no_wal_writes";
184
+ }>>;
185
+ }, z.core.$strict>>;
186
+ }, z.core.$strict>], "type">>;
187
+ //#endregion
188
+ //#region src/validation/zod/duck-validators-zod.d.ts
189
+ /**
190
+ * Common validators for duckdb parameters, tables...
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * import { duckValidatorsZod } from '@flowblade/sqlduck/zod';
195
+ *
196
+ * duckValidatorsZod.tableName.parse('my_table'); // valid
197
+ * duckValidatorsZod.tableName.parse('my table'); // invalid
198
+ * ```
199
+ */
200
+ declare const duckValidatorsZod: {
201
+ /**
202
+ * Validate duckdb objects names like table, alias, and schemas
203
+ * for validity.
204
+ */
205
+ readonly aliasName: import("zod").ZodString;
206
+ readonly schemaName: import("zod").ZodString;
207
+ readonly tableName: import("zod").ZodString;
208
+ };
209
+ //#endregion
210
+ //#region src/validation/zod/ensure-zod-table-schema.d.ts
211
+ type TObject = Record<string, string | number | null | undefined | boolean | Date>;
212
+ declare const EXPLICIT_GENERIC_REQUIRED: unique symbol;
213
+ type RequireExplicitGeneric = TObject & {
214
+ [EXPLICIT_GENERIC_REQUIRED]: never;
215
+ };
216
+ /**
217
+ * Helper to ensure a zod table schema is compatible with the provided type definition
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * import { ensureZodTableSchema } from '@flowblade/sqlduck/zod';
222
+ *
223
+ * type Row = {
224
+ * aNumber: number;
225
+ * aString: string;
226
+ * aNullableNumber: number | null;
227
+ * aNullableString: string | null;
228
+ * aBoolean: boolean;
229
+ * aNullableBoolean: boolean | null;
230
+ * aDate: Date;
231
+ * aNullableDate: Date | null;
232
+ * };
233
+ *
234
+ * const schema = ensureZodTableSchema<Row>(z.strictObject({
235
+ * aNumber: z.number(),
236
+ * aString: z.string(),
237
+ * aNullableNumber: z.nullable(z.number()),
238
+ * aNullableString: z.nullable(z.string()),
239
+ * aBoolean: z.boolean(),
240
+ * aNullableBoolean: z.nullable(z.boolean()),
241
+ * aDate: z.date(),
242
+ * aNullableDate: z.nullable(z.date()),
243
+ * }));
244
+ *
245
+ * ```
246
+ */
247
+ declare const ensureZodTableSchema: <T extends TObject = RequireExplicitGeneric>(schema: z.ZodObject<{ [K in keyof NoInfer<T>]-?: z.ZodType<NoInfer<T>[K]>; }>) => z.ZodObject<{ [K in keyof NoInfer<T>]-?: z.ZodType<NoInfer<T>[K], unknown, z.core.$ZodTypeInternals<NoInfer<T>[K], unknown>>; }, z.core.$strip>;
248
+ //#endregion
249
+ //#region src/validation/zod/infer-zod-relaxed-data-schema.d.ts
250
+ type MapRelaxedZodSchemaField<T extends z.ZodTypeAny> = T extends z.ZodDate ? string | Date : T extends z.ZodISODate ? string | Date : T extends z.ZodOptional<any> ? MapRelaxedZodSchemaField<T['_def']['innerType']> | undefined : T extends z.ZodNullable<any> ? MapRelaxedZodSchemaField<T['_def']['innerType']> | null : z.infer<T>;
251
+ /**
252
+ * Add string type to all Date properties so it makes it an union between
253
+ * Date | string
254
+ */
255
+ type InferZodRelaxedDataSchema<T extends z.ZodObject<any>> = { [K in keyof T['shape']]: MapRelaxedZodSchemaField<T['shape'][K]>; };
256
+ //#endregion
257
+ //#region src/validation/zod/table-schema-zod.d.ts
258
+ type ZodSchemaSupportedTypes = z.ZodString | z.ZodNumber | z.ZodInt | z.ZodInt32 | z.ZodUInt32 | z.ZodBigInt | z.ZodBoolean | z.ZodDate | z.ZodISODateTime | z.ZodISOTime | z.ZodISODate | z.ZodEmail | z.ZodURL | z.ZodUUID | z.ZodCUID | z.ZodCUID2 | z.ZodULID | z.ZodEnum;
259
+ type TableSchemaZod = z.ZodObject<Record<string, ZodSchemaSupportedTypes | z.ZodNullable<ZodSchemaSupportedTypes> | z.ZodCodec | z.ZodNullable<z.ZodCodec>>>;
260
+ //#endregion
261
+ export { duckDsnZodSchema as a, assertValidTableName as c, duckConnectionParamsZodSchema as d, duckValidatorsZod as i, DuckConnectionParams as l, InferZodRelaxedDataSchema as n, assertValidAliasName as o, ensureZodTableSchema as r, assertValidSchemaName as s, TableSchemaZod as t, duckAllConnectionOptionsZodSchema as u };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
- import { n as DuckConnectionParams } from "./types-BKI2f-Rk.mjs";
1
+ import { l as DuckConnectionParams, n as InferZodRelaxedDataSchema, t as TableSchemaZod } from "./index-BKsJVkXZ.mjs";
2
2
  import { DuckDBConnection, DuckDBType } from "@duckdb/node-api";
3
3
  import { Logger } from "@logtape/logtape";
4
4
  import * as z from "zod";
5
5
  import { ZodObject } from "zod";
6
-
7
6
  //#region src/appender/data-appender-callback.d.ts
8
7
  type OnChunkAppendedStats = {
9
8
  /**
@@ -78,10 +77,6 @@ declare class Table {
78
77
  withSchema: (schema: string) => Table;
79
78
  }
80
79
  //#endregion
81
- //#region src/table/table-schema-zod.type.d.ts
82
- type ZodSchemaSupportedTypes = z.ZodString | z.ZodNumber | z.ZodInt | z.ZodInt32 | z.ZodUInt32 | z.ZodBigInt | z.ZodBoolean | z.ZodDate | z.ZodISODateTime | z.ZodISOTime | z.ZodISODate | z.ZodEmail | z.ZodURL | z.ZodUUID | z.ZodCUID | z.ZodCUID2 | z.ZodULID | z.ZodEnum;
83
- type TableSchemaZod = z.ZodObject<Record<string, ZodSchemaSupportedTypes | z.ZodNullable<ZodSchemaSupportedTypes> | z.ZodCodec | z.ZodNullable<z.ZodCodec>>>;
84
- //#endregion
85
80
  //#region src/table/get-table-create-from-zod.d.ts
86
81
  type TableCreateOptions = {
87
82
  create?: 'CREATE' | 'CREATE_OR_REPLACE' | 'IF_NOT_EXISTS';
@@ -124,7 +119,7 @@ type ToTableParams<TSchema extends TableSchemaZod> = {
124
119
  * An iterable (async or sync) or generator that yields rows to be inserted.
125
120
  * Each row must match the structure defined in the `schema`.
126
121
  */
127
- rowStream: RowStream<z.infer<TSchema>>;
122
+ rowStream: RowStream<InferZodRelaxedDataSchema<TSchema>>;
128
123
  /**
129
124
  * The number of rows to accumulate before appending them to the DuckDB table as a single data chunk.
130
125
  * Tuning this value can impact memory usage and insertion performance.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as sqlduckDefaultLogtapeLogger, r as flowbladeLogtapeSqlduckConfig, t as FileSystemUtils } from "./file-system-utils-DT6smf4C.mjs";
2
2
  import { t as duckReservedKeywords } from "./duck-reserved-keywords-BzYA7jvN.mjs";
3
3
  import { c as duckValidatorsZod, r as assertValidAliasName, s as duckConnectionParamsZodSchema } from "./zod-DB5FHzXW.mjs";
4
- import { BIGINT, BOOLEAN, DATE, DECIMAL, DOUBLE, DuckDBDataChunk, DuckDBDecimalType, DuckDBDecimalValue, DuckDBInstanceCache, DuckDBTimestampMillisecondsValue, DuckDBTypeId, ENUM, FLOAT, HUGEINT, INTEGER, SMALLINT, TIMESTAMP, TIMESTAMP_MS, TINYINT, UBIGINT, UHUGEINT, UINTEGER, USMALLINT, UTINYINT, UUID, VARCHAR } from "@duckdb/node-api";
4
+ import { BIGINT, BOOLEAN, DATE, DECIMAL, DOUBLE, DuckDBDataChunk, DuckDBDateValue, DuckDBDecimalType, DuckDBDecimalValue, DuckDBInstanceCache, DuckDBTimestampMillisecondsValue, DuckDBTypeId, ENUM, FLOAT, HUGEINT, INTEGER, SMALLINT, TIMESTAMP, TIMESTAMP_MS, TINYINT, UBIGINT, UHUGEINT, UINTEGER, USMALLINT, UTINYINT, UUID, VARCHAR } from "@duckdb/node-api";
5
5
  import * as z from "zod";
6
6
  import { assertNever } from "@httpx/assert";
7
7
  import { isPlainObject } from "@httpx/plain-object";
@@ -127,6 +127,7 @@ const createOnChunkAppendedCollector = () => {
127
127
  //#region src/converter/duck-value-converter.ts
128
128
  const stringTimestampRegexp = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d{3,6})?Z?$/i;
129
129
  const dateRegexp = /^\d{4}-\d{2}-\d{2}$/;
130
+ const msInDay = 864e5;
130
131
  const createDuckValueConverterTypeError = (params) => {
131
132
  let serializableValue;
132
133
  try {
@@ -137,6 +138,10 @@ const createDuckValueConverterTypeError = (params) => {
137
138
  return /* @__PURE__ */ new TypeError(`[DuckValueConverter.${params.method}]: Unsupported type ${typeof params.value} with value ${serializableValue}`);
138
139
  };
139
140
  var DuckValueConverter = class {
141
+ /**
142
+ *
143
+ * @param value
144
+ */
140
145
  toUUID = (value) => {
141
146
  if (typeof value === "bigint") return value;
142
147
  else if (typeof value === "string") return BigInt("0x" + value.replaceAll("-", ""));
@@ -158,7 +163,24 @@ var DuckValueConverter = class {
158
163
  if (value === void 0 || value === null) return null;
159
164
  if (typeof value === "number") return DuckDBDecimalValue.fromDouble(value, width, scale);
160
165
  if (typeof value === "bigint") return new DuckDBDecimalValue(value, width, scale);
161
- throw new TypeError("Decimal converter require value to be a number or a bigint");
166
+ throw createDuckValueConverterTypeError({
167
+ method: "createDecimalConverter",
168
+ value
169
+ });
170
+ };
171
+ toDate = (value) => {
172
+ if (value === null || value === void 0) return null;
173
+ let dateInMs = null;
174
+ if (typeof value === "string" && value.length >= 10 && value.length < 30) {
175
+ const dateStr = value.slice(0, 10);
176
+ const utcDate = /* @__PURE__ */ new Date(`${dateStr}T00:00:00Z`);
177
+ dateInMs = Math.floor(utcDate.getTime());
178
+ } else if (value instanceof Date) dateInMs = Math.floor(value.getTime());
179
+ if (dateInMs !== null && !Number.isNaN(dateInMs)) return new DuckDBDateValue(Math.floor(dateInMs / msInDay));
180
+ throw createDuckValueConverterTypeError({
181
+ method: "toDate",
182
+ value
183
+ });
162
184
  };
163
185
  toBigIntString = (value) => {
164
186
  if (typeof value === "string") return value;
@@ -233,6 +255,9 @@ const createDuckColumnConverters = (duckTypes) => {
233
255
  case DuckDBTypeId.DECIMAL:
234
256
  conv = converter.createDecimalConverter(18, 3);
235
257
  break;
258
+ case DuckDBTypeId.DATE:
259
+ conv = converter.toDate;
260
+ break;
236
261
  default: throw new Error(`Unsupported duck type ${duckTypeId} / ${duckType.toString()} for column '${key}'`);
237
262
  }
238
263
  if (conv !== false) convMap[key] = conv;
@@ -347,10 +372,7 @@ var DuckDatabaseAttachCommand = class {
347
372
  case "encryptionKey":
348
373
  options.push(`ENCRYPTION_KEY '${value}'`);
349
374
  break;
350
- case "recoveryMode":
351
- options.push(`RECOVERY_MODE '${value}'`);
352
- break;
353
- default:
375
+ case "recoveryMode": options.push(`RECOVERY_MODE '${value}'`);
354
376
  }
355
377
  if (options.length > 0) parts.push(`(${options.join(", ")})`);
356
378
  return parts.filter(Boolean).join(" ");
@@ -551,7 +573,10 @@ const getScale = (value) => {
551
573
  const getDuckdbNumberColumnType = (params) => {
552
574
  const { minimum, maximum, multipleOf } = params;
553
575
  if (minimum === void 0 || maximum === void 0) return BIGINT;
554
- if (multipleOf !== void 0 && isFloatValue(multipleOf)) return DECIMAL(18, getScale(multipleOf));
576
+ if (multipleOf !== void 0 && isFloatValue(multipleOf)) {
577
+ const scale = getScale(multipleOf);
578
+ return DECIMAL(18, scale);
579
+ }
555
580
  if (isFloatValue(minimum) || isFloatValue(maximum)) {
556
581
  if (minimum >= -34028235e31 && maximum <= 34028235e31) return FLOAT;
557
582
  return DOUBLE;
@@ -611,6 +636,9 @@ const getTableCreateFromZod = (params) => {
611
636
  case "string":
612
637
  if (Array.isArray(def.enum)) c.duckdbType = ENUM(def.enum);
613
638
  else switch (format) {
639
+ case "date":
640
+ c.duckdbType = DATE;
641
+ break;
614
642
  case "date-time":
615
643
  c.duckdbType = TIMESTAMP_MS;
616
644
  break;
@@ -1,5 +1,4 @@
1
1
  import { Kysely, SelectQueryBuilder } from "kysely";
2
-
3
2
  //#region src/integrations/kysely/compile-duck-query.d.ts
4
3
  type SqlTagInformation = {
5
4
  text: string;
@@ -1,5 +1,4 @@
1
1
  import * as v from "valibot";
2
-
3
2
  //#region src/validation/valibot/duck-connection-params-valibot-schema.d.ts
4
3
  declare const duckAllConnectionOptionsValibotSchema: v.ObjectSchema<{
5
4
  readonly accessMode: v.OptionalSchema<v.PicklistSchema<readonly ["READ_ONLY", "READ_WRITE"], undefined>, undefined>;
@@ -1,159 +1,2 @@
1
- import { a as duckAllConnectionOptionsZodSchema, i as DuckTableName, o as duckConnectionParamsZodSchema, r as DuckSchemaName, t as DuckAliasName } from "../../types-BKI2f-Rk.mjs";
2
- import * as z from "zod";
3
-
4
- //#region src/validation/zod/duck-asserts-zod.d.ts
5
- declare function assertValidAliasName(aliasName: string): asserts aliasName is DuckAliasName;
6
- declare function assertValidSchemaName(schemaName: string): asserts schemaName is DuckSchemaName;
7
- declare function assertValidTableName(tableName: string): asserts tableName is DuckTableName;
8
- //#endregion
9
- //#region src/validation/zod/duck-dsn-zod-schema.d.ts
10
- declare const duckDsnZodSchema: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<{
11
- type: "memory";
12
- alias: string;
13
- options?: {
14
- accessMode?: "READ_ONLY" | "READ_WRITE" | undefined;
15
- compress?: boolean | undefined;
16
- type?: "DUCKDB" | "SQLITE" | "MYSQL" | "PostgreSQL" | undefined;
17
- blockSize?: number | undefined;
18
- rowGroupSize?: number | undefined;
19
- storageVersion?: string | undefined;
20
- encryptionKey?: string | undefined;
21
- encryptionCipher?: "CBC" | "CTR" | "GCM" | undefined;
22
- recoveryMode?: "no_wal_writes" | undefined;
23
- } | undefined;
24
- } | {
25
- type: "filesystem";
26
- path: string;
27
- alias: string;
28
- options?: {
29
- accessMode?: "READ_ONLY" | "READ_WRITE" | undefined;
30
- compress?: boolean | undefined;
31
- type?: "DUCKDB" | "SQLITE" | "MYSQL" | "PostgreSQL" | undefined;
32
- blockSize?: number | undefined;
33
- rowGroupSize?: number | undefined;
34
- storageVersion?: string | undefined;
35
- encryptionKey?: string | undefined;
36
- encryptionCipher?: "CBC" | "CTR" | "GCM" | undefined;
37
- recoveryMode?: "no_wal_writes" | undefined;
38
- } | undefined;
39
- }, string>>, z.ZodDiscriminatedUnion<[z.ZodObject<{
40
- type: z.ZodLiteral<"memory">;
41
- alias: z.ZodString;
42
- options: z.ZodOptional<z.ZodObject<{
43
- accessMode: z.ZodOptional<z.ZodEnum<{
44
- READ_ONLY: "READ_ONLY";
45
- READ_WRITE: "READ_WRITE";
46
- }>>;
47
- compress: z.ZodOptional<z.ZodBoolean>;
48
- type: z.ZodOptional<z.ZodEnum<{
49
- DUCKDB: "DUCKDB";
50
- SQLITE: "SQLITE";
51
- MYSQL: "MYSQL";
52
- PostgreSQL: "PostgreSQL";
53
- }>>;
54
- blockSize: z.ZodOptional<z.ZodInt32>;
55
- rowGroupSize: z.ZodOptional<z.ZodInt32>;
56
- storageVersion: z.ZodOptional<z.ZodString>;
57
- encryptionKey: z.ZodOptional<z.ZodString>;
58
- encryptionCipher: z.ZodOptional<z.ZodEnum<{
59
- CBC: "CBC";
60
- CTR: "CTR";
61
- GCM: "GCM";
62
- }>>;
63
- recoveryMode: z.ZodOptional<z.ZodEnum<{
64
- no_wal_writes: "no_wal_writes";
65
- }>>;
66
- }, z.core.$strict>>;
67
- }, z.core.$strict>, z.ZodObject<{
68
- type: z.ZodLiteral<"filesystem">;
69
- path: z.ZodString;
70
- alias: z.ZodString;
71
- options: z.ZodOptional<z.ZodObject<{
72
- accessMode: z.ZodOptional<z.ZodEnum<{
73
- READ_ONLY: "READ_ONLY";
74
- READ_WRITE: "READ_WRITE";
75
- }>>;
76
- compress: z.ZodOptional<z.ZodBoolean>;
77
- type: z.ZodOptional<z.ZodEnum<{
78
- DUCKDB: "DUCKDB";
79
- SQLITE: "SQLITE";
80
- MYSQL: "MYSQL";
81
- PostgreSQL: "PostgreSQL";
82
- }>>;
83
- blockSize: z.ZodOptional<z.ZodInt32>;
84
- rowGroupSize: z.ZodOptional<z.ZodInt32>;
85
- storageVersion: z.ZodOptional<z.ZodString>;
86
- encryptionKey: z.ZodOptional<z.ZodString>;
87
- encryptionCipher: z.ZodOptional<z.ZodEnum<{
88
- CBC: "CBC";
89
- CTR: "CTR";
90
- GCM: "GCM";
91
- }>>;
92
- recoveryMode: z.ZodOptional<z.ZodEnum<{
93
- no_wal_writes: "no_wal_writes";
94
- }>>;
95
- }, z.core.$strict>>;
96
- }, z.core.$strict>], "type">>;
97
- //#endregion
98
- //#region src/validation/zod/duck-validators-zod.d.ts
99
- /**
100
- * Common validators for duckdb parameters, tables...
101
- *
102
- * @example
103
- * ```typescript
104
- * import { duckValidatorsZod } from '@flowblade/sqlduck/zod';
105
- *
106
- * duckValidatorsZod.tableName.parse('my_table'); // valid
107
- * duckValidatorsZod.tableName.parse('my table'); // invalid
108
- * ```
109
- */
110
- declare const duckValidatorsZod: {
111
- /**
112
- * Validate duckdb objects names like table, alias, and schemas
113
- * for validity.
114
- */
115
- readonly aliasName: import("zod").ZodString;
116
- readonly schemaName: import("zod").ZodString;
117
- readonly tableName: import("zod").ZodString;
118
- };
119
- //#endregion
120
- //#region src/validation/zod/ensure-zod-table-schema.d.ts
121
- type TObject = Record<string, string | number | null | undefined | boolean | Date>;
122
- declare const EXPLICIT_GENERIC_REQUIRED: unique symbol;
123
- type RequireExplicitGeneric = TObject & {
124
- [EXPLICIT_GENERIC_REQUIRED]: never;
125
- };
126
- /**
127
- * Helper to ensure a zod table schema is compatible with the provided type definition
128
- *
129
- * @example
130
- * ```typescript
131
- * import { ensureZodTableSchema } from '@flowblade/sqlduck/zod';
132
- *
133
- * type Row = {
134
- * aNumber: number;
135
- * aString: string;
136
- * aNullableNumber: number | null;
137
- * aNullableString: string | null;
138
- * aBoolean: boolean;
139
- * aNullableBoolean: boolean | null;
140
- * aDate: Date;
141
- * aNullableDate: Date | null;
142
- * };
143
- *
144
- * const schema = ensureZodTableSchema<Row>(z.strictObject({
145
- * aNumber: z.number(),
146
- * aString: z.string(),
147
- * aNullableNumber: z.nullable(z.number()),
148
- * aNullableString: z.nullable(z.string()),
149
- * aBoolean: z.boolean(),
150
- * aNullableBoolean: z.nullable(z.boolean()),
151
- * aDate: z.date(),
152
- * aNullableDate: z.nullable(z.date()),
153
- * }));
154
- *
155
- * ```
156
- */
157
- declare const ensureZodTableSchema: <T extends TObject = RequireExplicitGeneric>(schema: z.ZodObject<{ [K in keyof NoInfer<T>]-?: z.ZodType<NoInfer<T>[K]> }>) => z.ZodObject<{ [K in keyof NoInfer<T>]-?: z.ZodType<NoInfer<T>[K], unknown, z.core.$ZodTypeInternals<NoInfer<T>[K], unknown>> }, z.core.$strip>;
158
- //#endregion
159
- export { assertValidAliasName, assertValidSchemaName, assertValidTableName, duckAllConnectionOptionsZodSchema, duckConnectionParamsZodSchema, duckDsnZodSchema, duckValidatorsZod, ensureZodTableSchema };
1
+ import { a as duckDsnZodSchema, c as assertValidTableName, d as duckConnectionParamsZodSchema, i as duckValidatorsZod, n as InferZodRelaxedDataSchema, o as assertValidAliasName, r as ensureZodTableSchema, s as assertValidSchemaName, t as TableSchemaZod, u as duckAllConnectionOptionsZodSchema } from "../../index-BKsJVkXZ.mjs";
2
+ export { type InferZodRelaxedDataSchema, type TableSchemaZod, assertValidAliasName, assertValidSchemaName, assertValidTableName, duckAllConnectionOptionsZodSchema, duckConnectionParamsZodSchema, duckDsnZodSchema, duckValidatorsZod, ensureZodTableSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowblade/sqlduck",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -67,15 +67,15 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@flowblade/core": "^0.2.29",
70
- "@flowblade/source-duckdb": "^0.25.1",
70
+ "@flowblade/source-duckdb": "^0.27.0",
71
71
  "@flowblade/sql-tag": "^0.3.4",
72
- "@httpx/assert": "^0.17.1",
73
- "@httpx/dsn-parser": "^1.9.11",
74
- "@httpx/plain-object": "^2.1.11",
75
- "@logtape/logtape": "^2.2.2",
72
+ "@httpx/assert": "^0.17.2",
73
+ "@httpx/dsn-parser": "^1.9.12",
74
+ "@httpx/plain-object": "^2.1.12",
75
+ "@logtape/logtape": "^2.3.0",
76
76
  "@standard-schema/spec": "^1.1.0",
77
77
  "is-safe-filename": "0.1.1",
78
- "p-queue": "^9.3.0",
78
+ "p-queue": "^9.3.3",
79
79
  "zod": "^4.4.3"
80
80
  },
81
81
  "peerDependencies": {
@@ -92,52 +92,52 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@belgattitude/eslint-config-bases": "8.17.0",
96
- "@dotenvx/dotenvx": "1.75.1",
97
- "@duckdb/node-api": "1.5.4-r.1",
95
+ "@belgattitude/eslint-config-bases": "8.19.1",
96
+ "@dotenvx/dotenvx": "2.19.1",
97
+ "@duckdb/node-api": "1.5.5-r.3",
98
98
  "@faker-js/faker": "10.5.0",
99
- "@flowblade/source-kysely": "^1.6.1",
100
- "@httpx/assert": "0.17.1",
99
+ "@flowblade/source-kysely": "^1.7.0",
100
+ "@httpx/assert": "0.17.2",
101
101
  "@mitata/counters": "0.0.8",
102
- "@size-limit/esbuild": "12.1.0",
103
- "@size-limit/file": "12.1.0",
102
+ "@size-limit/esbuild": "13.0.3",
103
+ "@size-limit/file": "13.0.3",
104
104
  "@testcontainers/mssqlserver": "12.0.4",
105
105
  "@total-typescript/ts-reset": "0.6.1",
106
- "@types/node": "26.0.1",
107
- "@typescript-eslint/eslint-plugin": "8.62.1",
108
- "@typescript-eslint/parser": "8.62.1",
109
- "@typescript/native-preview": "7.0.0-dev.20260630.1",
110
- "@vitest/coverage-v8": "4.1.9",
111
- "@vitest/ui": "4.1.9",
106
+ "@types/node": "26.1.2",
107
+ "@typescript-eslint/eslint-plugin": "8.66.0",
108
+ "@typescript-eslint/parser": "8.66.0",
109
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
110
+ "@vitest/coverage-v8": "4.1.10",
111
+ "@vitest/ui": "4.1.10",
112
112
  "ansis": "4.3.1",
113
113
  "browserslist-to-esbuild": "2.1.1",
114
114
  "core-js": "3.49.0",
115
115
  "cross-env": "10.1.0",
116
116
  "es-check": "9.6.4",
117
- "es-toolkit": "1.49.0",
117
+ "es-toolkit": "1.50.0",
118
118
  "esbuild": "0.28.1",
119
119
  "eslint": "8.57.1",
120
- "execa": "9.6.1",
120
+ "execa": "10.0.1",
121
121
  "is-in-ci": "2.0.0",
122
- "kysely": "0.29.2",
122
+ "kysely": "0.29.4",
123
123
  "mitata": "1.0.34",
124
- "npm-run-all2": "9.0.2",
125
- "prettier": "3.9.4",
126
- "publint": "0.3.21",
124
+ "npm-run-all2": "9.0.3",
125
+ "prettier": "3.9.6",
126
+ "publint": "0.3.22",
127
127
  "regexp.escape": "2.0.1",
128
128
  "rimraf": "6.1.3",
129
- "size-limit": "12.1.0",
129
+ "size-limit": "13.0.3",
130
130
  "sql-formatter": "15.8.2",
131
- "tarn": "3.1.0",
131
+ "tarn": "3.1.2",
132
132
  "tedious": "20.0.0",
133
133
  "testcontainers": "12.0.4",
134
- "tsdown": "0.22.3",
135
- "tsx": "4.22.4",
136
- "typedoc": "0.28.19",
134
+ "tsdown": "0.22.14",
135
+ "tsx": "4.23.5",
136
+ "typedoc": "0.28.20",
137
137
  "typedoc-plugin-markdown": "4.12.0",
138
138
  "typescript": "6.0.3",
139
139
  "valibot": "1.4.2",
140
- "vitest": "4.1.9"
140
+ "vitest": "4.1.10"
141
141
  },
142
142
  "files": [
143
143
  "dist"
@@ -1,95 +0,0 @@
1
- import * as z from "zod";
2
-
3
- //#region src/validation/zod/duck-connection-params-zod-schema.d.ts
4
- declare const duckAllConnectionOptionsZodSchema: z.ZodObject<{
5
- accessMode: z.ZodOptional<z.ZodEnum<{
6
- READ_ONLY: "READ_ONLY";
7
- READ_WRITE: "READ_WRITE";
8
- }>>;
9
- compress: z.ZodOptional<z.ZodBoolean>;
10
- type: z.ZodOptional<z.ZodEnum<{
11
- DUCKDB: "DUCKDB";
12
- SQLITE: "SQLITE";
13
- MYSQL: "MYSQL";
14
- PostgreSQL: "PostgreSQL";
15
- }>>;
16
- blockSize: z.ZodOptional<z.ZodInt32>;
17
- rowGroupSize: z.ZodOptional<z.ZodInt32>;
18
- storageVersion: z.ZodOptional<z.ZodString>;
19
- encryptionKey: z.ZodOptional<z.ZodString>;
20
- encryptionCipher: z.ZodOptional<z.ZodEnum<{
21
- CBC: "CBC";
22
- CTR: "CTR";
23
- GCM: "GCM";
24
- }>>;
25
- recoveryMode: z.ZodOptional<z.ZodEnum<{
26
- no_wal_writes: "no_wal_writes";
27
- }>>;
28
- }, z.core.$strict>;
29
- declare const duckConnectionParamsZodSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
- type: z.ZodLiteral<"memory">;
31
- alias: z.ZodString;
32
- options: z.ZodOptional<z.ZodObject<{
33
- accessMode: z.ZodOptional<z.ZodEnum<{
34
- READ_ONLY: "READ_ONLY";
35
- READ_WRITE: "READ_WRITE";
36
- }>>;
37
- compress: z.ZodOptional<z.ZodBoolean>;
38
- type: z.ZodOptional<z.ZodEnum<{
39
- DUCKDB: "DUCKDB";
40
- SQLITE: "SQLITE";
41
- MYSQL: "MYSQL";
42
- PostgreSQL: "PostgreSQL";
43
- }>>;
44
- blockSize: z.ZodOptional<z.ZodInt32>;
45
- rowGroupSize: z.ZodOptional<z.ZodInt32>;
46
- storageVersion: z.ZodOptional<z.ZodString>;
47
- encryptionKey: z.ZodOptional<z.ZodString>;
48
- encryptionCipher: z.ZodOptional<z.ZodEnum<{
49
- CBC: "CBC";
50
- CTR: "CTR";
51
- GCM: "GCM";
52
- }>>;
53
- recoveryMode: z.ZodOptional<z.ZodEnum<{
54
- no_wal_writes: "no_wal_writes";
55
- }>>;
56
- }, z.core.$strict>>;
57
- }, z.core.$strict>, z.ZodObject<{
58
- type: z.ZodLiteral<"filesystem">;
59
- path: z.ZodString;
60
- alias: z.ZodString;
61
- options: z.ZodOptional<z.ZodObject<{
62
- accessMode: z.ZodOptional<z.ZodEnum<{
63
- READ_ONLY: "READ_ONLY";
64
- READ_WRITE: "READ_WRITE";
65
- }>>;
66
- compress: z.ZodOptional<z.ZodBoolean>;
67
- type: z.ZodOptional<z.ZodEnum<{
68
- DUCKDB: "DUCKDB";
69
- SQLITE: "SQLITE";
70
- MYSQL: "MYSQL";
71
- PostgreSQL: "PostgreSQL";
72
- }>>;
73
- blockSize: z.ZodOptional<z.ZodInt32>;
74
- rowGroupSize: z.ZodOptional<z.ZodInt32>;
75
- storageVersion: z.ZodOptional<z.ZodString>;
76
- encryptionKey: z.ZodOptional<z.ZodString>;
77
- encryptionCipher: z.ZodOptional<z.ZodEnum<{
78
- CBC: "CBC";
79
- CTR: "CTR";
80
- GCM: "GCM";
81
- }>>;
82
- recoveryMode: z.ZodOptional<z.ZodEnum<{
83
- no_wal_writes: "no_wal_writes";
84
- }>>;
85
- }, z.core.$strict>>;
86
- }, z.core.$strict>], "type">;
87
- type DuckConnectionParamsZodSchema = z.infer<typeof duckConnectionParamsZodSchema>;
88
- //#endregion
89
- //#region src/validation/core/types.d.ts
90
- type DuckAliasName = string;
91
- type DuckTableName = string;
92
- type DuckSchemaName = string;
93
- type DuckConnectionParams = DuckConnectionParamsZodSchema;
94
- //#endregion
95
- export { duckAllConnectionOptionsZodSchema as a, DuckTableName as i, DuckConnectionParams as n, duckConnectionParamsZodSchema as o, DuckSchemaName as r, DuckAliasName as t };