@goable-io/sdk 0.3.0 → 0.4.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/dist/client.d.ts +60 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +137 -0
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +18 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/api.d.ts +1421 -370
- package/dist/generated/api.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +76 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +214 -0
- package/src/errors.ts +32 -1
- package/src/generated/api.ts +1421 -370
- package/src/index.ts +1 -0
- package/src/types.ts +104 -6
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, 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";
|
|
6
6
|
export type FetchLike = (input: string, init?: {
|
|
7
7
|
method?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
@@ -53,9 +53,68 @@ export declare class GoableClient {
|
|
|
53
53
|
* cold-start blend.
|
|
54
54
|
*/
|
|
55
55
|
recommendSpot(input: RecommendSpotRequest): Promise<RecommendSpotResponse>;
|
|
56
|
+
/** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */
|
|
57
|
+
scoreDifficulty(input: ScoreDifficultyRequest): Promise<ScoreDifficultyResponse>;
|
|
58
|
+
/** 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>;
|
|
61
|
+
/** LLM edge-case narrative for a marginal score. */
|
|
62
|
+
edgeCase(input: EdgeCaseRequest): Promise<EdgeCaseResponse>;
|
|
63
|
+
/** T3 — multi-spot climate-decadal projections (Scale). */
|
|
64
|
+
projectionsPortfolio(input: ProjectionsPortfolioRequest): Promise<ProjectionsPortfolioResponse>;
|
|
65
|
+
/** T3 — adaptation report across months × scenarios × decades (Scale). */
|
|
66
|
+
adaptationReport(input: AdaptationReportRequest): Promise<AdaptationReportResponse>;
|
|
67
|
+
/** Fetch a stored quote by id. */
|
|
68
|
+
getQuote(id: string): Promise<QuoteByIdResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Bind a recent quote into a policy. Responds 201. A watch-level drift event
|
|
71
|
+
* on the resolved cell surfaces as `driftAdvisories` on success; a
|
|
72
|
+
* warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
|
|
73
|
+
* a {@link DriftActiveError}.
|
|
74
|
+
*/
|
|
75
|
+
bindPolicy(input: BindPolicyRequest): Promise<BindPolicyResponse>;
|
|
76
|
+
/** List the calling tenant's bound policies (paginated, boundAt DESC). */
|
|
77
|
+
listPolicies(query?: ListPoliciesQuery): Promise<ListPoliciesResponse>;
|
|
78
|
+
/** Fetch a single policy + its payout events. */
|
|
79
|
+
getPolicy(policyId: string): Promise<PolicyResponse>;
|
|
80
|
+
/** Re-evaluate a bound policy against the historical archive; inserts any
|
|
81
|
+
* newly detected payout events. No request body. */
|
|
82
|
+
evaluatePolicy(policyId: string): Promise<EvaluatePolicyResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Settle a bound policy. PLATFORM-OPS ONLY — requires the `platform_admin`
|
|
85
|
+
* scope (a cross-tenant underwriter operation, normally run by the daily
|
|
86
|
+
* settlement cron). Not a policyholder self-service action; tenant
|
|
87
|
+
* integrations should not call this.
|
|
88
|
+
*/
|
|
89
|
+
settlePolicy(policyId: string, input: SettlePolicyRequest): Promise<SettlePolicyResponse>;
|
|
90
|
+
/** Register a tenant observation station. Responds 201. */
|
|
91
|
+
createStation(input: CreateStationRequest): Promise<CreateStationResponse>;
|
|
92
|
+
/** List the calling tenant's observation stations. */
|
|
93
|
+
listStations(): Promise<ListStationsResponse>;
|
|
94
|
+
/** Patch a station (partial update). */
|
|
95
|
+
updateStation(stationId: string, input: UpdateStationRequest): Promise<UpdateStationResponse>;
|
|
96
|
+
/** Push station observations into the 0-6h assimilation window (Pro+).
|
|
97
|
+
* Responds 202. */
|
|
98
|
+
submitObservations(input: SubmitObservationsRequest): Promise<SubmitObservationsResponse>;
|
|
99
|
+
/** Most-recent observations for one of the tenant's stations. */
|
|
100
|
+
recentObservations(stationId: string, query?: RecentObservationsQuery): Promise<RecentObservationsResponse>;
|
|
101
|
+
/** Public Goable Sustainability Index (JSON-LD, CC BY 4.0). */
|
|
102
|
+
sustainabilityIndex(query: SustainabilityIndexQuery): Promise<SustainabilityIndexResponse>;
|
|
103
|
+
/** Public Stream F forecast-verification export. Returns the raw NDJSON
|
|
104
|
+
* stream as a string (one cell per line + a trailing meta line). */
|
|
105
|
+
verificationExport(query?: VerificationExportQuery): Promise<string>;
|
|
106
|
+
/** Public L15 Difficulty Atlas export. Returns the raw NDJSON stream. */
|
|
107
|
+
difficultyAtlasExport(): Promise<string>;
|
|
108
|
+
/** Self-service tenant signup (no auth). Always 202 on success. */
|
|
109
|
+
publicSignup(input: PublicSignupRequest): Promise<PublicSignupResponse>;
|
|
110
|
+
/** Open catalogue coverage stats (no auth). */
|
|
111
|
+
catalogStats(): Promise<CatalogStatsResponse>;
|
|
56
112
|
/** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
|
|
57
113
|
deleteUserData(pseudonym: string): Promise<DeleteUserDataResult>;
|
|
58
114
|
private request;
|
|
115
|
+
/** 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. */
|
|
117
|
+
private requestText;
|
|
59
118
|
private rawRequest;
|
|
60
119
|
}
|
|
61
120
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GA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OAAO,CAAC,oBAAoB,CAAC;IASzF,2DAA2D;IAC3D,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI1E,sDAAsD;IACtD,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI7C,wCAAwC;IACxC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQ7F;wBACoB;IACpB,kBAAkB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIzF,iEAAiE;IACjE,kBAAkB,CAChB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,uBAAuB,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IAQtC,+DAA+D;IAC/D,mBAAmB,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,qEAAqE;IAC/D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAoBxD,OAAO;IAOrB;6EACyE;YAC3D,WAAW;YAoBX,UAAU;CAkCzB"}
|
package/dist/client.js
CHANGED
|
@@ -70,6 +70,107 @@ export class GoableClient {
|
|
|
70
70
|
recommendSpot(input) {
|
|
71
71
|
return this.request("POST", "/v1/recommend-spot", input);
|
|
72
72
|
}
|
|
73
|
+
/** L15 — skill-conditioned difficulty grids per scoring dimension (Pro+). */
|
|
74
|
+
scoreDifficulty(input) {
|
|
75
|
+
return this.request("POST", "/v1/score/difficulty", input);
|
|
76
|
+
}
|
|
77
|
+
/** 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);
|
|
81
|
+
}
|
|
82
|
+
/** LLM edge-case narrative for a marginal score. */
|
|
83
|
+
edgeCase(input) {
|
|
84
|
+
return this.request("POST", "/v1/intelligence/edge-case", input);
|
|
85
|
+
}
|
|
86
|
+
/** T3 — multi-spot climate-decadal projections (Scale). */
|
|
87
|
+
projectionsPortfolio(input) {
|
|
88
|
+
return this.request("POST", "/v1/projections/portfolio", input);
|
|
89
|
+
}
|
|
90
|
+
/** T3 — adaptation report across months × scenarios × decades (Scale). */
|
|
91
|
+
adaptationReport(input) {
|
|
92
|
+
return this.request("POST", "/v1/projections/adaptation-report", input);
|
|
93
|
+
}
|
|
94
|
+
// ── underwriting policy lifecycle (Scale) ─────────────────────────────────
|
|
95
|
+
/** Fetch a stored quote by id. */
|
|
96
|
+
getQuote(id) {
|
|
97
|
+
return this.request("GET", `/v1/underwriting/quote/${encodeURIComponent(id)}`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Bind a recent quote into a policy. Responds 201. A watch-level drift event
|
|
101
|
+
* on the resolved cell surfaces as `driftAdvisories` on success; a
|
|
102
|
+
* warning/critical event refuses the bind with `422 DRIFT_ACTIVE`, thrown as
|
|
103
|
+
* a {@link DriftActiveError}.
|
|
104
|
+
*/
|
|
105
|
+
bindPolicy(input) {
|
|
106
|
+
return this.request("POST", "/v1/underwriting/policy/bind", input);
|
|
107
|
+
}
|
|
108
|
+
/** List the calling tenant's bound policies (paginated, boundAt DESC). */
|
|
109
|
+
listPolicies(query) {
|
|
110
|
+
return this.request("GET", `/v1/underwriting/policy${toQuery(query)}`);
|
|
111
|
+
}
|
|
112
|
+
/** Fetch a single policy + its payout events. */
|
|
113
|
+
getPolicy(policyId) {
|
|
114
|
+
return this.request("GET", `/v1/underwriting/policy/${encodeURIComponent(policyId)}`);
|
|
115
|
+
}
|
|
116
|
+
/** Re-evaluate a bound policy against the historical archive; inserts any
|
|
117
|
+
* newly detected payout events. No request body. */
|
|
118
|
+
evaluatePolicy(policyId) {
|
|
119
|
+
return this.request("POST", `/v1/underwriting/policy/${encodeURIComponent(policyId)}/evaluate`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Settle a bound policy. PLATFORM-OPS ONLY — requires the `platform_admin`
|
|
123
|
+
* scope (a cross-tenant underwriter operation, normally run by the daily
|
|
124
|
+
* settlement cron). Not a policyholder self-service action; tenant
|
|
125
|
+
* integrations should not call this.
|
|
126
|
+
*/
|
|
127
|
+
settlePolicy(policyId, input) {
|
|
128
|
+
return this.request("POST", `/v1/underwriting/policy/${encodeURIComponent(policyId)}/settle`, input);
|
|
129
|
+
}
|
|
130
|
+
// ── observations / nowcasting (L5.3) ──────────────────────────────────────
|
|
131
|
+
/** Register a tenant observation station. Responds 201. */
|
|
132
|
+
createStation(input) {
|
|
133
|
+
return this.request("POST", "/v1/observations/stations", input);
|
|
134
|
+
}
|
|
135
|
+
/** List the calling tenant's observation stations. */
|
|
136
|
+
listStations() {
|
|
137
|
+
return this.request("GET", "/v1/observations/stations");
|
|
138
|
+
}
|
|
139
|
+
/** Patch a station (partial update). */
|
|
140
|
+
updateStation(stationId, input) {
|
|
141
|
+
return this.request("PATCH", `/v1/observations/stations/${encodeURIComponent(stationId)}`, input);
|
|
142
|
+
}
|
|
143
|
+
/** Push station observations into the 0-6h assimilation window (Pro+).
|
|
144
|
+
* Responds 202. */
|
|
145
|
+
submitObservations(input) {
|
|
146
|
+
return this.request("POST", "/v1/observations", input);
|
|
147
|
+
}
|
|
148
|
+
/** Most-recent observations for one of the tenant's stations. */
|
|
149
|
+
recentObservations(stationId, query) {
|
|
150
|
+
return this.request("GET", `/v1/observations/stations/${encodeURIComponent(stationId)}/recent${toQuery(query)}`);
|
|
151
|
+
}
|
|
152
|
+
// ── public / research (no-auth surfaces) ──────────────────────────────────
|
|
153
|
+
/** Public Goable Sustainability Index (JSON-LD, CC BY 4.0). */
|
|
154
|
+
sustainabilityIndex(query) {
|
|
155
|
+
return this.request("GET", `/v1/public/sustainability-index${toQuery(query)}`);
|
|
156
|
+
}
|
|
157
|
+
/** Public Stream F forecast-verification export. Returns the raw NDJSON
|
|
158
|
+
* stream as a string (one cell per line + a trailing meta line). */
|
|
159
|
+
verificationExport(query) {
|
|
160
|
+
return this.requestText("GET", `/v1/research/verification/export${toQuery(query)}`);
|
|
161
|
+
}
|
|
162
|
+
/** Public L15 Difficulty Atlas export. Returns the raw NDJSON stream. */
|
|
163
|
+
difficultyAtlasExport() {
|
|
164
|
+
return this.requestText("GET", "/v1/research/difficulty-atlas/export.jsonl");
|
|
165
|
+
}
|
|
166
|
+
/** Self-service tenant signup (no auth). Always 202 on success. */
|
|
167
|
+
publicSignup(input) {
|
|
168
|
+
return this.request("POST", "/v1/public/signup", input);
|
|
169
|
+
}
|
|
170
|
+
/** Open catalogue coverage stats (no auth). */
|
|
171
|
+
catalogStats() {
|
|
172
|
+
return this.request("GET", "/v1/public/catalog-stats");
|
|
173
|
+
}
|
|
73
174
|
/** GDPR Art. 17 erasure. Surfaces the receipt headers from a 204. */
|
|
74
175
|
async deleteUserData(pseudonym) {
|
|
75
176
|
const res = await this.rawRequest("DELETE", `/v1/decision/user-data/${encodeURIComponent(pseudonym)}`);
|
|
@@ -97,6 +198,29 @@ export class GoableClient {
|
|
|
97
198
|
throw toApiError(res.status, parsed);
|
|
98
199
|
return parsed;
|
|
99
200
|
}
|
|
201
|
+
/** 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. */
|
|
203
|
+
async requestText(method, path) {
|
|
204
|
+
const res = await this.rawRequest(method, path);
|
|
205
|
+
let text;
|
|
206
|
+
try {
|
|
207
|
+
text = await res.text();
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
throw new GoableNetworkError("Failed to read response body", "parse", err);
|
|
211
|
+
}
|
|
212
|
+
if (!res.ok) {
|
|
213
|
+
let parsed = text;
|
|
214
|
+
try {
|
|
215
|
+
parsed = JSON.parse(text);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// non-JSON error body — pass the raw text through to toApiError
|
|
219
|
+
}
|
|
220
|
+
throw toApiError(res.status, parsed);
|
|
221
|
+
}
|
|
222
|
+
return text;
|
|
223
|
+
}
|
|
100
224
|
async rawRequest(method, path, body) {
|
|
101
225
|
// `X-Goable-Key` rather than `Authorization: Bearer` — the API
|
|
102
226
|
// sits behind CloudFront with OAC, which hijacks the standard
|
|
@@ -130,6 +254,19 @@ export class GoableClient {
|
|
|
130
254
|
}
|
|
131
255
|
}
|
|
132
256
|
}
|
|
257
|
+
/** Serialise a query object into a leading-`?` string (or "" when empty).
|
|
258
|
+
* Skips undefined/null; isomorphic (URLSearchParams is a Node 18+/browser global). */
|
|
259
|
+
function toQuery(params) {
|
|
260
|
+
if (!params)
|
|
261
|
+
return "";
|
|
262
|
+
const usp = new URLSearchParams();
|
|
263
|
+
for (const [k, v] of Object.entries(params)) {
|
|
264
|
+
if (v !== undefined && v !== null)
|
|
265
|
+
usp.append(k, String(v));
|
|
266
|
+
}
|
|
267
|
+
const s = usp.toString();
|
|
268
|
+
return s ? `?${s}` : "";
|
|
269
|
+
}
|
|
133
270
|
async function safeJson(res) {
|
|
134
271
|
let text;
|
|
135
272
|
try {
|
package/dist/client.js.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":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AC,IAAI,CAAC,CAAA;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ZodIssueLike {
|
|
|
13
13
|
[k: string]: unknown;
|
|
14
14
|
}
|
|
15
15
|
export declare class GoableApiError extends Error {
|
|
16
|
-
readonly name
|
|
16
|
+
readonly name: string;
|
|
17
17
|
/** HTTP status code. */
|
|
18
18
|
readonly status: number;
|
|
19
19
|
/** Machine-readable code from the `error` field (e.g. "PAYMENT_REQUIRED"). */
|
|
@@ -27,6 +27,23 @@ export declare class GoableApiError extends Error {
|
|
|
27
27
|
detail?: Record<string, unknown>;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Raised on a `422 DRIFT_ACTIVE` from `POST /v1/underwriting/policy/bind`:
|
|
32
|
+
* the resolved cell has an open warning/critical L9 drift event, so the bind
|
|
33
|
+
* is refused (a watch-level event is a soft `driftAdvisories` on success, not
|
|
34
|
+
* an error). Subclasses `GoableApiError`, so existing `instanceof
|
|
35
|
+
* GoableApiError` / `.code === "DRIFT_ACTIVE"` checks keep working.
|
|
36
|
+
*/
|
|
37
|
+
export declare class DriftActiveError extends GoableApiError {
|
|
38
|
+
readonly name = "DriftActiveError";
|
|
39
|
+
/** The blocking cells, from the server's `detail.openDriftEvents`. Shape is
|
|
40
|
+
* per-cell and best-effort (documented, not part of the typed contract). */
|
|
41
|
+
readonly openDriftEvents: Array<Record<string, unknown>>;
|
|
42
|
+
constructor(status: number, code: string, message?: string, extra?: {
|
|
43
|
+
issues?: ZodIssueLike[];
|
|
44
|
+
detail?: Record<string, unknown>;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
30
47
|
export declare class GoableNetworkError extends Error {
|
|
31
48
|
readonly name = "GoableNetworkError";
|
|
32
49
|
/** "timeout" when the request was aborted by the configured timeout. */
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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,GAAG,MAAM,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,qBAAa,cAAe,SAAQ,KAAK;
|
|
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,GAAG,MAAM,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,qBAAa,cAAe,SAAQ,KAAK;IAGvC,SAAkB,IAAI,EAAE,MAAM,CAAmB;IACjD,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAA;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBAGvC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAUxE;AAED;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,SAAkB,IAAI,sBAAqB;IAC3C;iFAC6E;IAC7E,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;gBAGtD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAOxE;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAkB,IAAI,wBAAuB;IAC7C,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IAC9C,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAA;gBAErB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO;CAMpF;AASD;6EAC6E;AAC7E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,CAWxE"}
|
package/dist/errors.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* (DNS, connection, abort/timeout, JSON parse).
|
|
8
8
|
*/
|
|
9
9
|
export class GoableApiError extends Error {
|
|
10
|
+
// Typed `string` (not the literal) so subclasses like DriftActiveError can
|
|
11
|
+
// override it with their own name.
|
|
10
12
|
name = "GoableApiError";
|
|
11
13
|
/** HTTP status code. */
|
|
12
14
|
status;
|
|
@@ -28,6 +30,25 @@ export class GoableApiError extends Error {
|
|
|
28
30
|
Object.setPrototypeOf(this, GoableApiError.prototype);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Raised on a `422 DRIFT_ACTIVE` from `POST /v1/underwriting/policy/bind`:
|
|
35
|
+
* the resolved cell has an open warning/critical L9 drift event, so the bind
|
|
36
|
+
* is refused (a watch-level event is a soft `driftAdvisories` on success, not
|
|
37
|
+
* an error). Subclasses `GoableApiError`, so existing `instanceof
|
|
38
|
+
* GoableApiError` / `.code === "DRIFT_ACTIVE"` checks keep working.
|
|
39
|
+
*/
|
|
40
|
+
export class DriftActiveError extends GoableApiError {
|
|
41
|
+
name = "DriftActiveError";
|
|
42
|
+
/** The blocking cells, from the server's `detail.openDriftEvents`. Shape is
|
|
43
|
+
* per-cell and best-effort (documented, not part of the typed contract). */
|
|
44
|
+
openDriftEvents;
|
|
45
|
+
constructor(status, code, message, extra) {
|
|
46
|
+
super(status, code, message, extra);
|
|
47
|
+
const raw = extra?.detail?.openDriftEvents;
|
|
48
|
+
this.openDriftEvents = Array.isArray(raw) ? raw : [];
|
|
49
|
+
Object.setPrototypeOf(this, DriftActiveError.prototype);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
31
52
|
export class GoableNetworkError extends Error {
|
|
32
53
|
name = "GoableNetworkError";
|
|
33
54
|
/** "timeout" when the request was aborted by the configured timeout. */
|
|
@@ -52,6 +73,10 @@ export function toApiError(status, body) {
|
|
|
52
73
|
extra.issues = b.issues;
|
|
53
74
|
if (b.detail && typeof b.detail === "object")
|
|
54
75
|
extra.detail = b.detail;
|
|
76
|
+
// Specialise the one error the SDK models with its own class. Stays a
|
|
77
|
+
// GoableApiError subclass, so generic catch sites are unaffected.
|
|
78
|
+
if (code === "DRIFT_ACTIVE")
|
|
79
|
+
return new DriftActiveError(status, code, message, extra);
|
|
55
80
|
return new GoableApiError(status, code, message, extra);
|
|
56
81
|
}
|
|
57
82
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[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