effect 3.19.2 → 3.19.3

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.
Files changed (48) hide show
  1. package/dist/cjs/Inspectable.js +86 -4
  2. package/dist/cjs/Inspectable.js.map +1 -1
  3. package/dist/cjs/ParseResult.js +1 -1
  4. package/dist/cjs/ParseResult.js.map +1 -1
  5. package/dist/cjs/Pretty.js +4 -3
  6. package/dist/cjs/Pretty.js.map +1 -1
  7. package/dist/cjs/Schema.js +15 -14
  8. package/dist/cjs/Schema.js.map +1 -1
  9. package/dist/cjs/SchemaAST.js +4 -3
  10. package/dist/cjs/SchemaAST.js.map +1 -1
  11. package/dist/cjs/internal/config.js +10 -9
  12. package/dist/cjs/internal/config.js.map +1 -1
  13. package/dist/cjs/internal/schema/errors.js +6 -5
  14. package/dist/cjs/internal/schema/errors.js.map +1 -1
  15. package/dist/cjs/internal/schema/util.js +3 -77
  16. package/dist/cjs/internal/schema/util.js.map +1 -1
  17. package/dist/cjs/internal/version.js +1 -1
  18. package/dist/dts/Inspectable.d.ts.map +1 -1
  19. package/dist/dts/Pretty.d.ts.map +1 -1
  20. package/dist/dts/Schema.d.ts.map +1 -1
  21. package/dist/dts/SchemaAST.d.ts.map +1 -1
  22. package/dist/esm/Inspectable.js +79 -2
  23. package/dist/esm/Inspectable.js.map +1 -1
  24. package/dist/esm/ParseResult.js +1 -1
  25. package/dist/esm/ParseResult.js.map +1 -1
  26. package/dist/esm/Pretty.js +4 -3
  27. package/dist/esm/Pretty.js.map +1 -1
  28. package/dist/esm/Schema.js +15 -14
  29. package/dist/esm/Schema.js.map +1 -1
  30. package/dist/esm/SchemaAST.js +4 -3
  31. package/dist/esm/SchemaAST.js.map +1 -1
  32. package/dist/esm/internal/config.js +10 -9
  33. package/dist/esm/internal/config.js.map +1 -1
  34. package/dist/esm/internal/schema/errors.js +6 -5
  35. package/dist/esm/internal/schema/errors.js.map +1 -1
  36. package/dist/esm/internal/schema/util.js +2 -72
  37. package/dist/esm/internal/schema/util.js.map +1 -1
  38. package/dist/esm/internal/version.js +1 -1
  39. package/package.json +1 -1
  40. package/src/Inspectable.ts +115 -2
  41. package/src/ParseResult.ts +1 -1
  42. package/src/Pretty.ts +4 -3
  43. package/src/Schema.ts +18 -14
  44. package/src/SchemaAST.ts +4 -3
  45. package/src/internal/config.ts +15 -9
  46. package/src/internal/schema/errors.ts +12 -5
  47. package/src/internal/schema/util.ts +2 -100
  48. package/src/internal/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["array_","util_","getErrorMessage","reason","details","path","ast","out","isNonEmptyReadonlyArray","formatPath","undefined","_tag","getInvalidArgumentErrorMessage","getUnsupportedSchemaErrorMessage","getMissingAnnotationErrorMessage","getArbitraryUnsupportedErrorMessage","getArbitraryMissingAnnotationErrorMessage","getArbitraryEmptyEnumErrorMessage","getEquivalenceUnsupportedErrorMessage","getJSONSchemaMissingAnnotationErrorMessage","getJSONSchemaMissingIdentifierAnnotationErrorMessage","getJSONSchemaUnsupportedPostRestElementsErrorMessage","getJSONSchemaUnsupportedKeyErrorMessage","key","formatPropertyKey","getPrettyMissingAnnotationErrorMessage","getPrettyNeverErrorMessage","getPrettyNoMatchingSchemaErrorMessage","actual","formatUnknown","getSchemaExtendErrorMessage","x","y","getSchemaUnsupportedLiteralSpanErrorMessage","getASTUnsupportedSchemaErrorMessage","getASTUnsupportedKeySchemaErrorMessage","getASTUnsupportedLiteralErrorMessage","literal","getASTDuplicateIndexSignatureErrorMessage","type","getASTIndexSignatureParameterErrorMessage","getASTRequiredElementFollowinAnOptionalElementErrorMessage","getASTDuplicatePropertySignatureTransformationErrorMessage","getASTUnsupportedRenameSchemaErrorMessage","getASTDuplicatePropertySignatureErrorMessage"],"sources":["../../../../src/internal/schema/errors.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,gBAAgB;AAExC,OAAO,KAAKC,KAAK,MAAM,WAAW;AAElC,M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,EAAE,iBAAiBD,KAAK,CAAC4B,aAAa,CAACN,GAAG,CAAC,EAAE,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["array_","Inspectable","util_","getErrorMessage","reason","details","path","ast","out","isNonEmptyReadonlyArray","formatPath","undefined","_tag","getInvalidArgumentErrorMessage","getUnsupportedSchemaErrorMessage","getMissingAnnotationErrorMessage","getArbitraryUnsupportedErrorMessage","getArbitraryMissingAnnotationErrorMessage","getArbitraryEmptyEnumErrorMessage","getEquivalenceUnsupportedErrorMessage","getJSONSchemaMissingAnnotationErrorMessage","getJSONSchemaMissingIdentifierAnnotationErrorMessage","getJSONSchemaUnsupportedPostRestElementsErrorMessage","getJSONSchemaUnsupportedKeyErrorMessage","key","formatPropertyKey","getPrettyMissingAnnotationErrorMessage","getPrettyNeverErrorMessage","getPrettyNoMatchingSchemaErrorMessage","actual","formatUnknown","getSchemaExtendErrorMessage","x","y","getSchemaUnsupportedLiteralSpanErrorMessage","getASTUnsupportedSchemaErrorMessage","getASTUnsupportedKeySchemaErrorMessage","getASTUnsupportedLiteralErrorMessage","literal","getASTDuplicateIndexSignatureErrorMessage","type","getASTIndexSignatureParameterErrorMessage","getASTRequiredElementFollowinAnOptionalElementErrorMessage","getASTDuplicatePropertySignatureTransformationErrorMessage","getASTUnsupportedRenameSchemaErrorMessage","getASTDuplicatePropertySignatureErrorMessage"],"sources":["../../../../src/internal/schema/errors.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,WAAW,MAAM,sBAAsB;AAEnD,OAAO,KAAKC,KAAK,MAAM,WAAW;AAElC,MAAMC,eAAe,GAAGA,CACtBC,MAAc,EACdC,OAAgB,EAChBC,IAAiC,EACjCC,GAAa,KACH;EACV,IAAIC,GAAG,GAAGJ,MAAM;EAEhB,IAAIE,IAAI,IAAIN,MAAM,CAACS,uBAAuB,CAACH,IAAI,CAAC,EAAE;IAChDE,GAAG,IAAI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,GAAG,CAAC;AAEjF;AACA;AACA;AAEA;AACA,OAAO,MAAM4B,mCAAmC,GAAI5B,GAAY,IAC9DO,gCAAgC,CAACH,SAAS,EAAEA,SAAS,EAAEJ,GAAG,CAAC;AAE7D;AACA,OAAO,MAAM6B,sCAAsC,GAAI7B,GAAY,IACjEJ,eAAe,CAAC,wBAAwB,EAAEQ,SAAS,EAAEA,SAAS,EAAEJ,GAAG,CAAC;AAEtE;AACA,OAAO,MAAM8B,oCAAoC,GAAIC,OAAyB,IAC5EnC,eAAe,CAAC,qBAAqB,EAAE,kBAAkBF,WAAW,CAAC6B,aAAa,CAACQ,OAAO,CAAC,EAAE,CAAC;AAEhG;AACA,OAAO,MAAMC,yCAAyC,GAAIC,IAAyB,IACjFrC,eAAe,CAAC,2BAA2B,EAAE,GAAGqC,IAAI,kBAAkB,CAAC;AAEzE;AACA,OAAO,MAAMC,yCAAyC,gBAAGtC,eAAe,CACtE,uCAAuC,EACvC,6HAA6H,CAC9H;AAED;AACA,OAAO,MAAMuC,0DAA0D,gBAAGvC,eAAe,CACvF,iBAAiB,EACjB,gEAAgE,CACjE;AAED;AACA,OAAO,MAAMwC,0DAA0D,GAAInB,GAAgB,IACzFrB,eAAe,CAAC,6CAA6C,EAAE,iBAAiBF,WAAW,CAAC6B,aAAa,CAACN,GAAG,CAAC,EAAE,CAAC;AAEnH;AACA,OAAO,MAAMoB,yCAAyC,GAAIrC,GAAY,IACpEO,gCAAgC,CAACH,SAAS,EAAEA,SAAS,EAAEJ,GAAG,CAAC;AAE7D;AACA,OAAO,MAAMsC,4CAA4C,GAAIrB,GAAgB,IAC3ErB,eAAe,CAAC,8BAA8B,EAAE,iBAAiBF,WAAW,CAAC6B,aAAa,CAACN,GAAG,CAAC,EAAE,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import * as Predicate from "../../Predicate.js";
1
+ import * as Inspectable from "../../Inspectable.js";
2
2
  /** @internal */
3
3
  export const getKeysForIndexSignature = (input, parameter) => {
4
4
  switch (parameter._tag) {
@@ -25,81 +25,11 @@ export const memoizeThunk = f => {
25
25
  };
26
26
  };
27
27
  /** @internal */
28
- export const formatDate = date => {
29
- try {
30
- return date.toISOString();
31
- } catch {
32
- return String(date);
33
- }
34
- };
35
- const CIRCULAR = "[Circular]";
36
- /** @internal */
37
- export function formatUnknown(input, whitespace = 0) {
38
- const seen = new WeakSet();
39
- const gap = !whitespace ? "" : typeof whitespace === "number" ? " ".repeat(whitespace) : whitespace;
40
- const ind = d => gap.repeat(d);
41
- const safeToString = x => {
42
- try {
43
- const s = x.toString();
44
- return typeof s === "string" ? s : String(s);
45
- } catch {
46
- return "[toString threw]";
47
- }
48
- };
49
- const wrap = (v, body) => {
50
- const ctor = v?.constructor;
51
- return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
52
- };
53
- const ownKeys = o => {
54
- try {
55
- return Reflect.ownKeys(o);
56
- } catch {
57
- return ["[ownKeys threw]"];
58
- }
59
- };
60
- function go(v, d = 0) {
61
- if (Array.isArray(v)) {
62
- if (seen.has(v)) return CIRCULAR;
63
- seen.add(v);
64
- if (!gap || v.length <= 1) return `[${v.map(x => go(x, d)).join(",")}]`;
65
- const inner = v.map(x => go(x, d + 1)).join(",\n" + ind(d + 1));
66
- return `[\n${ind(d + 1)}${inner}\n${ind(d)}]`;
67
- }
68
- if (Predicate.isDate(v)) return formatDate(v);
69
- if (Predicate.hasProperty(v, "toString") && Predicate.isFunction(v["toString"]) && v["toString"] !== Object.prototype.toString) return safeToString(v);
70
- if (Predicate.isString(v)) return JSON.stringify(v);
71
- if (Predicate.isNumber(v) || v == null || Predicate.isBoolean(v) || Predicate.isSymbol(v)) return String(v);
72
- if (Predicate.isBigInt(v)) return String(v) + "n";
73
- if (v instanceof Set || v instanceof Map) {
74
- if (seen.has(v)) return CIRCULAR;
75
- seen.add(v);
76
- return `${v.constructor.name}(${go(Array.from(v), d)})`;
77
- }
78
- if (Predicate.isObject(v)) {
79
- if (seen.has(v)) return CIRCULAR;
80
- seen.add(v);
81
- const keys = ownKeys(v);
82
- if (!gap || keys.length <= 1) {
83
- const body = `{${keys.map(k => `${formatPropertyKey(k)}:${go(v[k], d)}`).join(",")}}`;
84
- return wrap(v, body);
85
- }
86
- const body = `{\n${keys.map(k => `${ind(d + 1)}${formatPropertyKey(k)}: ${go(v[k], d + 1)}`).join(",\n")}\n${ind(d)}}`;
87
- return wrap(v, body);
88
- }
89
- return String(v);
90
- }
91
- return go(input, 0);
92
- }
93
- /** @internal */
94
- export function formatPropertyKey(name) {
95
- return Predicate.isString(name) ? JSON.stringify(name) : String(name);
96
- }
97
- /** @internal */
98
28
  export const isNonEmpty = x => Array.isArray(x);
99
29
  /** @internal */
100
30
  export const isSingle = x => !Array.isArray(x);
101
31
  /** @internal */
102
- export const formatPathKey = key => `[${formatPropertyKey(key)}]`;
32
+ export const formatPathKey = key => `[${Inspectable.formatPropertyKey(key)}]`;
103
33
  /** @internal */
104
34
  export const formatPath = path => isNonEmpty(path) ? path.map(formatPathKey).join("") : formatPathKey(path);
105
35
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","names":["Predicate","getKeysForIndexSignature","input","parameter","_tag","Object","keys","getOwnPropertySymbols","from","memoizeThunk","f","done","a","formatDate","date","toISOString","String","CIRCULAR","formatUnknown","whitespace","seen","WeakSet","gap","repeat","ind","d","safeToString","x","s","toString","wrap","v","body","ctor","constructor","prototype","name","ownKeys","o","Reflect","go","Array","isArray","has","add","length","map","join","inner","isDate","hasProperty","isFunction","isString","JSON","stringify","isNumber","isBoolean","isSymbol","isBigInt","Set","Map","isObject","k","formatPropertyKey","isNonEmpty","isSingle","formatPathKey","key","formatPath","path"],"sources":["../../../../src/internal/schema/util.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAKA,SAAS,MAAM,oBAAoB;AAG/C;AACA,OAAO,MAAMC,wBAAwB,GAAGA,CACtCC,KAA6C,EAC7CC,SAAwB,KACyB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CAAC,CAAC;AAEpH;AACA,OAAO,MAAMsC,QAAQ,GAAOtC,CAAuB,IAAa,CAACc,KAAK,CAACC,OAAO,CAACf,CAAC,CAAC;AAEjF;AACA,OAAO,MAAMuC,aAAa,GAAIC,GAAgB,IAAa,IAAIJ,iBAAiB,CAACI,GAAG,CAAC,GAAG;AAExF;AACA,OAAO,MAAMC,UAAU,GAAIC,IAAsB,IAC/CL,UAAU,CAACK,IAAI,CAAC,GAAGA,IAAI,CAACvB,GAAG,CAACoB,aAAa,CAAC,CAACnB,IAAI,CAAC,EAAE,CAAC,GAAGmB,aAAa,CAACG,IAAI,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"util.js","names":["Inspectable","getKeysForIndexSignature","input","parameter","_tag","Object","keys","getOwnPropertySymbols","from","memoizeThunk","f","done","a","isNonEmpty","x","Array","isArray","isSingle","formatPathKey","key","formatPropertyKey","formatPath","path","map","join"],"sources":["../../../../src/internal/schema/util.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAKA,WAAW,MAAM,sBAAsB;AAInD;AACA,OAAO,MAAMC,wBAAwB,GAAGA,CACtCC,KAA6C,EAC7CC,SAAwB,KACyB;EACjD,QAAQA,SAAS,CAACC,IAAI;IACpB,KAAK,eAAe;IACpB,KAAK,iBAAiB;MACpB,OAAOC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;IAC3B,KAAK,eAAe;MAClB,OAAOG,MAAM,CAACE,qBAAqB,CAACL,KAAK,CAAC;IAC5C,KAAK,YAAY;MACf,OAAOD,wBAAwB,CAACC,KAAK,EAAEC,SAAS,CAACK,IAAI,CAAC;EAC1D;AACF,CAAC;AAED;AACA,OAAO,MAAMC,YAAY,GAAOC,CAAU,IAAa;EACrD,IAAIC,IAAI,GAAG,KAAK;EAChB,IAAIC,CAAI;EACR,OAAO,MAAK;IACV,IAAID,IAAI,EAAE;MACR,OAAOC,CAAC;IACV;IACAA,CAAC,GAAGF,CAAC,EAAE;IACPC,IAAI,GAAG,IAAI;IACX,OAAOC,CAAC;EACV,CAAC;AACH,CAAC;AAKD;AACA,OAAO,MAAMC,UAAU,GAAOC,CAAkC,IAAoCC,KAAK,CAACC,OAAO,CAACF,CAAC,CAAC;AAEpH;AACA,OAAO,MAAMG,QAAQ,GAAOH,CAAuB,IAAa,CAACC,KAAK,CAACC,OAAO,CAACF,CAAC,CAAC;AAEjF;AACA,OAAO,MAAMI,aAAa,GAAIC,GAAgB,IAAa,IAAInB,WAAW,CAACoB,iBAAiB,CAACD,GAAG,CAAC,GAAG;AAEpG;AACA,OAAO,MAAME,UAAU,GAAIC,IAAsB,IAC/CT,UAAU,CAACS,IAAI,CAAC,GAAGA,IAAI,CAACC,GAAG,CAACL,aAAa,CAAC,CAACM,IAAI,CAAC,EAAE,CAAC,GAAGN,aAAa,CAACI,IAAI,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.19.2";
1
+ let moduleVersion = "3.19.3";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect",
3
- "version": "3.19.2",
3
+ "version": "3.19.3",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import type * as FiberRefs from "./FiberRefs.js"
5
5
  import { globalValue } from "./GlobalValue.js"
6
- import { hasProperty, isFunction } from "./Predicate.js"
6
+ import * as Predicate from "./Predicate.js"
7
7
 
8
8
  /**
9
9
  * @since 2.0.0
@@ -33,7 +33,7 @@ export interface Inspectable {
33
33
  export const toJSON = (x: unknown): unknown => {
34
34
  try {
35
35
  if (
36
- hasProperty(x, "toJSON") && isFunction(x["toJSON"]) &&
36
+ Predicate.hasProperty(x, "toJSON") && Predicate.isFunction(x["toJSON"]) &&
37
37
  x["toJSON"].length === 0
38
38
  ) {
39
39
  return x.toJSON()
@@ -46,6 +46,119 @@ export const toJSON = (x: unknown): unknown => {
46
46
  return redact(x)
47
47
  }
48
48
 
49
+ const CIRCULAR = "[Circular]"
50
+
51
+ /** @internal */
52
+ export function formatDate(date: Date): string {
53
+ try {
54
+ return date.toISOString()
55
+ } catch {
56
+ return "Invalid Date"
57
+ }
58
+ }
59
+
60
+ function safeToString(input: any): string {
61
+ try {
62
+ const s = input.toString()
63
+ return typeof s === "string" ? s : String(s)
64
+ } catch {
65
+ return "[toString threw]"
66
+ }
67
+ }
68
+
69
+ /** @internal */
70
+ export function formatPropertyKey(name: PropertyKey): string {
71
+ return Predicate.isString(name) ? JSON.stringify(name) : String(name)
72
+ }
73
+
74
+ /** @internal */
75
+ export function formatUnknown(
76
+ input: unknown,
77
+ options?: {
78
+ readonly space?: number | string | undefined
79
+ readonly ignoreToString?: boolean | undefined
80
+ }
81
+ ): string {
82
+ const space = options?.space ?? 0
83
+ const seen = new WeakSet<object>()
84
+ const gap = !space ? "" : (Predicate.isNumber(space) ? " ".repeat(space) : space)
85
+ const ind = (d: number) => gap.repeat(d)
86
+
87
+ const wrap = (v: unknown, body: string): string => {
88
+ const ctor = (v as any)?.constructor
89
+ return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body
90
+ }
91
+
92
+ const ownKeys = (o: object): Array<PropertyKey> => {
93
+ try {
94
+ return Reflect.ownKeys(o)
95
+ } catch {
96
+ return ["[ownKeys threw]"]
97
+ }
98
+ }
99
+
100
+ function go(v: unknown, d = 0): string {
101
+ if (Array.isArray(v)) {
102
+ if (seen.has(v)) return CIRCULAR
103
+ seen.add(v)
104
+ if (!gap || v.length <= 1) return `[${v.map((x) => go(x, d)).join(",")}]`
105
+ const inner = v.map((x) => go(x, d + 1)).join(",\n" + ind(d + 1))
106
+ return `[\n${ind(d + 1)}${inner}\n${ind(d)}]`
107
+ }
108
+
109
+ if (Predicate.isDate(v)) return formatDate(v)
110
+
111
+ if (
112
+ !options?.ignoreToString &&
113
+ Predicate.hasProperty(v, "toString") &&
114
+ Predicate.isFunction(v["toString"]) &&
115
+ v["toString"] !== Object.prototype.toString &&
116
+ v["toString"] !== Array.prototype.toString
117
+ ) {
118
+ const s = safeToString(v)
119
+ if (v instanceof Error && v.cause) {
120
+ return `${s} (cause: ${go(v.cause, d)})`
121
+ }
122
+ return s
123
+ }
124
+
125
+ if (Predicate.isString(v)) return JSON.stringify(v)
126
+
127
+ if (
128
+ Predicate.isNumber(v) ||
129
+ v == null ||
130
+ Predicate.isBoolean(v) ||
131
+ Predicate.isSymbol(v)
132
+ ) return String(v)
133
+
134
+ if (Predicate.isBigInt(v)) return String(v) + "n"
135
+
136
+ if (v instanceof Set || v instanceof Map) {
137
+ if (seen.has(v)) return CIRCULAR
138
+ seen.add(v)
139
+ return `${v.constructor.name}(${go(Array.from(v), d)})`
140
+ }
141
+
142
+ if (Predicate.isObject(v)) {
143
+ if (seen.has(v)) return CIRCULAR
144
+ seen.add(v)
145
+ const keys = ownKeys(v)
146
+ if (!gap || keys.length <= 1) {
147
+ const body = `{${keys.map((k) => `${formatPropertyKey(k)}:${go((v as any)[k], d)}`).join(",")}}`
148
+ return wrap(v, body)
149
+ }
150
+ const body = `{\n${
151
+ keys.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${go((v as any)[k], d + 1)}`).join(",\n")
152
+ }\n${ind(d)}}`
153
+ return wrap(v, body)
154
+ }
155
+
156
+ return String(v)
157
+ }
158
+
159
+ return go(input, 0)
160
+ }
161
+
49
162
  /**
50
163
  * @since 2.0.0
51
164
  */
@@ -1911,7 +1911,7 @@ function getDefaultTypeMessage(issue: Type): string {
1911
1911
  return issue.message
1912
1912
  }
1913
1913
  const expected = AST.isRefinement(issue.ast) ? getRefinementExpected(issue.ast) : String(issue.ast)
1914
- return `Expected ${expected}, actual ${util_.formatUnknown(issue.actual)}`
1914
+ return `Expected ${expected}, actual ${Inspectable.formatUnknown(issue.actual)}`
1915
1915
  }
1916
1916
 
1917
1917
  const formatTypeMessage = (issue: Type): Effect.Effect<string> =>
package/src/Pretty.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @since 3.10.0
3
3
  */
4
4
  import * as Arr from "./Array.js"
5
+ import * as Inspectable from "./Inspectable.js"
5
6
  import * as errors_ from "./internal/schema/errors.js"
6
7
  import * as util_ from "./internal/schema/util.js"
7
8
  import * as Option from "./Option.js"
@@ -43,7 +44,7 @@ const toString = getMatcher((a) => String(a))
43
44
 
44
45
  const stringify = getMatcher((a) => JSON.stringify(a))
45
46
 
46
- const formatUnknown = getMatcher(util_.formatUnknown)
47
+ const formatUnknown = getMatcher(Inspectable.formatUnknown)
47
48
 
48
49
  /**
49
50
  * @since 3.10.0
@@ -142,7 +143,7 @@ export const match: AST.Match<Pretty<any>> = {
142
143
  continue
143
144
  }
144
145
  output.push(
145
- `${util_.formatPropertyKey(name)}: ${propertySignaturesTypes[i](input[name])}`
146
+ `${Inspectable.formatPropertyKey(name)}: ${propertySignaturesTypes[i](input[name])}`
146
147
  )
147
148
  }
148
149
  // ---------------------------------------------
@@ -156,7 +157,7 @@ export const match: AST.Match<Pretty<any>> = {
156
157
  if (Object.prototype.hasOwnProperty.call(expectedKeys, key)) {
157
158
  continue
158
159
  }
159
- output.push(`${util_.formatPropertyKey(key)}: ${type(input[key])}`)
160
+ output.push(`${Inspectable.formatPropertyKey(key)}: ${type(input[key])}`)
160
161
  }
161
162
  }
162
163
  }
package/src/Schema.ts CHANGED
@@ -29,6 +29,7 @@ import { dual, identity } from "./Function.js"
29
29
  import { globalValue } from "./GlobalValue.js"
30
30
  import * as hashMap_ from "./HashMap.js"
31
31
  import * as hashSet_ from "./HashSet.js"
32
+ import * as Inspectable from "./Inspectable.js"
32
33
  import * as internalCause_ from "./internal/cause.js"
33
34
  import * as errors_ from "./internal/schema/errors.js"
34
35
  import * as schemaId_ from "./internal/schema/schemaId.js"
@@ -7128,8 +7129,8 @@ export const lessThanDate = <S extends Schema.Any>(
7128
7129
  filter((a: Date) => a < max, {
7129
7130
  schemaId: LessThanDateSchemaId,
7130
7131
  [LessThanDateSchemaId]: { max },
7131
- title: `lessThanDate(${util_.formatDate(max)})`,
7132
- description: `a date before ${util_.formatDate(max)}`,
7132
+ title: `lessThanDate(${Inspectable.formatDate(max)})`,
7133
+ description: `a date before ${Inspectable.formatDate(max)}`,
7133
7134
  ...annotations
7134
7135
  })
7135
7136
  )
@@ -7155,8 +7156,8 @@ export const lessThanOrEqualToDate = <S extends Schema.Any>(
7155
7156
  filter((a: Date) => a <= max, {
7156
7157
  schemaId: LessThanOrEqualToDateSchemaId,
7157
7158
  [LessThanOrEqualToDateSchemaId]: { max },
7158
- title: `lessThanOrEqualToDate(${util_.formatDate(max)})`,
7159
- description: `a date before or equal to ${util_.formatDate(max)}`,
7159
+ title: `lessThanOrEqualToDate(${Inspectable.formatDate(max)})`,
7160
+ description: `a date before or equal to ${Inspectable.formatDate(max)}`,
7160
7161
  ...annotations
7161
7162
  })
7162
7163
  )
@@ -7180,8 +7181,8 @@ export const greaterThanDate = <S extends Schema.Any>(
7180
7181
  filter((a: Date) => a > min, {
7181
7182
  schemaId: GreaterThanDateSchemaId,
7182
7183
  [GreaterThanDateSchemaId]: { min },
7183
- title: `greaterThanDate(${util_.formatDate(min)})`,
7184
- description: `a date after ${util_.formatDate(min)}`,
7184
+ title: `greaterThanDate(${Inspectable.formatDate(min)})`,
7185
+ description: `a date after ${Inspectable.formatDate(min)}`,
7185
7186
  ...annotations
7186
7187
  })
7187
7188
  )
@@ -7207,8 +7208,8 @@ export const greaterThanOrEqualToDate = <S extends Schema.Any>(
7207
7208
  filter((a: Date) => a >= min, {
7208
7209
  schemaId: GreaterThanOrEqualToDateSchemaId,
7209
7210
  [GreaterThanOrEqualToDateSchemaId]: { min },
7210
- title: `greaterThanOrEqualToDate(${util_.formatDate(min)})`,
7211
- description: `a date after or equal to ${util_.formatDate(min)}`,
7211
+ title: `greaterThanOrEqualToDate(${Inspectable.formatDate(min)})`,
7212
+ description: `a date after or equal to ${Inspectable.formatDate(min)}`,
7212
7213
  ...annotations
7213
7214
  })
7214
7215
  )
@@ -7233,8 +7234,8 @@ export const betweenDate = <S extends Schema.Any>(
7233
7234
  filter((a: Date) => a <= max && a >= min, {
7234
7235
  schemaId: BetweenDateSchemaId,
7235
7236
  [BetweenDateSchemaId]: { max, min },
7236
- title: `betweenDate(${util_.formatDate(min)}, ${util_.formatDate(max)})`,
7237
- description: `a date between ${util_.formatDate(min)} and ${util_.formatDate(max)}`,
7237
+ title: `betweenDate(${Inspectable.formatDate(min)}, ${Inspectable.formatDate(max)})`,
7238
+ description: `a date between ${Inspectable.formatDate(min)} and ${Inspectable.formatDate(max)}`,
7238
7239
  ...annotations
7239
7240
  })
7240
7241
  )
@@ -7303,7 +7304,7 @@ export class DateFromString extends transform(
7303
7304
  {
7304
7305
  strict: true,
7305
7306
  decode: (i) => new Date(i),
7306
- encode: (a) => util_.formatDate(a)
7307
+ encode: (a) => Inspectable.formatDate(a)
7307
7308
  }
7308
7309
  ).annotations({ identifier: "DateFromString" }) {}
7309
7310
 
@@ -7366,7 +7367,8 @@ export class DateTimeUtcFromSelf extends declare(
7366
7367
  const decodeDateTimeUtc = <A extends dateTime.DateTime.Input>(input: A, ast: AST.AST) =>
7367
7368
  ParseResult.try({
7368
7369
  try: () => dateTime.unsafeMake(input),
7369
- catch: () => new ParseResult.Type(ast, input, `Unable to decode ${util_.formatUnknown(input)} into a DateTime.Utc`)
7370
+ catch: () =>
7371
+ new ParseResult.Type(ast, input, `Unable to decode ${Inspectable.formatUnknown(input)} into a DateTime.Utc`)
7370
7372
  })
7371
7373
 
7372
7374
  /**
@@ -9328,7 +9330,7 @@ export const TaggedError = <Self = never>(identifier?: string) =>
9328
9330
  get() {
9329
9331
  return `{ ${
9330
9332
  Reflect.ownKeys(fields)
9331
- .map((p: any) => `${util_.formatPropertyKey(p)}: ${util_.formatUnknown((this)[p])}`)
9333
+ .map((p: any) => `${Inspectable.formatPropertyKey(p)}: ${Inspectable.formatUnknown((this)[p])}`)
9332
9334
  .join(", ")
9333
9335
  } }`
9334
9336
  },
@@ -9593,7 +9595,9 @@ const makeClass = <Fields extends Struct.Fields>(
9593
9595
  Object.defineProperty(klass.prototype, "toString", {
9594
9596
  value() {
9595
9597
  return `${identifier}({ ${
9596
- Reflect.ownKeys(fields).map((p: any) => `${util_.formatPropertyKey(p)}: ${util_.formatUnknown(this[p])}`)
9598
+ Reflect.ownKeys(fields).map((p: any) =>
9599
+ `${Inspectable.formatPropertyKey(p)}: ${Inspectable.formatUnknown(this[p])}`
9600
+ )
9597
9601
  .join(", ")
9598
9602
  } })`
9599
9603
  },
package/src/SchemaAST.ts CHANGED
@@ -7,6 +7,7 @@ import type { Effect } from "./Effect.js"
7
7
  import type { Equivalence } from "./Equivalence.js"
8
8
  import { dual, identity } from "./Function.js"
9
9
  import { globalValue } from "./GlobalValue.js"
10
+ import * as Inspectable from "./Inspectable.js"
10
11
  import * as errors_ from "./internal/schema/errors.js"
11
12
  import * as util_ from "./internal/schema/util.js"
12
13
  import * as Number from "./Number.js"
@@ -541,7 +542,7 @@ export class Literal implements Annotated {
541
542
  * @since 3.10.0
542
543
  */
543
544
  toString() {
544
- return Option.getOrElse(getExpected(this), () => util_.formatUnknown(this.literal))
545
+ return Option.getOrElse(getExpected(this), () => Inspectable.formatUnknown(this.literal))
545
546
  }
546
547
  /**
547
548
  * @since 3.10.0
@@ -585,7 +586,7 @@ export class UniqueSymbol implements Annotated {
585
586
  * @since 3.10.0
586
587
  */
587
588
  toString() {
588
- return Option.getOrElse(getExpected(this), () => util_.formatUnknown(this.symbol))
589
+ return Option.getOrElse(getExpected(this), () => Inspectable.formatUnknown(this.symbol))
589
590
  }
590
591
  /**
591
592
  * @since 3.10.0
@@ -2976,7 +2977,7 @@ const formatKeyword = (ast: AST): string => Option.getOrElse(getExpected(ast), (
2976
2977
  function getBrands(ast: Annotated): string {
2977
2978
  return Option.match(getBrandAnnotation(ast), {
2978
2979
  onNone: () => "",
2979
- onSome: (brands) => brands.map((brand) => ` & Brand<${util_.formatUnknown(brand)}>`).join("")
2980
+ onSome: (brands) => brands.map((brand) => ` & Brand<${Inspectable.formatUnknown(brand)}>`).join("")
2980
2981
  })
2981
2982
  }
2982
2983
 
@@ -8,6 +8,7 @@ import type { LazyArg } from "../Function.js"
8
8
  import { constTrue, dual, pipe } from "../Function.js"
9
9
  import type * as HashMap from "../HashMap.js"
10
10
  import * as HashSet from "../HashSet.js"
11
+ import { formatUnknown } from "../Inspectable.js"
11
12
  import type * as LogLevel from "../LogLevel.js"
12
13
  import * as Option from "../Option.js"
13
14
  import { hasProperty, type Predicate, type Refinement } from "../Predicate.js"
@@ -170,7 +171,7 @@ export const boolean = (name?: string): Config.Config<boolean> => {
170
171
  default: {
171
172
  const error = configError.InvalidData(
172
173
  [],
173
- `Expected a boolean value but received ${text}`
174
+ `Expected a boolean value but received ${formatUnknown(text)}`
174
175
  )
175
176
  return Either.left(error)
176
177
  }
@@ -187,7 +188,7 @@ export const url = (name?: string): Config.Config<URL> => {
187
188
  (text) =>
188
189
  Either.try({
189
190
  try: () => new URL(text),
190
- catch: (_) => configError.InvalidData([], `Expected an URL value but received ${text}`)
191
+ catch: (_) => configError.InvalidData([], `Expected an URL value but received ${formatUnknown(text)}`)
191
192
  })
192
193
  )
193
194
  return name === undefined ? config : nested(config, name)
@@ -210,7 +211,7 @@ export const port = (name?: string): Config.Config<number> => {
210
211
  return Either.left(
211
212
  configError.InvalidData(
212
213
  [],
213
- `Expected a network port value but received ${text}`
214
+ `Expected a network port value but received ${formatUnknown(text)}`
214
215
  )
215
216
  )
216
217
  }
@@ -240,7 +241,7 @@ export const date = (name?: string): Config.Config<Date> => {
240
241
  return Either.left(
241
242
  configError.InvalidData(
242
243
  [],
243
- `Expected a Date value but received ${text}`
244
+ `Expected a Date value but received ${formatUnknown(text)}`
244
245
  )
245
246
  )
246
247
  }
@@ -269,7 +270,7 @@ export const number = (name?: string): Config.Config<number> => {
269
270
  return Either.left(
270
271
  configError.InvalidData(
271
272
  [],
272
- `Expected a number value but received ${text}`
273
+ `Expected a number value but received ${formatUnknown(text)}`
273
274
  )
274
275
  )
275
276
  }
@@ -289,7 +290,7 @@ export const integer = (name?: string): Config.Config<number> => {
289
290
  return Either.left(
290
291
  configError.InvalidData(
291
292
  [],
292
- `Expected an integer value but received ${text}`
293
+ `Expected an integer value but received ${formatUnknown(text)}`
293
294
  )
294
295
  )
295
296
  }
@@ -311,7 +312,7 @@ export const literal = <Literals extends ReadonlyArray<Config.LiteralValue>>(...
311
312
  return Either.left(
312
313
  configError.InvalidData(
313
314
  [],
314
- `Expected one of (${valuesString}) but received ${text}`
315
+ `Expected one of (${valuesString}) but received ${formatUnknown(text)}`
315
316
  )
316
317
  )
317
318
  }
@@ -326,7 +327,9 @@ export const logLevel = (name?: string): Config.Config<LogLevel.LogLevel> => {
326
327
  const label = value.toUpperCase()
327
328
  const level = core.allLogLevels.find((level) => level.label === label)
328
329
  return level === undefined
329
- ? Either.left(configError.InvalidData([], `Expected a log level but received ${value}`))
330
+ ? Either.left(
331
+ configError.InvalidData([], `Expected a log level but received ${formatUnknown(value)}`)
332
+ )
330
333
  : Either.right(level)
331
334
  })
332
335
  return name === undefined ? config : nested(config, name)
@@ -336,7 +339,10 @@ export const logLevel = (name?: string): Config.Config<LogLevel.LogLevel> => {
336
339
  export const duration = (name?: string): Config.Config<Duration.Duration> => {
337
340
  const config = mapOrFail(string(), (value) => {
338
341
  const duration = Duration.decodeUnknown(value)
339
- return Either.fromOption(duration, () => configError.InvalidData([], `Expected a duration but received ${value}`))
342
+ return Either.fromOption(
343
+ duration,
344
+ () => configError.InvalidData([], `Expected a duration but received ${formatUnknown(value)}`)
345
+ )
340
346
  })
341
347
  return name === undefined ? config : nested(config, name)
342
348
  }
@@ -1,4 +1,5 @@
1
1
  import * as array_ from "../../Array.js"
2
+ import * as Inspectable from "../../Inspectable.js"
2
3
  import type * as AST from "../../SchemaAST.js"
3
4
  import * as util_ from "./util.js"
4
5
 
@@ -105,7 +106,7 @@ export const getJSONSchemaUnsupportedPostRestElementsErrorMessage = (path: Reado
105
106
 
106
107
  /** @internal */
107
108
  export const getJSONSchemaUnsupportedKeyErrorMessage = (key: PropertyKey, path: ReadonlyArray<PropertyKey>): string =>
108
- getErrorMessage("Unsupported key", `Cannot encode ${util_.formatPropertyKey(key)} key to JSON Schema`, path)
109
+ getErrorMessage("Unsupported key", `Cannot encode ${Inspectable.formatPropertyKey(key)} key to JSON Schema`, path)
109
110
 
110
111
  // ---------------------------------------------
111
112
  // Pretty
@@ -125,7 +126,13 @@ export const getPrettyNoMatchingSchemaErrorMessage = (
125
126
  actual: unknown,
126
127
  path: ReadonlyArray<PropertyKey>,
127
128
  ast: AST.AST
128
- ) => getErrorMessage("Unexpected Error", `Cannot find a matching schema for ${util_.formatUnknown(actual)}`, path, ast)
129
+ ) =>
130
+ getErrorMessage(
131
+ "Unexpected Error",
132
+ `Cannot find a matching schema for ${Inspectable.formatUnknown(actual)}`,
133
+ path,
134
+ ast
135
+ )
129
136
 
130
137
  // ---------------------------------------------
131
138
  // Schema
@@ -153,7 +160,7 @@ export const getASTUnsupportedKeySchemaErrorMessage = (ast: AST.AST) =>
153
160
 
154
161
  /** @internal */
155
162
  export const getASTUnsupportedLiteralErrorMessage = (literal: AST.LiteralValue) =>
156
- getErrorMessage("Unsupported literal", `literal value: ${util_.formatUnknown(literal)}`)
163
+ getErrorMessage("Unsupported literal", `literal value: ${Inspectable.formatUnknown(literal)}`)
157
164
 
158
165
  /** @internal */
159
166
  export const getASTDuplicateIndexSignatureErrorMessage = (type: "string" | "symbol"): string =>
@@ -173,7 +180,7 @@ export const getASTRequiredElementFollowinAnOptionalElementErrorMessage = getErr
173
180
 
174
181
  /** @internal */
175
182
  export const getASTDuplicatePropertySignatureTransformationErrorMessage = (key: PropertyKey): string =>
176
- getErrorMessage("Duplicate property signature transformation", `Duplicate key ${util_.formatUnknown(key)}`)
183
+ getErrorMessage("Duplicate property signature transformation", `Duplicate key ${Inspectable.formatUnknown(key)}`)
177
184
 
178
185
  /** @internal */
179
186
  export const getASTUnsupportedRenameSchemaErrorMessage = (ast: AST.AST): string =>
@@ -181,4 +188,4 @@ export const getASTUnsupportedRenameSchemaErrorMessage = (ast: AST.AST): string
181
188
 
182
189
  /** @internal */
183
190
  export const getASTDuplicatePropertySignatureErrorMessage = (key: PropertyKey): string =>
184
- getErrorMessage("Duplicate property signature", `Duplicate key ${util_.formatUnknown(key)}`)
191
+ getErrorMessage("Duplicate property signature", `Duplicate key ${Inspectable.formatUnknown(key)}`)