Skip to content

Commit bc021b0

Browse files
2 parents cdea1c9 + 0415ad4 commit bc021b0

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎src/cloud-api.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}

‎src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
export * from "./session.js";
66
export * from "./runner.js";
7+
export * from "./cloud-api.js"

0 commit comments

Comments
 (0)