1import { GcpEnvironment } from "@/GCP/Environment";
2import * as Effect from "effect/Effect";
3import { MinimumLogLevel } from "effect/References";
4
5export const logLevel = Effect.provideService(
6 MinimumLogLevel,
7 process.env.DEBUG ? "Debug" : "Info",
8);
9
10export const currentProject = GcpEnvironment.current.pipe(
11 Effect.map((env) => env.project),
12);
13export const location = "us-central1";
14
15export const missingService = (serviceId = "alchemy-missing-service") =>
16 currentProject.pipe(
17 Effect.map(
18 (project) =>
19 `projects/${project}/locations/${location}/services/${serviceId}`,
20 ),
21 );
22
23export const missingSchema = (serviceId = "alchemy-missing-service") =>
24 missingService(serviceId).pipe(Effect.map((name) => `${name}/schemas/main`));
25
26export const missingConnector = (serviceId = "alchemy-missing-service") =>
27 missingService(serviceId).pipe(
28 Effect.map((name) => `${name}/connectors/alchemy-missing-connector`),
29 );
30
31export const schemaSource = (extraField?: string) => ({
32 files: [
33 {
34 path: "schema.gql",
35 content:
36 extraField === undefined
37 ? "type AlchemyNote @table { title: String! }"
38 : `type AlchemyNote @table { title: String! ${extraField} }`,
39 },
40 ],
41});
42
43export const unlinkedDatasources = [
44 { postgresql: { unlinked: true as const } },
45];
46
47export const connectorSource = {
48 files: [
49 {
50 path: "queries.gql",
51 content:
52 "query ListAlchemyNotes @auth(level: PUBLIC) { alchemyNotes { id title } }",
53 },
54 ],
55};