@protobase/server 0.127.5 → 0.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/better-auth/auth-schema.d.ts +0 -6
- package/dist/better-auth/auth-schema.js +2 -19
- package/dist/better-auth/store/drift.d.ts +1 -1
- package/dist/better-auth/store/drift.js +1 -1
- package/dist/better-auth/store/offline/name-changes.d.ts +2 -2
- package/dist/better-auth/store/offline/name-changes.js +6 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/internal.d.ts +4 -1
- package/dist/internal.js +6 -3
- package/dist/migration-record/check-record.d.ts +11 -0
- package/dist/migration-record/check-record.js +20 -0
- package/dist/migration-record/read-record.js +46 -0
- package/dist/migration-record/record-model.d.ts +11 -0
- package/dist/migration-record/record-model.js +14 -0
- package/dist/migration-record/record-table.d.ts +10 -0
- package/dist/migration-record/record-table.js +21 -0
- package/dist/migration-record/startup-decision.js +40 -0
- package/dist/package.js +1 -1
- package/package.json +6 -6
|
@@ -7,10 +7,4 @@ import { AdminAuth } from "./create-auth.js";
|
|
|
7
7
|
* follow. `undefined` when the store is current. The SQL never drops anything.
|
|
8
8
|
*/
|
|
9
9
|
export declare const authSchemaMigration: (auth: AdminAuth) => Promise<string | undefined>;
|
|
10
|
-
/**
|
|
11
|
-
* Refuses to go on while the admin store has not applied every migration of this version of Protobase, from its
|
|
12
|
-
* `auth_migrations` alone, since every sign-in would fail. The server never changes the schema itself: the project's
|
|
13
|
-
* migrations do, before the new version serves.
|
|
14
|
-
*/
|
|
15
|
-
export declare const checkAuthSchema: (auth: AdminAuth) => Promise<void>;
|
|
16
10
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { plainStoreDb } from "./store/store-db.js";
|
|
2
2
|
import { storeNames } from "./store/store-names.js";
|
|
3
|
-
import { appliedVersions
|
|
3
|
+
import { appliedVersions } from "./store/migrations-table.js";
|
|
4
4
|
import { latestStoreVersion, legacyVersions } from "./store/steps/legacy-versions.js";
|
|
5
5
|
import { migrationsTableSql, stepsSql } from "./store/migration-sql.js";
|
|
6
6
|
import { renderSteps } from "./store/steps/render.js";
|
|
@@ -8,8 +8,6 @@ import { migrationNames } from "./store/steps/step.js";
|
|
|
8
8
|
import { adoptionSql, planAdoption, storeHasTables } from "./store/adoption.js";
|
|
9
9
|
import { hadByVersion, refuseModulesOff } from "./store/modules-off.js";
|
|
10
10
|
//#region src/better-auth/auth-schema.ts
|
|
11
|
-
/** The command that writes the pending changes as a migration file of the project. */
|
|
12
|
-
const authMigrationCommand = "protobase auth migration";
|
|
13
11
|
const refuseNewer = (applied) => {
|
|
14
12
|
const newest = applied.at(-1);
|
|
15
13
|
if (newest !== void 0 && newest > latestStoreVersion) throw new Error(`The auth store is at migration ${newest}, newer than the ${latestStoreVersion} this version of Protobase knows; upgrade Protobase`);
|
|
@@ -47,20 +45,5 @@ const authSchemaMigration = async (auth) => {
|
|
|
47
45
|
...rest
|
|
48
46
|
].join("\n\n");
|
|
49
47
|
};
|
|
50
|
-
/**
|
|
51
|
-
* Refuses to go on while the admin store has not applied every migration of this version of Protobase, from its
|
|
52
|
-
* `auth_migrations` alone, since every sign-in would fail. The server never changes the schema itself: the project's
|
|
53
|
-
* migrations do, before the new version serves.
|
|
54
|
-
*/
|
|
55
|
-
const checkAuthSchema = async (auth) => {
|
|
56
|
-
const names = storeNames(auth);
|
|
57
|
-
const applied = await appliedVersions(plainStoreDb(auth), names);
|
|
58
|
-
const write = `Write it as a migration with \`${authMigrationCommand}\`, apply it with the project's migrations, then start again.`;
|
|
59
|
-
if (applied === void 0) throw new Error(`The auth store has no ${migrationsTable(names).name} table: it is new, or an earlier Protobase made it. ${write}`);
|
|
60
|
-
refuseNewer(applied);
|
|
61
|
-
const missing = legacyVersions.filter((migration) => !applied.includes(migration.version));
|
|
62
|
-
if (missing.length === 0) return;
|
|
63
|
-
throw new Error(`The auth schema is behind this version of Protobase (missing migrations ${missing.map(({ version, name }) => `${version} ${name}`).join(", ")}). ${write}`);
|
|
64
|
-
};
|
|
65
48
|
//#endregion
|
|
66
|
-
export {
|
|
49
|
+
export { authSchemaMigration };
|
|
@@ -3,7 +3,7 @@ import { AdminAuth } from "../create-auth.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* What Better Auth, with the features the app turns on, finds the store lacks or has otherwise: tables, `table.column`s,
|
|
5
5
|
* indexes and its other findings; none when the store matches. It compares the database's tables, so only
|
|
6
|
-
* `protobase dev` runs it, on the developer's machine: a deploy reads the record of migrations instead (`
|
|
6
|
+
* `protobase dev` runs it, on the developer's machine: a deploy reads the record of migrations instead (`checkMigrationRecord`).
|
|
7
7
|
* Better Auth compares through the store's plain connections, without the app's query plugins.
|
|
8
8
|
*/
|
|
9
9
|
export declare const authSchemaDrift: (auth: AdminAuth) => Promise<string[]>;
|
|
@@ -17,7 +17,7 @@ const userViewDrift = async (auth) => {
|
|
|
17
17
|
/**
|
|
18
18
|
* What Better Auth, with the features the app turns on, finds the store lacks or has otherwise: tables, `table.column`s,
|
|
19
19
|
* indexes and its other findings; none when the store matches. It compares the database's tables, so only
|
|
20
|
-
* `protobase dev` runs it, on the developer's machine: a deploy reads the record of migrations instead (`
|
|
20
|
+
* `protobase dev` runs it, on the developer's machine: a deploy reads the record of migrations instead (`checkMigrationRecord`).
|
|
21
21
|
* Better Auth compares through the store's plain connections, without the app's query plugins.
|
|
22
22
|
*/
|
|
23
23
|
const authSchemaDrift = async (auth) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StoreModel } from "./store-model.js";
|
|
2
2
|
//#region src/better-auth/store/offline/name-changes.d.ts
|
|
3
|
-
/** How `after` changes what `before` has, one line each, the last steps aside; none when it only adds. */
|
|
4
|
-
export declare const nameChanges: (before: StoreModel, after: StoreModel) => string[];
|
|
3
|
+
/** How `after` changes what `before`, from `source`, has, one line each, the last steps aside; none when it only adds. */
|
|
4
|
+
export declare const nameChanges: (before: StoreModel, after: StoreModel, source?: string) => string[];
|
|
5
5
|
//#endregion
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
//#region src/better-auth/store/offline/name-changes.ts
|
|
2
|
-
const changes = (before, after, at) => {
|
|
2
|
+
const changes = (before, after, at, source) => {
|
|
3
3
|
if (after === void 0) return [`${at} is gone`];
|
|
4
|
-
if (typeof before !== "object" || before === null || typeof after !== "object" || after === null) return before === after ? [] : [`${at} is ${JSON.stringify(before)} in
|
|
5
|
-
return Object.entries(before).flatMap(([key, value]) => changes(value, after[key], at === "" ? key : `${at}.${key}
|
|
4
|
+
if (typeof before !== "object" || before === null || typeof after !== "object" || after === null) return before === after ? [] : [`${at} is ${JSON.stringify(before)} in ${source} and ${JSON.stringify(after)} now`];
|
|
5
|
+
return Object.entries(before).flatMap(([key, value]) => changes(value, after[key], at === "" ? key : `${at}.${key}`, source));
|
|
6
6
|
};
|
|
7
|
-
/** How `after` changes what `before` has, one line each, the last steps aside; none when it only adds. */
|
|
8
|
-
const nameChanges = (before, after) => {
|
|
7
|
+
/** How `after` changes what `before`, from `source`, has, one line each, the last steps aside; none when it only adds. */
|
|
8
|
+
const nameChanges = (before, after, source = "the snapshot") => {
|
|
9
9
|
const withoutSteps = (model) => ({
|
|
10
10
|
...model,
|
|
11
11
|
modules: Object.fromEntries(Object.entries(model.modules).map(([module, entry]) => [module, entry.tables]))
|
|
12
12
|
});
|
|
13
|
-
return changes(withoutSteps(before), withoutSteps(after), "");
|
|
13
|
+
return changes(withoutSteps(before), withoutSteps(after), "", source);
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
16
16
|
export { nameChanges };
|
package/dist/index.d.ts
CHANGED
|
@@ -105,7 +105,8 @@ import { capSocketMessages, honorSocketMessageCaps, socketMessageCapOf } from ".
|
|
|
105
105
|
import { appNameOver, defaultAppName, shownAppName } from "./app-name.js";
|
|
106
106
|
import { webManifestPath } from "./web-app/web-manifest-route.js";
|
|
107
107
|
import { readPlatformSignIns } from "./better-auth/platform-sign-in-env.js";
|
|
108
|
-
import { authSchemaMigration
|
|
108
|
+
import { authSchemaMigration } from "./better-auth/auth-schema.js";
|
|
109
|
+
import { checkMigrationRecord } from "./migration-record/check-record.js";
|
|
109
110
|
import { authSchemaDrift } from "./better-auth/store/drift.js";
|
|
110
111
|
import { checkResourcesOutsideAuthStore } from "./better-auth/store/resources-outside.js";
|
|
111
112
|
import { changesMigration, checkChanges, migrationCommand } from "./changes/capture-schema.js";
|
|
@@ -238,4 +239,4 @@ import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/ru
|
|
|
238
239
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
239
240
|
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
240
241
|
import { ResourceSource, configExports } from "./resource-source.js";
|
|
241
|
-
export { type AddVerifier, 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, type ConnectionListing, 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, type PersonalMailEntry, 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 RealtimeRelaySettings, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayListedMembers, 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, SenderAddressError, type SenderAddressErrorCode, SenderAddressNotFoundError, type SenderAddressState, type SenderAddressVerifier, 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 VerificationInput, type VerificationMessage, type VerificationOutcome, type VerifyInput, type VerifyTools, 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, appRelayChannels, 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, defaultRelayChannels, 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, gmailSettingsScope, 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, 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, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, 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 };
|
|
242
|
+
export { type AddVerifier, 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, type ConnectionListing, 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, type PersonalMailEntry, 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 RealtimeRelaySettings, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayListedMembers, 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, SenderAddressError, type SenderAddressErrorCode, SenderAddressNotFoundError, type SenderAddressState, type SenderAddressVerifier, 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 VerificationInput, type VerificationMessage, type VerificationOutcome, type VerifyInput, type VerifyTools, 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, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkMigrationRecord, 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, defaultRelayChannels, 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, gmailSettingsScope, 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, 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, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, 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
|
@@ -136,7 +136,8 @@ import { withTrustedApps } from "./better-auth/app-tokens.js";
|
|
|
136
136
|
import { betterAuthTokens } from "./better-auth/authenticator.js";
|
|
137
137
|
import { overSignIn } from "./better-auth/over-sign-in.js";
|
|
138
138
|
import { issueToken, maxTokenTtlSeconds } from "./better-auth/tokens.js";
|
|
139
|
-
import { authSchemaMigration
|
|
139
|
+
import { authSchemaMigration } from "./better-auth/auth-schema.js";
|
|
140
|
+
import { checkMigrationRecord } from "./migration-record/check-record.js";
|
|
140
141
|
import { authSchemaDrift } from "./better-auth/store/drift.js";
|
|
141
142
|
import { authStoreTables } from "./better-auth/auth-tables.js";
|
|
142
143
|
import { checkResourcesOutsideAuthStore } from "./better-auth/store/resources-outside.js";
|
|
@@ -177,4 +178,4 @@ import { defineEmail } from "./mail/define-email.js";
|
|
|
177
178
|
import { definePdf } from "./pdf/define-pdf.js";
|
|
178
179
|
import { startJobs } from "./jobs/runtime.js";
|
|
179
180
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
180
|
-
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, SenderAddressError, SenderAddressNotFoundError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi,
|
|
181
|
+
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, SenderAddressError, SenderAddressNotFoundError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, appRelayChannels, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkMigrationRecord, 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, defaultRelayChannels, 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, gmailSettingsScope, 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, 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, readRelaySwitch, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, realtimeSwitchVariable, realtimeVariables, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relaySettings, 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/internal.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
|
|
|
9
9
|
import { buildAuthenticator } from "./better-auth/authenticate-settings.js";
|
|
10
10
|
import { isOverSignIn } from "./better-auth/over-sign-in.js";
|
|
11
11
|
import { readOrigins } from "./better-auth/origins.js";
|
|
12
|
+
import { recordsRuntimeModel } from "./migration-record/check-record.js";
|
|
12
13
|
import { uncapturedMessage } from "./changes/capture-schema.js";
|
|
13
14
|
import { localFiles } from "./files/local-files.js";
|
|
14
15
|
import { s3Files } from "./files/s3-files.js";
|
|
@@ -27,4 +28,6 @@ import { LastSteps, StoreModel, latestSteps, storeModel, storeNamesList } from "
|
|
|
27
28
|
import { nameChanges } from "./better-auth/store/offline/name-changes.js";
|
|
28
29
|
import { offlineStepsMigration } from "./better-auth/store/offline/offline-steps.js";
|
|
29
30
|
import { LintedStep, lintSteps } from "./better-auth/store/steps/step-lint.js";
|
|
30
|
-
|
|
31
|
+
import { RecordModel, modelHash, runtimeModel } from "./migration-record/record-model.js";
|
|
32
|
+
import { AfterIndex, recordTable, recordTableSql } from "./migration-record/record-table.js";
|
|
33
|
+
export { type AfterIndex, type AppAuthInput, type AuthPlugins, type LastSteps, type LintedStep, type RecordModel, type StoreModel, type StoreNames, appAuthOptions, appDialect, appPool, betterAuthAuthenticator, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, createAuth, declaredJob, fileProviderOf, isOverSignIn, isSubscription, latestSteps, lintSteps, loadAuthPlugins, localFiles, longQueryPool, modelHash, nameChanges, offlineStepsMigration, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, runtimeModel, s3Files, settingsStoreNames, storeModel, storeNames, storeNamesList, uncapturedMessage, webhooksModule, workflowPlugins, workflowsModule };
|
package/dist/internal.js
CHANGED
|
@@ -15,6 +15,11 @@ import { checkStatusOptions } from "./status/options.js";
|
|
|
15
15
|
import { appPool, longQueryPool } from "./app-pool.js";
|
|
16
16
|
import { betterAuthAuthenticator } from "./better-auth/authenticator.js";
|
|
17
17
|
import { isOverSignIn } from "./better-auth/over-sign-in.js";
|
|
18
|
+
import { latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
|
|
19
|
+
import { modelHash, runtimeModel } from "./migration-record/record-model.js";
|
|
20
|
+
import { recordTable, recordTableSql } from "./migration-record/record-table.js";
|
|
21
|
+
import { nameChanges } from "./better-auth/store/offline/name-changes.js";
|
|
22
|
+
import { recordsRuntimeModel } from "./migration-record/check-record.js";
|
|
18
23
|
import { webhooksModule } from "./webhooks/table/webhooks-module.js";
|
|
19
24
|
import { workflowsModule } from "./workflows/workflows-module.js";
|
|
20
25
|
import { appDialect } from "./app-dialect.js";
|
|
@@ -23,8 +28,6 @@ import { buildAuthenticator } from "./better-auth/authenticate-settings.js";
|
|
|
23
28
|
import { captureNames } from "./changes/capture-names.js";
|
|
24
29
|
import { checkCallsOptions } from "./calls/calls-options.js";
|
|
25
30
|
import { settingsStoreNames } from "./better-auth/store/offline/settings-names.js";
|
|
26
|
-
import { latestSteps, storeModel, storeNamesList } from "./better-auth/store/offline/store-model.js";
|
|
27
|
-
import { nameChanges } from "./better-auth/store/offline/name-changes.js";
|
|
28
31
|
import { offlineStepsMigration } from "./better-auth/store/offline/offline-steps.js";
|
|
29
32
|
import { lintSteps } from "./better-auth/store/steps/step-lint.js";
|
|
30
|
-
export { appAuthOptions, appDialect, appPool, betterAuthAuthenticator, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, createAuth, declaredJob, fileProviderOf, isOverSignIn, isSubscription, latestSteps, lintSteps, loadAuthPlugins, localFiles, longQueryPool, nameChanges, offlineStepsMigration, readOrigins, readPasskeyDomain, refreshBuckets, s3Files, settingsStoreNames, storeModel, storeNames, storeNamesList, uncapturedMessage, webhooksModule, workflowPlugins, workflowsModule };
|
|
33
|
+
export { appAuthOptions, appDialect, appPool, betterAuthAuthenticator, bucketsRefreshes, buildAppAuth, buildAuth, buildAuthenticator, captureNames, checkCallsOptions, checkNotificationsOptions, checkStatusOptions, createAuth, declaredJob, fileProviderOf, isOverSignIn, isSubscription, latestSteps, lintSteps, loadAuthPlugins, localFiles, longQueryPool, modelHash, nameChanges, offlineStepsMigration, readOrigins, readPasskeyDomain, recordTable, recordTableSql, recordsRuntimeModel, refreshBuckets, runtimeModel, s3Files, settingsStoreNames, storeModel, storeNames, storeNamesList, uncapturedMessage, webhooksModule, workflowPlugins, workflowsModule };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminAuth } from "../better-auth/create-auth.js";
|
|
2
|
+
//#region src/migration-record/check-record.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Refuses to go on, before the server serves, while the database's record of migrations does not match what this
|
|
5
|
+
* version reads (`startupRefusal`). It reads the record once and nothing else; the server never migrates itself.
|
|
6
|
+
* Without sign-in it reads nothing, as the runtime reads nothing of the record then.
|
|
7
|
+
*/
|
|
8
|
+
export declare const checkMigrationRecord: (auth: AdminAuth | undefined, running: string) => Promise<void>;
|
|
9
|
+
/** Whether the database's record has a migration of the model this version reads with `auth`. */
|
|
10
|
+
export declare const recordsRuntimeModel: (auth: AdminAuth) => Promise<boolean>;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { plainStoreDb } from "../better-auth/store/store-db.js";
|
|
2
|
+
import { modelHash, runtimeModel } from "./record-model.js";
|
|
3
|
+
import { readRecordState, recordHasModel } from "./read-record.js";
|
|
4
|
+
import { startupRefusal } from "./startup-decision.js";
|
|
5
|
+
//#region src/migration-record/check-record.ts
|
|
6
|
+
/**
|
|
7
|
+
* Refuses to go on, before the server serves, while the database's record of migrations does not match what this
|
|
8
|
+
* version reads (`startupRefusal`). It reads the record once and nothing else; the server never migrates itself.
|
|
9
|
+
* Without sign-in it reads nothing, as the runtime reads nothing of the record then.
|
|
10
|
+
*/
|
|
11
|
+
const checkMigrationRecord = async (auth, running) => {
|
|
12
|
+
if (!auth) return;
|
|
13
|
+
const runtime = runtimeModel(auth);
|
|
14
|
+
const refusal = startupRefusal(runtime, await readRecordState(plainStoreDb(auth), modelHash(runtime)), running);
|
|
15
|
+
if (refusal) throw new Error(refusal);
|
|
16
|
+
};
|
|
17
|
+
/** Whether the database's record has a migration of the model this version reads with `auth`. */
|
|
18
|
+
const recordsRuntimeModel = (auth) => recordHasModel(plainStoreDb(auth), modelHash(runtimeModel(auth)));
|
|
19
|
+
//#endregion
|
|
20
|
+
export { checkMigrationRecord, recordsRuntimeModel };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { recordTable } from "./record-table.js";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
//#region src/migration-record/read-record.ts
|
|
4
|
+
/**
|
|
5
|
+
* The record as the startup decides on it, for the runtime's model hash `hash`: whether the table is there, then one
|
|
6
|
+
* query for the newest row, whether a row records `hash`, the rows not marked additive since the newest such row, and
|
|
7
|
+
* the unfinished rows.
|
|
8
|
+
*/
|
|
9
|
+
const readRecordState = async (db, hash) => {
|
|
10
|
+
const [found] = (await sql`select to_regclass(${recordTable}) is not null as found`.execute(db)).rows;
|
|
11
|
+
if (!found?.found) return {
|
|
12
|
+
newest: void 0,
|
|
13
|
+
matched: false,
|
|
14
|
+
notAdditiveSince: [],
|
|
15
|
+
unfinished: []
|
|
16
|
+
};
|
|
17
|
+
const table = sql.raw(recordTable);
|
|
18
|
+
const [row] = (await sql`
|
|
19
|
+
with matched as (select max(applied_at) as at from ${table} where model_hash = ${hash})
|
|
20
|
+
select
|
|
21
|
+
(select json_build_object('name', name, 'protobase_version', protobase_version, 'model', model, 'model_hash', model_hash) from ${table} order by applied_at desc limit 1) as newest,
|
|
22
|
+
(select at is not null from matched) as matched,
|
|
23
|
+
(select coalesce(json_agg(h.name order by h.applied_at), '[]') from ${table} h, matched where h.applied_at > matched.at and h.additive is not true) as not_additive,
|
|
24
|
+
(select coalesce(json_agg(json_build_object('name', h.name, 'after', h.physical -> 'after') order by h.applied_at), '[]') from ${table} h where h.completed_at is null) as unfinished`.execute(db)).rows;
|
|
25
|
+
const newest = row.newest;
|
|
26
|
+
return {
|
|
27
|
+
newest: newest ? {
|
|
28
|
+
name: newest.name,
|
|
29
|
+
version: newest.protobase_version,
|
|
30
|
+
model: newest.model,
|
|
31
|
+
hash: newest.model_hash
|
|
32
|
+
} : void 0,
|
|
33
|
+
matched: row.matched,
|
|
34
|
+
notAdditiveSince: row.not_additive,
|
|
35
|
+
unfinished: row.unfinished
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Whether the record has a row of the model hash `hash`: `false` without a record. */
|
|
39
|
+
const recordHasModel = async (db, hash) => {
|
|
40
|
+
const [found] = (await sql`select to_regclass(${recordTable}) is not null as found`.execute(db)).rows;
|
|
41
|
+
if (!found?.found) return false;
|
|
42
|
+
const [row] = (await sql`select exists (select from ${sql.raw(recordTable)} where model_hash = ${hash}) as has`.execute(db)).rows;
|
|
43
|
+
return row.has;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { readRecordState, recordHasModel };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StoreNamesSource } from "../better-auth/store/store-names.js";
|
|
2
|
+
import { StoreModel } from "../better-auth/store/offline/store-model.js";
|
|
3
|
+
//#region src/migration-record/record-model.d.ts
|
|
4
|
+
export type RecordModel = {
|
|
5
|
+
auth?: StoreModel;
|
|
6
|
+
};
|
|
7
|
+
/** The SHA-256 of the model as JSON, the same for the snapshot, the record and the runtime. */
|
|
8
|
+
export declare const modelHash: (model: RecordModel) => string;
|
|
9
|
+
/** The model this version of Protobase reads with the app's auth: its store at every step this version ships. */
|
|
10
|
+
export declare const runtimeModel: (auth: StoreNamesSource | undefined) => RecordModel;
|
|
11
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { storeNames } from "../better-auth/store/store-names.js";
|
|
2
|
+
import { latestSteps, storeModel } from "../better-auth/store/offline/store-model.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
//#region src/migration-record/record-model.ts
|
|
5
|
+
/** The SHA-256 of the model as JSON, the same for the snapshot, the record and the runtime. */
|
|
6
|
+
const modelHash = (model) => createHash("sha256").update(JSON.stringify(model)).digest("hex");
|
|
7
|
+
/** The model this version of Protobase reads with the app's auth: its store at every step this version ships. */
|
|
8
|
+
const runtimeModel = (auth) => {
|
|
9
|
+
if (!auth) return {};
|
|
10
|
+
const names = storeNames(auth);
|
|
11
|
+
return { auth: storeModel(names, latestSteps(names.names.modules)) };
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { modelHash, runtimeModel };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migration-record/record-table.d.ts
|
|
2
|
+
export declare const recordTable = "migrations.history";
|
|
3
|
+
/** The statements that make the record, each only when missing. */
|
|
4
|
+
export declare const recordTableSql = "create schema if not exists migrations;\ncreate table if not exists migrations.history (\n id text primary key,\n number integer,\n name text not null,\n protobase_version text not null,\n model jsonb not null,\n model_hash text not null,\n physical jsonb not null,\n additive boolean,\n sql_hash text,\n applied_at timestamptz not null default clock_timestamp(),\n completed_at timestamptz\n);\ncreate index if not exists history_applied_at on migrations.history (applied_at);";
|
|
5
|
+
/** An index a migration's `.after.sql` builds, which is unfinished until its `completed_at` is set. */
|
|
6
|
+
export type AfterIndex = {
|
|
7
|
+
index: string;
|
|
8
|
+
unique: boolean;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/migration-record/record-table.ts
|
|
2
|
+
const recordSchema = "migrations";
|
|
3
|
+
const recordTable = `${recordSchema}.history`;
|
|
4
|
+
/** The statements that make the record, each only when missing. */
|
|
5
|
+
const recordTableSql = `create schema if not exists ${recordSchema};
|
|
6
|
+
create table if not exists ${recordTable} (
|
|
7
|
+
id text primary key,
|
|
8
|
+
number integer,
|
|
9
|
+
name text not null,
|
|
10
|
+
protobase_version text not null,
|
|
11
|
+
model jsonb not null,
|
|
12
|
+
model_hash text not null,
|
|
13
|
+
physical jsonb not null,
|
|
14
|
+
additive boolean,
|
|
15
|
+
sql_hash text,
|
|
16
|
+
applied_at timestamptz not null default clock_timestamp(),
|
|
17
|
+
completed_at timestamptz
|
|
18
|
+
);
|
|
19
|
+
create index if not exists history_applied_at on ${recordTable} (applied_at);`;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { recordSchema, recordTable, recordTableSql };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { moduleSteps } from "../better-auth/store/steps/index.js";
|
|
2
|
+
import { modelHash } from "./record-model.js";
|
|
3
|
+
import { recordTable } from "./record-table.js";
|
|
4
|
+
import { nameChanges } from "../better-auth/store/offline/name-changes.js";
|
|
5
|
+
//#region src/migration-record/startup-decision.ts
|
|
6
|
+
const stepLabel = (module, step) => `step ${step} (${moduleSteps[module][step - 1]?.name ?? "unknown"})`;
|
|
7
|
+
/** What the runtime needs of the auth store that the database's lacks or has older, one line each. */
|
|
8
|
+
const authNeeds = (database, runtime) => {
|
|
9
|
+
if (!database) return ["the auth store is not recorded"];
|
|
10
|
+
return [...Object.entries(runtime.modules).flatMap(([module, entry]) => {
|
|
11
|
+
const had = database.modules[module]?.lastStep;
|
|
12
|
+
const needed = entry.lastStep;
|
|
13
|
+
if (had === void 0) return [`the auth store lacks the ${module} module, which this version needs at ${stepLabel(module, needed)}`];
|
|
14
|
+
return had < needed ? [`the auth store's ${module} module is at ${stepLabel(module, had)}, and this version needs ${stepLabel(module, needed)}`] : [];
|
|
15
|
+
}), ...nameChanges(database, runtime, "the database").map((change) => `the auth store's ${change}`)];
|
|
16
|
+
};
|
|
17
|
+
/** The unfinished migrations that keep the server from starting: a unique index, or an `.after.sql` of unknown shape. */
|
|
18
|
+
const unfinishedRefusals = (unfinished) => unfinished.flatMap(({ name, after }) => {
|
|
19
|
+
if (after === null) return [`${name} has not finished its .after.sql, whose indexes are not recorded`];
|
|
20
|
+
return after.filter(({ unique }) => unique).map(({ index }) => `${name} has not finished building the unique index ${index}`);
|
|
21
|
+
});
|
|
22
|
+
const waysOut = (matches, running) => `To bring the database up to ${running}, run \`protobase migrate --plan\` to see the migrations it will apply, then \`protobase migrate\`. Or run Protobase ${matches}, the version the database matches.`;
|
|
23
|
+
/**
|
|
24
|
+
* Why the server must not start on the database `state` describes, running `running` with the model `runtime`;
|
|
25
|
+
* `undefined` when it starts. A runtime that reads nothing of the record, sign-in off, always starts.
|
|
26
|
+
*/
|
|
27
|
+
const startupRefusal = (runtime, state, running) => {
|
|
28
|
+
if (!runtime.auth) return;
|
|
29
|
+
const unfinished = unfinishedRefusals(state.unfinished);
|
|
30
|
+
if (unfinished.length > 0) return `The database's migrations have not finished, so the server will not start: ${unfinished.join("; ")}. Run \`protobase migrate\` to finish them.`;
|
|
31
|
+
const { newest } = state;
|
|
32
|
+
if (!newest) return `The database has no migration recorded in ${recordTable}, so the server will not start: this version of Protobase needs the auth store. Write the migration that makes and records it with \`protobase migration\`, or with \`protobase auth migration\` for a store whose tables are there already, run \`protobase migrate --plan\` to see it, then \`protobase migrate\`.`;
|
|
33
|
+
if (newest.hash === modelHash(runtime)) return;
|
|
34
|
+
if (state.matched && state.notAdditiveSince.length === 0) return;
|
|
35
|
+
const needs = authNeeds(newest.model.auth, runtime.auth);
|
|
36
|
+
if (needs.length > 0) return `The database is behind Protobase ${running}, so the server will not start: ${needs.join("; ")}. ${waysOut(newest.version, running)}`;
|
|
37
|
+
return `The database is ahead of Protobase ${running}, so the server will not start: ${state.matched ? `it has migrations that are not additive since the one this version reads: ${state.notAdditiveSince.join(", ")}` : `its newest migration, ${newest.name}, records a model no migration of this version's records`}. ${waysOut(newest.version, running)}`;
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { startupRefusal };
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.129.0",
|
|
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.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/workflow-plugins": "0.
|
|
51
|
-
"@protobase/workflows": "0.
|
|
47
|
+
"@protobase/layout": "0.129.0",
|
|
48
|
+
"@protobase/query": "0.129.0",
|
|
49
|
+
"@protobase/schema": "0.129.0",
|
|
50
|
+
"@protobase/workflow-plugins": "0.129.0",
|
|
51
|
+
"@protobase/workflows": "0.129.0",
|
|
52
52
|
"@react-email/render": "^2.1.0",
|
|
53
53
|
"@react-pdf/primitives": "^4.4.0",
|
|
54
54
|
"@react-pdf/renderer": "^4.9.0",
|