@shivaedev/server 0.24.2 → 0.26.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 (86) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +22 -16
  3. package/dist/AppHostFactory.d.ts +5 -5
  4. package/dist/AppHostFactory.d.ts.map +1 -1
  5. package/dist/AppHostInput.d.ts +16 -8
  6. package/dist/AppHostInput.d.ts.map +1 -1
  7. package/dist/appDatabase.d.ts +8 -3
  8. package/dist/appDatabase.d.ts.map +1 -1
  9. package/dist/appDatabase.js +16 -44
  10. package/dist/appDatabase.js.map +1 -1
  11. package/dist/appDatabaseHttp.d.ts +239 -0
  12. package/dist/appDatabaseHttp.d.ts.map +1 -0
  13. package/dist/appDatabaseHttp.js +10 -0
  14. package/dist/appDatabaseHttp.js.map +1 -0
  15. package/dist/appHost.d.ts +120 -18
  16. package/dist/appHost.d.ts.map +1 -1
  17. package/dist/appHost.js +7 -17
  18. package/dist/appHost.js.map +1 -1
  19. package/dist/appHostHttp.d.ts +0 -235
  20. package/dist/appHostHttp.d.ts.map +1 -1
  21. package/dist/appHostHttp.js +0 -7
  22. package/dist/appHostHttp.js.map +1 -1
  23. package/dist/hostOptions.d.ts +1 -2
  24. package/dist/hostOptions.d.ts.map +1 -1
  25. package/dist/hostPreflight.d.ts +9 -0
  26. package/dist/hostPreflight.d.ts.map +1 -0
  27. package/dist/hostPreflight.js +6 -0
  28. package/dist/hostPreflight.js.map +1 -0
  29. package/dist/prepareMigrations.d.ts +5 -0
  30. package/dist/prepareMigrations.d.ts.map +1 -0
  31. package/dist/prepareMigrations.js +46 -0
  32. package/dist/prepareMigrations.js.map +1 -0
  33. package/dist/workerHost.d.ts +1 -1
  34. package/dist/workerHost.d.ts.map +1 -1
  35. package/dist/workerHost.js.map +1 -1
  36. package/package.json +13 -17
  37. package/src/AppHostFactory.ts +5 -9
  38. package/src/AppHostInput.ts +53 -7
  39. package/src/appDatabase.ts +64 -54
  40. package/src/appDatabaseHttp.ts +78 -0
  41. package/src/appHost.ts +46 -79
  42. package/src/appHostHttp.ts +0 -74
  43. package/src/hostOptions.ts +1 -2
  44. package/src/hostPreflight.ts +22 -0
  45. package/src/prepareMigrations.ts +57 -0
  46. package/src/workerHost.ts +1 -2
  47. package/dist/testing/HostProcessError.d.ts +0 -10
  48. package/dist/testing/HostProcessError.d.ts.map +0 -1
  49. package/dist/testing/HostProcessError.js +0 -4
  50. package/dist/testing/HostProcessError.js.map +0 -1
  51. package/dist/testing/adapters/hostProcess.d.ts +0 -24
  52. package/dist/testing/adapters/hostProcess.d.ts.map +0 -1
  53. package/dist/testing/adapters/hostProcess.js +0 -111
  54. package/dist/testing/adapters/hostProcess.js.map +0 -1
  55. package/dist/testing/adapters/hostProcessReadouts.d.ts +0 -10
  56. package/dist/testing/adapters/hostProcessReadouts.d.ts.map +0 -1
  57. package/dist/testing/adapters/hostProcessReadouts.js +0 -26
  58. package/dist/testing/adapters/hostProcessReadouts.js.map +0 -1
  59. package/dist/testing/hostProcess.d.ts +0 -26
  60. package/dist/testing/hostProcess.d.ts.map +0 -1
  61. package/dist/testing/hostProcess.js +0 -56
  62. package/dist/testing/hostProcess.js.map +0 -1
  63. package/dist/testing/hostProcessChild.d.ts +0 -7
  64. package/dist/testing/hostProcessChild.d.ts.map +0 -1
  65. package/dist/testing/hostProcessChild.js +0 -19
  66. package/dist/testing/hostProcessChild.js.map +0 -1
  67. package/dist/testing/hostProcessProtocol.d.ts +0 -20
  68. package/dist/testing/hostProcessProtocol.d.ts.map +0 -1
  69. package/dist/testing/hostProcessProtocol.js +0 -11
  70. package/dist/testing/hostProcessProtocol.js.map +0 -1
  71. package/dist/testing/hostProcessReadouts.d.ts +0 -7
  72. package/dist/testing/hostProcessReadouts.d.ts.map +0 -1
  73. package/dist/testing/hostProcessReadouts.js +0 -37
  74. package/dist/testing/hostProcessReadouts.js.map +0 -1
  75. package/dist/testing/hostTime.d.ts +0 -9
  76. package/dist/testing/hostTime.d.ts.map +0 -1
  77. package/dist/testing/hostTime.js +0 -27
  78. package/dist/testing/hostTime.js.map +0 -1
  79. package/src/testing/HostProcessError.ts +0 -6
  80. package/src/testing/adapters/hostProcess.ts +0 -122
  81. package/src/testing/adapters/hostProcessReadouts.ts +0 -29
  82. package/src/testing/hostProcess.ts +0 -69
  83. package/src/testing/hostProcessChild.ts +0 -25
  84. package/src/testing/hostProcessProtocol.ts +0 -11
  85. package/src/testing/hostProcessReadouts.ts +0 -46
  86. package/src/testing/hostTime.ts +0 -33
