@protobase/server 0.31.0 → 0.31.1

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.
@@ -1,10 +1,10 @@
1
1
  import { AuditQueue, PipelineHook, ScanGuardMode } from "./types.js";
2
+ import { ApiKeysOptions } from "./api-keys/api-key-settings.js";
2
3
  import { ErrorReportingOptions } from "./error-reporting/error-reporting-settings.js";
3
4
  import { MapOptions } from "./maps/map-settings.js";
4
5
  import { PluginOption } from "./plugins/plugin-settings.js";
5
6
  import { SourceOption } from "./sources/source-settings.js";
6
7
  import { CorsOrigins } from "./api-cors.js";
7
- import { ApiKeysOptions } from "./api-keys/api-key-settings.js";
8
8
  import { AssistantOptions } from "./assistant/assistant-settings.js";
9
9
  import { LocaleOption } from "./locale/locale-option.js";
10
10
  import { RuntimeOptions } from "./runtime/runtime-settings.js";
@@ -19,7 +19,7 @@ import { realtimeApp } from "./realtime/realtime-app.js";
19
19
  import { restRoutes } from "./rest/rest-routes.js";
20
20
  import { storageRoutes } from "./storage/storage-routes.js";
21
21
  import { readAppName } from "./app-name.js";
22
- import { realtimePath, restPath, storagePath, supabasePath } from "./supabase-paths.js";
22
+ import { realtimePath, restPath, storagePath, supabaseFunctionsPath, supabasePath } from "./supabase-paths.js";
23
23
  import { goTruePath } from "./gotrue/keys.js";
24
24
  import { authBasePath } from "./better-auth/auth-base-path.js";
25
25
  import { organizationRoutes } from "./better-auth/organizations/admin-routes.js";
@@ -56,6 +56,7 @@ import { fileRoutes } from "./files/routes.js";
56
56
  import { formRoutes } from "./forms/routes.js";
57
57
  import { createFormsRuntime } from "./forms/runtime.js";
58
58
  import { functionRoutes } from "./functions/routes.js";
59
+ import { supabaseFunctionRoutes } from "./functions/supabase-routes.js";
59
60
  import { localeSetting } from "./locale/locale-option.js";
60
61
  import { mapSettings } from "./maps/map-settings.js";
61
62
  import { pluginOptions, pluginsBeforeSignIn } from "./plugins/plugin-settings.js";
@@ -230,7 +231,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
230
231
  const corsOrigins = withMobileOrigins(options.cors ?? readCorsOrigins(globalThis.process?.env ?? {}), Boolean(mobile));
231
232
  const ownOrigins = auth?.origins ?? [];
232
233
  if (corsOrigins !== void 0 || ownOrigins.length > 1) {
233
- const answering = [authBasePath, ...Object.entries(apiFunctions).filter(([, fn]) => fn.options.cors).map(([name]) => `${systemPath}/functions/${name}`)];
234
+ const answering = [authBasePath, ...Object.entries(apiFunctions).filter(([, fn]) => fn.options.cors).flatMap(([name]) => [`${systemPath}/functions/${name}`, `${supabaseFunctionsPath}/${name}`])];
234
235
  const skip = (path) => answering.some((prefix) => path === prefix || path.startsWith(`${prefix}/`));
235
236
  const cors = apiCors({
236
237
  own: ownOrigins,
@@ -280,6 +281,17 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
280
281
  onError,
281
282
  wake: () => wakeDispatch(deps)
282
283
  }));
284
+ const verifyGoTrue = auth ? jwtVerifier(goTrueTokens({ auth })) : () => Promise.reject(unauthorized("This app signs no user tokens"));
285
+ app.route("/", supabaseFunctionRoutes({
286
+ functions: apiFunctions,
287
+ db,
288
+ keys: apiKeys,
289
+ caller: apiKeyCaller({
290
+ keys: apiKeys,
291
+ verify: verifyGoTrue
292
+ }),
293
+ onError
294
+ }));
283
295
  app.route("/", batchRoute(deps, authenticate, meta));
