feat(nbstore): add cloud indexer storage (#12245)

close AF-2613
This commit is contained in:
fengmk2
2025-05-19 04:39:39 +00:00
parent a34c3ea200
commit 4e37a1322e
4 changed files with 174 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ import type { FlagInfo } from './types';
// const isNotStableBuild = BUILD_CONFIG.appBuildType !== 'stable';
const isDesktopEnvironment = BUILD_CONFIG.isElectron;
const isCanaryBuild = BUILD_CONFIG.appBuildType === 'canary';
const isBetaBuild = BUILD_CONFIG.appBuildType === 'beta';
const isMobile = BUILD_CONFIG.isMobileEdition;
export const AFFINE_FLAGS = {
@@ -317,6 +318,13 @@ export const AFFINE_FLAGS = {
configurable: isCanaryBuild,
defaultState: false,
},
enable_cloud_indexer: {
category: 'affine',
displayName: 'Enable Cloud Indexer',
description: 'Use cloud indexer to search docs',
configurable: isBetaBuild || isCanaryBuild,
defaultState: false,
},
} satisfies { [key in string]: FlagInfo };
// oxlint-disable-next-line no-redeclare

View File

@@ -1,3 +1,4 @@
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
import { DebugLogger } from '@affine/debug';
import {
createWorkspaceMutation,
@@ -85,6 +86,7 @@ const logger = new DebugLogger('affine:cloud-workspace-flavour-provider');
class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
private readonly authService: AuthService;
private readonly graphqlService: GraphQLService;
private readonly featureFlagService: FeatureFlagService;
private readonly unsubscribeAccountChanged: () => void;
constructor(
@@ -93,6 +95,7 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
) {
this.authService = server.scope.get(AuthService);
this.graphqlService = server.scope.get(GraphQLService);
this.featureFlagService = server.scope.get(FeatureFlagService);
this.unsubscribeAccountChanged = this.server.scope.eventBus.on(
AccountChanged,
() => {
@@ -474,14 +477,24 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
id: `${this.flavour}:${workspaceId}`,
},
},
indexer: {
name: 'IndexedDBIndexerStorage',
opts: {
flavour: this.flavour,
type: 'workspace',
id: workspaceId,
},
},
indexer: this.featureFlagService.flags.enable_cloud_indexer.value
? {
name: 'CloudIndexerStorage',
opts: {
flavour: this.flavour,
type: 'workspace',
id: workspaceId,
serverBaseUrl: this.server.serverMetadata.baseUrl,
},
}
: {
name: 'IndexedDBIndexerStorage',
opts: {
flavour: this.flavour,
type: 'workspace',
id: workspaceId,
},
},
indexerSync: {
name: 'IndexedDBIndexerSyncStorage',
opts: {