@rehearsal-db/core 0.1.0-beta.4 → 0.1.0-beta.6

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.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Purpose: Define the small, closed set of database runtimes Rehearsal can select.
3
+ * Runtime implementations stay behind this boundary so the shared CLI does not
4
+ * need target-specific branches.
5
+ */
6
+
7
+ const TARGETS = Object.freeze({
8
+ supabase: Object.freeze({
9
+ id: "supabase",
10
+ label: "Supabase",
11
+ }),
12
+ postgresql: Object.freeze({
13
+ id: "postgresql",
14
+ label: "PostgreSQL",
15
+ }),
16
+ });
17
+
18
+ export const REHEARSAL_RUNTIME_TARGETS = Object.freeze(Object.keys(TARGETS));
19
+
20
+ export const resolveRuntimeTarget = (value = "supabase") => {
21
+ if (typeof value !== "string" || !Object.hasOwn(TARGETS, value)) {
22
+ throw new Error(
23
+ `Unsupported Rehearsal runtime target: ${String(value)}. Supported targets: ${REHEARSAL_RUNTIME_TARGETS.join(", ")}.`,
24
+ );
25
+ }
26
+ return TARGETS[value];
27
+ };
28
+
29
+ export const runRuntimeTarget = async (target) => {
30
+ const resolved = resolveRuntimeTarget(target);
31
+ switch (resolved.id) {
32
+ case "supabase":
33
+ await import("./supabase_runtime.mjs");
34
+ return;
35
+ case "postgresql":
36
+ await import("./postgresql_runtime.mjs");
37
+ return;
38
+ default:
39
+ throw new Error(`No runtime driver is installed for ${resolved.id}.`);
40
+ }
41
+ };