mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-07 04:20:11 +08:00
refactor(native): cache & job runtime (#15139)
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
CREATE TABLE "runtime_states" (
|
||||
"purpose" TEXT NOT NULL,
|
||||
"token_hash" TEXT NOT NULL,
|
||||
"lookup_key" TEXT,
|
||||
"payload" JSONB NOT NULL,
|
||||
"attempts" INTEGER NOT NULL DEFAULT 0,
|
||||
"consumed_at" TIMESTAMPTZ(3),
|
||||
"expires_at" TIMESTAMPTZ(3) NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "runtime_states_pkey" PRIMARY KEY ("purpose", "token_hash")
|
||||
);
|
||||
|
||||
CREATE INDEX "runtime_states_lookup_idx" ON "runtime_states"("purpose", "lookup_key") WHERE "lookup_key" IS NOT NULL AND "consumed_at" IS NULL;
|
||||
CREATE INDEX "runtime_states_expires_at_idx" ON "runtime_states"("expires_at");
|
||||
|
||||
CREATE TABLE "runtime_gates" (
|
||||
"key" TEXT NOT NULL,
|
||||
"expires_at" TIMESTAMPTZ(3) NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "runtime_gates_pkey" PRIMARY KEY ("key")
|
||||
);
|
||||
|
||||
CREATE INDEX "runtime_gates_expires_at_idx" ON "runtime_gates"("expires_at");
|
||||
|
||||
CREATE TABLE "runtime_leases" (
|
||||
"key" TEXT NOT NULL,
|
||||
"owner" TEXT NOT NULL,
|
||||
"fencing_token" BIGINT NOT NULL,
|
||||
"expires_at" TIMESTAMPTZ(3) NOT NULL,
|
||||
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "runtime_leases_pkey" PRIMARY KEY ("key")
|
||||
);
|
||||
|
||||
CREATE INDEX "runtime_leases_expires_at_idx" ON "runtime_leases"("expires_at");
|
||||
@@ -2,6 +2,7 @@ import serverNativeModule, {
|
||||
type ActionEvent as NativeActionEventContract,
|
||||
type ActionRuntimeInput as NativeActionRuntimeInputContract,
|
||||
type AssertSafeUrlRequest,
|
||||
type BackendRuntimeHealth,
|
||||
type BuiltInPromptRenderContract,
|
||||
type BuiltInPromptSessionContract,
|
||||
type BuiltInPromptSpec,
|
||||
@@ -45,6 +46,22 @@ import serverNativeModule, {
|
||||
type RequestedModelMatchResponse,
|
||||
type ResolvedEntitlement,
|
||||
type ResolveEntitlementInput,
|
||||
type RuntimeBlobCleanupResult,
|
||||
type RuntimeBlobCompleteResult,
|
||||
type RuntimeByokLocalLeaseRecord,
|
||||
type RuntimeDocCompactionResult,
|
||||
type RuntimeMagicLinkOtpConsumeResult,
|
||||
type RuntimeMultipartUploadInit,
|
||||
type RuntimeMultipartUploadPart,
|
||||
type RuntimeObjectGetResult,
|
||||
type RuntimeObjectListEntry,
|
||||
type RuntimeObjectMetadata,
|
||||
type RuntimeObjectStorageHealth,
|
||||
type RuntimeObjectStoragePutOptions,
|
||||
type RuntimePresignedObjectRequest,
|
||||
type RuntimeVerificationTokenRecord,
|
||||
type RuntimeWorkspaceInviteLinkRecord,
|
||||
type RuntimeWorkspaceStatsDailyRecalibrationResult,
|
||||
type SafeFetchRequest,
|
||||
type SafeFetchResponse,
|
||||
type Tokenizer,
|
||||
@@ -52,6 +69,7 @@ import serverNativeModule, {
|
||||
|
||||
export type {
|
||||
AssertSafeUrlRequest,
|
||||
BackendRuntimeHealth,
|
||||
CapabilityAttachmentContract,
|
||||
CapabilityModelCapability,
|
||||
CommandResponse,
|
||||
@@ -73,6 +91,22 @@ export type {
|
||||
RemoteMimeTypeRequest,
|
||||
ResolvedEntitlement,
|
||||
ResolveEntitlementInput,
|
||||
RuntimeBlobCleanupResult,
|
||||
RuntimeBlobCompleteResult,
|
||||
RuntimeByokLocalLeaseRecord,
|
||||
RuntimeDocCompactionResult,
|
||||
RuntimeMagicLinkOtpConsumeResult,
|
||||
RuntimeMultipartUploadInit,
|
||||
RuntimeMultipartUploadPart,
|
||||
RuntimeObjectGetResult,
|
||||
RuntimeObjectListEntry,
|
||||
RuntimeObjectMetadata,
|
||||
RuntimeObjectStorageHealth,
|
||||
RuntimeObjectStoragePutOptions,
|
||||
RuntimePresignedObjectRequest,
|
||||
RuntimeVerificationTokenRecord,
|
||||
RuntimeWorkspaceInviteLinkRecord,
|
||||
RuntimeWorkspaceStatsDailyRecalibrationResult,
|
||||
SafeFetchRequest,
|
||||
SafeFetchResponse,
|
||||
};
|
||||
@@ -180,6 +214,7 @@ export const readAllDocIdsFromRootDoc =
|
||||
export const AFFINE_PRO_PUBLIC_KEY = serverNativeModule.AFFINE_PRO_PUBLIC_KEY;
|
||||
export const AFFINE_PRO_LICENSE_AES_KEY =
|
||||
serverNativeModule.AFFINE_PRO_LICENSE_AES_KEY;
|
||||
export const BackendRuntime = serverNativeModule.BackendRuntime;
|
||||
|
||||
export type PermissionWorkspaceRole = 'external' | 'member' | 'admin' | 'owner';
|
||||
export type PermissionDocRole =
|
||||
|
||||
Reference in New Issue
Block a user