@@ -3,8 +3,6 @@ import { HttpRouter, HttpServer } from "effect/http";
3
3
  import type { Rpc } from "effect/rpc";
4
4
  import { hostHttpServices } from "#adapters/hostHttpServices.ts";
5
5
  import { nodeHttpServer } from "#adapters/nodeHttpServer.ts";
6
- import type { appDatabase } from "#appDatabase.ts";
7
- import type { AppHttpHostOptions } from "#appHost.ts";
8
6
  import { browserErrorRoute } from "#browserErrorRoute.ts";
9
7
  import { healthRoute } from "#healthRoute.ts";
10
8
  import { hostApplicationRoutes } from "#hostApplicationRoutes.ts";
@@ -13,7 +11,6 @@ import type { HostOptions, HostPolicy, HostRouteRequirements } from "#hostOption
13
11
  import { hostRpcRoutes } from "#hostRpcRoutes.ts";
14
12
  import { hostSensitiveKeys } from "#hostSensitiveKeys.ts";
15
13
  import { hostTransport } from "#hostTransport.ts";
16
- import type { MigrationOptions } from "#MigrationOptions.ts";
17
14
  import { nativeClientOrigins } from "#nativeClientOrigins.ts";
18
15
  import { otlpTracing } from "#otlpTracing.ts";
19
16
  import { RedactionPolicy } from "#RedactionPolicy.ts";
@@ -75,74 +72,3 @@ export function appHostHttp<
75
72
  ),
76
73
  );
77
74
  }
78
-
79
- export function migratedHost<
80
- TRpcs extends Rpc.Any,
81
- THandlers,
82
- THandlerError,
83
- THandlerRequirements,
84
- TServices,
85
- TServiceError,
86
- TServiceRequirements,
87
- TMigrations,
88
- TRouteError = never,
89
- TRouteRequirements = HostRouteRequirements,
90
- TMigrationError = never,
91
- >(
92
- options: HostOptions<
93
- TRpcs,
94
- THandlers,
95
- THandlerError,
96
- THandlerRequirements,
97
- TServices,
98
- TServiceError,
99
- TServiceRequirements,
100
- TRouteError,
101
- TRouteRequirements
102
- > &
103
- HostPolicy & {
104
- readonly migrations: MigrationOptions<TMigrations, TMigrationError>;
105
- },
106
- database: ReturnType<typeof appDatabase<TMigrations, TMigrationError>>,
107
- ) {
108
- const services = Layer.mergeAll(options.services ?? Layer.empty);
109
- return appHostHttp({ ...options, services: services.pipe(Layer.provideMerge(database)) });
110
- }
111
-
112
- export function deferredHost<
113
- TRpcs extends Rpc.Any,
114
- THandlers,
115
- THandlerError,
116
- THandlerRequirements,
117
- TServices,
118
- TServiceError,
119
- TServiceRequirements,
120
- TMigrations,
121
- TApplicationError,
122
- TApplicationRequirements,
123
- TRouteError = never,
124
- TRouteRequirements = HostRouteRequirements,
125
- TMigrationError = never,
126
- >(
127
- application: Effect.Effect<
128
- AppHttpHostOptions<
129
- TRpcs,
130
- THandlers,
131
- THandlerError,
132
- THandlerRequirements,
133
- TServices,
134
- TServiceError,
135
- TServiceRequirements,
136
- never,
137
- never,
138
- never,
139
- TRouteError,
140
- TRouteRequirements
141
- >,
142
- TApplicationError,
143
- TApplicationRequirements
144
- >,
145
- database: ReturnType<typeof appDatabase<TMigrations, TMigrationError>>,
146
- ) {
147
- return Layer.unwrap(Effect.map(application, (options) => appHostHttp(options))).pipe(Layer.provideMerge(database));
148
- }
@@ -3,7 +3,6 @@ import type { HttpRouter } from "effect/http";
3
3
  import type { Rpc, RpcGroup } from "effect/rpc";
