mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
feat(server): add doc embedding switch for workspace (#11760)
fix AI-33
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "workspaces" ADD COLUMN "enable_doc_embedding" BOOLEAN NOT NULL DEFAULT true;
|
||||
@@ -1,3 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "postgresql"
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "postgresql"
|
||||
|
||||
@@ -104,14 +104,15 @@ model VerificationToken {
|
||||
}
|
||||
|
||||
model Workspace {
|
||||
id String @id @default(uuid()) @db.VarChar
|
||||
public Boolean
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
||||
id String @id @default(uuid()) @db.VarChar
|
||||
public Boolean
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
||||
// workspace level feature flags
|
||||
enableAi Boolean @default(true) @map("enable_ai")
|
||||
enableUrlPreview Boolean @default(false) @map("enable_url_preview")
|
||||
name String? @db.VarChar
|
||||
avatarKey String? @map("avatar_key") @db.VarChar
|
||||
enableAi Boolean @default(true) @map("enable_ai")
|
||||
enableUrlPreview Boolean @default(false) @map("enable_url_preview")
|
||||
enableDocEmbedding Boolean @default(true) @map("enable_doc_embedding")
|
||||
name String? @db.VarChar
|
||||
avatarKey String? @map("avatar_key") @db.VarChar
|
||||
|
||||
features WorkspaceFeature[]
|
||||
docs WorkspaceDoc[]
|
||||
|
||||
@@ -60,6 +60,7 @@ test('should update workspace', async t => {
|
||||
public: true,
|
||||
enableAi: true,
|
||||
enableUrlPreview: true,
|
||||
enableDocEmbedding: false,
|
||||
};
|
||||
await t.context.workspace.update(workspace.id, data);
|
||||
const workspace1 = await t.context.workspace.get(workspace.id);
|
||||
|
||||
@@ -88,6 +88,9 @@ export class WorkspaceType extends WorkspaceFeatureType {
|
||||
@Field({ description: 'Enable url previous when sharing' })
|
||||
enableUrlPreview!: boolean;
|
||||
|
||||
@Field({ description: 'Enable doc embedding' })
|
||||
enableDocEmbedding!: boolean;
|
||||
|
||||
@Field(() => [InviteUserType], {
|
||||
description: 'Members of workspace',
|
||||
})
|
||||
@@ -133,7 +136,7 @@ export class InvitationType {
|
||||
@InputType()
|
||||
export class UpdateWorkspaceInput extends PickType(
|
||||
PartialType(WorkspaceType),
|
||||
['public', 'enableAi', 'enableUrlPreview'],
|
||||
['public', 'enableAi', 'enableUrlPreview', 'enableDocEmbedding'],
|
||||
InputType
|
||||
) {
|
||||
@Field(() => ID)
|
||||
|
||||
@@ -16,7 +16,12 @@ declare global {
|
||||
export type { Workspace };
|
||||
export type UpdateWorkspaceInput = Pick<
|
||||
Partial<Workspace>,
|
||||
'public' | 'enableAi' | 'enableUrlPreview' | 'name' | 'avatarKey'
|
||||
| 'public'
|
||||
| 'enableAi'
|
||||
| 'enableUrlPreview'
|
||||
| 'enableDocEmbedding'
|
||||
| 'name'
|
||||
| 'avatarKey'
|
||||
>;
|
||||
|
||||
@Injectable()
|
||||
@@ -88,5 +93,10 @@ export class WorkspaceModel extends BaseModel {
|
||||
const workspace = await this.get(workspaceId);
|
||||
return workspace?.enableUrlPreview ?? false;
|
||||
}
|
||||
|
||||
async allowEmbedding(workspaceId: string) {
|
||||
const workspace = await this.get(workspaceId);
|
||||
return workspace?.enableDocEmbedding ?? false;
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
@@ -1493,6 +1493,9 @@ input UpdateWorkspaceInput {
|
||||
"""Enable AI"""
|
||||
enableAi: Boolean
|
||||
|
||||
"""Enable doc embedding"""
|
||||
enableDocEmbedding: Boolean
|
||||
|
||||
"""Enable url previous when sharing"""
|
||||
enableUrlPreview: Boolean
|
||||
id: ID!
|
||||
@@ -1702,6 +1705,9 @@ type WorkspaceType {
|
||||
"""Enable AI"""
|
||||
enableAi: Boolean!
|
||||
|
||||
"""Enable doc embedding"""
|
||||
enableDocEmbedding: Boolean!
|
||||
|
||||
"""Enable url previous when sharing"""
|
||||
enableUrlPreview: Boolean!
|
||||
histories(before: DateTime, guid: String!, take: Int): [DocHistoryType!]!
|
||||
|
||||
@@ -1595,6 +1595,7 @@ export const getWorkspaceConfigQuery = {
|
||||
workspace(id: $id) {
|
||||
enableAi
|
||||
enableUrlPreview
|
||||
enableDocEmbedding
|
||||
inviteLink {
|
||||
link
|
||||
expireTime
|
||||
@@ -1613,6 +1614,16 @@ export const setEnableAiMutation = {
|
||||
}`,
|
||||
};
|
||||
|
||||
export const setEnableDocEmbeddingMutation = {
|
||||
id: 'setEnableDocEmbeddingMutation' as const,
|
||||
op: 'setEnableDocEmbedding',
|
||||
query: `mutation setEnableDocEmbedding($id: ID!, $enableDocEmbedding: Boolean!) {
|
||||
updateWorkspace(input: {id: $id, enableDocEmbedding: $enableDocEmbedding}) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
export const setEnableUrlPreviewMutation = {
|
||||
id: 'setEnableUrlPreviewMutation' as const,
|
||||
op: 'setEnableUrlPreview',
|
||||
|
||||
@@ -2,6 +2,7 @@ query getWorkspaceConfig($id: String!) {
|
||||
workspace(id: $id) {
|
||||
enableAi
|
||||
enableUrlPreview
|
||||
enableDocEmbedding
|
||||
inviteLink {
|
||||
link
|
||||
expireTime
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
mutation setEnableDocEmbedding($id: ID!, $enableDocEmbedding: Boolean!) {
|
||||
updateWorkspace(input: { id: $id, enableDocEmbedding: $enableDocEmbedding }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -2006,6 +2006,8 @@ export interface UpdateUserSettingsInput {
|
||||
export interface UpdateWorkspaceInput {
|
||||
/** Enable AI */
|
||||
enableAi?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
/** Enable doc embedding */
|
||||
enableDocEmbedding?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
/** Enable url previous when sharing */
|
||||
enableUrlPreview?: InputMaybe<Scalars['Boolean']['input']>;
|
||||
id: Scalars['ID']['input'];
|
||||
@@ -2230,6 +2232,8 @@ export interface WorkspaceType {
|
||||
doc: DocType;
|
||||
/** Enable AI */
|
||||
enableAi: Scalars['Boolean']['output'];
|
||||
/** Enable doc embedding */
|
||||
enableDocEmbedding: Scalars['Boolean']['output'];
|
||||
/** Enable url previous when sharing */
|
||||
enableUrlPreview: Scalars['Boolean']['output'];
|
||||
histories: Array<DocHistoryType>;
|
||||
@@ -4107,6 +4111,7 @@ export type GetWorkspaceConfigQuery = {
|
||||
__typename?: 'WorkspaceType';
|
||||
enableAi: boolean;
|
||||
enableUrlPreview: boolean;
|
||||
enableDocEmbedding: boolean;
|
||||
inviteLink: {
|
||||
__typename?: 'InviteLink';
|
||||
link: string;
|
||||
@@ -4125,6 +4130,16 @@ export type SetEnableAiMutation = {
|
||||
updateWorkspace: { __typename?: 'WorkspaceType'; id: string };
|
||||
};
|
||||
|
||||
export type SetEnableDocEmbeddingMutationVariables = Exact<{
|
||||
id: Scalars['ID']['input'];
|
||||
enableDocEmbedding: Scalars['Boolean']['input'];
|
||||
}>;
|
||||
|
||||
export type SetEnableDocEmbeddingMutation = {
|
||||
__typename?: 'Mutation';
|
||||
updateWorkspace: { __typename?: 'WorkspaceType'; id: string };
|
||||
};
|
||||
|
||||
export type SetEnableUrlPreviewMutationVariables = Exact<{
|
||||
id: Scalars['ID']['input'];
|
||||
enableUrlPreview: Scalars['Boolean']['input'];
|
||||
@@ -4931,6 +4946,11 @@ export type Mutations =
|
||||
variables: SetEnableAiMutationVariables;
|
||||
response: SetEnableAiMutation;
|
||||
}
|
||||
| {
|
||||
name: 'setEnableDocEmbeddingMutation';
|
||||
variables: SetEnableDocEmbeddingMutationVariables;
|
||||
response: SetEnableDocEmbeddingMutation;
|
||||
}
|
||||
| {
|
||||
name: 'setEnableUrlPreviewMutation';
|
||||
variables: SetEnableUrlPreviewMutationVariables;
|
||||
|
||||
Reference in New Issue
Block a user