Client class red: literate usage tests and stub

test/client/usage.test.ts is a tutorial-as-test-suite that walks
through the entire quack API in order: login, whoami, listCollections,
listFiles, downloadFile, downloadThumbnail, toJSON/fromJSON, logout.

Each it() block is a self-contained example with prose commentary
explaining what the code does and why, with code samples showing the
API as a consumer would use it. The mock server performs real SRP and
crypto so the test data is structurally identical to production.

8 tests, all failing against the stub.
This commit is contained in:
2026-05-13 17:59:18 -07:00
parent 3b04a8134f
commit ca6857d3fe
2 changed files with 692 additions and 0 deletions

72
src/client.ts Normal file
View File

@@ -0,0 +1,72 @@
// Stub: see the README "Development workflow" section for TDD policy.
import type { ApiClientOptions } from "./api/client.js";
import type { Collection, EnteFile } from "./model/types.js";
import type { DownloadResult } from "./download/index.js";
export interface LoginOptions {
email: string;
password: string;
totp?: () => Promise<string>;
emailOTP?: () => Promise<string>;
apiOptions?: ApiClientOptions;
}
export interface ClientSnapshot {
email: string;
userID: number;
token: string;
masterKey: string;
secretKey: string;
publicKey: string;
}
export class Client {
static async login(_opts: LoginOptions): Promise<Client> {
throw new Error("Client.login not implemented");
}
static fromJSON(
_snapshot: ClientSnapshot,
_apiOptions?: ApiClientOptions,
): Client {
throw new Error("Client.fromJSON not implemented");
}
whoami(): { email: string; userID: number } {
throw new Error("Client.whoami not implemented");
}
toJSON(): ClientSnapshot {
throw new Error("Client.toJSON not implemented");
}
logout(): void {
throw new Error("Client.logout not implemented");
}
async listCollections(): Promise<Collection[]> {
throw new Error("Client.listCollections not implemented");
}
async listFiles(
_collectionID: number,
_collectionKey: Uint8Array,
): Promise<EnteFile[]> {
throw new Error("Client.listFiles not implemented");
}
async downloadFile(
_file: EnteFile,
_outPath?: string,
): Promise<DownloadResult> {
throw new Error("Client.downloadFile not implemented");
}
async downloadThumbnail(
_file: EnteFile,
_outPath?: string,
): Promise<DownloadResult> {
throw new Error("Client.downloadThumbnail not implemented");
}
}