@goable-io/sdk 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -81,21 +81,105 @@ new GoableClient({
81
81
 
82
82
  ## Methods
83
83
 
84
+ The client mirrors the full public tenant-facing surface — one method per
85
+ OpenAPI path. Grouped by area:
86
+
87
+ ### Score
88
+
84
89
  | Method | Endpoint | Notes |
85
90
  |---|---|---|
86
- | `score(input)` | `POST /v1/score` | `ensemble: true` → probabilistic (Pro+) |
91
+ | `score(input)` | `POST /v1/score` | `ensemble: true` → probabilistic (Pro+); `rider_skill_level` skill-conditioned (Pro+) |
87
92
  | `scoreSeries(input)` | `POST /v1/score/series` | per-step over a window |
88
93
  | `scoreMulti(input)` | `POST /v1/score/multi` | many activities, one location |
89
94
  | `scoreHistorical(input)` | `POST /v1/score/historical` | climatology percentiles (Pro+) |
90
95
  | `scorePortfolio(input)` | `POST /v1/score/portfolio` | multi-spot joint variance |
96
+ | `scoreDifficulty(input)` | `POST /v1/score/difficulty` | L15 skill-conditioned difficulty grids (Pro+) |
91
97
  | `explainCounterfactual(input)` | `POST /v1/score/explain-counterfactual` | binding constraint, sensitivities, best window/spot |
98
+ | `reportOutcome(sessionId, input, opts?)` | `POST /v1/score/{sessionId}/outcome` | close the calibration loop; `opts.idempotencyKey` |
99
+
100
+ ### Recommend
101
+
102
+ | Method | Endpoint | Notes |
103
+ |---|---|---|
92
104
  | `recommendSpot(input)` | `POST /v1/recommend-spot` | inverse query: top-K ranked sub-spots |
105
+
106
+ ### Decision
107
+
108
+ | Method | Endpoint | Notes |
109
+ |---|---|---|
93
110
  | `decision(input)` | `POST /v1/decision` | personalized go/no-go (Pro+) |
94
- | `deleteUserData(pseudonym)` | `DELETE /v1/decision/user-data/:p` | GDPR erasure; returns receipt headers |
95
- | `explain(input)` / `briefing(input)` | `POST /v1/intelligence/*` | LLM narratives (Pro+) |
96
- | `projections(input)` | `POST /v1/projections` | climate-decadal (Scale) |
97
- | `quote(input)` | `POST /v1/underwriting/quote` | parametric premium (Scale) |
111
+ | `deleteUserData(pseudonym)` | `DELETE /v1/decision/user-data/{pseudonym}` | GDPR erasure; returns receipt headers |
112
+
113
+ ### Intelligence
114
+
115
+ | Method | Endpoint | Notes |
116
+ |---|---|---|
117
+ | `explain(input)` | `POST /v1/intelligence/explain` | LLM narrative (Pro+) |
118
+ | `briefing(input)` | `POST /v1/intelligence/briefing` | LLM briefing (Pro+) |
119
+ | `edgeCase(input)` | `POST /v1/intelligence/edge-case` | LLM edge-case narrative for a marginal score |
120
+
121
+ ### Projections (Scale)
122
+
123
+ | Method | Endpoint | Notes |
124
+ |---|---|---|
125
+ | `projections(input)` | `POST /v1/projections` | single-spot climate-decadal |
126
+ | `projectionsPortfolio(input)` | `POST /v1/projections/portfolio` | multi-spot |
127
+ | `adaptationReport(input)` | `POST /v1/projections/adaptation-report` | months × scenarios × decades |
128
+
129
+ ### Underwriting (Scale)
130
+
131
+ | Method | Endpoint | Notes |
132
+ |---|---|---|
133
+ | `quote(input)` | `POST /v1/underwriting/quote` | parametric premium |
134
+ | `getQuote(id)` | `GET /v1/underwriting/quote/{id}` | fetch a stored quote |
135
+ | `bindPolicy(input, opts?)` | `POST /v1/underwriting/policy/bind` | bind a quote; `opts.idempotencyKey`; 422 `DRIFT_ACTIVE` → `DriftActiveError` |
136
+ | `listPolicies(query?)` | `GET /v1/underwriting/policy` | paginated, `boundAt` DESC |
137
+ | `getPolicy(policyId)` | `GET /v1/underwriting/policy/{policyId}` | policy + payout events |
138
+ | `evaluatePolicy(policyId)` | `POST /v1/underwriting/policy/{policyId}/evaluate` | re-evaluate; bodyless |
139
+ | `settlePolicy(policyId, input)` | `POST /v1/underwriting/policy/{policyId}/settle` | platform-ops only |
140
+
141
+ ### Observations / nowcasting (L5.3)
142
+
143
+ | Method | Endpoint | Notes |
144
+ |---|---|---|
145
+ | `createStation(input)` | `POST /v1/observations/stations` | register a station |
146
+ | `listStations()` | `GET /v1/observations/stations` | the tenant's stations |
147
+ | `updateStation(stationId, input)` | `PATCH /v1/observations/stations/{stationId}` | partial update |
148
+ | `recentObservations(stationId, query?)` | `GET /v1/observations/stations/{stationId}/recent` | most-recent observations |
149
+ | `submitObservations(input)` | `POST /v1/observations` | push into the 0-6h window (Pro+) |
150
+ | `submitOutcome(input)` | `POST /v1/outcomes` | standalone outcome (not tied to a scored session) |
151
+
152
+ ### Audit & compliance
153
+
154
+ | Method | Endpoint | Notes |
155
+ |---|---|---|
156
+ | `auditExport(query)` | `GET /v1/audit/export` | `format: "csv"` → `string`, else parsed JSON |
157
+
158
+ ### LLM BYOK (bring-your-own Anthropic key)
159
+
160
+ | Method | Endpoint | Notes |
161
+ |---|---|---|
162
+ | `setLlmKey(input)` | `PUT /v1/tenant/llm-key` | validate + store; resolves `void` (204) |
163
+ | `getLlmKey()` | `GET /v1/tenant/llm-key` | masked status (never the key) |
164
+ | `deleteLlmKey()` | `DELETE /v1/tenant/llm-key` | remove; resolves `void` (204) |
165
+
166
+ ### Health, legal & public (no auth)
167
+
168
+ | Method | Endpoint | Notes |
169
+ |---|---|---|
98
170
  | `health()` | `GET /v1/health` | liveness |
171
+ | `healthReady()` | `GET /v1/health/ready` | readiness (503 → `GoableApiError`) |
172
+ | `legalDocument(kind)` | `GET /v1/legal/{kind}/current` | current published legal doc |
173
+ | `catalogStats()` | `GET /v1/public/catalog-stats` | open catalogue coverage stats |
174
+ | `sustainabilityIndex(query)` | `GET /v1/public/sustainability-index` | Goable Sustainability Index (JSON-LD) |
175
+ | `publicSignup(input)` | `POST /v1/public/signup` | self-service tenant signup |
176
+
177
+ ### Research (open data, CC BY — NDJSON streams returned as `string`)
178
+
179
+ | Method | Endpoint | Notes |
180
+ |---|---|---|
181
+ | `difficultyAtlasExport()` | `GET /v1/research/difficulty-atlas/export.jsonl` | L15 Difficulty Atlas |
182
+ | `verificationExport(query?)` | `GET /v1/research/verification/export` | Stream F forecast verification |
99
183
 
100
184
  Full endpoint reference: [goable.io/docs](https://goable.io/docs).
101
185
 
@@ -108,16 +192,30 @@ try {
108
192
  await goable.score({ activity: "kitesurfing", location: { lat: 43.7, lng: 7.27 }, ensemble: true })
109
193
  } catch (err) {
110
194
  if (err instanceof GoableApiError) {
111
- err.status // e.g. 402
112
- err.code // e.g. "PAYMENT_REQUIRED"
113
- err.issues // Zod issues on 422 VALIDATION_ERROR
114
- err.detail // free-form context (e.g. plan info)
195
+ err.status // e.g. 402
196
+ err.code // e.g. "PAYMENT_REQUIRED"
197
+ err.issues // Zod issues on 422 VALIDATION_ERROR
198
+ err.detail // free-form context (e.g. plan info)
199
+ err.retryAfterSeconds // seconds from `Retry-After` on a 429 (else null)
200
+ err.rateLimit // { limit, remaining, reset } when the response carried X-RateLimit-* headers
115
201
  } else if (err instanceof GoableNetworkError) {
116
202
  err.kind // "timeout" | "network" | "parse"
117
203
  }
118
204
  }
119
205
  ```
120
206
 
207
+ On a `429`, back off using the server's hint:
208
+
209
+ ```ts
210
+ if (err instanceof GoableApiError && err.status === 429 && err.retryAfterSeconds != null) {
211
+ await new Promise((r) => setTimeout(r, err.retryAfterSeconds! * 1000))
212
+ // …then retry
213
+ }
214
+ ```
215
+
216
+ `DriftActiveError` (a `GoableApiError` subclass) is thrown on `422 DRIFT_ACTIVE`
217
+ from `bindPolicy()` and exposes `openDriftEvents`.
218
+
121
219
  ## Browser use
122
220
 
123
221
  The client runs in the browser, but **API keys are secrets** — prefer
package/dist/client.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * GoableClient — thin typed transport over the public Goable REST API.
3
3
  * No caching, no business logic; one `request<T>` powers every method.
4
4
  */
5
- import type { BriefingRequest, BriefingResponse, CounterfactualRequest, CounterfactualResponse, DecisionRequest, DecisionResponse, DeleteUserDataResult, ExplainRequest, ExplainResponse, HealthResponse, ProjectionsRequest, ProjectionsResponse, QuoteRequest, QuoteResponse, RecommendSpotRequest, RecommendSpotResponse, ScoreHistoricalRequest, ScoreHistoricalResponse, ScoreMultiRequest, ScoreMultiResponse, ScorePortfolioRequest, ScorePortfolioResponse, ScoreRequest, ScoreResponse, ScoreSeriesRequest, ScoreSeriesResponse } from "./types.ts";
5
+ import type { 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, SustainabilityIndexQuery, SustainabilityIndexResponse, UpdateStationRequest, UpdateStationResponse, VerificationExportQuery } from "./types.ts";
6
6
  export type FetchLike = (input: string, init?: {
7
7
  method?: string;
8
8
  headers?: Record<string, string>;
@@ -33,6 +33,9 @@ export declare class GoableClient {
33
33
  private readonly timeoutMs;
34
34
  constructor(options: GoableClientOptions);
35
35
  health(): Promise<HealthResponse>;
36
+ /** Readiness probe (DB + skill lookup + LLM config). Note: a degraded/critical
37
+ * deployment answers `503`, which surfaces here as a {@link GoableApiError}. */
38
+ healthReady(): Promise<HealthReadyResponse>;
36
39
  score(input: ScoreRequest): Promise<ScoreResponse>;
37
40
  scoreSeries(input: ScoreSeriesRequest): Promise<ScoreSeriesResponse>;
38
41
  scoreMulti(input: ScoreMultiRequest): Promise<ScoreMultiResponse>;
@@ -53,9 +56,97 @@ export declare class GoableClient {
53
56
  * cold-start blend.
54
57
  */
55
58
  recommendSpot(input: RecommendSpotRequest): Promise<RecommendSpotResponse>;
59
+ /** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */
60
+ scoreDifficulty(input: ScoreDifficultyRequest): Promise<ScoreDifficultyResponse>;
61
+ /** Close the calibration loop: report the observed outcome of a scored
62
+ * session. Requires the `outcomes:write` scope. Pass `idempotencyKey` so a
63
+ * retry after a network timeout can't record the same outcome twice. */
64
+ reportOutcome(sessionId: string, input: ReportOutcomeRequest, options?: IdempotencyOptions): Promise<ReportOutcomeResponse>;
65
+ /** Report a standalone activity outcome not tied to a scored session — the
66
+ * operator-reported behavioural signal behind the calibration + research
67
+ * datasets. Responds 202. Requires the `outcomes:write` scope. For an
68
+ * outcome linked to a specific score, use {@link reportOutcome} instead. */
69
+ submitOutcome(input: SubmitOutcomeRequest): Promise<SubmitOutcomeResponse>;
70
+ /** LLM edge-case narrative for a marginal score. */
71
+ edgeCase(input: EdgeCaseRequest): Promise<EdgeCaseResponse>;
72
+ /** T3 — multi-spot climate-decadal projections (Scale). */
73
+ projectionsPortfolio(input: ProjectionsPortfolioRequest): Promise<ProjectionsPortfolioResponse>;
74
+ /** T3 — adaptation report across months × scenarios × decades (Scale). */
75
+ adaptationReport(input: AdaptationReportRequest): Promise<AdaptationReportResponse>;
76
+ /** Fetch a stored quote by id. */
77
+ getQuote(id: string): Promise<QuoteByIdResponse>;
78
+ /**
79
+ * Bind a recent quote into a policy. Responds 201. A watch-level drift event
80
+ * on the resolved cell surfaces as `driftAdvisories` on success; a
81
+ * warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
82
+ * a {@link DriftActiveError}.
83
+ */
84
+ bindPolicy(input: BindPolicyRequest, options?: IdempotencyOptions): Promise<BindPolicyResponse>;
85
+ /** List the calling tenant's bound policies (paginated, boundAt DESC). */
86
+ listPolicies(query?: ListPoliciesQuery): Promise<ListPoliciesResponse>;
87
+ /** Fetch a single policy + its payout events. */
88
+ getPolicy(policyId: string): Promise<PolicyResponse>;
89
+ /** Re-evaluate a bound policy against the historical archive; inserts any
90
+ * newly detected payout events. No request body. */
91
+ evaluatePolicy(policyId: string): Promise<EvaluatePolicyResponse>;
92
+ /**
93
+ * Settle a bound policy. PLATFORM-OPS ONLY — requires the `platform_admin`
94
+ * scope (a cross-tenant underwriter operation, normally run by the daily
95
+ * settlement cron). Not a policyholder self-service action; tenant
96
+ * integrations should not call this.
97
+ */
98
+ settlePolicy(policyId: string, input: SettlePolicyRequest): Promise<SettlePolicyResponse>;
99
+ /** Register a tenant observation station. Responds 201. */
100
+ createStation(input: CreateStationRequest): Promise<CreateStationResponse>;
101
+ /** List the calling tenant's observation stations. */
102
+ listStations(): Promise<ListStationsResponse>;
103
+ /** Patch a station (partial update). */
104
+ updateStation(stationId: string, input: UpdateStationRequest): Promise<UpdateStationResponse>;
105
+ /** Push station observations into the 0-6h assimilation window (Pro+).
106
+ * Responds 202. */
107
+ submitObservations(input: SubmitObservationsRequest): Promise<SubmitObservationsResponse>;
108
+ /** Most-recent observations for one of the tenant's stations. */
109
+ recentObservations(stationId: string, query?: RecentObservationsQuery): Promise<RecentObservationsResponse>;
110
+ /** Public Goable Sustainability Index (JSON-LD, CC BY 4.0). */
111
+ sustainabilityIndex(query: SustainabilityIndexQuery): Promise<SustainabilityIndexResponse>;
112
+ /** Public Stream F forecast-verification export. Returns the raw NDJSON
113
+ * stream as a string (one cell per line + a trailing meta line). */
114
+ verificationExport(query?: VerificationExportQuery): Promise<string>;
115
+ /** Public L15 Difficulty Atlas export. Returns the raw NDJSON stream. */
116
+ difficultyAtlasExport(): Promise<string>;
117
+ /** Self-service tenant signup (no auth). Always 202 on success. */
118
+ publicSignup(input: PublicSignupRequest): Promise<PublicSignupResponse>;
119
+ /** Open catalogue coverage stats (no auth). */
120
+ catalogStats(): Promise<CatalogStatsResponse>;
121
+ /** Fetch the current published legal document of a kind (no auth). */
122
+ legalDocument(kind: LegalDocumentKind): Promise<LegalDocumentResponse>;
123
+ /**
124
+ * Export the calling tenant's own score + outcome audit history for a date
125
+ * range. `format: "csv"` returns the raw CSV as a `string`; the default
126
+ * (`"json"`) returns the parsed {@link AuditExportResponse}. Offset-paginated
127
+ * via `limit` / `offset`.
128
+ */
129
+ auditExport(query: AuditExportQuery & {
130
+ format: "csv";
131
+ }): Promise<string>;
132
+ auditExport(query: AuditExportQuery & {
133
+ format?: "json";
134
+ }): Promise<AuditExportResponse>;
135
+ /** Set/rotate the tenant's Anthropic API key. The server validates it with
136
+ * one cheap Anthropic call, encrypts it at rest, and never echoes it back.
137
+ * Resolves `void` on the 204. */
138
+ setLlmKey(input: SetLlmKeyRequest): Promise<void>;
139
+ /** Get the tenant's Anthropic key status (masked — never the key itself). */
140
+ getLlmKey(): Promise<LlmKeyStatus>;
141
+ /** Remove the tenant's Anthropic key. Resolves `void` on the 204. */
142
+ deleteLlmKey(): Promise<void>;
56
143
  /** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
57
144
  deleteUserData(pseudonym: string): Promise<DeleteUserDataResult>;
58
145
  private request;
146
+ /** Like {@link request} but returns the raw response body as text — used for
147
+ * the NDJSON research streams and the `format=csv` audit export, which are
148
+ * not a single JSON document. */
149
+ private requestText;
59
150
  private rawRequest;
60
151
  }
61
152
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,qBAAqB,E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,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQtE;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG;QAAE,MAAM,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IACzE,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQxF;;sCAEkC;IAC5B,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,6EAA6E;IAC7E,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC;IAIlC,qEAAqE;IAC/D,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,qEAAqE;IAC/D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAoBxD,OAAO;IAYrB;;sCAEkC;YACpB,WAAW;YAoBX,UAAU;CA4CzB"}
package/dist/client.js CHANGED
@@ -26,6 +26,11 @@ export class GoableClient {
26
26
  health() {
27
27
  return this.request("GET", "/v1/health");
28
28
  }
29
+ /** Readiness probe (DB + skill lookup + LLM config). Note: a degraded/critical
30
+ * deployment answers `503`, which surfaces here as a {@link GoableApiError}. */
31
+ healthReady() {
32
+ return this.request("GET", "/v1/health/ready");
33
+ }
29
34
  score(input) {
30
35
  return this.request("POST", "/v1/score", input);
31
36
  }
@@ -70,6 +75,140 @@ export class GoableClient {
70
75
  recommendSpot(input) {
71
76
  return this.request("POST", "/v1/recommend-spot", input);
72
77
  }
78
+ /** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */
79
+ scoreDifficulty(input) {
80
+ return this.request("POST", "/v1/score/difficulty", input);
81
+ }
82
+ /** Close the calibration loop: report the observed outcome of a scored
83
+ * session. Requires the `outcomes:write` scope. Pass `idempotencyKey` so a
84
+ * retry after a network timeout can't record the same outcome twice. */
85
+ reportOutcome(sessionId, input, options) {
86
+ return this.request("POST", `/v1/score/${encodeURIComponent(sessionId)}/outcome`, input, idempotencyHeader(options));
87
+ }
88
+ /** Report a standalone activity outcome not tied to a scored session — the
89
+ * operator-reported behavioural signal behind the calibration + research
90
+ * datasets. Responds 202. Requires the `outcomes:write` scope. For an
91
+ * outcome linked to a specific score, use {@link reportOutcome} instead. */
92
+ submitOutcome(input) {
93
+ return this.request("POST", "/v1/outcomes", input);
94
+ }
95
+ /** LLM edge-case narrative for a marginal score. */
96
+ edgeCase(input) {
97
+ return this.request("POST", "/v1/intelligence/edge-case", input);
98
+ }
99
+ /** T3 — multi-spot climate-decadal projections (Scale). */
100
+ projectionsPortfolio(input) {
101
+ return this.request("POST", "/v1/projections/portfolio", input);
102
+ }
103
+ /** T3 — adaptation report across months × scenarios × decades (Scale). */
104
+ adaptationReport(input) {
105
+ return this.request("POST", "/v1/projections/adaptation-report", input);
106
+ }
107
+ // ── underwriting policy lifecycle (Scale) ─────────────────────────────────
108
+ /** Fetch a stored quote by id. */
109
+ getQuote(id) {
110
+ return this.request("GET", `/v1/underwriting/quote/${encodeURIComponent(id)}`);
111
+ }
112
+ /**
113
+ * Bind a recent quote into a policy. Responds 201. A watch-level drift event
114
+ * on the resolved cell surfaces as `driftAdvisories` on success; a
115
+ * warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
116
+ * a {@link DriftActiveError}.
117
+ */
118
+ bindPolicy(input, options) {
119
+ return this.request("POST", "/v1/underwriting/policy/bind", input, idempotencyHeader(options));
120
+ }
121
+ /** List the calling tenant's bound policies (paginated, boundAt DESC). */
122
+ listPolicies(query) {
123
+ return this.request("GET", `/v1/underwriting/policy${toQuery(query)}`);
124
+ }
125
+ /** Fetch a single policy + its payout events. */
126
+ getPolicy(policyId) {
127
+ return this.request("GET", `/v1/underwriting/policy/${encodeURIComponent(policyId)}`);
128
+ }
129
+ /** Re-evaluate a bound policy against the historical archive; inserts any
130
+ * newly detected payout events. No request body. */
131
+ evaluatePolicy(policyId) {
132
+ return this.request("POST", `/v1/underwriting/policy/${encodeURIComponent(policyId)}/evaluate`);
133
+ }
134
+ /**
135
+ * Settle a bound policy. PLATFORM-OPS ONLY — requires the `platform_admin`
136
+ * scope (a cross-tenant underwriter operation, normally run by the daily
137
+ * settlement cron). Not a policyholder self-service action; tenant
138
+ * integrations should not call this.
139
+ */
140
+ settlePolicy(policyId, input) {
141
+ return this.request("POST", `/v1/underwriting/policy/${encodeURIComponent(policyId)}/settle`, input);
142
+ }
143
+ // ── observations / nowcasting (L5.3) ──────────────────────────────────────
144
+ /** Register a tenant observation station. Responds 201. */
145
+ createStation(input) {
146
+ return this.request("POST", "/v1/observations/stations", input);
147
+ }
148
+ /** List the calling tenant's observation stations. */
149
+ listStations() {
150
+ return this.request("GET", "/v1/observations/stations");
151
+ }
152
+ /** Patch a station (partial update). */
153
+ updateStation(stationId, input) {
154
+ return this.request("PATCH", `/v1/observations/stations/${encodeURIComponent(stationId)}`, input);
155
+ }
156
+ /** Push station observations into the 0-6h assimilation window (Pro+).
157
+ * Responds 202. */
158
+ submitObservations(input) {
159
+ return this.request("POST", "/v1/observations", input);
160
+ }
161
+ /** Most-recent observations for one of the tenant's stations. */
162
+ recentObservations(stationId, query) {
163
+ return this.request("GET", `/v1/observations/stations/${encodeURIComponent(stationId)}/recent${toQuery(query)}`);
164
+ }
165
+ // ── public / research (no-auth surfaces) ──────────────────────────────────
166
+ /** Public Goable Sustainability Index (JSON-LD, CC BY 4.0). */
167
+ sustainabilityIndex(query) {
168
+ return this.request("GET", `/v1/public/sustainability-index${toQuery(query)}`);
169
+ }
170
+ /** Public Stream F forecast-verification export. Returns the raw NDJSON
171
+ * stream as a string (one cell per line + a trailing meta line). */
172
+ verificationExport(query) {
173
+ return this.requestText("GET", `/v1/research/verification/export${toQuery(query)}`);
174
+ }
175
+ /** Public L15 Difficulty Atlas export. Returns the raw NDJSON stream. */
176
+ difficultyAtlasExport() {
177
+ return this.requestText("GET", "/v1/research/difficulty-atlas/export.jsonl");
178
+ }
179
+ /** Self-service tenant signup (no auth). Always 202 on success. */
180
+ publicSignup(input) {
181
+ return this.request("POST", "/v1/public/signup", input);
182
+ }
183
+ /** Open catalogue coverage stats (no auth). */
184
+ catalogStats() {
185
+ return this.request("GET", "/v1/public/catalog-stats");
186
+ }
187
+ /** Fetch the current published legal document of a kind (no auth). */
188
+ legalDocument(kind) {
189
+ return this.request("GET", `/v1/legal/${encodeURIComponent(kind)}/current`);
190
+ }
191
+ auditExport(query) {
192
+ const path = `/v1/audit/export${toQuery(query)}`;
193
+ if (query.format === "csv")
194
+ return this.requestText("GET", path);
195
+ return this.request("GET", path);
196
+ }
197
+ // ── LLM BYOK (bring-your-own Anthropic key) ───────────────────────────────
198
+ /** Set/rotate the tenant's Anthropic API key. The server validates it with
199
+ * one cheap Anthropic call, encrypts it at rest, and never echoes it back.
200
+ * Resolves `void` on the 204. */
201
+ async setLlmKey(input) {
202
+ await this.request("PUT", "/v1/tenant/llm-key", input);
203
+ }
204
+ /** Get the tenant's Anthropic key status (masked — never the key itself). */
205
+ getLlmKey() {
206
+ return this.request("GET", "/v1/tenant/llm-key");
207
+ }
208
+ /** Remove the tenant's Anthropic key. Resolves `void` on the 204. */
209
+ async deleteLlmKey() {
210
+ await this.request("DELETE", "/v1/tenant/llm-key");
211
+ }
73
212
  /** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
74
213
  async deleteUserData(pseudonym) {
75
214
  const res = await this.rawRequest("DELETE", `/v1/decision/user-data/${encodeURIComponent(pseudonym)}`);
@@ -90,14 +229,38 @@ export class GoableClient {
90
229
  };
91
230
  }
92
231
  // ── transport ─────────────────────────────────────────────────────────────
93
- async request(method, path, body) {
94
- const res = await this.rawRequest(method, path, body);
232
+ async request(method, path, body, extraHeaders) {
233
+ const res = await this.rawRequest(method, path, body, extraHeaders);
95
234
  const parsed = await safeJson(res);
96
235
  if (!res.ok)
97
- throw toApiError(res.status, parsed);
236
+ throw toApiError(res.status, parsed, res.headers);
98
237
  return parsed;
99
238
  }
100
- async rawRequest(method, path, body) {
239
+ /** Like {@link request} but returns the raw response body as text — used for
240
+ * the NDJSON research streams and the `format=csv` audit export, which are
241
+ * not a single JSON document. */
242
+ async requestText(method, path) {
243
+ const res = await this.rawRequest(method, path);
244
+ let text;
245
+ try {
246
+ text = await res.text();
247
+ }
248
+ catch (err) {
249
+ throw new GoableNetworkError("Failed to read response body", "parse", err);
250
+ }
251
+ if (!res.ok) {
252
+ let parsed = text;
253
+ try {
254
+ parsed = JSON.parse(text);
255
+ }
256
+ catch {
257
+ // non-JSON error body — pass the raw text through to toApiError
258
+ }
259
+ throw toApiError(res.status, parsed, res.headers);
260
+ }
261
+ return text;
262
+ }
263
+ async rawRequest(method, path, body, extraHeaders) {
101
264
  // `X-Goable-Key` rather than `Authorization: Bearer` — the API
102
265
  // sits behind CloudFront with OAC, which hijacks the standard
103
266
  // Authorization header for its own SigV4 signature. Custom header
@@ -110,6 +273,12 @@ export class GoableClient {
110
273
  };
111
274
  if (body !== undefined)
112
275
  headers["Content-Type"] = "application/json";
276
+ if (extraHeaders) {
277
+ for (const [k, v] of Object.entries(extraHeaders)) {
278
+ if (v !== undefined)
279
+ headers[k] = v;
280
+ }
281
+ }
113
282
  const controller = this.timeoutMs > 0 ? new AbortController() : undefined;
114
283
  const timer = controller && this.timeoutMs > 0 ? setTimeout(() => controller.abort(), this.timeoutMs) : undefined;
115
284
  try {
@@ -130,6 +299,23 @@ export class GoableClient {
130
299
  }
131
300
  }
132
301
  }
302
+ /** Serialise a query object into a leading-`?` string (or "" when empty).
303
+ * Skips undefined/null; isomorphic (URLSearchParams is a Node 18+/browser global). */
304
+ function toQuery(params) {
305
+ if (!params)
306
+ return "";
307
+ const usp = new URLSearchParams();
308
+ for (const [k, v] of Object.entries(params)) {
309
+ if (v !== undefined && v !== null)
310
+ usp.append(k, String(v));
311
+ }
312
+ const s = usp.toString();
313
+ return s ? `?${s}` : "";
314
+ }
315
+ /** Build the optional `Idempotency-Key` header bag from per-call options. */
316
+ function idempotencyHeader(options) {
317
+ return options?.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : undefined;
318
+ }
133
319
  async function safeJson(res) {
134
320
  let text;
135
321
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAwD5D,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAChD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC,MAAM,OAAO,YAAY;IACN,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,SAAS,CAAW;IACpB,SAAS,CAAQ;IAElC,YAAY,OAA4B;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACvE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACxE,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,IAAK,UAAU,CAAC,KAA0C,CAAA;QACjF,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAA;QAC7F,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAA;IAC1D,CAAC;IAED,2EAA2E;IAC3E,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAiB,KAAK,EAAE,YAAY,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,KAAmB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAg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E,GAAG,CAAC,CAAA;IAC5E,CAAC;IACD,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -12,8 +12,26 @@ export interface ZodIssueLike {
12
12
  message?: string;
13
13
  [k: string]: unknown;
14
14
  }
15
+ /** Rate-limit snapshot parsed from `X-RateLimit-*` response headers. Present
16
+ * when the server sent them (currently the `score` + `recommend-spot`
17
+ * endpoints; omitted on unlimited Scale plans). */
18
+ export interface RateLimit {
19
+ /** `X-RateLimit-Limit` — daily safety cap for this endpoint + plan. */
20
+ limit: number;
21
+ /** `X-RateLimit-Remaining` — requests left in the current window. */
22
+ remaining: number;
23
+ /** `X-RateLimit-Reset` — Unix timestamp (seconds) when the window resets. */
24
+ reset: number;
25
+ }
26
+ /** Structured extras attached to a {@link GoableApiError}. */
27
+ export interface ApiErrorExtra {
28
+ issues?: ZodIssueLike[];
29
+ detail?: Record<string, unknown>;
30
+ retryAfterSeconds?: number | null;
31
+ rateLimit?: RateLimit;
32
+ }
15
33
  export declare class GoableApiError extends Error {
16
- readonly name = "GoableApiError";
34
+ readonly name: string;
17
35
  /** HTTP status code. */
18
36
  readonly status: number;
19
37
  /** Machine-readable code from the `error` field (e.g. "PAYMENT_REQUIRED"). */
@@ -22,10 +40,27 @@ export declare class GoableApiError extends Error {
22
40
  readonly issues?: ZodIssueLike[];
23
41
  /** Free-form extra context (e.g. plan info, quote id). */
24
42
  readonly detail?: Record<string, unknown>;
25
- constructor(status: number, code: string, message?: string, extra?: {
26
- issues?: ZodIssueLike[];
27
- detail?: Record<string, unknown>;
28
- });
43
+ /** Seconds to wait before retrying, from the `Retry-After` header. Set on a
44
+ * `429`; `null` when the header is absent or unparseable. Lets a caller
45
+ * implement a compliant back-off (`if (err.status === 429) sleep(err.retryAfterSeconds)`). */
46
+ readonly retryAfterSeconds: number | null;
47
+ /** Rate-limit snapshot from `X-RateLimit-*` headers, when the response carried them. */
48
+ readonly rateLimit?: RateLimit;
49
+ constructor(status: number, code: string, message?: string, extra?: ApiErrorExtra);
50
+ }
51
+ /**
52
+ * Raised on a `422 DRIFT_ACTIVE` from `POST /v1/underwriting/policy/bind`:
53
+ * the resolved cell has an open warning/critical L9 drift event, so the bind
54
+ * is refused (a watch-level event is a soft `driftAdvisories` on success, not
55
+ * an error). Subclasses `GoableApiError`, so existing `instanceof
56
+ * GoableApiError` / `.code === "DRIFT_ACTIVE"` checks keep working.
57
+ */
58
+ export declare class DriftActiveError extends GoableApiError {
59
+ readonly name = "DriftActiveError";
60
+ /** The blocking cells, from the server's `detail.openDriftEvents`. Shape is
61
+ * per-cell and best-effort (documented, not part of the typed contract). */
62
+ readonly openDriftEvents: Array<Record<string, unknown>>;
63
+ constructor(status: number, code: string, message?: string, extra?: ApiErrorExtra);
29
64
  }
30
65
  export declare class GoableNetworkError extends Error {
31
66
  readonly name = "GoableNetworkError";
@@ -34,7 +69,13 @@ export declare class GoableNetworkError extends Error {
34
69
  readonly cause?: unknown;
35
70
  constructor(message: string, kind: "timeout" | "network" | "parse", cause?: unknown);
36
71
  }
72
+ /** A minimal read-only header bag (the `headers` of a fetch Response). */
73
+ export interface HeaderBag {
74
+ get(name: string): string | null;
75
+ }
37
76
  /** Map a parsed error body + status into a GoableApiError. Tolerant of a
38
- * non-conforming body (falls back to the status code as the error code). */
39
- export declare function toApiError(status: number, body: unknown): GoableApiError;
77
+ * non-conforming body (falls back to the status code as the error code).
78
+ * When `headers` are supplied, surfaces `Retry-After` (as `retryAfterSeconds`)
79
+ * and the `X-RateLimit-*` snapshot on the resulting error. */
80
+ export declare function toApiError(status: number, body: unknown, headers?: HeaderBag): GoableApiError;
40
81
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file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