1import { GcpEnvironment } from "@/GCP/Environment";
2import * as Effect from "effect/Effect";
3import { MinimumLogLevel } from "effect/References";
4import * as Schedule from "effect/Schedule";
5
6export const logLevel = Effect.provideService(
7 MinimumLogLevel,
8 process.env.DEBUG ? "Debug" : "Info",
9);
10
11// The Cloud Number Registry API is not enabled in the testing project. Set
12// GCP_TEST_CLOUD_NUMBER_REGISTRY=1 on a project where it is.
13export const entitled = !!process.env.GCP_TEST_CLOUD_NUMBER_REGISTRY;
14export const runLifecycle = entitled && !process.env.FAST;
15
16export const currentProject = GcpEnvironment.current.pipe(
17 Effect.map((env) => env.project),
18);
19export const location = "global";
20
21export const waitUntilGone = <E extends { readonly _tag: string }, R>(
22 get: Effect.Effect<unknown, E, R>,
23) =>
24 get.pipe(
25 Effect.as("found" as const),
26 Effect.catchIf(
27 (error): error is Extract<E, { readonly _tag: "NotFound" }> =>
28 error._tag === "NotFound",
29 () => Effect.succeed("gone" as const),
30 ),
31 Effect.repeat({
32 schedule: Schedule.spaced("2 seconds"),
33 until: (status) => status === "gone",
34 times: 10,
35 }),
36 );