4
4
  import type { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
5
5
  import type { AssetOptions } from "#AssetOptions.ts";
6
- import type { AppDatabaseOptions } from "#appHost.ts";
7
6
  import type { BrowserErrorOptions } from "#browserErrorRoute.ts";
8
7
 
9
8
  export type HostRouteRequirements = HttpRouter.HttpRouter | HttpRouter.Request<"Error", unknown>;
@@ -11,7 +10,7 @@ export type HostRouteRequirements = HttpRouter.HttpRouter | HttpRouter.Request<"
11
10
  export type HostCoreOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> = {
12
11
  readonly assets?: string | AssetOptions;
13
12
  readonly browserErrors?: BrowserErrorOptions;
14
- readonly config?: AppDatabaseOptions["config"] & {
13
+ readonly config?: {
15
14
  readonly buildVersion?: string;
16
15
  readonly port?: number;
17
16
  readonly socketPath?: string;
@@ -0,0 +1,22 @@
1
+ import { type Crypto, Effect, Layer } from "effect";
2
+ import { redactingDiagnostics } from "#redactingDiagnostics.ts";
3
+
4
+ export type HostPreflight<TServices = never, TError = never, TRequirements = never> =
5
+ | { readonly preflight: Layer.Layer<TServices, TError, TRequirements> }
6
+ | ([TServices | TError | TRequirements] extends [never] ? { readonly preflight?: never } : never);
7
+
8
+ export type PreflightHost<THost extends Layer.Any, TServices, TError, TRequirements> = Layer.Layer<
9
+ Layer.Success<THost> | TServices,
10
+ Layer.Error<THost> | TError,
11
+ Exclude<Layer.Services<THost>, TServices | Crypto.Crypto> | Exclude<TRequirements, Crypto.Crypto>
12
+ >;
13
+
14
+ export function hostPreflight<TServices, TError, TRequirements, TSensitiveError>(
15
+ startup: Layer.Layer<TServices, TError, TRequirements> | undefined,
16
+ sensitive: Effect.Effect<(key: string) => boolean, TSensitiveError>,
17
+ ) {
18
+ return Layer.mergeAll(
19
+ Layer.empty,
20
+ ...(startup === undefined ? [] : [Layer.unwrap(Effect.map(sensitive, (policy) => startup.pipe(Layer.provide(redactingDiagnostics(policy)))))]),
21
+ );
22
+ }
@@ -0,0 +1,57 @@
1
+ import { Duration, Effect, Fiber, Schedule } from "effect";
2
+ import { Migrator } from "effect/sql";
3
+ import { assertPostgresMigrations, postgresMigrationError } from "@shivaedev/sql/assertPostgresMigrations.ts";
4
+ import { migratePostgres } from "@shivaedev/sql/migrations.ts";
5
+ import { type PendingPostgresMigrations, pendingPostgresMigrations } from "@shivaedev/sql/pendingPostgresMigrations.ts";
6
+ import type { MigrationOptions } from "#MigrationOptions.ts";
7
+
8
+ export function prepareMigrations<R, E>(migrations: MigrationOptions<R, E>) {
9
+ switch (migrations.mode) {
10
+ case "check": {
11
+ const { release: _release, ...schema } = migrations;
12
+ return assertPostgresMigrations(schema);
13
+ }
14
+ case "wait":
15
+ return waitForMigrations(migrations);
16
+ default:
17
+ return migratePostgres({ ...migrations, lockTimeout: migrations.lockTimeout ?? "5 seconds" }).pipe(Effect.asVoid);
18
+ }
19
+ }
20
+
21
+ function waitForMigrations<R, E>(migrations: MigrationOptions<R, E>) {
22
+ return Effect.gen(function* () {
23
+ const progressInterval = Duration.fromInputUnsafe(migrations.progressInterval ?? "30 seconds");
24
+ let pending: PendingPostgresMigrations = { components: [], migrations: [] };
25
+ let progress: Fiber.Fiber<never> | undefined;
26
+ function log(message: string) {
27
+ return Effect.suspend(() =>
28
+ Effect.logInfo(message).pipe(Effect.annotateLogs({ pendingComponents: pending.components, pendingMigrations: pending.migrations })),
29
+ );
30
+ }
31
+ yield* Effect.gen(function* () {
32
+ pending = yield* pendingPostgresMigrations(migrations);
33
+ if (pending.migrations.length === 0 && pending.components.length === 0) {
34
+ return;
35
+ }
36
+ if (progress === undefined) {
37
+ yield* log("Waiting for database migrations");
38
+ progress = yield* Effect.forever(Effect.sleep(progressInterval).pipe(Effect.andThen(log("Still waiting for database migrations")))).pipe(
39
+ Effect.forkScoped,
40
+ );
41
+ }
42
+ return yield* Effect.fail(postgresMigrationError(pending));
43
+ }).pipe(
44
+ Effect.retry({
45
+ schedule: Schedule.max([Schedule.spaced(migrations.pollInterval ?? "1 second"), Schedule.during(migrations.waitTimeout ?? "5 minutes")]),
46
+ while: (error) => error instanceof Migrator.MigrationError && error.kind === "BadState",
47
+ }),
48
+ Effect.tapError((error) =>
49
+ error instanceof Migrator.MigrationError && error.kind === "BadState" ? log("Timed out waiting for database migrations") : Effect.void,
50
+ ),
51
+ );
52
+ if (progress !== undefined) {
53
+ yield* Fiber.interrupt(progress);
54
+ yield* Effect.logInfo("Database migrations current");
55
+ }
56
+ }).pipe(Effect.scoped);
57
+ }
package/src/workerHost.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2
2
  import { Layer } from "effect";
3
- import { appDatabase } from "#appDatabase.ts";
4
- import type { AppDatabaseOptions } from "#appHost.ts";
3
+ import { type AppDatabaseOptions, appDatabase } from "#appDatabase.ts";
5
4
 
6
5
  export function workerHost<R, E, TRequirements, TServices, TServiceError, TServiceRequirements, TMigrations = never, TMigrationError = never>(
7
6
  options: AppDatabaseOptions<TMigrations, TMigrationError> & {
@@ -1,10 +0,0 @@
1
- declare const HostProcessError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
2
- readonly _tag: "HostProcessError";
3
- } & Readonly<A>;
4
- export declare class HostProcessError extends HostProcessError_base<{
5
- readonly operation: "launch" | "signal" | "request" | "readout";
6
- readonly cause: unknown;
7
- }> {
8
- }
9
- export {};
10
- //# sourceMappingURL=HostProcessError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HostProcessError.d.ts","sourceRoot":"","sources":["../../src/testing/HostProcessError.ts"],"names":[],"mappings":";;;AAEA,qBAAa,gBAAiB,SAAQ,sBAAqC;IAC1E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAChE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB,CAAC;CAAG"}
@@ -1,4 +0,0 @@
1
- import { Data } from "effect";
2
- export class HostProcessError extends Data.TaggedError("HostProcessError") {
3
- }
4
- //# sourceMappingURL=HostProcessError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HostProcessError.js","sourceRoot":"","sources":["../../src/testing/HostProcessError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAGvE;CAAG"}
@@ -1,24 +0,0 @@
1
- import { type ChildProcess } from "node:child_process";
2
- import { type Redacted, Schema } from "effect";
3
- export interface HostProcessOptions {
4
- readonly args?: readonly string[];
5
- readonly cwd?: string;
6
- readonly databaseUrl?: Redacted.Redacted<string>;
7
- readonly env?: NodeJS.ProcessEnv;
8
- readonly execArgv?: readonly string[];
9
- readonly module: string | URL;
10
- }
11
- export declare function forkHost(options: HostProcessOptions, databaseUrl?: string): ChildProcess;
12
- export declare function receiveHostMessage<A>(child: ChildProcess, schema: Schema.Codec<A>, signal: AbortSignal, action?: () => void): Promise<A>;
13
- export declare function stopHost(child: ChildProcess): Promise<void>;
14
- export declare function sendHostMessage(message: unknown): Promise<void>;
15
- export declare function sendHostReady(url: string): Promise<void>;
16
- export declare function waitForHostStart(signal: AbortSignal): Promise<void>;
17
- export declare function hostResponse(url: string, path: string, signal: AbortSignal): Promise<{
18
- body: string;
19
- headers: {
20
- [k: string]: string;
21
- };
22
- status: number;
23
- }>;
24
- //# sourceMappingURL=hostProcess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcess.d.ts","sourceRoot":"","sources":["../../../src/testing/adapters/hostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAG/E,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC;CAC9B;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,MAAM,gBAQzE;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,IAAI,cAyC3H;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,iBAQ3C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,iBAQ/C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,iBAExC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,iBAyBnD;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW;;;;;;GAGhF"}
@@ -1,111 +0,0 @@
1
- import { fork } from "node:child_process";
2
- import process from "node:process";
3
- import { fileURLToPath } from "node:url";
4
- import { Option, Schema } from "effect";
5
- export function forkHost(options, databaseUrl) {
6
- const settings = {
7
- cwd: options.cwd,
8
- env: databaseUrl === undefined ? options.env : { ...options.env, "DATABASE_URL": databaseUrl },
9
- execArgv: [...(options.execArgv ?? [])],
10
- stdio: ["ignore", "ignore", "inherit", "ipc"],
11
- };
12
- return fork(typeof options.module === "string" ? options.module : fileURLToPath(options.module), [...(options.args ?? [])], settings);
13
- }
14
- export function receiveHostMessage(child, schema, signal, action) {
15
- return new Promise((resolve, reject) => {
16
- function cleanup() {
17
- child.off("message", message);
18
- child.off("exit", exited);
19
- child.off("error", failed);
20
- signal.removeEventListener("abort", aborted);
21
- }
22
- function failed(cause) {
23
- cleanup();
24
- reject(cause);
25
- }
26
- function exited(code, delivered) {
27
- failed(new Error(`Host exited (${delivered ?? code}) before IPC acknowledgement`));
28
- }
29
- function aborted() {
30
- failed(signal.reason);
31
- }
32
- function message(value) {
33
- const decoded = Schema.decodeUnknownOption(schema)(value);
34
- if (Option.isSome(decoded)) {
35
- cleanup();
36
- resolve(decoded.value);
37
- }
38
- }
39
- child.on("message", message);
40
- child.once("exit", exited);
41
- child.once("error", failed);
42
- signal.addEventListener("abort", aborted, { once: true });
43
- if (signal.aborted) {
44
- aborted();
45
- }
46
- else if (child.exitCode !== null || child.signalCode !== null) {
47
- exited(child.exitCode, child.signalCode);
48
- }
49
- else {
50
- try {
51
- action?.();
52
- }
53
- catch (cause) {
54
- failed(cause);
55
- }
56
- }
57
- });
58
- }
59
- export function stopHost(child) {
60
- if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null) {
61
- return Promise.resolve();
62
- }
63
- return new Promise((resolve) => {
64
- child.once("exit", () => resolve());
65
- child.kill("SIGKILL");
66
- });
67
- }
68
- export function sendHostMessage(message) {
69
- return new Promise((resolve, reject) => {
70
- if (process.send === undefined) {
71
- reject(new Error("Host process needs a parent IPC channel"));
72
- return;
73
- }
74
- process.send(message, (error) => (error === null ? resolve() : reject(error)));
75
- });
76
- }
77
- export function sendHostReady(url) {
78
- return sendHostMessage({ pid: process.pid, type: "host-ready", url });
79
- }
80
- export function waitForHostStart(signal) {
81
- return new Promise((resolve, reject) => {
82
- function cleanup() {
83
- process.off("SIGUSR2", start);
84
- signal.removeEventListener("abort", aborted);
85
- }
86
- function failed(cause) {
87
- cleanup();
88
- reject(cause);
89
- }
90
- function start() {
91
- cleanup();
92
- resolve();
93
- }
94
- function aborted() {
95
- failed(signal.reason);
96
- }
97
- process.once("SIGUSR2", start);
98
- signal.addEventListener("abort", aborted, { once: true });
99
- if (signal.aborted) {
100
- aborted();
101
- }
102
- else {
103
- void sendHostMessage({ type: "host-prepared" }).catch(failed);
104
- }
105
- });
106
- }
107
- export async function hostResponse(url, path, signal) {
108
- const response = await fetch(new URL(path, url), { redirect: "manual", signal });
109
- return { body: await response.text(), headers: Object.fromEntries(response.headers), status: response.status };
110
- }
111
- //# sourceMappingURL=hostProcess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcess.js","sourceRoot":"","sources":["../../../src/testing/adapters/hostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAWvD,MAAM,UAAU,QAAQ,CAAC,OAA2B,EAAE,WAAoB;IACzE,MAAM,QAAQ,GAAgB;QAC7B,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE;QAC9F,QAAQ,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QACvC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC;KAC7C,CAAC;IACF,OAAO,IAAI,CAAC,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AACvI,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAI,KAAmB,EAAE,MAAuB,E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AU,YAAY,CAAC,GAAW,EAAE,IAAY,EAAE,MAAmB;IAChF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACjF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;AAChH,CAAC"}
@@ -1,10 +0,0 @@
1
- import type { ChildProcess } from "node:child_process";
2
- import { HostReadouts } from "#testing/hostProcessProtocol.ts";
3
- export declare function listenHostReadouts(read: () => typeof HostReadouts.Type): () => NodeJS.Process;
4
- export declare function collectHostReadouts(child: ChildProcess): (signal: AbortSignal) => Promise<{
5
- readonly activeWork: readonly string[];
6
- readonly finalizers: readonly string[];
7
- readonly shutdownDuration: number | null;
8
- readonly type: "host-readouts";
9
- }>;
10
- //# sourceMappingURL=hostProcessReadouts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessReadouts.d.ts","sourceRoot":"","sources":["../../../src/testing/adapters/hostProcessReadouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,OAAO,YAAY,CAAC,IAAI,wBAQtE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,YAQtC,WAAW;;;;;GAI3B"}
@@ -1,26 +0,0 @@
1
- import process from "node:process";
2
- import { Option, Predicate, Schema } from "effect";
3
- import { HostReadouts } from "#testing/hostProcessProtocol.ts";
4
- import { receiveHostMessage } from "./hostProcess.js";
5
- export function listenHostReadouts(read) {
6
- function requested(message) {
7
- if (Predicate.hasProperty(message, "type") && message.type === "host-readouts") {
8
- process.send?.(read());
9
- }
10
- }
11
- process.on("message", requested);
12
- return () => process.off("message", requested);
13
- }
14
- export function collectHostReadouts(child) {
15
- let completed;
16
- child.on("message", (message) => {
17
- const decoded = Schema.decodeUnknownOption(HostReadouts)(message);
18
- if (Option.isSome(decoded) && decoded.value.shutdownDuration !== null) {
19
- completed = decoded.value;
20
- }
21
- });
22
- return (signal) => completed === undefined
23
- ? receiveHostMessage(child, HostReadouts, signal, () => child.send({ type: "host-readouts" }))
24
- : Promise.resolve(completed);
25
- }
26
- //# sourceMappingURL=hostProcessReadouts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessReadouts.js","sourceRoot":"","sources":["../../../src/testing/adapters/hostProcessReadouts.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,UAAU,kBAAkB,CAAC,IAAoC;IACtE,SAAS,SAAS,CAAC,OAAgB;QAClC,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAChF,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IACD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAmB;IACtD,IAAI,SAA+C,CAAC;IACpD,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAgB,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YACvE,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,MAAmB,EAAE,EAAE,CAC9B,SAAS,KAAK,SAAS;QACtB,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC"}
@@ -1,26 +0,0 @@
1
- import { Effect } from "effect";
2
- import { type HostProcessOptions } from "#testing/adapters/hostProcess.ts";
3
- import { HostProcessError } from "./HostProcessError.ts";
4
- export declare const hostProcess: <E = never, R = never>(options: HostProcessOptions & {
5
- readonly beforeStart?: Effect.Effect<void, E, R>;
6
- }) => Effect.Effect<{
7
- activeWork: () => Effect.Effect<readonly string[], HostProcessError, never>;
8
- disconnectIdlePostgres: () => Effect.Effect<void, never, never>;
9
- finalizers: () => Effect.Effect<readonly string[], HostProcessError, never>;
10
- headers: (path: string) => Effect.Effect<{
11
- [k: string]: string;
12
- }, HostProcessError, never>;
13
- health: () => Effect.Effect<{
14
- body: string;
15
- headers: {
16
- [k: string]: string;
17
- };
18
- status: number;
19
- }, HostProcessError, never>;
20
- pid: number;
21
- shutdownDuration: () => Effect.Effect<number | null, HostProcessError, never>;
22
- signal: (delivered: NodeJS.Signals) => Effect.Effect<void, HostProcessError, never>;
23
- stop: () => Effect.Effect<void, never, never>;
24
- url: string;
25
- }, E | HostProcessError, R | import("effect/Scope").Scope>;
26
- //# sourceMappingURL=hostProcess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcess.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAY,KAAK,kBAAkB,EAA8C,MAAM,kCAAkC,CAAC;AAEjI,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,eAAO,MAAM,WAAW,GAAmD,CAAC,UAAU,CAAC;2BAC/B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;;;;;oBA8C/D,MAAM;;;;;;;;;;;;wBAIF,MAAM,CAAC,OAAO;;;0DAWlC,CAAC"}
@@ -1,56 +0,0 @@
1
- import { Effect, Redacted, Schema } from "effect";
2
- import { forkHost, hostResponse, receiveHostMessage, stopHost } from "#testing/adapters/hostProcess.ts";
3
- import { collectHostReadouts } from "#testing/adapters/hostProcessReadouts.ts";
4
- import { HostProcessError } from "./HostProcessError.js";
5
- import { HostPrepared, HostReady, HostSignal } from "./hostProcessProtocol.js";
6
- export const hostProcess = Effect.fn("HostProcess.hostProcess")(function* (options) {
7
- const databaseUrl = options.databaseUrl;
8
- const database = databaseUrl === undefined
9
- ? undefined
10
- : yield* Effect.promise(() => import("@shivaedev/test-sql/server/disconnectProxy.ts")).pipe(Effect.flatMap(({ disconnectProxy }) => disconnectProxy(Redacted.value(databaseUrl))));
11
- const child = yield* Effect.acquireRelease(Effect.try({ catch: (cause) => new HostProcessError({ cause, operation: "launch" }), try: () => forkHost(options, database?.url) }), (acquired) => Effect.promise(() => stopHost(acquired)));
12
- const read = collectHostReadouts(child);
13
- if (options.beforeStart !== undefined) {
14
- yield* Effect.tryPromise({
15
- catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
16
- try: (signal) => receiveHostMessage(child, HostPrepared, signal),
17
- });
18
- yield* options.beforeStart;
19
- }
20
- const { pid, url } = yield* Effect.tryPromise({
21
- catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
22
- try: (signal) => receiveHostMessage(child, HostReady, signal, options.beforeStart === undefined ? undefined : () => child.kill("SIGUSR2")),
23
- });
24
- function response(path) {
25
- return Effect.tryPromise({
26
- catch: (cause) => new HostProcessError({ cause, operation: "request" }),
27
- try: (signal) => hostResponse(url, path, signal),
28
- });
29
- }
30
- function readouts() {
31
- return Effect.tryPromise({
32
- catch: (cause) => new HostProcessError({ cause, operation: "readout" }),
33
- try: read,
34
- });
35
- }
36
- return {
37
- activeWork: () => readouts().pipe(Effect.map((state) => state.activeWork)),
38
- disconnectIdlePostgres: () => Effect.suspend(() => database === undefined
39
- ? Effect.die(new Error("Launch the host with databaseUrl before disconnecting PostgreSQL"))
40
- : Effect.sync(database.disconnect)),
41
- finalizers: () => readouts().pipe(Effect.map((state) => state.finalizers)),
42
- headers: (path) => response(path).pipe(Effect.map((answer) => answer.headers)),
43
- health: () => response("/health"),
44
- pid,
45
- shutdownDuration: () => readouts().pipe(Effect.map((state) => state.shutdownDuration)),
46
- signal: (delivered) => Effect.tryPromise({
47
- catch: (cause) => new HostProcessError({ cause, operation: "signal" }),
48
- try: (signal) => receiveHostMessage(child, HostSignal.pipe(Schema.check(Schema.makeFilter((ack) => ack.signal === delivered))), signal, () => {
49
- child.kill(delivered);
50
- }),
51
- }).pipe(Effect.asVoid),
52
- stop: () => Effect.promise(() => stopHost(child)),
53
- url,
54
- };
55
- });
56
- //# sourceMappingURL=hostProcess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcess.js","sourceRoot":"","sources":["../../src/testing/hostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,QAAQ,EAA2B,YAAY,EAAE,kBAAkB,EAAE,Q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AAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;YACtE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CACf,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE;gBAC3H,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvB,CAAC,CAAC;SACH,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjD,GAAG;KACH,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Effect } from "effect";
2
- import { HttpServer } from "effect/http";
3
- import { HostProcessError } from "#testing/HostProcessError.ts";
4
- export declare const awaitHostStart: Effect.Effect<void, HostProcessError, never>;
5
- export declare const reportHostReady: Effect.Effect<void, HostProcessError, HttpServer.HttpServer>;
6
- export declare function acknowledgeHostSignal(signal: NodeJS.Signals): Effect.Effect<void, HostProcessError, never>;
7
- //# sourceMappingURL=hostProcessChild.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessChild.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,eAAO,MAAM,cAAc,8CAGzB,CAAC;AAEH,eAAO,MAAM,eAAe,8DAO3B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,gDAK3D"}
@@ -1,19 +0,0 @@
1
- import { Effect } from "effect";
2
- import { HttpServer } from "effect/http";
3
- import { sendHostMessage, sendHostReady, waitForHostStart } from "#testing/adapters/hostProcess.ts";
4
- import { HostProcessError } from "#testing/HostProcessError.ts";
5
- export const awaitHostStart = Effect.tryPromise({
6
- catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
7
- try: waitForHostStart,
8
- });
9
- export const reportHostReady = HttpServer.HttpServer.pipe(Effect.flatMap((server) => Effect.tryPromise({
10
- catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
11
- try: () => sendHostReady(HttpServer.formatAddress(server.address)),
12
- })));
13
- export function acknowledgeHostSignal(signal) {
14
- return Effect.tryPromise({
15
- catch: (cause) => new HostProcessError({ cause, operation: "signal" }),
16
- try: () => sendHostMessage({ signal, type: "host-signal" }),
17
- });
18
- }
19
- //# sourceMappingURL=hostProcessChild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessChild.js","sourceRoot":"","sources":["../../src/testing/hostProcessChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;IAC/C,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtE,GAAG,EAAE,gBAAgB;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CACxD,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACzB,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAClE,CAAC,CACF,CACD,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IAC3D,OAAO,MAAM,CAAC,UAAU,CAAC;QACxB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtE,GAAG,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAC3D,CAAC,CAAC;AACJ,CAAC"}
@@ -1,20 +0,0 @@
1
- import { Schema } from "effect";
2
- export declare const HostReady: Schema.Struct<{
3
- readonly pid: Schema.Number;
4
- readonly type: Schema.Literal<"host-ready">;
5
- readonly url: Schema.String;
6
- }>;
7
- export declare const HostPrepared: Schema.Struct<{
8
- readonly type: Schema.Literal<"host-prepared">;
9
- }>;
10
- export declare const HostSignal: Schema.Struct<{
11
- readonly signal: Schema.String;
12
- readonly type: Schema.Literal<"host-signal">;
13
- }>;
14
- export declare const HostReadouts: Schema.Struct<{
15
- readonly activeWork: Schema.$Array<Schema.String>;
16
- readonly finalizers: Schema.$Array<Schema.String>;
17
- readonly shutdownDuration: Schema.NullOr<Schema.Number>;
18
- readonly type: Schema.Literal<"host-readouts">;
19
- }>;
20
- //# sourceMappingURL=hostProcessProtocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessProtocol.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,SAAS;;;;EAAgG,CAAC;AACvH,eAAO,MAAM,YAAY;;EAA2D,CAAC;AACrF,eAAO,MAAM,UAAU;;;EAAgF,CAAC;AACxG,eAAO,MAAM,YAAY;;;;;EAKvB,CAAC"}
@@ -1,11 +0,0 @@
1
- import { Schema } from "effect";
2
- export const HostReady = Schema.Struct({ pid: Schema.Number, type: Schema.Literal("host-ready"), url: Schema.String });
3
- export const HostPrepared = Schema.Struct({ type: Schema.Literal("host-prepared") });
4
- export const HostSignal = Schema.Struct({ signal: Schema.String, type: Schema.Literal("host-signal") });
5
- export const HostReadouts = Schema.Struct({
6
- activeWork: Schema.Array(Schema.String),
7
- finalizers: Schema.Array(Schema.String),
8
- shutdownDuration: Schema.NullOr(Schema.Number),
9
- type: Schema.Literal("host-readouts"),
10
- });
11
- //# sourceMappingURL=hostProcessProtocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessProtocol.js","sourceRoot":"","sources":["../../src/testing/hostProcessProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACvH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AACrF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AACxG,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;CACrC,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Effect } from "effect";
2
- export declare const hostProcessReadouts: Effect.Effect<{
3
- finalizer: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
4
- shutdown: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
5
- work: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
6
- }, never, import("effect/Scope").Scope>;
7
- //# sourceMappingURL=hostProcessReadouts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostProcessReadouts.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessReadouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKjD,eAAO,MAAM,mBAAmB;gBAsBlB,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,MAAM,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;eACtD,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;WAM3C,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,MAAM,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;uCAW5D,CAAC"}