/** * GoableClient — thin typed transport over the public Goable REST API. * No caching, no business logic; one `request` powers every method. */ import type { ActivitiesResponse, AdaptationReportRequest, AdaptationReportResponse, AuditExportQuery, AuditExportResponse, BindPolicyRequest, BindPolicyResponse, BriefingRequest, BriefingResponse, CatalogStatsResponse, CounterfactualRequest, CounterfactualResponse, CreateStationRequest, CreateStationResponse, DecisionRequest, DecisionResponse, DeleteUserDataResult, EdgeCaseRequest, EdgeCaseResponse, EvaluatePolicyResponse, ExplainRequest, ExplainResponse, HealthReadyResponse, HealthResponse, IdempotencyOptions, LegalDocumentKind, LegalDocumentResponse, ListPoliciesQuery, ListPoliciesResponse, ListStationsResponse, LlmKeyStatus, PolicyResponse, ProjectionsPortfolioRequest, ProjectionsPortfolioResponse, ProjectionsRequest, ProjectionsResponse, PublicSignupRequest, PublicSignupResponse, QuoteByIdResponse, QuoteRequest, QuoteResponse, RecentObservationsQuery, RecentObservationsResponse, RecommendSpotRequest, RecommendSpotResponse, ReportOutcomeRequest, ReportOutcomeResponse, ScoreDifficultyRequest, ScoreDifficultyResponse, ScoreHistoricalRequest, ScoreHistoricalResponse, ScoreMultiRequest, ScoreMultiResponse, ScorePortfolioRequest, ScorePortfolioResponse, ScoreRequest, ScoreResponse, ScoreSeriesRequest, ScoreSeriesResponse, SetLlmKeyRequest, SettlePolicyRequest, SettlePolicyResponse, SubmitObservationsRequest, SubmitObservationsResponse, SubmitOutcomeRequest, SubmitOutcomeResponse, VoidOutcomesRequest, VoidOutcomesResponse, SustainabilityIndexQuery, SustainabilityIndexResponse, UpdateStationRequest, UpdateStationResponse, VerificationExportQuery } from "./types.ts"; export type FetchLike = (input: string, init?: { method?: string; headers?: Record; body?: string; signal?: AbortSignal; }) => Promise<{ ok: boolean; status: number; headers: { get(name: string): string | null; }; text(): Promise; }>; export interface GoableClientOptions { /** Tenant API key — sent as `X-Goable-Key: `. */ apiKey: string; /** Base URL. Default https://api.goable.io */ baseUrl?: string; /** Injected fetch (tests, non-global-fetch runtimes). Default globalThis.fetch. */ fetch?: FetchLike; /** Per-request timeout in ms. Default 30000. 0 disables. */ timeoutMs?: number; } export declare class GoableClient { private readonly apiKey; private readonly baseUrl; private readonly fetchImpl; private readonly timeoutMs; constructor(options: GoableClientOptions); health(): Promise; /** Readiness probe (DB + skill lookup + LLM config). Note: a degraded/critical * deployment answers `503`, which surfaces here as a {@link GoableApiError}. */ healthReady(): Promise; score(input: ScoreRequest): Promise; /** Discover the catalogue's base activity slugs (slug / display_name / * family) — the canonical list a caller can pass as `activity`. Public: * no API key required (the client still sends one if configured). Mirrors * the server's `GET /v1/profiles` alias. */ activities(): Promise; scoreSeries(input: ScoreSeriesRequest): Promise; scoreMulti(input: ScoreMultiRequest): Promise; scoreHistorical(input: ScoreHistoricalRequest): Promise; scorePortfolio(input: ScorePortfolioRequest): Promise; explainCounterfactual(input: CounterfactualRequest): Promise; decision(input: DecisionRequest): Promise; explain(input: ExplainRequest): Promise; briefing(input: BriefingRequest): Promise; projections(input: ProjectionsRequest): Promise; quote(input: QuoteRequest): Promise; /** * L10 — inverse query: given `(activity, region, radius, window)`, * returns top-K ranked sub-spots. Per-plan caps apply (radius * 25/50/200/1000 km, topK 5/10/20/50 across Free / Starter / Pro * / Scale); requests above the cap return 402 PLAN_LIMIT_EXCEEDED. * Pass `userPseudonym` on Pro+ to get personalization via the L6 * cold-start blend. */ recommendSpot(input: RecommendSpotRequest): Promise; /** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */ scoreDifficulty(input: ScoreDifficultyRequest): Promise; /** Close the calibration loop: report the observed outcome of a scored * session. The write is durable and synchronous; an unknown or non-linkable * session id is rejected `404 SESSION_NOT_FOUND` (only single `POST /v1/score` * session ids are linkable — not series/multi). Requires the `outcomes:write` * scope. Pass `idempotencyKey` so a retry after a network timeout can't * record the same outcome twice. */ reportOutcome(sessionId: string, input: ReportOutcomeRequest, options?: IdempotencyOptions): Promise; /** Report a standalone activity outcome not tied to a scored session — the * operator-reported behavioural signal behind the calibration + research * datasets. Responds 202. Requires the `outcomes:write` scope. For an * outcome linked to a specific score, use {@link reportOutcome} instead. * * Pass `reasonCategory` on the input to attribute a non-run cause * (only `weather` / `safety` feed forecast calibration; other causes are * recorded but excluded), and `batchRef` to tag a lot that a later * {@link voidOutcomes} recall can pull back. Pass `idempotencyKey` via * `options` so a retry after a network timeout can't double-record. */ submitOutcome(input: SubmitOutcomeRequest, options?: IdempotencyOptions): Promise; /** Recall ("lot recall") a batch of previously-reported outcomes: stamp the * matching rows voided so they stop influencing calibration + verification, * without deleting them (they stay for audit). Non-destructive and * idempotent — already-voided rows are skipped. At least one narrowing * selector (`batchRef`, `auditLogId`, `submittedByKeyId`, `occurredFrom`, * `occurredTo`) is REQUIRED so a recall can never blank a tenant's whole * history. Returns `{ voided }` — the number of rows retracted. Requires * the `outcomes:write` scope. */ voidOutcomes(input: VoidOutcomesRequest): Promise; /** LLM edge-case narrative for a marginal score. */ edgeCase(input: EdgeCaseRequest): Promise; /** T3 — multi-spot climate-decadal projections (Scale). */ projectionsPortfolio(input: ProjectionsPortfolioRequest): Promise; /** T3 — adaptation report across months × scenarios × decades (Scale). */ adaptationReport(input: AdaptationReportRequest): Promise; /** Fetch a stored quote by id. */ getQuote(id: string): Promise; /** * Bind a recent quote into a policy. Responds 201. A watch-level drift event * on the resolved cell surfaces as `driftAdvisories` on success; a * warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as * a {@link DriftActiveError}. */ bindPolicy(input: BindPolicyRequest, options?: IdempotencyOptions): Promise; /** List the calling tenant's bound policies (paginated, boundAt DESC). */ listPolicies(query?: ListPoliciesQuery): Promise; /** Fetch a single policy + its payout events. */ getPolicy(policyId: string): Promise; /** Re-evaluate a bound policy against the historical archive; inserts any * newly detected payout events. No request body. */ evaluatePolicy(policyId: string): Promise; /** * Settle a bound policy. PLATFORM-OPS ONLY — requires the `platform_admin` * scope (a cross-tenant underwriter operation, normally run by the daily * settlement cron). Not a policyholder self-service action; tenant * integrations should not call this. */ settlePolicy(policyId: string, input: SettlePolicyRequest): Promise; /** Register a tenant observation station. Responds 201. */ createStation(input: CreateStationRequest): Promise; /** List the calling tenant's observation stations. */ listStations(): Promise; /** Patch a station (partial update). */ updateStation(stationId: string, input: UpdateStationRequest): Promise; /** Push station observations into the 0-6h assimilation window (Pro+). * Responds 202. */ submitObservations(input: SubmitObservationsRequest): Promise; /** Most-recent observations for one of the tenant's stations. */ recentObservations(stationId: string, query?: RecentObservationsQuery): Promise; /** Public Goable Sustainability Index (JSON-LD, CC BY 4.0). */ sustainabilityIndex(query: SustainabilityIndexQuery): Promise; /** Public Stream F forecast-verification export. Returns the raw NDJSON * stream as a string (one cell per line + a trailing meta line). */ verificationExport(query?: VerificationExportQuery): Promise; /** Public L15 Difficulty Atlas export. Returns the raw NDJSON stream. */ difficultyAtlasExport(): Promise; /** Self-service tenant signup (no auth). Always 202 on success. */ publicSignup(input: PublicSignupRequest): Promise; /** Open catalogue coverage stats (no auth). */ catalogStats(): Promise; /** Fetch the current published legal document of a kind (no auth). */ legalDocument(kind: LegalDocumentKind): Promise; /** * Export the calling tenant's own score + outcome audit history for a date * range. `format: "csv"` returns the raw CSV as a `string`; the default * (`"json"`) returns the parsed {@link AuditExportResponse}. Offset-paginated * via `limit` / `offset`. */ auditExport(query: AuditExportQuery & { format: "csv"; }): Promise; auditExport(query: AuditExportQuery & { format?: "json"; }): Promise; /** Set/rotate the tenant's Anthropic API key. The server validates it with * one cheap Anthropic call, encrypts it at rest, and never echoes it back. * Resolves `void` on the 204. */ setLlmKey(input: SetLlmKeyRequest): Promise; /** Get the tenant's Anthropic key status (masked — never the key itself). */ getLlmKey(): Promise; /** Remove the tenant's Anthropic key. Resolves `void` on the 204. */ deleteLlmKey(): Promise; /** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */ deleteUserData(pseudonym: string): Promise; private request; /** Like {@link request} but returns the raw response body as text — used for * the NDJSON research streams and the `format=csv` audit export, which are * not a single JSON document. */ private requestText; private rawRequest; } //# sourceMappingURL=client.d.ts.map