@specific.dev/spectest 0.82.0 → 0.85.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 (46) hide show
  1. package/dist/components/index.d.ts +1 -0
  2. package/dist/components/index.js +1 -0
  3. package/dist/components/postgres-tls.d.ts +10 -0
  4. package/dist/components/postgres-tls.js +9 -0
  5. package/dist/components/postgres.d.ts +59 -1
  6. package/dist/components/postgres.js +5 -2
  7. package/dist/components/supabase-config.d.ts +5 -0
  8. package/dist/components/supabase-config.js +12 -4
  9. package/dist/components/supabase-webhooks.d.ts +1 -0
  10. package/dist/components/supabase-webhooks.js +262 -0
  11. package/dist/components/supabase.d.ts +36 -11
  12. package/dist/components/supabase.js +75 -18
  13. package/dist/components/temporal.d.ts +89 -0
  14. package/dist/components/temporal.js +185 -0
  15. package/dist/coverage.d.ts +78 -3
  16. package/dist/coverage.js +251 -11
  17. package/dist/daemon.js +71 -5
  18. package/dist/environment-ca.d.ts +8 -0
  19. package/dist/environment-ca.js +16 -0
  20. package/dist/harness/container-run.js +3 -0
  21. package/dist/harness/coverage.d.ts +19 -7
  22. package/dist/harness/coverage.js +52 -9
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/package.json +1 -1
  26. package/src/components/index.ts +3 -0
  27. package/src/components/postgres-tls.test.ts +23 -0
  28. package/src/components/postgres-tls.ts +11 -0
  29. package/src/components/postgres.ts +8 -2
  30. package/src/components/supabase-config.ts +11 -2
  31. package/src/components/supabase-db.test.ts +64 -0
  32. package/src/components/supabase-dir.test.ts +71 -0
  33. package/src/components/supabase-webhooks.ts +263 -0
  34. package/src/components/supabase.ts +108 -28
  35. package/src/components/temporal.test.ts +86 -0
  36. package/src/components/temporal.ts +188 -0
  37. package/src/coverage.test.ts +93 -13
  38. package/src/coverage.ts +295 -11
  39. package/src/daemon.ts +68 -3
  40. package/src/environment-ca.test.ts +44 -0
  41. package/src/environment-ca.ts +20 -0
  42. package/src/harness/container-run.test.ts +14 -2
  43. package/src/harness/container-run.ts +3 -0
  44. package/src/harness/coverage.test.ts +32 -1
  45. package/src/harness/coverage.ts +47 -9
  46. package/src/index.ts +1 -0
@@ -1,3 +1,4 @@
1
+ export { temporal, temporalClient, type TemporalOptions, type TemporalClient, type TemporalNamespace, type TemporalWorkerOptions, type TemporalPoller, type TemporalSearchAttributeType, type TemporalTaskType } from "./temporal.js";
1
2
  export { postgres, type PostgresOptions, type PostgresHelpers, } from "./postgres.js";
2
3
  export { s3, type S3Options, type S3Helpers, } from "./s3.js";
3
4
  export { SQL, type SqlClient, type SqlOptions } from "../sql.js";
@@ -1,4 +1,5 @@
1
1
  // Reusable, pre-built service definitions for common dependencies.
2
+ export { temporal, temporalClient } from "./temporal.js";
2
3
  //
3
4
  // Each component returns a fully-formed `ServiceDefinition` ready to
4
5
  // drop into an environment's `services` map. Beyond the container
