@shivaedev/effect-trpc 0.3.3 → 0.4.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/CHANGELOG.md +29 -1
- package/README.md +76 -0
- package/dist/adapter.d.ts +6 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +2 -1
- package/dist/adapter.js.map +1 -1
- package/dist/client/rejection.d.ts +10 -0
- package/dist/client/rejection.d.ts.map +1 -0
- package/dist/client/rejection.js +9 -0
- package/dist/client/rejection.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/context-bridge.d.ts.map +1 -1
- package/dist/internal/context-bridge.js +1 -2
- package/dist/internal/context-bridge.js.map +1 -1
- package/dist/internal/loose.d.ts +4 -0
- package/dist/internal/loose.d.ts.map +1 -0
- package/dist/internal/loose.js +7 -0
- package/dist/internal/loose.js.map +1 -0
- package/dist/internal/procedure-handler.d.ts +5 -12
- package/dist/internal/procedure-handler.d.ts.map +1 -1
- package/dist/internal/procedure-handler.js +3 -4
- package/dist/internal/procedure-handler.js.map +1 -1
- package/dist/internal/procedure-types.d.ts +17 -4
- package/dist/internal/procedure-types.d.ts.map +1 -1
- package/dist/internal/runtime.d.ts +4 -4
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +5 -13
- package/dist/internal/runtime.js.map +1 -1
- package/dist/internal/subscription-handler.d.ts +5 -12
- package/dist/internal/subscription-handler.d.ts.map +1 -1
- package/dist/internal/subscription-handler.js +5 -6
- package/dist/internal/subscription-handler.js.map +1 -1
- package/dist/procedure.d.ts +6 -8
- package/dist/procedure.d.ts.map +1 -1
- package/dist/procedure.js +8 -17
- package/dist/procedure.js.map +1 -1
- package/dist/rejection-formatter.d.ts +18 -0
- package/dist/rejection-formatter.d.ts.map +1 -0
- package/dist/rejection-formatter.js +21 -0
- package/dist/rejection-formatter.js.map +1 -0
- package/dist/rejection.d.ts +15 -0
- package/dist/rejection.d.ts.map +1 -0
- package/dist/rejection.js +31 -0
- package/dist/rejection.js.map +1 -0
- package/dist/request-services.d.ts.map +1 -1
- package/dist/request-services.js.map +1 -1
- package/dist/request-signal.d.ts.map +1 -1
- package/dist/request-signal.js.map +1 -1
- package/dist/testing/any-test-layer.d.ts +3 -0
- package/dist/testing/any-test-layer.d.ts.map +1 -0
- package/dist/testing/any-test-layer.js +2 -0
- package/dist/testing/any-test-layer.js.map +1 -0
- package/dist/testing/caller.d.ts +5 -3
- package/dist/testing/caller.d.ts.map +1 -1
- package/dist/testing/caller.js +12 -11
- package/dist/testing/caller.js.map +1 -1
- package/dist/testing/types.d.ts +5 -4
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/vitest.d.ts +4 -3
- package/dist/testing/vitest.d.ts.map +1 -1
- package/dist/testing/vitest.js +13 -14
- package/dist/testing/vitest.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -6
- package/src/adapter.ts +24 -76
- package/src/client/rejection.ts +16 -0
- package/src/client.ts +1 -0
- package/src/errors.ts +8 -19
- package/src/index.ts +9 -6
- package/src/internal/context-bridge.ts +3 -10
- package/src/internal/loose.ts +14 -0
- package/src/internal/procedure-handler.ts +11 -34
- package/src/internal/procedure-types.ts +37 -50
- package/src/internal/runtime.ts +14 -49
- package/src/internal/subscription-handler.ts +15 -47
- package/src/procedure.ts +33 -142
- package/src/rejection-formatter.ts +29 -0
- package/src/rejection.ts +47 -0
- package/src/request-services.ts +5 -25
- package/src/request-signal.ts +1 -4
- package/src/testing/any-test-layer.ts +3 -0
- package/src/testing/caller.ts +29 -32
- package/src/testing/types.ts +15 -47
- package/src/testing/vitest.ts +19 -51
- package/src/testing.ts +3 -3
- package/src/types.ts +3 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.4.0 - 2026-09-26
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `rejectWith(schema)` sends failures matching a tagged schema to the client as
|
|
8
|
+
a `RejectionError` carrying the schema-encoded value. The tRPC code follows
|
|
9
|
+
the Platform error taxonomy (`NotFound`, `Unauthorized`, `Forbidden`,
|
|
10
|
+
`Conflict`, `PreconditionFailed`, and `AuthUnavailable` as
|
|
11
|
+
`SERVICE_UNAVAILABLE`), otherwise `BAD_REQUEST`, or a `code` option.
|
|
12
|
+
`rejectionCode` exposes that mapping.
|
|
13
|
+
- `rejectionFormatter` and `withRejection` add the encoded value to the error
|
|
14
|
+
data as `data.rejection`. An input that fails the procedure's input schema
|
|
15
|
+
becomes a `BadRequest` rejection whose `field` is the first issue's dotted
|
|
16
|
+
path.
|
|
17
|
+
- `@shivaedev/effect-trpc/client`, a browser-safe entry that imports only
|
|
18
|
+
Effect: `rejectionOf(error)` reads the encoded rejection from a
|
|
19
|
+
`TRPCClientError` and `decodeRejection(schema)(error)` decodes it.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Require Effect Test 0.1.2, whose `eventually` retries only typed failures.
|
|
24
|
+
|
|
25
|
+
## 0.3.4 - 2026-09-04
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Require Effect 4.0.0-rc.112, so applications tracking the current release
|
|
30
|
+
candidate install without unmet peer warnings.
|
|
31
|
+
- Require Effect Test 0.1.1, which moves to the same Effect release.
|
|
4
32
|
|
|
5
33
|
## 0.3.3 - 2026-08-30
|
|
6
34
|
|
package/README.md
CHANGED
|
@@ -112,6 +112,82 @@ Each procedure runs in a span named after its tRPC path. `instrument` and
|
|
|
112
112
|
`instrumentStream` can add application-specific Effect logging, metrics, or
|
|
113
113
|
tracing without changing procedure definitions.
|
|
114
114
|
|
|
115
|
+
## Declared rejections
|
|
116
|
+
|
|
117
|
+
A declared rejection is a tagged Schema value the client may act on, such as a
|
|
118
|
+
field error. `rejectWith(schema)` sends failures that match `schema` to the
|
|
119
|
+
client as data; every other failure keeps the handling above.
|
|
120
|
+
|
|
121
|
+
Install the formatter once, then declare the rejections a procedure may send:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { rejectionFormatter, rejectWith } from "@shivaedev/effect-trpc"
|
|
125
|
+
import { BadRequest, Conflict } from "@shivaedev/platform/errors"
|
|
126
|
+
|
|
127
|
+
const t = initTRPC.context<RequestContext>().create({
|
|
128
|
+
errorFormatter: rejectionFormatter,
|
|
129
|
+
transformer: superjson,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const rename = procedure
|
|
133
|
+
.input(Schema.Struct({ name: Schema.String }))
|
|
134
|
+
.mutation(function* ({ name }) {
|
|
135
|
+
return yield* profiles.rename(name).pipe(rejectWith(Schema.Union([BadRequest, Conflict])))
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`rejectWith` encodes the matching failure with its schema and fails with a
|
|
140
|
+
`RejectionError`, a `TRPCError` that carries the encoded value. The formatter
|
|
141
|
+
adds it to the error data, next to tRPC's own fields:
|
|
142
|
+
|
|
143
|
+
```jsonc
|
|
144
|
+
{ "code": "CONFLICT", "httpStatus": 409, "path": "rename",
|
|
145
|
+
"rejection": { "_tag": "Conflict", "message": "Name is taken", "field": "name" } }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- The error message is the rejection's `message` when it has one, otherwise
|
|
149
|
+
its `_tag`. Only the encoded declared fields cross; the failure's `cause` and
|
|
150
|
+
anything outside the schema never do.
|
|
151
|
+
- The code comes from the tag. tRPC derives the HTTP status from the code.
|
|
152
|
+
Pass `rejectWith(schema, { code: (tag) => ... })` to choose another code;
|
|
153
|
+
`rejectionCode(tag)` is the default mapping:
|
|
154
|
+
|
|
155
|
+
| Tag | Code | HTTP |
|
|
156
|
+
| --- | --- | --- |
|
|
157
|
+
| `NotFound` | `NOT_FOUND` | 404 |
|
|
158
|
+
| `Unauthorized` | `UNAUTHORIZED` | 401 |
|
|
159
|
+
| `Forbidden` | `FORBIDDEN` | 403 |
|
|
160
|
+
| `Conflict` | `CONFLICT` | 409 |
|
|
161
|
+
| `PreconditionFailed` | `PRECONDITION_FAILED` | 412 |
|
|
162
|
+
| `AuthUnavailable` | `SERVICE_UNAVAILABLE` | 503 |
|
|
163
|
+
| any other, including `BadRequest` | `BAD_REQUEST` | 400 |
|
|
164
|
+
- When a procedure's input schema rejects the input, the formatter sends a
|
|
165
|
+
`BadRequest` rejection with the first issue's message and, unless the issue
|
|
166
|
+
concerns the whole input, its path as `field` (`"address.city"`,
|
|
167
|
+
`"tags.1"`). The code is `BAD_REQUEST`, as for a `BadRequest` the procedure
|
|
168
|
+
raises, so a form shows the error on its field before the handler runs.
|
|
169
|
+
- An application with its own `errorFormatter` calls
|
|
170
|
+
`withRejection(shape, error)` inside it.
|
|
171
|
+
- The error channel loses the declared types and gains `RejectionError`. An
|
|
172
|
+
effect-contract operation's `error` schema works directly:
|
|
173
|
+
`rejectWith(SaveMeal.error)`.
|
|
174
|
+
|
|
175
|
+
The browser-safe `@shivaedev/effect-trpc/client` entry reads the rejection from
|
|
176
|
+
a `TRPCClientError`:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { decodeRejection, rejectionOf } from "@shivaedev/effect-trpc/client"
|
|
180
|
+
import { rejectedField } from "@shivaedev/platform/errors"
|
|
181
|
+
|
|
182
|
+
rejectionOf(error) // Option<{ _tag: string, ... }>, still encoded
|
|
183
|
+
decodeRejection(Schema.Union([BadRequest, Conflict]))(error) // Option<BadRequest | Conflict>
|
|
184
|
+
Option.flatMap(rejectionOf(error), rejectedField) // Option<{ field, message }>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Both return `Option.none()` for any error without a tagged rejection, and
|
|
188
|
+
`decodeRejection` also for a rejection its schema does not declare. The client
|
|
189
|
+
entry imports only `effect`.
|
|
190
|
+
|
|
115
191
|
## Vitest
|
|
116
192
|
|
|
117
193
|
Install `@effect/vitest` to use the optional testing entrypoint:
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TRPCProcedureBuilder } from "@trpc/server";
|
|
2
2
|
import type { Context, Effect, Exit } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
3
|
+
import type { ResolverContext } from "./internal/procedure-types.ts";
|
|
4
|
+
import { EffectProcedureBuilder } from "./procedure.ts";
|
|
5
|
+
import type { EffectProcedureRequestServices } from "./request-services.ts";
|
|
6
|
+
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, EffectTRPCStreamInstrument } from "./types.ts";
|
|
6
7
|
export interface MakeEffectTRPCOptions<Requirements, RuntimeError> {
|
|
7
8
|
readonly instrument?: EffectTRPCInstrument;
|
|
8
9
|
readonly instrumentStream?: EffectTRPCStreamInstrument;
|
|
@@ -21,7 +22,7 @@ export interface EffectTRPCRuntime<Requirements, RuntimeError> {
|
|
|
21
22
|
readonly runWithServices?: <Services, Value>(services: Context.Context<Services>, evaluate: () => Value) => Value;
|
|
22
23
|
}
|
|
23
24
|
export interface EffectTRPCAdapter<Requirements> {
|
|
24
|
-
readonly procedure: <Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, ProvidedServices, LayerError>(builder: TRPCProcedureBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, false>, requestServices: EffectProcedureRequestServices<
|
|
25
|
+
readonly procedure: <Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, ProvidedServices, LayerError>(builder: TRPCProcedureBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, false>, requestServices: EffectProcedureRequestServices<ResolverContext<Context, Meta, ContextOverrides>, ProvidedServices, LayerError>) => EffectProcedureBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, ProvidedServices, LayerError, Requirements>;
|
|
25
26
|
readonly runWithServices: <Services, Value>(services: Context.Context<Services>, evaluate: () => Value) => Value;
|
|
26
27
|
}
|
|
27
28
|
export declare const makeEffectTRPC: <Requirements, RuntimeError = never>(options: MakeEffectTRPCOptions<Requirements, RuntimeError>) => EffectTRPCAdapter<Requirements>;
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE1G,MAAM,WAAW,qBAAqB,CAAC,YAAY,EAAE,YAAY;IAChE,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,YAAY,EA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AC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,EAC7G,eAAe,EAAE,8BAA8B,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,KAC3H,sBAAsB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IACjJ,QAAQ,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,KAAK,KAAK,CAAC;CACjH;AAED,eAAO,MAAM,cAAc,GAAI,YAAY,EAAE,YAAY,GAAG,KAAK,EAChE,SAAS,qBAAqB,CAAC,YAAY,EAAE,YAAY,CAAC,KACxD,iBAAiB,CAAC,YAAY,CAgBhC,CAAC"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { makeContextBridge } from "./internal/context-bridge.js";
|
|
2
|
+
import { looseBuilder } from "./internal/loose.js";
|
|
2
3
|
import { makeRuntimeBridge } from "./internal/runtime.js";
|
|
3
4
|
import { EffectProcedureBuilder } from "./procedure.js";
|
|
4
5
|
export const makeEffectTRPC = (options) => {
|
|
5
6
|
const contextBridge = makeContextBridge(options.runtime);
|
|
6
7
|
const runtime = makeRuntimeBridge(options.runtime, contextBridge, options);
|
|
7
8
|
return {
|
|
8
|
-
procedure: (builder, requestServices) => new EffectProcedureBuilder(builder, requestServices, runtime),
|
|
9
|
+
procedure: (builder, requestServices) => new EffectProcedureBuilder(looseBuilder(builder), requestServices, runtime),
|
|
9
10
|
runWithServices: contextBridge.run,
|
|
10
11
|
};
|
|
11
12
|
};
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAiCxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,OAA0D,EACxB,EAAE;IACpC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAE3E,OAAO;QACN,SAAS,EAAE,CACV,OAA6G,EAC7G,eAA+H,EAC9H,EAAE,CACH,IAAI,sBAAsB,CACzB,YAAY,CAAC,OAAO,CAAC,EACrB,eAAe,EACf,OAAO,CACP;QACF,eAAe,EAAE,aAAa,CAAC,GAAG;KAClC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
export declare const EncodedRejection: Schema.StructWithRest<Schema.Struct<{
|
|
3
|
+
readonly _tag: Schema.String;
|
|
4
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
|
|
5
|
+
export type EncodedRejection = typeof EncodedRejection.Type;
|
|
6
|
+
export declare const rejectionOf: (error: unknown) => Option.Option<EncodedRejection>;
|
|
7
|
+
export declare const decodeRejection: <S extends Schema.ConstraintDecoder<{
|
|
8
|
+
readonly _tag: string;
|
|
9
|
+
}>>(schema: S) => ((error: unknown) => Option.Option<S["Type"]>);
|
|
10
|
+
//# sourceMappingURL=rejection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejection.d.ts","sourceRoot":"","sources":["../../src/client/rejection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,gBAAgB;;6DAAgH,CAAC;AAE9I,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAI5D,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAmE,CAAC;AAE/I,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,CAAC,iBAAiB,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAC5F,QAAQ,CAAC,KACP,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAG/C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
export const EncodedRejection = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
3
|
+
const decodeCarrier = Schema.decodeUnknownOption(Schema.Struct({ data: Schema.Struct({ rejection: EncodedRejection }) }));
|
|
4
|
+
export const rejectionOf = (error) => Option.map(decodeCarrier(error), ({ data }) => data.rejection);
|
|
5
|
+
export const decodeRejection = (schema) => {
|
|
6
|
+
const decode = Schema.decodeUnknownOption(schema);
|
|
7
|
+
return (error) => Option.flatMap(rejectionOf(error), (rejection) => decode(rejection));
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=rejection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejection.js","sourceRoot":"","sources":["../../src/client/rejection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAI9I,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE1H,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAmC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAE/I,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,MAAS,EACwC,EAAE;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyB,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,IAAI,GAAI,MAAM,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,QAAQ,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAC1D,CAAC;AAEtD,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAwC,CAAC;AAEpG,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAyC,CAAC;AAEvG,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAsC,CAAC;AAEjG,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAsC,CAAC;AAEhG,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAqC,CAAC;AAE/F,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAgD,CAAC;AAEpH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,2CAAkD,CAAC"}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAuB,EAAE,OAAe,EAAE,KAAe,EAAmC,EAAE,CAClH,MAAM,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEpG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEvG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEjG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEhG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEpH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export { type EffectTRPCAdapter, type EffectTRPCRuntime, type MakeEffectTRPCOptions, makeEffectTRPC, } from "./adapter.
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
1
|
+
export { type EffectTRPCAdapter, type EffectTRPCRuntime, type MakeEffectTRPCOptions, makeEffectTRPC, } from "./adapter.ts";
|
|
2
|
+
export type { EncodedRejection } from "./client/rejection.ts";
|
|
3
|
+
export { badRequest, conflict, fail, forbidden, internalServerError, notFound, preconditionFailed, unauthorized, } from "./errors.ts";
|
|
4
|
+
export type { EffectProcedureBuilder } from "./procedure.ts";
|
|
5
|
+
export { RejectionError, type RejectWithOptions, rejectionCode, rejectWith } from "./rejection.ts";
|
|
6
|
+
export { type RejectionData, type RejectionErrorShape, rejectionFormatter, withRejection } from "./rejection-formatter.ts";
|
|
7
|
+
export { type EffectProcedureRequestServices, extendRequestServices, makeRequestServices, } from "./request-services.ts";
|
|
8
|
+
export { RequestSignal } from "./request-signal.ts";
|
|
9
|
+
export type { EffectTRPCErrorContext, EffectTRPCErrorMapper, EffectTRPCInstrument, EffectTRPCStreamInstrument, ProcedureInfo, ProcedureKind, } from "./types.ts";
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACN,KAAK,8BAA8B,EACnC,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,aAAa,EACb,aAAa,GACb,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EACN,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC3H,OAAO,EACN,KAAK,8BAA8B,EACnC,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,aAAa,EACb,aAAa,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { makeEffectTRPC, } from "./adapter.js";
|
|
2
2
|
export { badRequest, conflict, fail, forbidden, internalServerError, notFound, preconditionFailed, unauthorized, } from "./errors.js";
|
|
3
|
+
export { RejectionError, rejectionCode, rejectWith } from "./rejection.js";
|
|
4
|
+
export { rejectionFormatter, withRejection } from "./rejection-formatter.js";
|
|
3
5
|
export { extendRequestServices, makeRequestServices, } from "./request-services.js";
|
|
4
6
|
export { RequestSignal } from "./request-signal.js";
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,cAAc,GACd,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,cAAc,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,YAAY,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAA0B,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAgD,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC3H,OAAO,EAEN,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-bridge.d.ts","sourceRoot":"","sources":["../../src/internal/context-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"context-bridge.d.ts","sourceRoot":"","sources":["../../src/internal/context-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,KAAK,KAAK,CAAC;CACrG;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS;IAC1C,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACpD,QAAQ,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAChD,KAAG,aAcH,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
export const makeContextBridge = (shared) => {
|
|
3
|
-
if (shared?.currentServices !== undefined &&
|
|
4
|
-
shared.runWithServices !== undefined) {
|
|
3
|
+
if (shared?.currentServices !== undefined && shared.runWithServices !== undefined) {
|
|
5
4
|
return {
|
|
6
5
|
current: shared.currentServices,
|
|
7
6
|
run: shared.runWithServices,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-bridge.js","sourceRoot":"","sources":["../../src/internal/context-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"context-bridge.js","sourceRoot":"","sources":["../../src/internal/context-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAGjC,EAAiB,EAAE;IACnB,IAAI,MAAM,EAAE,eAAe,KAAK,SAAS,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACnF,OAAO;YACN,OAAO,EAAE,MAAM,CAAC,eAAe;YAC/B,GAAG,EAAE,MAAM,CAAC,eAAe;SAC3B,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAA0B,CAAC;IAEhE,OAAO;QACN,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE;QACjC,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAC5D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProcedureBuilderOf, ProcedureBuilderSurface, ResolverContext } from "./procedure-types.ts";
|
|
2
|
+
export declare function looseBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut>(builder: ProcedureBuilderOf<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut>): ProcedureBuilderSurface<ResolverContext<Context, Meta, ContextOverrides>>;
|
|
3
|
+
export declare function acceptParsedInput<Result>(resolver: (input: never) => Result): (input: unknown) => Result;
|
|
4
|
+
//# sourceMappingURL=loose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loose.d.ts","sourceRoot":"","sources":["../../src/internal/loose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEzG,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EACnG,OAAO,EAAE,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,GAClG,uBAAuB,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAM7E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loose.js","sourceRoot":"","sources":["../../src/internal/loose.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC5C,OAAO,OAAO,CAAC;AAChB,CAAC;AAID,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IAClD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import type { EffectProcedureRequestServices } from "../request-services.
|
|
2
|
-
import type { ProcedureInfo } from "../types.
|
|
3
|
-
import type { EffectProcedureResolver } from "./procedure-types.
|
|
4
|
-
import type { RuntimeBridge } from "./runtime.
|
|
5
|
-
|
|
6
|
-
readonly ctx: Context;
|
|
7
|
-
readonly input: Input;
|
|
8
|
-
readonly path: string;
|
|
9
|
-
readonly signal?: AbortSignal;
|
|
10
|
-
}
|
|
11
|
-
export declare const makeProcedureHandler: <RuntimeRequirements, Context, Input, ProvidedServices, LayerError, Output>(runtime: RuntimeBridge<RuntimeRequirements>, resolver: EffectProcedureResolver<Input, ProvidedServices | NoInfer<RuntimeRequirements>, Output>, requestServices: EffectProcedureRequestServices<Context, ProvidedServices, LayerError>, procedure: Omit<ProcedureInfo, "path">) => (invocation: ProcedureInvocation<Context, Input>) => Promise<Output>;
|
|
12
|
-
export {};
|
|
1
|
+
import type { EffectProcedureRequestServices } from "../request-services.ts";
|
|
2
|
+
import type { ProcedureInfo } from "../types.ts";
|
|
3
|
+
import type { EffectProcedureResolver, ProcedureInvocation } from "./procedure-types.ts";
|
|
4
|
+
import type { RuntimeBridge } from "./runtime.ts";
|
|
5
|
+
export declare const makeProcedureHandler: <RuntimeRequirements, Context, ProvidedServices, LayerError>(runtime: RuntimeBridge<RuntimeRequirements>, resolver: EffectProcedureResolver<never, ProvidedServices | NoInfer<RuntimeRequirements>, unknown>, requestServices: EffectProcedureRequestServices<Context, ProvidedServices, LayerError>, procedure: Omit<ProcedureInfo, "path">) => (invocation: ProcedureInvocation<Context>) => Promise<unknown>;
|
|
13
6
|
//# sourceMappingURL=procedure-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure-handler.d.ts","sourceRoot":"","sources":["../../src/internal/procedure-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"procedure-handler.d.ts","sourceRoot":"","sources":["../../src/internal/procedure-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,oBAAoB,GAAI,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAC9F,SAAS,aAAa,CAAC,mBAAmB,CAAC,EAC3C,UAAU,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,EAClG,iBAAiB,8BAA8B,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,CAAC,EACtF,WAAW,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,MAIxB,YAAY,mBAAmB,CAAC,OAAO,CAAC,qBAUtD,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { acceptParsedInput } from "./loose.js";
|
|
2
3
|
export const makeProcedureHandler = (runtime, resolver, requestServices, procedure) => {
|
|
3
|
-
const tracedResolver = Effect.fnUntraced(resolver);
|
|
4
|
+
const tracedResolver = Effect.fnUntraced(acceptParsedInput(resolver));
|
|
4
5
|
return async (invocation) => {
|
|
5
6
|
const info = { ...procedure, path: invocation.path };
|
|
6
|
-
const provided = Effect.suspend(() => runtime
|
|
7
|
-
.instrument(tracedResolver(invocation.input), info)
|
|
8
|
-
.pipe(Effect.provide(requestServices.layer(invocation.ctx))));
|
|
7
|
+
const provided = Effect.suspend(() => runtime.instrument(tracedResolver(invocation.input), info).pipe(Effect.provide(requestServices.layer(invocation.ctx))));
|
|
9
8
|
return await runtime.runEffect(provided, {
|
|
10
9
|
procedure: info,
|
|
11
10
|
...(invocation.signal === undefined ? {} : { signal: invocation.signal }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure-handler.js","sourceRoot":"","sources":["../../src/internal/procedure-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"procedure-handler.js","sourceRoot":"","sources":["../../src/internal/procedure-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,OAA2C,EAC3C,QAAkG,EAClG,eAAsF,EACtF,SAAsC,EACrC,EAAE;IACH,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtE,OAAO,KAAK,EAAE,UAAwC,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CACpC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACtH,CAAC;QACF,OAAO,MAAM,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;YACxC,SAAS,EAAE,IAAI;YACf,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;SACzE,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { inferProcedureBuilderResolverOptions, TRPCProcedureBuilder, TRPCUnsetMarker } from "@trpc/server";
|
|
2
|
-
import type { Effect, Stream } from "effect";
|
|
3
|
-
export type
|
|
2
|
+
import type { Effect, StandardSchema, Stream } from "effect";
|
|
3
|
+
export type ProcedureBuilderOf<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut> = TRPCProcedureBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, false>;
|
|
4
4
|
export type DefaultValue<Value, Fallback> = Value extends TRPCUnsetMarker ? Fallback : Value;
|
|
5
5
|
export type IntersectIfDefined<Value, With> = Value extends TRPCUnsetMarker ? With : With extends TRPCUnsetMarker ? Value : Value & With;
|
|
6
|
-
export type ResolverContext<
|
|
7
|
-
export type ProcedureEffect<Requirements> = Effect.Effect<
|
|
6
|
+
export type ResolverContext<Context, Meta, ContextOverrides> = inferProcedureBuilderResolverOptions<ProcedureBuilderOf<Context, Meta, ContextOverrides, TRPCUnsetMarker, TRPCUnsetMarker, TRPCUnsetMarker, TRPCUnsetMarker>>["ctx"];
|
|
7
|
+
export type ProcedureEffect<Requirements> = Effect.Effect<unknown, unknown, Requirements>;
|
|
8
8
|
export type EffectProcedureResolver<Input, Requirements, Output> = (input: Input) => Generator<ProcedureEffect<Requirements>, Output, never>;
|
|
9
9
|
export type EffectSubscriptionResolver<Input, Requirements, Output> = (input: Input) => Generator<ProcedureEffect<Requirements>, Stream.Stream<Output, unknown, Requirements>, never>;
|
|
10
|
+
export interface ProcedureInvocation<Context> {
|
|
11
|
+
readonly ctx: Context;
|
|
12
|
+
readonly input: unknown;
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly signal: AbortSignal | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface ProcedureBuilderSurface<Context> {
|
|
17
|
+
input(schema: StandardSchema.StandardSchemaV1): ProcedureBuilderSurface<Context>;
|
|
18
|
+
output(schema: StandardSchema.StandardSchemaV1): ProcedureBuilderSurface<Context>;
|
|
19
|
+
query(resolver: (invocation: ProcedureInvocation<Context>) => Promise<unknown>): unknown;
|
|
20
|
+
mutation(resolver: (invocation: ProcedureInvocation<Context>) => Promise<unknown>): unknown;
|
|
21
|
+
subscription(resolver: (invocation: ProcedureInvocation<Context>) => Promise<AsyncIterable<unknown, void, unknown>>): unknown;
|
|
22
|
+
}
|
|
10
23
|
//# sourceMappingURL=procedure-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure-types.d.ts","sourceRoot":"","sources":["../../src/internal/procedure-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"procedure-types.d.ts","sourceRoot":"","sources":["../../src/internal/procedure-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oCAAoC,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAChH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,IAAI,oBAAoB,CAC7H,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,CACL,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,KAAK,EAAE,QAAQ,IAAI,KAAK,SAAS,eAAe,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE7F,MAAM,MAAM,kBAAkB,CAAC,KAAK,EAAE,IAAI,IAAI,KAAK,SAAS,eAAe,GAAG,IAAI,GAAG,IAAI,SAAS,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAEzI,MAAM,MAAM,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,IAAI,oCAAoC,CAClG,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,E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AAO,CAAC,GAAG,OAAO,CAAC;IAC5F,YAAY,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;CAC9H"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
|
-
import type { EffectTRPCRuntime } from "../adapter.
|
|
3
|
-
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, ProcedureInfo } from "../types.
|
|
4
|
-
import type { ContextBridge } from "./context-bridge.
|
|
2
|
+
import type { EffectTRPCRuntime } from "../adapter.ts";
|
|
3
|
+
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, ProcedureInfo } from "../types.ts";
|
|
4
|
+
import type { ContextBridge } from "./context-bridge.ts";
|
|
5
5
|
interface RunEffectOptions {
|
|
6
6
|
readonly procedure: ProcedureInfo;
|
|
7
7
|
readonly signal?: AbortSignal;
|
|
@@ -13,7 +13,7 @@ export interface RuntimeBridge<Requirements> {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const makeRuntimeBridge: <Requirements, RuntimeError>(runtime: EffectTRPCRuntime<Requirements, RuntimeError>, contextBridge: ContextBridge, options: {
|
|
15
15
|
readonly instrument?: EffectTRPCInstrument;
|
|
16
|
-
readonly instrumentStream?: import("../types.
|
|
16
|
+
readonly instrumentStream?: import("../types.ts").EffectTRPCStreamInstrument;
|
|
17
17
|
readonly mapError?: EffectTRPCErrorMapper;
|
|
18
18
|
}) => RuntimeBridge<Requirements>;
|
|
19
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/internal/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,MAAM,EAAwB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,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CAAC;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC1C,KACC,aAAa,CAAC,YAAY,CAgD3B,CAAC"}
|
package/dist/internal/runtime.js
CHANGED
|
@@ -10,7 +10,7 @@ const mapError = (error, origin, procedure, consumerMapper) => {
|
|
|
10
10
|
return error;
|
|
11
11
|
}
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
13
|
+
return consumerMapper?.(error, { ...procedure, origin }) ?? internalError(error);
|
|
14
14
|
}
|
|
15
15
|
catch (mapperDefect) {
|
|
16
16
|
return internalError(mapperDefect);
|
|
@@ -47,13 +47,9 @@ const interruptOn = (signal) => {
|
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
export const makeRuntimeBridge = (runtime, contextBridge, options) => ({
|
|
50
|
-
instrument: (effect, procedure) => Effect.suspend(() => options.instrument === undefined
|
|
51
|
-
? effect
|
|
52
|
-
: options.instrument(effect, procedure)),
|
|
50
|
+
instrument: (effect, procedure) => Effect.suspend(() => (options.instrument === undefined ? effect : options.instrument(effect, procedure))),
|
|
53
51
|
runStream: async (stream, runOptions) => {
|
|
54
|
-
const instrumented = Stream.suspend(() => options.instrumentStream === undefined
|
|
55
|
-
? stream
|
|
56
|
-
: options.instrumentStream(stream, runOptions.procedure)).pipe(Stream.withSpan(runOptions.procedure.path, {
|
|
52
|
+
const instrumented = Stream.suspend(() => options.instrumentStream === undefined ? stream : options.instrumentStream(stream, runOptions.procedure)).pipe(Stream.withSpan(runOptions.procedure.path, {
|
|
57
53
|
attributes: {
|
|
58
54
|
"rpc.method": runOptions.procedure.path,
|
|
59
55
|
"rpc.system": "trpc",
|
|
@@ -77,12 +73,8 @@ export const makeRuntimeBridge = (runtime, contextBridge, options) => ({
|
|
|
77
73
|
captureStackTrace: runOptions.procedure.captureStackTrace,
|
|
78
74
|
}));
|
|
79
75
|
const ambient = contextBridge.current();
|
|
80
|
-
const runnable = ambient === undefined
|
|
81
|
-
|
|
82
|
-
: Effect.flatMap(runtime.contextEffect, (base) => Effect.provideContext(traced, Context.merge(base, ambient)));
|
|
83
|
-
const exit = await runtime.runPromiseExit(runnable, runOptions.signal === undefined
|
|
84
|
-
? undefined
|
|
85
|
-
: { signal: runOptions.signal });
|
|
76
|
+
const runnable = ambient === undefined ? traced : Effect.flatMap(runtime.contextEffect, (base) => Effect.provideContext(traced, Context.merge(base, ambient)));
|
|
77
|
+
const exit = await runtime.runPromiseExit(runnable, runOptions.signal === undefined ? undefined : { signal: runOptions.signal });
|
|
86
78
|
if (Exit.isSuccess(exit)) {
|
|
87
79
|
return exit.value;
|
|
88
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/internal/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/internal/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgB9E,MAAM,aAAa,GAAG,CAAC,KAAe,EAAa,EAAE,CACpD,IAAI,SAAS,CAAC;IACb,KAAK;IACL,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,uBAAuB;CAChC,CAAC,CAAC;AAEJ,MAAM,QAAQ,GAAG,CAChB,KAAc,EACd,MAA4B,EAC5B,SAAwB,EACxB,cAAiD,EACrC,EAAE;IACd,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,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CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAEjI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,KAAK,CAAC;QACnB,CAAC;QACD,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import type { EffectProcedureRequestServices } from "../request-services.
|
|
3
|
-
import type { ProcedureInfo } from "../types.
|
|
4
|
-
import type { EffectSubscriptionResolver } from "./procedure-types.
|
|
5
|
-
import type { RuntimeBridge } from "./runtime.
|
|
6
|
-
|
|
7
|
-
readonly ctx: Context;
|
|
8
|
-
readonly input: Input;
|
|
9
|
-
readonly path: string;
|
|
10
|
-
readonly signal?: AbortSignal;
|
|
11
|
-
}
|
|
12
|
-
export declare const makeSubscriptionHandler: <RuntimeRequirements, Context, Input, ProvidedServices, LayerError, Output>(runtime: RuntimeBridge<RuntimeRequirements>, resolver: EffectSubscriptionResolver<Input, ProvidedServices | NoInfer<RuntimeRequirements>, Output>, requestServices: EffectProcedureRequestServices<Context, ProvidedServices, LayerError>, procedure: Omit<ProcedureInfo, "path">, outputSchema?: Schema.ConstraintDecoder<unknown>) => (invocation: SubscriptionInvocation<Context, Input>) => Promise<AsyncIterable<Output>>;
|
|
13
|
-
export {};
|
|
2
|
+
import type { EffectProcedureRequestServices } from "../request-services.ts";
|
|
3
|
+
import type { ProcedureInfo } from "../types.ts";
|
|
4
|
+
import type { EffectSubscriptionResolver, ProcedureInvocation } from "./procedure-types.ts";
|
|
5
|
+
import type { RuntimeBridge } from "./runtime.ts";
|
|
6
|
+
export declare const makeSubscriptionHandler: <RuntimeRequirements, Context, ProvidedServices, LayerError>(runtime: RuntimeBridge<RuntimeRequirements>, resolver: EffectSubscriptionResolver<never, ProvidedServices | NoInfer<RuntimeRequirements>, unknown>, requestServices: EffectProcedureRequestServices<Context, ProvidedServices, LayerError>, procedure: Omit<ProcedureInfo, "path">, outputSchema?: Schema.ConstraintDecoder<unknown>) => (invocation: ProcedureInvocation<Context>) => Promise<AsyncIterable<unknown>>;
|
|
14
7
|
//# sourceMappingURL=subscription-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-handler.d.ts","sourceRoot":"","sources":["../../src/internal/subscription-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription-handler.d.ts","sourceRoot":"","sources":["../../src/internal/subscription-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,uBAAuB,GAAI,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EACjG,SAAS,aAAa,CAAC,mBAAmB,CAAC,EAC3C,UAAU,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,EACrG,iBAAiB,8BAA8B,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,CAAC,EACtF,WAAW,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EACtC,eAAe,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAIlC,YAAY,mBAAmB,CAAC,OAAO,CAAC,oCAWtD,CAAC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Effect, Layer, Schema, Stream } from "effect";
|
|
2
2
|
import { RequestSignal } from "../request-signal.js";
|
|
3
|
+
import { acceptParsedInput } from "./loose.js";
|
|
3
4
|
export const makeSubscriptionHandler = (runtime, resolver, requestServices, procedure, outputSchema) => {
|
|
4
|
-
const tracedResolver = Effect.fnUntraced(resolver);
|
|
5
|
+
const tracedResolver = Effect.fnUntraced(acceptParsedInput(resolver));
|
|
5
6
|
return async (invocation) => {
|
|
6
7
|
const info = { ...procedure, path: invocation.path };
|
|
7
8
|
const requestLayer = Layer.merge(requestServices.layer(invocation.ctx), Layer.succeed(RequestSignal, invocation.signal));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return await runtime.runStream(stream, {
|
|
9
|
+
const stream = Stream.unwrap(Effect.suspend(() => runtime.instrument(tracedResolver(invocation.input), info))).pipe(Stream.provide(requestLayer));
|
|
10
|
+
const decoded = outputSchema === undefined ? stream : Stream.mapEffect(stream, (value) => Schema.decodeUnknownEffect(outputSchema)(value));
|
|
11
|
+
return await runtime.runStream(decoded, {
|
|
13
12
|
procedure: info,
|
|
14
13
|
...(invocation.signal === undefined ? {} : { signal: invocation.signal }),
|
|
15
14
|
});
|