feat(sdk): Effect v4 + @effect/openapi-generator; typed pf.api & example ladder
Drop Orval for the first-party @effect/openapi-generator (OpenAPI 3.1 -> Effect Schema + a typed HttpClient client) and bump effect 3.19 -> 4.0.0-beta.98. Port the hand-written surfaces to the v4 API (Result over Either, Context.Service, Codec, Literals/Union arrays, Stream/Schedule/ Effect renames). Transport (CA-pinning fetch) and the reconnecting SSE source are kept intact. Make the SDK approachable for non-Effect users: - Add pf.api.* on the Promise facade: the generated client surfaced as typed, Promise-native methods (await pf.api.listPairedClients()), so REST calls are autocompleted and checked instead of stringly-typed pf.request(method, path, body) + `as` casts. Zero-drift veneer over make(httpClient), backed by the same pinning fetch. pf.request stays as the untyped escape hatch. - Re-tier examples into a 1-4 complexity ladder, rewritten onto pf.api.* (the typed payloads caught a wrong `launch` shape in provider-sync); the Effect example is labelled advanced. Add examples/ to tsconfig so they are typechecked (stops rot). typecheck + 19 tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
// Tail the host's lifecycle events — the SDK "hello world" (Promise facade).
|
||||
// ── Example 1/4 · the "hello world" ─────────────────────────────────────────────────────────
|
||||
// Connect, make one typed API call, and tail the host's lifecycle events. No Effect knowledge
|
||||
// needed — `connect()` returns a plain Promise client.
|
||||
//
|
||||
// bun examples/tail-events.ts (on the host box: zero config)
|
||||
// PUNKTFUNK_MGMT_URL=… PUNKTFUNK_MGMT_TOKEN=… bun examples/tail-events.ts
|
||||
import { connect } from "../src/index.js";
|
||||
|
||||
const pf = await connect();
|
||||
const host = (await pf.request("GET", "/host")) as { hostname?: string };
|
||||
console.log(`connected to ${host.hostname ?? "host"} — tailing events (^C to stop)`);
|
||||
|
||||
// `pf.api.*` is the typed front door: `host` is a fully-typed HostInfo — no cast, autocomplete
|
||||
// for every field.
|
||||
const host = await pf.api.getHostInfo();
|
||||
console.log(`connected to ${host.hostname} — tailing events (^C to stop)`);
|
||||
|
||||
pf.events.on("*", (e) => console.log(`[${e.seq}] ${e.kind}`, JSON.stringify(e)));
|
||||
pf.events.on("unknown", (e) => console.log("[unknown kind]", JSON.stringify(e)));
|
||||
|
||||
Reference in New Issue
Block a user