@shivaedev/effect-trpc 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +12 -4
- package/dist/adapter.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/procedure-handler.d.ts +2 -2
- package/dist/internal/procedure-handler.d.ts.map +1 -1
- package/dist/internal/procedure-types.d.ts +5 -5
- package/dist/internal/procedure-types.d.ts.map +1 -1
- package/dist/internal/runtime.d.ts +3 -3
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +16 -15
- package/dist/internal/runtime.js.map +1 -1
- package/dist/internal/subscription-handler.d.ts +2 -2
- package/dist/internal/subscription-handler.d.ts.map +1 -1
- package/dist/internal/subscription-handler.js +1 -1
- package/dist/internal/subscription-handler.js.map +1 -1
- package/dist/procedure.d.ts +12 -8
- package/dist/procedure.d.ts.map +1 -1
- package/dist/procedure.js +20 -20
- package/dist/procedure.js.map +1 -1
- package/dist/rejection-formatter.d.ts +1 -1
- package/dist/rejection-formatter.d.ts.map +1 -1
- package/dist/rejection-formatter.js +8 -5
- package/dist/rejection-formatter.js.map +1 -1
- package/dist/request-signal.d.ts +0 -1
- package/dist/request-signal.d.ts.map +1 -1
- package/dist/request-signal.js +0 -1
- package/dist/request-signal.js.map +1 -1
- package/dist/testing/caller.d.ts +1 -1
- package/dist/testing/caller.d.ts.map +1 -1
- package/dist/testing/caller.js.map +1 -1
- package/dist/testing/types.d.ts +6 -6
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/vitest.d.ts.map +1 -1
- package/dist/testing/vitest.js +1 -1
- package/dist/testing/vitest.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/package.json +43 -37
- package/src/adapter.ts +22 -8
- package/src/client.ts +1 -1
- package/src/index.ts +1 -1
- package/src/internal/procedure-handler.ts +2 -2
- package/src/internal/procedure-types.ts +5 -5
- package/src/internal/runtime.ts +26 -24
- package/src/internal/subscription-handler.ts +3 -3
- package/src/procedure.ts +35 -33
- package/src/rejection-formatter.ts +12 -6
- package/src/request-signal.ts +0 -1
- package/src/testing/caller.ts +3 -3
- package/src/testing/types.ts +7 -7
- package/src/testing/vitest.ts +1 -1
- package/src/testing.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,EAAE,GAAG,SAAS,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE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AM,WAAW,wBAAwB,CAAC,YAAY,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,SAAS,SAAS,YAAY,EAAE,OAAO,CACzI,SAAQ,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC;IAClD,QAAQ,CAAC,WAAW,EAAE,CACrB,IAAI,EAAE,mBAAmB,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,EAClF,OAAO,EAAE,WAAW,KAChB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;CAC/D;AAED,MAAM,MAAM,aAAa,CAAC,YAAY,IAAI,YAAY,SAAS,CAAC,GAAG,UAAU,EAAE,MAAM,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAEjI,MAAM,MAAM,YAAY,CAAC,YAAY,IAAI,YAAY,SAAS,CAAC,GAAG,UAAU,EAAE,MAAM,UAAU,KAAK,MAAM,MAAM,GAC5G,MAAM,SAAS,MAAM,GACpB,MAAM,GACN,KAAK,GACN,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/testing/vitest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../src/testing/vitest.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAclI,wBAAgB,iBAAiB,CAAC,YAAY,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,SAAS,SAAS,YAAY,EAAE,OAAO,EACjI,OAAO,EAAE,wBAAwB,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,GACjE,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;AAmBpD,eAAO,MAAM,UAAU,GAAI,YAAY,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,SAAS,SAAS,YAAY,EACjH,SAAS,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,KACjD,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAIxF,CAAC"}
|
package/dist/testing/vitest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { it as effectIt } from "@effect/vitest";
|
|
2
|
-
import { makeEffectIt } from "@shivaedev/effect-test";
|
|
3
2
|
import { Effect } from "effect";
|
|
3
|
+
import { makeEffectIt } from "@shivaedev/effect-test";
|
|
4
4
|
import { makeEffectCallerFactory } from "./caller.js";
|
|
5
5
|
function withEffectTRPC(tester) {
|
|
6
6
|
return new Proxy(effectIt, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/testing/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/testing/vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAA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ing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type EffectCaller, type EffectCallerFactory, makeEffectCaller, makeEffectCallerFactory, } from "
|
|
2
|
-
export type { CallerOptions, CallerResult, MakeTrpcHarnessItOptions, MakeTrpcItOptions, TrpcHarnessIt, TrpcHarnessTest, TrpcHarnessTester, TrpcIt, TrpcTest, TrpcTester, } from "
|
|
3
|
-
export { makeTrpcHarnessIt, makeTrpcIt } from "
|
|
1
|
+
export { type EffectCaller, type EffectCallerFactory, makeEffectCaller, makeEffectCallerFactory, } from "#testing/caller.ts";
|
|
2
|
+
export type { CallerOptions, CallerResult, MakeTrpcHarnessItOptions, MakeTrpcItOptions, TrpcHarnessIt, TrpcHarnessTest, TrpcHarnessTester, TrpcIt, TrpcTest, TrpcTester, } from "#testing/types.ts";
|
|
3
|
+
export { makeTrpcHarnessIt, makeTrpcIt } from "#testing/vitest.ts";
|
|
4
4
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,UAAU,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/testing.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { makeEffectCaller, makeEffectCallerFactory, } from "
|
|
2
|
-
export { makeTrpcHarnessIt, makeTrpcIt } from "
|
|
1
|
+
export { makeEffectCaller, makeEffectCallerFactory, } from "#testing/caller.ts";
|
|
2
|
+
export { makeTrpcHarnessIt, makeTrpcIt } from "#testing/vitest.ts";
|
|
3
3
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/effect-trpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Effect-native procedures and testing for tRPC",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/ShivaeDev/platform.git",
|
|
10
|
-
"directory": "packages/effect-trpc"
|
|
11
|
-
},
|
|
12
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/effect-trpc#readme",
|
|
13
6
|
"bugs": {
|
|
14
7
|
"url": "https://github.com/ShivaeDev/platform/issues"
|
|
15
8
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/ShivaeDev/platform.git",
|
|
12
|
+
"directory": "packages/effect-trpc"
|
|
18
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
19
15
|
"sideEffects": false,
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
"type": "module",
|
|
17
|
+
"imports": {
|
|
18
|
+
"#test/*": "./test/*",
|
|
19
|
+
"#*.ts": {
|
|
20
|
+
"source": "./src/*.ts",
|
|
21
|
+
"types": "./dist/*.d.ts",
|
|
22
|
+
"default": "./dist/*.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"types": "./dist/index.d.ts",
|
|
@@ -44,12 +43,27 @@
|
|
|
44
43
|
},
|
|
45
44
|
"./package.json": "./package.json"
|
|
46
45
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"src",
|
|
49
|
+
"CHANGELOG.md",
|
|
50
|
+
"README.md"
|
|
51
|
+
],
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@shivaedev/effect-test": "0.1.
|
|
53
|
+
"@shivaedev/effect-test": "0.1.3"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@effect/vitest": "4.0.0-rc.112",
|
|
57
|
+
"@shivaedev/effect-contract": "0.2.1",
|
|
58
|
+
"@shivaedev/quality": "0.7.3",
|
|
59
|
+
"@trpc/client": "11.18.0",
|
|
60
|
+
"@trpc/server": "11.18.0",
|
|
61
|
+
"@types/node": "24.10.1",
|
|
62
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
63
|
+
"effect": "4.0.0-rc.112",
|
|
64
|
+
"superjson": "2.2.6",
|
|
65
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
66
|
+
"vitest": "4.1.9"
|
|
53
67
|
},
|
|
54
68
|
"peerDependencies": {
|
|
55
69
|
"@effect/vitest": "4.0.0-rc.112",
|
|
@@ -61,25 +75,17 @@
|
|
|
61
75
|
"optional": true
|
|
62
76
|
}
|
|
63
77
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"effect": "4.0.0-rc.112",
|
|
71
|
-
"superjson": "2.2.6",
|
|
72
|
-
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
73
|
-
"vitest": "4.1.9",
|
|
74
|
-
"@shivaedev/effect-contract": "0.1.0"
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=24"
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public",
|
|
83
|
+
"provenance": true
|
|
75
84
|
},
|
|
76
85
|
"scripts": {
|
|
77
86
|
"build": "node --eval \"import('node:fs').then(({ rmSync }) => rmSync('dist', { force: true, recursive: true }))\" && tsc6 --project tsconfig.build.json",
|
|
78
|
-
"
|
|
87
|
+
"ready": "pnpm typecheck && pnpm test && pnpm build",
|
|
79
88
|
"test": "vitest run",
|
|
80
|
-
"
|
|
81
|
-
"typecheck": "tsc --noEmit",
|
|
82
|
-
"typecheck:compat": "tsc6 --noEmit",
|
|
83
|
-
"ready": "pnpm check && pnpm typecheck && pnpm typecheck:compat && pnpm test && pnpm build && pnpm test:package"
|
|
89
|
+
"typecheck": "tsc --noEmit"
|
|
84
90
|
}
|
|
85
91
|
}
|
package/src/adapter.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TRPCProcedureBuilder } from "@trpc/server";
|
|
2
2
|
import type { Context, Effect, Exit } from "effect";
|
|
3
|
-
import { makeContextBridge } from "
|
|
4
|
-
import { looseBuilder } from "
|
|
5
|
-
import type { ResolverContext } from "
|
|
6
|
-
import { makeRuntimeBridge } from "
|
|
3
|
+
import { makeContextBridge } from "#internal/context-bridge.ts";
|
|
4
|
+
import { looseBuilder } from "#internal/loose.ts";
|
|
5
|
+
import type { ResolverContext } from "#internal/procedure-types.ts";
|
|
6
|
+
import { makeRuntimeBridge } from "#internal/runtime.ts";
|
|
7
7
|
import { EffectProcedureBuilder } from "./procedure.ts";
|
|
8
8
|
import type { EffectProcedureRequestServices } from "./request-services.ts";
|
|
9
9
|
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, EffectTRPCStreamInstrument } from "./types.ts";
|
|
@@ -47,12 +47,26 @@ export const makeEffectTRPC = <Requirements, RuntimeError = never>(
|
|
|
47
47
|
procedure: <Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, ProvidedServices, LayerError>(
|
|
48
48
|
builder: TRPCProcedureBuilder<Context, Meta, ContextOverrides, InputIn, InputOut, OutputIn, OutputOut, false>,
|
|
49
49
|
requestServices: EffectProcedureRequestServices<ResolverContext<Context, Meta, ContextOverrides>, ProvidedServices, LayerError>,
|
|
50
|
-
) =>
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
) => {
|
|
51
|
+
const loose = looseBuilder(builder);
|
|
52
|
+
return new EffectProcedureBuilder<
|
|
53
|
+
Context,
|
|
54
|
+
Meta,
|
|
55
|
+
ContextOverrides,
|
|
56
|
+
InputIn,
|
|
57
|
+
InputOut,
|
|
58
|
+
OutputIn,
|
|
59
|
+
OutputOut,
|
|
60
|
+
ProvidedServices,
|
|
61
|
+
LayerError,
|
|
62
|
+
Requirements
|
|
63
|
+
>({
|
|
64
|
+
builder: loose,
|
|
53
65
|
requestServices,
|
|
54
66
|
runtime,
|
|
55
|
-
|
|
67
|
+
subscriptionBuilder: loose,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
56
70
|
runWithServices: contextBridge.run,
|
|
57
71
|
};
|
|
58
72
|
};
|
package/src/client.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { decodeRejection, type EncodedRejection, rejectionOf } from "
|
|
1
|
+
export { decodeRejection, type EncodedRejection, rejectionOf } from "#client/rejection.ts";
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
export type { EncodedRejection } from "#client/rejection.ts";
|
|
1
2
|
export {
|
|
2
3
|
type EffectTRPCAdapter,
|
|
3
4
|
type EffectTRPCRuntime,
|
|
4
5
|
type MakeEffectTRPCOptions,
|
|
5
6
|
makeEffectTRPC,
|
|
6
7
|
} from "./adapter.ts";
|
|
7
|
-
export type { EncodedRejection } from "./client/rejection.ts";
|
|
8
8
|
export {
|
|
9
9
|
badRequest,
|
|
10
10
|
conflict,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type { EffectProcedureRequestServices } from "
|
|
3
|
-
import type { ProcedureInfo } from "
|
|
2
|
+
import type { EffectProcedureRequestServices } from "#request-services.ts";
|
|
3
|
+
import type { ProcedureInfo } from "#types.ts";
|
|
4
4
|
import { acceptParsedInput } from "./loose.ts";
|
|
5
5
|
import type { EffectProcedureResolver, ProcedureInvocation } from "./procedure-types.ts";
|
|
6
6
|
import type { RuntimeBridge } from "./runtime.ts";
|
|
@@ -36,9 +36,9 @@ export interface ProcedureInvocation<Context> {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface ProcedureBuilderSurface<Context> {
|
|
39
|
-
input(schema: StandardSchema.StandardSchemaV1)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
subscription(resolver: (invocation: ProcedureInvocation<Context>) => Promise<AsyncIterable<unknown, void, unknown>>)
|
|
39
|
+
input: (schema: StandardSchema.StandardSchemaV1) => ProcedureBuilderSurface<Context>;
|
|
40
|
+
mutation: (resolver: (invocation: ProcedureInvocation<Context>) => Promise<unknown>) => unknown;
|
|
41
|
+
output: (schema: StandardSchema.StandardSchemaV1) => ProcedureBuilderSurface<Context>;
|
|
42
|
+
query: (resolver: (invocation: ProcedureInvocation<Context>) => Promise<unknown>) => unknown;
|
|
43
|
+
subscription: (resolver: (invocation: ProcedureInvocation<Context>) => Promise<AsyncIterable<unknown, void, unknown>>) => unknown;
|
|
44
44
|
}
|
package/src/internal/runtime.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TRPCError } from "@trpc/server";
|
|
2
2
|
import { Cause, Context, Effect, Exit, Option, Result, Stream } from "effect";
|
|
3
|
-
import type { EffectTRPCRuntime } from "
|
|
4
|
-
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, ProcedureInfo } from "
|
|
3
|
+
import type { EffectTRPCRuntime } from "#adapter.ts";
|
|
4
|
+
import type { EffectTRPCErrorMapper, EffectTRPCInstrument, ProcedureInfo } from "#types.ts";
|
|
5
5
|
import type { ContextBridge } from "./context-bridge.ts";
|
|
6
6
|
|
|
7
7
|
interface RunEffectOptions {
|
|
@@ -61,7 +61,9 @@ const mapCause = (cause: Cause.Cause<unknown>, procedure: ProcedureInfo, consume
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const interruptOn = (signal: AbortSignal | undefined): Effect.Effect<void> => {
|
|
64
|
-
if (signal === undefined)
|
|
64
|
+
if (signal === undefined) {
|
|
65
|
+
return Effect.never;
|
|
66
|
+
}
|
|
65
67
|
return Effect.callback<void>((resume) => {
|
|
66
68
|
if (signal.aborted) {
|
|
67
69
|
resume(Effect.void);
|
|
@@ -78,31 +80,11 @@ export const makeRuntimeBridge = <Requirements, RuntimeError>(
|
|
|
78
80
|
contextBridge: ContextBridge,
|
|
79
81
|
options: {
|
|
80
82
|
readonly instrument?: EffectTRPCInstrument;
|
|
81
|
-
readonly instrumentStream?: import("
|
|
83
|
+
readonly instrumentStream?: import("#types.ts").EffectTRPCStreamInstrument;
|
|
82
84
|
readonly mapError?: EffectTRPCErrorMapper;
|
|
83
85
|
},
|
|
84
86
|
): RuntimeBridge<Requirements> => ({
|
|
85
87
|
instrument: (effect, procedure) => Effect.suspend(() => (options.instrument === undefined ? effect : options.instrument(effect, procedure))),
|
|
86
|
-
runStream: async (stream, runOptions) => {
|
|
87
|
-
const instrumented = Stream.suspend(() =>
|
|
88
|
-
options.instrumentStream === undefined ? stream : options.instrumentStream(stream, runOptions.procedure),
|
|
89
|
-
).pipe(
|
|
90
|
-
Stream.withSpan(runOptions.procedure.path, {
|
|
91
|
-
attributes: {
|
|
92
|
-
"rpc.method": runOptions.procedure.path,
|
|
93
|
-
"rpc.system": "trpc",
|
|
94
|
-
"trpc.type": runOptions.procedure.type,
|
|
95
|
-
},
|
|
96
|
-
captureStackTrace: runOptions.procedure.captureStackTrace,
|
|
97
|
-
}),
|
|
98
|
-
Stream.interruptWhen(interruptOn(runOptions.signal)),
|
|
99
|
-
Stream.catchCause((cause) => Stream.fail(mapCause(cause, runOptions.procedure, options.mapError))),
|
|
100
|
-
);
|
|
101
|
-
const context = await runtime.runPromise(Effect.context<Requirements>());
|
|
102
|
-
const ambient = contextBridge.current();
|
|
103
|
-
const provided = ambient === undefined ? context : Context.merge(context, ambient);
|
|
104
|
-
return Stream.toAsyncIterableWith(instrumented, provided);
|
|
105
|
-
},
|
|
106
88
|
runEffect: async (effect, runOptions) => {
|
|
107
89
|
const traced = effect.pipe(
|
|
108
90
|
Effect.withSpan(
|
|
@@ -129,4 +111,24 @@ export const makeRuntimeBridge = <Requirements, RuntimeError>(
|
|
|
129
111
|
}
|
|
130
112
|
throw mapCause(exit.cause, runOptions.procedure, options.mapError);
|
|
131
113
|
},
|
|
114
|
+
runStream: async (stream, runOptions) => {
|
|
115
|
+
const instrumented = Stream.suspend(() =>
|
|
116
|
+
options.instrumentStream === undefined ? stream : options.instrumentStream(stream, runOptions.procedure),
|
|
117
|
+
).pipe(
|
|
118
|
+
Stream.withSpan(runOptions.procedure.path, {
|
|
119
|
+
attributes: {
|
|
120
|
+
"rpc.method": runOptions.procedure.path,
|
|
121
|
+
"rpc.system": "trpc",
|
|
122
|
+
"trpc.type": runOptions.procedure.type,
|
|
123
|
+
},
|
|
124
|
+
captureStackTrace: runOptions.procedure.captureStackTrace,
|
|
125
|
+
}),
|
|
126
|
+
Stream.interruptWhen(interruptOn(runOptions.signal)),
|
|
127
|
+
Stream.catchCause((cause) => Stream.fail(mapCause(cause, runOptions.procedure, options.mapError))),
|
|
128
|
+
);
|
|
129
|
+
const context = await runtime.runPromise(Effect.context<Requirements>());
|
|
130
|
+
const ambient = contextBridge.current();
|
|
131
|
+
const provided = ambient === undefined ? context : Context.merge(context, ambient);
|
|
132
|
+
return Stream.toAsyncIterableWith(instrumented, provided);
|
|
133
|
+
},
|
|
132
134
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Layer, Schema, Stream } from "effect";
|
|
2
|
-
import type { EffectProcedureRequestServices } from "
|
|
3
|
-
import { RequestSignal } from "
|
|
4
|
-
import type { ProcedureInfo } from "
|
|
2
|
+
import type { EffectProcedureRequestServices } from "#request-services.ts";
|
|
3
|
+
import { RequestSignal } from "#request-signal.ts";
|
|
4
|
+
import type { ProcedureInfo } from "#types.ts";
|
|
5
5
|
import { acceptParsedInput } from "./loose.ts";
|
|
6
6
|
import type { EffectSubscriptionResolver, ProcedureInvocation } from "./procedure-types.ts";
|
|
7
7
|
import type { RuntimeBridge } from "./runtime.ts";
|
package/src/procedure.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TRPCMutationProcedure, TRPCQueryProcedure, TRPCSubscriptionProcedure } from "@trpc/server";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import { makeProcedureHandler } from "
|
|
3
|
+
import { makeProcedureHandler } from "#internal/procedure-handler.ts";
|
|
4
4
|
import type {
|
|
5
5
|
DefaultValue,
|
|
6
6
|
EffectProcedureResolver,
|
|
@@ -8,12 +8,20 @@ import type {
|
|
|
8
8
|
IntersectIfDefined,
|
|
9
9
|
ProcedureBuilderSurface,
|
|
10
10
|
ResolverContext,
|
|
11
|
-
} from "
|
|
12
|
-
import type { RuntimeBridge } from "
|
|
13
|
-
import { captureStackTrace } from "
|
|
14
|
-
import { makeSubscriptionHandler } from "
|
|
11
|
+
} from "#internal/procedure-types.ts";
|
|
12
|
+
import type { RuntimeBridge } from "#internal/runtime.ts";
|
|
13
|
+
import { captureStackTrace } from "#internal/stack-trace.ts";
|
|
14
|
+
import { makeSubscriptionHandler } from "#internal/subscription-handler.ts";
|
|
15
15
|
import type { EffectProcedureRequestServices } from "./request-services.ts";
|
|
16
16
|
|
|
17
|
+
interface ProcedureParts<Context, Meta, ContextOverrides, ProvidedServices, LayerError, RuntimeRequirements> {
|
|
18
|
+
readonly builder: ProcedureBuilderSurface<ResolverContext<Context, Meta, ContextOverrides>>;
|
|
19
|
+
readonly requestServices: EffectProcedureRequestServices<ResolverContext<Context, Meta, ContextOverrides>, ProvidedServices, LayerError>;
|
|
20
|
+
readonly runtime: RuntimeBridge<RuntimeRequirements>;
|
|
21
|
+
readonly subscriptionBuilder: ProcedureBuilderSurface<ResolverContext<Context, Meta, ContextOverrides>>;
|
|
22
|
+
readonly subscriptionOutput?: Schema.ConstraintDecoder<unknown> | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
export class EffectProcedureBuilder<
|
|
18
26
|
Context,
|
|
19
27
|
Meta,
|
|
@@ -26,13 +34,11 @@ export class EffectProcedureBuilder<
|
|
|
26
34
|
LayerError,
|
|
27
35
|
RuntimeRequirements,
|
|
28
36
|
> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private readonly subscriptionOutput?: Schema.ConstraintDecoder<unknown>,
|
|
35
|
-
) {}
|
|
37
|
+
private readonly parts: ProcedureParts<Context, Meta, ContextOverrides, ProvidedServices, LayerError, RuntimeRequirements>;
|
|
38
|
+
|
|
39
|
+
constructor(parts: ProcedureParts<Context, Meta, ContextOverrides, ProvidedServices, LayerError, RuntimeRequirements>) {
|
|
40
|
+
this.parts = parts;
|
|
41
|
+
}
|
|
36
42
|
|
|
37
43
|
input<SchemaValue extends Schema.ConstraintDecoder<unknown>>(
|
|
38
44
|
schema: SchemaValue,
|
|
@@ -49,13 +55,11 @@ export class EffectProcedureBuilder<
|
|
|
49
55
|
RuntimeRequirements
|
|
50
56
|
> {
|
|
51
57
|
const parser = Schema.toStandardSchemaV1(schema);
|
|
52
|
-
return new EffectProcedureBuilder(
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
this.subscriptionOutput,
|
|
58
|
-
);
|
|
58
|
+
return new EffectProcedureBuilder({
|
|
59
|
+
...this.parts,
|
|
60
|
+
builder: this.parts.builder.input(parser),
|
|
61
|
+
subscriptionBuilder: this.parts.subscriptionBuilder.input(parser),
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
output<SchemaValue extends Schema.ConstraintDecoder<unknown>>(
|
|
@@ -72,13 +76,11 @@ export class EffectProcedureBuilder<
|
|
|
72
76
|
LayerError,
|
|
73
77
|
RuntimeRequirements
|
|
74
78
|
> {
|
|
75
|
-
return new EffectProcedureBuilder(
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
schema,
|
|
81
|
-
);
|
|
79
|
+
return new EffectProcedureBuilder({
|
|
80
|
+
...this.parts,
|
|
81
|
+
builder: this.parts.builder.output(Schema.toStandardSchemaV1(schema)),
|
|
82
|
+
subscriptionOutput: schema,
|
|
83
|
+
});
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
query<Output>(
|
|
@@ -93,7 +95,7 @@ export class EffectProcedureBuilder<
|
|
|
93
95
|
meta: Meta;
|
|
94
96
|
}>;
|
|
95
97
|
query(resolver: EffectProcedureResolver<never, ProvidedServices | RuntimeRequirements, unknown>): unknown {
|
|
96
|
-
return this.builder.query(this.handler("query", resolver));
|
|
98
|
+
return this.parts.builder.query(this.handler("query", resolver));
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
mutation<Output>(
|
|
@@ -108,7 +110,7 @@ export class EffectProcedureBuilder<
|
|
|
108
110
|
meta: Meta;
|
|
109
111
|
}>;
|
|
110
112
|
mutation(resolver: EffectProcedureResolver<never, ProvidedServices | RuntimeRequirements, unknown>): unknown {
|
|
111
|
-
return this.builder.mutation(this.handler("mutation", resolver));
|
|
113
|
+
return this.parts.builder.mutation(this.handler("mutation", resolver));
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
subscription<Output>(
|
|
@@ -123,18 +125,18 @@ export class EffectProcedureBuilder<
|
|
|
123
125
|
meta: Meta;
|
|
124
126
|
}>;
|
|
125
127
|
subscription(resolver: EffectSubscriptionResolver<never, ProvidedServices | RuntimeRequirements, unknown>): unknown {
|
|
126
|
-
return this.subscriptionBuilder.subscription(
|
|
128
|
+
return this.parts.subscriptionBuilder.subscription(
|
|
127
129
|
makeSubscriptionHandler(
|
|
128
|
-
this.runtime,
|
|
130
|
+
this.parts.runtime,
|
|
129
131
|
resolver,
|
|
130
|
-
this.requestServices,
|
|
132
|
+
this.parts.requestServices,
|
|
131
133
|
{ captureStackTrace: captureStackTrace(), type: "subscription" },
|
|
132
|
-
this.subscriptionOutput,
|
|
134
|
+
this.parts.subscriptionOutput,
|
|
133
135
|
),
|
|
134
136
|
);
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
private handler(type: "mutation" | "query", resolver: EffectProcedureResolver<never, ProvidedServices | RuntimeRequirements, unknown>) {
|
|
138
|
-
return makeProcedureHandler(this.runtime, resolver, this.requestServices, { captureStackTrace: captureStackTrace(), type });
|
|
140
|
+
return makeProcedureHandler(this.parts.runtime, resolver, this.parts.requestServices, { captureStackTrace: captureStackTrace(), type });
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1Error, type TRPCDefaultErrorShape, type TRPCError } from "@trpc/server";
|
|
2
|
-
import type { EncodedRejection } from "
|
|
2
|
+
import type { EncodedRejection } from "#client/rejection.ts";
|
|
3
3
|
import { type DeclaredRejection, RejectionError } from "./rejection.ts";
|
|
4
4
|
|
|
5
5
|
export interface RejectionData {
|
|
@@ -9,18 +9,24 @@ export interface RejectionData {
|
|
|
9
9
|
export type RejectionErrorShape = TRPCDefaultErrorShape & { readonly data: RejectionData };
|
|
10
10
|
|
|
11
11
|
const inputRejection = ({ issues: [issue] }: StandardSchemaV1Error): EncodedRejection | undefined => {
|
|
12
|
-
if (issue === undefined)
|
|
12
|
+
if (issue === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
13
15
|
const field = (issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".");
|
|
14
16
|
return field === ""
|
|
15
|
-
? { _tag: "BadRequest", message: issue.message
|
|
16
|
-
: { _tag: "BadRequest",
|
|
17
|
+
? { _tag: "BadRequest", invalidInput: true, message: issue.message }
|
|
18
|
+
: { _tag: "BadRequest", field, invalidInput: true, message: issue.message };
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
const declared = ({ invalidInput: _reserved, ...rejection }: DeclaredRejection): EncodedRejection => rejection;
|
|
20
22
|
|
|
21
23
|
const rejectionFrom = (error: TRPCError): EncodedRejection | undefined => {
|
|
22
|
-
if (error instanceof RejectionError)
|
|
23
|
-
|
|
24
|
+
if (error instanceof RejectionError) {
|
|
25
|
+
return declared(error.rejection);
|
|
26
|
+
}
|
|
27
|
+
if (error.code === "BAD_REQUEST" && error.cause instanceof StandardSchemaV1Error) {
|
|
28
|
+
return inputRejection(error.cause);
|
|
29
|
+
}
|
|
24
30
|
return undefined;
|
|
25
31
|
};
|
|
26
32
|
|
package/src/request-signal.ts
CHANGED
package/src/testing/caller.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTRPCErrorFromUnknown, type TRPCError } from "@trpc/server";
|
|
2
2
|
import { type Context, Effect } from "effect";
|
|
3
|
-
import type { EffectTRPCAdapter } from "
|
|
3
|
+
import type { EffectTRPCAdapter } from "#adapter.ts";
|
|
4
4
|
|
|
5
5
|
export type EffectCaller<Caller> = {
|
|
6
6
|
readonly [Key in keyof Caller]: Caller[Key] extends (...arguments_: infer Arguments) => Promise<infer Result>
|
|
@@ -19,7 +19,7 @@ type Adapter = Pick<EffectTRPCAdapter<never>, "runWithServices">;
|
|
|
19
19
|
const member = (node: unknown, segment: string): unknown =>
|
|
20
20
|
(typeof node === "object" && node !== null) || typeof node === "function" ? Reflect.get(node, segment) : undefined;
|
|
21
21
|
|
|
22
|
-
const invoke = (promiseCaller: object, path:
|
|
22
|
+
const invoke = (promiseCaller: object, path: readonly string[], argumentsList: readonly unknown[]): Promise<unknown> => {
|
|
23
23
|
const leaf = path.reduce<unknown>(member, promiseCaller);
|
|
24
24
|
return typeof leaf === "function"
|
|
25
25
|
? Promise.resolve(Reflect.apply(leaf, undefined, argumentsList))
|
|
@@ -32,7 +32,7 @@ export function makeEffectCaller<Caller extends object, Services>(
|
|
|
32
32
|
services: Context.Context<Services>,
|
|
33
33
|
): EffectCaller<Caller>;
|
|
34
34
|
export function makeEffectCaller(adapter: Adapter, promiseCaller: object, services: Context.Context<never>): unknown {
|
|
35
|
-
const build = (path:
|
|
35
|
+
const build = (path: readonly string[]): unknown =>
|
|
36
36
|
new Proxy(
|
|
37
37
|
Object.assign(() => undefined, { path }),
|
|
38
38
|
{
|
package/src/testing/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TestContext, Vitest } from "@effect/vitest";
|
|
2
|
-
import type { EffectClock, EffectTestOptions } from "@shivaedev/effect-test";
|
|
3
2
|
import type { Effect, Layer } from "effect";
|
|
4
|
-
import type {
|
|
3
|
+
import type { EffectClock, EffectTestOptions } from "@shivaedev/effect-test";
|
|
4
|
+
import type { EffectTRPCAdapter } from "#adapter.ts";
|
|
5
5
|
import type { AnyTestLayer } from "./any-test-layer.ts";
|
|
6
6
|
import type { EffectCallerFactory } from "./caller.ts";
|
|
7
7
|
|
|
@@ -12,18 +12,18 @@ export type TrpcHarnessTest<Harness, Provided> = <A, Eff extends Effect.Effect<u
|
|
|
12
12
|
) => void;
|
|
13
13
|
|
|
14
14
|
export interface TrpcHarnessTester<Harness, Provided> extends TrpcHarnessTest<Harness, Provided> {
|
|
15
|
-
readonly skip: TrpcHarnessTest<Harness, Provided>;
|
|
16
|
-
readonly skipIf: (condition: unknown) => TrpcHarnessTest<Harness, Provided>;
|
|
17
|
-
readonly runIf: (condition: unknown) => TrpcHarnessTest<Harness, Provided>;
|
|
18
|
-
readonly only: TrpcHarnessTest<Harness, Provided>;
|
|
19
15
|
readonly each: <Item>(
|
|
20
|
-
cases:
|
|
16
|
+
cases: readonly Item[],
|
|
21
17
|
) => <A, Eff extends Effect.Effect<unknown, unknown, Provided>>(
|
|
22
18
|
name: string,
|
|
23
19
|
body: (item: Item, harness: Harness, context: TestContext) => Generator<Eff, A, never>,
|
|
24
20
|
options?: number | EffectTestOptions,
|
|
25
21
|
) => void;
|
|
26
22
|
readonly fails: TrpcHarnessTest<Harness, Provided>;
|
|
23
|
+
readonly only: TrpcHarnessTest<Harness, Provided>;
|
|
24
|
+
readonly runIf: (condition: unknown) => TrpcHarnessTest<Harness, Provided>;
|
|
25
|
+
readonly skip: TrpcHarnessTest<Harness, Provided>;
|
|
26
|
+
readonly skipIf: (condition: unknown) => TrpcHarnessTest<Harness, Provided>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export type TrpcTest<Options, Caller, Provided> = TrpcHarnessTest<EffectCallerFactory<Options, Caller>, Provided>;
|
package/src/testing/vitest.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { it as effectIt, type Vitest } from "@effect/vitest";
|
|
2
|
-
import { makeEffectIt } from "@shivaedev/effect-test";
|
|
3
2
|
import { Effect, type Layer } from "effect";
|
|
3
|
+
import { makeEffectIt } from "@shivaedev/effect-test";
|
|
4
4
|
import type { AnyTestLayer } from "./any-test-layer.ts";
|
|
5
5
|
import { makeEffectCallerFactory } from "./caller.ts";
|
|
6
6
|
import type { CallerOptions, CallerResult, MakeTrpcHarnessItOptions, MakeTrpcItOptions, TrpcHarnessIt, TrpcIt } from "./types.ts";
|
package/src/testing.ts
CHANGED
|
@@ -3,7 +3,7 @@ export {
|
|
|
3
3
|
type EffectCallerFactory,
|
|
4
4
|
makeEffectCaller,
|
|
5
5
|
makeEffectCallerFactory,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#testing/caller.ts";
|
|
7
7
|
export type {
|
|
8
8
|
CallerOptions,
|
|
9
9
|
CallerResult,
|
|
@@ -15,5 +15,5 @@ export type {
|
|
|
15
15
|
TrpcIt,
|
|
16
16
|
TrpcTest,
|
|
17
17
|
TrpcTester,
|
|
18
|
-
} from "
|
|
19
|
-
export { makeTrpcHarnessIt, makeTrpcIt } from "
|
|
18
|
+
} from "#testing/types.ts";
|
|
19
|
+
export { makeTrpcHarnessIt, makeTrpcIt } from "#testing/vitest.ts";
|