mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
@@ -0,0 +1,56 @@
|
|||||||
|
# Snapshot report for `src/__tests__/models/copilot-workspace.spec.ts`
|
||||||
|
|
||||||
|
The actual snapshot is saved in `copilot-workspace.spec.ts.snap`.
|
||||||
|
|
||||||
|
Generated by [AVA](https://avajs.dev).
|
||||||
|
|
||||||
|
## should manage copilot workspace ignored docs
|
||||||
|
|
||||||
|
> should add ignored doc
|
||||||
|
|
||||||
|
1
|
||||||
|
|
||||||
|
> should return added doc
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
docId: 'doc1',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
> should return ignored docs in workspace
|
||||||
|
|
||||||
|
[
|
||||||
|
'doc1',
|
||||||
|
]
|
||||||
|
|
||||||
|
> should not add ignored doc again
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
docId: 'doc1',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
> should add new ignored doc
|
||||||
|
|
||||||
|
2
|
||||||
|
|
||||||
|
> should add ignored doc
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
docId: 'new_doc',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
docId: 'doc1',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
> should remove ignored doc
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
docId: 'new_doc',
|
||||||
|
},
|
||||||
|
]
|
||||||
Binary file not shown.
@@ -6,6 +6,7 @@ import { CopilotWorkspaceConfigModel } from '../../models/copilot-workspace';
|
|||||||
import { UserModel } from '../../models/user';
|
import { UserModel } from '../../models/user';
|
||||||
import { WorkspaceModel } from '../../models/workspace';
|
import { WorkspaceModel } from '../../models/workspace';
|
||||||
import { createTestingModule, type TestingModule } from '../utils';
|
import { createTestingModule, type TestingModule } from '../utils';
|
||||||
|
import { cleanObject } from '../utils/copilot';
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
config: Config;
|
config: Config;
|
||||||
@@ -56,16 +57,16 @@ test('should manage copilot workspace ignored docs', async t => {
|
|||||||
workspace.id,
|
workspace.id,
|
||||||
[docId]
|
[docId]
|
||||||
);
|
);
|
||||||
t.is(count, 1, 'should add ignored doc');
|
t.snapshot(count, 'should add ignored doc');
|
||||||
|
|
||||||
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
||||||
t.deepEqual(ret, [docId], 'should return added doc');
|
t.snapshot(cleanObject(ret), 'should return added doc');
|
||||||
|
|
||||||
const check = await t.context.copilotWorkspace.checkIgnoredDocs(
|
const check = await t.context.copilotWorkspace.checkIgnoredDocs(
|
||||||
workspace.id,
|
workspace.id,
|
||||||
[docId]
|
[docId]
|
||||||
);
|
);
|
||||||
t.deepEqual(check, [docId], 'should return ignored docs in workspace');
|
t.snapshot(check, 'should return ignored docs in workspace');
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -76,7 +77,7 @@ test('should manage copilot workspace ignored docs', async t => {
|
|||||||
t.is(count, 1, 'should not add ignored doc again');
|
t.is(count, 1, 'should not add ignored doc again');
|
||||||
|
|
||||||
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
||||||
t.deepEqual(ret, [docId], 'should not add ignored doc again');
|
t.snapshot(cleanObject(ret), 'should not add ignored doc again');
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -84,10 +85,10 @@ test('should manage copilot workspace ignored docs', async t => {
|
|||||||
workspace.id,
|
workspace.id,
|
||||||
['new_doc']
|
['new_doc']
|
||||||
);
|
);
|
||||||
t.is(count, 2, 'should add new ignored doc');
|
t.snapshot(count, 'should add new ignored doc');
|
||||||
|
|
||||||
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
||||||
t.deepEqual(ret, [docId, 'new_doc'], 'should add ignored doc');
|
t.snapshot(cleanObject(ret), 'should add ignored doc');
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -98,7 +99,7 @@ test('should manage copilot workspace ignored docs', async t => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
|
||||||
t.deepEqual(ret, ['new_doc'], 'should remove ignored doc');
|
t.snapshot(cleanObject(ret), 'should remove ignored doc');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { Transactional } from '@nestjs-cls/transactional';
|
import { Transactional } from '@nestjs-cls/transactional';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
|
|
||||||
|
import { PaginationInput } from '../base';
|
||||||
import { BaseModel } from './base';
|
import { BaseModel } from './base';
|
||||||
import type {
|
import type {
|
||||||
CopilotWorkspaceFile,
|
CopilotWorkspaceFile,
|
||||||
@@ -22,7 +23,7 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
|||||||
) {
|
) {
|
||||||
const removed = new Set(remove);
|
const removed = new Set(remove);
|
||||||
const ignored = await this.listIgnoredDocs(workspaceId).then(
|
const ignored = await this.listIgnoredDocs(workspaceId).then(
|
||||||
r => new Set(r.filter(id => !removed.has(id)))
|
r => new Set(r.map(r => r.docId).filter(id => !removed.has(id)))
|
||||||
);
|
);
|
||||||
const added = add.filter(id => !ignored.has(id));
|
const added = add.filter(id => !ignored.has(id));
|
||||||
|
|
||||||
@@ -49,22 +50,40 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
|||||||
return added.length + ignored.size;
|
return added.length + ignored.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
async listIgnoredDocs(workspaceId: string): Promise<string[]> {
|
async listIgnoredDocs(
|
||||||
|
workspaceId: string,
|
||||||
|
options?: {
|
||||||
|
includeRead?: boolean;
|
||||||
|
} & PaginationInput
|
||||||
|
): Promise<{ docId: string; createdAt: Date }[]> {
|
||||||
const row = await this.db.aiWorkspaceIgnoredDocs.findMany({
|
const row = await this.db.aiWorkspaceIgnoredDocs.findMany({
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
docId: true,
|
docId: true,
|
||||||
|
createdAt: true,
|
||||||
|
},
|
||||||
|
orderBy: { createdAt: 'desc' },
|
||||||
|
skip: options?.offset,
|
||||||
|
take: options?.first,
|
||||||
|
});
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
async countIgnoredDocs(workspaceId: string): Promise<number> {
|
||||||
|
const count = await this.db.aiWorkspaceIgnoredDocs.count({
|
||||||
|
where: {
|
||||||
|
workspaceId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return row.map(r => r.docId);
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional()
|
@Transactional()
|
||||||
async checkIgnoredDocs(workspaceId: string, docIds: string[]) {
|
async checkIgnoredDocs(workspaceId: string, docIds: string[]) {
|
||||||
const ignored = await this.listIgnoredDocs(workspaceId).then(
|
const ignored = await this.listIgnoredDocs(workspaceId).then(
|
||||||
r => new Set(r)
|
r => new Set(r.map(r => r.docId))
|
||||||
);
|
);
|
||||||
|
|
||||||
return docIds.filter(id => ignored.has(id));
|
return docIds.filter(id => ignored.has(id));
|
||||||
@@ -133,16 +152,31 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async listWorkspaceFiles(
|
async listWorkspaceFiles(
|
||||||
workspaceId: string
|
workspaceId: string,
|
||||||
|
options?: {
|
||||||
|
includeRead?: boolean;
|
||||||
|
} & PaginationInput
|
||||||
): Promise<CopilotWorkspaceFile[]> {
|
): Promise<CopilotWorkspaceFile[]> {
|
||||||
const files = await this.db.aiWorkspaceFiles.findMany({
|
const files = await this.db.aiWorkspaceFiles.findMany({
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
},
|
},
|
||||||
|
orderBy: { createdAt: 'desc' },
|
||||||
|
skip: options?.offset,
|
||||||
|
take: options?.first,
|
||||||
});
|
});
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async countWorkspaceFiles(workspaceId: string): Promise<number> {
|
||||||
|
const count = await this.db.aiWorkspaceFiles.count({
|
||||||
|
where: {
|
||||||
|
workspaceId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
async matchWorkspaceFileEmbedding(
|
async matchWorkspaceFileEmbedding(
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
embedding: number[],
|
embedding: number[],
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
Resolver,
|
Resolver,
|
||||||
} from '@nestjs/graphql';
|
} from '@nestjs/graphql';
|
||||||
import type { Request } from 'express';
|
import type { Request } from 'express';
|
||||||
import { SafeIntResolver } from 'graphql-scalars';
|
|
||||||
import GraphQLUpload, {
|
import GraphQLUpload, {
|
||||||
type FileUpload,
|
type FileUpload,
|
||||||
} from 'graphql-upload/GraphQLUpload.mjs';
|
} from 'graphql-upload/GraphQLUpload.mjs';
|
||||||
@@ -19,16 +18,22 @@ import {
|
|||||||
CopilotEmbeddingUnavailable,
|
CopilotEmbeddingUnavailable,
|
||||||
CopilotFailedToAddWorkspaceFileEmbedding,
|
CopilotFailedToAddWorkspaceFileEmbedding,
|
||||||
Mutex,
|
Mutex,
|
||||||
|
paginate,
|
||||||
|
PaginationInput,
|
||||||
TooManyRequest,
|
TooManyRequest,
|
||||||
UserFriendlyError,
|
UserFriendlyError,
|
||||||
} from '../../../base';
|
} from '../../../base';
|
||||||
import { CurrentUser } from '../../../core/auth';
|
import { CurrentUser } from '../../../core/auth';
|
||||||
import { AccessController } from '../../../core/permission';
|
import { AccessController } from '../../../core/permission';
|
||||||
import { WorkspaceType } from '../../../core/workspaces';
|
import { WorkspaceType } from '../../../core/workspaces';
|
||||||
import { CopilotWorkspaceFile, Models } from '../../../models';
|
|
||||||
import { COPILOT_LOCKER } from '../resolver';
|
import { COPILOT_LOCKER } from '../resolver';
|
||||||
import { MAX_EMBEDDABLE_SIZE } from '../types';
|
import { MAX_EMBEDDABLE_SIZE } from '../types';
|
||||||
import { CopilotWorkspaceService } from './service';
|
import { CopilotWorkspaceService } from './service';
|
||||||
|
import {
|
||||||
|
CopilotWorkspaceFileType,
|
||||||
|
PaginatedCopilotWorkspaceFileType,
|
||||||
|
PaginatedIgnoredDocsType,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
@ObjectType('CopilotWorkspaceConfig')
|
@ObjectType('CopilotWorkspaceConfig')
|
||||||
export class CopilotWorkspaceConfigType {
|
export class CopilotWorkspaceConfigType {
|
||||||
@@ -36,27 +41,6 @@ export class CopilotWorkspaceConfigType {
|
|||||||
workspaceId!: string;
|
workspaceId!: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ObjectType('CopilotWorkspaceFile')
|
|
||||||
export class CopilotWorkspaceFileType implements CopilotWorkspaceFile {
|
|
||||||
@Field(() => String)
|
|
||||||
workspaceId!: string;
|
|
||||||
|
|
||||||
@Field(() => String)
|
|
||||||
fileId!: string;
|
|
||||||
|
|
||||||
@Field(() => String)
|
|
||||||
fileName!: string;
|
|
||||||
|
|
||||||
@Field(() => String)
|
|
||||||
mimeType!: string;
|
|
||||||
|
|
||||||
@Field(() => SafeIntResolver)
|
|
||||||
size!: number;
|
|
||||||
|
|
||||||
@Field(() => Date)
|
|
||||||
createdAt!: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workspace embedding config resolver
|
* Workspace embedding config resolver
|
||||||
* Public apis rate limit: 10 req/m
|
* Public apis rate limit: 10 req/m
|
||||||
@@ -86,18 +70,24 @@ export class CopilotWorkspaceEmbeddingResolver {
|
|||||||
export class CopilotWorkspaceEmbeddingConfigResolver {
|
export class CopilotWorkspaceEmbeddingConfigResolver {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly ac: AccessController,
|
private readonly ac: AccessController,
|
||||||
private readonly models: Models,
|
|
||||||
private readonly mutex: Mutex,
|
private readonly mutex: Mutex,
|
||||||
private readonly copilotWorkspace: CopilotWorkspaceService
|
private readonly copilotWorkspace: CopilotWorkspaceService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ResolveField(() => [String], {
|
@ResolveField(() => PaginatedIgnoredDocsType, {
|
||||||
complexity: 2,
|
complexity: 2,
|
||||||
})
|
})
|
||||||
async ignoredDocs(
|
async ignoredDocs(
|
||||||
@Parent() config: CopilotWorkspaceConfigType
|
@Parent() config: CopilotWorkspaceConfigType,
|
||||||
): Promise<string[]> {
|
@Args('pagination', PaginationInput.decode) pagination: PaginationInput
|
||||||
return this.models.copilotWorkspace.listIgnoredDocs(config.workspaceId);
|
): Promise<PaginatedIgnoredDocsType> {
|
||||||
|
const [ignoredDocs, totalCount] =
|
||||||
|
await this.copilotWorkspace.listIgnoredDocs(
|
||||||
|
config.workspaceId,
|
||||||
|
pagination
|
||||||
|
);
|
||||||
|
|
||||||
|
return paginate(ignoredDocs, 'createdAt', pagination, totalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => Number, {
|
@Mutation(() => Number, {
|
||||||
@@ -118,20 +108,26 @@ export class CopilotWorkspaceEmbeddingConfigResolver {
|
|||||||
.user(user.id)
|
.user(user.id)
|
||||||
.workspace(workspaceId)
|
.workspace(workspaceId)
|
||||||
.assert('Workspace.Settings.Update');
|
.assert('Workspace.Settings.Update');
|
||||||
return await this.models.copilotWorkspace.updateIgnoredDocs(
|
return await this.copilotWorkspace.updateIgnoredDocs(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
add,
|
add,
|
||||||
remove
|
remove
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResolveField(() => [CopilotWorkspaceFileType], {
|
@ResolveField(() => PaginatedCopilotWorkspaceFileType, {
|
||||||
complexity: 2,
|
complexity: 2,
|
||||||
})
|
})
|
||||||
async files(
|
async files(
|
||||||
@Parent() config: CopilotWorkspaceConfigType
|
@Parent() config: CopilotWorkspaceConfigType,
|
||||||
): Promise<CopilotWorkspaceFileType[]> {
|
@Args('pagination', PaginationInput.decode) pagination: PaginationInput
|
||||||
return this.models.copilotWorkspace.listWorkspaceFiles(config.workspaceId);
|
): Promise<PaginatedCopilotWorkspaceFileType> {
|
||||||
|
const [files, totalCount] = await this.copilotWorkspace.listWorkspaceFiles(
|
||||||
|
config.workspaceId,
|
||||||
|
pagination
|
||||||
|
);
|
||||||
|
|
||||||
|
return paginate(files, 'createdAt', pagination, totalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => CopilotWorkspaceFileType, {
|
@Mutation(() => CopilotWorkspaceFileType, {
|
||||||
@@ -210,9 +206,6 @@ export class CopilotWorkspaceEmbeddingConfigResolver {
|
|||||||
.workspace(workspaceId)
|
.workspace(workspaceId)
|
||||||
.assert('Workspace.Settings.Update');
|
.assert('Workspace.Settings.Update');
|
||||||
|
|
||||||
return await this.models.copilotWorkspace.removeWorkspaceFile(
|
return await this.copilotWorkspace.removeWorkspaceFile(workspaceId, fileId);
|
||||||
workspaceId,
|
|
||||||
fileId
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,31 +2,11 @@ import { createHash } from 'node:crypto';
|
|||||||
|
|
||||||
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
||||||
|
|
||||||
import { FileUpload, JobQueue } from '../../../base';
|
import { FileUpload, JobQueue, PaginationInput } from '../../../base';
|
||||||
import { Models } from '../../../models';
|
import { Models } from '../../../models';
|
||||||
import { CopilotStorage } from '../storage';
|
import { CopilotStorage } from '../storage';
|
||||||
import { readStream } from '../utils';
|
import { readStream } from '../utils';
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface Events {
|
|
||||||
'workspace.file.embedding.finished': {
|
|
||||||
jobId: string;
|
|
||||||
};
|
|
||||||
'workspace.file.embedding.failed': {
|
|
||||||
jobId: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
interface Jobs {
|
|
||||||
'copilot.workspace.embedding.files': {
|
|
||||||
userId: string;
|
|
||||||
workspaceId: string;
|
|
||||||
blobId: string;
|
|
||||||
fileId: string;
|
|
||||||
fileName: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
||||||
private supportEmbedding = false;
|
private supportEmbedding = false;
|
||||||
@@ -49,6 +29,30 @@ export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
|||||||
return this.supportEmbedding;
|
return this.supportEmbedding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateIgnoredDocs(
|
||||||
|
workspaceId: string,
|
||||||
|
add?: string[],
|
||||||
|
remove?: string[]
|
||||||
|
) {
|
||||||
|
return await this.models.copilotWorkspace.updateIgnoredDocs(
|
||||||
|
workspaceId,
|
||||||
|
add,
|
||||||
|
remove
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async listIgnoredDocs(
|
||||||
|
workspaceId: string,
|
||||||
|
pagination?: {
|
||||||
|
includeRead?: boolean;
|
||||||
|
} & PaginationInput
|
||||||
|
) {
|
||||||
|
return await Promise.all([
|
||||||
|
this.models.copilotWorkspace.listIgnoredDocs(workspaceId, pagination),
|
||||||
|
this.models.copilotWorkspace.countIgnoredDocs(workspaceId),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
async addWorkspaceFile(
|
async addWorkspaceFile(
|
||||||
userId: string,
|
userId: string,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
@@ -70,6 +74,18 @@ export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
|||||||
return await this.models.copilotWorkspace.getFile(workspaceId, fileId);
|
return await this.models.copilotWorkspace.getFile(workspaceId, fileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async listWorkspaceFiles(
|
||||||
|
workspaceId: string,
|
||||||
|
pagination?: {
|
||||||
|
includeRead?: boolean;
|
||||||
|
} & PaginationInput
|
||||||
|
) {
|
||||||
|
return await Promise.all([
|
||||||
|
this.models.copilotWorkspace.listWorkspaceFiles(workspaceId, pagination),
|
||||||
|
this.models.copilotWorkspace.countIgnoredDocs(workspaceId),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
async addWorkspaceFileEmbeddingQueue(
|
async addWorkspaceFileEmbeddingQueue(
|
||||||
file: Jobs['copilot.workspace.embedding.files']
|
file: Jobs['copilot.workspace.embedding.files']
|
||||||
) {
|
) {
|
||||||
@@ -84,4 +100,11 @@ export class CopilotWorkspaceService implements OnApplicationBootstrap {
|
|||||||
fileName,
|
fileName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeWorkspaceFile(workspaceId: string, fileId: string) {
|
||||||
|
return await this.models.copilotWorkspace.removeWorkspaceFile(
|
||||||
|
workspaceId,
|
||||||
|
fileId
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { Field, ObjectType } from '@nestjs/graphql';
|
||||||
|
import { SafeIntResolver } from 'graphql-scalars';
|
||||||
|
|
||||||
|
import { Paginated } from '../../../base';
|
||||||
|
import { CopilotWorkspaceFile } from '../../../models';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Events {
|
||||||
|
'workspace.file.embedding.finished': {
|
||||||
|
jobId: string;
|
||||||
|
};
|
||||||
|
'workspace.file.embedding.failed': {
|
||||||
|
jobId: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
interface Jobs {
|
||||||
|
'copilot.workspace.embedding.files': {
|
||||||
|
userId: string;
|
||||||
|
workspaceId: string;
|
||||||
|
blobId: string;
|
||||||
|
fileId: string;
|
||||||
|
fileName: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ObjectType('CopilotWorkspaceIgnoredDoc')
|
||||||
|
export class CopilotWorkspaceIgnoredDocType {
|
||||||
|
@Field(() => String)
|
||||||
|
docId!: string;
|
||||||
|
|
||||||
|
@Field(() => Date)
|
||||||
|
createdAt!: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class PaginatedIgnoredDocsType extends Paginated(
|
||||||
|
CopilotWorkspaceIgnoredDocType
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@ObjectType('CopilotWorkspaceFile')
|
||||||
|
export class CopilotWorkspaceFileType implements CopilotWorkspaceFile {
|
||||||
|
@Field(() => String)
|
||||||
|
workspaceId!: string;
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
fileId!: string;
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
fileName!: string;
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
mimeType!: string;
|
||||||
|
|
||||||
|
@Field(() => SafeIntResolver)
|
||||||
|
size!: number;
|
||||||
|
|
||||||
|
@Field(() => Date)
|
||||||
|
createdAt!: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class PaginatedCopilotWorkspaceFileType extends Paginated(
|
||||||
|
CopilotWorkspaceFileType
|
||||||
|
) {}
|
||||||
@@ -273,8 +273,8 @@ type CopilotSessionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CopilotWorkspaceConfig {
|
type CopilotWorkspaceConfig {
|
||||||
files: [CopilotWorkspaceFile!]!
|
files(pagination: PaginationInput!): PaginatedCopilotWorkspaceFileType!
|
||||||
ignoredDocs: [String!]!
|
ignoredDocs(pagination: PaginationInput!): PaginatedIgnoredDocsType!
|
||||||
workspaceId: String!
|
workspaceId: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +287,21 @@ type CopilotWorkspaceFile {
|
|||||||
workspaceId: String!
|
workspaceId: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CopilotWorkspaceFileTypeEdge {
|
||||||
|
cursor: String!
|
||||||
|
node: CopilotWorkspaceFile!
|
||||||
|
}
|
||||||
|
|
||||||
|
type CopilotWorkspaceIgnoredDoc {
|
||||||
|
createdAt: DateTime!
|
||||||
|
docId: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type CopilotWorkspaceIgnoredDocTypeEdge {
|
||||||
|
cursor: String!
|
||||||
|
node: CopilotWorkspaceIgnoredDoc!
|
||||||
|
}
|
||||||
|
|
||||||
input CreateChatMessageInput {
|
input CreateChatMessageInput {
|
||||||
attachments: [String!]
|
attachments: [String!]
|
||||||
blobs: [Upload!]
|
blobs: [Upload!]
|
||||||
@@ -1149,12 +1164,24 @@ type PageInfo {
|
|||||||
startCursor: String
|
startCursor: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PaginatedCopilotWorkspaceFileType {
|
||||||
|
edges: [CopilotWorkspaceFileTypeEdge!]!
|
||||||
|
pageInfo: PageInfo!
|
||||||
|
totalCount: Int!
|
||||||
|
}
|
||||||
|
|
||||||
type PaginatedGrantedDocUserType {
|
type PaginatedGrantedDocUserType {
|
||||||
edges: [GrantedDocUserTypeEdge!]!
|
edges: [GrantedDocUserTypeEdge!]!
|
||||||
pageInfo: PageInfo!
|
pageInfo: PageInfo!
|
||||||
totalCount: Int!
|
totalCount: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PaginatedIgnoredDocsType {
|
||||||
|
edges: [CopilotWorkspaceIgnoredDocTypeEdge!]!
|
||||||
|
pageInfo: PageInfo!
|
||||||
|
totalCount: Int!
|
||||||
|
}
|
||||||
|
|
||||||
type PaginatedNotificationObjectType {
|
type PaginatedNotificationObjectType {
|
||||||
edges: [NotificationObjectTypeEdge!]!
|
edges: [NotificationObjectTypeEdge!]!
|
||||||
pageInfo: PageInfo!
|
pageInfo: PageInfo!
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
query getWorkspaceEmbeddingFiles($workspaceId: String!, $pagination: PaginationInput!) {
|
||||||
|
workspace(id: $workspaceId) {
|
||||||
|
embedding {
|
||||||
|
files(pagination: $pagination) {
|
||||||
|
totalCount
|
||||||
|
pageInfo {
|
||||||
|
endCursor
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
fileId
|
||||||
|
fileName
|
||||||
|
mimeType
|
||||||
|
size
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
query getWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $pagination: PaginationInput!) {
|
||||||
|
workspace(id: $workspaceId) {
|
||||||
|
embedding {
|
||||||
|
ignoredDocs(pagination: $pagination) {
|
||||||
|
totalCount
|
||||||
|
pageInfo {
|
||||||
|
endCursor
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
docId
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
query getWorkspaceEmbeddingConfig($workspaceId: String!) {
|
|
||||||
workspace(id: $workspaceId) {
|
|
||||||
embedding {
|
|
||||||
files {
|
|
||||||
fileId
|
|
||||||
fileName
|
|
||||||
mimeType
|
|
||||||
size
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
ignoredDocs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -764,20 +764,52 @@ export const removeWorkspaceEmbeddingFilesMutation = {
|
|||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWorkspaceEmbeddingConfigQuery = {
|
export const getWorkspaceEmbeddingFilesQuery = {
|
||||||
id: 'getWorkspaceEmbeddingConfigQuery' as const,
|
id: 'getWorkspaceEmbeddingFilesQuery' as const,
|
||||||
op: 'getWorkspaceEmbeddingConfig',
|
op: 'getWorkspaceEmbeddingFiles',
|
||||||
query: `query getWorkspaceEmbeddingConfig($workspaceId: String!) {
|
query: `query getWorkspaceEmbeddingFiles($workspaceId: String!, $pagination: PaginationInput!) {
|
||||||
workspace(id: $workspaceId) {
|
workspace(id: $workspaceId) {
|
||||||
embedding {
|
embedding {
|
||||||
files {
|
files(pagination: $pagination) {
|
||||||
fileId
|
totalCount
|
||||||
fileName
|
pageInfo {
|
||||||
mimeType
|
endCursor
|
||||||
size
|
hasNextPage
|
||||||
createdAt
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
fileId
|
||||||
|
fileName
|
||||||
|
mimeType
|
||||||
|
size
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||||
|
id: 'getWorkspaceEmbeddingIgnoredDocsQuery' as const,
|
||||||
|
op: 'getWorkspaceEmbeddingIgnoredDocs',
|
||||||
|
query: `query getWorkspaceEmbeddingIgnoredDocs($workspaceId: String!, $pagination: PaginationInput!) {
|
||||||
|
workspace(id: $workspaceId) {
|
||||||
|
embedding {
|
||||||
|
ignoredDocs(pagination: $pagination) {
|
||||||
|
totalCount
|
||||||
|
pageInfo {
|
||||||
|
endCursor
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
docId
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ignoredDocs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
@@ -366,11 +366,19 @@ export interface CopilotSessionType {
|
|||||||
|
|
||||||
export interface CopilotWorkspaceConfig {
|
export interface CopilotWorkspaceConfig {
|
||||||
__typename?: 'CopilotWorkspaceConfig';
|
__typename?: 'CopilotWorkspaceConfig';
|
||||||
files: Array<CopilotWorkspaceFile>;
|
files: PaginatedCopilotWorkspaceFileType;
|
||||||
ignoredDocs: Array<Scalars['String']['output']>;
|
ignoredDocs: PaginatedIgnoredDocsType;
|
||||||
workspaceId: Scalars['String']['output'];
|
workspaceId: Scalars['String']['output'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CopilotWorkspaceConfigFilesArgs {
|
||||||
|
pagination: PaginationInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CopilotWorkspaceConfigIgnoredDocsArgs {
|
||||||
|
pagination: PaginationInput;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CopilotWorkspaceFile {
|
export interface CopilotWorkspaceFile {
|
||||||
__typename?: 'CopilotWorkspaceFile';
|
__typename?: 'CopilotWorkspaceFile';
|
||||||
createdAt: Scalars['DateTime']['output'];
|
createdAt: Scalars['DateTime']['output'];
|
||||||
@@ -381,6 +389,24 @@ export interface CopilotWorkspaceFile {
|
|||||||
workspaceId: Scalars['String']['output'];
|
workspaceId: Scalars['String']['output'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CopilotWorkspaceFileTypeEdge {
|
||||||
|
__typename?: 'CopilotWorkspaceFileTypeEdge';
|
||||||
|
cursor: Scalars['String']['output'];
|
||||||
|
node: CopilotWorkspaceFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CopilotWorkspaceIgnoredDoc {
|
||||||
|
__typename?: 'CopilotWorkspaceIgnoredDoc';
|
||||||
|
createdAt: Scalars['DateTime']['output'];
|
||||||
|
docId: Scalars['String']['output'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CopilotWorkspaceIgnoredDocTypeEdge {
|
||||||
|
__typename?: 'CopilotWorkspaceIgnoredDocTypeEdge';
|
||||||
|
cursor: Scalars['String']['output'];
|
||||||
|
node: CopilotWorkspaceIgnoredDoc;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreateChatMessageInput {
|
export interface CreateChatMessageInput {
|
||||||
attachments?: InputMaybe<Array<Scalars['String']['input']>>;
|
attachments?: InputMaybe<Array<Scalars['String']['input']>>;
|
||||||
blobs?: InputMaybe<Array<Scalars['Upload']['input']>>;
|
blobs?: InputMaybe<Array<Scalars['Upload']['input']>>;
|
||||||
@@ -1622,6 +1648,13 @@ export interface PageInfo {
|
|||||||
startCursor: Maybe<Scalars['String']['output']>;
|
startCursor: Maybe<Scalars['String']['output']>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PaginatedCopilotWorkspaceFileType {
|
||||||
|
__typename?: 'PaginatedCopilotWorkspaceFileType';
|
||||||
|
edges: Array<CopilotWorkspaceFileTypeEdge>;
|
||||||
|
pageInfo: PageInfo;
|
||||||
|
totalCount: Scalars['Int']['output'];
|
||||||
|
}
|
||||||
|
|
||||||
export interface PaginatedGrantedDocUserType {
|
export interface PaginatedGrantedDocUserType {
|
||||||
__typename?: 'PaginatedGrantedDocUserType';
|
__typename?: 'PaginatedGrantedDocUserType';
|
||||||
edges: Array<GrantedDocUserTypeEdge>;
|
edges: Array<GrantedDocUserTypeEdge>;
|
||||||
@@ -1629,6 +1662,13 @@ export interface PaginatedGrantedDocUserType {
|
|||||||
totalCount: Scalars['Int']['output'];
|
totalCount: Scalars['Int']['output'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PaginatedIgnoredDocsType {
|
||||||
|
__typename?: 'PaginatedIgnoredDocsType';
|
||||||
|
edges: Array<CopilotWorkspaceIgnoredDocTypeEdge>;
|
||||||
|
pageInfo: PageInfo;
|
||||||
|
totalCount: Scalars['Int']['output'];
|
||||||
|
}
|
||||||
|
|
||||||
export interface PaginatedNotificationObjectType {
|
export interface PaginatedNotificationObjectType {
|
||||||
__typename?: 'PaginatedNotificationObjectType';
|
__typename?: 'PaginatedNotificationObjectType';
|
||||||
edges: Array<NotificationObjectTypeEdge>;
|
edges: Array<NotificationObjectTypeEdge>;
|
||||||
@@ -3243,25 +3283,69 @@ export type RemoveWorkspaceEmbeddingFilesMutation = {
|
|||||||
removeWorkspaceEmbeddingFiles: boolean;
|
removeWorkspaceEmbeddingFiles: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetWorkspaceEmbeddingConfigQueryVariables = Exact<{
|
export type GetWorkspaceEmbeddingFilesQueryVariables = Exact<{
|
||||||
workspaceId: Scalars['String']['input'];
|
workspaceId: Scalars['String']['input'];
|
||||||
|
pagination: PaginationInput;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export type GetWorkspaceEmbeddingConfigQuery = {
|
export type GetWorkspaceEmbeddingFilesQuery = {
|
||||||
__typename?: 'Query';
|
__typename?: 'Query';
|
||||||
workspace: {
|
workspace: {
|
||||||
__typename?: 'WorkspaceType';
|
__typename?: 'WorkspaceType';
|
||||||
embedding: {
|
embedding: {
|
||||||
__typename?: 'CopilotWorkspaceConfig';
|
__typename?: 'CopilotWorkspaceConfig';
|
||||||
ignoredDocs: Array<string>;
|
files: {
|
||||||
files: Array<{
|
__typename?: 'PaginatedCopilotWorkspaceFileType';
|
||||||
__typename?: 'CopilotWorkspaceFile';
|
totalCount: number;
|
||||||
fileId: string;
|
pageInfo: {
|
||||||
fileName: string;
|
__typename?: 'PageInfo';
|
||||||
mimeType: string;
|
endCursor: string | null;
|
||||||
size: number;
|
hasNextPage: boolean;
|
||||||
createdAt: string;
|
};
|
||||||
}>;
|
edges: Array<{
|
||||||
|
__typename?: 'CopilotWorkspaceFileTypeEdge';
|
||||||
|
node: {
|
||||||
|
__typename?: 'CopilotWorkspaceFile';
|
||||||
|
fileId: string;
|
||||||
|
fileName: string;
|
||||||
|
mimeType: string;
|
||||||
|
size: number;
|
||||||
|
createdAt: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GetWorkspaceEmbeddingIgnoredDocsQueryVariables = Exact<{
|
||||||
|
workspaceId: Scalars['String']['input'];
|
||||||
|
pagination: PaginationInput;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export type GetWorkspaceEmbeddingIgnoredDocsQuery = {
|
||||||
|
__typename?: 'Query';
|
||||||
|
workspace: {
|
||||||
|
__typename?: 'WorkspaceType';
|
||||||
|
embedding: {
|
||||||
|
__typename?: 'CopilotWorkspaceConfig';
|
||||||
|
ignoredDocs: {
|
||||||
|
__typename?: 'PaginatedIgnoredDocsType';
|
||||||
|
totalCount: number;
|
||||||
|
pageInfo: {
|
||||||
|
__typename?: 'PageInfo';
|
||||||
|
endCursor: string | null;
|
||||||
|
hasNextPage: boolean;
|
||||||
|
};
|
||||||
|
edges: Array<{
|
||||||
|
__typename?: 'CopilotWorkspaceIgnoredDocTypeEdge';
|
||||||
|
node: {
|
||||||
|
__typename?: 'CopilotWorkspaceIgnoredDoc';
|
||||||
|
docId: string;
|
||||||
|
createdAt: string;
|
||||||
|
};
|
||||||
|
}>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -4540,9 +4624,14 @@ export type Queries =
|
|||||||
response: GetCopilotSessionsQuery;
|
response: GetCopilotSessionsQuery;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
name: 'getWorkspaceEmbeddingConfigQuery';
|
name: 'getWorkspaceEmbeddingFilesQuery';
|
||||||
variables: GetWorkspaceEmbeddingConfigQueryVariables;
|
variables: GetWorkspaceEmbeddingFilesQueryVariables;
|
||||||
response: GetWorkspaceEmbeddingConfigQuery;
|
response: GetWorkspaceEmbeddingFilesQuery;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
name: 'getWorkspaceEmbeddingIgnoredDocsQuery';
|
||||||
|
variables: GetWorkspaceEmbeddingIgnoredDocsQueryVariables;
|
||||||
|
response: GetWorkspaceEmbeddingIgnoredDocsQuery;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
name: 'getDocRolePermissionsQuery';
|
name: 'getDocRolePermissionsQuery';
|
||||||
|
|||||||
Reference in New Issue
Block a user