@shivaedev/effect-trpc 0.6.0 → 0.7.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 (172) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +309 -186
  3. package/dist/{client/rejection.d.ts → rejectionDecoding.d.ts} +4 -4
  4. package/dist/rejectionDecoding.d.ts.map +1 -0
  5. package/dist/{client/rejection.js → rejectionDecoding.js} +6 -4
  6. package/dist/rejectionDecoding.js.map +1 -0
  7. package/dist/server/EffectProcedureBuilder.d.ts +35 -0
  8. package/dist/server/EffectProcedureBuilder.d.ts.map +1 -0
  9. package/dist/server/EffectProcedureBuilder.js +38 -0
  10. package/dist/server/EffectProcedureBuilder.js.map +1 -0
  11. package/dist/{request-signal.d.ts → server/RequestSignal.d.ts} +1 -1
  12. package/dist/server/RequestSignal.d.ts.map +1 -0
  13. package/dist/{request-signal.js → server/RequestSignal.js} +1 -1
  14. package/dist/server/RequestSignal.js.map +1 -0
  15. package/dist/server/adapter.d.ts +29 -0
  16. package/dist/server/adapter.d.ts.map +1 -0
  17. package/dist/{adapter.js → server/adapter.js} +3 -3
  18. package/dist/server/adapter.js.map +1 -0
  19. package/dist/server/errors.d.ts +11 -0
  20. package/dist/server/errors.d.ts.map +1 -0
  21. package/dist/server/errors.js +27 -0
  22. package/dist/server/errors.js.map +1 -0
  23. package/dist/server/internal/captureStackTrace.d.ts +2 -0
  24. package/dist/server/internal/captureStackTrace.d.ts.map +1 -0
  25. package/dist/{internal/stack-trace.js → server/internal/captureStackTrace.js} +4 -4
  26. package/dist/server/internal/captureStackTrace.js.map +1 -0
  27. package/dist/{internal/context-bridge.d.ts → server/internal/contextBridge.d.ts} +4 -4
  28. package/dist/server/internal/contextBridge.d.ts.map +1 -0
  29. package/dist/{internal/context-bridge.js → server/internal/contextBridge.js} +3 -3
  30. package/dist/server/internal/contextBridge.js.map +1 -0
  31. package/dist/server/internal/loose.d.ts +4 -0
  32. package/dist/server/internal/loose.d.ts.map +1 -0
  33. package/dist/server/internal/loose.js.map +1 -0
  34. package/dist/server/internal/makeProcedureHandler.d.ts +6 -0
  35. package/dist/server/internal/makeProcedureHandler.d.ts.map +1 -0
  36. package/dist/{internal/procedure-handler.js → server/internal/makeProcedureHandler.js} +3 -3
  37. package/dist/server/internal/makeProcedureHandler.js.map +1 -0
  38. package/dist/server/internal/makeSubscriptionHandler.d.ts +7 -0
  39. package/dist/server/internal/makeSubscriptionHandler.d.ts.map +1 -0
  40. package/dist/{internal/subscription-handler.js → server/internal/makeSubscriptionHandler.js} +7 -5
  41. package/dist/server/internal/makeSubscriptionHandler.js.map +1 -0
  42. package/dist/server/internal/procedureTypes.d.ts +23 -0
  43. package/dist/server/internal/procedureTypes.d.ts.map +1 -0
  44. package/dist/server/internal/procedureTypes.js +2 -0
  45. package/dist/server/internal/procedureTypes.js.map +1 -0
  46. package/dist/server/internal/runtime.d.ts +20 -0
  47. package/dist/server/internal/runtime.d.ts.map +1 -0
  48. package/dist/server/internal/runtime.js +94 -0
  49. package/dist/server/internal/runtime.js.map +1 -0
  50. package/dist/{rejection.d.ts → server/rejection.d.ts} +5 -5
  51. package/dist/server/rejection.d.ts.map +1 -0
  52. package/dist/{rejection.js → server/rejection.js} +7 -3
  53. package/dist/server/rejection.js.map +1 -0
  54. package/dist/{rejection-formatter.d.ts → server/rejectionFormatter.d.ts} +6 -6
  55. package/dist/server/rejectionFormatter.d.ts.map +1 -0
  56. package/dist/{rejection-formatter.js → server/rejectionFormatter.js} +13 -9
  57. package/dist/server/rejectionFormatter.js.map +1 -0
  58. package/dist/server/requestServices.d.ts +7 -0
  59. package/dist/server/requestServices.d.ts.map +1 -0
  60. package/dist/server/requestServices.js +8 -0
  61. package/dist/server/requestServices.js.map +1 -0
  62. package/dist/{testing/any-test-layer.d.ts → server/testing/AnyTestLayer.d.ts} +1 -1
  63. package/dist/server/testing/AnyTestLayer.d.ts.map +1 -0
  64. package/dist/server/testing/AnyTestLayer.js +2 -0
  65. package/dist/server/testing/AnyTestLayer.js.map +1 -0
  66. package/dist/server/testing/caller.d.ts +12 -0
  67. package/dist/server/testing/caller.d.ts.map +1 -0
  68. package/dist/server/testing/caller.js +48 -0
  69. package/dist/server/testing/caller.js.map +1 -0
  70. package/dist/server/testing/types.d.ts +36 -0
  71. package/dist/server/testing/types.d.ts.map +1 -0
  72. package/dist/server/testing/types.js.map +1 -0
  73. package/dist/server/testing/vitest.d.ts +6 -0
  74. package/dist/server/testing/vitest.d.ts.map +1 -0
  75. package/dist/{testing → server/testing}/vitest.js +8 -6
  76. package/dist/server/testing/vitest.js.map +1 -0
  77. package/dist/server/types.d.ts.map +1 -0
  78. package/dist/{testing → server}/types.js.map +1 -1
  79. package/docs/north-star.md +48 -0
  80. package/docs/roadmap.md +33 -0
  81. package/package.json +198 -22
  82. package/src/{client/rejection.ts → rejectionDecoding.ts} +7 -5
  83. package/src/server/EffectProcedureBuilder.ts +134 -0
  84. package/src/{request-signal.ts → server/RequestSignal.ts} +0 -1
  85. package/src/server/adapter.ts +83 -0
  86. package/src/server/errors.ts +26 -0
  87. package/src/{internal/stack-trace.ts → server/internal/captureStackTrace.ts} +3 -4
  88. package/src/{internal/context-bridge.ts → server/internal/contextBridge.ts} +4 -8
  89. package/src/server/internal/loose.ts +12 -0
  90. package/src/{internal/procedure-handler.ts → server/internal/makeProcedureHandler.ts} +8 -10
  91. package/src/{internal/subscription-handler.ts → server/internal/makeSubscriptionHandler.ts} +12 -13
  92. package/src/server/internal/procedureTypes.ts +35 -0
  93. package/src/server/internal/runtime.ts +131 -0
  94. package/src/{rejection.ts → server/rejection.ts} +22 -19
  95. package/src/{rejection-formatter.ts → server/rejectionFormatter.ts} +25 -18
  96. package/src/server/requestServices.ts +23 -0
  97. package/src/{testing/any-test-layer.ts → server/testing/AnyTestLayer.ts} +0 -1
  98. package/src/{testing → server/testing}/caller.ts +28 -33
  99. package/src/server/testing/types.ts +55 -0
  100. package/src/{testing → server/testing}/vitest.ts +17 -17
  101. package/src/{types.ts → server/types.ts} +0 -6
  102. package/dist/adapter.d.ts +0 -29
  103. package/dist/adapter.d.ts.map +0 -1
  104. package/dist/adapter.js.map +0 -1
  105. package/dist/client/rejection.d.ts.map +0 -1
  106. package/dist/client/rejection.js.map +0 -1
  107. package/dist/errors.d.ts +0 -11
  108. package/dist/errors.d.ts.map +0 -1
  109. package/dist/errors.js +0 -11
  110. package/dist/errors.js.map +0 -1
  111. package/dist/internal/context-bridge.d.ts.map +0 -1
  112. package/dist/internal/context-bridge.js.map +0 -1
  113. package/dist/internal/loose.d.ts +0 -4
  114. package/dist/internal/loose.d.ts.map +0 -1
  115. package/dist/internal/loose.js.map +0 -1
  116. package/dist/internal/procedure-handler.d.ts +0 -6
  117. package/dist/internal/procedure-handler.d.ts.map +0 -1
  118. package/dist/internal/procedure-handler.js.map +0 -1
  119. package/dist/internal/procedure-types.d.ts +0 -23
  120. package/dist/internal/procedure-types.d.ts.map +0 -1
  121. package/dist/internal/procedure-types.js +0 -2
  122. package/dist/internal/procedure-types.js.map +0 -1
  123. package/dist/internal/runtime.d.ts +0 -20
  124. package/dist/internal/runtime.d.ts.map +0 -1
  125. package/dist/internal/runtime.js +0 -85
  126. package/dist/internal/runtime.js.map +0 -1
  127. package/dist/internal/stack-trace.d.ts +0 -2
  128. package/dist/internal/stack-trace.d.ts.map +0 -1
  129. package/dist/internal/stack-trace.js.map +0 -1
  130. package/dist/internal/subscription-handler.d.ts +0 -7
  131. package/dist/internal/subscription-handler.d.ts.map +0 -1
  132. package/dist/internal/subscription-handler.js.map +0 -1
  133. package/dist/procedure.d.ts +0 -36
  134. package/dist/procedure.d.ts.map +0 -1
  135. package/dist/procedure.js +0 -38
  136. package/dist/procedure.js.map +0 -1
  137. package/dist/rejection-formatter.d.ts.map +0 -1
  138. package/dist/rejection-formatter.js.map +0 -1
  139. package/dist/rejection.d.ts.map +0 -1
  140. package/dist/rejection.js.map +0 -1
  141. package/dist/request-services.d.ts +0 -7
  142. package/dist/request-services.d.ts.map +0 -1
  143. package/dist/request-services.js +0 -4
  144. package/dist/request-services.js.map +0 -1
  145. package/dist/request-signal.d.ts.map +0 -1
  146. package/dist/request-signal.js.map +0 -1
  147. package/dist/testing/any-test-layer.d.ts.map +0 -1
  148. package/dist/testing/any-test-layer.js +0 -2
  149. package/dist/testing/any-test-layer.js.map +0 -1
  150. package/dist/testing/caller.d.ts +0 -12
  151. package/dist/testing/caller.d.ts.map +0 -1
  152. package/dist/testing/caller.js +0 -42
  153. package/dist/testing/caller.js.map +0 -1
  154. package/dist/testing/types.d.ts +0 -36
  155. package/dist/testing/types.d.ts.map +0 -1
  156. package/dist/testing/vitest.d.ts +0 -6
  157. package/dist/testing/vitest.d.ts.map +0 -1
  158. package/dist/testing/vitest.js.map +0 -1
  159. package/dist/types.d.ts.map +0 -1
  160. package/dist/types.js.map +0 -1
  161. package/src/adapter.ts +0 -72
  162. package/src/errors.ts +0 -19
  163. package/src/internal/loose.ts +0 -14
  164. package/src/internal/procedure-types.ts +0 -44
  165. package/src/internal/runtime.ts +0 -134
  166. package/src/procedure.ts +0 -142
  167. package/src/request-services.ts +0 -23
  168. package/src/testing/types.ts +0 -63
  169. /package/dist/{internal → server/internal}/loose.js +0 -0
  170. /package/dist/{testing → server/testing}/types.js +0 -0
  171. /package/dist/{types.d.ts → server/types.d.ts} +0 -0
  172. /package/dist/{types.js → server/types.js} +0 -0
