1+ // cloud-api.ts · C3 Cloud API v0.1.0
2+
3+ export type RecordKind =
4+ | "project" | "session" | "event"
5+ | "memory" | "preference" ;
6+
7+ export interface CloudDevice { id : string ; name : string ; createdAt : string }
8+
9+ export interface AuthResult {
10+ userId : string ;
11+ device : CloudDevice ;
12+ deviceToken : string ; // per laptop, revoked on logout
13+ }
14+
15+ export interface CloudAuth {
16+ signUp ( input : { githubCode : string ; deviceName : string } ) : Promise < AuthResult > ;
17+ logIn ( input : { githubCode : string ; deviceName : string } ) : Promise < AuthResult > ;
18+ logOut ( ) : Promise < { ok : true } > ; // revokes only this device's token
19+ }
20+
21+ export interface SyncChange {
22+ kind : RecordKind ;
23+ id : string ; // stable ID. Events: `${sessionId}:${seq}`
24+ version : number ;
25+ deleted ?: boolean ;
26+ data : Record < string , unknown > ; // never paths, secrets or raw output
27+ }
28+
29+ export interface PushRequest { changes : SyncChange [ ] }
30+ export interface PushResult {
31+ accepted : string [ ] ;
32+ rejected : { id : string ; reason : "too_large" | "forbidden_field" | "illegal_move" | "stale" } [ ] ;
33+ }
34+
35+ export interface PullRequest { cursor : string | null }
36+ export interface PullResult {
37+ changes : SyncChange [ ] ;
38+ nextCursor : string ;
39+ hasMore : boolean ;
40+ }
41+
42+ export interface CloudSync {
43+ push ( req : PushRequest ) : Promise < PushResult > ;
44+ pull ( req : PullRequest ) : Promise < PullResult > ;
45+ }
46+
47+ export interface CloudDevices {
48+ listDevices ( ) : Promise < { devices : CloudDevice [ ] } > ;
49+ revokeDevice ( id : string ) : Promise < { ok : true } > ;
50+ }
0 commit comments