@supawatch/target-valibot 0.8.0 → 0.9.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/README.md +1 -1
- package/dist/index.js +10 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,9 +4,11 @@ import { exportBaseName, fileBaseName } from "@supawatch/core";
|
|
|
4
4
|
function valibotExpr(runtime) {
|
|
5
5
|
switch (runtime.kind) {
|
|
6
6
|
case "number":
|
|
7
|
+
// Floats can really be NaN (measured); v.number() rejects it,
|
|
8
|
+
// while +-Infinity already passes.
|
|
7
9
|
return runtime.integer
|
|
8
10
|
? "v.pipe(v.number(), v.integer())"
|
|
9
|
-
: "v.number()";
|
|
11
|
+
: "v.union([v.number(), v.nan()])";
|
|
10
12
|
case "string":
|
|
11
13
|
return runtime.format === "uuid"
|
|
12
14
|
? "v.pipe(v.string(), v.uuid())"
|
|
@@ -14,7 +16,9 @@ function valibotExpr(runtime) {
|
|
|
14
16
|
case "boolean":
|
|
15
17
|
return "v.boolean()";
|
|
16
18
|
case "date":
|
|
17
|
-
|
|
19
|
+
// Invalid Date instances are real driver output for timestamp
|
|
20
|
+
// 'infinity' and BC values; v.date() rejects them.
|
|
21
|
+
return "v.instance(Date)";
|
|
18
22
|
case "bytes":
|
|
19
23
|
return "v.instance(Uint8Array)";
|
|
20
24
|
case "json":
|
|
@@ -23,6 +27,8 @@ function valibotExpr(runtime) {
|
|
|
23
27
|
case "array":
|
|
24
28
|
return `v.array(${valibotExpr(runtime.element)})`;
|
|
25
29
|
case "enum": {
|
|
30
|
+
if (runtime.labels.length === 0)
|
|
31
|
+
return "v.never()";
|
|
26
32
|
const labels = runtime.labels.map((l) => JSON.stringify(l)).join(", ");
|
|
27
33
|
return `v.picklist([${labels}])`;
|
|
28
34
|
}
|
|
@@ -48,6 +54,8 @@ function tsType(runtime) {
|
|
|
48
54
|
return el.includes("|") ? `(${el})[]` : `${el}[]`;
|
|
49
55
|
}
|
|
50
56
|
case "enum":
|
|
57
|
+
if (runtime.labels.length === 0)
|
|
58
|
+
return "never";
|
|
51
59
|
return runtime.labels.map((l) => JSON.stringify(l)).join(" | ");
|
|
52
60
|
}
|
|
53
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supawatch/target-valibot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Valibot schemas generated from live Postgres by supawatch, mapped to what the driver actually returns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"supabase",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"valibot": "^1.1.0",
|
|
36
|
-
"@supawatch/core": "0.
|
|
36
|
+
"@supawatch/core": "0.9.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"valibot": "^1.0.0"
|