viell-effect-schema-http 0.16.1 → 0.17.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/README.md
CHANGED
|
@@ -54,13 +54,14 @@ In an existing Node.js 24 or 26 ESM project with Effect `^4.0.7`, add the librar
|
|
|
54
54
|
npm install viell-effect-schema-http
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
`0.
|
|
58
|
-
tarball](https://github.com/viell-dev/slop-effect-schema-http/releases/tag/0.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
`0.17.0` is the current release. The same package is available as a checksummed [GitHub release
|
|
58
|
+
tarball](https://github.com/viell-dev/slop-effect-schema-http/releases/tag/0.17.0). This is a
|
|
59
|
+
breaking release. Read [What's in
|
|
60
|
+
0.17](https://viell-dev.github.io/slop-effect-schema-http/release-notes/0.17) before updating from
|
|
61
|
+
`0.16`: constructor-alias validation now recognises nested primitive alternatives such as
|
|
62
|
+
`Schema.Literals([...])` and `Schema.NullOr(Schema.String)`, so an invalid encoded alias beside one
|
|
63
|
+
refuses before dispatch instead of being replaced by a default. Broader default and
|
|
64
|
+
alias-preservation limits remain active.
|
|
64
65
|
|
|
65
66
|
TypeScript declarations and editor documentation are included. The supported environments are Node
|
|
66
67
|
24 or 26 on Windows/Linux and browser Fetch in Chromium. See [compatibility and
|
|
@@ -79,8 +80,8 @@ versions and provider boundaries.
|
|
|
79
80
|
Operation, Policy, Interaction, UrlEncoding and Transport, from basic use to advanced behavior.
|
|
80
81
|
- [Limits and recovery](https://viell-dev.github.io/slop-effect-schema-http/limits): compatibility,
|
|
81
82
|
where the library's promise stops, failure stages and bug reporting.
|
|
82
|
-
- [What's in 0.
|
|
83
|
-
|
|
83
|
+
- [What's in 0.17](https://viell-dev.github.io/slop-effect-schema-http/release-notes/0.17): nested
|
|
84
|
+
primitive alternatives in constructor-alias validation, migration and remaining limits.
|
|
84
85
|
- [Release history](https://viell-dev.github.io/slop-effect-schema-http/release-notes/): earlier
|
|
85
86
|
articles and a comparison of the related schema-input repairs.
|
|
86
87
|
- [Versions](https://viell-dev.github.io/slop-effect-schema-http/versions): updates and
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { SchemaAST } from "effect";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Unencoded union members that cannot consume an actual object; Void deliberately does not qualify.
|
|
4
|
+
*
|
|
5
|
+
* An unencoded union qualifies when every member does, so `Schema.Literals` and
|
|
6
|
+
* `Schema.NullOr(Schema.String)` read like their flat members. Shared members are visited once.
|
|
7
|
+
*/
|
|
3
8
|
export declare const isNonObjectAlternative: (ast: SchemaAST.AST) => boolean;
|
|
4
9
|
//# sourceMappingURL=primitive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../../src/http/internal/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../../../src/http/internal/primitive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAmCxC;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,SAAS,CAAC,GAAG,KAAG,OAGG,CAAC"}
|
|
@@ -12,6 +12,25 @@ const nonObjectTags = new Set([
|
|
|
12
12
|
"Undefined",
|
|
13
13
|
"Never",
|
|
14
14
|
]);
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const isPrimitiveUnion = (ast, known) => {
|
|
16
|
+
const cached = known.get(ast);
|
|
17
|
+
if (cached !== undefined)
|
|
18
|
+
return cached;
|
|
19
|
+
// Only a mutated AST forms a union cycle. Seeding false declines it when it is reached again.
|
|
20
|
+
known.set(ast, false);
|
|
21
|
+
const result = ast.types.every((member) => member.encoding === undefined &&
|
|
22
|
+
(nonObjectTags.has(member._tag) ||
|
|
23
|
+
(member._tag === "Union" && isPrimitiveUnion(member, known))));
|
|
24
|
+
known.set(ast, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Unencoded union members that cannot consume an actual object; Void deliberately does not qualify.
|
|
29
|
+
*
|
|
30
|
+
* An unencoded union qualifies when every member does, so `Schema.Literals` and
|
|
31
|
+
* `Schema.NullOr(Schema.String)` read like their flat members. Shared members are visited once.
|
|
32
|
+
*/
|
|
33
|
+
export const isNonObjectAlternative = (ast) => ast.encoding === undefined &&
|
|
34
|
+
(nonObjectTags.has(ast._tag) ||
|
|
35
|
+
(ast._tag === "Union" && isPrimitiveUnion(ast, new Map())));
|
|
17
36
|
//# sourceMappingURL=primitive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.js","sourceRoot":"","sources":["../../../src/http/internal/primitive.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAuC,IAAI,GAAG,CAAC;IAChE,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,SAAS;IACT,MAAM;IACN,iBAAiB;IACjB,MAAM;IACN,WAAW;IACX,OAAO;CACR,CAAC,CAAC;AAEH,
|
|
1
|
+
{"version":3,"file":"primitive.js","sourceRoot":"","sources":["../../../src/http/internal/primitive.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAuC,IAAI,GAAG,CAAC;IAChE,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,SAAS;IACT,MAAM;IACN,iBAAiB;IACjB,MAAM;IACN,WAAW;IACX,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CACvB,GAAoB,EACpB,KAAkC,EACzB,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,8FAA8F;IAC9F,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAC5B,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC7B,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YAC7B,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAClE,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAkB,EAAW,EAAE,CACpE,GAAG,CAAC,QAAQ,KAAK,SAAS;IAC1B,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;QAC1B,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,IAAI,gBAAgB,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viell-effect-schema-http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Consumer-owned HTTP contracts composed with Effect",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
"minimatch@10": "11.0.1"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@effect/vitest": "^4.1.
|
|
112
|
+
"@effect/vitest": "^4.1.4",
|
|
113
113
|
"@eslint/js": "^10.0.1",
|
|
114
114
|
"@types/node": "^26.6.6",
|
|
115
|
-
"effect": "^4.1.
|
|
115
|
+
"effect": "^4.1.4",
|
|
116
116
|
"eslint": "^10.14.0",
|
|
117
117
|
"eslint-config-prettier": "^10.1.8",
|
|
118
118
|
"eslint-plugin-oxlint": "^1.92.0",
|
|
@@ -15,6 +15,31 @@ const nonObjectTags: ReadonlySet<SchemaAST.AST["_tag"]> = new Set([
|
|
|
15
15
|
"Never",
|
|
16
16
|
]);
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const isPrimitiveUnion = (
|
|
19
|
+
ast: SchemaAST.Union,
|
|
20
|
+
known: Map<SchemaAST.AST, boolean>,
|
|
21
|
+
): boolean => {
|
|
22
|
+
const cached = known.get(ast);
|
|
23
|
+
if (cached !== undefined) return cached;
|
|
24
|
+
// Only a mutated AST forms a union cycle. Seeding false declines it when it is reached again.
|
|
25
|
+
known.set(ast, false);
|
|
26
|
+
const result = ast.types.every(
|
|
27
|
+
(member) =>
|
|
28
|
+
member.encoding === undefined &&
|
|
29
|
+
(nonObjectTags.has(member._tag) ||
|
|
30
|
+
(member._tag === "Union" && isPrimitiveUnion(member, known))),
|
|
31
|
+
);
|
|
32
|
+
known.set(ast, result);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Unencoded union members that cannot consume an actual object; Void deliberately does not qualify.
|
|
38
|
+
*
|
|
39
|
+
* An unencoded union qualifies when every member does, so `Schema.Literals` and
|
|
40
|
+
* `Schema.NullOr(Schema.String)` read like their flat members. Shared members are visited once.
|
|
41
|
+
*/
|
|
19
42
|
export const isNonObjectAlternative = (ast: SchemaAST.AST): boolean =>
|
|
20
|
-
ast.encoding === undefined &&
|
|
43
|
+
ast.encoding === undefined &&
|
|
44
|
+
(nonObjectTags.has(ast._tag) ||
|
|
45
|
+
(ast._tag === "Union" && isPrimitiveUnion(ast, new Map())));
|