@shivaedev/platform 0.4.3 → 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.
Files changed (115) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/better-auth/adapter.d.ts +2 -3
  3. package/dist/better-auth/adapter.d.ts.map +1 -1
  4. package/dist/better-auth/adapter.js +2 -2
  5. package/dist/better-auth/adapter.js.map +1 -1
  6. package/dist/better-auth/relation.d.ts +15 -15
  7. package/dist/better-auth/relation.d.ts.map +1 -1
  8. package/dist/better-auth/relation.js +4 -2
  9. package/dist/better-auth/relation.js.map +1 -1
  10. package/dist/better-auth/row-adapter.d.ts.map +1 -1
  11. package/dist/better-auth/row-adapter.js +16 -15
  12. package/dist/better-auth/row-adapter.js.map +1 -1
  13. package/dist/better-auth/where.d.ts +16 -16
  14. package/dist/better-auth/where.d.ts.map +1 -1
  15. package/dist/better-auth/where.js +16 -8
  16. package/dist/better-auth/where.js.map +1 -1
  17. package/dist/better-auth.d.ts +1 -1
  18. package/dist/better-auth.d.ts.map +1 -1
  19. package/dist/better-auth.js +1 -1
  20. package/dist/better-auth.js.map +1 -1
  21. package/dist/errors/taxonomy.d.ts +2 -2
  22. package/dist/errors/taxonomy.js +1 -1
  23. package/dist/errors/taxonomy.js.map +1 -1
  24. package/dist/errors.d.ts +2 -2
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +2 -2
  27. package/dist/errors.js.map +1 -1
  28. package/dist/node-http/subscription-signal.d.ts +1 -11
  29. package/dist/node-http/subscription-signal.d.ts.map +1 -1
  30. package/dist/node-http/subscription-signal.js +11 -10
  31. package/dist/node-http/subscription-signal.js.map +1 -1
  32. package/dist/node-http.d.ts +1 -1
  33. package/dist/node-http.d.ts.map +1 -1
  34. package/dist/node-http.js +1 -1
  35. package/dist/node-http.js.map +1 -1
  36. package/dist/rpc/middleware.d.ts +1 -1
  37. package/dist/rpc/middleware.d.ts.map +1 -1
  38. package/dist/rpc/middleware.js +1 -1
  39. package/dist/rpc/middleware.js.map +1 -1
  40. package/dist/rpc-server/adapters/better-auth-sessions.d.ts +1 -1
  41. package/dist/rpc-server/adapters/better-auth-sessions.d.ts.map +1 -1
  42. package/dist/rpc-server/adapters/better-auth-sessions.js +2 -2
  43. package/dist/rpc-server/adapters/better-auth-sessions.js.map +1 -1
  44. package/dist/rpc-server/origin.d.ts +2 -2
  45. package/dist/rpc-server/origin.d.ts.map +1 -1
  46. package/dist/rpc-server/origin.js +1 -1
  47. package/dist/rpc-server/origin.js.map +1 -1
  48. package/dist/rpc-server/redact-cause.js +2 -2
  49. package/dist/rpc-server/redact-cause.js.map +1 -1
  50. package/dist/rpc-server/redact.d.ts.map +1 -1
  51. package/dist/rpc-server/redact.js +16 -8
  52. package/dist/rpc-server/redact.js.map +1 -1
  53. package/dist/rpc-server/sensitive.js +11 -11
  54. package/dist/rpc-server/sensitive.js.map +1 -1
  55. package/dist/rpc-server/session.d.ts +3 -3
  56. package/dist/rpc-server/session.d.ts.map +1 -1
  57. package/dist/rpc-server/session.js +9 -6
  58. package/dist/rpc-server/session.js.map +1 -1
  59. package/dist/rpc-server/tracing.d.ts +1 -1
  60. package/dist/rpc-server/tracing.d.ts.map +1 -1
  61. package/dist/rpc-server/tracing.js +7 -5
  62. package/dist/rpc-server/tracing.js.map +1 -1
  63. package/dist/rpc-server.d.ts +8 -8
  64. package/dist/rpc-server.d.ts.map +1 -1
  65. package/dist/rpc-server.js +8 -8
  66. package/dist/rpc-server.js.map +1 -1
  67. package/dist/rpc.d.ts +2 -2
  68. package/dist/rpc.d.ts.map +1 -1
  69. package/dist/rpc.js +2 -2
  70. package/dist/rpc.js.map +1 -1
  71. package/dist/runtime/make.d.ts.map +1 -1
  72. package/dist/runtime/make.js +6 -3
  73. package/dist/runtime/make.js.map +1 -1
  74. package/dist/runtime/types.d.ts +0 -1
  75. package/dist/runtime/types.d.ts.map +1 -1
  76. package/dist/runtime.d.ts +2 -2
  77. package/dist/runtime.d.ts.map +1 -1
  78. package/dist/runtime.js +1 -1
  79. package/dist/runtime.js.map +1 -1
  80. package/dist/testing/types.d.ts +1 -1
  81. package/dist/testing/types.d.ts.map +1 -1
  82. package/dist/testing/vitest.d.ts +1 -1
  83. package/dist/testing/vitest.d.ts.map +1 -1
  84. package/dist/testing/vitest.js +2 -2
  85. package/dist/testing/vitest.js.map +1 -1
  86. package/dist/testing.d.ts +2 -2
  87. package/dist/testing.d.ts.map +1 -1
  88. package/dist/testing.js +1 -1
  89. package/dist/testing.js.map +1 -1
  90. package/package.json +52 -45
  91. package/src/better-auth/adapter.ts +4 -5
  92. package/src/better-auth/relation.ts +22 -18
  93. package/src/better-auth/row-adapter.ts +18 -16
  94. package/src/better-auth/where.ts +41 -26
  95. package/src/better-auth.ts +1 -1
  96. package/src/errors/taxonomy.ts +1 -1
  97. package/src/errors.ts +2 -2
  98. package/src/node-http/subscription-signal.ts +17 -16
  99. package/src/node-http.ts +1 -1
  100. package/src/rpc/middleware.ts +1 -1
  101. package/src/rpc-server/adapters/better-auth-sessions.ts +3 -3
  102. package/src/rpc-server/origin.ts +3 -3
  103. package/src/rpc-server/redact-cause.ts +2 -2
  104. package/src/rpc-server/redact.ts +26 -10
  105. package/src/rpc-server/sensitive.ts +12 -12
  106. package/src/rpc-server/session.ts +13 -7
  107. package/src/rpc-server/tracing.ts +9 -5
  108. package/src/rpc-server.ts +8 -8
  109. package/src/rpc.ts +2 -2
  110. package/src/runtime/make.ts +9 -3
  111. package/src/runtime/types.ts +0 -1
  112. package/src/runtime.ts +2 -2
  113. package/src/testing/types.ts +1 -1
  114. package/src/testing/vitest.ts +9 -6
  115. package/src/testing.ts +2 -2
