@rc312/tss-effect-serverfn 0.0.0-stage → 0.2.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -2
  3. package/dist/bootstrap.server.d.ts +12 -0
  4. package/dist/bootstrap.server.d.ts.map +1 -0
  5. package/dist/bootstrap.server.js +17 -0
  6. package/dist/bootstrap.server.js.map +1 -0
  7. package/dist/boundary.server.d.ts +26 -0
  8. package/dist/boundary.server.d.ts.map +1 -0
  9. package/dist/boundary.server.js +117 -0
  10. package/dist/boundary.server.js.map +1 -0
  11. package/dist/compiler-runtime.d.ts +40 -0
  12. package/dist/compiler-runtime.d.ts.map +1 -0
  13. package/dist/compiler-runtime.js +54 -0
  14. package/dist/compiler-runtime.js.map +1 -0
  15. package/dist/create-effect-server-fn.d.ts +84 -0
  16. package/dist/create-effect-server-fn.d.ts.map +1 -0
  17. package/dist/create-effect-server-fn.js +27 -0
  18. package/dist/create-effect-server-fn.js.map +1 -0
  19. package/dist/effect-middleware.d.ts +116 -0
  20. package/dist/effect-middleware.d.ts.map +1 -0
  21. package/dist/effect-middleware.js +46 -0
  22. package/dist/effect-middleware.js.map +1 -0
  23. package/dist/execution.d.ts +35 -0
  24. package/dist/execution.d.ts.map +1 -0
  25. package/dist/execution.js +7 -0
  26. package/dist/execution.js.map +1 -0
  27. package/dist/failure.server.d.ts +44 -0
  28. package/dist/failure.server.d.ts.map +1 -0
  29. package/dist/failure.server.js +161 -0
  30. package/dist/failure.server.js.map +1 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +3 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/provenance.server.d.ts +54 -0
  36. package/dist/provenance.server.d.ts.map +1 -0
  37. package/dist/provenance.server.js +87 -0
  38. package/dist/provenance.server.js.map +1 -0
  39. package/dist/server.d.ts +3 -0
  40. package/dist/server.d.ts.map +1 -0
  41. package/dist/server.js +3 -0
  42. package/dist/server.js.map +1 -0
  43. package/dist/vite.d.ts +24 -0
  44. package/dist/vite.d.ts.map +1 -0
  45. package/dist/vite.js +296 -0
  46. package/dist/vite.js.map +1 -0
  47. package/docs/composition.md +188 -0
  48. package/docs/development.md +48 -0
  49. package/docs/usage.md +223 -0
  50. package/package.json +69 -4
  51. package/src/bootstrap.server.ts +22 -0
  52. package/src/boundary.server.ts +198 -0
  53. package/src/compiler-runtime.ts +75 -0
  54. package/src/create-effect-server-fn.ts +197 -0
  55. package/src/effect-middleware.ts +171 -0
  56. package/src/execution.ts +39 -0
  57. package/src/failure.server.ts +257 -0
  58. package/src/index.ts +12 -0
  59. package/src/provenance.server.ts +125 -0
  60. package/src/server.ts +7 -0
  61. package/src/vite.ts +462 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ryan Callahan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