284
296
  app.route("/", fileRoutes(deps, authenticate));
285
297
  if (forms) app.route(`${systemPath}/forms`, formRoutes(deps, forms));
@@ -1,4 +1,5 @@
1
1
  import { Session } from "../types.js";
2
+ import { Caller } from "../api-keys/resolve-caller.js";
2
3
  import { FunctionRecords } from "./records.js";
3
4
  import { Capability } from "@protobase/schema";
4
5
  import { Db } from "@protobase/query";
@@ -20,6 +21,13 @@ export type FunctionCaller = {
20
21
  };
21
22
  /** What a function that needs a signed-in caller gets: the caller resolved before it runs. */
22
23
  export type FunctionContext = PublicFunctionContext & FunctionCaller;
24
+ /** What a function gets at `/api/sb/functions/v1/<name>`, where supabase-js calls it: the caller its keys and token make. */
25
+ export type KeyFunctionContext = {
26
+ name: string;
27
+ db: Db;
28
+ /** The caller of the `apikey` header and bearer token: rejects with a 401 problem when they admit nobody. */
29
+ caller: () => Promise<Caller>;
30
+ };
23
31
  /** A Web-standard handler. Its request's path is the part after `/api/functions/<name>`: `/` or `/more/parts`. */
24
32
  export type FunctionHandler = (request: Request, context: FunctionContext) => Response | Promise<Response>;
25
33
  export type PublicFunctionHandler = (request: Request, context: PublicFunctionContext) => Response | Promise<Response>;
