@protobase/server 0.67.1 → 0.67.2
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.
- package/dist/better-auth/auth-settings.d.ts +2 -2
- package/dist/better-auth/create-auth.d.ts +2 -2
- package/dist/create-admin.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/package.js +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/user-tables/definitions-version.d.ts +10 -0
- package/dist/user-tables/definitions-version.js +16 -0
- package/dist/user-tables/latest-admin.js +47 -0
- package/dist/user-tables/reloading-admin.d.ts +40 -0
- package/dist/user-tables/reloading-admin.js +63 -0
- package/package.json +4 -4
|
@@ -1010,8 +1010,8 @@ export declare const buildAppAuth: (settings: AuthSettings, input: AppAuthInput)
|
|
|
1010
1010
|
$Infer: {
|
|
1011
1011
|
body: {
|
|
1012
1012
|
permissions: {
|
|
1013
|
-
readonly user?: ("
|
|
1014
|
-
readonly session?: ("
|
|
1013
|
+
readonly user?: ("list" | "create" | "update" | "delete" | "set-role" | "ban" | "impersonate" | "set-password" | "set-email" | "get" | "impersonate-admins")[] | undefined;
|
|
1014
|
+
readonly session?: ("list" | "delete" | "revoke")[] | undefined;
|
|
1015
1015
|
};
|
|
1016
1016
|
} & {
|
|
1017
1017
|
userId?: string | undefined;
|
|
@@ -1143,8 +1143,8 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
1143
1143
|
$Infer: {
|
|
1144
1144
|
body: {
|
|
1145
1145
|
permissions: {
|
|
1146
|
-
readonly user?: ("
|
|
1147
|
-
readonly session?: ("
|
|
1146
|
+
readonly user?: ("list" | "create" | "update" | "delete" | "set-role" | "ban" | "impersonate" | "set-password" | "set-email" | "get" | "impersonate-admins")[] | undefined;
|
|
1147
|
+
readonly session?: ("list" | "delete" | "revoke")[] | undefined;
|
|
1148
1148
|
};
|
|
1149
1149
|
} & {
|
|
1150
1150
|
userId?: string | undefined;
|
package/dist/create-admin.js
CHANGED
|
@@ -565,6 +565,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], userTables
|
|
|
565
565
|
return Object.assign(app, {
|
|
566
566
|
startRealtimePrune: prune,
|
|
567
567
|
decryptField,
|
|
568
|
+
metaPath: `${deps.systemPath}/meta`,
|
|
568
569
|
jobs: [
|
|
569
570
|
...webhooks.jobs,
|
|
570
571
|
...withHistory && days !== void 0 ? [pruneHistoryJob(changes, days)] : [],
|
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,8 @@ import { newWebhookSecret } from "./webhooks/standard-webhooks.js";
|
|
|
103
103
|
import { checkWebhooksSchema, webhooksMigration } from "./webhooks/table/schema.js";
|
|
104
104
|
import { checkUserTablesSchema, userTablesMigration } from "./user-tables/schema.js";
|
|
105
105
|
import { UserTables, userTableResources } from "./user-tables/user-table-resources.js";
|
|
106
|
+
import { readDefinitionsVersion } from "./user-tables/definitions-version.js";
|
|
107
|
+
import { reloadingAdmin } from "./user-tables/reloading-admin.js";
|
|
106
108
|
import { checkRealtimeRelay, realtimeRelayMigration } from "./realtime/relay/relay-schema.js";
|
|
107
109
|
import { channelSendsMigration, checkChannelSends } from "./channels/sends-schema.js";
|
|
108
110
|
import { checkComments, commentsMigration } from "./comments/comments-sql.js";
|
|
@@ -186,4 +188,4 @@ import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/ru
|
|
|
186
188
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
187
189
|
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
188
190
|
import { AdminAuth, CreateAuthOptions, UserCreatedHook, normalizeRoles } from "./better-auth/create-auth.js";
|
|
189
|
-
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailMessage, MailServerTimeoutError, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PdfComponent, type PdfOptions, type PdfTemplate, PersonalMailError, type PersonalMailErrorCode, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, 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 SendNotification, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type Urgency, type User, type UserCreatedHook, type UserTables, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, callsMigration, capSocketMessages, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTool, deleteRecordTool, deleteUser, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordOf, refusalOf, refused, relayed, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, userTableResources, userTablesMigration, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };
|
|
191
|
+
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailMessage, MailServerTimeoutError, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PdfComponent, type PdfOptions, type PdfTemplate, PersonalMailError, type PersonalMailErrorCode, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, 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 SendNotification, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type Urgency, type User, type UserCreatedHook, type UserTables, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, callsMigration, capSocketMessages, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTool, deleteRecordTool, deleteUser, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readDefinitionsVersion, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordOf, refusalOf, refused, relayed, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, userTableResources, userTablesMigration, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };
|
package/dist/index.js
CHANGED
|
@@ -115,6 +115,8 @@ import { checkComputed, computedMigration } from "./computed/computed-schema.js"
|
|
|
115
115
|
import { checkWebhooksSchema, webhooksMigration } from "./webhooks/table/schema.js";
|
|
116
116
|
import { checkUserTablesSchema, userTablesMigration } from "./user-tables/schema.js";
|
|
117
117
|
import { userTableResources } from "./user-tables/user-table-resources.js";
|
|
118
|
+
import { readDefinitionsVersion } from "./user-tables/definitions-version.js";
|
|
119
|
+
import { reloadingAdmin } from "./user-tables/reloading-admin.js";
|
|
118
120
|
import { checkRealtimeRelay, realtimeRelayMigration } from "./realtime/relay/relay-schema.js";
|
|
119
121
|
import { channelSendsMigration, checkChannelSends } from "./channels/sends-schema.js";
|
|
120
122
|
import { callsMigration, checkCalls } from "./calls/calls-sql.js";
|
|
@@ -137,4 +139,4 @@ import { defineEmail } from "./mail/define-email.js";
|
|
|
137
139
|
import { definePdf } from "./pdf/define-pdf.js";
|
|
138
140
|
import { startJobs } from "./jobs/runtime.js";
|
|
139
141
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
140
|
-
export { ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, addAppRoleToOwners, addCommentTool, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, callsMigration, capSocketMessages, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTool, deleteRecordTool, deleteUser, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordOf, refusalOf, refused, relayed, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, userTableResources, userTablesMigration, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };
|
|
142
|
+
export { ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, addAppRoleToOwners, addCommentTool, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, callsMigration, capSocketMessages, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTool, deleteRecordTool, deleteUser, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readDbConnections, readDefinitionsVersion, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readRecordTools, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordOf, refusalOf, refused, relayed, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, thumbHash, unauthorized, updateRecordTool, urgencies, userTableResources, userTablesMigration, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, writeRecordTools };
|
package/dist/package.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -147,11 +147,12 @@ export type PageSource = {
|
|
|
147
147
|
/**
|
|
148
148
|
* The admin API, the jobs it needs a worker to run (the delivery of resource events), the pruning of the realtime
|
|
149
149
|
* tables a serving process starts once it listens and stops as it closes, and the read of encrypted fields that
|
|
150
|
-
* `startJobs` gives the jobs' context.
|
|
150
|
+
* `startJobs` gives the jobs' context, and the path it answers `/meta` at.
|
|
151
151
|
*/
|
|
152
152
|
export type Admin = Hono<AdminEnv> & {
|
|
153
153
|
jobs: JobDefinition[];
|
|
154
154
|
startRealtimePrune: () => RealtimePrune;
|
|
155
155
|
decryptField: FieldDecrypter;
|
|
156
|
+
metaPath: string;
|
|
156
157
|
};
|
|
157
158
|
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Db } from "@protobase/query";
|
|
2
|
+
//#region src/user-tables/definitions-version.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The version of the stored definitions as a whole, from their rows alone: how many there are, the highest id and the
|
|
5
|
+
* sum of their versions. Adding one raises the highest id, which an identity never gives again, removing one lowers the
|
|
6
|
+
* count, and changing one raises its version, so each change moves it, as long as every change of a definition or its
|
|
7
|
+
* fields raises the definition's version. One read of `tables`, which holds a row per table users add.
|
|
8
|
+
*/
|
|
9
|
+
export declare const readDefinitionsVersion: (db: Db) => Promise<string>;
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { definitionsSchema } from "./names.js";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
//#region src/user-tables/definitions-version.ts
|
|
4
|
+
/**
|
|
5
|
+
* The version of the stored definitions as a whole, from their rows alone: how many there are, the highest id and the
|
|
6
|
+
* sum of their versions. Adding one raises the highest id, which an identity never gives again, removing one lowers the
|
|
7
|
+
* count, and changing one raises its version, so each change moves it, as long as every change of a definition or its
|
|
8
|
+
* fields raises the definition's version. One read of `tables`, which holds a row per table users add.
|
|
9
|
+
*/
|
|
10
|
+
const readDefinitionsVersion = async (db) => {
|
|
11
|
+
const { rows } = await sql`select count(*) || ':' || coalesce(max(id), 0) || ':' || coalesce(sum(version), 0) as version
|
|
12
|
+
from ${sql.table(`${definitionsSchema}.tables`)}`.execute(db);
|
|
13
|
+
return rows[0].version;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { readDefinitionsVersion };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/user-tables/latest-admin.ts
|
|
2
|
+
/** How long a read of the definitions version holds before a request reads it again, in milliseconds. */
|
|
3
|
+
const versionCheckMs = 1e3;
|
|
4
|
+
/**
|
|
5
|
+
* The latest admin built, the only one kept: a cache of one entry, swapped for one built anew when the definitions
|
|
6
|
+
* version moved. `get(true)` reads the version at once, `get()` at most once a `versionCheckMs`; either waits for a read
|
|
7
|
+
* or rebuild already running instead of starting another, so two requests never build twice. A request keeps the admin
|
|
8
|
+
* it got until it is answered.
|
|
9
|
+
*/
|
|
10
|
+
const latestAdmin = ({ admin, version, readVersion, rebuild, now = Date.now }) => {
|
|
11
|
+
let latest = {
|
|
12
|
+
admin,
|
|
13
|
+
version,
|
|
14
|
+
checkedAt: now()
|
|
15
|
+
};
|
|
16
|
+
let checking;
|
|
17
|
+
const check = async () => {
|
|
18
|
+
const checkedAt = now();
|
|
19
|
+
const read = await readVersion();
|
|
20
|
+
if (read === latest.version) {
|
|
21
|
+
latest = {
|
|
22
|
+
...latest,
|
|
23
|
+
checkedAt
|
|
24
|
+
};
|
|
25
|
+
return latest.admin;
|
|
26
|
+
}
|
|
27
|
+
latest = {
|
|
28
|
+
admin: await rebuild(latest.admin),
|
|
29
|
+
version: read,
|
|
30
|
+
checkedAt
|
|
31
|
+
};
|
|
32
|
+
return latest.admin;
|
|
33
|
+
};
|
|
34
|
+
const get = (atOnce = false) => {
|
|
35
|
+
if (!atOnce && now() - latest.checkedAt < 1e3) return Promise.resolve(latest.admin);
|
|
36
|
+
checking ??= check().finally(() => {
|
|
37
|
+
checking = void 0;
|
|
38
|
+
});
|
|
39
|
+
return checking;
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
get,
|
|
43
|
+
current: () => latest.admin
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { latestAdmin, versionCheckMs };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FieldDecrypter } from "../encryption/decrypt-field-types.js";
|
|
2
|
+
import { JobDefinition } from "../jobs/job-types.js";
|
|
3
|
+
import { RealtimePrune } from "../realtime/realtime-prune.js";
|
|
4
|
+
import { Admin, AdminEnv } from "../types.js";
|
|
5
|
+
import { UserTables } from "./user-table-resources.js";
|
|
6
|
+
import "../index.js";
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
//#region src/user-tables/reloading-admin.d.ts
|
|
9
|
+
export type ReloadingAdminInput = {
|
|
10
|
+
/** The admin startup built, from the user tables of `version`. */
|
|
11
|
+
first: Admin;
|
|
12
|
+
version: string;
|
|
13
|
+
/** The definitions version now (`readDefinitionsVersion`). */
|
|
14
|
+
readVersion: () => Promise<string>;
|
|
15
|
+
/** The user tables now (`userTableResources`). */
|
|
16
|
+
readTables: () => Promise<UserTables>;
|
|
17
|
+
/** The admin of the app with these user tables, as startup built `first`. */
|
|
18
|
+
build: (tables: UserTables) => Admin;
|
|
19
|
+
/** The app's `onUnhandledError`: a failed version read, and an admin that does not build. */
|
|
20
|
+
report?: (error: unknown, request?: Request) => void;
|
|
21
|
+
statementTimeoutMs?: number;
|
|
22
|
+
now?: () => number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The app's admin, rebuilt when the tables users add change, so every process serves a new definition without a
|
|
26
|
+
* restart. `/meta` reads the definitions version first; any other request at most once a second, and once more when the
|
|
27
|
+
* admin answers it not found or invalid, as it does a resource or field it does not know, and then is answered again by
|
|
28
|
+
* the admin built anew. A request finishes on the admin it started with, and a WebSocket keeps the admin it opened
|
|
29
|
+
* with. An admin that does not build with the new definitions is reported, and the one before keeps serving.
|
|
30
|
+
* `reload()` reads the version at once, for the process that changed a definition. The jobs, the realtime prune and
|
|
31
|
+
* the field decrypter are those of `first`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const reloadingAdmin: ({ first, version, readVersion, readTables, build, report, statementTimeoutMs, now }: ReloadingAdminInput) => Hono<AdminEnv, import("hono/types").BlankSchema, "/"> & {
|
|
34
|
+
jobs: JobDefinition[];
|
|
35
|
+
startRealtimePrune: () => RealtimePrune;
|
|
36
|
+
decryptField: FieldDecrypter;
|
|
37
|
+
metaPath: string;
|
|
38
|
+
reload: () => Promise<undefined>;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createErrorHandler } from "../error-handler.js";
|
|
2
|
+
import { latestAdmin } from "./latest-admin.js";
|
|
3
|
+
import { Hono } from "hono";
|
|
4
|
+
//#region src/user-tables/reloading-admin.ts
|
|
5
|
+
const problemStatuses = /* @__PURE__ */ new Set([400, 404]);
|
|
6
|
+
const namesUnknown = (response) => problemStatuses.has(response.status) && (response.headers.get("content-type")?.startsWith("application/problem+json") ?? false);
|
|
7
|
+
const replayable = async (request) => {
|
|
8
|
+
if (!request.body) return () => request;
|
|
9
|
+
if (!request.headers.get("content-type")?.includes("json")) return;
|
|
10
|
+
const body = await request.arrayBuffer();
|
|
11
|
+
return () => new Request(request, { body });
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The app's admin, rebuilt when the tables users add change, so every process serves a new definition without a
|
|
15
|
+
* restart. `/meta` reads the definitions version first; any other request at most once a second, and once more when the
|
|
16
|
+
* admin answers it not found or invalid, as it does a resource or field it does not know, and then is answered again by
|
|
17
|
+
* the admin built anew. A request finishes on the admin it started with, and a WebSocket keeps the admin it opened
|
|
18
|
+
* with. An admin that does not build with the new definitions is reported, and the one before keeps serving.
|
|
19
|
+
* `reload()` reads the version at once, for the process that changed a definition. The jobs, the realtime prune and
|
|
20
|
+
* the field decrypter are those of `first`.
|
|
21
|
+
*/
|
|
22
|
+
const reloadingAdmin = ({ first, version, readVersion, readTables, build, report, statementTimeoutMs, now }) => {
|
|
23
|
+
const rebuild = async (current) => {
|
|
24
|
+
const tables = await readTables();
|
|
25
|
+
try {
|
|
26
|
+
return build(tables);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
report?.(new Error("The tables users add changed, but the app does not build with them, so it serves the tables it served before", { cause: error }));
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const latest = latestAdmin({
|
|
33
|
+
admin: first,
|
|
34
|
+
version,
|
|
35
|
+
readVersion,
|
|
36
|
+
rebuild,
|
|
37
|
+
...now && { now }
|
|
38
|
+
});
|
|
39
|
+
const answer = async (request, env) => {
|
|
40
|
+
const path = new URL(request.url).pathname;
|
|
41
|
+
const atOnce = path === first.metaPath || path.startsWith(`${first.metaPath}/`);
|
|
42
|
+
const admin = await latest.get(atOnce);
|
|
43
|
+
const again = atOnce ? void 0 : await replayable(request);
|
|
44
|
+
if (!again) return admin.fetch(request, env);
|
|
45
|
+
const answered = await admin.fetch(again(), env);
|
|
46
|
+
if (!namesUnknown(answered)) return answered;
|
|
47
|
+
const fresh = await latest.get(true);
|
|
48
|
+
return fresh === admin ? answered : fresh.fetch(again(), env);
|
|
49
|
+
};
|
|
50
|
+
const app = new Hono();
|
|
51
|
+
app.onError(createErrorHandler(report, statementTimeoutMs));
|
|
52
|
+
app.all("*", (c) => answer(c.req.raw, c.env));
|
|
53
|
+
const reload = async () => void await latest.get(true);
|
|
54
|
+
return Object.assign(app, {
|
|
55
|
+
jobs: first.jobs,
|
|
56
|
+
startRealtimePrune: first.startRealtimePrune,
|
|
57
|
+
decryptField: first.decryptField,
|
|
58
|
+
metaPath: first.metaPath,
|
|
59
|
+
reload
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { reloadingAdmin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.2",
|
|
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": {
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@better-auth/sso": "^1.7.12",
|
|
44
44
|
"@livekit/protocol": "1.53.1",
|
|
45
45
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
46
|
-
"@protobase/layout": "0.67.
|
|
47
|
-
"@protobase/query": "0.67.
|
|
48
|
-
"@protobase/schema": "0.67.
|
|
46
|
+
"@protobase/layout": "0.67.2",
|
|
47
|
+
"@protobase/query": "0.67.2",
|
|
48
|
+
"@protobase/schema": "0.67.2",
|
|
49
49
|
"@react-email/render": "^2.1.0",
|
|
50
50
|
"@react-pdf/primitives": "^4.4.0",
|
|
51
51
|
"@react-pdf/renderer": "^4.9.0",
|