@protobase/server 0.123.1 → 0.123.3
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/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/package.js +1 -1
- package/dist/relay/change-commands.js +16 -5
- package/dist/relay/client-events.d.ts +25 -0
- package/dist/relay/client-events.js +51 -0
- package/dist/relay/relay-options.d.ts +16 -0
- package/dist/relay/relay-options.js +30 -1
- package/dist/relay/relay-runtime.js +1 -1
- package/dist/relay/ticket-route.js +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MobileConfig, MobileSplash, MobileSplashLook } from "./mobile-config.js";
|
|
2
2
|
import { AppIdentity } from "./app-identity.js";
|
|
3
3
|
import { AppIcons, PngIcon, pngIcons } from "./web-app/app-icons.js";
|
|
4
|
-
import { RealtimeRelayOptions, RelayChannelOptions, RelayMembers, RelayPresence, checkRelayOptions } from "./relay/relay-options.js";
|
|
4
|
+
import { RealtimeRelayOptions, RelayChannelOptions, RelayClientEvent, RelayMembers, RelayPresence, checkRelayOptions } from "./relay/relay-options.js";
|
|
5
5
|
import { RealtimeOptions, relayed, sqlSends } from "./realtime/relay/realtime-options.js";
|
|
6
6
|
import { StaffSignIn } from "./better-auth/staff-log.js";
|
|
7
7
|
import { MailAttachment, MailMessage, Mailer, SentMail } from "./mail/mail-message.js";
|
|
@@ -161,6 +161,7 @@ import { mailCheckHeaders, mailCheckSecret } from "./personal-mail/mail-check-si
|
|
|
161
161
|
import { MailFeedback } from "./mail/feedback/feedback-record.js";
|
|
162
162
|
import { onDoNotDisturb } from "./status/do-not-disturb.js";
|
|
163
163
|
import { relayPresencePath } from "./relay/presence-route.js";
|
|
164
|
+
import { relayClientEvents, typingResources } from "./relay/client-events.js";
|
|
164
165
|
import { checkRelaySchema, relayMigration } from "./relay/relay-schema.js";
|
|
165
166
|
import { ListedOrganization, MemberInput, NewOrganization, OrganizationsCursor, OrganizationsPage, addAppRoleToOwners, addMember, createOrganization, listOrganizations, organizationsPageSize, removeMember, setMemberRoles } from "./better-auth/organizations/host.js";
|
|
166
167
|
import { JoinedUser, addEveryUser } from "./better-auth/organizations/add-every-user.js";
|
|
@@ -231,4 +232,4 @@ import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/ru
|
|
|
231
232
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
232
233
|
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
233
234
|
import { ResourceSource, configExports } from "./resource-source.js";
|
|
234
|
-
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, 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 BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, 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 DerivedClock, type DerivedCompute, type DerivedContext, 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 FcmOptions, type FcmSettings, 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 JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, 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, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, 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 RealtimeRelayOptions, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayDevice, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, 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 SentMail, 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 StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, 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 UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, 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, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
|
235
|
+
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, 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 BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, 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 DerivedClock, type DerivedCompute, type DerivedContext, 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 FcmOptions, type FcmSettings, 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 JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, 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, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, 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 RealtimeRelayOptions, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, 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 SentMail, 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 StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, 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 UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, 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, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
package/dist/index.js
CHANGED
|
@@ -155,6 +155,7 @@ import { checkStatusSchema, statusMigration } from "./status/schema.js";
|
|
|
155
155
|
import { checkUnsubscribesSchema, unsubscribesMigration } from "./mail/unsubscribe/unsubscribe-schema.js";
|
|
156
156
|
import { BulkMailError } from "./mail/unsubscribe/bulk-mail-error.js";
|
|
157
157
|
import { checkMailFeedbackSchema, mailFeedbackMigration } from "./mail/feedback/feedback-schema.js";
|
|
158
|
+
import { relayClientEvents, typingResources } from "./relay/client-events.js";
|
|
158
159
|
import { checkRelaySchema, relayMigration } from "./relay/relay-schema.js";
|
|
159
160
|
import { addEveryUser } from "./better-auth/organizations/add-every-user.js";
|
|
160
161
|
import { maxWidgetPropsBytes, widget } from "./assistant/widget.js";
|
|
@@ -173,4 +174,4 @@ import { defineEmail } from "./mail/define-email.js";
|
|
|
173
174
|
import { definePdf } from "./pdf/define-pdf.js";
|
|
174
175
|
import { startJobs } from "./jobs/runtime.js";
|
|
175
176
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
176
|
-
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, 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, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
|
177
|
+
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, 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, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
package/dist/package.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { peopleChannel } from "./presence-commands.js";
|
|
1
2
|
//#region src/relay/change-commands.ts
|
|
2
3
|
/** The event every notice of a change is published as. */
|
|
3
4
|
const changeEvent = "change";
|
|
5
|
+
/** The event that tells a person on `people` of a channel they were added to, so their open pages join it. */
|
|
6
|
+
const joinedEvent = "joined";
|
|
4
7
|
/** A channel by name: `<resource>/<key>`, as the record channels name it too. */
|
|
5
8
|
const channelName = (resource, key) => `${resource}/${String(key)}`;
|
|
6
9
|
const present = (value) => value !== null && value !== void 0;
|
|
@@ -60,22 +63,30 @@ const notice = (models, change, channel, members, moved) => {
|
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
};
|
|
66
|
+
const joinedCommand = (sequence, add) => ({
|
|
67
|
+
kind: "publish",
|
|
68
|
+
id: `${sequence}:${add.channel}:${joinedEvent}`,
|
|
69
|
+
channel: peopleChannel,
|
|
70
|
+
users: add.users,
|
|
71
|
+
event: joinedEvent,
|
|
72
|
+
payload: { channel: add.channel }
|
|
73
|
+
});
|
|
63
74
|
const reaches = (command, open) => command.users === void 0 ? open.has(command.channel) : command.users.length > 0;
|
|
64
75
|
/**
|
|
65
76
|
* The relay's commands for a dispatched batch, in commit order: for each change, a person who joins a channel joins it
|
|
66
|
-
* first
|
|
67
|
-
* members hears it only through its members as the app's database has them
|
|
68
|
-
* left; an open one through everyone joined to it, and only while its record is public (`open`), so sockets that joined
|
|
77
|
+
* first and hears `joined` of it on `people`, then each channel the record was or is on hears one notice, then a person
|
|
78
|
+
* who left it leaves. A channel with members hears it only through its members as the app's database has them
|
|
79
|
+
* (`members`), and the person who joined or left; an open one through everyone joined to it, and only while its record is public (`open`), so sockets that joined
|
|
69
80
|
* it before hear nothing once it is not. A notice of a channel with no one to reach is left out.
|
|
70
81
|
*/
|
|
71
82
|
const changeCommands = (models, changes, members, open) => changes.flatMap((change) => {
|
|
72
83
|
const moved = membersCommands(models, change);
|
|
73
84
|
const notices = noticedChannels(models, change).map((channel) => notice(models, change, channel, members, moved)).filter((command) => reaches(command, open));
|
|
74
85
|
return [
|
|
75
|
-
...moved.filter((command) => command.kind === "add"),
|
|
86
|
+
...moved.filter((command) => command.kind === "add").flatMap((add) => [add, joinedCommand(change.sequence, add)]),
|
|
76
87
|
...notices,
|
|
77
88
|
...moved.filter((command) => command.kind === "remove")
|
|
78
89
|
];
|
|
79
90
|
});
|
|
80
91
|
//#endregion
|
|
81
|
-
export { audienceChannels, changeCommands, changeEvent, channelName, noticedChannels, openChannels };
|
|
92
|
+
export { audienceChannels, changeCommands, changeEvent, channelName, joinedEvent, noticedChannels, openChannels };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RealtimeRelayOptions } from "./relay-options.js";
|
|
2
|
+
import { ViewModel } from "@protobase/schema";
|
|
3
|
+
//#region src/relay/client-events.d.ts
|
|
4
|
+
/** The resources whose conversation page has `typing`, so their channels carry the typing event. */
|
|
5
|
+
export declare const typingResources: (views: readonly ViewModel[]) => Set<string>;
|
|
6
|
+
/**
|
|
7
|
+
* The relay's `client_events` of the app: each channel resource's declared events, with `typing` on those whose
|
|
8
|
+
* conversation page types unless the resource declares a `typing` of its own, in the relay's field names. Undefined
|
|
9
|
+
* when no channel has an event, so clients send nothing.
|
|
10
|
+
*/
|
|
11
|
+
export declare const relayClientEvents: (channels: RealtimeRelayOptions["channels"], typing: ReadonlySet<string>) => {
|
|
12
|
+
channels: {
|
|
13
|
+
[k: string]: {
|
|
14
|
+
readonly events: {
|
|
15
|
+
[k: string]: {
|
|
16
|
+
schema: Record<string, unknown>;
|
|
17
|
+
max_bytes: unknown;
|
|
18
|
+
per_second: unknown;
|
|
19
|
+
burst: unknown;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | undefined;
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { eventLimit } from "./relay-options.js";
|
|
2
|
+
//#region src/relay/client-events.ts
|
|
3
|
+
/**
|
|
4
|
+
* The framework's typing event, as a conversation page with `typing` sends it on its record's channel:
|
|
5
|
+
* `{ typing, thread }`, `thread` the key of the thread's first message or null, so the size leaves room for a key.
|
|
6
|
+
*/
|
|
7
|
+
const typingClientEvent = {
|
|
8
|
+
schema: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
typing: { type: "boolean" },
|
|
12
|
+
thread: { type: [
|
|
13
|
+
"string",
|
|
14
|
+
"number",
|
|
15
|
+
"null"
|
|
16
|
+
] }
|
|
17
|
+
},
|
|
18
|
+
required: ["typing"],
|
|
19
|
+
additionalProperties: false
|
|
20
|
+
},
|
|
21
|
+
maxBytes: 256,
|
|
22
|
+
perSecond: 2,
|
|
23
|
+
burst: 4
|
|
24
|
+
};
|
|
25
|
+
/** The resources whose conversation page has `typing`, so their channels carry the typing event. */
|
|
26
|
+
const typingResources = (views) => new Set(views.flatMap((view) => view.record && "conversation" in view.record && view.record.conversation.typing ? [view.resource] : []));
|
|
27
|
+
const relayEvent = (event) => ({
|
|
28
|
+
schema: event.schema,
|
|
29
|
+
max_bytes: eventLimit(event.maxBytes),
|
|
30
|
+
per_second: eventLimit(event.perSecond),
|
|
31
|
+
burst: eventLimit(event.burst)
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* The relay's `client_events` of the app: each channel resource's declared events, with `typing` on those whose
|
|
35
|
+
* conversation page types unless the resource declares a `typing` of its own, in the relay's field names. Undefined
|
|
36
|
+
* when no channel has an event, so clients send nothing.
|
|
37
|
+
*/
|
|
38
|
+
const relayClientEvents = (channels, typing) => {
|
|
39
|
+
const declared = Object.entries(channels).flatMap(([resource, channel]) => {
|
|
40
|
+
const events = {
|
|
41
|
+
...typing.has(resource) && { typing: typingClientEvent },
|
|
42
|
+
...channel.events
|
|
43
|
+
};
|
|
44
|
+
if (Object.keys(events).length === 0) return [];
|
|
45
|
+
return [[resource, { events: Object.fromEntries(Object.entries(events).map(([name, event]) => [name, relayEvent(event)])) }]];
|
|
46
|
+
});
|
|
47
|
+
if (declared.length === 0) return;
|
|
48
|
+
return { channels: Object.fromEntries(declared) };
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { relayClientEvents, typingClientEvent, typingResources };
|
|
@@ -17,6 +17,22 @@ export type RelayChannelOptions = {
|
|
|
17
17
|
members?: RelayMembers;
|
|
18
18
|
/** A field of the records noticed on the channel that lists the user ids a record mentions, such as a message's `mentions`. */
|
|
19
19
|
mentions?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The events its members may send each other on a channel through the relay, by name, such as `{ ring: ... }`; the
|
|
22
|
+
* relay refuses any other. A conversation page with `typing` declares `typing` itself.
|
|
23
|
+
*/
|
|
24
|
+
events?: Record<string, RelayClientEvent>;
|
|
25
|
+
};
|
|
26
|
+
/** An event clients may send on a channel: its payload's JSON schema and size, and how often one person may send it. */
|
|
27
|
+
export type RelayClientEvent = {
|
|
28
|
+
/** The payload's JSON schema, draft 2020-12 unless it names another; it may load no other document. */
|
|
29
|
+
schema: Record<string, unknown>;
|
|
30
|
+
/** The payload's largest size in bytes, 1 to 65536. */
|
|
31
|
+
maxBytes: number;
|
|
32
|
+
/** How often one person may send it, a second, over all their sockets. */
|
|
33
|
+
perSecond: number;
|
|
34
|
+
/** How many one person may send at once before `perSecond` holds them back. */
|
|
35
|
+
burst: number;
|
|
20
36
|
};
|
|
21
37
|
/**
|
|
22
38
|
* Where the relay's presence reports go: a resource of the app's own with one record per person, which the reports
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
//#region src/relay/relay-options.ts
|
|
2
2
|
const appPattern = /^[a-z0-9_-]{1,64}$/;
|
|
3
3
|
const minKeyLength = 32;
|
|
4
|
+
const maxEventBytes = 65536;
|
|
5
|
+
const reservedEvents = /* @__PURE__ */ new Set([
|
|
6
|
+
"heartbeat",
|
|
7
|
+
"interest",
|
|
8
|
+
"presence",
|
|
9
|
+
"client_event"
|
|
10
|
+
]);
|
|
11
|
+
/**
|
|
12
|
+
* An event's limit as a number: one read from the environment (`{ "$env": ... }` in a JSON config) is text, such as
|
|
13
|
+
* `"128"`, and counts as the number it writes; any other value stays as it is, for the check to refuse.
|
|
14
|
+
*/
|
|
15
|
+
const eventLimit = (value) => typeof value === "string" && value.trim() !== "" ? Number(value) : value;
|
|
4
16
|
const nonEmpty = (value) => typeof value === "string" && value.length > 0;
|
|
17
|
+
const checkEvents = (where, events) => {
|
|
18
|
+
if (typeof events !== "object" || events === null || Array.isArray(events)) throw new Error(`${where} must be an object of events by name`);
|
|
19
|
+
for (const [name, event] of Object.entries(events)) {
|
|
20
|
+
if (name.length === 0 || new TextEncoder().encode(name).length > 64 || reservedEvents.has(name) || name.startsWith("phx_")) throw new Error(`${where}: "${name}" must be 1 to 64 bytes and none of heartbeat, interest, presence, client_event and phx_*`);
|
|
21
|
+
const schema = event?.schema;
|
|
22
|
+
if (typeof schema !== "object" || schema === null || Array.isArray(schema)) throw new Error(`${where}.${name}.schema must be a JSON schema object`);
|
|
23
|
+
const [maxBytes, perSecond, burst] = [
|
|
24
|
+
event.maxBytes,
|
|
25
|
+
event.perSecond,
|
|
26
|
+
event.burst
|
|
27
|
+
].map(eventLimit);
|
|
28
|
+
if (!Number.isInteger(maxBytes) || maxBytes < 1 || maxBytes > maxEventBytes) throw new Error(`${where}.${name}.maxBytes must be a whole number from 1 to ${maxEventBytes}`);
|
|
29
|
+
if (typeof perSecond !== "number" || !(perSecond > 0) || !Number.isFinite(perSecond)) throw new Error(`${where}.${name}.perSecond must be a positive number`);
|
|
30
|
+
if (!Number.isInteger(burst) || burst < 1) throw new Error(`${where}.${name}.burst must be a positive whole number`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
5
33
|
/** The options, or an error naming what is wrong with their shape; `relayModels` checks them against the resources. */
|
|
6
34
|
const checkRelayOptions = (options) => {
|
|
7
35
|
if (!nonEmpty(options?.url) || !/^https?:\/\//.test(options.url)) throw new Error(`realtime.relay.url must start with https:// or http://, not ${JSON.stringify(options?.url)}`);
|
|
@@ -12,6 +40,7 @@ const checkRelayOptions = (options) => {
|
|
|
12
40
|
const members = channel?.members;
|
|
13
41
|
if (members !== void 0 && !(nonEmpty(members.resource) && nonEmpty(members.channel) && nonEmpty(members.user))) throw new Error(`realtime.relay.channels.${name}.members must be { resource, channel, user }`);
|
|
14
42
|
if (channel?.mentions !== void 0 && !nonEmpty(channel.mentions)) throw new Error(`realtime.relay.channels.${name}.mentions must name a field`);
|
|
43
|
+
if (channel?.events !== void 0) checkEvents(`realtime.relay.channels.${name}.events`, channel.events);
|
|
15
44
|
}
|
|
16
45
|
const presence = options.presence;
|
|
17
46
|
if (presence !== void 0) {
|
|
@@ -21,4 +50,4 @@ const checkRelayOptions = (options) => {
|
|
|
21
50
|
return options;
|
|
22
51
|
};
|
|
23
52
|
//#endregion
|
|
24
|
-
export { checkRelayOptions };
|
|
53
|
+
export { checkRelayOptions, eventLimit };
|
|
@@ -2,9 +2,9 @@ import { runningJobs } from "../jobs/current.js";
|
|
|
2
2
|
import { dispatchJobName } from "../changes/capture-sql.js";
|
|
3
3
|
import { anonymousSession } from "../anonymous.js";
|
|
4
4
|
import { readableKeys } from "../channels/records-readable.js";
|
|
5
|
+
import { presenceCommands, presencePeople } from "./presence-commands.js";
|
|
5
6
|
import { audienceChannels, changeCommands, openChannels } from "./change-commands.js";
|
|
6
7
|
import { channelMembers, coMembers } from "./members-sql.js";
|
|
7
|
-
import { presenceCommands, presencePeople } from "./presence-commands.js";
|
|
8
8
|
import { presenceRoutes } from "./presence-route.js";
|
|
9
9
|
import { presenceWriter } from "./presence-sql.js";
|
|
10
10
|
import { relayClient } from "./relay-commands.js";
|
|
@@ -3,8 +3,8 @@ import { channelRecord } from "../channels/channel-name.js";
|
|
|
3
3
|
import { recordReadable } from "../channels/record-readable.js";
|
|
4
4
|
import { anonymousSession } from "../anonymous.js";
|
|
5
5
|
import { jsonBody, jsonOnly } from "../notifications/history-request.js";
|
|
6
|
-
import { memberships } from "./members-sql.js";
|
|
7
6
|
import { peopleChannel } from "./presence-commands.js";
|
|
7
|
+
import { memberships } from "./members-sql.js";
|
|
8
8
|
import { signTicket } from "./ticket.js";
|
|
9
9
|
import { Hono } from "hono";
|
|
10
10
|
import { bodyLimit } from "hono/body-limit";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.123.
|
|
3
|
+
"version": "0.123.3",
|
|
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": {
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@better-auth/sso": "^1.7.12",
|
|
45
45
|
"@livekit/protocol": "1.53.1",
|
|
46
46
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
47
|
-
"@protobase/layout": "0.123.
|
|
48
|
-
"@protobase/query": "0.123.
|
|
49
|
-
"@protobase/schema": "0.123.
|
|
50
|
-
"@protobase/workflow-plugins": "0.123.
|
|
51
|
-
"@protobase/workflows": "0.123.
|
|
47
|
+
"@protobase/layout": "0.123.3",
|
|
48
|
+
"@protobase/query": "0.123.3",
|
|
49
|
+
"@protobase/schema": "0.123.3",
|
|
50
|
+
"@protobase/workflow-plugins": "0.123.3",
|
|
51
|
+
"@protobase/workflows": "0.123.3",
|
|
52
52
|
"@react-email/render": "^2.1.0",
|
|
53
53
|
"@react-pdf/primitives": "^4.4.0",
|
|
54
54
|
"@react-pdf/renderer": "^4.9.0",
|