- # Temporary Holding Version
1
+ # @rc312/tss-effect-serverfn
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Write TanStack Start server functions with **Effect Schemas and Effect handlers**. Call them with Start's normal Promise API.
4
+
5
+ ## Quick start
6
+
7
+ In an existing **TanStack React Start** app using **Effect 4**:
8
+
9
+ ```sh
10
+ bun add @rc312/tss-effect-serverfn 'effect@^4.1.2'
11
+ ```
12
+
13
+ ### 1. Register the Vite plugin
14
+
15
+ Add `effectServerFns()` **before** `tanstackStart()` in your existing config. Keep your other plugins and your usual Vite dev/build commands.
16
+
17
+ ```ts
18
+ import { effectServerFns } from "@rc312/tss-effect-serverfn/vite";
19
+ // vite.config.ts
20
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
21
+ import { defineConfig } from "vite";
22
+
23
+ export default defineConfig({
24
+ plugins: [effectServerFns(), tanstackStart()],
25
+ });
26
+ ```
27
+
28
+ ### 2. Configure a shared factory
29
+
30
+ Create this file once. `createEffectMiddleware` runs your Effects and catches failures. This starter needs no application services and returns a safe fallback for unexpected failures.
31
+
32
+ ```ts
33
+ import {
34
+ createEffectMiddleware,
35
+ createEffectServerFn as base,
36
+ } from "@rc312/tss-effect-serverfn";
37
+ // src/effect-server-fn.ts
38
+ import { createServerOnlyFn } from "@tanstack/react-start";
39
+ import { Effect } from "effect";
40
+
41
+ export const createEffectServerFn = base().middleware([
42
+ createEffectMiddleware({
43
+ fallbackFailure: { code: "INTERNAL", message: "Internal error" },
44
+ resolve: createServerOnlyFn(() => ({
45
+ runPromiseExit: Effect.runPromiseExit,
46
+ })),
47
+ }),
48
+ ]);
49
+ ```
50
+
51
+ Already have a `ManagedRuntime`? Use its `runPromiseExit` here; see [application services](docs/usage.md#application-services).
52
+
53
+ ### 3. Write a server function
54
+
55
+ Import the **configured factory from your app**, pass the Schema directly, and return an Effect.
56
+
57
+ ```ts
58
+ // src/greeting.functions.ts
59
+ import { Effect, Schema } from "effect";
60
+
61
+ import { createEffectServerFn } from "./effect-server-fn";
62
+
63
+ export const getGreeting = createEffectServerFn({ method: "GET" })
64
+ .validator(Schema.Struct({ name: Schema.NonEmptyString }))
65
+ .handler(({ data }) =>
66
+ Effect.gen(function* greet() {
67
+ yield* Effect.logInfo("Greeting requested");
68
+ return { message: `Hello, ${data.name}!` };
69
+ }).pipe(Effect.annotateLogs({ feature: "greeting" }))
70
+ );
71
+ ```
72
+
73
+ ### 4. Call it
74
+
75
+ Call the function from a loader, component event handler, or another server function:
76
+
77
+ ```ts
78
+ import { getGreeting } from "./greeting.functions";
79
+
80
+ const greeting = await getGreeting({ data: { name: "Ada" } });
81
+ // { message: "Hello, Ada!" }
82
+ ```
83
+
84
+ That's the setup. The plugin handles compilation; the middleware handles execution, request cancellation, cleanup, and safe failures.
85
+
86
+ ## Everyday usage
87
+
88
+ | You want to… | Use |
89
+ | --- | --- |
90
+ | Accept and transform input | `.validator(schema)`; callers pass `Encoded`, handlers receive `Type` |
91
+ | Use application services | Supply `runtime.runPromiseExit` in the shared factory |
92
+ | Add authentication/context | Native `.middleware([authMiddleware])`; read `context` in the handler |
93
+ | Acquire request resources | `Effect.acquireRelease` or `Effect.forkScoped`; Scope is provided |
94
+ | Return an approved business error | Native Schema error + a `publicError` schema in `resolve` |
95
+ | Add logs or traces | Native Effect annotations, `Effect.fn`, and `Effect.withSpan` |
96
+ | Handle router redirects/not-found in components | TanStack's `useServerFn` |
97
+
98
+ Invalid schema input rejects with `{ code: "INVALID_INPUT", message: "Invalid input" }` and HTTP 400. Other unapproved failures reject with your `fallbackFailure`. Detailed Causes stay on the server.
99
+
100
+ **Common setup mistakes:**
101
+
102
+ - Place `effectServerFns()` before `tanstackStart()`, then restart the dev server after changing Vite config.
103
+ - Import your configured factory in endpoints. The package's bare factory needs `createEffectMiddleware`, configured locally as above or through Start's global function middleware.
104
+ - Export configured builders directly, as in step 2. Keep factory calls and method names static so the compiler can find them.
105
+ - Keep runtime initialization and private configuration inside the `createServerOnlyFn` resolver.
106
+
107
+ ## Other Start function utilities
108
+
109
+ Use Start's native helpers directly from `@tanstack/react-start`:
110
+
111
+ | Utility | Effect support |
112
+ | --- | --- |
113
+ | `createServerFn` | Use `createEffectServerFn` for raw Schemas and automatically executed Effect handlers. Ordinary native server functions also work alongside it. |
114
+ | `createServerOnlyFn` | Preserves an Effect-returning function; calling it on the client throws. |
115
+ | `createClientOnlyFn` | Preserves an Effect-returning function; calling it on the server throws. |
116
+ | `createIsomorphicFn` | Selects an Effect-returning `.server()` or `.client()` implementation. |
117
+
118
+ The three environment helpers return lazy Effects for composition. Use `yield*` inside your Effect handler; the handler's runtime executes them. [Examples and execution details →](docs/usage.md#start-function-utilities)
119
+
120
+ ## More
121
+
122
+ - [Composition examples: pipe, flow, Effect.fn, and combinators](docs/composition.md)
123
+ - [Runnable basic and service examples](examples)
124
+ - [Application services, errors, reporting, and execution details](docs/usage.md)
125
+ - [Workspace development](docs/development.md)
126
+
127
+ Tested with Effect 4.1.2, React Start 1.169.2, and Vite 8.3.4. Supported peer ranges are in `package.json`.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Create a safe rejection when the lazy execution boundary cannot be loaded.
3
+ * This eager path depends only on the provenance registry and never initializes
4
+ * application services or invokes an application reporter.
5
+ *
6
+ * @param template - Trusted fallback available before loading application code.
7
+ * @param cause - Original module-loading rejection, retained only on the server.
8
+ * @returns A fresh fallback record eligible for native framework reporting.
9
+ * @internal
10
+ */
11
+ export declare const bootstrapFailure: <P extends object>(template: Readonly<P>, cause: unknown) => P;
12
+ //# sourceMappingURL=bootstrap.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.server.d.ts","sourceRoot":"","sources":["../src/bootstrap.server.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,YACrC,QAAQ,CAAC,CAAC,CAAC,SACd,OAAO,KACb,CAIF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Cause } from "effect";
2
+ import { ownFailure } from "./provenance.server.js";
3
+ /**
4
+ * Create a safe rejection when the lazy execution boundary cannot be loaded.
5
+ * This eager path depends only on the provenance registry and never initializes
6
+ * application services or invokes an application reporter.
7
+ *
8
+ * @param template - Trusted fallback available before loading application code.
9
+ * @param cause - Original module-loading rejection, retained only on the server.
10
+ * @returns A fresh fallback record eligible for native framework reporting.
11
+ * @internal
12
+ */
13
+ export const bootstrapFailure = (template, cause) => {
14
+ const failure = { ...template };
15
+ return ownFailure(failure, "native", Cause.fail(cause));
16
+ };
17
+ //# sourceMappingURL=bootstrap.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.server.js","sourceRoot":"","sources":["../src/bootstrap.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAqB,EACrB,KAAc,EACX,EAAE;IACL,MAAM,OAAO,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IAEhC,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Method } from "@tanstack/react-start";
2
+ import type { EffectMiddlewareOptions, FailureReport } from "./effect-middleware.ts";
3
+ import type { ExecutionCapability } from "./execution.ts";
4
+ interface Operation {
5
+ readonly method: Method;
6
+ readonly serverFnMeta: FailureReport["serverFnMeta"];
7
+ }
8
+ /**
9
+ * Lend a request-local execution capability to the native middleware chain.
10
+ *
11
+ * Runtime configuration is resolved only when the generated handler calls `run`.
12
+ * Decoding and business work share a Scope and operation span; both close before
13
+ * failure projection and reporting. Request cancellation interrupts that work,
14
+ * while cleanup and rejection processing are awaited before returning to Start.
15
+ * The application's runtime remains application-owned.
16
+ *
17
+ * @param options - Execution configuration and trusted fallback rejection.
18
+ * @param operation - Native function metadata used for tracing and reporting.
19
+ * @param context - Incoming native context, checked for conflicting ownership.
20
+ * @param continueMiddleware - Continue the native chain with the new capability.
21
+ * @returns The native middleware result, or a rejection selected by the boundary.
22
+ * @internal
23
+ */
24
+ export declare const execute: <R, RuntimeError, P extends object, F extends object, Output>(options: EffectMiddlewareOptions<R, RuntimeError, P, F>, operation: Operation, context: unknown, continueMiddleware: (context: ExecutionCapability<R>) => Promise<Output>) => Promise<Output>;
25
+ export {};
26
+ //# sourceMappingURL=boundary.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundary.server.d.ts","sourceRoot":"","sources":["../src/boundary.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,KAAK,EAEV,uBAAuB,EACvB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQ1D,UAAU,SAAS;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,GAClB,CAAC,EACD,YAAY,EACZ,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,EAChB,MAAM,WAEG,uBAAuB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,aAC5C,SAAS,WAEX,OAAO,sBACI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KACvE,OAAO,CAAC,MAAM,CAiJhB,CAAC"}
@@ -0,0 +1,117 @@
1
+ import { getRequest } from "@tanstack/react-start/server";
2
+ import { Cause, Effect, Exit, Predicate } from "effect";
3
+ import { HttpServerRequest } from "effect/http";
4
+ import { executionKey } from "./execution.js";
5
+ import { projectFailure, rejectMiddlewareFailure, rejectRuntimeFailure, } from "./failure.server.js";
6
+ import { ownFailure } from "./provenance.server.js";
7
+ /**
8
+ * Lend a request-local execution capability to the native middleware chain.
9
+ *
10
+ * Runtime configuration is resolved only when the generated handler calls `run`.
11
+ * Decoding and business work share a Scope and operation span; both close before
12
+ * failure projection and reporting. Request cancellation interrupts that work,
13
+ * while cleanup and rejection processing are awaited before returning to Start.
14
+ * The application's runtime remains application-owned.
15
+ *
16
+ * @param options - Execution configuration and trusted fallback rejection.
17
+ * @param operation - Native function metadata used for tracing and reporting.
18
+ * @param context - Incoming native context, checked for conflicting ownership.
19
+ * @param continueMiddleware - Continue the native chain with the new capability.
20
+ * @returns The native middleware result, or a rejection selected by the boundary.
21
+ * @internal
22
+ */
23
+ export const execute = async (options, operation,
24
+ // oxlint-disable-next-line anti-slop/no-unknown-parameters -- This native framework context is inspected only for conflicting execution ownership.
25
+ context, continueMiddleware) => {
26
+ const { fallbackFailure } = options;
27
+ let request;
28
+ try {
29
+ request = getRequest();
30
+ if (Predicate.hasProperty(context, executionKey)) {
31
+ throw new Error("Multiple Effect middleware owners cannot execute one server function");
32
+ }
33
+ }
34
+ catch (error) {
35
+ return rejectRuntimeFailure(fallbackFailure, Cause.fail(error));
36
+ }
37
+ let phase = "execution";
38
+ let active = true;
39
+ const capability = {
40
+ [executionKey]: {
41
+ beginExecution: () => {
42
+ phase = "execution";
43
+ },
44
+ beginInput: () => {
45
+ phase = "input";
46
+ },
47
+ async run(program) {
48
+ if (!active) {
49
+ return rejectRuntimeFailure(fallbackFailure, Cause.die(new Error("Effect execution outlived its native handler")));
50
+ }
51
+ if (request.signal.aborted) {
52
+ return rejectRuntimeFailure(fallbackFailure, Cause.interrupt());
53
+ }
54
+ // Resolve lazily: native middleware can reject or replace the handler without acquiring the runtime.
55
+ let configuration;
56
+ try {
57
+ configuration = await options.resolve();
58
+ }
59
+ catch (error) {
60
+ return rejectRuntimeFailure(fallbackFailure, Cause.fail(error));
61
+ }
62
+ const scopedOperation = Effect.scoped(program).pipe(Effect.withSpan(operation.serverFnMeta.name, {
63
+ attributes: {
64
+ "rpc.boundary": "server-function",
65
+ "rpc.method": operation.method,
66
+ },
67
+ }));
68
+ const supervisedOperation = Effect.uninterruptibleMask((restore) => Effect.gen(function* superviseOperation() {
69
+ // Cancellation interrupts the operation; cleanup and failure projection are awaited.
70
+ const operationExit = yield* Effect.exit(restore(scopedOperation));
71
+ if (Exit.isSuccess(operationExit)) {
72
+ return operationExit;
73
+ }
74
+ const projectionExit = yield* Effect.exit(projectFailure(operationExit.cause, phase, configuration, fallbackFailure, operation.serverFnMeta));
75
+ const rejection = Exit.isSuccess(projectionExit)
76
+ ? projectionExit.value
77
+ : ownFailure({ ...fallbackFailure }, "native", operationExit.cause);
78
+ return Exit.fail(rejection);
79
+ })).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, HttpServerRequest.fromWeb(request)));
80
+ // The outer Exit represents runtime acquisition/execution faults; the inner Exit is the projected operation result.
81
+ let runtimeExit;
82
+ try {
83
+ runtimeExit = await configuration.runPromiseExit(supervisedOperation, { signal: request.signal });
84
+ }
85
+ catch (error) {
86
+ return rejectRuntimeFailure(fallbackFailure, Cause.die(error));
87
+ }
88
+ if (Exit.isFailure(runtimeExit)) {
89
+ return rejectRuntimeFailure(fallbackFailure, runtimeExit.cause);
90
+ }
91
+ const operationExit = runtimeExit.value;
92
+ if (Exit.isFailure(operationExit)) {
93
+ throw Cause.squash(operationExit.cause);
94
+ }
95
+ return operationExit.value;
96
+ },
97
+ },
98
+ };
99
+ try {
100
+ if (request.signal.aborted) {
101
+ return rejectRuntimeFailure(fallbackFailure, Cause.interrupt());
102
+ }
103
+ const output = await continueMiddleware(capability);
104
+ if (Predicate.hasProperty(output, "result") &&
105
+ Effect.isEffect(output.result)) {
106
+ throw new Error("Missing effectServerFns() Vite plugin: the handler returned an unexecuted Effect");
107
+ }
108
+ return output;
109
+ }
110
+ catch (error) {
111
+ return rejectMiddlewareFailure(fallbackFailure, error);
112
+ }
113
+ finally {
114
+ active = false;
115
+ }
116
+ };
117
+ //# sourceMappingURL=boundary.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundary.server.js","sourceRoot":"","sources":["../src/boundary.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAO1B,OAAuD,EACvD,SAAoB;AACpB,mJAAmJ;AACnJ,OAAgB,EAChB,kBAAwE,EACvD,EAAE;IACnB,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACpC,IAAI,OAAgB,CAAC;IAErB,IAAI,CAAC;QACH,OAAO,GAAG,UAAU,EAAE,CAAC;QAEvB,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,oBAAoB,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,CAA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BAAoB,CAAC,eAAe,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;gBAClE,CAAC;gBAED,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC;gBAExC,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;oBAClC,MAAM,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC1C,CAAC;gBAED,OAAO,aAAa,CAAC,KAAK,CAAC;YAC7B,CAAC;SACF;KACF,CAAC;IAEF,IAAI,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,oBAAoB,CAAC,eAAe,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAEpD,IACE,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC;YACvC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAC9B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,uBAAuB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Effect, Schema } from "effect";
2
+ import type { ExecutionCapability } from "./execution.ts";
3
+ /**
4
+ * Nominal token carrying input decoding across native middleware validation.
5
+ * The class identity prevents arbitrary user data from impersonating a decoder.
6
+ */
7
+ declare class PendingInput {
8
+ readonly decode: Effect.Effect<unknown, Schema.SchemaError, unknown>;
9
+ constructor(decode: Effect.Effect<unknown, Schema.SchemaError, unknown>);
10
+ }
11
+ /**
12
+ * Adapt a raw Effect Schema into a deferred validator for generated Start code.
13
+ *
14
+ * Constructing the validator or applying it to input does not run decoding.
15
+ * {@link effectHandler} executes the stored decoder in the same runtime and
16
+ * Scope as business work, so service requirements and finalizers are preserved.
17
+ *
18
+ * @param schema - Endpoint Schema evaluated at the original declaration site.
19
+ * @returns A native validator that wraps raw input in a pending decoder.
20
+ * @internal
21
+ */
22
+ export declare const prepareInput: <S extends Schema.Constraint>(schema: S) => <A>(value: A) => PendingInput;
23
+ /**
24
+ * Adapt an Effect-returning callback into Start's Promise-based provider handler.
25
+ *
26
+ * Pending input is decoded first and written back to the native context. Phase
27
+ * transitions let the boundary distinguish input errors from business failures.
28
+ * Callback construction is suspended so synchronous throws become defects.
29
+ *
30
+ * @param handler - The original application handler retained by compiler lowering.
31
+ * @returns A provider callback that delegates execution to the request capability.
32
+ * @throws {Error} If execution middleware has not supplied a valid capability.
33
+ * @internal
34
+ */
35
+ export declare const effectHandler: <C extends {
36
+ data: unknown;
37
+ context: ExecutionCapability<never>;
38
+ }, A, E, R>(handler: (context: C) => Effect.Effect<A, E, R>) => (context: C) => Promise<A>;
39
+ export {};
40
+ //# sourceMappingURL=compiler-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-runtime.d.ts","sourceRoot":"","sources":["../src/compiler-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;GAGG;AACH,cAAM,YAAY;IAChB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAErE,YAAY,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAEtE;CACF;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACtB,CAAC,SAAS,MAAM,CAAC,UAAU,UAAU,CAAC,MACtC,CAAC,SAAS,CAAC,iBAGT,CAAC;AAEN;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACvB,CAAC,SAAS;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAA;CAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAC/D,CAAC,OAAO,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,eAEvC,CAAC,KAAG,OAAO,CAAC,CAAC,CAuBtB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { Effect, Predicate, Schema } from "effect";
2
+ import { executionKey } from "./execution.js";
3
+ /**
4
+ * Nominal token carrying input decoding across native middleware validation.
5
+ * The class identity prevents arbitrary user data from impersonating a decoder.
6
+ */
7
+ class PendingInput {
8
+ decode;
9
+ constructor(decode) {
10
+ this.decode = decode;
11
+ }
12
+ }
13
+ /**
14
+ * Adapt a raw Effect Schema into a deferred validator for generated Start code.
15
+ *
16
+ * Constructing the validator or applying it to input does not run decoding.
17
+ * {@link effectHandler} executes the stored decoder in the same runtime and
18
+ * Scope as business work, so service requirements and finalizers are preserved.
19
+ *
20
+ * @param schema - Endpoint Schema evaluated at the original declaration site.
21
+ * @returns A native validator that wraps raw input in a pending decoder.
22
+ * @internal
23
+ */
24
+ export const prepareInput = (schema) => (value) => new PendingInput(Effect.suspend(() => Schema.decodeUnknownEffect(schema)(value)));
25
+ /**
26
+ * Adapt an Effect-returning callback into Start's Promise-based provider handler.
27
+ *
28
+ * Pending input is decoded first and written back to the native context. Phase
29
+ * transitions let the boundary distinguish input errors from business failures.
30
+ * Callback construction is suspended so synchronous throws become defects.
31
+ *
32
+ * @param handler - The original application handler retained by compiler lowering.
33
+ * @returns A provider callback that delegates execution to the request capability.
34
+ * @throws {Error} If execution middleware has not supplied a valid capability.
35
+ * @internal
36
+ */
37
+ export const effectHandler = (handler) => (context) => {
38
+ const execution = context.context[executionKey];
39
+ if (!execution || !Predicate.isFunction(execution.run)) {
40
+ throw new Error("Effect server functions require createEffectMiddleware");
41
+ }
42
+ const program = Effect.gen(function* executeProgram() {
43
+ if (context.data instanceof PendingInput) {
44
+ execution.beginInput();
45
+ // Update the native context so post-handler middleware also sees decoded data.
46
+ context.data = yield* context.data.decode;
47
+ }
48
+ execution.beginExecution();
49
+ return yield* Effect.suspend(() => handler(context));
50
+ });
51
+ // SAFETY: The configured builder checks handler and decoder services; lowering erases that shared environment at this single execution edge.
52
+ return execution.run(program);
53
+ };
54
+ //# sourceMappingURL=compiler-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-runtime.js","sourceRoot":"","sources":["../src/compiler-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;GAGG;AACH,MAAM,YAAY;IACP,MAAM,CAAsD;IAErE,YAAY,MAA2D;QACrE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GACvB,CAA8B,MAAS,EAAE,EAAE,CAC3C,CAAI,KAAQ,EAAE,EAAE,CACd,IAAI,YAAY,CACd,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAChE,CAAC;AAEN;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,CACE,OAA+C,EAC/C,EAAE,CACJ,CAAC,OAAU,EAAc,EAAE;IACzB,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEhD,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,cAAc;QACjD,IAAI,OAAO,CAAC,IAAI,YAAY,YAAY,EAAE,CAAC;YACzC,SAAS,CAAC,UAAU,EAAE,CAAC;YACvB,+EAA+E;YAC/E,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5C,CAAC;QAED,SAAS,CAAC,cAAc,EAAE,CAAC;QAE3B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,6IAA6I;IAC7I,OAAO,SAAS,CAAC,GAAG,CAClB,OAA0D,CAC3D,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import type { Fetcher, FunctionMiddlewareWithTypes, Method, Register, ServerFnBuilder, ServerFnCtx, ServerFnOptions, ServerFnStrict, ServerFnStrictOutput } from "@tanstack/react-start";
3
+ import type { ValidateSerializableInput } from "@tanstack/router-core";
4
+ import type { Effect, Schema } from "effect";
5
+ import type { ExecutionCapability, RequestServices } from "./execution.ts";
6
+ /**
7
+ * Type-only bridge from an Effect Schema to Start's validator inference.
8
+ * Clients supply encoded input; handlers receive decoded data. Runtime decoding
9
+ * is supplied by the compiler bridge, not a Standard Schema adapter.
10
+ */
11
+ type NativeValidator<Input> = Input extends Schema.Constraint ? StandardSchemaV1<Input["Encoded"], Input["Type"]> : undefined;
12
+ type HandlerContext<MethodType, Middlewares, Input> = ServerFnCtx<Register, MethodType, Middlewares, NativeValidator<Input>>;
13
+ type DecodingServices<Input> = Input extends Schema.Constraint ? Input["DecodingServices"] : never;
14
+ type AppendMiddlewares<Current, Next extends NativeMiddlewares> = Current extends readonly unknown[] ? readonly [...Current, ...Next] : Next;
15
+ type SerializableOutput<A, Strict extends ServerFnStrict> = ServerFnStrictOutput<Strict> extends false ? A : A extends Response ? A : ValidateSerializableInput<Register, A>;
16
+ type NativeBuilder<M extends Method, Strict extends ServerFnStrict> = ServerFnBuilder<Register, M, Strict>;
17
+ type NativeMiddlewares = Parameters<NativeBuilder<Method, ServerFnStrict>["middleware"]>[0];
18
+ /**
19
+ * Enable handlers only when middleware supplies a runtime and all decoding
20
+ * services. The returned Effect must also satisfy service and wire-output checks.
21
+ */
22
+ type Handler<M extends Method, Middlewares, Input, Strict extends ServerFnStrict> = HandlerContext<M, Middlewares, Input>["context"] extends ExecutionCapability<infer Services> ? [Exclude<DecodingServices<Input>, Services | RequestServices>] extends [
23
+ never
24
+ ] ? <A, E>(handler: (context: HandlerContext<M, Middlewares, Input>) => Effect.Effect<A, E, Services | RequestServices> & Effect.Effect<SerializableOutput<A, Strict>, unknown, unknown>) => Fetcher<Middlewares, NativeValidator<Input>, A> : never : never;
25
+ type SerializableInput<Input extends Schema.Constraint, M extends Method, Strict extends ServerFnStrict> = Strict extends false | {
26
+ input: false;
27
+ } ? unknown : [M, Input["Encoded"]] extends ["POST", FormData] ? unknown : Schema.ConstraintCodec<unknown, ValidateSerializableInput<Register, Input["Encoded"]>, unknown, unknown>;
28
+ /**
29
+ * Start's server-function builder with raw Effect Schemas and Effect handlers.
30
+ *
31
+ * Native method, middleware-context, and serialization inference are preserved.
32
+ * Configured builders remain callable until a validator is attached, following
33
+ * Start's builder contract.
34
+ *
35
+ * @template M - HTTP method used by the server function.
36
+ * @template Middlewares - Accumulated native middleware and its context types.
37
+ * @template Input - The attached Effect Schema, or `undefined` before validation.
38
+ * @template Strict - Start's input/output serialization-check policy.
39
+ * @template Callable - Whether this builder can configure another endpoint.
40
+ */
41
+ export type EffectServerFnBuilder<M extends Method = "GET", Middlewares = undefined, Input = undefined, Strict extends ServerFnStrict = true, Callable extends boolean = true> = Omit<NativeBuilder<M, Strict>, "handler" | "validator" | "middleware" | "~types"> & {
42
+ readonly "~types": FunctionMiddlewareWithTypes<Register, Middlewares, NativeValidator<Input>, undefined, undefined, undefined, undefined>["~types"] & {
43
+ readonly method: M;
44
+ readonly strict: Strict;
45
+ readonly response: undefined;
46
+ };
47
+ /**
48
+ * Return an Effect using decoded data and native middleware context.
49
+ * The generated client function returns a Promise; remote rejections do not
50
+ * carry the Effect error channel as a TypeScript rejection type.
51
+ */
52
+ readonly handler: Handler<M, Middlewares, Input, Strict>;
53
+ /** Decode raw input in the handler's application runtime and request Scope. */
54
+ readonly validator: <NextInput extends Schema.Constraint>(schema: NextInput & SerializableInput<NextInput, M, Strict>) => EffectServerFnBuilder<M, Middlewares, NextInput, Strict, false>;
55
+ /** Append native middleware, retaining its inferred context and execution services. */
56
+ readonly middleware: <const Next extends NativeMiddlewares>(middlewares: Next) => EffectServerFnBuilder<M, AppendMiddlewares<Middlewares, Next>, Input, Strict, Callable>;
57
+ } & (Callable extends true ? <NextMethod extends Method = M, NextStrict extends ServerFnStrict = Strict>(options?: ServerFnOptions<NextMethod, NextStrict>) => EffectServerFnBuilder<NextMethod, Middlewares, Input, NextStrict> : unknown);
58
+ /** Factory signature for an Effect-aware native Start server-function builder. */
59
+ export type CreateEffectServerFn = <M extends Method = "GET", Strict extends ServerFnStrict = true>(options?: ServerFnOptions<M, Strict>) => EffectServerFnBuilder<M, undefined, undefined, Strict>;
60
+ /**
61
+ * Define a Start server function using an Effect Schema and an Effect handler.
62
+ *
63
+ * Requires `effectServerFns()` from `@rc312/tss-effect-serverfn/vite`, installed before
64
+ * `tanstackStart()`, and execution middleware from `createEffectMiddleware`.
65
+ * This value retains the native `createServerFn` identity; the plugin adapts
66
+ * validators and handlers before Start performs extraction and RPC generation.
67
+ *
68
+ * @param options - Native Start options, including HTTP method and strictness.
69
+ * @returns A builder whose completed handler exposes Start's Promise client.
70
+ *
71
+ * @example
72
+ * Using the shared factory configured with execution middleware:
73
+ * ```ts
74
+ * import { Effect, Schema } from "effect";
75
+ * import { createEffectServerFn } from "./effect-server-fn";
76
+ *
77
+ * export const greet = createEffectServerFn({ method: "GET" })
78
+ * .validator(Schema.Struct({ name: Schema.NonEmptyString }))
79
+ * .handler(({ data }) => Effect.succeed(`Hello, ${data.name}!`));
80
+ * ```
81
+ */
82
+ export declare const createEffectServerFn: CreateEffectServerFn;
83
+ export {};
84
+ //# sourceMappingURL=create-effect-server-fn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-effect-server-fn.d.ts","sourceRoot":"","sources":["../src/create-effect-server-fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EACV,OAAO,EACP,2BAA2B,EAC3B,MAAM,EACN,QAAQ,EACR,eAAe,EACf,WAAW,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE3E;;;;GAIG;AACH,KAAK,eAAe,CAAC,KAAK,IAAI,KAAK,SAAS,MAAM,CAAC,UAAU,GACzD,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GACjD,SAAS,CAAC;AAEd,KAAK,cAAc,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,IAAI,WAAW,CAC/D,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,CAAC,KAAK,CAAC,CACvB,C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,oBAE6B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { createServerFn } from "@tanstack/react-start";
2
+ /**
3
+ * Define a Start server function using an Effect Schema and an Effect handler.
4
+ *
5
+ * Requires `effectServerFns()` from `@rc312/tss-effect-serverfn/vite`, installed before
6
+ * `tanstackStart()`, and execution middleware from `createEffectMiddleware`.
7
+ * This value retains the native `createServerFn` identity; the plugin adapts
8
+ * validators and handlers before Start performs extraction and RPC generation.
9
+ *
10
+ * @param options - Native Start options, including HTTP method and strictness.
11
+ * @returns A builder whose completed handler exposes Start's Promise client.
12
+ *
13
+ * @example
14
+ * Using the shared factory configured with execution middleware:
15
+ * ```ts
16
+ * import { Effect, Schema } from "effect";
17
+ * import { createEffectServerFn } from "./effect-server-fn";
18
+ *
19
+ * export const greet = createEffectServerFn({ method: "GET" })
20
+ * .validator(Schema.Struct({ name: Schema.NonEmptyString }))
21
+ * .handler(({ data }) => Effect.succeed(`Hello, ${data.name}!`));
22
+ * ```
23
+ */
24
+ export const createEffectServerFn =
25
+ // SAFETY: The compiler lowers raw schemas and Effect callbacks before TanStack consumes them.
26
+ createServerFn;
27
+ //# sourceMappingURL=create-effect-server-fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-effect-server-fn.js","sourceRoot":"","sources":["../src/create-effect-server-fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA2KvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,oBAAoB;AAC/B,8FAA8F;AAC9F,cAA8D,CAAC"}