snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped

This commit is contained in:
upstream-mirror
2026-09-16 04:01:20 +05:00
commit 702cc698a7
9990 changed files with 1073618 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
{
"name": "@affine/realtime",
"type": "module",
"version": "0.27.5",
"private": true,
"sideEffects": false,
"exports": {
".": "./src/index.ts"
},
"dependencies": {
"@affine/graphql": "workspace:*"
}
}

View File

@@ -0,0 +1,516 @@
export type RealtimeRequestName = keyof RealtimeRequestMap;
export type RealtimeTopicName = keyof RealtimeTopicMap;
export const WORKSPACE_MEMBERS_REQUEST_TAKE_MAX = 100;
export interface RealtimeRequestMap {
'copilot.delegated.editor.upsert': {
input: DelegatedEditorLeaseInput;
output: { ok: true; expiresAt: number };
};
'copilot.delegated.editor.release': {
input: { clientId: string; editorStateId: string };
output: { ok: true };
};
'copilot.delegated.tool.respond': {
input: DelegatedToolResponse;
output: { accepted: boolean };
};
'workspace.access.get': {
input: { workspaceId: string };
output: { access: WorkspaceAccessSnapshot };
};
'workspace.config.get': {
input: { workspaceId: string };
output: { config: WorkspaceConfigSnapshot };
};
'workspace.members.get': {
input: {
workspaceId: string;
skip?: number;
take?: number;
query?: string;
};
output: { members: WorkspaceMemberSnapshot[]; memberCount: number };
};
'workspace.invite-link.get': {
input: { workspaceId: string };
output: { inviteLink: WorkspaceInviteLinkSnapshot | null };
};
'doc.share-state.get': {
input: { workspaceId: string; docId: string };
output: { state: DocShareStateSnapshot | null };
};
'doc.grants.get': {
input: { workspaceId: string; docId: string; pagination: PaginationInput };
output: PaginatedDocGrantedUsersSnapshot;
};
'user.profile.get': {
input: Record<string, never>;
output: { user: CurrentUserProfileSnapshot | null };
};
'user.settings.get': {
input: Record<string, never>;
output: { settings: UserSettingsSnapshot };
};
'notification.count.get': {
input: Record<string, never>;
output: { count: number };
};
'comment.changes.get': {
input: {
workspaceId: string;
docId: string;
after?: string;
first?: number;
};
output: {
changes: CommentChangeSnapshot[];
startCursor: string;
endCursor: string;
hasNextPage: boolean;
};
};
'workspace.embedding.progress.get': {
input: { workspaceId: string };
output: { total: number; embedded: number };
};
'copilot.transcript.task.get': {
input: {
workspaceId: string;
blobId?: string;
taskId?: string;
};
output: { task: unknown | null };
};
'copilot.transcript.task.retry': {
input: {
workspaceId: string;
taskId: string;
};
output: { task: unknown | null };
};
'user.quota-state.get': {
input: Record<string, never>;
output: { state: UserQuotaStateSnapshot };
};
'workspace.quota-state.get': {
input: { workspaceId: string };
output: { state: WorkspaceQuotaStateSnapshot };
};
}
export type WorkspaceRoleSnapshot =
| 'Owner'
| 'Admin'
| 'Collaborator'
| 'External'
| string;
export type DocRoleSnapshot =
| 'Owner'
| 'Manager'
| 'Editor'
| 'Commenter'
| 'Reader'
| 'External'
| string;
export type PublicDocModeSnapshot = 'Page' | 'Edgeless' | string;
export interface WorkspaceAccessSnapshot {
role: WorkspaceRoleSnapshot;
permissions: Record<string, boolean>;
team: boolean;
}
export interface WorkspaceConfigSnapshot {
enableAi: boolean;
enableSharing: boolean;
enableUrlPreview: boolean;
enableDocEmbedding: boolean;
}
export interface WorkspaceMemberSnapshot {
id: string;
name: string;
email: string;
avatarUrl: string | null;
permission: WorkspaceRoleSnapshot;
role: WorkspaceRoleSnapshot;
inviteId: string;
emailVerified: boolean | null;
status: string;
}
export interface WorkspaceInviteLinkSnapshot {
link: string;
expireTime: string;
}
export interface DocShareStateSnapshot {
public: boolean;
mode: PublicDocModeSnapshot;
defaultRole: DocRoleSnapshot;
}
export interface PaginationInput {
first: number;
offset?: number;
after?: string;
}
export interface DocGrantedUserSnapshot {
role: DocRoleSnapshot;
user: {
id: string;
name: string;
email: string;
avatarUrl: string | null;
};
}
export interface PaginatedDocGrantedUsersSnapshot {
totalCount: number;
pageInfo: {
endCursor: string | null;
hasNextPage: boolean;
};
edges: { node: DocGrantedUserSnapshot }[];
}
export interface CurrentUserProfileSnapshot {
id: string;
name: string;
email: string;
emailVerified: boolean;
hasPassword: boolean | null;
avatarUrl: string | null;
features: string[];
}
export interface UserSettingsSnapshot {
receiveInvitationEmail: boolean;
receiveMentionEmail: boolean;
receiveCommentEmail: boolean;
}
export type CommentChangeActionSnapshot = 'update' | 'delete';
export interface CommentChangeSnapshot {
id: string;
action: CommentChangeActionSnapshot;
item: object;
commentId: string | null;
}
export interface UserQuotaStateSnapshot {
plan: string;
seatLimit: number;
blobLimit: number;
storageQuota: number;
usedStorageQuota: number;
historyPeriodSeconds: number;
copilotActionLimit?: number;
unlimitedCopilot: boolean;
}
export interface WorkspaceQuotaStateSnapshot {
plan: string;
ownerUserId: string;
usesOwnerQuota: boolean;
seatLimit: number;
memberCount: number;
overcapacityMemberCount: number;
blobLimit: number;
storageQuota: number;
usedStorageQuota: number;
historyPeriodSeconds: number;
readonly: boolean;
readonlyReasons: string[];
unlimitedCopilot: boolean;
}
export type NotificationCountChangedReason =
| 'created'
| 'read'
| 'read-all'
| 'expired-cleanup'
| 'resync';
export type WorkspaceEmbeddingProgressReason =
| 'queued'
| 'progress'
| 'finished'
| 'failed'
| 'resync';
export interface RealtimeTopicMap {
'copilot.delegated.tool.requested': {
input: { clientId: string };
event: DelegatedToolRequest | DelegatedToolCancel;
};
'workspace.access.changed': {
input: { workspaceId: string };
event: { changed: true; reason: string };
};
'workspace.config.changed': {
input: { workspaceId: string };
event: { changed: true; reason: string };
};
'workspace.members.changed': {
input: { workspaceId: string };
event: { changed: true; reason: string };
};
'workspace.invite-link.changed': {
input: { workspaceId: string };
event: { changed: true; reason: string };
};
'doc.share-state.changed': {
input: { workspaceId: string; docId: string };
event: { changed: true; reason: string };
};
'doc.grants.changed': {
input: { workspaceId: string; docId: string };
event: { changed: true; reason: string };
};
'user.profile.changed': {
input: Record<string, never>;
event: { changed: true; reason: string };
};
'user.settings.changed': {
input: Record<string, never>;
event: { changed: true; reason: string };
};
'notification.count.changed': {
input: Record<string, never>;
event: {
count: number;
reason: NotificationCountChangedReason;
};
};
'comment.changed': {
input: {
workspaceId: string;
docId: string;
};
event: {
changed: true;
cursor?: string;
};
};
'workspace.embedding.progress.changed': {
input: { workspaceId: string };
event: {
total?: number;
embedded?: number;
reason: WorkspaceEmbeddingProgressReason;
};
};
'copilot.transcript.task.changed': {
input: {
workspaceId: string;
taskId: string;
};
event: {
taskId: string;
status: string;
error?: string;
};
};
'user.quota-state.changed': {
input: Record<string, never>;
event: { changed: true };
};
'workspace.quota-state.changed': {
input: { workspaceId: string };
event: { changed: true };
};
}
export type DelegatedToolName =
| 'frontend_get_editor_state'
| 'frontend_read_selection'
| 'frontend_read_nodes'
| 'frontend_snapshot_document';
export interface DelegatedEditorLeaseInput {
clientId: string;
sessionId: string;
workspaceId: string;
docId: string;
editorStateId: string;
mode: 'page' | 'edgeless';
readonly: boolean;
focused: boolean;
capabilities: DelegatedToolName[];
}
export interface DelegatedToolIdentity {
requestId: string;
runId: string;
toolCallId: string;
sessionId: string;
workspaceId: string;
docId: string;
clientId: string;
editorStateId: string;
}
export interface DelegatedToolRequest extends DelegatedToolIdentity {
type: 'request';
tool: DelegatedToolName;
args: Record<string, unknown>;
deadlineAt: number;
}
export interface DelegatedToolCancel extends DelegatedToolIdentity {
type: 'cancel';
reason: 'aborted' | 'timeout' | 'disconnect';
}
export interface DelegatedToolResponse extends DelegatedToolIdentity {
result?: unknown;
error?: {
code: string;
message: string;
retryable: boolean;
};
}
export type RealtimeRequestInputOf<Op extends RealtimeRequestName> =
RealtimeRequestMap[Op]['input'];
export type RealtimeRequestOutputOf<Op extends RealtimeRequestName> =
RealtimeRequestMap[Op]['output'];
export type RealtimeTopicInputOf<Topic extends RealtimeTopicName> =
RealtimeTopicMap[Topic]['input'];
export type RealtimeTopicEventOf<Topic extends RealtimeTopicName> =
RealtimeTopicMap[Topic]['event'];
export type RealtimeError = {
name: string;
message: string;
code?: string;
};
export type RealtimeAck<T> = { data: T } | { error: RealtimeError };
export type RealtimeRequestId = string;
export type RealtimeSubscriptionId = string;
export type RealtimeRequestEnvelope<
Op extends RealtimeRequestName = RealtimeRequestName,
> = {
requestId?: RealtimeRequestId;
op: Op;
input: RealtimeRequestInputOf<Op>;
clientVersion?: string;
};
export type RealtimeRequestInput<
Op extends RealtimeRequestName = RealtimeRequestName,
> = Op extends RealtimeRequestName
? {
op: Op;
input: RealtimeRequestInputOf<Op>;
timeoutMs?: number;
}
: never;
export type RealtimeRequestOutput<
Op extends RealtimeRequestName = RealtimeRequestName,
> = RealtimeRequestOutputOf<Op>;
export type RealtimeSubscribeEnvelope<
Topic extends RealtimeTopicName = RealtimeTopicName,
> = {
subscriptionId?: RealtimeSubscriptionId;
topic: Topic;
input: RealtimeTopicInputOf<Topic>;
clientVersion?: string;
};
export type RealtimeSubscribeInput<
Topic extends RealtimeTopicName = RealtimeTopicName,
> = Topic extends RealtimeTopicName
? {
topic: Topic;
input: RealtimeTopicInputOf<Topic>;
}
: never;
export type RealtimeUnsubscribeEnvelope = {
subscriptionId?: RealtimeSubscriptionId;
topic: RealtimeTopicName;
input: RealtimeTopicInputOf<RealtimeTopicName>;
clientVersion?: string;
};
export type RealtimeReadyEvent = {
type: 'ready';
snapshot?: unknown;
};
export type RealtimeSubscriptionReady = RealtimeReadyEvent;
export type RealtimeEvent<Topic extends RealtimeTopicName = RealtimeTopicName> =
Topic extends RealtimeTopicName
? {
topic: Topic;
inputKey: string;
seq?: number;
sentAt: number;
event: RealtimeTopicEventOf<Topic>;
}
: never;
export type RealtimeTopicEvent<
Topic extends RealtimeTopicName = RealtimeTopicName,
> = RealtimeTopicEventOf<Topic> | RealtimeReadyEvent;
export type RealtimeStatus = {
endpoint?: string;
connected: boolean;
connecting: boolean;
subscriptions: number;
lastError?: RealtimeError;
};
export type RealtimeConfigureInput = {
endpoint: string;
isSelfHosted: boolean;
authenticated: boolean;
clientVersion?: string;
};
export function getRealtimeInputKey(input: unknown): string {
if (
input === undefined ||
typeof input === 'function' ||
typeof input === 'symbol'
) {
return 'null';
}
if (input === null || typeof input !== 'object') {
return JSON.stringify(input);
}
if (Array.isArray(input)) {
return `[${input.map(getRealtimeInputKey).join(',')}]`;
}
if (input instanceof Date) {
return JSON.stringify(input.toJSON());
}
const record = input as Record<string, unknown>;
return `{${Object.keys(record)
.filter(key => {
const property = record[key];
return (
property !== undefined &&
typeof property !== 'function' &&
typeof property !== 'symbol'
);
})
.sort()
.map(key => `${JSON.stringify(key)}:${getRealtimeInputKey(record[key])}`)
.join(',')}}`;
}

View File

@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.web.json",
"include": ["./src"],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
},
"references": [{ "path": "../graphql" }]
}