@@ -0,0 +1,10 @@
1
+ /** Postgres terminates its own TLS; HTTP ingress cannot proxy its wire protocol. */
2
+ export declare function postgresTls(hostnames?: string[]): {
3
+ args: string[];
4
+ certificates: {
5
+ hostnames: string[];
6
+ certPath: string;
7
+ keyPath: string;
8
+ user: string;
9
+ }[];
10
+ };
@@ -0,0 +1,9 @@
1
+ /** Postgres terminates its own TLS; HTTP ingress cannot proxy its wire protocol. */
2
+ export function postgresTls(hostnames = ["{{SPECTEST_SERVICE}}", "{{SPECTEST_SERVICE}}.internal"]) {
3
+ return {
4
+ args: ["-c", "ssl=on", "-c", "ssl_cert_file=/tls/postgres.crt", "-c", "ssl_key_file=/tls/postgres.key"],
5
+ certificates: [{
6
+ hostnames, certPath: "/tls/postgres.crt", keyPath: "/tls/postgres.key", user: "postgres",
7
+ }],
8
+ };
9
+ }
@@ -25,6 +25,9 @@ export interface PostgresOptions {
25
25
  persistent?: boolean;
26
26
  /** TCP port the container listens on. Default `5432`. */
27
27
  port?: number;
28
+ /** Native TLS is available by default using the environment CA; plaintext
29
+ * connections remain accepted. Set false to disable TLS for a custom image. */
30
+ tls?: boolean;
28
31
  /**
29
32
  * CMD args appended after the image entrypoint (keeps the entrypoint, unlike
30
33
  * `command`). For extension tuning, e.g.
@@ -109,7 +112,62 @@ export declare function postgres(opts: PostgresOptions): {
109
112
  helpers: ({ name }: {
110
113
  name: string;
111
114
  }) => PostgresHelpers;
112
- args?: string[] | undefined;
115
+ args: string[];
116
+ certificates: {
117
+ hostnames: string[];
118
+ certPath: string;
119
+ keyPath: string;
120
+ user: string;
121
+ }[];
122
+ image: {
123
+ type: "registry";
124
+ reference: string;
125
+ };
126
+ } | {
127
+ setup?: ((args: ServiceSetupContext<PostgresHelpers>) => void | Promise<void>) | undefined;
128
+ env: {
129
+ POSTGRES_DB: string;
130
+ POSTGRES_USER: string;
131
+ POSTGRES_PASSWORD: string;
132
+ PGDATA: string;
133
+ };
134
+ volumes: {
135
+ target: string;
136
+ }[];
137
+ ports: number[];
138
+ readyCheck: {
139
+ type: "tcp";
140
+ port: number;
141
+ timeoutSecs: number;
142
+ };
143
+ helpers: ({ name }: {
144
+ name: string;
145
+ }) => PostgresHelpers;
146
+ args: string[];
147
+ image: {
148
+ type: "registry";
149
+ reference: string;
150
+ };
151
+ } | {
152
+ setup?: ((args: ServiceSetupContext<PostgresHelpers>) => void | Promise<void>) | undefined;
153
+ env: {
154
+ POSTGRES_DB: string;
155
+ POSTGRES_USER: string;
156
+ POSTGRES_PASSWORD: string;
157
+ PGDATA: string;
158
+ };
159
+ volumes: {
160
+ target: string;
161
+ }[];
162
+ ports: number[];
163
+ readyCheck: {
164
+ type: "tcp";
165
+ port: number;
166
+ timeoutSecs: number;
167
+ };
168
+ helpers: ({ name }: {
169
+ name: string;
170
+ }) => PostgresHelpers;
113
171
  image: {
114
172
  type: "registry";
115
173
  reference: string;
@@ -1,4 +1,5 @@
1
1
  import { SQL } from "../sql.js";
2
+ import { postgresTls } from "./postgres-tls.js";
2
3
  /**
3
4
  * A ready-to-use Postgres service. Drop into `environment.services`:
4
5
  *
@@ -29,13 +30,15 @@ export function postgres(opts) {
29
30
  const reference = opts.image ?? `postgres:${version}`;
30
31
  const port = opts.port ?? 5432;
31
32
  const persistent = opts.persistent ?? true;
33
+ const tls = opts.tls !== false ? postgresTls() : undefined;
32
34
  // `satisfies` (instead of a return-type annotation) preserves the
33
35
  // literal type — in particular, the `helpers` factory's return shape.
34
36
  // The mapped type in `ServiceHandlesFor<S>` reads that to type
35
37
  // `ctx.svc.<name>` as `{ client: SqlClient }`.
36
38
  return {
37
39
  image: { type: "registry", reference },
38
- ...(opts.args ? { args: opts.args } : {}),
40
+ ...(tls ? { args: [...(opts.args ?? ["postgres"]), ...tls.args], certificates: tls.certificates }
41
+ : opts.args ? { args: opts.args } : {}),
39
42
  env: {
40
43
  POSTGRES_DB: opts.database,
41
44
  POSTGRES_USER: opts.user,
@@ -51,7 +54,7 @@ export function postgres(opts) {
51
54
  helpers: ({ name }) => {
52
55
  const url = `postgres://${encodeURIComponent(opts.user)}` +
53
56
  `:${encodeURIComponent(opts.password)}` +
54
- `@${name}:${port}/${encodeURIComponent(opts.database)}`;
57
+ `@${name}:${port}/${encodeURIComponent(opts.database)}` + (tls ? "?sslmode=verify-full" : "");
55
58
  return { client: new SQL(url, { label: name }) };
56
59
  },
57
60
  // The user's hook, forwarded verbatim — postgres() declares none of
@@ -15,6 +15,11 @@ export interface MailTemplateSpec {
15
15
  export interface MappedSupabaseConfig {
16
16
  /** GoTrue (`<name>-auth`) environment. */
17
17
  auth: Record<string, string>;
18
+ /** GoTrue variables whose values come from the component's env option. */
19
+ deferredAuth: Record<string, {
20
+ from: string;
21
+ key: string;
22
+ }>;
18
23
  /** PostgREST (`<name>-rest`) environment. */
19
24
  rest: Record<string, string>;
20
25
  /** Per-function JWT verification, by function name (`functions.<name>.verify_jwt`). */
@@ -210,10 +210,17 @@ const RULES = [
210
210
  const field = path[3];
211
211
  if (field === "enabled")
212
212
  out.auth[`GOTRUE_HOOK_${prefix}_ENABLED`] = bool(v);
213
- else if (field === "uri")
214
- out.auth[`GOTRUE_HOOK_${prefix}_URI`] = str(v);
215
- else if (field === "secrets")
216
- out.auth[`GOTRUE_HOOK_${prefix}_SECRETS`] = str(v);
213
+ else if (field === "uri" || field === "secrets") {
214
+ const target = `GOTRUE_HOOK_${prefix}_${field.toUpperCase()}`;
215
+ const value = configValue(v);
216
+ if (value.literal !== undefined)
217
+ out.auth[target] = value.literal;
218
+ else if (value.from !== undefined) {
219
+ out.deferredAuth[target] = { from: value.from, key: path.join(".") };
220
+ }
221
+ else if (value.encrypted)
222
+ out.encryptedValues.push(path.join("."));
223
+ }
217
224
  },
218
225
  },
