feat(server): export title and summary on doc resolver (#13139)
Some checks are pending
Build & Test / Analyze (javascript, affine) (push) Waiting to run
Build & Test / Analyze (javascript, blocksuite) (push) Waiting to run
Build & Test / Analyze (typescript, affine) (push) Waiting to run
Build & Test / Analyze (typescript, blocksuite) (push) Waiting to run
Build & Test / Lint (push) Waiting to run
Build & Test / Typecheck (push) Waiting to run
Build & Test / Lint Rust (push) Waiting to run
Build & Test / Check Git Status (push) Blocked by required conditions
Build & Test / Check yarn binary (push) Waiting to run
Build & Test / E2E BlockSuite Test (1) (push) Waiting to run
Build & Test / E2E BlockSuite Test (10) (push) Waiting to run
Build & Test / E2E BlockSuite Test (2) (push) Waiting to run
Build & Test / E2E BlockSuite Test (3) (push) Waiting to run
Build & Test / E2E BlockSuite Test (4) (push) Waiting to run
Build & Test / E2E BlockSuite Test (5) (push) Waiting to run
Build & Test / E2E BlockSuite Test (6) (push) Waiting to run
Build & Test / E2E BlockSuite Test (7) (push) Waiting to run
Build & Test / E2E BlockSuite Test (8) (push) Waiting to run
Build & Test / E2E BlockSuite Test (9) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (chromium, 1) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (chromium, 2) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (firefox, 1) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (firefox, 2) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (webkit, 1) (push) Waiting to run
Build & Test / E2E BlockSuite Cross Browser Test (webkit, 2) (push) Waiting to run
Build & Test / E2E Test (1) (push) Waiting to run
Build & Test / E2E Test (10) (push) Waiting to run
Build & Test / E2E Test (2) (push) Waiting to run
Build & Test / E2E Test (3) (push) Waiting to run
Build & Test / E2E Test (4) (push) Waiting to run
Build & Test / E2E Test (5) (push) Waiting to run
Build & Test / E2E Test (6) (push) Waiting to run
Build & Test / E2E Test (7) (push) Waiting to run
Build & Test / E2E Test (8) (push) Waiting to run
Build & Test / E2E Test (9) (push) Waiting to run
Build & Test / E2E Mobile Test (1) (push) Waiting to run
Build & Test / E2E Mobile Test (2) (push) Waiting to run
Build & Test / E2E Mobile Test (3) (push) Waiting to run
Build & Test / E2E Mobile Test (4) (push) Waiting to run
Build & Test / E2E Mobile Test (5) (push) Waiting to run
Build & Test / Unit Test (1) (push) Blocked by required conditions
Build & Test / Unit Test (2) (push) Blocked by required conditions
Build & Test / Unit Test (3) (push) Blocked by required conditions
Build & Test / Unit Test (4) (push) Blocked by required conditions
Build & Test / Unit Test (5) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:aarch64-apple-darwin]) (push) Waiting to run
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:x86_64-apple-darwin]) (push) Waiting to run
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:ubuntu-latest target:x86_64-unknown-linux-gnu]) (push) Waiting to run
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:aarch64-pc-windows-msvc]) (push) Waiting to run
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:x86_64-pc-windows-msvc]) (push) Waiting to run
Build & Test / Build Server native (push) Waiting to run
Build & Test / Build @affine/electron renderer (push) Waiting to run
Build & Test / Native Unit Test (push) Blocked by required conditions
Build & Test / Server Test (0, 8) (push) Blocked by required conditions
Build & Test / Server Test (1, 8) (push) Blocked by required conditions
Build & Test / Server Test (2, 8) (push) Blocked by required conditions
Build & Test / Server Test (3, 8) (push) Blocked by required conditions
Build & Test / Server Test (4, 8) (push) Blocked by required conditions
Build & Test / Server Test (5, 8) (push) Blocked by required conditions
Build & Test / Server Test (6, 8) (push) Blocked by required conditions
Build & Test / Server Test (7, 8) (push) Blocked by required conditions
Build & Test / Server Test with Elasticsearch (push) Blocked by required conditions
Build & Test / Server E2E Test (push) Blocked by required conditions
Build & Test / miri code check (push) Waiting to run
Build & Test / loom thread test (push) Waiting to run
Build & Test / fuzzing (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:macos-13 target:x86_64-apple-darwin]) (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:macos-latest target:aarch64-apple-darwin]) (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:ubuntu-24.04-arm target:aarch64-unknown-linux-gnu]) (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:ubuntu-latest target:x86_64-unknown-linux-gnu]) (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:windows-11-arm target:aarch64-pc-windows-msvc]) (push) Waiting to run
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:windows-latest target:x86_64-pc-windows-msvc]) (push) Waiting to run
Build & Test / Run native tests (push) Waiting to run
Build & Test / Server Copilot Api Test (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (1, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (10, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (2, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (3, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (4, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (5, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (6, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (7, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (8, 10) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (9, 10) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud Desktop E2E Test script:yarn affine @affine/electron build:dev # Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions # Disables unprivileged user namespaces restrictio… (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 1/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/10 shard:1]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 10/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=10/10 shard:10]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 2/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/10 shard:2]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 3/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=3/10 shard:3]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 4/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=4/10 shard:4]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 5/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=5/10 shard:5]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 6/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=6/10 shard:6]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 7/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=7/10 shard:7]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 8/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=8/10 shard:8]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 9/10 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=9/10 shard:9]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:windows-latest platform:windows target:x86_64-pc-windows-msvc test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:windows-latest platform:windows target:x86_64-pc-windows-msvc test:true]) (push) Blocked by required conditions
Build & Test / 3, 2, 1 Launch (push) Blocked by required conditions
Sync I18n with Crowdin / synchronize-with-crowdin (push) Waiting to run
Sync I18n with Crowdin / i18n-codegen (push) Blocked by required conditions

close AF-2732






#### PR Dependency Tree


* **PR #13139** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added support for a document summary field, allowing documents to
include and display an optional summary alongside the title.

* **Bug Fixes**
* Improved access control when retrieving documents, ensuring proper
permission checks are enforced.

* **Tests**
* Expanded test coverage to verify correct handling of document title
and summary fields, including cases where the summary is absent.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fengmk2 2025-07-10 19:13:19 +08:00 committed by GitHub
parent 46a9d0f7fe
commit f655e6e8bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 79 additions and 2 deletions

View File

@ -99,3 +99,56 @@ e2e(
t.is(result2.workspace.doc.public, true);
}
);
e2e('should get doc with title and summary', async t => {
const owner = await app.signup();
const workspace = await app.create(Mockers.Workspace, {
owner: { id: owner.id },
});
const docSnapshot = await app.create(Mockers.DocSnapshot, {
workspaceId: workspace.id,
user: owner,
});
const doc = await app.create(Mockers.DocMeta, {
workspaceId: workspace.id,
docId: docSnapshot.id,
title: 'doc1',
summary: 'summary1',
});
const result = await app.gql({
query: getWorkspacePageByIdQuery,
variables: { workspaceId: workspace.id, pageId: doc.docId },
});
t.is(result.workspace.doc.title, doc.title);
t.is(result.workspace.doc.summary, doc.summary);
});
e2e('should get doc with title and null summary', async t => {
const owner = await app.signup();
const workspace = await app.create(Mockers.Workspace, {
owner: { id: owner.id },
});
const docSnapshot = await app.create(Mockers.DocSnapshot, {
workspaceId: workspace.id,
user: owner,
});
const doc = await app.create(Mockers.DocMeta, {
workspaceId: workspace.id,
docId: docSnapshot.id,
title: 'doc1',
});
const result = await app.gql({
query: getWorkspacePageByIdQuery,
variables: { workspaceId: workspace.id, pageId: doc.docId },
});
t.is(result.workspace.doc.title, doc.title);
t.is(result.workspace.doc.summary, null);
});

View File

@ -669,7 +669,10 @@ test('should get doc info', async t => {
};
await t.context.doc.upsert(snapshot);
await t.context.doc.upsertMeta(workspace.id, docId);
await t.context.doc.upsertMeta(workspace.id, docId, {
title: 'test title',
summary: 'test summary',
});
const docInfo = await t.context.doc.getDocInfo(workspace.id, docId);
@ -679,6 +682,8 @@ test('should get doc info', async t => {
updatedAt: new Date(snapshot.timestamp),
creatorId: user.id,
lastUpdaterId: user.id,
title: 'test title',
summary: 'test summary',
});
});

View File

@ -79,6 +79,9 @@ class DocType {
@Field(() => String, { nullable: true })
title?: string | null;
@Field(() => String, { nullable: true })
summary?: string | null;
}
@InputType()
@ -250,10 +253,11 @@ export class WorkspaceDocResolver {
deprecationReason: 'use [WorkspaceType.doc] instead',
})
async publicPage(
@CurrentUser() me: CurrentUser,
@Parent() workspace: WorkspaceType,
@Args('pageId') pageId: string
) {
return this.doc(workspace, pageId);
return this.doc(me, workspace, pageId);
}
@ResolveField(() => PaginatedDocType)
@ -294,11 +298,14 @@ export class WorkspaceDocResolver {
complexity: 2,
})
async doc(
@CurrentUser() me: CurrentUser,
@Parent() workspace: WorkspaceType,
@Args('docId') docId: string
): Promise<DocType> {
const doc = await this.models.doc.getDocInfo(workspace.id, docId);
if (doc) {
// check if doc is readable
await this.ac.user(me.id).doc(workspace.id, docId).assert('Doc.Read');
return doc;
}

View File

@ -558,6 +558,8 @@ export class DocModel extends BaseModel {
mode: PublicDocMode;
public: boolean;
defaultRole: DocRole;
title: string | null;
summary: string | null;
createdAt: Date;
updatedAt: Date;
creatorId?: string;
@ -570,6 +572,8 @@ export class DocModel extends BaseModel {
"workspace_pages"."mode" as "mode",
"workspace_pages"."public" as "public",
"workspace_pages"."defaultRole" as "defaultRole",
"workspace_pages"."title" as "title",
"workspace_pages"."summary" as "summary",
"snapshots"."created_at" as "createdAt",
"snapshots"."updated_at" as "updatedAt",
"snapshots"."created_by" as "creatorId",

View File

@ -595,6 +595,7 @@ type DocType {
mode: PublicDocMode!
permissions: DocPermissions!
public: Boolean!
summary: String
title: String
updatedAt: DateTime
workspaceId: String!

View File

@ -5,6 +5,8 @@ query getWorkspacePageById($workspaceId: String!, $pageId: String!) {
mode
defaultRole
public
title
summary
}
}
}

View File

@ -1584,6 +1584,8 @@ export const getWorkspacePageByIdQuery = {
mode
defaultRole
public
title
summary
}
}
}`,

View File

@ -703,6 +703,7 @@ export interface DocType {
mode: PublicDocMode;
permissions: DocPermissions;
public: Scalars['Boolean']['output'];
summary: Maybe<Scalars['String']['output']>;
title: Maybe<Scalars['String']['output']>;
updatedAt: Maybe<Scalars['DateTime']['output']>;
workspaceId: Scalars['String']['output'];
@ -5147,6 +5148,8 @@ export type GetWorkspacePageByIdQuery = {
mode: PublicDocMode;
defaultRole: DocRole;
public: boolean;
title: string | null;
summary: string | null;
};
};
};