@@ -59,4 +59,4 @@ const functionRoutes = ({ basePath, functions, authenticate, access, db, records
59
59
  return app;
60
60
  };
61
61
  //#endregion
62
- export { functionRoutes };
62
+ export { functionRoutes, relativeRequest };
@@ -0,0 +1,49 @@
1
+ import { notFound, unauthorized } from "../problem.js";
2
+ import { supabaseFunctionsPath } from "../supabase-paths.js";
3
+ import { invokeFunction } from "./define-function.js";
4
+ import { runInBackground } from "../background-work.js";
5
+ import { relativeRequest } from "./routes.js";
6
+ import { Hono } from "hono";
7
+ import { cors } from "hono/cors";
8
+ //#region src/functions/supabase-routes.ts
9
+ /**
10
+ * The app's functions again at `/api/sb/functions/v1/<name>`, as Supabase serves Edge Functions. A protected function lets in
11
+ * a request its app's keys admit, as Supabase's `verify_jwt` does, and a public one anyone. Either gets the key-made
12
+ * caller, not the app's session, so a function with `roles` is served at `/api/functions/<name>` only. As on Supabase,
13
+ * the function sees the path from its name on, `/<name>/more/parts`, and a CORS preflight, which carries no key,
14
+ * reaches it unchecked.
15
+ */
16
+ const supabaseFunctionRoutes = ({ functions, db, keys, caller, onError }) => {
17
+ const app = new Hono().basePath(supabaseFunctionsPath);
18
+ app.onError(onError);
19
+ const hasKeys = keys.publishable !== void 0 || keys.secret !== void 0;
20
+ for (const [name, fn] of Object.entries(functions)) {
21
+ const { options } = fn;
22
+ if (options.cors) app.use(`/${name}/*`, cors(options.cors));
23
+ app.all(`/${name}/*`, (c) => runInBackground(async () => {
24
+ if (!options.public && options.roles) throw notFound(`The function "${name}" checks roles, so it is served at /api/functions/${name} only`);
25
+ const request = relativeRequest(c.req.raw, supabaseFunctionsPath);
26
+ if (options.public || c.req.method === "OPTIONS") {
27
+ let resolved;
28
+ return invokeFunction(name, fn, request, {
29
+ name,
30
+ db,
31
+ caller: () => resolved ??= caller(c.req.raw)
32
+ });
33
+ }
34
+ if (!hasKeys) throw unauthorized("This app has no keys, so only its public functions answer here");
35
+ const resolved = await caller(c.req.raw);
36
+ return invokeFunction(name, fn, request, {
37
+ name,
38
+ db,
39
+ caller: async () => resolved
40
+ });
41
+ }));
42
+ }
43
+ app.all("/*", (c) => {
44
+ throw notFound(`There is no function at ${c.req.path}`);
45
+ });
46
+ return app;
47
+ };
48
+ //#endregion
49
+ export { supabaseFunctionRoutes };
@@ -0,0 +1,10 @@
1
+ //#region src/functions/wait-until.d.ts
2
+ /**
3
+ * Keeps the process up until `work` settles, as Supabase's `EdgeRuntime.waitUntil`: a function answers at once and
4
+ * goes on working after its response. A graceful shutdown awaits the work (`backgroundSettled`); a process killed
5
+ * before it settles loses it. A rejection is printed, as nobody awaits the work to see it.
6
+ */
7
+ export declare const waitUntil: (work: Promise<unknown>) => void;
8
+ /** Resolves once every `waitUntil` work has settled, including work started while it waits. */
9
+ export declare const backgroundSettled: () => Promise<void>;
10
+ //#endregion
@@ -0,0 +1,18 @@
1
+ //#region src/functions/wait-until.ts
2
+ const pending = /* @__PURE__ */ new Set();
3
+ /**
4
+ * Keeps the process up until `work` settles, as Supabase's `EdgeRuntime.waitUntil`: a function answers at once and
5
+ * goes on working after its response. A graceful shutdown awaits the work (`backgroundSettled`); a process killed
6
+ * before it settles loses it. A rejection is printed, as nobody awaits the work to see it.
7
+ */
8
+ const waitUntil = (work) => {
9
+ const tracked = work.then(() => void 0, (error) => console.error(error));
10
+ pending.add(tracked);
11
+ tracked.then(() => pending.delete(tracked));
12
+ };
13
+ /** Resolves once every `waitUntil` work has settled, including work started while it waits. */
14
+ const backgroundSettled = async () => {
15
+ while (pending.size > 0) await Promise.all(pending);
16
+ };
17
+ //#endregion
18
+ export { backgroundSettled, waitUntil };
@@ -0,0 +1,5 @@
1
+ import "jose";
2
+ //#region src/gotrue/keys.d.ts
3
+ /** Where the GoTrue-compatible endpoints are served, below the app's origin. */
4
+ export declare const goTruePath = "/api/sb/auth/v1";
5
+ //#endregion
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ import { EventData, RunContext, SubscriptionDefinition, SubscriptionEvent, Subsc
22
22
  import { Sharp, renderVariant, thumbHash } from "./files/images.js";
23
23
  import { FileProvider, FileStore, StoredObject } from "./files/store.js";
24
24
  import { FilesOptions } from "./files/options.js";
25
+ import { ApiKeys, ApiKeysOptions, apiKeySettings, apiKeyVariables } from "./api-keys/api-key-settings.js";
26
+ import { Caller, CallerOptions, apiKeyCaller } from "./api-keys/resolve-caller.js";
25
27
  import { ErrorReportingOptions, ErrorReportingSettings, errorReportingSettings, errorReportingVariable } from "./error-reporting/error-reporting-settings.js";
26
28
  import { ChatMessage, ChatTextPart, Completion, CompletionOptions, ModelError, ModelSettings, ReasoningDetail, ReasoningEffort, ToolCall, ToolSpec, streamChatCompletion } from "./assistant/chat-completions.js";
27
29
  import { CleanupEntry, CleanupSchedule, ScheduledDelete, storageCleanupSchedule } from "./files/cleanup-schedule.js";
@@ -33,9 +35,8 @@ import { ResourceSource, configExports } from "./resource-source.js";
33
35
  import { SourceOption, SourceRef, checkSourceNames, sourceOptions, sourcesFor, sourcesVariable } from "./sources/source-settings.js";
34
36
  import { RecordKeyInput, ToolRecord, ToolRecords } from "./assistant/records.js";
35
37
  import { FunctionRecords, ListParams, RecordPage } from "./functions/records.js";
36
- import { ApiFunction, CorsOptions, FunctionApp, FunctionCaller, FunctionContext, FunctionHandler, FunctionOptions, FunctionSource, ProtectedFunctionOptions, PublicFunctionContext, PublicFunctionHandler, PublicFunctionOptions, defineFunction } from "./functions/define-function.js";
38
+ import { ApiFunction, CorsOptions, FunctionApp, FunctionCaller, FunctionContext, FunctionHandler, FunctionOptions, FunctionSource, KeyFunctionContext, ProtectedFunctionOptions, PublicFunctionContext, PublicFunctionHandler, PublicFunctionOptions, defineFunction } from "./functions/define-function.js";
37
39
  import { CorsOrigins } from "./api-cors.js";
38
- import { ApiKeys, ApiKeysOptions, apiKeySettings, apiKeyVariables } from "./api-keys/api-key-settings.js";
39
40
  import { ConversationRecord, ConversationStore } from "./assistant/conversation-store.js";
40
41
  import { Conversation, ConversationsOptions, conversationKey, createConversations } from "./assistant/conversations.js";
41
42
  import { ApprovalAnswer, ApprovalRequest, requestApproval } from "./assistant/approval.js";
@@ -50,7 +51,6 @@ import { checkViewQueries } from "./check-view-queries.js";
50
51
  import { ProjectConfig, defineConfig, mergeConfig } from "./project-config.js";
51
52
  import { consoleAuditQueue } from "./audit/console-queue.js";
52
53
  import { JwtOptions, JwtVerifyOptions, jwtAuthenticator, jwtVerifier } from "./auth/jwt.js";
53
- import { Caller, CallerOptions, apiKeyCaller } from "./api-keys/resolve-caller.js";
54
54
  import { HttpProblem, MissingCredentials, badRequest, forbidden, notFound, unauthorized } from "./problem.js";
55
55
  import { TrustedApp, withTrustedApps } from "./better-auth/app-tokens.js";
56
56
  import { BetterAuthAuthenticatorOptions, betterAuthAuthenticator, betterAuthTokens } from "./better-auth/authenticator.js";
@@ -58,6 +58,8 @@ import { parseRoles } from "./better-auth/parse-roles.js";
58
58
  import { LinkedAccount, NewUser, StoredUser, createUser, deleteUser, hasUsers, listUsers, roleChoices, setUserBanned, setUserRole } from "./better-auth/users.js";
59
59
  import { IssueTokenOptions, issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
60
60
  import { webauthnPath } from "./better-auth/origins.js";
61
+ import { goTruePath } from "./gotrue/keys.js";
62
+ import { supabasePath } from "./supabase-paths.js";
61
63
  import { defaultAppName } from "./app-name.js";
62
64
  import { authSchemaMigration, checkAuthSchema } from "./better-auth/auth-schema.js";
63
65
  import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
@@ -86,6 +88,7 @@ import { startErrorReporting } from "./error-reporting/error-reporter.js";
86
88
  import { FunctionEnv, PublicFunctionEnv, functionApp } from "./functions/function-app.js";
87
89
  import { SignatureOptions, StandardWebhookOptions, verifySignature, verifyStandardWebhook } from "./functions/verify-signature.js";
88
90
  import { requireEnv } from "./functions/require-env.js";
91
+ import { backgroundSettled, waitUntil } from "./functions/wait-until.js";
89
92
  import { FileLimits, limitedFileStore, storeUsage } from "./files/limits.js";
90
93
  import { LocalFilesOptions, localFileStore, localFiles } from "./files/local-files.js";
91
94
  import { StoreFileInput, storeFile } from "./files/store-file.js";
@@ -102,4 +105,4 @@ import { isSchedule } from "./jobs/schedule.js";
102
105
  import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
103
106
  import { jobsDrainApp } from "./jobs/drain-route.js";
104
107
  import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
105
- export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type AppIcons, type AppIdentity, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSource, type HistoryOptions, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JwtOptions, type JwtVerifyOptions, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type MemberInput, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewOrganization, type NewUser, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type QueryOptions, type QueryResult, type ReasoningDetail, type ReasoningEffort, type RecordKeyInput, type RecordPage, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredObject, type StoredOrganization, type StoredUser, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type User, type UserCreatedHook, type ViewSource, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, objectKey, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
108
+ export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type AppIcons, type AppIdentity, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSource, type HistoryOptions, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type MemberInput, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewOrganization, type NewUser, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type QueryOptions, type QueryResult, type ReasoningDetail, type ReasoningEffort, type RecordKeyInput, type RecordPage, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredObject, type StoredOrganization, type StoredUser, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type User, type UserCreatedHook, type ViewSource, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, backgroundSettled, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, goTruePath, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, objectKey, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, waitUntil, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
package/dist/index.js CHANGED
@@ -23,6 +23,8 @@ import { apiKeyCaller } from "./api-keys/resolve-caller.js";
23
23
  import { jwtAuthenticator, jwtVerifier } from "./auth/jwt.js";
24
24
  import { objectKey } from "./storage/object-key.js";
25
25
  import { defaultAppName } from "./app-name.js";
26
+ import { supabasePath } from "./supabase-paths.js";
27
+ import { goTruePath } from "./gotrue/keys.js";
26
28
  import { defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
27
29
  import { parseRoles } from "./better-auth/parse-roles.js";
28
30
  import { readOperatorSettings } from "./better-auth/operator-provider.js";
@@ -71,10 +73,11 @@ import { functionApp } from "./functions/function-app.js";
71
73
  import { readJson } from "./functions/read-json.js";
72
74
  import { verifySignature, verifyStandardWebhook } from "./functions/verify-signature.js";
73
75
  import { requireEnv } from "./functions/require-env.js";
76
+ import { backgroundSettled, waitUntil } from "./functions/wait-until.js";
74
77
  import { storeFile } from "./files/store-file.js";
75
78
  import { createFileCleanup } from "./files/file-cleanup.js";
76
79
  import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/processors.js";
77
80
  import { defineEmail } from "./mail/define-email.js";
78
81
  import { startJobs } from "./jobs/runtime.js";
79
82
  import { jobsDrainApp } from "./jobs/drain-route.js";
80
- export { FatalJobError, HttpProblem, MissingCredentials, ModelError, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, objectKey, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
83
+ export { FatalJobError, HttpProblem, MissingCredentials, ModelError, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, backgroundSettled, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, goTruePath, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, objectKey, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, waitUntil, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
@@ -0,0 +1,4 @@
1
+ //#region src/supabase-paths.d.ts
2
+ /** Where the Supabase-compatible endpoints live, below the app's origin: supabase-js takes `<origin>/api/sb` as its URL. */
3
+ export declare const supabasePath = "/api/sb";
4
+ //#endregion
@@ -7,5 +7,7 @@ const restPath = `${supabasePath}/rest/v1`;
7
7
  const realtimePath = `${supabasePath}/realtime/v1`;
8
8
  /** The Storage-compatible API of `storage`. */
9
9
  const storagePath = `${supabasePath}/storage/v1`;
10
+ /** Where `functions.invoke` calls a function: `<origin>/api/sb/functions/v1/<name>`. */
11
+ const supabaseFunctionsPath = `${supabasePath}/functions/v1`;
10
12
  //#endregion
11
- export { realtimePath, restPath, storagePath, supabasePath };
13
+ export { realtimePath, restPath, storagePath, supabaseFunctionsPath, supabasePath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -32,9 +32,9 @@
32
32
  "dependencies": {
33
33
  "@better-auth/passkey": "^1.7.7",
34
34
  "@better-auth/sso": "^1.7.7",
35
- "@protobase/layout": "0.31.0",
36
- "@protobase/query": "0.31.0",
37
- "@protobase/schema": "0.31.0",
35
+ "@protobase/layout": "0.31.1",
36
+ "@protobase/query": "0.31.1",
37
+ "@protobase/schema": "0.31.1",
38
38
  "@react-email/render": "^2.1.0",
39
39
  "@scalar/hono-api-reference": "^0.12.10",
40
40
  "@sentry/core": "^11.7.0",