@supacloud/lite 0.2.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 (108) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +201 -0
  3. package/LICENSES/PGLITE-APACHE-2.0.txt +176 -0
  4. package/LICENSES/TINBASE-MIT.txt +21 -0
  5. package/README.md +170 -0
  6. package/RELEASING.md +22 -0
  7. package/THIRD_PARTY_NOTICES.md +24 -0
  8. package/dist/cli.js +9018 -0
  9. package/dist/index.d.ts +13 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +8469 -0
  12. package/dist/project-runtime.d.ts +65 -0
  13. package/dist/project-runtime.d.ts.map +1 -0
  14. package/dist/vendor/tinbase/auth/handler.d.ts +140 -0
  15. package/dist/vendor/tinbase/auth/handler.d.ts.map +1 -0
  16. package/dist/vendor/tinbase/auth/inbox.d.ts +34 -0
  17. package/dist/vendor/tinbase/auth/inbox.d.ts.map +1 -0
  18. package/dist/vendor/tinbase/auth/oauth.d.ts +88 -0
  19. package/dist/vendor/tinbase/auth/oauth.d.ts.map +1 -0
  20. package/dist/vendor/tinbase/auth/password.d.ts +9 -0
  21. package/dist/vendor/tinbase/auth/password.d.ts.map +1 -0
  22. package/dist/vendor/tinbase/auth/qr.d.ts +9 -0
  23. package/dist/vendor/tinbase/auth/qr.d.ts.map +1 -0
  24. package/dist/vendor/tinbase/auth/rate-limit.d.ts +34 -0
  25. package/dist/vendor/tinbase/auth/rate-limit.d.ts.map +1 -0
  26. package/dist/vendor/tinbase/auth/redirect.d.ts +21 -0
  27. package/dist/vendor/tinbase/auth/redirect.d.ts.map +1 -0
  28. package/dist/vendor/tinbase/auth/settings.d.ts +56 -0
  29. package/dist/vendor/tinbase/auth/settings.d.ts.map +1 -0
  30. package/dist/vendor/tinbase/auth/totp.d.ts +20 -0
  31. package/dist/vendor/tinbase/auth/totp.d.ts.map +1 -0
  32. package/dist/vendor/tinbase/cron/service.d.ts +47 -0
  33. package/dist/vendor/tinbase/cron/service.d.ts.map +1 -0
  34. package/dist/vendor/tinbase/db/bootstrap.d.ts +21 -0
  35. package/dist/vendor/tinbase/db/bootstrap.d.ts.map +1 -0
  36. package/dist/vendor/tinbase/db/database.d.ts +168 -0
  37. package/dist/vendor/tinbase/db/database.d.ts.map +1 -0
  38. package/dist/vendor/tinbase/db/emulated.d.ts +53 -0
  39. package/dist/vendor/tinbase/db/emulated.d.ts.map +1 -0
  40. package/dist/vendor/tinbase/db/engine.d.ts +47 -0
  41. package/dist/vendor/tinbase/db/engine.d.ts.map +1 -0
  42. package/dist/vendor/tinbase/db/inspect.d.ts +19 -0
  43. package/dist/vendor/tinbase/db/inspect.d.ts.map +1 -0
  44. package/dist/vendor/tinbase/db/pglite-engine.d.ts +9 -0
  45. package/dist/vendor/tinbase/db/pglite-engine.d.ts.map +1 -0
  46. package/dist/vendor/tinbase/db/schema-diff.d.ts +32 -0
  47. package/dist/vendor/tinbase/db/schema-diff.d.ts.map +1 -0
  48. package/dist/vendor/tinbase/db/sql-compat.d.ts +33 -0
  49. package/dist/vendor/tinbase/db/sql-compat.d.ts.map +1 -0
  50. package/dist/vendor/tinbase/functions/deno-shim.d.ts +15 -0
  51. package/dist/vendor/tinbase/functions/deno-shim.d.ts.map +1 -0
  52. package/dist/vendor/tinbase/functions/handler.d.ts +36 -0
  53. package/dist/vendor/tinbase/functions/handler.d.ts.map +1 -0
  54. package/dist/vendor/tinbase/gen-types.d.ts +23 -0
  55. package/dist/vendor/tinbase/gen-types.d.ts.map +1 -0
  56. package/dist/vendor/tinbase/index.d.ts +82 -0
  57. package/dist/vendor/tinbase/index.d.ts.map +1 -0
  58. package/dist/vendor/tinbase/jwt.d.ts +31 -0
  59. package/dist/vendor/tinbase/jwt.d.ts.map +1 -0
  60. package/dist/vendor/tinbase/log-buffer.d.ts +28 -0
  61. package/dist/vendor/tinbase/log-buffer.d.ts.map +1 -0
  62. package/dist/vendor/tinbase/net/service.d.ts +72 -0
  63. package/dist/vendor/tinbase/net/service.d.ts.map +1 -0
  64. package/dist/vendor/tinbase/node/bun-server.d.ts +23 -0
  65. package/dist/vendor/tinbase/node/bun-server.d.ts.map +1 -0
  66. package/dist/vendor/tinbase/node/bundle-function.d.ts +8 -0
  67. package/dist/vendor/tinbase/node/bundle-function.d.ts.map +1 -0
  68. package/dist/vendor/tinbase/node/config-toml.d.ts +34 -0
  69. package/dist/vendor/tinbase/node/config-toml.d.ts.map +1 -0
  70. package/dist/vendor/tinbase/node/fs-driver.d.ts +27 -0
  71. package/dist/vendor/tinbase/node/fs-driver.d.ts.map +1 -0
  72. package/dist/vendor/tinbase/node/load-config.d.ts +82 -0
  73. package/dist/vendor/tinbase/node/load-config.d.ts.map +1 -0
  74. package/dist/vendor/tinbase/node/load-functions.d.ts +24 -0
  75. package/dist/vendor/tinbase/node/load-functions.d.ts.map +1 -0
  76. package/dist/vendor/tinbase/node/project.d.ts +21 -0
  77. package/dist/vendor/tinbase/node/project.d.ts.map +1 -0
  78. package/dist/vendor/tinbase/node/server-shared.d.ts +10 -0
  79. package/dist/vendor/tinbase/node/server-shared.d.ts.map +1 -0
  80. package/dist/vendor/tinbase/realtime/engine.d.ts +82 -0
  81. package/dist/vendor/tinbase/realtime/engine.d.ts.map +1 -0
  82. package/dist/vendor/tinbase/rest/build.d.ts +101 -0
  83. package/dist/vendor/tinbase/rest/build.d.ts.map +1 -0
  84. package/dist/vendor/tinbase/rest/errors.d.ts +11 -0
  85. package/dist/vendor/tinbase/rest/errors.d.ts.map +1 -0
  86. package/dist/vendor/tinbase/rest/handler.d.ts +28 -0
  87. package/dist/vendor/tinbase/rest/handler.d.ts.map +1 -0
  88. package/dist/vendor/tinbase/rest/parse.d.ts +95 -0
  89. package/dist/vendor/tinbase/rest/parse.d.ts.map +1 -0
  90. package/dist/vendor/tinbase/retention/service.d.ts +41 -0
  91. package/dist/vendor/tinbase/retention/service.d.ts.map +1 -0
  92. package/dist/vendor/tinbase/security.d.ts +23 -0
  93. package/dist/vendor/tinbase/security.d.ts.map +1 -0
  94. package/dist/vendor/tinbase/storage/driver.d.ts +17 -0
  95. package/dist/vendor/tinbase/storage/driver.d.ts.map +1 -0
  96. package/dist/vendor/tinbase/storage/handler.d.ts +76 -0
  97. package/dist/vendor/tinbase/storage/handler.d.ts.map +1 -0
  98. package/dist/vendor/tinbase/storage/image-transform.d.ts +38 -0
  99. package/dist/vendor/tinbase/storage/image-transform.d.ts.map +1 -0
  100. package/dist/vendor/tinbase/storage/s3-driver.d.ts +36 -0
  101. package/dist/vendor/tinbase/storage/s3-driver.d.ts.map +1 -0
  102. package/dist/vendor/tinbase/types.d.ts +171 -0
  103. package/dist/vendor/tinbase/types.d.ts.map +1 -0
  104. package/dist/vendor/tinbase/webhooks/service.d.ts +71 -0
  105. package/dist/vendor/tinbase/webhooks/service.d.ts.map +1 -0
  106. package/dist/version.d.ts +2 -0
  107. package/dist/version.d.ts.map +1 -0
  108. package/package.json +64 -0
