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