@goable-io/sdk 0.1.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 +121 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +134 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +57 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/api.d.ts +1051 -0
- package/dist/generated/api.d.ts.map +1 -0
- package/dist/generated/api.js +7 -0
- package/dist/generated/api.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
- package/src/client.ts +206 -0
- package/src/errors.ts +75 -0
- package/src/generated/api.ts +1051 -0
- package/src/index.ts +19 -0
- package/src/types.ts +77 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @goable-io/sdk — TypeScript client for the Goable API.
|
|
3
|
+
*
|
|
4
|
+
* import { GoableClient } from "@goable-io/sdk"
|
|
5
|
+
* const goable = new GoableClient({ apiKey: process.env.GOABLE_API_KEY! })
|
|
6
|
+
* const { score, verdict } = await goable.score({
|
|
7
|
+
* activity: "kitesurfing",
|
|
8
|
+
* location: { lat: 43.7, lng: 7.27 },
|
|
9
|
+
* })
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export { GoableClient } from "./client.js"
|
|
13
|
+
export type { FetchLike, GoableClientOptions } from "./client.js"
|
|
14
|
+
export {
|
|
15
|
+
GoableApiError,
|
|
16
|
+
GoableNetworkError,
|
|
17
|
+
type ZodIssueLike,
|
|
18
|
+
} from "./errors.js"
|
|
19
|
+
export type * from "./types.js"
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public request/response types — DERIVED from the generated OpenAPI
|
|
3
|
+
* contract (src/generated/api.ts), never hand-authored. A change to the
|
|
4
|
+
* API's OpenAPI document + `pnpm gen` updates these automatically; only a
|
|
5
|
+
* genuinely new endpoint (new client method) is a manual change.
|
|
6
|
+
*
|
|
7
|
+
* These are thin, named aliases over `paths[...]` so call sites read
|
|
8
|
+
* nicely (`ScoreRequest`, `ScoreResponse`) instead of deep index chains.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { components, paths } from "./generated/api.js"
|
|
12
|
+
|
|
13
|
+
// ── helpers ────────────────────────────────────────────────────────────
|
|
14
|
+
type JsonOf<T> = T extends { content: { "application/json": infer B } } ? B : never
|
|
15
|
+
/** application/json request body of an operation. */
|
|
16
|
+
type ReqOf<O> = O extends { requestBody?: infer RB } ? JsonOf<NonNullable<RB>> : never
|
|
17
|
+
/** application/json body of a response status code. */
|
|
18
|
+
type ResOf<O, C extends number> = O extends { responses: infer R }
|
|
19
|
+
? C extends keyof R
|
|
20
|
+
? JsonOf<R[C]>
|
|
21
|
+
: never
|
|
22
|
+
: never
|
|
23
|
+
|
|
24
|
+
type Post<P extends keyof paths> = paths[P] extends { post: infer O } ? O : never
|
|
25
|
+
|
|
26
|
+
// ── shared primitives (from components) ───────────────────────────────────
|
|
27
|
+
export type GeoPoint = components["schemas"]["GeoPoint"]
|
|
28
|
+
export type TimeWindowInput = components["schemas"]["TimeWindow"]
|
|
29
|
+
export type Verdict = components["schemas"]["Verdict"]
|
|
30
|
+
|
|
31
|
+
// ── per-endpoint request + response aliases ───────────────────────────────
|
|
32
|
+
export type ScoreRequest = ReqOf<Post<"/v1/score">>
|
|
33
|
+
export type ScoreResponse = ResOf<Post<"/v1/score">, 200>
|
|
34
|
+
|
|
35
|
+
export type ScoreSeriesRequest = ReqOf<Post<"/v1/score/series">>
|
|
36
|
+
export type ScoreSeriesResponse = ResOf<Post<"/v1/score/series">, 200>
|
|
37
|
+
|
|
38
|
+
export type ScoreMultiRequest = ReqOf<Post<"/v1/score/multi">>
|
|
39
|
+
export type ScoreMultiResponse = ResOf<Post<"/v1/score/multi">, 200>
|
|
40
|
+
|
|
41
|
+
export type ScoreHistoricalRequest = ReqOf<Post<"/v1/score/historical">>
|
|
42
|
+
export type ScoreHistoricalResponse = ResOf<Post<"/v1/score/historical">, 200>
|
|
43
|
+
|
|
44
|
+
export type ScorePortfolioRequest = ReqOf<Post<"/v1/score/portfolio">>
|
|
45
|
+
export type ScorePortfolioResponse = ResOf<Post<"/v1/score/portfolio">, 200>
|
|
46
|
+
|
|
47
|
+
export type CounterfactualRequest = ReqOf<Post<"/v1/score/explain-counterfactual">>
|
|
48
|
+
export type CounterfactualResponse = ResOf<Post<"/v1/score/explain-counterfactual">, 200>
|
|
49
|
+
|
|
50
|
+
export type DecisionRequest = ReqOf<Post<"/v1/decision">>
|
|
51
|
+
export type DecisionResponse = ResOf<Post<"/v1/decision">, 200>
|
|
52
|
+
|
|
53
|
+
export type ExplainRequest = ReqOf<Post<"/v1/intelligence/explain">>
|
|
54
|
+
export type ExplainResponse = ResOf<Post<"/v1/intelligence/explain">, 200>
|
|
55
|
+
|
|
56
|
+
export type BriefingRequest = ReqOf<Post<"/v1/intelligence/briefing">>
|
|
57
|
+
export type BriefingResponse = ResOf<Post<"/v1/intelligence/briefing">, 200>
|
|
58
|
+
|
|
59
|
+
export type ProjectionsRequest = ReqOf<Post<"/v1/projections">>
|
|
60
|
+
export type ProjectionsResponse = ResOf<Post<"/v1/projections">, 200>
|
|
61
|
+
|
|
62
|
+
export type QuoteRequest = ReqOf<Post<"/v1/underwriting/quote">>
|
|
63
|
+
export type QuoteResponse = ResOf<Post<"/v1/underwriting/quote">, 200>
|
|
64
|
+
|
|
65
|
+
export type HealthResponse = ResOf<paths["/v1/health"] extends { get: infer O } ? O : never, 200>
|
|
66
|
+
|
|
67
|
+
// ── SDK-specific result types (not wire schemas) ─────────────────────────
|
|
68
|
+
/** GDPR erasure surfaces receipt headers from the 204 response. */
|
|
69
|
+
export interface DeleteUserDataResult {
|
|
70
|
+
status: number
|
|
71
|
+
anonymizedRows: number | null
|
|
72
|
+
anonymizedDecisionRuns: number | null
|
|
73
|
+
receipt: string | null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Re-export the raw generated surface for advanced consumers.
|
|
77
|
+
export type { components, paths } from "./generated/api.js"
|