@goable-io/sdk 0.4.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 { AdaptationReportRequest, AdaptationReportResponse, BindPolicyRequest, BindPolicyResponse, BriefingRequest, BriefingResponse, CatalogStatsResponse, CounterfactualRequest, CounterfactualResponse, CreateStationRequest, CreateStationResponse, DecisionRequest, DecisionResponse, DeleteUserDataResult, EdgeCaseRequest, EdgeCaseResponse, EvaluatePolicyResponse, ExplainRequest, ExplainResponse, HealthResponse, ListPoliciesQuery, ListPoliciesResponse, ListStationsResponse, 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, SettlePolicyRequest, SettlePolicyResponse, SubmitObservationsRequest, SubmitObservationsResponse, SustainabilityIndexQuery, SustainabilityIndexResponse, UpdateStationRequest, UpdateStationResponse, VerificationExportQuery } 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>;
@@ -56,8 +59,14 @@ export declare class GoableClient {
56
59
  /** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */
57
60
  scoreDifficulty(input: ScoreDifficultyRequest): Promise<ScoreDifficultyResponse>;
58
61
  /** Close the calibration loop: report the observed outcome of a scored
59
- * session. Requires the `outcomes:write` scope. */
60
- reportOutcome(sessionId: string, input: ReportOutcomeRequest): Promise<ReportOutcomeResponse>;
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>;
61
70
  /** LLM edge-case narrative for a marginal score. */
62
71
  edgeCase(input: EdgeCaseRequest): Promise<EdgeCaseResponse>;
63
72
  /** T3 — multi-spot climate-decadal projections (Scale). */
@@ -72,7 +81,7 @@ export declare class GoableClient {
72
81
  * warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
73
82
  * a {@link DriftActiveError}.
74
83
  */
75
- bindPolicy(input: BindPolicyRequest): Promise<BindPolicyResponse>;
84
+ bindPolicy(input: BindPolicyRequest, options?: IdempotencyOptions): Promise<BindPolicyResponse>;
76
85
  /** List the calling tenant's bound policies (paginated, boundAt DESC). */
77
86
  listPolicies(query?: ListPoliciesQuery): Promise<ListPoliciesResponse>;
78
87
  /** Fetch a single policy + its payout events. */
@@ -109,11 +118,34 @@ export declare class GoableClient {
109
118
  publicSignup(input: PublicSignupRequest): Promise<PublicSignupResponse>;
110
119
  /** Open catalogue coverage stats (no auth). */
111
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>;
112
143
  /** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
113
144
  deleteUserData(pseudonym: string): Promise<DeleteUserDataResult>;
114
145
  private request;
115
146
  /** Like {@link request} but returns the raw response body as text — used for
116
- * the NDJSON research streams, which are not a single JSON document. */
147
+ * the NDJSON research streams and the `format=csv` audit export, which are
148
+ * not a single JSON document. */
117
149
  private requestText;
118
150
  private rawRequest;
119
151
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,E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AAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIvE,+CAA+C;IAC/C,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI7C,qEAAqE;IAC/D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAoBxD,OAAO;IAOrB;6EACyE;YAC3D,WAAW;YAoBX,UAAU;CAkCzB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,oBA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AAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAO1F;yEACqE;IACrE,kBAAkB,CAAC,KAAK,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpE,yEAAyE;IACzE,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxC,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIvE,+CAA+C;IAC/C,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI7C,sEAAsE;IACtE,aAAa,CAAC,IAAI,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
  }
@@ -75,9 +80,17 @@ export class GoableClient {
75
80
  return this.request("POST", "/v1/score/difficulty", input);
76
81
  }
77
82
  /** Close the calibration loop: report the observed outcome of a scored
78
- * session. Requires the `outcomes:write` scope. */
79
- reportOutcome(sessionId, input) {
80
- return this.request("POST", `/v1/score/${encodeURIComponent(sessionId)}/outcome`, input);
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);
81
94
  }
82
95
  /** LLM edge-case narrative for a marginal score. */
83
96
  edgeCase(input) {
@@ -102,8 +115,8 @@ export class GoableClient {
102
115
  * warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
103
116
  * a {@link DriftActiveError}.
104
117
  */
105
- bindPolicy(input) {
106
- return this.request("POST", "/v1/underwriting/policy/bind", input);
118
+ bindPolicy(input, options) {
119
+ return this.request("POST", "/v1/underwriting/policy/bind", input, idempotencyHeader(options));
107
120
  }
108
121
  /** List the calling tenant's bound policies (paginated, boundAt DESC). */
109
122
  listPolicies(query) {
@@ -171,6 +184,31 @@ export class GoableClient {
171
184
  catalogStats() {
172
185
  return this.request("GET", "/v1/public/catalog-stats");
173
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
+ }
174
212
  /** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
175
213
  async deleteUserData(pseudonym) {
176
214
  const res = await this.rawRequest("DELETE", `/v1/decision/user-data/${encodeURIComponent(pseudonym)}`);
@@ -191,15 +229,16 @@ export class GoableClient {
191
229
  };
192
230
  }
193
231
  // ── transport ─────────────────────────────────────────────────────────────
194
- async request(method, path, body) {
195
- 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);
196
234
  const parsed = await safeJson(res);
197
235
  if (!res.ok)
198
- throw toApiError(res.status, parsed);
236
+ throw toApiError(res.status, parsed, res.headers);
199
237
  return parsed;
200
238
  }
201
239
  /** Like {@link request} but returns the raw response body as text — used for
202
- * the NDJSON research streams, which are not a single JSON document. */
240
+ * the NDJSON research streams and the `format=csv` audit export, which are
241
+ * not a single JSON document. */
203
242
  async requestText(method, path) {
204
243
  const res = await this.rawRequest(method, path);
205
244
  let text;
@@ -217,11 +256,11 @@ export class GoableClient {
217
256
  catch {
218
257
  // non-JSON error body — pass the raw text through to toApiError
219
258
  }
220
- throw toApiError(res.status, parsed);
259
+ throw toApiError(res.status, parsed, res.headers);
221
260
  }
222
261
  return text;
223
262
  }
224
- async rawRequest(method, path, body) {
263
+ async rawRequest(method, path, body, extraHeaders) {
225
264
  // `X-Goable-Key` rather than `Authorization: Bearer` — the API
226
265
  // sits behind CloudFront with OAC, which hijacks the standard
227
266
  // Authorization header for its own SigV4 signature. Custom header
@@ -234,6 +273,12 @@ export class GoableClient {
234
273
  };
235
274
  if (body !== undefined)
236
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
+ }
237
282
  const controller = this.timeoutMs > 0 ? new AbortController() : undefined;
238
283
  const timer = controller && this.timeoutMs > 0 ? setTimeout(() => controller.abort(), this.timeoutMs) : undefined;
239
284
  try {
@@ -267,6 +312,10 @@ function toQuery(params) {
267
312
  const s = usp.toString();
268
313
  return s ? `?${s}` : "";
269
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
+ }
270
319
  async function safeJson(res) {
271
320
  let text;
272
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;AA0F5D,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,OAA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,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,6 +12,24 @@ 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
34
  readonly name: string;
17
35
  /** HTTP status code. */
@@ -22,10 +40,13 @@ 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);
29
50
  }
30
51
  /**
31
52
  * Raised on a `422 DRIFT_ACTIVE` from `POST /v1/underwriting/policy/bind`:
@@ -39,10 +60,7 @@ export declare class DriftActiveError extends GoableApiError {
39
60
  /** The blocking cells, from the server's `detail.openDriftEvents`. Shape is
40
61
  * per-cell and best-effort (documented, not part of the typed contract). */
41
62
  readonly openDriftEvents: Array<Record<string, unknown>>;
42
- constructor(status: number, code: string, message?: string, extra?: {
43
- issues?: ZodIssueLike[];
44
- detail?: Record<string, unknown>;
45
- });
63
+ constructor(status: number, code: string, message?: string, extra?: ApiErrorExtra);
46
64
  }
47
65
  export declare class GoableNetworkError extends Error {
48
66
  readonly name = "GoableNetworkError";
@@ -51,7 +69,13 @@ export declare class GoableNetworkError extends Error {
51
69
  readonly cause?: unknown;
52
70
  constructor(message: string, kind: "timeout" | "network" | "parse", cause?: unknown);
53
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
+ }
54
76
  /** Map a parsed error body + status into a GoableApiError. Tolerant of a
55
- * non-conforming body (falls back to the status code as the error code). */
56
- 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;
57
81
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GA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ist/errors.js CHANGED
@@ -18,6 +18,12 @@ export class GoableApiError extends Error {
18
18
  issues;
19
19
  /** Free-form extra context (e.g. plan info, quote id). */
20
20
  detail;
21
+ /** Seconds to wait before retrying, from the `Retry-After` header. Set on a
22
+ * `429`; `null` when the header is absent or unparseable. Lets a caller
23
+ * implement a compliant back-off (`if (err.status === 429) sleep(err.retryAfterSeconds)`). */
24
+ retryAfterSeconds;
25
+ /** Rate-limit snapshot from `X-RateLimit-*` headers, when the response carried them. */
26
+ rateLimit;
21
27
  constructor(status, code, message, extra) {
22
28
  super(message ?? code);
23
29
  this.status = status;
@@ -26,6 +32,9 @@ export class GoableApiError extends Error {
26
32
  this.issues = extra.issues;
27
33
  if (extra?.detail)
28
34
  this.detail = extra.detail;
35
+ this.retryAfterSeconds = extra?.retryAfterSeconds ?? null;
36
+ if (extra?.rateLimit)
37
+ this.rateLimit = extra.rateLimit;
29
38
  // Restore prototype chain for `instanceof` across transpilation targets.
30
39
  Object.setPrototypeOf(this, GoableApiError.prototype);
31
40
  }
@@ -62,9 +71,19 @@ export class GoableNetworkError extends Error {
62
71
  Object.setPrototypeOf(this, GoableNetworkError.prototype);
63
72
  }
64
73
  }
74
+ /** Parse an integer header, returning null when absent or non-numeric. */
75
+ function intHeader(headers, name) {
76
+ const v = headers?.get(name);
77
+ if (v == null)
78
+ return null;
79
+ const n = Number(v);
80
+ return Number.isFinite(n) ? n : null;
81
+ }
65
82
  /** Map a parsed error body + status into a GoableApiError. Tolerant of a
66
- * non-conforming body (falls back to the status code as the error code). */
67
- export function toApiError(status, body) {
83
+ * non-conforming body (falls back to the status code as the error code).
84
+ * When `headers` are supplied, surfaces `Retry-After` (as `retryAfterSeconds`)
85
+ * and the `X-RateLimit-*` snapshot on the resulting error. */
86
+ export function toApiError(status, body, headers) {
68
87
  const b = (body ?? {});
69
88
  const code = typeof b.error === "string" ? b.error : `HTTP_${status}`;
70
89
  const message = typeof b.message === "string" ? b.message : undefined;
@@ -73,6 +92,13 @@ export function toApiError(status, body) {
73
92
  extra.issues = b.issues;
74
93
  if (b.detail && typeof b.detail === "object")
75
94
  extra.detail = b.detail;
95
+ extra.retryAfterSeconds = intHeader(headers, "Retry-After");
96
+ const limit = intHeader(headers, "X-RateLimit-Limit");
97
+ const remaining = intHeader(headers, "X-RateLimit-Remaining");
98
+ const reset = intHeader(headers, "X-RateLimit-Reset");
99
+ if (limit !== null && remaining !== null && reset !== null) {
100
+ extra.rateLimit = { limit, remaining, reset };
101
+ }
76
102
  // Specialise the one error the SDK models with its own class. Stays a
77
103
  // GoableApiError subclass, so generic catch sites are unaffected.
78
104
  if (code === "DRIFT_ACTIVE")
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,2EAA2E;IAC3E,mCAAmC;IACjB,IAAI,GAAW,gBAAgB,CAAA;IACjD,wBAAwB;IACf,MAAM,CAAQ;IACvB,8EAA8E;IACrE,IAAI,CAAQ;IACrB,wEAAwE;IAC/D,MAAM,CAAiB;IAChC,0DAA0D;IACjD,MAAM,CAA0B;IAEzC,YACE,MAAc,EACd,IAAY,EACZ,OAAgB,EAChB,KAAqE;QAErE,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,KAAK,EAAE,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC7C,IAAI,KAAK,EAAE,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC7C,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IACvD,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,gBAA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