reposets 1.0.21 → 2.0.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.
@@ -1,50 +0,0 @@
1
- import { SchemaIssue } from "effect";
2
-
3
- //#region src/lib/schema-issues.ts
4
- /**
5
- * Core's structured formatter: one entry per leaf, each with its property path.
6
- *
7
- * @remarks
8
- * Built once. It is a pure function of the issue tree, and `Formatter` carries
9
- * no state.
10
- */
11
- const formatter = SchemaIssue.makeFormatterStandardSchemaV1({ leafHook: (issue) => issue._tag === "UnexpectedKey" ? "unknown key" : SchemaIssue.defaultLeafHook(issue) });
12
- /**
13
- * Render a `ConfigValidationError`'s `issue` as one line per rejected value.
14
- *
15
- * @remarks
16
- * **No walker of our own.** Core already ships one:
17
- * `SchemaIssue.makeFormatterStandardSchemaV1()` flattens the tree to
18
- * `{ message, path }` entries, which is exactly the shape this needs.
19
- * `defaultLeafHook` handles every leaf variant — `UnexpectedKey`,
20
- * `InvalidType`, `MissingKey`, `Forbidden`, `OneOf` — so a wrong *type* renders
21
- * as sensibly as an unknown key, and a variant added upstream is covered
22
- * without a change here. Hand-rolling this against the excess-property shape
23
- * alone would have got every other cause wrong.
24
- *
25
- * `issue` is declared `Schema.Defect`, so it arrives as `unknown`; the
26
- * `isIssue` guard is what makes reading it safe. Anything that is not an issue
27
- * tree yields no lines rather than a crash — a rendering helper on an error
28
- * path must never become the reason a command dies.
29
- *
30
- * Nodes are never stringified. Each carries the entire AST inline, annotations
31
- * included, so `String(node)` would dump the schema rather than describe the
32
- * failure. Only `message` and `path` are read.
33
- *
34
- * @param issue - the `issue` field of a `ConfigValidationError`, or any value
35
- * @returns one line per rejected value, deepest path last; empty if `issue` is
36
- * not an issue tree
37
- *
38
- * @public
39
- */
40
- const formatSchemaIssue = (issue) => {
41
- if (!SchemaIssue.isIssue(issue)) return [];
42
- const lines = formatter(issue).issues.map((entry) => {
43
- const path = (entry.path ?? []).map(String).join(".");
44
- return path === "" ? entry.message : `${entry.message} at ${path}`;
45
- });
46
- return [...new Set(lines)];
47
- };
48
-
49
- //#endregion
50
- export { formatSchemaIssue };