@@ -0,0 +1,82 @@
1
+ import { InboxMailer } from './auth/inbox.js';
2
+ import { LogBuffer } from './log-buffer.js';
3
+ import { FunctionsHandler } from './functions/handler.js';
4
+ import { Database } from './db/database.js';
5
+ import { RealtimeEngine } from './realtime/engine.js';
6
+ import { WebhooksService } from './webhooks/service.js';
7
+ import { CronService } from './cron/service.js';
8
+ import { NetService } from './net/service.js';
9
+ import { RetentionService } from './retention/service.js';
10
+ import type { BackendConfig, MigrationFile } from './types.js';
11
+ export * from './types.js';
12
+ export { Database } from './db/database.js';
13
+ export { createPgliteEngine } from './db/pglite-engine.js';
14
+ export { MemoryStorageDriver } from './storage/driver.js';
15
+ export { InboxMailer, type InboxEntry } from './auth/inbox.js';
16
+ export { LogBuffer, type LogEntry, type LogLevel } from './log-buffer.js';
17
+ export { RealtimeEngine, type RealtimeSocketLike } from './realtime/engine.js';
18
+ export { signJwt, verifyJwt, decodeJwt } from './jwt.js';
19
+ export { FunctionsHandler, type EdgeFunction, type FunctionContext } from './functions/handler.js';
20
+ export { generateTypes } from './gen-types.js';
21
+ export { installDenoShim } from './functions/deno-shim.js';
22
+ export { WebhooksService, type WebhookConfig, type WebhookDelivery } from './webhooks/service.js';
23
+ export { CronService, cronMatches } from './cron/service.js';
24
+ export { NetService, type NetDelivery } from './net/service.js';
25
+ export { RetentionService, type RetentionConfig } from './retention/service.js';
26
+ export { snapshotSchema, diffSchemas, type SchemaSnapshot } from './db/schema-diff.js';
27
+ export { inspectDb, type TableInfo } from './db/inspect.js';
28
+ /**
29
+ * A running tinbase backend. The one field a consumer always needs is
30
+ * {@link TinbaseBackend.fetch}; the rest expose the underlying services for
31
+ * advanced/embedded use (in-process realtime, manual migrations, log access).
32
+ * Returned by {@link createBackend}.
33
+ */
34
+ export interface TinbaseBackend {
35
+ /** The whole backend as a fetch handler. Pass to supabase-js as global.fetch for in-process use. */
36
+ fetch: typeof fetch;
37
+ /** The database engine wrapper - run raw SQL, inspect schema, apply migrations. */
38
+ db: Database;
39
+ /** Realtime (Postgres CDC → WebSocket) engine backing supabase.channel(). */
40
+ realtime: RealtimeEngine;
41
+ /** Edge-function registry/dispatcher backing supabase.functions.invoke(). */
42
+ functions: FunctionsHandler;
43
+ /** Database-webhook service (HTTP requests fired on row changes). */
44
+ webhooks: WebhooksService;
45
+ /** pg_cron emulation scheduler. */
46
+ cron: CronService;
47
+ /** pg_net emulation sender (net.http_* queue drain). */
48
+ net: NetService;
49
+ /** Background sweeper that purges expired tokens and aged-out audit rows. */
50
+ retention: RetentionService;
51
+ /** JWT for the anon role - use as supabase-js's supabaseKey. */
52
+ anonKey: string;
53
+ /** JWT for the service_role - bypasses RLS. */
54
+ serviceRoleKey: string;
55
+ /** Secret used to sign/verify every JWT (the resolved value, incl. the default). */
56
+ jwtSecret: string;
57
+ /** Recent server logs (also surfaced in the Studio Logs pane). */
58
+ logs: LogBuffer;
59
+ /** Captured dev email inbox mounted only on loopback, or null when disabled or replaced. */
60
+ inbox: InboxMailer | null;
61
+ /** Apply additional migrations at runtime. */
62
+ migrate: (migrations: MigrationFile[], seedSql?: string) => Promise<string[]>;
63
+ /** Tear down every background service and close the database. Idempotent-safe to await once. */
64
+ close: () => Promise<void>;
65
+ }
66
+ /**
67
+ * Build a running tinbase backend from {@link BackendConfig}. Wires the
68
+ * database, auth, storage, realtime, edge functions, and the background
69
+ * services (webhooks/cron/net/retention), mints the anon/service_role keys, and
70
+ * returns a {@link TinbaseBackend} whose `fetch` handles every Supabase wire
71
+ * route.
72
+ *
73
+ * All config is optional: with an empty config it boots an in-memory PGlite
74
+ * backend on the Supabase local-dev defaults. If any startup step throws (e.g. a
75
+ * failing migration), every handle opened so far is torn down before the error
76
+ * propagates, so a failed construction never leaks the engine or a timer.
77
+ *
78
+ * @throws Error from {@link assertSecretsSafe} when bound to a network-exposed
79
+ * host with a weak/default JWT secret or a derived vault key.
80
+ */
81
+ export declare function createBackend(config?: BackendConfig): Promise<TinbaseBackend>;
82
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vendor/tinbase/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Minimal HS256 JWT implementation on WebCrypto.
3
+ * Works in Node (>=18) and browsers - no dependencies.
4
+ */
5
+ /** Standard + Supabase/GoTrue claims carried in an access token. Open-ended: any extra claims are preserved. */
6
+ export interface JwtClaims {
7
+ [key: string]: unknown;
8
+ sub?: string;
9
+ role?: string;
10
+ exp?: number;
11
+ iat?: number;
12
+ iss?: string;
13
+ aud?: string;
14
+ email?: string;
15
+ /** authenticator assurance level: 'aal1' (single-factor) or 'aal2' (MFA-verified) */
16
+ aal?: string;
17
+ /** authentication methods references, e.g. [{ method: 'password' | 'totp', timestamp }] */
18
+ amr?: {
19
+ method: string;
20
+ timestamp: number;
21
+ }[];
22
+ }
23
+ /** Sign claims as an HS256 JWT. */
24
+ export declare function signJwt(claims: JwtClaims, secret: string): Promise<string>;
25
+ /** Verifies signature and expiry. Returns claims, or null when invalid. */
26
+ export declare function verifyJwt(token: string, secret: string): Promise<JwtClaims | null>;
27
+ /** Decode without verification (for introspection/debugging only). */
28
+ export declare function decodeJwt(token: string): JwtClaims | null;
29
+ /** A URL-safe random token (base64url of `bytes` CSPRNG bytes). Used for refresh/one-time/link tokens. */
30
+ export declare function randomToken(bytes?: number): string;
31
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../src/vendor/tinbase/jwt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiCH,gHAAgH;AAChH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2FAA2F;IAC3F,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC9C;AAED,mCAAmC;AACnC,wBAAsB,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhF;AAED,2EAA2E;AAC3E,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAuBxF;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQzD;AAED,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,KAAK,SAAK,GAAG,MAAM,CAI9C"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * In-memory ring buffer of recent server log lines, surfaced in the Studio
3
+ * "Logs" pane (and available as backend.logs). Captures request lines and the
4
+ * internal log() output (migrations, mail, webhooks, cron). Dev convenience -
5
+ * bounded, never persisted.
6
+ */
7
+ /** Severity derived from response status (or passed explicitly by internal log calls). */
8
+ export type LogLevel = 'info' | 'warn' | 'error';
9
+ /** One buffered log line. */
10
+ export interface LogEntry {
11
+ /** ISO timestamp when pushed. */
12
+ ts: string;
13
+ level: LogLevel;
14
+ msg: string;
15
+ }
16
+ /** Bounded FIFO of the most recent {@link LogEntry} lines; oldest are dropped past `cap`. */
17
+ export declare class LogBuffer {
18
+ private cap;
19
+ private entries;
20
+ constructor(cap?: number);
21
+ /** Append a line, evicting the oldest once over capacity. */
22
+ push(msg: string, level?: LogLevel): void;
23
+ /** Most recent first. */
24
+ list(limit?: number): LogEntry[];
25
+ /** Drop all buffered lines. */
26
+ clear(): void;
27
+ }
28
+ //# sourceMappingURL=log-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-buffer.d.ts","sourceRoot":"","sources":["../../../src/vendor/tinbase/log-buffer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEhD,6BAA6B;AAC7B,MAAM,WAAW,QAAQ;IACvB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,QAAQ,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,6FAA6F;AAC7F,qBAAa,SAAS;IAER,OAAO,CAAC,GAAG;IADvB,OAAO,CAAC,OAAO,CAAiB;gBACZ,GAAG,SAAM;IAE7B,6DAA6D;IAC7D,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,QAAiB,GAAG,IAAI;IAKjD,yBAAyB;IACzB,IAAI,CAAC,KAAK,SAAM,GAAG,QAAQ,EAAE;IAI7B,+BAA+B;IAC/B,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * In-process HTTP sender for the pg_net emulation - the execution half of the
3
+ * net.* surface (the net.http_get/post/delete SQL functions live in
4
+ * db/emulated.ts). It drains net.http_request_queue, performs each request with
5
+ * fetch, and records the reply in net._http_response, mirroring pg_net's
6
+ * background worker. No C extension, works on the wasm and native engines.
7
+ */
8
+ import type { Database } from '../db/database.js';
9
+ /**
10
+ * Reject requests to non-public destinations. A synchronous literal-host guard
11
+ * (loopback / private / link-local / cloud-metadata) that also rejects
12
+ * alternate numeric IP encodings which would slip past the literal checks but
13
+ * still connect to a real address. No DNS lookup - a public hostname that
14
+ * *resolves* to private space (DNS rebinding) is a residual this doesn't cover;
15
+ * doing so would add a per-request lookup that can hang for 30s on an
16
+ * unresolvable host. Returns an error string, or null when the URL is allowed.
17
+ */
18
+ export declare function blockedNetTarget(rawUrl: string): string | null;
19
+ /**
20
+ * fetch with an SSRF guard that re-validates every redirect hop. Default fetch
21
+ * follows redirects without re-checking, so a public URL could 3xx into private
22
+ * space; this follows manually (capped at {@link MAX_REDIRECTS}) and runs
23
+ * {@link blockedNetTarget} on each target. Throws with the block reason on a
24
+ * rejected hop.
25
+ */
26
+ export declare function guardedFetch(fetchImpl: typeof fetch, url: string, init?: RequestInit): Promise<Response>;
27
+ /** Outcome of one drained request, passed to the optional `onDeliver` callback. */
28
+ export interface NetDelivery {
29
+ /** net.http_request_queue row id */
30
+ id: number;
31
+ method: string;
32
+ url: string;
33
+ /** response status; undefined when the request failed before a reply */
34
+ status?: number;
35
+ /** true if the request aborted on its timeout */
36
+ timedOut: boolean;
37
+ /** failure reason (network error, blocked target, etc.); undefined on success */
38
+ error?: string;
39
+ }
40
+ /**
41
+ * Drains net.http_request_queue on an interval, performs each request, and
42
+ * records the reply in net._http_response - the pg_net background worker,
43
+ * in-process.
44
+ */
45
+ export declare class NetService {
46
+ private db;
47
+ private fetchImpl;
48
+ /** how often to drain the queue (ms) */
49
+ private tickMs;
50
+ private onDeliver?;
51
+ private timer;
52
+ private draining;
53
+ /** The in-flight tick, tracked so stop() can drain it before db.close(). */
54
+ private inFlight;
55
+ constructor(db: Database, fetchImpl?: typeof fetch,
56
+ /** how often to drain the queue (ms) */
57
+ tickMs?: number, onDeliver?: ((d: NetDelivery) => void) | undefined);
58
+ /** Begin draining the queue on the tick interval; no-op if already running. */
59
+ start(): void;
60
+ /**
61
+ * Stop the drain loop and wait for any in-flight tick to finish before the
62
+ * caller closes the database - the single connection busy-loops if closed
63
+ * while a query is still queued.
64
+ */
65
+ stop(): Promise<void>;
66
+ /** Drain any queued requests once (also callable directly in tests). */
67
+ tick(): Promise<void>;
68
+ private deliver;
69
+ /** Record the response and remove the request from the queue (best-effort). */
70
+ private record;
71
+ }
72
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/net/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAQjD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmB9D;AAqBD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWlH;AAWD,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAA;IACjB,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,qBAAa,UAAU;IAOnB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,SAAS;IACjB,wCAAwC;IACxC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS,CAAC;IAVpB,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,QAAQ,CAAQ;IACxB,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAA6B;gBAGnC,EAAE,EAAE,QAAQ,EACZ,SAAS,GAAE,OAAO,KAAa;IACvC,wCAAwC;IAChC,MAAM,SAAM,EACZ,SAAS,CAAC,GAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,aAAA;IAG9C,+EAA+E;IAC/E,KAAK,IAAI,IAAI;IAQb;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,wEAAwE;IAClE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YA8Bb,OAAO;IA6CrB,+EAA+E;YACjE,MAAM;CAoBrB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Bun-native server: Bun.serve with first-class WebSockets. Used automatically
3
+ * when the CLI runs under Bun (including single-binary builds) - same backend,
4
+ * same RealtimeSocketLike contract as the node:http path.
5
+ */
6
+ import type { SupaliteBackendShape } from './server-shared.js';
7
+ export interface ServeOptions {
8
+ port?: number;
9
+ host?: string;
10
+ }
11
+ export interface ServerHandle {
12
+ readonly port?: number;
13
+ stop(closeActiveConnections?: boolean): void | Promise<void>;
14
+ }
15
+ export interface RunningServer {
16
+ server: ServerHandle;
17
+ port: number;
18
+ url: string;
19
+ close: () => Promise<void>;
20
+ }
21
+ /** Bun equivalent of {@link import('./server.js').serve}; same backend contract. */
22
+ export declare function serveBun(backend: SupaliteBackendShape, opts?: ServeOptions): Promise<RunningServer>;
23
+ //# sourceMappingURL=bun-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun-server.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/bun-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7D;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AASD,oFAAoF;AACpF,wBAAsB,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmD7G"}
@@ -0,0 +1,8 @@
1
+ /** Map a Deno-style specifier to a fetchable URL. Pure - unit tested. */
2
+ export declare function rewriteRemoteSpecifier(spec: string): string;
3
+ /**
4
+ * Bundle `entryPath` to a single ESM file and return its path (written under
5
+ * the OS temp dir).
6
+ */
7
+ export declare function bundleFunction(entryPath: string, name: string): Promise<string>;
8
+ //# sourceMappingURL=bundle-function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-function.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/bundle-function.ts"],"names":[],"mappings":"AAgBA,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI3D;AAsCD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAerF"}
@@ -0,0 +1,34 @@
1
+ /** A parsed table: its scalar/array values plus nested child tables. */
2
+ export interface ConfigTable {
3
+ /** scalar and single-line-array values declared directly under this table, by key */
4
+ values: Map<string, string | string[]>;
5
+ /** nested child tables, by their (single, undotted) segment name */
6
+ children: Map<string, ConfigTable>;
7
+ }
8
+ /** Environment values accepted by config.toml's env(VAR) substitution. */
9
+ export type Environment = Record<string, string | undefined>;
10
+ /** Parse config.toml at `projectDir/supabase/config.toml`; empty root if absent/unreadable. */
11
+ export declare function loadConfigToml(projectDir: string, env?: Environment): ConfigTable;
12
+ /** Parse TOML `text` into a table tree, resolving `env(VAR)` references. */
13
+ export declare function parseConfigToml(text: string, env?: Environment): ConfigTable;
14
+ /** Child table at a dotted path, or undefined if any segment is missing. */
15
+ export declare function tableAt(root: ConfigTable, path: string): ConfigTable | undefined;
16
+ /** String value at `key`, or undefined if absent, empty, or an array. */
17
+ export declare function getString(table: ConfigTable | undefined, key: string): string | undefined;
18
+ /** Boolean value at `key`, or undefined if absent or not exactly true/false. */
19
+ export declare function getBool(table: ConfigTable | undefined, key: string): boolean | undefined;
20
+ /** Integer value at `key` (base 10), or undefined if absent or unparseable. */
21
+ export declare function getInt(table: ConfigTable | undefined, key: string): number | undefined;
22
+ /** String-array value at `key`, or undefined if absent or a scalar. */
23
+ export declare function getStringArray(table: ConfigTable | undefined, key: string): string[] | undefined;
24
+ /**
25
+ * Parse a Supabase duration string ("1m", "24h", "10s", "50m") to seconds.
26
+ * Returns undefined if absent or malformed.
27
+ */
28
+ export declare function getDurationSeconds(table: ConfigTable | undefined, key: string): number | undefined;
29
+ /**
30
+ * Parse a Supabase byte-size string ("50MiB", "5MB", "500KB") to bytes.
31
+ * Returns undefined if absent or malformed.
32
+ */
33
+ export declare function getByteSize(table: ConfigTable | undefined, key: string): number | undefined;
34
+ //# sourceMappingURL=config-toml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-toml.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/config-toml.ts"],"names":[],"mappings":"AAmBA,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IACtC,oEAAoE;IACpE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACnC;AAED,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAM5D,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,WAAyB,GAAG,WAAW,CAQ9F;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,WAAyB,GAAG,WAAW,CAiBzF;AAuDD,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAOhF;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzF;AAED,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAKxF;AAED,+EAA+E;AAC/E,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKtF;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAGhG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWlG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiB3F"}
@@ -0,0 +1,27 @@
1
+ import type { StorageDriver } from '../types.js';
2
+ /**
3
+ * Node-only {@link StorageDriver} that keeps object bytes as files under a
4
+ * single root directory. Keys map to relative paths beneath the root.
5
+ */
6
+ export declare class FsStorageDriver implements StorageDriver {
7
+ private root;
8
+ constructor(root: string);
9
+ /**
10
+ * Resolve a storage key to an absolute path inside the root.
11
+ *
12
+ * SECURITY: rejects keys that escape the root (e.g. `../`); the normalized
13
+ * path must stay under `root` + separator or the key is refused.
14
+ *
15
+ * @throws if the key would resolve outside the root directory.
16
+ */
17
+ private resolve;
18
+ /** Write object bytes, creating parent directories as needed. */
19
+ put(key: string, data: Uint8Array): Promise<void>;
20
+ /** Read object bytes, or null if the key does not exist. */
21
+ get(key: string): Promise<Uint8Array | null>;
22
+ /** Delete an object; a missing key is not an error. */
23
+ delete(key: string): Promise<void>;
24
+ /** Delete several objects in sequence. */
25
+ deleteMany(keys: string[]): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=fs-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-driver.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/fs-driver.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;GAGG;AACH,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IAEhC;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;IAQf,iEAAiE;IAC3D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAavD,4DAA4D;IACtD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IASlD,uDAAuD;IACjD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,0CAA0C;IACpC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhD"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Read everything tinbase can honor from an existing Supabase project's
3
+ * supabase/config.toml, so pointing tinbase at that project needs no new config.
4
+ *
5
+ * config.toml is one document, so this is one loader: parse once, then project
6
+ * the tree into a nested `ProjectConfig` that mirrors the file's sections. The
7
+ * CLI spreads those sections into createBackend. Sections for services tinbase
8
+ * doesn't run (SMS, analytics, pooler, studio/edge-runtime ports, experimental)
9
+ * are intentionally ignored.
10
+ */
11
+ import type { AuthSettings } from '../auth/settings.js';
12
+ import type { OAuthProviderConfig } from '../auth/oauth.js';
13
+ import type { RateLimitRule } from '../auth/rate-limit.js';
14
+ import type { BucketSeed } from '../types.js';
15
+ import { type Environment } from './config-toml.js';
16
+ /** The project's config.toml, projected into the shapes tinbase consumes. */
17
+ export interface ProjectConfig {
18
+ /** the [auth] slice: settings, redirects, sessions, rate limits, OAuth */
19
+ auth: AuthConfig;
20
+ /** the [api] slice: exposed schemas and row cap */
21
+ api: ApiConfig;
22
+ /** the [storage] slice: default size limit and buckets to seed */
23
+ storage: StorageConfig;
24
+ /** the [db.seed] slice: whether/what to seed */
25
+ seed: SeedConfig;
26
+ /** per-function options keyed by function name ([functions.<name>]) */
27
+ functions: Record<string, FunctionOptions>;
28
+ }
29
+ /** The `[auth]` slice of config.toml, projected into the shapes the backend consumes. */
30
+ export interface AuthConfig {
31
+ /** whether to run the auth service ([auth].enabled) */
32
+ enabled?: boolean;
33
+ /** runtime-toggleable settings, layered under the live auth.config table */
34
+ settings: Partial<AuthSettings>;
35
+ /** [auth].site_url */
36
+ siteUrl?: string;
37
+ /** [auth].jwt_expiry, seconds */
38
+ jwtExpiry?: number;
39
+ /** [auth].additional_redirect_urls */
40
+ uriAllowList?: string[];
41
+ /** [auth.rate_limit].* mapped to the auth limiter's rules */
42
+ rateLimits?: Record<string, RateLimitRule>;
43
+ /** [auth.sessions].timebox, seconds */
44
+ sessionTimeboxSeconds?: number;
45
+ /** [auth.sessions].inactivity_timeout, seconds */
46
+ sessionInactivitySeconds?: number;
47
+ /** OAuth providers from [auth.external.*] and env-var fallbacks */
48
+ oauthProviders: Record<string, OAuthProviderConfig>;
49
+ }
50
+ /** The `[api]` slice of config.toml. */
51
+ export interface ApiConfig {
52
+ /** [api].schemas: schemas exposed through the Data API (db-schemas) */
53
+ schemas?: string[];
54
+ /** [api].max_rows: REST read row cap */
55
+ maxRows?: number;
56
+ }
57
+ /** The `[storage]` slice of config.toml. */
58
+ export interface StorageConfig {
59
+ /** [storage].file_size_limit: default per-bucket byte limit */
60
+ fileSizeLimit?: number;
61
+ /** [storage.buckets.*]: buckets to create at boot */
62
+ buckets?: BucketSeed[];
63
+ }
64
+ /** The `[db.seed]` slice of config.toml. */
65
+ export interface SeedConfig {
66
+ /** [db.seed].enabled */
67
+ enabled?: boolean;
68
+ /** [db.seed].sql_paths (files or globs, relative to supabase/) */
69
+ paths?: string[];
70
+ }
71
+ /** Per-function `[functions.<name>]` options. */
72
+ export interface FunctionOptions {
73
+ /** [functions.<name>].enabled */
74
+ enabled?: boolean;
75
+ /** [functions.<name>].verify_jwt */
76
+ verifyJwt?: boolean;
77
+ /** [functions.<name>].entrypoint, relative to the project root */
78
+ entrypoint?: string;
79
+ }
80
+ /** Parse supabase/config.toml once and project it into a {@link ProjectConfig}. */
81
+ export declare function loadProjectConfig(projectDir: string, env?: Environment): ProjectConfig;
82
+ //# sourceMappingURL=load-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/load-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA;AAEzB,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,IAAI,EAAE,UAAU,CAAA;IAChB,mDAAmD;IACnD,GAAG,EAAE,SAAS,CAAA;IACd,kEAAkE;IAClE,OAAO,EAAE,aAAa,CAAA;IACtB,gDAAgD;IAChD,IAAI,EAAE,UAAU,CAAA;IAChB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC3C;AAED,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAC/B,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C,uCAAuC;IACvC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,kDAAkD;IAClD,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;CACpD;AAED,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;CACvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oCAAoC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,WAAyB,GAAG,aAAa,CASnG"}
@@ -0,0 +1,24 @@
1
+ import type { EdgeFunction } from '../functions/handler.js';
2
+ /**
3
+ * Load edge-function secrets from supabase/functions/.env (KEY=VALUE lines,
4
+ * `#` comments). These are exposed to functions via Deno.env and ctx.env -
5
+ * the local equivalent of `supabase functions serve --env-file`.
6
+ */
7
+ export declare function loadFunctionEnv(projectDir: string): Promise<Record<string, string>>;
8
+ /** Per-function options from config.toml [functions.<name>]. */
9
+ export interface LoadFunctionOptions {
10
+ /** Skip loading when explicitly disabled. */
11
+ enabled?: boolean;
12
+ /** Custom entrypoint path, relative to the project root. */
13
+ entrypoint?: string;
14
+ }
15
+ /**
16
+ * Discover and load every edge function under supabase/functions/, keyed by
17
+ * directory name. Dirs starting with `_` or `.` are skipped (shared code), as
18
+ * are functions disabled in config.toml. Each function is bundled with esbuild
19
+ * when available (falling back to a plain import), then its handler is taken
20
+ * from a default export or a captured `Deno.serve()` call. Load failures warn
21
+ * and skip rather than throwing, so one broken function can't block startup.
22
+ */
23
+ export declare function loadFunctions(projectDir: string, options?: Record<string, LoadFunctionOptions>): Promise<Map<string, EdgeFunction>>;
24
+ //# sourceMappingURL=load-functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-functions.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/load-functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAI3D;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAqBzF;AAED,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAID;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAM,GAChD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAYpC"}
@@ -0,0 +1,21 @@
1
+ import type { MigrationFile } from '../types.js';
2
+ /** Migrations and optional seed SQL discovered under a project's supabase/ dir. */
3
+ export interface SupabaseProject {
4
+ /** Migrations in filename order (timestamp-prefixed, so lexical == chronological). */
5
+ migrations: MigrationFile[];
6
+ /** Concatenated seed files, if any were found and seeding is enabled. */
7
+ seedSql?: string;
8
+ }
9
+ /** Seed config from config.toml [db.seed] (enabled + explicit file paths). */
10
+ export interface SeedOptions {
11
+ /** whether seeding runs; only `false` disables it (undefined means enabled) */
12
+ enabled?: boolean;
13
+ /** Files or Bun glob patterns relative to supabase/, applied in order. Defaults to ['seed.sql']. */
14
+ paths?: string[];
15
+ }
16
+ /**
17
+ * Read supabase/migrations/*.sql (sorted) and, unless disabled, the configured
18
+ * seed files. A missing migrations dir or seed file is not an error.
19
+ */
20
+ export declare function loadSupabaseProject(projectDir: string, seed?: SeedOptions): Promise<SupabaseProject>;
21
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oGAAoG;IACpG,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAqC9G"}
@@ -0,0 +1,10 @@
1
+ /** Backend shape shared by the node:http and Bun servers, keeping each decoupled from the full backend. */
2
+ import type { RealtimeEngine } from '../realtime/engine.js';
3
+ /** The slice of a backend that servers need - keeps bun/node servers decoupled. */
4
+ export interface SupaliteBackendShape {
5
+ /** HTTP request handler; the server forwards every non-upgrade request here */
6
+ fetch: typeof fetch;
7
+ /** realtime engine the server hands accepted websocket connections to */
8
+ realtime: RealtimeEngine;
9
+ }
10
+ //# sourceMappingURL=server-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-shared.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/node/server-shared.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,KAAK,EAAE,OAAO,KAAK,CAAA;IACnB,yEAAyE;IACzE,QAAQ,EAAE,cAAc,CAAA;CACzB"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Realtime engine speaking the Phoenix-channel protocol that
3
+ * @supabase/realtime-js uses (vsn=1.0.0 JSON serialization): channel
4
+ * join/leave, heartbeat, broadcast, presence, and postgres_changes fed by
5
+ * the trigger-based CDC pipeline in the database layer.
6
+ *
7
+ * Transport-agnostic: sockets are anything with send()/close(), so the same
8
+ * engine works over Node WebSockets today and an in-process pair in the
9
+ * browser.
10
+ */
11
+ import type { Database } from '../db/database.js';
12
+ /** The minimal socket surface the engine needs; any transport can supply it. */
13
+ export interface RealtimeSocketLike {
14
+ /** send a text or binary frame to the client */
15
+ send(data: string | Uint8Array): void;
16
+ /** close the connection with an optional WebSocket close code/reason */
17
+ close(code?: number, reason?: string): void;
18
+ }
19
+ /** Holds all live connections and fans database changes and broadcasts out to them. */
20
+ export declare class RealtimeEngine {
21
+ private db;
22
+ private jwtSecret?;
23
+ private connections;
24
+ private bindingCounter;
25
+ private phxRefCounter;
26
+ /** topic → key → metas */
27
+ private presence;
28
+ private stopCdc;
29
+ private stopDbBroadcast;
30
+ constructor(db: Database, jwtSecret?: string | undefined);
31
+ /** Resolve a subscriber's access token to a role/claims context. */
32
+ private contextFromToken;
33
+ /**
34
+ * Authorize a private channel against RLS on realtime.messages, as the
35
+ * subscriber. read = a SELECT policy lets them receive; write = an INSERT
36
+ * policy lets them broadcast. Runs in a transaction that always rolls back so
37
+ * the probe rows never persist.
38
+ */
39
+ private authorizePrivate;
40
+ /** Fan a realtime.send() database broadcast out to a topic's subscribers. */
41
+ private dispatchDbBroadcast;
42
+ /** Wire up the CDC and database-broadcast listeners; idempotent once started. */
43
+ start(): Promise<void>;
44
+ /** Detach listeners and close every open socket (server shutdown). */
45
+ stop(): void;
46
+ /** Attach a socket. Returns callbacks the transport must wire up. */
47
+ connect(socket: RealtimeSocketLike, opts?: {
48
+ vsn?: string;
49
+ }): {
50
+ onMessage: (data: string | Uint8Array) => void;
51
+ onClose: () => void;
52
+ };
53
+ private send;
54
+ private reply;
55
+ private handleMessage;
56
+ private handleJoin;
57
+ private leaveChannel;
58
+ /**
59
+ * Phoenix binary serializer, kind 3 (userBroadcastPush):
60
+ * [3, joinRefLen, refLen, topicLen, eventLen, metaLen, encoding,
61
+ * joinRef, ref, topic, event, meta, payloadBytes]
62
+ * encoding: 0 = raw binary payload, 1 = JSON payload
63
+ */
64
+ private handleBinary;
65
+ private handleBroadcast;
66
+ private handlePresence;
67
+ private broadcastToTopic;
68
+ private dispatchCdc;
69
+ /**
70
+ * Whether a subscriber may receive a given change event under RLS.
71
+ * - service_role (bypassrls) and non-RLS tables: always.
72
+ * - INSERT/UPDATE on an RLS table: re-query the row by PK as the subscriber;
73
+ * deliver only if the currently visible row still matches the event snapshot.
74
+ * - DELETE on an RLS table: only service_role receives it because the deleted
75
+ * row can no longer be re-queried safely as an ordinary subscriber.
76
+ */
77
+ private canSee;
78
+ private bindingMatches;
79
+ }
80
+ /** Evaluate a realtime filter string ("col=eq.value") against a row. */
81
+ export declare function matchFilter(filter: string, row: Record<string, unknown>): boolean;
82
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../../src/vendor/tinbase/realtime/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAK3D,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAA;IACrC,wEAAwE;IACxE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5C;AA+DD,uFAAuF;AACvF,qBAAa,cAAc;IAUvB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,SAAS,CAAC;IAVpB,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,aAAa,CAAI;IACzB,0BAA0B;IAC1B,OAAO,CAAC,QAAQ,CAAgD;IAChE,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,eAAe,CAA4B;gBAGzC,EAAE,EAAE,QAAQ,EACZ,SAAS,CAAC,EAAE,MAAM,YAAA;IAG5B,oEAAoE;YACtD,gBAAgB;IAQ9B;;;;;OAKG;YACW,gBAAgB;IA0C9B,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB;IAc3B,iFAAiF;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5B,sEAAsE;IACtE,IAAI,IAAI,IAAI;IASZ,qEAAqE;IACrE,OAAO,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG;QAChE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,KAAK,IAAI,CAAA;QAC9C,OAAO,EAAE,MAAM,IAAI,CAAA;KACpB;IAcD,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,KAAK;YAUC,aAAa;YAgEb,UAAU;IAsGxB,OAAO,CAAC,YAAY;IAmBpB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,eAAe;IA8BvB,OAAO,CAAC,cAAc;IA+CtB,OAAO,CAAC,gBAAgB;YAQV,WAAW;IAoDzB;;;;;;;OAOG;YACW,MAAM;IA6BpB,OAAO,CAAC,cAAc;CAUvB;AAkBD,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CA2BjF"}