@@ -2,15 +2,15 @@ import { Option } from "effect";
2
2
  import { Headers } from "effect/unstable/http";
3
3
 
4
4
  export interface OriginRequest {
5
+ readonly headers: Headers.Headers;
5
6
  readonly origin: Option.Option<string>;
6
7
  readonly rpc: string;
7
- readonly headers: Headers.Headers;
8
8
  }
9
9
 
10
10
  export type OriginPolicy = (request: OriginRequest) => boolean;
11
11
 
12
12
  export interface TrustedOriginsOptions {
13
- readonly allow: ReadonlyArray<string>;
13
+ readonly allow: readonly string[];
14
14
  readonly missing: "allow" | "reject";
15
15
  }
16
16
 
@@ -23,7 +23,7 @@ export const trustedOrigins =
23
23
  });
24
24
 
25
25
  export const originRequest = (headers: Headers.Headers, rpc: string): OriginRequest => ({
26
+ headers,
26
27
  origin: Headers.get(headers, "origin"),
27
28
  rpc,
28
- headers,
29
29
  });
@@ -11,11 +11,11 @@ const reporterHints = (error: Error, sensitive: SensitiveKey) => ({
11
11
  const redactError = (error: Error, sensitive: SensitiveKey): Error => {
12
12
  const options = error.cause === undefined ? undefined : { cause: redact(error.cause, sensitive) };
13
13
  const copy = new Error(redactText(error.message, sensitive), options);
14
- Object.defineProperty(copy, "name", { value: error.name, writable: true, configurable: true });
14
+ Object.defineProperty(copy, "name", { configurable: true, value: error.name, writable: true });
15
15
  Object.defineProperty(copy, "stack", {
16
+ configurable: true,
16
17
  value: error.stack === undefined ? undefined : redactText(error.stack, sensitive),
17
18
  writable: true,
18
- configurable: true,
19
19
  });
20
20
  return Object.assign(copy, redact(Object.fromEntries(Object.entries(error)), sensitive), reporterHints(error, sensitive));
21
21
  };
@@ -5,15 +5,21 @@ const MAX_DEPTH = 8;
5
5
  const MAX_ENTRIES = 50;
6
6
 
7
7
  const binary = (value: object): string | undefined => {
8
- if (ArrayBuffer.isView(value)) return `<${value.constructor.name} ${value.byteLength} bytes>`;
9
- if (value instanceof ArrayBuffer) return `<ArrayBuffer ${value.byteLength} bytes>`;
8
+ if (ArrayBuffer.isView(value)) {
9
+ return `<${value.constructor.name} ${value.byteLength} bytes>`;
10
+ }
11
+ if (value instanceof ArrayBuffer) {
12
+ return `<ArrayBuffer ${value.byteLength} bytes>`;
13
+ }
10
14
  return undefined;
11
15
  };
12
16
 
13
- const entriesOf = (value: object): Array<[string, unknown]> => {
17
+ const entriesOf = (value: object): [string, unknown][] => {
14
18
  const entries = Object.entries(value);
15
- if (!Predicate.isError(value)) return entries;
16
- const shape: Array<[string, unknown]> = [
19
+ if (!Predicate.isError(value)) {
20
+ return entries;
21
+ }
22
+ const shape: [string, unknown][] = [
17
23
  ["name", value.name],
18
24
  ["message", value.message],
19
25
  ["stack", value.stack],
@@ -22,12 +28,22 @@ const entriesOf = (value: object): Array<[string, unknown]> => {
22
28
  };
23
29
 
24
30
  const walk = (value: unknown, sensitive: SensitiveKey, depth: number): unknown => {
25
- if (Redacted.isRedacted(value)) return REDACTED;
26
- if (Predicate.isString(value)) return redactText(value, sensitive);
27
- if (!Predicate.isObjectOrArray(value)) return value;
31
+ if (Redacted.isRedacted(value)) {
32
+ return REDACTED;
33
+ }
34
+ if (Predicate.isString(value)) {
35
+ return redactText(value, sensitive);
36
+ }
37
+ if (!Predicate.isObjectOrArray(value)) {
38
+ return value;
39
+ }
28
40
  const summary = binary(value);
29
- if (summary !== undefined) return summary;
30
- if (depth >= MAX_DEPTH) return "<truncated>";
41
+ if (summary !== undefined) {
42
+ return summary;
43
+ }
44
+ if (depth >= MAX_DEPTH) {
45
+ return "<truncated>";
46
+ }
31
47
  if (Array.isArray(value)) {
32
48
  const items = value.slice(0, MAX_ENTRIES).map((item) => walk(item, sensitive, depth + 1));
33
49
  return value.length > MAX_ENTRIES ? [...items, `<${value.length - MAX_ENTRIES} more items>`] : items;
@@ -26,26 +26,26 @@ const SENSITIVE_NAMES = ["session", "pan"];
26
26
 
27
27
  export type SensitiveKey = (key: string) => boolean;
28
28
 
29
- const wordsOf = (key: string): Array<string> =>
29
+ const wordsOf = (key: string): string[] =>
30
30
  key
31
- .replaceAll(/([a-z0-9])([A-Z])/g, "$1 $2")
32
- .replaceAll(/([A-Z])([A-Z][a-z])/g, "$1 $2")
31
+ .replaceAll(/([a-z0-9])([A-Z])/gu, "$1 $2")
32
+ .replaceAll(/([A-Z])([A-Z][a-z])/gu, "$1 $2")
33
33
  .toLowerCase()
34
- .split(/[\s_-]+/);
34
+ .split(/[\s_-]+/u);
35
35
 
36
36
  export const isSensitiveKey: SensitiveKey = (key) => {
37
- const normalized = key.toLowerCase().replaceAll(/[-_]/g, "");
37
+ const normalized = key.toLowerCase().replaceAll(/[-_]/gu, "");
38
38
  return (
39
- SENSITIVE_NAMES.includes(normalized) ||
40
- SENSITIVE_PARTS.some((part) => normalized.includes(part)) ||
41
- wordsOf(key).some((word) => SENSITIVE_WORDS.includes(word))
39
+ SENSITIVE_NAMES.includes(normalized)
40
+ || SENSITIVE_PARTS.some((part) => normalized.includes(part))
41
+ || wordsOf(key).some((word) => SENSITIVE_WORDS.includes(word))
42
42
  );
43
43
  };
44
44
 
45
- const AUTH_SCHEME = /\b(Bearer|Basic)\s+[A-Za-z0-9._~+/-]+=*/gi;
46
- const JWT = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g;
47
- const URL_PASSWORD = /(\/\/[^:/\s@]+:)[^@/\s]+@/g;
48
- const ASSIGNMENT = /([A-Za-z][\w.-]*)(["']?\s*[=:]\s*["']?)([^\s"'&,;]+)/g;
45
+ const AUTH_SCHEME = /\b(Bearer|Basic)\s+[A-Za-z0-9._~+/-]+=*/giu;
46
+ const JWT = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/gu;
47
+ const URL_PASSWORD = /(\/\/[^:/\s@]+:)[^@/\s]+@/gu;
48
+ const ASSIGNMENT = /([A-Za-z][\w.-]*)(["']?\s*[=:]\s*["']?)([^\s"'&,;]+)/gu;
49
49
 
50
50
  const scrub = (text: string, sensitive: SensitiveKey): string =>
51
51
  text
@@ -1,8 +1,8 @@
1
1
  import { Effect, Layer, Option } from "effect";
2
2
  import type { Headers } from "effect/unstable/http";
3
- import { type AuthUnavailable, Forbidden, Unauthorized } from "../errors/taxonomy.ts";
4
- import { Identity, OptionalIdentity } from "../rpc/identity.ts";
5
- import { Authenticated, MaybeAuthenticated } from "../rpc/middleware.ts";
3
+ import { type AuthUnavailable, Forbidden, Unauthorized } from "#errors/taxonomy.ts";
4
+ import { Identity, OptionalIdentity } from "#rpc/identity.ts";
5
+ import { Authenticated, MaybeAuthenticated } from "#rpc/middleware.ts";
6
6
  import { type OriginPolicy, originRequest } from "./origin.ts";
7
7
  import { transportHeaders } from "./transport.ts";
8
8
 
@@ -15,8 +15,8 @@ export interface SessionProvider<Session extends SessionShape> {
15
15
  }
16
16
 
17
17
  export interface SessionPolicy<Session extends SessionShape> {
18
- readonly provider: SessionProvider<Session>;
19
18
  readonly origin: OriginPolicy;
19
+ readonly provider: SessionProvider<Session>;
20
20
  }
21
21
 
22
22
  export const resolveSession: <Session extends SessionShape>(
@@ -27,7 +27,9 @@ export const resolveSession: <Session extends SessionShape>(
27
27
  Session extends SessionShape,
28
28
  >(policy: SessionPolicy<Session>, headers: Headers.Headers, rpc: string) {
29
29
  const transport = yield* transportHeaders(headers);
30
- if (!policy.origin(originRequest(transport, rpc))) return yield* new Forbidden({ message: "Origin not allowed" });
30
+ if (!policy.origin(originRequest(transport, rpc))) {
31
+ return yield* new Forbidden({ message: "Origin not allowed" });
32
+ }
31
33
  return yield* policy.provider.get(transport);
32
34
  });
33
35
 
@@ -37,7 +39,9 @@ export const authenticatedLayer = <Session extends SessionShape>(policy: Session
37
39
  Layer.succeed(Authenticated, (effect, { headers, rpc }) =>
38
40
  Effect.gen(function* () {
39
41
  const session = yield* resolveSession(policy, headers, rpc._tag);
40
- if (Option.isNone(session)) return yield* new Unauthorized({ message: "Authentication required" });
42
+ if (Option.isNone(session)) {
43
+ return yield* new Unauthorized({ message: "Authentication required" });
44
+ }
41
45
  const id = yield* identified(session.value.user.id);
42
46
  return yield* effect.pipe(Effect.provideService(Identity, { id }), Effect.annotateLogs({ userId: id }));
43
47
  }),
@@ -47,7 +51,9 @@ export const maybeAuthenticatedLayer = <Session extends SessionShape>(policy: Se
47
51
  Layer.succeed(MaybeAuthenticated, (effect, { headers, rpc }) =>
48
52
  Effect.gen(function* () {
49
53
  const session = yield* resolveSession(policy, headers, rpc._tag);
50
- if (Option.isNone(session)) return yield* Effect.provideService(effect, OptionalIdentity, Option.none());
54
+ if (Option.isNone(session)) {
55
+ return yield* Effect.provideService(effect, OptionalIdentity, Option.none());
56
+ }
51
57
  const id = yield* identified(session.value.user.id);
52
58
  return yield* effect.pipe(Effect.provideService(OptionalIdentity, Option.some({ id })), Effect.annotateLogs({ userId: id }));
53
59
  }),
@@ -1,7 +1,7 @@
1
1
  import { Cause, Effect, Layer, Option, Predicate, Random } from "effect";
2
2
  import { Headers } from "effect/unstable/http";
3
- import { RequestId } from "../rpc/identity.ts";
4
- import { RequestTracing } from "../rpc/middleware.ts";
3
+ import { RequestId } from "#rpc/identity.ts";
4
+ import { RequestTracing } from "#rpc/middleware.ts";
5
5
  import { redact } from "./redact.ts";
6
6
  import { redactCause } from "./redact-cause.ts";
7
7
  import type { SensitiveKey } from "./sensitive.ts";
@@ -11,7 +11,7 @@ export interface RequestTracingOptions {
11
11
  readonly sensitive?: SensitiveKey;
12
12
  }
13
13
 
14
- const ACCEPTED_REQUEST_ID = /^[A-Za-z0-9._:-]{1,128}$/;
14
+ const ACCEPTED_REQUEST_ID = /^[A-Za-z0-9._:-]{1,128}$/u;
15
15
 
16
16
  const hex = (byte: number): string => byte.toString(16).padStart(2, "0");
17
17
 
@@ -33,9 +33,13 @@ const failureTag = (cause: Cause.Cause<unknown>): string =>
33
33
  });
34
34
 
35
35
  const logFailure = (cause: Cause.Cause<unknown>, payload: unknown, sensitive: SensitiveKey | undefined): Effect.Effect<void> => {
36
- if (Cause.hasInterruptsOnly(cause)) return Effect.void;
36
+ if (Cause.hasInterruptsOnly(cause)) {
37
+ return Effect.void;
38
+ }
37
39
  const annotations = { "rpc.payload": redact(payload, sensitive) };
38
- if (!Cause.hasDies(cause)) return Effect.annotateLogs(Effect.logInfo("RPC failure"), { ...annotations, "rpc.failure": failureTag(cause) });
40
+ if (!Cause.hasDies(cause)) {
41
+ return Effect.annotateLogs(Effect.logInfo("RPC failure"), { ...annotations, "rpc.failure": failureTag(cause) });
42
+ }
39
43
  const defects = cause.reasons.filter(Cause.isDieReason).map((reason) => redact(reason.defect, sensitive));
40
44
  return Effect.annotateLogs(Effect.logError("RPC defect"), { ...annotations, "rpc.defect": defects });
41
45
  };
package/src/rpc-server.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { betterAuthSessions, type GetSession } from "./rpc-server/adapters/better-auth-sessions.ts";
2
- export { type OriginPolicy, type OriginRequest, type TrustedOriginsOptions, trustedOrigins } from "./rpc-server/origin.ts";
3
- export { redact } from "./rpc-server/redact.ts";
4
- export { redactCause, redactDefect, redactingErrorReporter } from "./rpc-server/redact-cause.ts";
5
- export { isSensitiveKey, type SensitiveKey } from "./rpc-server/sensitive.ts";
1
+ export { betterAuthSessions, type GetSession } from "#rpc-server/adapters/better-auth-sessions.ts";
2
+ export { type OriginPolicy, type OriginRequest, type TrustedOriginsOptions, trustedOrigins } from "#rpc-server/origin.ts";
3
+ export { redact } from "#rpc-server/redact.ts";
4
+ export { redactCause, redactDefect, redactingErrorReporter } from "#rpc-server/redact-cause.ts";
5
+ export { isSensitiveKey, type SensitiveKey } from "#rpc-server/sensitive.ts";
6
6
  export {
7
7
  authenticatedLayer,
8
8
  maybeAuthenticatedLayer,
@@ -10,6 +10,6 @@ export {
10
10
  type SessionPolicy,
11
11
  type SessionProvider,
12
12
  type SessionShape,
13
- } from "./rpc-server/session.ts";
14
- export { type RequestTracingOptions, requestTracingLayer } from "./rpc-server/tracing.ts";
15
- export { transportHeaders } from "./rpc-server/transport.ts";
13
+ } from "#rpc-server/session.ts";
14
+ export { type RequestTracingOptions, requestTracingLayer } from "#rpc-server/tracing.ts";
15
+ export { transportHeaders } from "#rpc-server/transport.ts";
package/src/rpc.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { Identity, type IdentityValue, OptionalIdentity, RequestId } from "./rpc/identity.ts";
2
- export { Authenticated, MaybeAuthenticated, RequestTracing } from "./rpc/middleware.ts";
1
+ export { Identity, type IdentityValue, OptionalIdentity, RequestId } from "#rpc/identity.ts";
2
+ export { Authenticated, MaybeAuthenticated, RequestTracing } from "#rpc/middleware.ts";
@@ -40,7 +40,9 @@ const make = <Services, BuildError>(layer: Layer.Layer<Services, BuildError>): P
40
40
  dispose: () => managed.dispose(),
41
41
  runPromise: async (effect, options) => {
42
42
  const exit = await runPromiseExit(effect, options);
43
- if (Exit.isSuccess(exit)) return exit.value;
43
+ if (Exit.isSuccess(exit)) {
44
+ return exit.value;
45
+ }
44
46
  throw Cause.squash(exit.cause);
45
47
  },
46
48
  runPromiseExit,
@@ -57,7 +59,9 @@ export const makePlatformRuntime = <Services, BuildError>(
57
59
  options: PlatformRuntimeOptions = {},
58
60
  ): PlatformRuntime<Services, BuildError> => {
59
61
  const key = Effect.runSync(production) ? undefined : options.developmentCacheKey;
60
- if (key === undefined) return make(layer);
62
+ if (key === undefined) {
63
+ return make(layer);
64
+ }
61
65
 
62
66
  const cached = runtimeCache.get(key);
63
67
  if (cached !== undefined) {
@@ -68,7 +72,9 @@ export const makePlatformRuntime = <Services, BuildError>(
68
72
  const cachedRuntime: PlatformRuntime<Services, BuildError> = {
69
73
  ...runtime,
70
74
  dispose: async () => {
71
- if (runtimeCache.get(key) === cachedRuntime) runtimeCache.delete(key);
75
+ if (runtimeCache.get(key) === cachedRuntime) {
76
+ runtimeCache.delete(key);
77
+ }
72
78
  await runtime.dispose();
73
79
  },
74
80
  };
@@ -1,7 +1,6 @@
1
1
  import type { Context, Effect, Exit } from "effect";
2
2
 
3
3
  export interface PlatformRuntimeOptions {
4
- /** Reuse one runtime across development module reloads. */
5
4
  readonly developmentCacheKey?: string | symbol;
6
5
  }
7
6
 
package/src/runtime.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { makePlatformRuntime } from "./runtime/make.ts";
1
+ export { makePlatformRuntime } from "#runtime/make.ts";
2
2
  export type {
3
3
  PlatformRuntime,
4
4
  PlatformRuntimeBuildError,
5
5
  PlatformRuntimeOptions,
6
6
  PlatformRuntimeServices,
7
- } from "./runtime/types.ts";
7
+ } from "#runtime/types.ts";
@@ -1,8 +1,8 @@
1
1
  import type { TestContext, Vitest } from "@effect/vitest";
2
+ import type { Effect, Layer } from "effect";
2
3
  import type { AnyDatabase, DatabaseService } from "@shivaedev/effect-prisma/testing";
3
4
  import type { EffectTRPCAdapter } from "@shivaedev/effect-trpc";
4
5
  import type { CallerOptions, CallerResult, EffectCallerFactory, TrpcHarnessTest, TrpcHarnessTester } from "@shivaedev/effect-trpc/testing";
5
- import type { Effect, Layer } from "effect";
6
6
 
7
7
  export type PlatformHarness<Database extends AnyDatabase, Options, Caller, Extension> = Readonly<{
8
8
  db: DatabaseService<Database>;
@@ -1,17 +1,20 @@
1
1
  import type { TestContext } from "@effect/vitest";
2
+ import { Effect, type Layer } from "effect";
2
3
  import { type AnyDatabase, withTestTransaction } from "@shivaedev/effect-prisma/testing";
3
4
  import type { EffectTRPCAdapter } from "@shivaedev/effect-trpc";
4
5
  import { type CallerOptions, type CallerResult, type EffectCallerFactory, makeTrpcHarnessIt } from "@shivaedev/effect-trpc/testing";
5
- import { Effect, type Layer } from "effect";
6
+ import type { Bivariant } from "@shivaedev/types";
6
7
  import type { MakePlatformItOptions, PlatformHarness, PlatformIt } from "./types.ts";
7
8
 
8
9
  interface LooseOptions {
9
10
  readonly adapter: Pick<EffectTRPCAdapter<never>, "runWithServices">;
10
11
  readonly createCaller: (options?: unknown) => object;
11
- extend?(
12
- base: { readonly db: unknown; readonly trpc: EffectCallerFactory<unknown, object> },
13
- context: TestContext,
14
- ): Effect.Effect<object, unknown, unknown>;
12
+ extend?: Bivariant<
13
+ (
14
+ base: { readonly db: unknown; readonly trpc: EffectCallerFactory<unknown, object> },
15
+ context: TestContext,
16
+ ) => Effect.Effect<object, unknown, unknown>
17
+ >;
15
18
  readonly layer: Layer.Layer<unknown, unknown>;
16
19
  }
17
20
 
@@ -30,9 +33,9 @@ function platformIt<
30
33
  function platformIt(database: AnyDatabase, options: LooseOptions): unknown {
31
34
  const trpcIt = makeTrpcHarnessIt({
32
35
  adapter: options.adapter,
36
+ around: (effect) => withTestTransaction(database, effect),
33
37
  createCaller: options.createCaller,
34
38
  layer: options.layer,
35
- around: (effect) => withTestTransaction(database, effect),
36
39
  makeHarness: (trpc, context) =>
37
40
  Effect.gen(function* () {
38
41
  const services = yield* Effect.context<unknown>();
package/src/testing.ts CHANGED
@@ -4,5 +4,5 @@ export type {
4
4
  PlatformIt,
5
5
  PlatformTest,
6
6
  PlatformTester,
7
- } from "./testing/types.ts";
8
- export { makePlatformIt } from "./testing/vitest.ts";
7
+ } from "#testing/types.ts";
8
+ export { makePlatformIt } from "#testing/vitest.ts";