newOS for Developers
Back to Overview
Core Types
TypeScriptEnriched types that extend base API responses with client-side state and metadata.
packages/newgraph-signals/src/index.ts
EnrichedPost
Extends PostReadResponse with upload state, AI metadata, and voting information.
type EnrichedPost = PostReadResponse & PostVotingState & {
uploadState?: PostUploadState; // Current upload status
thumbUrl?: string; // Thumbnail URL for preview
aiMeta?: AIMeta; // AI generation metadata
reasoning?: string[]; // AI reasoning traces
relativeRating?: number; // Computed rating score
};| Property | Type | Description |
|---|---|---|
| uploadState | PostUploadState? | Tracks upload progress for new posts |
| thumbUrl | string? | Generated thumbnail for media preview |
| aiMeta | AIMeta? | AI model info and token usage |
| reasoning | string[]? | Step-by-step AI reasoning |
| vote | number? | User's vote on this post (from PostVotingState) |
EnrichedFolder
Extends MoodReadResponse with voting state and local enhancements.
type EnrichedFolder = MoodReadResponse & FolderVotingState & LocalFolderEnhancements;
// Voting state tracks pagination and completion
type FolderVotingState = {
lastVotedPostId?: string; // Last post user voted on
lastLoadedPage?: number; // Pagination tracking
votingComplete?: boolean; // All posts in folder voted
score?: number; // Aggregated folder score
};
// Local enhancements for special folder types
type LocalFolderEnhancements = {
oneOnOne?: string[]; // DM participants
future?: boolean; // Scheduled/future folder
futureGrantees?: Partial<UserReadPublicResponseWithAccess>[];
};PostUploadState
Tracks the multi-step upload process for new posts.
const POST_UPLOAD_STATE_SEQUENCE = [
"preparing", // Initial state, creating metadata
"created", // Post record created in API
"attached", // Post attached to folder(s)
"upload-requested", // Pre-signed URL obtained
"uploaded" // File successfully uploaded
];
type PostUploadState = {
status: "preparing" | "created" | "attached" | "upload-requested" | "uploaded";
done?: boolean; // Upload fully complete
filename: string; // Original filename
blob: Blob; // File content
thumb: string; // Base64 thumbnail
foldersToAttach: { id: string }[]; // Target folder IDs
};Upload Flow: The sequence array defines the valid progression. Status moves forward through each step. Use this to show progress indicators.
AIMeta
Metadata for AI-generated content, including model info and token usage.
interface AIMeta {
model?: {
name?: string; // e.g., "gpt-4", "claude-3"
provider?: string; // e.g., "openai", "anthropic"
};
usage?: {
tokens?: {
prompt?: number; // Input tokens used
completion?: number; // Output tokens generated
};
};
request?: {
prompt?: string; // Original prompt text
completion?: string; // Generated response
reasoning?: string[]; // Chain-of-thought steps
references?: string[]; // Source citations
swarm?: string[]; // Multi-agent collaboration IDs
};
}UserReadPublicResponseWithAccess
Extends user profile with access level information for permission checks.
type UserReadPublicResponseWithAccess = UserReadPublicResponse & {
accessLevel: string; // User's permission level (e.g., "owner", "member", "viewer")
};Type Relationships
PostReadResponse (API)
└── + PostVotingState
└── + uploadState, thumbUrl, aiMeta, reasoning
└── = EnrichedPost
MoodReadResponse (API)
└── + FolderVotingState
└── + LocalFolderEnhancements
└── = EnrichedFolder
UserReadPublicResponse (API)
└── + accessLevel
└── = UserReadPublicResponseWithAccess