// Paper REST API Types
export interface PaperUser {
_id: string;
createdAt: number;
email: string;
firstName: string;
id: string;
lastName: string | null;
lastSignInAt: number;
profilePictureUrl: string;
recentFiles: string[];
teamIds: string[];
updatedAt: number;
workOSUserId: string;
isProvisioned: boolean;
settings: {
showGuides: boolean;
};
}
export interface PaperAuthMeResponse {
user: PaperUser;
activeTeamId: string;
plan: string;
}
// WebSocket Message Types
export interface PaperWebSocketMessage {
id?: string;
type?: string;
'$t'?: number;
fileId?: string;
edit?: {
path: string;
type: 'add' | 'update' | 'delete';
value?: any;
};
file?: {
nodes?: Record<string, PaperNode>;
nodeRelationships?: Record<string, string>;
pages?: Array<{ id: string; label: string }>;
images?: Record<string, any>;
};
[key: string]: any;
}
export interface PaperColor {
value: {
mode: 'oklch';
l: number;
c: number;
h: number;
alpha?: number;
};
mode: 'hex';
gamut: 'rgb';
}
export interface PaperFill {
type: 'solid';
color: PaperColor;
isVisible: boolean;
}
export interface PaperStyleMeta {
fill?: PaperFill[];
}
export interface PaperNode {
id: string;
label?: string;
x?: number;
y?: number;
component?: 'Rectangle' | 'Frame' | 'Ellipse' | 'Text' | string;
styles?: {
width?: string;
height?: string;
[key: string]: any;
};
styleMeta?: PaperStyleMeta;
isVisible?: boolean;
isLocked?: boolean;
'~'?: boolean;
[key: string]: any;
}
export interface PaperDocumentState {
nodes: Map<string, PaperNode>;
documentId: string;
}
// Request/Response Matching
export interface PendingRequest {
id: string;
resolve: (value: any) => void;
reject: (error: Error) => void;
timeout: NodeJS.Timeout;
}
// Connection State
export enum ConnectionState {
Disconnected = 'disconnected',
Connecting = 'connecting',
Connected = 'connected',
Reconnecting = 'reconnecting',
}