219
226
  // ── auth: OAuth server (cli gotrue.service.ts:641-646) ──────────────────
@@ -386,6 +393,7 @@ function isOff(v) {
386
393
  export function mapSupabaseConfig(doc) {
387
394
  const out = {
388
395
  auth: {},
396
+ deferredAuth: {},
389
397
  rest: {},
390
398
  functionVerifyJwt: {},
391
399
  functionSecrets: {},
@@ -0,0 +1 @@
1
+ export declare const SUPABASE_WEBHOOKS_SQL: string;
@@ -0,0 +1,262 @@
1
+ // Supabase CLI database-webhook bootstrap, pinned at 9266dce406db8266d3c6f82839619330aab773c2.
2
+ // https://github.com/supabase/cli/blob/9266dce406db8266d3c6f82839619330aab773c2/apps/cli-go/internal/db/start/templates/webhook.sql
3
+ /*
4
+ MIT License
5
+
6
+ Copyright (c) 2021 Supabase, Inc. and contributors
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ */
26
+ export const SUPABASE_WEBHOOKS_SQL = String.raw `
27
+ SELECT to_regprocedure('supabase_functions.http_request()') IS NULL AS install_webhooks \gset
28
+ \if :install_webhooks
29
+ BEGIN;
30
+
31
+ -- Create pg_net extension
32
+ CREATE EXTENSION IF NOT EXISTS pg_net SCHEMA extensions;
33
+
34
+ -- Create supabase_functions schema
35
+ CREATE SCHEMA supabase_functions AUTHORIZATION supabase_admin;
36
+
37
+ GRANT USAGE ON SCHEMA supabase_functions TO postgres, anon, authenticated, service_role;
38
+ ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON TABLES TO postgres, anon, authenticated, service_role;
39
+ ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO postgres, anon, authenticated, service_role;
40
+ ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO postgres, anon, authenticated, service_role;
41
+
42
+ -- supabase_functions.migrations definition
43
+ CREATE TABLE supabase_functions.migrations (
44
+ version text PRIMARY KEY,
45
+ inserted_at timestamptz NOT NULL DEFAULT NOW()
46
+ );
47
+
48
+ -- Initial supabase_functions migration
49
+ INSERT INTO supabase_functions.migrations (version) VALUES ('initial');
50
+
51
+ -- supabase_functions.hooks definition
52
+ CREATE TABLE supabase_functions.hooks (
53
+ id bigserial PRIMARY KEY,
54
+ hook_table_id integer NOT NULL,
55
+ hook_name text NOT NULL,
56
+ created_at timestamptz NOT NULL DEFAULT NOW(),
57
+ request_id bigint
58
+ );
59
+ CREATE INDEX supabase_functions_hooks_request_id_idx ON supabase_functions.hooks USING btree (request_id);
60
+ CREATE INDEX supabase_functions_hooks_h_table_id_h_name_idx ON supabase_functions.hooks USING btree (hook_table_id, hook_name);
61
+ COMMENT ON TABLE supabase_functions.hooks IS 'Supabase Functions Hooks: Audit trail for triggered hooks.';
62
+
63
+ CREATE FUNCTION supabase_functions.http_request()
64
+ RETURNS trigger
65
+ LANGUAGE plpgsql
66
+ AS $function$
67
+ DECLARE
68
+ request_id bigint;
69
+ payload jsonb;
70
+ url text := TG_ARGV[0]::text;
71
+ method text := TG_ARGV[1]::text;
72
+ headers jsonb DEFAULT '{}'::jsonb;
73
+ params jsonb DEFAULT '{}'::jsonb;
74
+ timeout_ms integer DEFAULT 1000;
75
+ BEGIN
76
+ IF url IS NULL OR url = 'null' THEN
77
+ RAISE EXCEPTION 'url argument is missing';
78
+ END IF;
79
+
80
+ IF method IS NULL OR method = 'null' THEN
81
+ RAISE EXCEPTION 'method argument is missing';
82
+ END IF;
83
+
84
+ IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN
85
+ headers = '{"Content-Type": "application/json"}'::jsonb;
86
+ ELSE
87
+ headers = TG_ARGV[2]::jsonb;
88
+ END IF;
89
+
90
+ IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN
91
+ params = '{}'::jsonb;
92
+ ELSE
93
+ params = TG_ARGV[3]::jsonb;
94
+ END IF;
95
+
96
+ IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN
97
+ timeout_ms = 1000;
98
+ ELSE
99
+ timeout_ms = TG_ARGV[4]::integer;
100
+ END IF;
101
+
102
+ CASE
103
+ WHEN method = 'GET' THEN
104
+ SELECT http_get INTO request_id FROM net.http_get(
105
+ url,
106
+ params,
107
+ headers,
108
+ timeout_ms
109
+ );
110
+ WHEN method = 'POST' THEN
111
+ payload = jsonb_build_object(
112
+ 'old_record', OLD,
113
+ 'record', NEW,
114
+ 'type', TG_OP,
115
+ 'table', TG_TABLE_NAME,
116
+ 'schema', TG_TABLE_SCHEMA
117
+ );
118
+
119
+ SELECT http_post INTO request_id FROM net.http_post(
120
+ url,
121
+ payload,
122
+ params,
123
+ headers,
124
+ timeout_ms
125
+ );
126
+ ELSE
127
+ RAISE EXCEPTION 'method argument % is invalid', method;
128
+ END CASE;
129
+
130
+ INSERT INTO supabase_functions.hooks
131
+ (hook_table_id, hook_name, request_id)
132
+ VALUES
133
+ (TG_RELID, TG_NAME, request_id);
134
+
135
+ RETURN NEW;
136
+ END
137
+ $function$;
138
+
139
+ -- Supabase super admin
140
+ DO
141
+ $$
142
+ BEGIN
143
+ IF NOT EXISTS (
144
+ SELECT 1
145
+ FROM pg_roles
146
+ WHERE rolname = 'supabase_functions_admin'
147
+ )
148
+ THEN
149
+ CREATE USER supabase_functions_admin NOINHERIT CREATEROLE LOGIN NOREPLICATION;
150
+ END IF;
151
+ END
152
+ $$;
153
+
154
+ GRANT ALL PRIVILEGES ON SCHEMA supabase_functions TO supabase_functions_admin;
155
+ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA supabase_functions TO supabase_functions_admin;
156
+ GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA supabase_functions TO supabase_functions_admin;
157
+ ALTER USER supabase_functions_admin SET search_path = "supabase_functions";
158
+ ALTER table "supabase_functions".migrations OWNER TO supabase_functions_admin;
159
+ ALTER table "supabase_functions".hooks OWNER TO supabase_functions_admin;
160
+ ALTER function "supabase_functions".http_request() OWNER TO supabase_functions_admin;
161
+ GRANT supabase_functions_admin TO postgres;
162
+
163
+ -- Remove unused supabase_pg_net_admin role
164
+ DO
165
+ $$
166
+ BEGIN
167
+ IF EXISTS (
168
+ SELECT 1
169
+ FROM pg_roles
170
+ WHERE rolname = 'supabase_pg_net_admin'
171
+ )
172
+ THEN
173
+ REASSIGN OWNED BY supabase_pg_net_admin TO supabase_admin;
174
+ DROP OWNED BY supabase_pg_net_admin;
175
+ DROP ROLE supabase_pg_net_admin;
176
+ END IF;
177
+ END
178
+ $$;
179
+
180
+ -- pg_net grants when extension is already enabled
181
+ DO
182
+ $$
183
+ BEGIN
184
+ IF EXISTS (
185
+ SELECT 1
186
+ FROM pg_extension
187
+ WHERE extname = 'pg_net'
188
+ )
189
+ THEN
190
+ GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role;
191
+
192
+ ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
193
+ ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
194
+
195
+ ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
196
+ ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
197
+
198
+ REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
199
+ REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
200
+
201
+ GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
202
+ GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
203
+ END IF;
204
+ END
205
+ $$;
206
+
207
+ -- Event trigger for pg_net
208
+ CREATE OR REPLACE FUNCTION extensions.grant_pg_net_access()
209
+ RETURNS event_trigger
210
+ LANGUAGE plpgsql
211
+ AS $$
212
+ BEGIN
213
+ IF EXISTS (
214
+ SELECT 1
215
+ FROM pg_event_trigger_ddl_commands() AS ev
216
+ JOIN pg_extension AS ext
217
+ ON ev.objid = ext.oid
218
+ WHERE ext.extname = 'pg_net'
219
+ )
220
+ THEN
221
+ GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role;
222
+
223
+ ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
224
+ ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
225
+
226
+ ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
227
+ ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
228
+
229
+ REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
230
+ REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
231
+
232
+ GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
233
+ GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
234
+ END IF;
235
+ END;
236
+ $$;
237
+ COMMENT ON FUNCTION extensions.grant_pg_net_access IS 'Grants access to pg_net';
238
+
239
+ DO
240
+ $$
241
+ BEGIN
242
+ IF NOT EXISTS (
243
+ SELECT 1
244
+ FROM pg_event_trigger
245
+ WHERE evtname = 'issue_pg_net_access'
246
+ ) THEN
247
+ CREATE EVENT TRIGGER issue_pg_net_access ON ddl_command_end WHEN TAG IN ('CREATE EXTENSION')
248
+ EXECUTE PROCEDURE extensions.grant_pg_net_access();
249
+ END IF;
250
+ END
251
+ $$;
252
+
253
+ INSERT INTO supabase_functions.migrations (version) VALUES ('20210809183423_update_grants');
254
+
255
+ ALTER function supabase_functions.http_request() SECURITY DEFINER;
256
+ ALTER function supabase_functions.http_request() SET search_path = supabase_functions;
257
+ REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC;
258
+ GRANT EXECUTE ON FUNCTION supabase_functions.http_request() TO postgres, anon, authenticated, service_role;
259
+
260
+ COMMIT;
261
+ \endif
262
+ `;
@@ -3,6 +3,25 @@ import { type SqlClient } from "../sql.js";
3
3
  import { type EmailHelpers } from "./email.js";
4
4
  export type { MailTemplateId, MailTemplateSpec } from "./supabase-config.js";
5
5
  export interface SupabaseOptions {
6
+ /** Database image and extensions installed before project migrations. */
7
+ db?: {
8
+ /** Native database TLS, enabled by default using the environment CA. */
9
+ tls?: boolean;
10
+ /** Full Supabase-compatible Postgres image reference. Defaults to the pinned SDK image. */
11
+ image?: string;
12
+ /**
13
+ * Explicit extension overrides for projects whose migrations pin versions
14
+ * absent from the image. Omit version to use the image's default, or use
15
+ * db.image to supply an image containing the exact required version.
16
+ * Existing extensions must match the requested schema/version.
17
+ * Example: `{ vector: { schema: "public" } }` opts into the image's vector
18
+ * version before a historical CREATE EXTENSION IF NOT EXISTS migration.
19
+ */
20
+ extensions?: Record<string, {
21
+ schema?: string;
22
+ version?: string;
23
+ }>;
24
+ };
6
25
  /**
7
26
  * Key of the API-gateway service and the prefix for every other piece.
8
27
  * Default `"supabase"`. The gateway is reachable at `http://<name>:8000`
@@ -36,7 +55,7 @@ export interface SupabaseOptions {
36
55
  /**
37
56
  * Also serve the gateway over **HTTPS** at `https://<hostname>` via the
38
57
  * daemon's CA-trusted TLS reverse proxy (in addition to the plain
39
- * `http://<name>:8000`). `sb.url` and `sb.appEnv` then point at the HTTPS
58
+ * `http://<name>:8000`). `sb.url` then points at the HTTPS
40
59
  * address. Use TLS wherever you can: set this when a browser reaches the
41
60
  * gateway, because a page that is open over `https://` cannot call an
42
61
  * `http://` origin (Chromium blocks the request before it leaves the
@@ -95,13 +114,19 @@ export interface SupabaseOptions {
95
114
  * written one. Nothing is derived unless you name the folder, and each piece
96
115
  * is optional inside it — a folder with only a `config.toml` is fine.
97
116
  *
98
- * There is deliberately no per-piece path option and no way to configure
99
- * mail, OTP, redirect or JWT behaviour here: those live in `config.toml`,
100
- * where your project already declares them and where the Supabase CLI reads
101
- * them too. One source of truth, and the environment matches the one you run
102
- * locally.
117
+ * Use `configOverrides` for environment-specific config values without
118
+ * moving this folder's migrations, seed, templates or functions.
103
119
  */
104
120
  dir?: string;
121
+ /**
122
+ * Values recursively merged into the project's parsed Supabase config.
123
+ * Tables merge; arrays and scalar values replace their originals. Uses the
124
+ * same nested keys as config.toml, e.g.:
125
+ * `{ auth: { hook: { before_user_created: { uri: "https://app.test/hook" } } } }`.
126
+ * `env(...)` in overrides resolves through `env` just as it does in the file.
127
+ * Also works without `dir` for a stack with no project SQL or functions.
128
+ */
129
+ configOverrides?: Record<string, unknown>;
105
130
  /**
106
131
  * The `.env` of this environment — the values your `config.toml` reads with
107
132
  * `env(...)`.
@@ -279,18 +304,18 @@ export interface SupabaseStack {
279
304
  host: string;
280
305
  port: number;
281
306
  };
282
- /** Ready-to-spread env for the app under test: `SUPABASE_URL`,
283
- * `SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, `DATABASE_URL`. */
284
- appEnv: Record<string, string>;
285
307
  }
286
308
  /**
287
309
  * A ready-to-use self-hosted Supabase stack. Mount `.group` at the key
288
310
  * matching the `name` option (default `"supabase"`) and wire the app with
289
- * `.appEnv` / `.ready`:
311
+ * its connection values and `.ready`:
290
312
  *
291
313
  * ```ts
292
314
  * const sb = supabase({ dbPassword: "postgres" });
293
- * services: { supabase: sb.group, app: { image, env: sb.appEnv, dependsOn: [sb.ready] } }
315
+ * services: { supabase: sb.group, app: {
316
+ * image, env: { SUPABASE_URL: sb.url, SUPABASE_ANON_KEY: sb.anonKey },
317
+ * dependsOn: [sb.ready],
318
+ * } }
294
319
  * ```
295
320
  *
296
321
  * See the file header for the full picture. Tests get an instrumented DB client