@@ -8,8 +8,12 @@ const TAXONOMY_CODES = new Map([
8
8
  ["PreconditionFailed", "PRECONDITION_FAILED"],
9
9
  ["TooManyRequests", "TOO_MANY_REQUESTS"],
10
10
  ["AuthUnavailable", "SERVICE_UNAVAILABLE"],
11
+ ["ServiceUnavailable", "SERVICE_UNAVAILABLE"],
12
+ ["InternalServerError", "INTERNAL_SERVER_ERROR"],
11
13
  ]);
12
- export const rejectionCode = (tag) => TAXONOMY_CODES.get(tag) ?? "BAD_REQUEST";
14
+ export function rejectionCode(tag) {
15
+ return TAXONOMY_CODES.get(tag) ?? "BAD_REQUEST";
16
+ }
13
17
  const DeclaredRejection = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Unknown)]);
14
18
  export class RejectionError extends TRPCError {
15
19
  rejection;
@@ -18,11 +22,11 @@ export class RejectionError extends TRPCError {
18
22
  this.rejection = rejection;
19
23
  }
20
24
  }
21
- const encodeRejection = (schema) => {
25
+ function encodeRejection(schema) {
22
26
  const encode = Schema.encodeUnknownEffect(schema);
23
27
  const tagged = Schema.decodeUnknownEffect(DeclaredRejection);
24
28
  return (rejection) => Effect.orDie(Effect.flatMap(encode(rejection), tagged));
25
- };
29
+ }
26
30
  export function rejectWith(schema, options) {
27
31
  const is = Schema.is(schema);
28
32
  const encode = encodeRejection(schema);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rejection.js","sourceRoot":"","sources":["../../src/server/rejection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,SAAS,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,cAAc,GAAG,IAAI,GAAG,CAA8B;IAC3D,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,WAAW,EAAE,WAAW,CAAC;IAC1B,CAAC,UAAU,EAAE,UAAU,CAAC;IACxB,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;IAC7C,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IACxC,CAAC,iBAAiB,EAAE,qBAAqB,CAAC;IAC1C,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;IAC7C,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;CAChD,CAAC,CAAC;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACxC,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC;AACjD,CAAC;AACD,MAAM,iBAAiB,GAAG,M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AE,EAAE,CACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC5G,CAAC;AACJ,CAAC"}
@@ -1,18 +1,18 @@
1
1
  import { type TRPCDefaultErrorShape, type TRPCError } from "@trpc/server";
2
- import type { EncodedRejection } from "#client/rejection.ts";
2
+ import type { EncodedRejection } from "#rejectionDecoding.ts";
3
3
  export interface RejectionData {
4
4
  readonly rejection?: EncodedRejection;
5
5
  }
6
6
  export type RejectionErrorShape = TRPCDefaultErrorShape & {
7
7
  readonly data: RejectionData;
8
8
  };
9
- export declare const withRejection: <Shape extends {
9
+ export declare function withRejection<TShape extends {
10
10
  readonly data: object;
11
- }>(shape: Shape, error: TRPCError) => Shape & {
11
+ }>(shape: TShape, error: TRPCError): TShape & {
12
12
  readonly data: RejectionData;
13
13
  };
14
- export declare const rejectionFormatter: ({ shape, error }: {
14
+ export declare function rejectionFormatter({ shape, error }: {
15
15
  readonly shape: TRPCDefaultErrorShape;
16
16
  readonly error: TRPCError;
17
- }) => RejectionErrorShape;
18
- //# sourceMappingURL=rejection-formatter.d.ts.map
17
+ }): RejectionErrorShape;
18
+ //# sourceMappingURL=rejectionFormatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rejectionFormatter.d.ts","sourceRoot":"","sources":["../../src/server/rejectionFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,qBAAqB,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CACtC;AACD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG;IACzD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC7B,CAAC;AAsBF,wBAAgB,aAAa,CAC5B,MAAM,SAAS;IACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,EAED,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,GACd,MAAM,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC7B,CAGA;AACD,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,mBAAmB,CAE9I"}
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1Error } from "@trpc/server";
2
2
  import { RejectionError } from "./rejection.js";
3
- const inputRejection = ({ issues: [issue] }) => {
3
+ function inputRejection({ issues: [issue] }) {
4
4
  if (issue === undefined) {
5
5
  return undefined;
6
6
  }
@@ -8,9 +8,11 @@ const inputRejection = ({ issues: [issue] }) => {
8
8
  return field === ""
9
9
  ? { _tag: "BadRequest", invalidInput: true, message: issue.message }
10
10
  : { _tag: "BadRequest", field, invalidInput: true, message: issue.message };
11
- };
12
- const declared = ({ invalidInput: _reserved, ...rejection }) => rejection;
13
- const rejectionFrom = (error) => {
11
+ }
12
+ function declared({ invalidInput: _reserved, ...rejection }) {
13
+ return rejection;
14
+ }
15
+ function rejectionFrom(error) {
14
16
  if (error instanceof RejectionError) {
15
17
  return declared(error.rejection);
16
18
  }
@@ -18,10 +20,12 @@ const rejectionFrom = (error) => {
18
20
  return inputRejection(error.cause);
19
21
  }
20
22
  return undefined;
21
- };
22
- export const withRejection = (shape, error) => {
23
+ }
24
+ export function withRejection(shape, error) {
23
25
  const rejection = rejectionFrom(error);
24
26
  return rejection === undefined ? shape : { ...shape, data: { ...shape.data, rejection } };
25
- };
26
- export const rejectionFormatter = ({ shape, error }) => withRejection(shape, error);
27
- //# sourceMappingURL=rejection-formatter.js.map
27
+ }
28
+ export function rejectionFormatter({ shape, error }) {
29
+ return withRejection(shape, error);
30
+ }
31
+ //# sourceMappingURL=rejectionFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rejectionFormatter.js","sourceRoot":"","sources":["../../src/server/rejectionFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA8C,MAAM,cAAc,CAAC;AAEjG,OAAO,EAA0B,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOxE,SAAS,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAyB;IACjE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzH,OAAO,KAAK,KAAK,EAAE;QAClB,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;QACpE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AAC9E,CAAC;AACD,SAAS,QAAQ,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,SAAS,EAAqB;IAC7E,OAAO,SAAS,CAAC;AAClB,CAAC;AACD,SAAS,aAAa,CAAC,KAAgB;IACtC,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,KAAK,YAAY,qBAAqB,EAAE,CAAC;QAClF,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AACD,MAAM,UAAU,aAAa,CAK5B,KAAa,EACb,KAAgB;IAIhB,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;AAC3F,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAwE;IACxH,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Layer as EffectLayer } from "effect";
2
+ export interface EffectProcedureRequestServices<TContext, TRequirements, TError = never> {
3
+ readonly layer: (context: TContext) => EffectLayer.Layer<TRequirements, TError>;
4
+ }
5
+ export declare function makeRequestServices<TContext, TRequirements, TError = never>(layer: (context: TContext) => EffectLayer.Layer<TRequirements, TError>): EffectProcedureRequestServices<TContext, TRequirements, TError>;
6
+ export declare function extendRequestServices<TBaseContext, TContext extends TBaseContext, TBaseRequirements, TBaseError, TAdditionalRequirements, TAdditionalError, TAdditionalDependencies extends TBaseRequirements = TBaseRequirements>(base: EffectProcedureRequestServices<TBaseContext, TBaseRequirements, TBaseError>, additional: (context: TContext) => EffectLayer.Layer<TAdditionalRequirements, TAdditionalError, TAdditionalDependencies>): EffectProcedureRequestServices<TContext, TBaseRequirements | TAdditionalRequirements, TBaseError | TAdditionalError>;
7
+ //# sourceMappingURL=requestServices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestServices.d.ts","sourceRoot":"","sources":["../../src/server/requestServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,WAAW,EAAS,MAAM,QAAQ,CAAC;AAC1D,MAAM,WAAW,8BAA8B,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,KAAK;IACtF,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,WAAW,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;CAChF;AACD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,KAAK,EAC1E,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,WAAW,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,GACpE,8BAA8B,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAEjE;AACD,wBAAgB,qBAAqB,CACpC,YAAY,EACZ,QAAQ,SAAS,YAAY,EAC7B,iBAAiB,EACjB,UAAU,EACV,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,SAAS,iBAAiB,GAAG,iBAAiB,EAErE,IAAI,EAAE,8BAA8B,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,CAAC,EACjF,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,WAAW,CAAC,KAAK,CAAC,uBAAuB,EAAE,gBAAgB,EAAE,uBAAuB,CAAC,GACtH,8BAA8B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,uBAAuB,EAAE,UAAU,GAAG,gBAAgB,CAAC,CAEtH"}
@@ -0,0 +1,8 @@
1
+ import { Layer } from "effect";
2
+ export function makeRequestServices(layer) {
3
+ return { layer };
4
+ }
5
+ export function extendRequestServices(base, additional) {
6
+ return makeRequestServices((context) => Layer.provideMerge(additional(context), base.layer(context)));
7
+ }
8
+ //# sourceMappingURL=requestServices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestServices.js","sourceRoot":"","sources":["../../src/server/requestServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI1D,MAAM,UAAU,mBAAmB,CAClC,KAAsE;IAEtE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AACD,MAAM,UAAU,qBAAqB,CASpC,IAAiF,EACjF,UAAwH;IAExH,OAAO,mBAAmB,CAAC,CAAC,OAAiB,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjH,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import type { Layer } from "effect";
2
2
  export type AnyTestLayer = Layer.Layer<any, any, never>;
3
- //# sourceMappingURL=any-test-layer.d.ts.map
3
+ //# sourceMappingURL=AnyTestLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnyTestLayer.d.ts","sourceRoot":"","sources":["../../../src/server/testing/AnyTestLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AnyTestLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnyTestLayer.js","sourceRoot":"","sources":["../../../src/server/testing/AnyTestLayer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { type TRPCError } from "@trpc/server";
2
+ import { type Context, Effect } from "effect";
3
+ import type { EffectTRPCAdapter } from "#adapter.ts";
4
+ export type EffectCaller<TCaller> = {
5
+ readonly [TKey in keyof TCaller]: TCaller[TKey] extends (...arguments_: infer TArguments) => Promise<infer TResult> ? (...arguments_: TArguments) => Effect.Effect<TResult, TRPCError> : TCaller[TKey] extends (...arguments_: infer TArguments) => infer TResult ? (...arguments_: TArguments) => TResult : TCaller[TKey] extends Record<string, unknown> ? EffectCaller<TCaller[TKey]> : TCaller[TKey];
6
+ };
7
+ export type EffectCallerFactory<TOptions, TCaller> = EffectCaller<TCaller> & ((options?: TOptions) => EffectCaller<TCaller>);
8
+ type Adapter = Pick<EffectTRPCAdapter<never>, "runWithServices">;
9
+ export declare function makeEffectCaller<TCaller extends object, TServices>(adapter: Adapter, promiseCaller: TCaller, services: Context.Context<TServices>): EffectCaller<TCaller>;
10
+ export declare function makeEffectCallerFactory<TOptions, TCaller extends object, TServices>(adapter: Adapter, createCaller: (options?: TOptions) => TCaller, services: Context.Context<TServices>): EffectCallerFactory<TOptions, TCaller>;
11
+ export {};
12
+ //# sourceMappingURL=caller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caller.d.ts","sourceRoot":"","sources":["../../../src/server/testing/caller.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,MAAM,MAAM,YAAY,CAAC,OAAO,IAAI;IACnC,QAAQ,EAAE,IAAI,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,EAAE,MAAM,UAAU,KAAK,OAAO,CAAC,MAAM,OAAO,CAAC,GAChH,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAChE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,EAAE,MAAM,UAAU,KAAK,MAAM,OAAO,GACvE,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,OAAO,GACtC,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5C,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,mBAAmB,CAAC,QAAQ,EAAE,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7H,KAAK,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC;AAUjE,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,EACjE,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAClC,YAAY,CAAC,OAAO,CAAC,CAAC;AAuBzB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,SAAS,MAAM,EAAE,SAAS,EAClF,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,KAAK,OAAO,EAC7C,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAClC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { getTRPCErrorFromUnknown } from "@trpc/server";
2
+ import { Effect } from "effect";
3
+ function member(node, segment) {
4
+ return (typeof node === "object" && node !== null) || typeof node === "function" ? Reflect.get(node, segment) : undefined;
5
+ }
6
+ function invoke(promiseCaller, path, argumentsList) {
7
+ const leaf = path.reduce(member, promiseCaller);
8
+ return typeof leaf === "function"
9
+ ? Promise.resolve(Reflect.apply(leaf, undefined, argumentsList))
10
+ : Promise.reject(new TypeError(`${path.join(".")} is not a procedure`));
11
+ }
12
+ export function makeEffectCaller(adapter, promiseCaller, services) {
13
+ function build(path) {
14
+ return new Proxy(Object.assign(() => undefined, { path }), {
15
+ apply(_target, _this, argumentsList) {
16
+ return Effect.tryPromise({
17
+ catch: getTRPCErrorFromUnknown,
18
+ try: () => adapter.runWithServices(services, () => invoke(promiseCaller, path, argumentsList)),
19
+ });
20
+ },
21
+ get(_target, property) {
22
+ if (typeof property !== "string" || property === "then") {
23
+ return undefined;
24
+ }
25
+ return build([...path, property]);
26
+ },
27
+ });
28
+ }
29
+ return build([]);
30
+ }
31
+ export function makeEffectCallerFactory(adapter, createCaller, services) {
32
+ const defaultCaller = makeEffectCaller(adapter, createCaller(), services);
33
+ function target(options) {
34
+ return makeEffectCaller(adapter, createCaller(options), services);
35
+ }
36
+ return new Proxy(target, {
37
+ get(_target, property, receiver) {
38
+ if (property === "then") {
39
+ return undefined;
40
+ }
41
+ if (typeof property !== "string") {
42
+ return Reflect.get(_target, property, receiver);
43
+ }
44
+ return Reflect.get(defaultCaller, property);
45
+ },
46
+ });
47
+ }
48
+ //# sourceMappingURL=caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caller.js","sourceRoot":"","sources":["../../../src/server/testing/caller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAkB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAgB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAa9C,SAAS,MAAM,CAAC,IAAa,EAAE,OAAe;IAC7C,OAAO,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3H,CAAC;AACD,SAAS,MAAM,CAAC,aAAqB,EAAE,IAAuB,EAAE,aAAiC;IAChG,MAAM,IAAI,GAAG,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MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC1E,SAAS,MAAM,CAAC,OAAiB;QAChC,OAAO,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACxB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ;YAC9B,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAClC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjD,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { TestContext, Vitest } from "@effect/vitest";
2
+ import type { Effect, Layer, Scope } from "effect";
3
+ import type { EffectClock, EffectTestOptions } from "@shivaedev/effect-test/types.ts";
4
+ import type { EffectTRPCAdapter } from "#adapter.ts";
5
+ import type { AnyTestLayer } from "./AnyTestLayer.ts";
6
+ import type { EffectCallerFactory } from "./caller.ts";
7
+ export type TrpcHarnessTest<THarness, TProvided> = <A, TEff extends Effect.Effect<unknown, unknown, TProvided>>(name: string, body: (harness: THarness, context: TestContext) => Generator<TEff, A, never>, options?: number | EffectTestOptions) => void;
8
+ export interface TrpcHarnessTester<THarness, TProvided> extends TrpcHarnessTest<THarness, TProvided> {
9
+ readonly each: <TItem>(cases: readonly TItem[]) => <A, TEff extends Effect.Effect<unknown, unknown, TProvided>>(name: string, body: (item: TItem, harness: THarness, context: TestContext) => Generator<TEff, A, never>, options?: number | EffectTestOptions) => void;
10
+ readonly fails: TrpcHarnessTest<THarness, TProvided>;
11
+ readonly only: TrpcHarnessTest<THarness, TProvided>;
12
+ readonly runIf: (condition: unknown) => TrpcHarnessTest<THarness, TProvided>;
13
+ readonly skip: TrpcHarnessTest<THarness, TProvided>;
14
+ readonly skipIf: (condition: unknown) => TrpcHarnessTest<THarness, TProvided>;
15
+ }
16
+ export type TrpcTest<TOptions, TCaller, TProvided> = TrpcHarnessTest<EffectCallerFactory<TOptions, TCaller>, TProvided>;
17
+ export type TrpcTester<TOptions, TCaller, TProvided> = TrpcHarnessTester<EffectCallerFactory<TOptions, TCaller>, TProvided>;
18
+ export type TrpcIt<TOptions, TCaller, TProvided> = Vitest.Methods & {
19
+ readonly "effectTRPC": TrpcTester<TOptions, TCaller, TProvided>;
20
+ };
21
+ export type TrpcHarnessIt<THarness, TProvided> = Vitest.Methods & {
22
+ readonly "effectTRPC": TrpcHarnessTester<THarness, TProvided>;
23
+ };
24
+ export interface MakeTrpcItOptions<TCreateCaller extends (...arguments_: never[]) => object, TTestLayer extends AnyTestLayer> {
25
+ readonly adapter: Pick<EffectTRPCAdapter<never>, "runWithServices">;
26
+ readonly around?: <A, E>(effect: Effect.Effect<A, E, Layer.Success<TTestLayer> | Scope.Scope>) => Effect.Effect<A, unknown, Layer.Success<TTestLayer> | Scope.Scope>;
27
+ readonly clock?: EffectClock;
28
+ readonly createCaller: TCreateCaller;
29
+ readonly layer: TTestLayer;
30
+ }
31
+ export interface MakeTrpcHarnessItOptions<TCreateCaller extends (...arguments_: never[]) => object, TTestLayer extends AnyTestLayer, THarness> extends MakeTrpcItOptions<TCreateCaller, TTestLayer> {
32
+ readonly makeHarness: (trpc: EffectCallerFactory<CallerOptions<TCreateCaller>, CallerResult<TCreateCaller>>, context: TestContext) => Effect.Effect<THarness, unknown, Layer.Success<TTestLayer>>;
33
+ }
34
+ export type CallerOptions<TCreateCaller> = TCreateCaller extends (...arguments_: infer TArguments) => object ? TArguments[0] : never;
35
+ export type CallerResult<TCreateCaller> = TCreateCaller extends (...arguments_: infer _TArguments) => infer TCaller ? TCaller extends object ? TCaller : never : never;
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/testing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,MAAM,MAAM,eAAe,CAAC,QAAQ,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAC7G,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,iBAAiB,KAChC,IAAI,CAAC;AACV,MAAM,WAAW,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAE,SAAQ,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC;IACnG,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EACpB,KAAK,EAAE,SAAS,KAAK,EAAE,KACnB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,EAC/D,IAAI,EAAE,MAAM,EACZ,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C,GAAG,UAAU,EAAE,MAAM,UAAU,KAAK,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AACrI,MAAM,MAAM,YAAY,CAAC,aAAa,IAAI,aAAa,SAAS,CAAC,GAAG,UAAU,EAAE,MAAM,WAAW,KAAK,MAAM,OAAO,GAChH,OAAO,SAAS,MAAM,GACrB,OAAO,GACP,KAAK,GACN,KAAK,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/server/testing/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { type Layer } from "effect";
2
+ import type { AnyTestLayer } from "./AnyTestLayer.ts";
3
+ import type { CallerOptions, CallerResult, MakeTrpcHarnessItOptions, MakeTrpcItOptions, TrpcHarnessIt, TrpcIt } from "./types.ts";
4
+ export declare function makeTrpcHarnessIt<TCreateCaller extends (...arguments_: never[]) => object, TTestLayer extends AnyTestLayer, THarness>(options: MakeTrpcHarnessItOptions<TCreateCaller, TTestLayer, THarness>): TrpcHarnessIt<THarness, Layer.Success<TTestLayer>>;
5
+ export declare function makeTrpcIt<TCreateCaller extends (...arguments_: never[]) => object, TTestLayer extends AnyTestLayer>(options: MakeTrpcItOptions<TCreateCaller, TTestLayer>): TrpcIt<CallerOptions<TCreateCaller>, CallerResult<TCreateCaller>, Layer.Success<TTestLayer>>;
6
+ //# sourceMappingURL=vitest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../../../src/server/testing/vitest.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAelI,wBAAgB,iBAAiB,CAAC,aAAa,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,UAAU,SAAS,YAAY,EAAE,QAAQ,EACpI,OAAO,EAAE,wBAAwB,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,GACpE,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAiBtD,wBAAgB,UAAU,CAAC,aAAa,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,UAAU,SAAS,YAAY,EACnH,OAAO,EAAE,iBAAiB,CAAC,aAAa,EAAE,UAAU,CAAC,GACnD,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAK9F"}
@@ -2,7 +2,7 @@ import { it as effectIt } from "@effect/vitest";
2
2
  import { Effect } from "effect";
3
3
  import { makeEffectIt } from "@shivaedev/effect-test/vitest.ts";
4
4
  import { makeEffectCallerFactory } from "./caller.js";
5
- function withEffectTRPC(tester) {
5
+ function withEffectTrpc(tester) {
6
6
  return new Proxy(effectIt, {
7
7
  get(target, property, receiver) {
8
8
  if (property === "effectTRPC") {
@@ -23,10 +23,12 @@ export function makeTrpcHarnessIt(options) {
23
23
  return yield* options.makeHarness(trpc, context);
24
24
  }),
25
25
  });
26
- return withEffectTRPC(effectApp);
26
+ return withEffectTrpc(effectApp);
27
+ }
28
+ export function makeTrpcIt(options) {
29
+ return makeTrpcHarnessIt({
30
+ ...options,
31
+ makeHarness: (trpc) => Effect.succeed(trpc),
32
+ });
27
33
  }
28
- export const makeTrpcIt = (options) => makeTrpcHarnessIt({
29
- ...options,
30
- makeHarness: (trpc) => Effect.succeed(trpc),
31
- });
32
34
  //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"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EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/testing/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ # The north star
2
+
3
+ ## The problem
4
+
5
+ A tRPC application has a Promise boundary at every procedure. An Effect application has a different set of obligations inside that boundary: a service must be provided, a typed failure must remain distinguishable from a defect, a request must carry its own identity, and a scoped resource must live until its work ends. Handwritten adapters repeat this work at every feature and make it easy to weaken one obligation while fixing another.
6
+
7
+ The package gives tRPC applications one small bridge. An application supplies its runtime once. A request Layer turns the context tRPC middleware produced into Effect services. A procedure yields those services and returns a value or a Stream. Schema describes the data boundary; an explicitly declared rejection describes the failure data a client can understand.
8
+
9
+ This is the integration path for applications that use tRPC. Native Effect queries and commands belong to `effect-contract`; native request identity and server middleware belong to the `platform` RPC modules. Sharing a rejection schema across transports is useful. Making tRPC a requirement of the native framework is not.
10
+
11
+ ## What good looks like
12
+
13
+ ### Effects keep their meaning
14
+
15
+ A procedure's generator is ordinary Effect work. Its service requirements must be supplied by the application runtime or request Layer; unavailable requirements must not disappear into a cast. Schema's encoded and decoded sides stay visible to both the caller and resolver. Input and output are decoders, so the resolver sees decoded input and produces encoded output.
16
+
17
+ Resources keep the lifetime their work needs. A query or mutation has request work; a subscription has a Stream whose consumption owns its resources. Interruption belongs to that work too. Tests observe both the interruption and the finalizer, not just a returned cancellation error.
18
+
19
+ ### Requests and failures cross deliberately
20
+
21
+ A tRPC context value becomes a service in a request Layer. Middleware remains the place to establish or refine that context. The adapter does not invent an authentication policy, a global current user or a second request-context vocabulary.
22
+
23
+ Failure data crosses only by an explicit choice. A declared Schema rejection is data a client may decode and act on. A `TRPCError` is an explicit transport response. An application mapper may expose another known error. An unlisted failure or defect is an internal error, not an accidental serialization of database or infrastructure details.
24
+
25
+ An invalid input and an application rejection are different events. The formatter's reserved `invalidInput` mark allows a client to distinguish them while keeping field-error data in one location. Declared failures must not be able to forge that mark.
26
+
27
+ ### tRPC and Effect remain recognizable
28
+
29
+ tRPC owns routers, middleware, metadata and host transports. Effect owns services, Layers, Streams and the error channel. The adapter removes repetitive conversion at their boundary; it does not replace either side with its own framework.
30
+
31
+ Tests use the router's real caller and an Effect-shaped view of it. Application fixtures can surround that caller, and test services can replace matching runtime services. The shared `effect-test` runner owns clocks and test lifecycle so this package does not maintain another implementation of them.
32
+
33
+ ## Trade-offs
34
+
35
+ The order is Effect types, scope and interruption; deliberate request and error boundaries; tRPC interoperability; then convenience. A helper that saves a few lines but makes unavailable services compile or lets a Stream outlive its resource scope loses. A richer public error that has not been declared loses to a redacted error. A feature needing tRPC middleware should use that middleware before adding another hook to this package.
36
+
37
+ Test coverage limits the wording of guarantees. In-process HTTP serialization is valuable evidence for rejection encoding, but it cannot establish a production proxy's disconnect behavior. A caller signal and finalizer test establishes that path, not all hosts and transports. Application adoption and deployment validation stay with the framework and consuming application.
38
+
39
+ ## What stays outside
40
+
41
+ - A replacement for native `effect-contract` queries and commands.
42
+ - A router, HTTP server, WebSocket server or transport selection policy.
43
+ - Authentication, authorization, user-facing error wording and transaction policy.
44
+ - A client cache, form state engine or automatic invalidation protocol.
45
+ - A second Effect runtime owner or test runner.
46
+ - An implied guarantee about deployed cancellation based only on local fixtures.
47
+
48
+ Local implementation status, next work and maintainer decisions are in [the roadmap](./roadmap.md).
@@ -0,0 +1,33 @@
1
+ # Roadmap
2
+
3
+ This file owns `effect-trpc` implementation status and local next work. The [framework roadmap](https://github.com/ShivaeDev/platform/blob/main/docs/framework/roadmap.md) owns composed application fixtures, adoption and deployment validation. A library test is not application adoption evidence.
4
+
5
+ ## Built
6
+
7
+ - Generator queries and mutations over an application runtime and request services, including context supplied by tRPC middleware and request-Layer extensions that consume base services. `src/server/adapter.test.ts` covers runtime execution; `src/server/EffectProcedureBuilder.typecheck.test.ts` rejects missing services.
8
+ - Effect Schema input and output decoding with encoded/decoded caller and resolver types. Adapter runtime tests and procedure type tests cover the distinction, including subscription output decoding.
9
+ - Stream subscriptions with request services, scoped finalizers and interruption when a caller signal aborts. `src/server/adapter.test.ts` observes values, stream instrumentation and finalization; `src/server/internal/runtime.test.ts` covers pure interruption's transport error.
10
+ - Explicit tRPC errors, application error mapping and redaction of unmapped failures and defects. Adapter/runtime tests cover resolver, request-Layer, mapper and Effect-instrumentation defects; `src/server/httpRejections.spec.ts` checks opaque serialized failures.
11
+ - Tagged declared rejection encoding, taxonomy code mapping, custom code selection and formatter composition. `src/server/rejection.test.ts` and `src/server/httpRejections.spec.ts` cover fields, messages, encodings, HTTP statuses and mixed batches.
12
+ - Input-validation field paths and the reserved `invalidInput` mark. `src/server/inputRejections.spec.ts` covers dotted paths, array indexes, whole-input issues and stripping forged marks; `src/server/rejection.typecheck.test.ts` rejects reserved fields.
13
+ - Client rejection reading and schema decoding, including malformed carriers and unknown tags. HTTP rejection tests and rejection type tests cover values, class instances and synchronous decoder requirements.
14
+ - Reuse of `effect-contract` operation error schemas with generated and reused rejection classes. `src/server/contractRejections.spec.ts` also checks opaque failures for an operation without declared rejections.
15
+ - An Effect-shaped caller and application-defined test harness built on `effect-test`. `src/server/testing/vitest.test.ts` covers runtime service overrides, alternate contexts, table cases and harness services; its type tests preserve caller and harness types.
16
+
17
+ ## Next
18
+
19
+ 1. Add direct observations for the declared instrumentation boundary: span naming, stream instrumentation with request services, and the supplied `RequestSignal` value. The source exposes these pieces; existing tests do not establish all of those observations.
20
+ 2. Add a representative real-host transport cancellation fixture when a consumer selects that transport. Observe query and subscription interruption and resource release; keep proxy/deployment acceptance with the consuming application.
21
+ 3. Exercise test-harness setup inside the `around` wrapper and Layer acquisition lifetime through this adapter if consumers rely on that composition. The shared runner owns the implementation; adapter tests should observe the composition they promise.
22
+
23
+ These are draft priorities, subject to the maintainer's investment decision below.
24
+
25
+ ## Questions the maintainer owns
26
+
27
+ - Should the package receive new adapter features, or focus on compatibility and stronger boundary evidence for tRPC consumers? The draft next work favors evidence for existing behavior. The root package paths establish its purpose but do not set its investment order.
28
+ - Which real host and tRPC transport should be the first cancellation fixture? Caller-signal tests and in-process fetch serialization do not decide a deployment transport.
29
+ - Should `RequestSignal` become a uniform service for queries and mutations as well as subscriptions? It is currently supplied by the subscription handler; expanding that boundary is an API/behavior decision, not documentation work.
30
+
31
+ ## Evidence boundaries
32
+
33
+ The HTTP rejection tests call tRPC's fetch handler in process with its actual client and transformer. Subscription cancellation uses `router.createCaller` with an abort signal and observes its iterator and finalizer. Neither is proof of a network server, WebSocket disconnect, reverse proxy, SSR or mobile lifecycle. Broader composed fixtures and deployment acceptance belong to the framework roadmap and the adopting application.