@flowblade/sqlduck 0.27.0 → 0.28.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.
- package/dist/filesystem/index.mjs +1 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +32 -10
- package/dist/validation/valibot/index.d.mts +3 -3
- package/dist/validation/valibot/index.mjs +1 -1
- package/dist/validation/zod/index.d.mts +4 -4
- package/dist/validation/zod/index.mjs +1 -1
- package/dist/{zod-uQPzaK64.mjs → zod-DB5FHzXW.mjs} +1 -1
- package/package.json +24 -24
- /package/dist/{duck-reserved-keywords-D_yi_PVW.mjs → duck-reserved-keywords-BzYA7jvN.mjs} +0 -0
- /package/dist/{file-system-utils-BX51TrfT.mjs → file-system-utils-DT6smf4C.mjs} +0 -0
- /package/dist/{types-C6EIVpFJ.d.mts → types-BKI2f-Rk.d.mts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as FileSystemUtils } from "../file-system-utils-
|
|
1
|
+
import { t as FileSystemUtils } from "../file-system-utils-DT6smf4C.mjs";
|
|
2
2
|
export { FileSystemUtils };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as DuckConnectionParams } from "./types-
|
|
1
|
+
import { n as DuckConnectionParams } from "./types-BKI2f-Rk.mjs";
|
|
2
2
|
import { DuckDBConnection, DuckDBType } from "@duckdb/node-api";
|
|
3
|
-
import * as _$_logtape_logtape0 from "@logtape/logtape";
|
|
4
3
|
import { Logger } from "@logtape/logtape";
|
|
5
4
|
import * as z from "zod";
|
|
6
5
|
import { ZodObject } from "zod";
|
|
@@ -394,6 +393,6 @@ declare const flowbladeLogtapeSqlduckConfig: {
|
|
|
394
393
|
};
|
|
395
394
|
//#endregion
|
|
396
395
|
//#region src/logger/sqlduck-default-logtape-logger.d.ts
|
|
397
|
-
declare const sqlduckDefaultLogtapeLogger:
|
|
396
|
+
declare const sqlduckDefaultLogtapeLogger: import("@logtape/logtape").Logger;
|
|
398
397
|
//#endregion
|
|
399
398
|
export { Database, type DuckConnectionParams, DuckDatabaseManager, DuckExtensionsManager, DuckMemory, type DuckMemoryTag, DuckSettingsManager, type DuckdbReservedKeywords, type OnChunkAppendedCb, type OnChunkAppendedStats, SqlDuck, type SqlDuckParams, Table, type ToTableParams, duckReservedKeywords, flowbladeLogtapeSqlduckConfig, getTableCreateFromZod, sqlduckDefaultLogtapeLogger, zodCodecs };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as sqlduckDefaultLogtapeLogger, r as flowbladeLogtapeSqlduckConfig, t as FileSystemUtils } from "./file-system-utils-
|
|
2
|
-
import { t as duckReservedKeywords } from "./duck-reserved-keywords-
|
|
3
|
-
import { c as duckValidatorsZod, r as assertValidAliasName, s as duckConnectionParamsZodSchema } from "./zod-
|
|
4
|
-
import { BIGINT, BOOLEAN, DOUBLE, DuckDBDataChunk, DuckDBInstanceCache, DuckDBTimestampMillisecondsValue, DuckDBTypeId, ENUM, FLOAT, HUGEINT, INTEGER, SMALLINT, TIMESTAMP, TIMESTAMP_MS, TINYINT, UBIGINT, UHUGEINT, UINTEGER, USMALLINT, UTINYINT, UUID, VARCHAR } from "@duckdb/node-api";
|
|
1
|
+
import { n as sqlduckDefaultLogtapeLogger, r as flowbladeLogtapeSqlduckConfig, t as FileSystemUtils } from "./file-system-utils-DT6smf4C.mjs";
|
|
2
|
+
import { t as duckReservedKeywords } from "./duck-reserved-keywords-BzYA7jvN.mjs";
|
|
3
|
+
import { c as duckValidatorsZod, r as assertValidAliasName, s as duckConnectionParamsZodSchema } from "./zod-DB5FHzXW.mjs";
|
|
4
|
+
import { BIGINT, BOOLEAN, 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";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { assertNever } from "@httpx/assert";
|
|
7
7
|
import { isPlainObject } from "@httpx/plain-object";
|
|
@@ -154,6 +154,12 @@ var DuckValueConverter = class {
|
|
|
154
154
|
value
|
|
155
155
|
});
|
|
156
156
|
};
|
|
157
|
+
createDecimalConverter = (width, scale) => (value) => {
|
|
158
|
+
if (value === void 0 || value === null) return null;
|
|
159
|
+
if (typeof value === "number") return DuckDBDecimalValue.fromDouble(value, width, scale);
|
|
160
|
+
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");
|
|
162
|
+
};
|
|
157
163
|
toBigIntString = (value) => {
|
|
158
164
|
if (typeof value === "string") return value;
|
|
159
165
|
if (typeof value === "number" || typeof value === "bigint") return value.toString(10);
|
|
@@ -221,6 +227,12 @@ const createDuckColumnConverters = (duckTypes) => {
|
|
|
221
227
|
case DuckDBTypeId.SMALLINT:
|
|
222
228
|
conv = false;
|
|
223
229
|
break;
|
|
230
|
+
case DuckDBTypeId.FLOAT:
|
|
231
|
+
conv = false;
|
|
232
|
+
break;
|
|
233
|
+
case DuckDBTypeId.DECIMAL:
|
|
234
|
+
conv = converter.createDecimalConverter(18, 3);
|
|
235
|
+
break;
|
|
224
236
|
default: throw new Error(`Unsupported duck type ${duckTypeId} / ${duckType.toString()} for column '${key}'`);
|
|
225
237
|
}
|
|
226
238
|
if (conv !== false) convMap[key] = conv;
|
|
@@ -527,12 +539,19 @@ var DuckDatabaseManager = class {
|
|
|
527
539
|
//#region src/table/get-duckdb-number-column-type.ts
|
|
528
540
|
const isFloatValue = (value) => {
|
|
529
541
|
if (!Number.isFinite(value)) return true;
|
|
542
|
+
if (!value.toString(10).includes(".")) return false;
|
|
530
543
|
if (Math.abs(value) > Number.MAX_SAFE_INTEGER) return true;
|
|
531
544
|
return !Number.isInteger(value);
|
|
532
545
|
};
|
|
546
|
+
const getScale = (value) => {
|
|
547
|
+
const parts = value.toString().split(".");
|
|
548
|
+
if (parts.length < 2) return 0;
|
|
549
|
+
return parts[1].length;
|
|
550
|
+
};
|
|
533
551
|
const getDuckdbNumberColumnType = (params) => {
|
|
534
|
-
const { minimum, maximum } = params;
|
|
552
|
+
const { minimum, maximum, multipleOf } = params;
|
|
535
553
|
if (minimum === void 0 || maximum === void 0) return BIGINT;
|
|
554
|
+
if (multipleOf !== void 0 && isFloatValue(multipleOf)) return DECIMAL(18, getScale(multipleOf));
|
|
536
555
|
if (isFloatValue(minimum) || isFloatValue(maximum)) {
|
|
537
556
|
if (minimum >= -34028235e31 && maximum <= 34028235e31) return FLOAT;
|
|
538
557
|
return DOUBLE;
|
|
@@ -557,7 +576,7 @@ const createOptions = {
|
|
|
557
576
|
CREATE_OR_REPLACE: "CREATE OR REPLACE TABLE",
|
|
558
577
|
IF_NOT_EXISTS: "CREATE TABLE IF NOT EXISTS"
|
|
559
578
|
};
|
|
560
|
-
const
|
|
579
|
+
const duckDbTypes = [
|
|
561
580
|
["VARCHAR", VARCHAR],
|
|
562
581
|
["BIGINT", BIGINT],
|
|
563
582
|
["UBIGINT", UBIGINT],
|
|
@@ -568,8 +587,10 @@ const duckDbTypesMap = new Map([
|
|
|
568
587
|
["BOOLEAN", BOOLEAN],
|
|
569
588
|
["INTEGER", INTEGER],
|
|
570
589
|
["DOUBLE", DOUBLE],
|
|
571
|
-
["FLOAT", FLOAT]
|
|
572
|
-
]
|
|
590
|
+
["FLOAT", FLOAT],
|
|
591
|
+
["DECIMAL", new DuckDBDecimalType(18, 3)]
|
|
592
|
+
];
|
|
593
|
+
const duckDbTypesMap = new Map(duckDbTypes);
|
|
573
594
|
const getTableCreateFromZod = (params) => {
|
|
574
595
|
const { table, schema, options } = params;
|
|
575
596
|
const { create = "CREATE" } = options ?? {};
|
|
@@ -582,7 +603,7 @@ const getTableCreateFromZod = (params) => {
|
|
|
582
603
|
if (json.properties === void 0) throw new TypeError("Schema must have at least one property");
|
|
583
604
|
const columnTypesMap = /* @__PURE__ */ new Map();
|
|
584
605
|
for (const [columnName, def] of Object.entries(json.properties)) {
|
|
585
|
-
const { type, duckdbType, nullable, format, primaryKey, minimum, maximum } = def;
|
|
606
|
+
const { type, duckdbType, nullable, format, primaryKey, minimum, maximum, multipleOf } = def;
|
|
586
607
|
const c = { name: columnName };
|
|
587
608
|
if (duckdbType !== void 0 && duckDbTypesMap.has(duckdbType)) c.duckdbType = duckDbTypesMap.get(duckdbType);
|
|
588
609
|
else switch (type) {
|
|
@@ -604,7 +625,8 @@ const getTableCreateFromZod = (params) => {
|
|
|
604
625
|
case "number":
|
|
605
626
|
c.duckdbType = getDuckdbNumberColumnType({
|
|
606
627
|
minimum,
|
|
607
|
-
maximum
|
|
628
|
+
maximum,
|
|
629
|
+
multipleOf
|
|
608
630
|
});
|
|
609
631
|
break;
|
|
610
632
|
case "integer":
|
|
@@ -126,9 +126,9 @@ declare const duckValidatorsValibot: {
|
|
|
126
126
|
* Validate duckdb objects names like table, alias, and schemas
|
|
127
127
|
* for validity.
|
|
128
128
|
*/
|
|
129
|
-
readonly aliasName:
|
|
130
|
-
readonly schemaName:
|
|
131
|
-
readonly tableName:
|
|
129
|
+
readonly aliasName: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>, import("valibot").RegexAction<string, "Identifier must start with a letter or underscore, and contain only letters, numbers and underscores">, import("valibot").CheckAction<string, "Identifier value is a DuckDB reserved keyword and cannot be used as an identifier">]>;
|
|
130
|
+
readonly schemaName: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>, import("valibot").RegexAction<string, "Identifier must start with a letter or underscore, and contain only letters, numbers and underscores">, import("valibot").CheckAction<string, "Identifier value is a DuckDB reserved keyword and cannot be used as an identifier">]>;
|
|
131
|
+
readonly tableName: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 120, undefined>, import("valibot").RegexAction<string, "Identifier must start with a letter or underscore, and contain only letters, numbers and underscores">, import("valibot").CheckAction<string, "Identifier value is a DuckDB reserved keyword and cannot be used as an identifier">]>;
|
|
132
132
|
};
|
|
133
133
|
//#endregion
|
|
134
134
|
export { type DuckAllConnectionOptionsValibotSchema, duckAllConnectionOptionsValibotSchema, duckConnectionParamsValibotSchema, duckDsnValibotSchema, duckIdentifierValibotSchema, duckValidatorsValibot };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as duckStorageVersionRegexp, i as duckIdentifierNameRegex, n as duckdbReservedKeywordsSet, r as duckConnectionsOptions } from "../../duck-reserved-keywords-
|
|
1
|
+
import { a as duckStorageVersionRegexp, i as duckIdentifierNameRegex, n as duckdbReservedKeywordsSet, r as duckConnectionsOptions } from "../../duck-reserved-keywords-BzYA7jvN.mjs";
|
|
2
2
|
import isSafeFilename from "is-safe-filename";
|
|
3
3
|
import { parseDsn, parseDsnOrThrow } from "@httpx/dsn-parser";
|
|
4
4
|
import * as v from "valibot";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as duckAllConnectionOptionsZodSchema, i as DuckTableName, o as duckConnectionParamsZodSchema, r as DuckSchemaName, t as DuckAliasName } from "../../types-
|
|
1
|
+
import { a as duckAllConnectionOptionsZodSchema, i as DuckTableName, o as duckConnectionParamsZodSchema, r as DuckSchemaName, t as DuckAliasName } from "../../types-BKI2f-Rk.mjs";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/validation/zod/duck-asserts-zod.d.ts
|
|
@@ -112,9 +112,9 @@ declare const duckValidatorsZod: {
|
|
|
112
112
|
* Validate duckdb objects names like table, alias, and schemas
|
|
113
113
|
* for validity.
|
|
114
114
|
*/
|
|
115
|
-
readonly aliasName:
|
|
116
|
-
readonly schemaName:
|
|
117
|
-
readonly tableName:
|
|
115
|
+
readonly aliasName: import("zod").ZodString;
|
|
116
|
+
readonly schemaName: import("zod").ZodString;
|
|
117
|
+
readonly tableName: import("zod").ZodString;
|
|
118
118
|
};
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/validation/zod/ensure-zod-table-schema.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as assertValidTableName, c as duckValidatorsZod, i as assertValidSchemaName, n as duckDsnZodSchema, o as duckAllConnectionOptionsZodSchema, r as assertValidAliasName, s as duckConnectionParamsZodSchema, t as ensureZodTableSchema } from "../../zod-
|
|
1
|
+
import { a as assertValidTableName, c as duckValidatorsZod, i as assertValidSchemaName, n as duckDsnZodSchema, o as duckAllConnectionOptionsZodSchema, r as assertValidAliasName, s as duckConnectionParamsZodSchema, t as ensureZodTableSchema } from "../../zod-DB5FHzXW.mjs";
|
|
2
2
|
export { assertValidAliasName, assertValidSchemaName, assertValidTableName, duckAllConnectionOptionsZodSchema, duckConnectionParamsZodSchema, duckDsnZodSchema, duckValidatorsZod, ensureZodTableSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as duckStorageVersionRegexp, i as duckIdentifierNameRegex, n as duckdbReservedKeywordsSet, r as duckConnectionsOptions } from "./duck-reserved-keywords-
|
|
1
|
+
import { a as duckStorageVersionRegexp, i as duckIdentifierNameRegex, n as duckdbReservedKeywordsSet, r as duckConnectionsOptions } from "./duck-reserved-keywords-BzYA7jvN.mjs";
|
|
2
2
|
import isSafeFilename from "is-safe-filename";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { parseDsn } from "@httpx/dsn-parser";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowblade/sqlduck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@flowblade/core": "^0.2.29",
|
|
70
|
-
"@flowblade/source-duckdb": "^0.23.
|
|
70
|
+
"@flowblade/source-duckdb": "^0.23.1",
|
|
71
71
|
"@flowblade/sql-tag": "^0.3.4",
|
|
72
72
|
"@httpx/assert": "^0.17.1",
|
|
73
73
|
"@httpx/dsn-parser": "^1.9.11",
|
|
74
74
|
"@httpx/plain-object": "^2.1.11",
|
|
75
|
-
"@logtape/logtape": "^2.1.
|
|
75
|
+
"@logtape/logtape": "^2.1.4",
|
|
76
76
|
"@standard-schema/spec": "^1.1.0",
|
|
77
77
|
"is-safe-filename": "0.1.1",
|
|
78
78
|
"p-queue": "^9.3.0",
|
|
@@ -93,51 +93,51 @@
|
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@belgattitude/eslint-config-bases": "8.15.0",
|
|
96
|
-
"@dotenvx/dotenvx": "1.
|
|
97
|
-
"@duckdb/node-api": "1.5.3-r.
|
|
96
|
+
"@dotenvx/dotenvx": "1.71.3",
|
|
97
|
+
"@duckdb/node-api": "1.5.3-r.3",
|
|
98
98
|
"@faker-js/faker": "10.4.0",
|
|
99
|
-
"@flowblade/source-kysely": "^1.4.
|
|
99
|
+
"@flowblade/source-kysely": "^1.4.2",
|
|
100
100
|
"@httpx/assert": "0.17.1",
|
|
101
101
|
"@mitata/counters": "0.0.8",
|
|
102
102
|
"@size-limit/esbuild": "12.1.0",
|
|
103
103
|
"@size-limit/file": "12.1.0",
|
|
104
|
-
"@testcontainers/mssqlserver": "12.0.
|
|
104
|
+
"@testcontainers/mssqlserver": "12.0.2",
|
|
105
105
|
"@total-typescript/ts-reset": "0.6.1",
|
|
106
|
-
"@types/node": "25.9.
|
|
107
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
108
|
-
"@typescript-eslint/parser": "8.
|
|
109
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
110
|
-
"@vitest/coverage-v8": "4.1.
|
|
111
|
-
"@vitest/ui": "4.1.
|
|
112
|
-
"ansis": "4.3.
|
|
106
|
+
"@types/node": "25.9.3",
|
|
107
|
+
"@typescript-eslint/eslint-plugin": "8.61.0",
|
|
108
|
+
"@typescript-eslint/parser": "8.61.0",
|
|
109
|
+
"@typescript/native-preview": "7.0.0-dev.20260613.1",
|
|
110
|
+
"@vitest/coverage-v8": "4.1.9",
|
|
111
|
+
"@vitest/ui": "4.1.9",
|
|
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.47.
|
|
118
|
-
"esbuild": "0.28.
|
|
117
|
+
"es-toolkit": "1.47.1",
|
|
118
|
+
"esbuild": "0.28.1",
|
|
119
119
|
"eslint": "8.57.1",
|
|
120
120
|
"execa": "9.6.1",
|
|
121
121
|
"is-in-ci": "2.0.0",
|
|
122
122
|
"kysely": "0.29.2",
|
|
123
123
|
"mitata": "1.0.34",
|
|
124
|
-
"npm-run-all2": "9.0.
|
|
125
|
-
"prettier": "3.8.
|
|
124
|
+
"npm-run-all2": "9.0.2",
|
|
125
|
+
"prettier": "3.8.4",
|
|
126
126
|
"publint": "0.3.21",
|
|
127
127
|
"regexp.escape": "2.0.1",
|
|
128
128
|
"rimraf": "6.1.3",
|
|
129
129
|
"size-limit": "12.1.0",
|
|
130
|
-
"sql-formatter": "15.8.
|
|
130
|
+
"sql-formatter": "15.8.1",
|
|
131
131
|
"tarn": "3.0.2",
|
|
132
132
|
"tedious": "19.2.1",
|
|
133
|
-
"testcontainers": "12.0.
|
|
134
|
-
"tsdown": "0.22.
|
|
135
|
-
"tsx": "4.22.
|
|
133
|
+
"testcontainers": "12.0.2",
|
|
134
|
+
"tsdown": "0.22.2",
|
|
135
|
+
"tsx": "4.22.4",
|
|
136
136
|
"typedoc": "0.28.19",
|
|
137
|
-
"typedoc-plugin-markdown": "4.
|
|
137
|
+
"typedoc-plugin-markdown": "4.12.0",
|
|
138
138
|
"typescript": "6.0.3",
|
|
139
139
|
"valibot": "1.4.1",
|
|
140
|
-
"vitest": "4.1.
|
|
140
|
+
"vitest": "4.1.9"
|
|
141
141
|
},
|
|
142
142
|
"files": [
|
|
143
143
|
"dist"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|