effect 3.9.2 → 3.10.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/Arbitrary/package.json +6 -0
- package/FastCheck/package.json +6 -0
- package/JSONSchema/package.json +6 -0
- package/ParseResult/package.json +6 -0
- package/Pretty/package.json +6 -0
- package/Schema/package.json +6 -0
- package/SchemaAST/package.json +6 -0
- package/TSubscriptionRef/package.json +6 -0
- package/dist/cjs/Arbitrary.js +490 -0
- package/dist/cjs/Arbitrary.js.map +1 -0
- package/dist/cjs/Effect.js +247 -16
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FastCheck.js +17 -0
- package/dist/cjs/FastCheck.js.map +1 -0
- package/dist/cjs/Inspectable.js +43 -3
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/JSONSchema.js +418 -0
- package/dist/cjs/JSONSchema.js.map +1 -0
- package/dist/cjs/ParseResult.js +1539 -0
- package/dist/cjs/ParseResult.js.map +1 -0
- package/dist/cjs/Predicate.js +3 -1
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Pretty.js +183 -0
- package/dist/cjs/Pretty.js.map +1 -0
- package/dist/cjs/Schema.js +5529 -0
- package/dist/cjs/Schema.js.map +1 -0
- package/dist/cjs/SchemaAST.js +2365 -0
- package/dist/cjs/SchemaAST.js.map +1 -0
- package/dist/cjs/Stream.js +17 -3
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/TPubSub.js +9 -1
- package/dist/cjs/TPubSub.js.map +1 -1
- package/dist/cjs/TQueue.js.map +1 -1
- package/dist/cjs/TRef.js.map +1 -1
- package/dist/cjs/TSubscriptionRef.js +96 -0
- package/dist/cjs/TSubscriptionRef.js.map +1 -0
- package/dist/cjs/index.js +18 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/cause.js +2 -2
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/core.js +4 -4
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +14 -12
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/logger.js +7 -6
- package/dist/cjs/internal/logger.js.map +1 -1
- package/dist/cjs/internal/redacted.js +4 -0
- package/dist/cjs/internal/redacted.js.map +1 -1
- package/dist/cjs/internal/schema/errors.js +116 -0
- package/dist/cjs/internal/schema/errors.js.map +1 -0
- package/dist/cjs/internal/schema/filters.js +41 -0
- package/dist/cjs/internal/schema/filters.js.map +1 -0
- package/dist/cjs/internal/schema/util.js +96 -0
- package/dist/cjs/internal/schema/util.js.map +1 -0
- package/dist/cjs/internal/stm/core.js +2 -3
- package/dist/cjs/internal/stm/core.js.map +1 -1
- package/dist/cjs/internal/stm/tPubSub.js.map +1 -1
- package/dist/cjs/internal/stm/tQueue.js +1 -2
- package/dist/cjs/internal/stm/tQueue.js.map +1 -1
- package/dist/cjs/internal/stm/tRef.js +6 -2
- package/dist/cjs/internal/stm/tRef.js.map +1 -1
- package/dist/cjs/internal/stm/tSubscriptionRef.js +178 -0
- package/dist/cjs/internal/stm/tSubscriptionRef.js.map +1 -0
- package/dist/cjs/internal/stream.js +36 -16
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Arbitrary.d.ts +45 -0
- package/dist/dts/Arbitrary.d.ts.map +1 -0
- package/dist/dts/Effect.d.ts +298 -30
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FastCheck.d.ts +9 -0
- package/dist/dts/FastCheck.d.ts.map +1 -0
- package/dist/dts/Inspectable.d.ts +28 -0
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +181 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -0
- package/dist/dts/ParseResult.d.ts +551 -0
- package/dist/dts/ParseResult.d.ts.map +1 -0
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Pretty.d.ts +26 -0
- package/dist/dts/Pretty.d.ts.map +1 -0
- package/dist/dts/Schema.d.ts +4562 -0
- package/dist/dts/Schema.d.ts.map +1 -0
- package/dist/dts/SchemaAST.d.ts +1321 -0
- package/dist/dts/SchemaAST.d.ts.map +1 -0
- package/dist/dts/Stream.d.ts +67 -2
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/TPubSub.d.ts +8 -0
- package/dist/dts/TPubSub.d.ts.map +1 -1
- package/dist/dts/TQueue.d.ts +7 -7
- package/dist/dts/TQueue.d.ts.map +1 -1
- package/dist/dts/TRef.d.ts +2 -1
- package/dist/dts/TRef.d.ts.map +1 -1
- package/dist/dts/TSubscriptionRef.d.ts +251 -0
- package/dist/dts/TSubscriptionRef.d.ts.map +1 -0
- package/dist/dts/index.d.ts +32 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/schema/errors.d.ts +2 -0
- package/dist/dts/internal/schema/errors.d.ts.map +1 -0
- package/dist/dts/internal/schema/filters.d.ts +2 -0
- package/dist/dts/internal/schema/filters.d.ts.map +1 -0
- package/dist/dts/internal/schema/util.d.ts +2 -0
- package/dist/dts/internal/schema/util.d.ts.map +1 -0
- package/dist/dts/internal/stm/tRef.d.ts +3 -1
- package/dist/dts/internal/stm/tRef.d.ts.map +1 -1
- package/dist/dts/internal/stm/tSubscriptionRef.d.ts +2 -0
- package/dist/dts/internal/stm/tSubscriptionRef.d.ts.map +1 -0
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Arbitrary.js +472 -0
- package/dist/esm/Arbitrary.js.map +1 -0
- package/dist/esm/Effect.js +256 -18
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FastCheck.js +9 -0
- package/dist/esm/FastCheck.js.map +1 -0
- package/dist/esm/Inspectable.js +39 -2
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/JSONSchema.js +408 -0
- package/dist/esm/JSONSchema.js.map +1 -0
- package/dist/esm/ParseResult.js +1503 -0
- package/dist/esm/ParseResult.js.map +1 -0
- package/dist/esm/Predicate.js +2 -1
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Pretty.js +173 -0
- package/dist/esm/Pretty.js.map +1 -0
- package/dist/esm/Schema.js +5328 -0
- package/dist/esm/Schema.js.map +1 -0
- package/dist/esm/SchemaAST.js +2300 -0
- package/dist/esm/SchemaAST.js.map +1 -0
- package/dist/esm/Stream.js +14 -0
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/TPubSub.js +8 -0
- package/dist/esm/TPubSub.js.map +1 -1
- package/dist/esm/TQueue.js.map +1 -1
- package/dist/esm/TRef.js.map +1 -1
- package/dist/esm/TSubscriptionRef.js +87 -0
- package/dist/esm/TSubscriptionRef.js.map +1 -0
- package/dist/esm/index.js +32 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/cause.js +3 -3
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/core.js +4 -4
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +14 -12
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/logger.js +7 -6
- package/dist/esm/internal/logger.js.map +1 -1
- package/dist/esm/internal/redacted.js +4 -0
- package/dist/esm/internal/redacted.js.map +1 -1
- package/dist/esm/internal/schema/errors.js +87 -0
- package/dist/esm/internal/schema/errors.js.map +1 -0
- package/dist/esm/internal/schema/filters.js +35 -0
- package/dist/esm/internal/schema/filters.js.map +1 -0
- package/dist/esm/internal/schema/util.js +78 -0
- package/dist/esm/internal/schema/util.js.map +1 -0
- package/dist/esm/internal/stm/core.js +1 -2
- package/dist/esm/internal/stm/core.js.map +1 -1
- package/dist/esm/internal/stm/tPubSub.js.map +1 -1
- package/dist/esm/internal/stm/tQueue.js +1 -2
- package/dist/esm/internal/stm/tQueue.js.map +1 -1
- package/dist/esm/internal/stm/tRef.js +5 -1
- package/dist/esm/internal/stm/tRef.js.map +1 -1
- package/dist/esm/internal/stm/tSubscriptionRef.js +166 -0
- package/dist/esm/internal/stm/tSubscriptionRef.js.map +1 -0
- package/dist/esm/internal/stream.js +33 -15
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +68 -1
- package/src/Arbitrary.ts +563 -0
- package/src/Effect.ts +302 -31
- package/src/FastCheck.ts +9 -0
- package/src/Inspectable.ts +56 -2
- package/src/JSONSchema.ts +601 -0
- package/src/ParseResult.ts +2027 -0
- package/src/Predicate.ts +3 -1
- package/src/Pretty.ts +204 -0
- package/src/Schema.ts +10388 -0
- package/src/SchemaAST.ts +2827 -0
- package/src/Stream.ts +77 -9
- package/src/TPubSub.ts +9 -0
- package/src/TQueue.ts +7 -7
- package/src/TRef.ts +2 -1
- package/src/TSubscriptionRef.ts +284 -0
- package/src/index.ts +40 -0
- package/src/internal/cause.ts +3 -3
- package/src/internal/core-effect.ts +2 -2
- package/src/internal/core.ts +4 -4
- package/src/internal/fiberRuntime.ts +14 -12
- package/src/internal/logger.ts +7 -6
- package/src/internal/redacted.ts +4 -0
- package/src/internal/schema/errors.ts +189 -0
- package/src/internal/schema/filters.ts +86 -0
- package/src/internal/schema/util.ts +113 -0
- package/src/internal/stm/core.ts +1 -2
- package/src/internal/stm/tPubSub.ts +1 -0
- package/src/internal/stm/tQueue.ts +2 -2
- package/src/internal/stm/tRef.ts +7 -2
- package/src/internal/stm/tSubscriptionRef.ts +286 -0
- package/src/internal/stream.ts +97 -20
- package/src/internal/version.ts +1 -1
package/src/internal/logger.ts
CHANGED
|
@@ -341,7 +341,7 @@ export const structuredMessage = (u: unknown): unknown => {
|
|
|
341
341
|
return String(u)
|
|
342
342
|
}
|
|
343
343
|
default: {
|
|
344
|
-
return u
|
|
344
|
+
return Inspectable.toJSON(u)
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
}
|
|
@@ -488,13 +488,13 @@ const prettyLoggerTty = (options: {
|
|
|
488
488
|
|
|
489
489
|
if (messageIndex < message.length) {
|
|
490
490
|
for (; messageIndex < message.length; messageIndex++) {
|
|
491
|
-
log(message[messageIndex])
|
|
491
|
+
log(Inspectable.redact(message[messageIndex]))
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
if (HashMap.size(annotations) > 0) {
|
|
496
496
|
for (const [key, value] of annotations) {
|
|
497
|
-
log(color(`${key}:`, colors.bold, colors.white), value)
|
|
497
|
+
log(color(`${key}:`, colors.bold, colors.white), Inspectable.redact(value))
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
|
|
@@ -553,16 +553,17 @@ const prettyLoggerBrowser = (options: {
|
|
|
553
553
|
|
|
554
554
|
if (messageIndex < message.length) {
|
|
555
555
|
for (; messageIndex < message.length; messageIndex++) {
|
|
556
|
-
console.log(message[messageIndex])
|
|
556
|
+
console.log(Inspectable.redact(message[messageIndex]))
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
if (HashMap.size(annotations) > 0) {
|
|
561
561
|
for (const [key, value] of annotations) {
|
|
562
|
+
const redacted = Inspectable.redact(value)
|
|
562
563
|
if (options.colors) {
|
|
563
|
-
console.log(`%c${key}:`, "color:gray",
|
|
564
|
+
console.log(`%c${key}:`, "color:gray", redacted)
|
|
564
565
|
} else {
|
|
565
|
-
console.log(`${key}:`,
|
|
566
|
+
console.log(`${key}:`, redacted)
|
|
566
567
|
}
|
|
567
568
|
}
|
|
568
569
|
}
|
package/src/internal/redacted.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NodeInspectSymbol } from "effect/Inspectable"
|
|
1
2
|
import * as Equal from "../Equal.js"
|
|
2
3
|
import { pipe } from "../Function.js"
|
|
3
4
|
import { globalValue } from "../GlobalValue.js"
|
|
@@ -34,6 +35,9 @@ export const proto = {
|
|
|
34
35
|
toJSON() {
|
|
35
36
|
return "<redacted>"
|
|
36
37
|
},
|
|
38
|
+
[NodeInspectSymbol]() {
|
|
39
|
+
return "<redacted>"
|
|
40
|
+
},
|
|
37
41
|
[Hash.symbol]<T>(this: Redacted.Redacted<T>): number {
|
|
38
42
|
return pipe(
|
|
39
43
|
Hash.hash(RedactedSymbolKey),
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import * as array_ from "effect/Array"
|
|
2
|
+
import type * as AST from "../../SchemaAST.js"
|
|
3
|
+
import * as util_ from "./util.js"
|
|
4
|
+
|
|
5
|
+
const getErrorMessage = (
|
|
6
|
+
reason: string,
|
|
7
|
+
details?: string,
|
|
8
|
+
path?: ReadonlyArray<PropertyKey>,
|
|
9
|
+
ast?: AST.AST
|
|
10
|
+
): string => {
|
|
11
|
+
let out = reason
|
|
12
|
+
|
|
13
|
+
if (path && array_.isNonEmptyReadonlyArray(path)) {
|
|
14
|
+
out += `\nat path: ${util_.formatPath(path)}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (details !== undefined) {
|
|
18
|
+
out += `\ndetails: ${details}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (ast) {
|
|
22
|
+
out += `\nschema (${ast._tag}): ${ast}`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return out
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ---------------------------------------------
|
|
29
|
+
// generic
|
|
30
|
+
// ---------------------------------------------
|
|
31
|
+
|
|
32
|
+
/** @internal */
|
|
33
|
+
export const getInvalidArgumentErrorMessage = (details: string) => getErrorMessage("Invalid Argument", details)
|
|
34
|
+
|
|
35
|
+
const getUnsupportedSchemaErrorMessage = (details?: string, path?: ReadonlyArray<PropertyKey>, ast?: AST.AST): string =>
|
|
36
|
+
getErrorMessage("Unsupported schema", details, path, ast)
|
|
37
|
+
|
|
38
|
+
const getMissingAnnotationErrorMessage = (details?: string, path?: ReadonlyArray<PropertyKey>, ast?: AST.AST): string =>
|
|
39
|
+
getErrorMessage("Missing annotation", details, path, ast)
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------
|
|
42
|
+
// Arbitrary
|
|
43
|
+
// ---------------------------------------------
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const getArbitraryUnsupportedErrorMessage = (path: ReadonlyArray<PropertyKey>, ast: AST.AST) =>
|
|
47
|
+
getUnsupportedSchemaErrorMessage("Cannot build an Arbitrary for this schema", path, ast)
|
|
48
|
+
|
|
49
|
+
/** @internal */
|
|
50
|
+
export const getArbitraryMissingAnnotationErrorMessage = (
|
|
51
|
+
path: ReadonlyArray<PropertyKey>,
|
|
52
|
+
ast: AST.AST
|
|
53
|
+
) =>
|
|
54
|
+
getMissingAnnotationErrorMessage(
|
|
55
|
+
`Generating an Arbitrary for this schema requires an "arbitrary" annotation`,
|
|
56
|
+
path,
|
|
57
|
+
ast
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
export const getArbitraryEmptyEnumErrorMessage = (path: ReadonlyArray<PropertyKey>) =>
|
|
62
|
+
getErrorMessage("Empty Enums schema", "Generating an Arbitrary for this schema requires at least one enum", path)
|
|
63
|
+
|
|
64
|
+
// ---------------------------------------------
|
|
65
|
+
// Equivalence
|
|
66
|
+
// ---------------------------------------------
|
|
67
|
+
|
|
68
|
+
/** @internal */
|
|
69
|
+
export const getEquivalenceUnsupportedErrorMessage = (ast: AST.AST, path: ReadonlyArray<PropertyKey>) =>
|
|
70
|
+
getUnsupportedSchemaErrorMessage("Cannot build an Equivalence", path, ast)
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------
|
|
73
|
+
// JSON Schema
|
|
74
|
+
// ---------------------------------------------
|
|
75
|
+
|
|
76
|
+
/** @internal */
|
|
77
|
+
export const getJSONSchemaMissingAnnotationErrorMessage = (
|
|
78
|
+
path: ReadonlyArray<PropertyKey>,
|
|
79
|
+
ast: AST.AST
|
|
80
|
+
) =>
|
|
81
|
+
getMissingAnnotationErrorMessage(
|
|
82
|
+
`Generating a JSON Schema for this schema requires a "jsonSchema" annotation`,
|
|
83
|
+
path,
|
|
84
|
+
ast
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
/** @internal */
|
|
88
|
+
export const getJSONSchemaMissingIdentifierAnnotationErrorMessage = (
|
|
89
|
+
path: ReadonlyArray<PropertyKey>,
|
|
90
|
+
ast: AST.AST
|
|
91
|
+
) =>
|
|
92
|
+
getMissingAnnotationErrorMessage(
|
|
93
|
+
`Generating a JSON Schema for this schema requires an "identifier" annotation`,
|
|
94
|
+
path,
|
|
95
|
+
ast
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
/** @internal */
|
|
99
|
+
export const getJSONSchemaUnsupportedParameterErrorMessage = (
|
|
100
|
+
path: ReadonlyArray<PropertyKey>,
|
|
101
|
+
parameter: AST.AST
|
|
102
|
+
): string => getErrorMessage("Unsupported index signature parameter", undefined, path, parameter)
|
|
103
|
+
|
|
104
|
+
/** @internal */
|
|
105
|
+
export const getJSONSchemaUnsupportedPostRestElementsErrorMessage = (path: ReadonlyArray<PropertyKey>): string =>
|
|
106
|
+
getErrorMessage(
|
|
107
|
+
"Generating a JSON Schema for post-rest elements is not currently supported. You're welcome to contribute by submitting a Pull Request",
|
|
108
|
+
undefined,
|
|
109
|
+
path
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
/** @internal */
|
|
113
|
+
export const getJSONSchemaUnsupportedKeyErrorMessage = (key: PropertyKey, path: ReadonlyArray<PropertyKey>): string =>
|
|
114
|
+
getErrorMessage("Unsupported key", `Cannot encode ${util_.formatPropertyKey(key)} key to JSON Schema`, path)
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------
|
|
117
|
+
// Pretty
|
|
118
|
+
// ---------------------------------------------
|
|
119
|
+
|
|
120
|
+
/** @internal */
|
|
121
|
+
export const getPrettyMissingAnnotationErrorMessage = (
|
|
122
|
+
path: ReadonlyArray<PropertyKey>,
|
|
123
|
+
ast: AST.AST
|
|
124
|
+
) => getMissingAnnotationErrorMessage(`Generating a Pretty for this schema requires a "pretty" annotation`, path, ast)
|
|
125
|
+
|
|
126
|
+
/** @internal */
|
|
127
|
+
export const getPrettyNeverErrorMessage = "Cannot pretty print a `never` value"
|
|
128
|
+
|
|
129
|
+
/** @internal */
|
|
130
|
+
export const getPrettyNoMatchingSchemaErrorMessage = (
|
|
131
|
+
actual: unknown,
|
|
132
|
+
path: ReadonlyArray<PropertyKey>,
|
|
133
|
+
ast: AST.AST
|
|
134
|
+
) => getErrorMessage("Unexpected Error", `Cannot find a matching schema for ${util_.formatUnknown(actual)}`, path, ast)
|
|
135
|
+
|
|
136
|
+
// ---------------------------------------------
|
|
137
|
+
// Schema
|
|
138
|
+
// ---------------------------------------------
|
|
139
|
+
|
|
140
|
+
/** @internal */
|
|
141
|
+
export const getSchemaExtendErrorMessage = (x: AST.AST, y: AST.AST, path: ReadonlyArray<PropertyKey>) =>
|
|
142
|
+
getErrorMessage("Unsupported schema or overlapping types", `cannot extend ${x} with ${y}`, path)
|
|
143
|
+
|
|
144
|
+
/** @internal */
|
|
145
|
+
export const getSchemaUnsupportedLiteralSpanErrorMessage = (ast: AST.AST) =>
|
|
146
|
+
getErrorMessage("Unsupported template literal span", undefined, undefined, ast)
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------
|
|
149
|
+
// AST
|
|
150
|
+
// ---------------------------------------------
|
|
151
|
+
|
|
152
|
+
/** @internal */
|
|
153
|
+
export const getASTUnsupportedSchema = (ast: AST.AST) => getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
|
|
154
|
+
|
|
155
|
+
/** @internal */
|
|
156
|
+
export const getASTUnsupportedKeySchema = (ast: AST.AST) =>
|
|
157
|
+
getErrorMessage("Unsupported key schema", undefined, undefined, ast)
|
|
158
|
+
|
|
159
|
+
/** @internal */
|
|
160
|
+
export const getASTUnsupportedLiteral = (literal: AST.LiteralValue) =>
|
|
161
|
+
getErrorMessage("Unsupported literal", `literal value: ${util_.formatUnknown(literal)}`)
|
|
162
|
+
|
|
163
|
+
/** @internal */
|
|
164
|
+
export const getASTDuplicateIndexSignatureErrorMessage = (type: "string" | "symbol"): string =>
|
|
165
|
+
getErrorMessage("Duplicate index signature", `${type} index signature`)
|
|
166
|
+
|
|
167
|
+
/** @internal */
|
|
168
|
+
export const getASTIndexSignatureParameterErrorMessage = getErrorMessage(
|
|
169
|
+
"Unsupported index signature parameter",
|
|
170
|
+
"An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
/** @internal */
|
|
174
|
+
export const getASTRequiredElementFollowinAnOptionalElementErrorMessage = getErrorMessage(
|
|
175
|
+
"Invalid element",
|
|
176
|
+
"A required element cannot follow an optional element. ts(1257)"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
/** @internal */
|
|
180
|
+
export const getASTDuplicatePropertySignatureTransformationErrorMessage = (key: PropertyKey): string =>
|
|
181
|
+
getErrorMessage("Duplicate property signature transformation", `Duplicate key ${util_.formatUnknown(key)}`)
|
|
182
|
+
|
|
183
|
+
/** @internal */
|
|
184
|
+
export const getASTUnsupportedRenameSchema = (ast: AST.AST): string =>
|
|
185
|
+
getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
|
|
186
|
+
|
|
187
|
+
/** @internal */
|
|
188
|
+
export const getASTDuplicatePropertySignatureErrorMessage = (key: PropertyKey): string =>
|
|
189
|
+
getErrorMessage("Duplicate property signature", `Duplicate key ${util_.formatUnknown(key)}`)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type * as Schema from "../../Schema.js"
|
|
2
|
+
|
|
3
|
+
/** @internal */
|
|
4
|
+
export const GreaterThanSchemaId: Schema.GreaterThanSchemaId = Symbol.for(
|
|
5
|
+
"effect/schema/GreaterThan"
|
|
6
|
+
) as Schema.GreaterThanSchemaId
|
|
7
|
+
|
|
8
|
+
/** @internal */
|
|
9
|
+
export const GreaterThanOrEqualToSchemaId: Schema.GreaterThanOrEqualToSchemaId = Symbol.for(
|
|
10
|
+
"effect/schema/GreaterThanOrEqualTo"
|
|
11
|
+
) as Schema.GreaterThanOrEqualToSchemaId
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
export const LessThanSchemaId: Schema.LessThanSchemaId = Symbol.for(
|
|
15
|
+
"effect/schema/LessThan"
|
|
16
|
+
) as Schema.LessThanSchemaId
|
|
17
|
+
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const LessThanOrEqualToSchemaId: Schema.LessThanOrEqualToSchemaId = Symbol.for(
|
|
20
|
+
"effect/schema/LessThanOrEqualTo"
|
|
21
|
+
) as Schema.LessThanOrEqualToSchemaId
|
|
22
|
+
|
|
23
|
+
/** @internal */
|
|
24
|
+
export const IntSchemaId: Schema.IntSchemaId = Symbol.for(
|
|
25
|
+
"effect/schema/Int"
|
|
26
|
+
) as Schema.IntSchemaId
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const BetweenSchemaId: Schema.BetweenSchemaId = Symbol.for(
|
|
30
|
+
"effect/schema/Between"
|
|
31
|
+
) as Schema.BetweenSchemaId
|
|
32
|
+
|
|
33
|
+
/** @internal */
|
|
34
|
+
export const GreaterThanBigintSchemaId: Schema.GreaterThanBigIntSchemaId = Symbol.for(
|
|
35
|
+
"effect/schema/GreaterThanBigint"
|
|
36
|
+
) as Schema.GreaterThanBigIntSchemaId
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export const GreaterThanOrEqualToBigIntSchemaId: Schema.GreaterThanOrEqualToBigIntSchemaId = Symbol.for(
|
|
40
|
+
"effect/schema/GreaterThanOrEqualToBigint"
|
|
41
|
+
) as Schema.GreaterThanOrEqualToBigIntSchemaId
|
|
42
|
+
|
|
43
|
+
/** @internal */
|
|
44
|
+
export const LessThanBigIntSchemaId: Schema.LessThanBigIntSchemaId = Symbol.for(
|
|
45
|
+
"effect/schema/LessThanBigint"
|
|
46
|
+
) as Schema.LessThanBigIntSchemaId
|
|
47
|
+
|
|
48
|
+
/** @internal */
|
|
49
|
+
export const LessThanOrEqualToBigIntSchemaId: Schema.LessThanOrEqualToBigIntSchemaId = Symbol.for(
|
|
50
|
+
"effect/schema/LessThanOrEqualToBigint"
|
|
51
|
+
) as Schema.LessThanOrEqualToBigIntSchemaId
|
|
52
|
+
|
|
53
|
+
/** @internal */
|
|
54
|
+
export const BetweenBigintSchemaId: Schema.BetweenBigIntSchemaId = Symbol.for(
|
|
55
|
+
"effect/schema/BetweenBigint"
|
|
56
|
+
) as Schema.BetweenBigIntSchemaId
|
|
57
|
+
|
|
58
|
+
/** @internal */
|
|
59
|
+
export const MinLengthSchemaId: Schema.MinLengthSchemaId = Symbol.for(
|
|
60
|
+
"effect/schema/MinLength"
|
|
61
|
+
) as Schema.MinLengthSchemaId
|
|
62
|
+
|
|
63
|
+
/** @internal */
|
|
64
|
+
export const MaxLengthSchemaId: Schema.MaxLengthSchemaId = Symbol.for(
|
|
65
|
+
"effect/schema/MaxLength"
|
|
66
|
+
) as Schema.MaxLengthSchemaId
|
|
67
|
+
|
|
68
|
+
/** @internal */
|
|
69
|
+
export const LengthSchemaId: Schema.LengthSchemaId = Symbol.for(
|
|
70
|
+
"effect/schema/Length"
|
|
71
|
+
) as Schema.LengthSchemaId
|
|
72
|
+
|
|
73
|
+
/** @internal */
|
|
74
|
+
export const MinItemsSchemaId: Schema.MinItemsSchemaId = Symbol.for(
|
|
75
|
+
"effect/schema/MinItems"
|
|
76
|
+
) as Schema.MinItemsSchemaId
|
|
77
|
+
|
|
78
|
+
/** @internal */
|
|
79
|
+
export const MaxItemsSchemaId: Schema.MaxItemsSchemaId = Symbol.for(
|
|
80
|
+
"effect/schema/MaxItems"
|
|
81
|
+
) as Schema.MaxItemsSchemaId
|
|
82
|
+
|
|
83
|
+
/** @internal */
|
|
84
|
+
export const ItemsCountSchemaId: Schema.ItemsCountSchemaId = Symbol.for(
|
|
85
|
+
"effect/schema/ItemsCount"
|
|
86
|
+
) as Schema.ItemsCountSchemaId
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as array_ from "effect/Array"
|
|
2
|
+
import * as Predicate from "effect/Predicate"
|
|
3
|
+
import type * as ParseResult from "../../ParseResult.js"
|
|
4
|
+
import type * as AST from "../../SchemaAST.js"
|
|
5
|
+
|
|
6
|
+
/** @internal */
|
|
7
|
+
export const getKeysForIndexSignature = (
|
|
8
|
+
input: { readonly [x: PropertyKey]: unknown },
|
|
9
|
+
parameter: AST.Parameter
|
|
10
|
+
): ReadonlyArray<string> | ReadonlyArray<symbol> => {
|
|
11
|
+
switch (parameter._tag) {
|
|
12
|
+
case "StringKeyword":
|
|
13
|
+
case "TemplateLiteral":
|
|
14
|
+
return Object.keys(input)
|
|
15
|
+
case "SymbolKeyword":
|
|
16
|
+
return Object.getOwnPropertySymbols(input)
|
|
17
|
+
case "Refinement":
|
|
18
|
+
return getKeysForIndexSignature(input, parameter.from)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* JavaScript does not store the insertion order of properties in a way that
|
|
24
|
+
* combines both string and symbol keys. The internal order groups string keys
|
|
25
|
+
* and symbol keys separately. Hence concatenating the keys is fine.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export const ownKeys = (o: object): Array<PropertyKey> =>
|
|
30
|
+
(Object.keys(o) as Array<PropertyKey>).concat(Object.getOwnPropertySymbols(o))
|
|
31
|
+
|
|
32
|
+
/** @internal */
|
|
33
|
+
export const memoizeThunk = <A>(f: () => A): () => A => {
|
|
34
|
+
let done = false
|
|
35
|
+
let a: A
|
|
36
|
+
return () => {
|
|
37
|
+
if (done) {
|
|
38
|
+
return a
|
|
39
|
+
}
|
|
40
|
+
a = f()
|
|
41
|
+
done = true
|
|
42
|
+
return a
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @internal */
|
|
47
|
+
export const formatDate = (date: Date): string => {
|
|
48
|
+
try {
|
|
49
|
+
return date.toISOString()
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return String(date)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @internal */
|
|
56
|
+
export const formatUnknown = (u: unknown): string => {
|
|
57
|
+
if (Predicate.isString(u)) {
|
|
58
|
+
return JSON.stringify(u)
|
|
59
|
+
} else if (
|
|
60
|
+
Predicate.isNumber(u)
|
|
61
|
+
|| u == null
|
|
62
|
+
|| Predicate.isBoolean(u)
|
|
63
|
+
|| Predicate.isSymbol(u)
|
|
64
|
+
) {
|
|
65
|
+
return String(u)
|
|
66
|
+
} else if (Predicate.isDate(u)) {
|
|
67
|
+
return formatDate(u)
|
|
68
|
+
} else if (Predicate.isBigInt(u)) {
|
|
69
|
+
return String(u) + "n"
|
|
70
|
+
} else if (
|
|
71
|
+
!array_.isArray(u)
|
|
72
|
+
&& Predicate.hasProperty(u, "toString")
|
|
73
|
+
&& Predicate.isFunction(u["toString"])
|
|
74
|
+
&& u["toString"] !== Object.prototype.toString
|
|
75
|
+
) {
|
|
76
|
+
return u["toString"]()
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
JSON.stringify(u)
|
|
80
|
+
if (array_.isArray(u)) {
|
|
81
|
+
return `[${u.map(formatUnknown).join(",")}]`
|
|
82
|
+
} else {
|
|
83
|
+
return `{${
|
|
84
|
+
ownKeys(u).map((k) =>
|
|
85
|
+
`${Predicate.isString(k) ? JSON.stringify(k) : String(k)}:${formatUnknown((u as any)[k])}`
|
|
86
|
+
).join(",")
|
|
87
|
+
}}`
|
|
88
|
+
}
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return String(u)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @internal */
|
|
95
|
+
export const formatPropertyKey = (name: PropertyKey): string =>
|
|
96
|
+
typeof name === "string" ? JSON.stringify(name) : String(name)
|
|
97
|
+
|
|
98
|
+
/** @internal */
|
|
99
|
+
export type SingleOrArray<A> = A | ReadonlyArray<A>
|
|
100
|
+
|
|
101
|
+
/** @internal */
|
|
102
|
+
export const isNonEmpty = <A>(x: ParseResult.SingleOrNonEmpty<A>): x is array_.NonEmptyReadonlyArray<A> =>
|
|
103
|
+
Array.isArray(x)
|
|
104
|
+
|
|
105
|
+
/** @internal */
|
|
106
|
+
export const isSingle = <A>(x: A | ReadonlyArray<A>): x is A => !Array.isArray(x)
|
|
107
|
+
|
|
108
|
+
/** @internal */
|
|
109
|
+
export const formatPathKey = (key: PropertyKey): string => `[${formatPropertyKey(key)}]`
|
|
110
|
+
|
|
111
|
+
/** @internal */
|
|
112
|
+
export const formatPath = (path: ParseResult.Path): string =>
|
|
113
|
+
isNonEmpty(path) ? path.map(formatPathKey).join("") : formatPathKey(path)
|
package/src/internal/stm/core.ts
CHANGED
|
@@ -15,11 +15,10 @@ import { pipeArguments } from "../../Pipeable.js"
|
|
|
15
15
|
import { hasProperty } from "../../Predicate.js"
|
|
16
16
|
import type * as Scheduler from "../../Scheduler.js"
|
|
17
17
|
import type * as STM from "../../STM.js"
|
|
18
|
-
import { StreamTypeId } from "../../Stream.js"
|
|
19
18
|
import { YieldWrap } from "../../Utils.js"
|
|
20
19
|
import { ChannelTypeId } from "../core-stream.js"
|
|
21
20
|
import { withFiberRuntime } from "../core.js"
|
|
22
|
-
import { effectVariance } from "../effectable.js"
|
|
21
|
+
import { effectVariance, StreamTypeId } from "../effectable.js"
|
|
23
22
|
import { OP_COMMIT } from "../opCodes/effect.js"
|
|
24
23
|
import { SingleShotGen } from "../singleShotGen.js"
|
|
25
24
|
import { SinkTypeId } from "../sink.js"
|
|
@@ -201,6 +201,7 @@ class TPubSubSubscriptionImpl<in out A> implements TQueue.TDequeue<A> {
|
|
|
201
201
|
capacity(): number {
|
|
202
202
|
return this.requestedCapacity
|
|
203
203
|
}
|
|
204
|
+
|
|
204
205
|
size: STM.STM<number> = core.withSTMRuntime((runtime) => {
|
|
205
206
|
let currentSubscriberHead = tRef.unsafeGet(this.subscriberHead, runtime.journal)
|
|
206
207
|
if (currentSubscriberHead === undefined) {
|
|
@@ -3,7 +3,7 @@ import * as Chunk from "../../Chunk.js"
|
|
|
3
3
|
import { dual, pipe } from "../../Function.js"
|
|
4
4
|
import * as Option from "../../Option.js"
|
|
5
5
|
import { hasProperty, type Predicate } from "../../Predicate.js"
|
|
6
|
-
import * as STM from "../../STM.js"
|
|
6
|
+
import type * as STM from "../../STM.js"
|
|
7
7
|
import type * as TQueue from "../../TQueue.js"
|
|
8
8
|
import type * as TRef from "../../TRef.js"
|
|
9
9
|
import * as core from "./core.js"
|
|
@@ -99,7 +99,7 @@ class TQueueImpl<in out A> implements TQueue.TQueue<A> {
|
|
|
99
99
|
size: STM.STM<number> = core.withSTMRuntime((runtime) => {
|
|
100
100
|
const queue = tRef.unsafeGet(this.ref, runtime.journal)
|
|
101
101
|
if (queue === undefined) {
|
|
102
|
-
return
|
|
102
|
+
return core.interruptAs(runtime.fiberId)
|
|
103
103
|
}
|
|
104
104
|
return core.succeed(queue.length)
|
|
105
105
|
})
|
package/src/internal/stm/tRef.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { dual } from "../../Function.js"
|
|
2
2
|
import * as Option from "../../Option.js"
|
|
3
|
+
import type { Pipeable } from "../../Pipeable.js"
|
|
4
|
+
import { pipeArguments } from "../../Pipeable.js"
|
|
3
5
|
import type * as STM from "../../STM.js"
|
|
4
6
|
import type * as TRef from "../../TRef.js"
|
|
5
7
|
import * as core from "./core.js"
|
|
@@ -16,13 +18,13 @@ export const TRefTypeId: TRef.TRefTypeId = Symbol.for(
|
|
|
16
18
|
TRefSymbolKey
|
|
17
19
|
) as TRef.TRefTypeId
|
|
18
20
|
|
|
19
|
-
const tRefVariance = {
|
|
21
|
+
export const tRefVariance = {
|
|
20
22
|
/* c8 ignore next */
|
|
21
23
|
_A: (_: any) => _
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/** @internal */
|
|
25
|
-
export class TRefImpl<in out A> implements TRef.TRef<A
|
|
27
|
+
export class TRefImpl<in out A> implements TRef.TRef<A>, Pipeable {
|
|
26
28
|
readonly [TRefTypeId] = tRefVariance
|
|
27
29
|
/** @internal */
|
|
28
30
|
todos: Map<TxnId.TxnId, Journal.Todo>
|
|
@@ -40,6 +42,9 @@ export class TRefImpl<in out A> implements TRef.TRef<A> {
|
|
|
40
42
|
return retValue
|
|
41
43
|
})
|
|
42
44
|
}
|
|
45
|
+
pipe() {
|
|
46
|
+
return pipeArguments(this, arguments)
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/** @internal */
|