effect 4.0.0-beta.83 → 4.0.0-beta.85
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/dist/Array.d.ts +64 -64
- package/dist/Array.js +26 -26
- package/dist/Cache.d.ts +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cause.d.ts +68 -68
- package/dist/Cause.js +47 -47
- package/dist/Channel.d.ts +5 -5
- package/dist/Channel.js +3 -3
- package/dist/Clock.d.ts +1 -1
- package/dist/Clock.js +1 -1
- package/dist/Combiner.d.ts +9 -9
- package/dist/Combiner.js +8 -8
- package/dist/Config.d.ts +15 -94
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +22 -70
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +58 -74
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +66 -41
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +1 -1
- package/dist/Console.js +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +4 -3
- package/dist/Context.js.map +1 -1
- package/dist/Data.d.ts +15 -15
- package/dist/Data.js +3 -3
- package/dist/DateTime.d.ts +6 -6
- package/dist/DateTime.js +2 -2
- package/dist/Duration.d.ts +3 -3
- package/dist/Duration.js +3 -3
- package/dist/Effect.d.ts +84 -45
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -33
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +7 -7
- package/dist/Equal.js +5 -5
- package/dist/Equivalence.d.ts +17 -17
- package/dist/Equivalence.js +13 -13
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.js +3 -3
- package/dist/Formatter.d.ts +5 -5
- package/dist/Formatter.js +4 -4
- package/dist/Function.d.ts +10 -10
- package/dist/Function.js +3 -3
- package/dist/HashMap.d.ts +3 -3
- package/dist/HashMap.js +1 -1
- package/dist/Iterable.d.ts +6 -6
- package/dist/Iterable.js +2 -2
- package/dist/JsonPatch.d.ts +2 -2
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.js +5 -4
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +4 -3
- package/dist/LayerMap.js.map +1 -1
- package/dist/Logger.d.ts +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Match.d.ts +8 -8
- package/dist/Match.js +8 -8
- package/dist/Metric.d.ts +3 -3
- package/dist/Metric.js +3 -3
- package/dist/Optic.d.ts +30 -30
- package/dist/Optic.js +12 -12
- package/dist/Option.d.ts +7 -7
- package/dist/Option.js +7 -7
- package/dist/Order.d.ts +23 -23
- package/dist/Order.js +20 -20
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Predicate.d.ts +88 -88
- package/dist/Predicate.js +47 -47
- package/dist/PubSub.d.ts +3 -3
- package/dist/PubSub.js +3 -3
- package/dist/Random.d.ts +31 -0
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +32 -0
- package/dist/Random.js.map +1 -1
- package/dist/Reducer.d.ts +1 -1
- package/dist/Reducer.js +1 -1
- package/dist/Result.d.ts +18 -18
- package/dist/Result.js +8 -8
- package/dist/Runtime.d.ts +1 -1
- package/dist/Runtime.js +1 -1
- package/dist/Schema.d.ts +313 -126
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +316 -127
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +9 -8
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +203 -140
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +48 -48
- package/dist/SchemaGetter.js +44 -44
- package/dist/SchemaIssue.d.ts +3 -3
- package/dist/SchemaIssue.js +3 -3
- package/dist/SchemaParser.d.ts +122 -22
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +186 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +96 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +20 -20
- package/dist/SchemaTransformation.js +18 -18
- package/dist/Stream.d.ts +3 -3
- package/dist/Stream.js +2 -2
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +1 -1
- package/dist/String.js +1 -1
- package/dist/Struct.d.ts +1 -1
- package/dist/Struct.js +1 -1
- package/dist/Types.d.ts +13 -13
- package/dist/internal/effect.js +33 -20
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/arbitrary.js +17 -1
- package/dist/internal/schema/arbitrary.js.map +1 -1
- package/dist/internal/schema/cause.d.ts +2 -0
- package/dist/internal/schema/cause.d.ts.map +1 -0
- package/dist/internal/schema/cause.js +24 -0
- package/dist/internal/schema/cause.js.map +1 -0
- package/dist/internal/schema/schema.d.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -8
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/stackTraceLimit.d.ts +2 -0
- package/dist/internal/stackTraceLimit.d.ts.map +1 -0
- package/dist/internal/stackTraceLimit.js +40 -0
- package/dist/internal/stackTraceLimit.js.map +1 -0
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +4 -3
- package/dist/internal/tracer.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.js +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +4 -5
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +2 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +4 -3
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/persistence/PersistedQueue.js +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +3 -4
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +4 -3
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +15 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +65 -65
- package/src/Cache.ts +1 -1
- package/src/Cause.ts +68 -68
- package/src/Channel.ts +5 -5
- package/src/Clock.ts +1 -1
- package/src/Combiner.ts +9 -9
- package/src/Config.ts +40 -108
- package/src/ConfigProvider.ts +139 -100
- package/src/Console.ts +1 -1
- package/src/Context.ts +4 -5
- package/src/Data.ts +15 -15
- package/src/DateTime.ts +6 -6
- package/src/Duration.ts +3 -3
- package/src/Effect.ts +89 -45
- package/src/Equal.ts +7 -7
- package/src/Equivalence.ts +17 -17
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +5 -5
- package/src/Function.ts +10 -10
- package/src/HashMap.ts +3 -3
- package/src/Iterable.ts +6 -6
- package/src/JsonPatch.ts +2 -2
- package/src/Layer.ts +5 -5
- package/src/LayerMap.ts +4 -3
- package/src/Logger.ts +1 -1
- package/src/Match.ts +8 -8
- package/src/Metric.ts +3 -3
- package/src/Optic.ts +30 -30
- package/src/Option.ts +7 -7
- package/src/Order.ts +23 -23
- package/src/Pool.ts +1 -1
- package/src/Predicate.ts +88 -88
- package/src/PubSub.ts +3 -3
- package/src/Random.ts +42 -0
- package/src/Reducer.ts +1 -1
- package/src/Result.ts +20 -20
- package/src/Runtime.ts +1 -1
- package/src/Schema.ts +389 -153
- package/src/SchemaAST.ts +237 -148
- package/src/SchemaGetter.ts +48 -48
- package/src/SchemaIssue.ts +3 -3
- package/src/SchemaParser.ts +197 -58
- package/src/SchemaRepresentation.ts +73 -3
- package/src/SchemaTransformation.ts +20 -20
- package/src/Stream.ts +4 -4
- package/src/String.ts +1 -1
- package/src/Struct.ts +1 -1
- package/src/Types.ts +13 -13
- package/src/internal/effect.ts +40 -21
- package/src/internal/schema/arbitrary.ts +23 -2
- package/src/internal/schema/cause.ts +26 -0
- package/src/internal/schema/schema.ts +36 -10
- package/src/internal/stackTraceLimit.ts +63 -0
- package/src/internal/tracer.ts +4 -3
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/ai/Tool.ts +4 -3
- package/src/unstable/cli/Prompt.ts +1 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -3
- package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
- package/src/unstable/persistence/PersistedQueue.ts +1 -1
- package/src/unstable/rpc/Rpc.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -4
- package/src/unstable/rpc/RpcMiddleware.ts +4 -3
- package/src/unstable/sql/SqlResolver.ts +15 -2
- package/src/unstable/workflow/Activity.ts +2 -0
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for safely manipulating `Error.stackTraceLimit` in environments
|
|
3
|
+
* where intrinsics may be frozen (e.g., SES / hardened JavaScript or
|
|
4
|
+
* deterministic sandboxes such as Temporal). When the property is non-writable,
|
|
5
|
+
* mutating it throws, so all manipulation here degrades to a best-effort,
|
|
6
|
+
* silent no-op.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the guard Node uses internally:
|
|
9
|
+
* https://github.com/nodejs/node/blob/e77694631f1642c302f664703197b5aabc65b482/lib/internal/errors.js#L246
|
|
10
|
+
*
|
|
11
|
+
* The error is constructed inline at each call site (rather than inside a
|
|
12
|
+
* closure here) so the captured stack trace keeps pointing at the real caller
|
|
13
|
+
* instead of this module.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
import type { ErrorWithStackTraceLimit } from "./tracer.ts"
|
|
18
|
+
|
|
19
|
+
const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
|
|
20
|
+
const ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty
|
|
21
|
+
const ObjectIsExtensible = Object.isExtensible
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Check if `Error.stackTraceLimit` is writable.
|
|
25
|
+
* Returns `false` if the property is frozen, non-writable, or `Error` is non-extensible.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export const isStackTraceLimitWritable = (): boolean => {
|
|
30
|
+
const desc = ObjectGetOwnPropertyDescriptor(Error, "stackTraceLimit")
|
|
31
|
+
if (desc === undefined) {
|
|
32
|
+
return ObjectIsExtensible(Error)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ObjectPrototypeHasOwnProperty.call(desc, "writable")
|
|
36
|
+
? desc.writable === true
|
|
37
|
+
: desc.set !== undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Cache the check result since it won't change during runtime
|
|
41
|
+
const canWriteStackTraceLimit = isStackTraceLimitWritable()
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the current `Error.stackTraceLimit` value.
|
|
45
|
+
* Returns `undefined` if the property doesn't exist.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export const getStackTraceLimit = (): number | undefined => (Error as ErrorWithStackTraceLimit).stackTraceLimit
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Safely set `Error.stackTraceLimit` if possible, otherwise no-op.
|
|
53
|
+
*
|
|
54
|
+
* Accepts `undefined` so a value read via {@link getStackTraceLimit} can be
|
|
55
|
+
* restored faithfully.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export const setStackTraceLimit = (value: number | undefined): void => {
|
|
60
|
+
if (canWriteStackTraceLimit) {
|
|
61
|
+
;(Error as ErrorWithStackTraceLimit).stackTraceLimit = value
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/internal/tracer.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as Tracer from "../Tracer.ts"
|
|
2
|
+
import { getStackTraceLimit, setStackTraceLimit } from "./stackTraceLimit.ts"
|
|
2
3
|
|
|
3
4
|
export interface ErrorWithStackTraceLimit {
|
|
4
5
|
stackTraceLimit?: number | undefined
|
|
@@ -13,10 +14,10 @@ export const addSpanStackTrace = <A extends Tracer.TraceOptions>(
|
|
|
13
14
|
} else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") {
|
|
14
15
|
return options
|
|
15
16
|
}
|
|
16
|
-
const limit = (
|
|
17
|
-
|
|
17
|
+
const limit = getStackTraceLimit()
|
|
18
|
+
setStackTraceLimit(3)
|
|
18
19
|
const traceError = new Error()
|
|
19
|
-
|
|
20
|
+
setStackTraceLimit(limit)
|
|
20
21
|
return {
|
|
21
22
|
...options,
|
|
22
23
|
captureStackTrace: spanCleaner(() => traceError.stack)
|
|
@@ -154,7 +154,7 @@ export class Asserts<S extends Schema.Top> {
|
|
|
154
154
|
*
|
|
155
155
|
* FastCheck generates arbitrary values matching the schema's `Type`. The assertion fails if any generated value does not round-trip. Pass `options.params` to control FastCheck parameters such as `numRuns`.
|
|
156
156
|
*
|
|
157
|
-
* **Example** (
|
|
157
|
+
* **Example** (Verifying round trips)
|
|
158
158
|
*
|
|
159
159
|
* ```ts
|
|
160
160
|
* import { Schema } from "effect"
|
|
@@ -338,7 +338,7 @@ export class Decoding<S extends Schema.Top> {
|
|
|
338
338
|
*
|
|
339
339
|
* Use to verify successful decoding for one input case.
|
|
340
340
|
*
|
|
341
|
-
* **Example** (
|
|
341
|
+
* **Example** (Testing identity and transformed decoding)
|
|
342
342
|
*
|
|
343
343
|
* ```ts
|
|
344
344
|
* import { Schema } from "effect"
|
|
@@ -478,7 +478,7 @@ export class Encoding<S extends Schema.Top> {
|
|
|
478
478
|
*
|
|
479
479
|
* Use to verify successful encoding for one input case.
|
|
480
480
|
*
|
|
481
|
-
* **Example** (
|
|
481
|
+
* **Example** (Testing identity and transformed encoding)
|
|
482
482
|
*
|
|
483
483
|
* ```ts
|
|
484
484
|
* import { Schema } from "effect"
|
|
@@ -181,7 +181,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
|
|
|
181
181
|
* Provider-specific metadata is namespaced by provider name. Each provider
|
|
182
182
|
* value can contain arbitrary mutable JSON metadata or `null`.
|
|
183
183
|
*
|
|
184
|
-
* **Example** (
|
|
184
|
+
* **Example** (Inspecting metadata shape)
|
|
185
185
|
*
|
|
186
186
|
* ```ts
|
|
187
187
|
* const metadata = {
|
package/src/unstable/ai/Chat.ts
CHANGED
|
@@ -46,7 +46,7 @@ import type * as Tool from "./Tool.ts"
|
|
|
46
46
|
* enabling persistent conversational AI interactions with full context
|
|
47
47
|
* management.
|
|
48
48
|
*
|
|
49
|
-
* **Example** (
|
|
49
|
+
* **Example** (Accessing the Chat service)
|
|
50
50
|
*
|
|
51
51
|
* ```ts
|
|
52
52
|
* import { Effect } from "effect"
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import * as Context from "../../Context.ts"
|
|
15
15
|
import type * as Effect from "../../Effect.ts"
|
|
16
16
|
import { constFalse, constTrue, identity } from "../../Function.ts"
|
|
17
|
+
import * as StackTraceLimit from "../../internal/stackTraceLimit.ts"
|
|
17
18
|
import type * as JsonSchema from "../../JsonSchema.ts"
|
|
18
19
|
import { pipeArguments } from "../../Pipeable.ts"
|
|
19
20
|
import * as Predicate from "../../Predicate.ts"
|
|
@@ -1997,12 +1998,12 @@ function filter(obj: any) {
|
|
|
1997
1998
|
*/
|
|
1998
1999
|
export const unsafeSecureJsonParse = (text: string): unknown => {
|
|
1999
2000
|
// Performance optimization, see https://github.com/fastify/secure-json-parse/pull/90
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2001
|
+
const prevLimit = StackTraceLimit.getStackTraceLimit()
|
|
2002
|
+
StackTraceLimit.setStackTraceLimit(0)
|
|
2002
2003
|
try {
|
|
2003
2004
|
return _parse(text)
|
|
2004
2005
|
} finally {
|
|
2005
|
-
|
|
2006
|
+
StackTraceLimit.setStackTraceLimit(prevLimit)
|
|
2006
2007
|
}
|
|
2007
2008
|
}
|
|
2008
2009
|
|
|
@@ -1422,7 +1422,7 @@ const runLoop = Effect.fnUntraced(
|
|
|
1422
1422
|
yield* Effect.orDie(terminal.display(msg))
|
|
1423
1423
|
if (loop.events) {
|
|
1424
1424
|
const takeInput = Queue.take(input).pipe(
|
|
1425
|
-
Effect.map((
|
|
1425
|
+
Effect.map((input) => ({ _tag: "Input" as const, input }))
|
|
1426
1426
|
)
|
|
1427
1427
|
const result = yield* Effect.raceFirst(
|
|
1428
1428
|
takeInput,
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
/** @effect-diagnostics classSelfMismatch:off */
|
|
16
16
|
import * as Context from "../../Context.ts"
|
|
17
17
|
import * as Effect from "../../Effect.ts"
|
|
18
|
+
import { getStackTraceLimit, setStackTraceLimit } from "../../internal/stackTraceLimit.ts"
|
|
18
19
|
import * as Layer from "../../Layer.ts"
|
|
19
20
|
import { hasProperty } from "../../Predicate.ts"
|
|
20
21
|
import type * as Schema from "../../Schema.ts"
|
|
@@ -352,10 +353,10 @@ export const Service = <
|
|
|
352
353
|
} | undefined
|
|
353
354
|
) => {
|
|
354
355
|
const Err = globalThis.Error as any
|
|
355
|
-
const limit =
|
|
356
|
-
|
|
356
|
+
const limit = getStackTraceLimit()
|
|
357
|
+
setStackTraceLimit(2)
|
|
357
358
|
const creationError = new Err()
|
|
358
|
-
|
|
359
|
+
setStackTraceLimit(limit)
|
|
359
360
|
|
|
360
361
|
class Service extends Context.Service<Self, any>()(id) {}
|
|
361
362
|
const self = Service as any
|
|
@@ -87,7 +87,7 @@ export type ScalarConfig = {
|
|
|
87
87
|
/**
|
|
88
88
|
* Path to a favicon image.
|
|
89
89
|
*
|
|
90
|
-
* **Example** (
|
|
90
|
+
* **Example** (Setting a relative favicon)
|
|
91
91
|
*
|
|
92
92
|
* ```ts
|
|
93
93
|
* const favicon = "/favicon.svg"
|
|
@@ -107,7 +107,7 @@ export type ScalarConfig = {
|
|
|
107
107
|
* Browsers can derive the origin from `window.location.origin`; server
|
|
108
108
|
* rendering needs this value supplied explicitly.
|
|
109
109
|
*
|
|
110
|
-
* **Example** (
|
|
110
|
+
* **Example** (Setting a local server URL)
|
|
111
111
|
*
|
|
112
112
|
* ```ts
|
|
113
113
|
* const baseServerURL = "http://localhost:3000"
|
|
@@ -508,7 +508,7 @@ export const makeStoreRedis = Effect.fnUntraced(function*(
|
|
|
508
508
|
id,
|
|
509
509
|
JSON.stringify({ id, element, attempts: 0 })
|
|
510
510
|
)
|
|
511
|
-
: redis.send("
|
|
511
|
+
: redis.send("RPUSH", `${prefix}${name}`, JSON.stringify({ id, element, attempts: 0 })),
|
|
512
512
|
({ cause }) =>
|
|
513
513
|
new PersistedQueueError({
|
|
514
514
|
message: "Failed to offer element to persisted queue",
|
package/src/unstable/rpc/Rpc.ts
CHANGED
|
@@ -955,7 +955,7 @@ export const make = <
|
|
|
955
955
|
/**
|
|
956
956
|
* Creates a custom `Rpc` constructor that can transform the output schemas.
|
|
957
957
|
*
|
|
958
|
-
* **Example** (
|
|
958
|
+
* **Example** (Defining a paginated RPC constructor)
|
|
959
959
|
*
|
|
960
960
|
* ```ts
|
|
961
961
|
* import { Schema } from "effect"
|
|
@@ -303,14 +303,13 @@ const RpcGroupProto = {
|
|
|
303
303
|
const services = yield* Effect.context<never>()
|
|
304
304
|
const handlers = Effect.isEffect(build) ? yield* build : build
|
|
305
305
|
const contextMap = new Map<string, unknown>()
|
|
306
|
-
|
|
307
|
-
const rpc = self.requests.get(tag)!
|
|
306
|
+
self.requests.forEach((rpc, tag) => {
|
|
308
307
|
contextMap.set(rpc.key, {
|
|
309
308
|
tag: rpc._tag,
|
|
310
|
-
handler,
|
|
309
|
+
handler: handlers[tag],
|
|
311
310
|
context: services
|
|
312
311
|
})
|
|
313
|
-
}
|
|
312
|
+
})
|
|
314
313
|
return Context.makeUnsafe(contextMap)
|
|
315
314
|
})
|
|
316
315
|
},
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import * as Context from "../../Context.ts"
|
|
13
13
|
import * as Effect from "../../Effect.ts"
|
|
14
|
+
import { getStackTraceLimit, setStackTraceLimit } from "../../internal/stackTraceLimit.ts"
|
|
14
15
|
import * as Layer from "../../Layer.ts"
|
|
15
16
|
import * as Schema from "../../Schema.ts"
|
|
16
17
|
import { Scope } from "../../Scope.ts"
|
|
@@ -292,10 +293,10 @@ export const Service = <
|
|
|
292
293
|
}
|
|
293
294
|
) => {
|
|
294
295
|
const Err = globalThis.Error as any
|
|
295
|
-
const limit =
|
|
296
|
-
|
|
296
|
+
const limit = getStackTraceLimit()
|
|
297
|
+
setStackTraceLimit(2)
|
|
297
298
|
const creationError = new Err()
|
|
298
|
-
|
|
299
|
+
setStackTraceLimit(limit)
|
|
299
300
|
|
|
300
301
|
function ServiceClass() {}
|
|
301
302
|
const ServiceClass_ = ServiceClass as any as Mutable<AnyService>
|
|
@@ -17,6 +17,7 @@ import * as Equal from "../../Equal.ts"
|
|
|
17
17
|
import * as Exit from "../../Exit.ts"
|
|
18
18
|
import * as Hash from "../../Hash.ts"
|
|
19
19
|
import * as MutableHashMap from "../../MutableHashMap.ts"
|
|
20
|
+
import * as Option from "../../Option.ts"
|
|
20
21
|
import * as Request from "../../Request.ts"
|
|
21
22
|
import * as RequestResolver from "../../RequestResolver.ts"
|
|
22
23
|
import * as Schema from "../../Schema.ts"
|
|
@@ -376,8 +377,20 @@ const partitionRequestsById = function*<In, A, E, R, InE>(
|
|
|
376
377
|
|
|
377
378
|
for (let i = 0; i < len; i++) {
|
|
378
379
|
entry = requests[i]
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
const existing = MutableHashMap.get(byIdMap, entry.request.payload)
|
|
381
|
+
if (Option.isSome(existing)) {
|
|
382
|
+
const duplicate = entry
|
|
383
|
+
MutableHashMap.set(byIdMap, entry.request.payload, {
|
|
384
|
+
...existing.value,
|
|
385
|
+
completeUnsafe(exit) {
|
|
386
|
+
existing.value.completeUnsafe(exit)
|
|
387
|
+
duplicate.completeUnsafe(exit)
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
} else {
|
|
391
|
+
yield (Effect.provideContext(handle(encode(entry.request.payload)), entry.context) as Effect.Effect<void>)
|
|
392
|
+
MutableHashMap.set(byIdMap, entry.request.payload, entry)
|
|
393
|
+
}
|
|
381
394
|
}
|
|
382
395
|
|
|
383
396
|
return [inputs, byIdMap] as const
|
|
@@ -49,6 +49,7 @@ export interface Activity<
|
|
|
49
49
|
readonly successSchema: Success
|
|
50
50
|
readonly errorSchema: Error
|
|
51
51
|
readonly exitSchema: Schema.Exit<Success, Error, Schema.Defect>
|
|
52
|
+
readonly exitSchemaPartial: Schema.Exit<Success, Error, Schema.Unknown>
|
|
52
53
|
readonly annotations: Context.Context<never>
|
|
53
54
|
annotate<I, S>(
|
|
54
55
|
key: Context.Key<I, S>,
|
|
@@ -153,6 +154,7 @@ export const make = <
|
|
|
153
154
|
successSchema,
|
|
154
155
|
errorSchema,
|
|
155
156
|
exitSchema: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Defect()),
|
|
157
|
+
exitSchemaPartial: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Unknown),
|
|
156
158
|
annotations: options.annotations ?? Context.empty(),
|
|
157
159
|
annotate(tag: Context.Key<any, any>, value: any) {
|
|
158
160
|
return make({
|
|
@@ -478,7 +478,7 @@ export const makeUnsafe = (options: Encoded): WorkflowEngine["Service"] =>
|
|
|
478
478
|
return result
|
|
479
479
|
}
|
|
480
480
|
const exit = yield* Effect.orDie(
|
|
481
|
-
Schema.decodeEffect(activity.
|
|
481
|
+
Schema.decodeEffect(activity.exitSchemaPartial)(toJsonExit(result.exit))
|
|
482
482
|
)
|
|
483
483
|
return new Workflow.Complete({ exit })
|
|
484
484
|
}),
|