@goable-io/sdk 0.2.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/LICENSE +21 -0
- package/README.md +61 -39
- 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 +1423 -372
- package/dist/generated/api.d.ts.map +1 -1
- package/dist/generated/api.js +2 -2
- 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 +21 -18
- package/src/client.ts +214 -0
- package/src/errors.ts +32 -1
- package/src/generated/api.ts +1423 -372
- package/src/index.ts +1 -0
- package/src/types.ts +104 -6
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -11,13 +11,33 @@
|
|
|
11
11
|
import type { components, paths } from "./generated/api.ts"
|
|
12
12
|
|
|
13
13
|
// ── helpers ────────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type
|
|
17
|
-
/**
|
|
18
|
-
type
|
|
19
|
-
|
|
14
|
+
/** The sole media body of a request/response, whatever the media type
|
|
15
|
+
* (application/json, application/ld+json, or application/x-ndjson → string). */
|
|
16
|
+
type ContentOf<T> = T extends { content: infer C } ? C[keyof C] : never
|
|
17
|
+
/** Request body of an operation. */
|
|
18
|
+
type ReqOf<O> = O extends { requestBody?: infer RB } ? ContentOf<NonNullable<RB>> : never
|
|
19
|
+
/** Response body for a specific status code. */
|
|
20
|
+
type ResOf<O, C extends number> = O extends { responses: infer R }
|
|
21
|
+
? C extends keyof R
|
|
22
|
+
? ContentOf<R[C]>
|
|
23
|
+
: never
|
|
24
|
+
: never
|
|
25
|
+
/** The 2xx success body — the first of 200 / 201 / 202 the operation declares. */
|
|
26
|
+
type OkOf<O> = O extends { responses: infer R }
|
|
27
|
+
? 200 extends keyof R
|
|
28
|
+
? ContentOf<R[200]>
|
|
29
|
+
: 201 extends keyof R
|
|
30
|
+
? ContentOf<R[201]>
|
|
31
|
+
: 202 extends keyof R
|
|
32
|
+
? ContentOf<R[202]>
|
|
33
|
+
: never
|
|
34
|
+
: never
|
|
35
|
+
/** The query-parameter object of an operation. */
|
|
36
|
+
type QueryOf<O> = O extends { parameters: { query?: infer Q } } ? NonNullable<Q> : never
|
|
37
|
+
|
|
38
|
+
type Get<P extends keyof paths> = paths[P] extends { get: infer O } ? O : never
|
|
20
39
|
type Post<P extends keyof paths> = paths[P] extends { post: infer O } ? O : never
|
|
40
|
+
type Patch<P extends keyof paths> = paths[P] extends { patch: infer O } ? O : never
|
|
21
41
|
|
|
22
42
|
// ── shared primitives (from components) ───────────────────────────────────
|
|
23
43
|
export type GeoPoint = components["schemas"]["GeoPoint"]
|
|
@@ -61,6 +81,84 @@ export type QuoteResponse = ResOf<Post<"/v1/underwriting/quote">, 200>
|
|
|
61
81
|
export type RecommendSpotRequest = ReqOf<Post<"/v1/recommend-spot">>
|
|
62
82
|
export type RecommendSpotResponse = ResOf<Post<"/v1/recommend-spot">, 200>
|
|
63
83
|
|
|
84
|
+
export type ScoreDifficultyRequest = ReqOf<Post<"/v1/score/difficulty">>
|
|
85
|
+
export type ScoreDifficultyResponse = OkOf<Post<"/v1/score/difficulty">>
|
|
86
|
+
|
|
87
|
+
export type ReportOutcomeRequest = ReqOf<Post<"/v1/score/{sessionId}/outcome">>
|
|
88
|
+
export type ReportOutcomeResponse = OkOf<Post<"/v1/score/{sessionId}/outcome">>
|
|
89
|
+
|
|
90
|
+
export type EdgeCaseRequest = ReqOf<Post<"/v1/intelligence/edge-case">>
|
|
91
|
+
export type EdgeCaseResponse = OkOf<Post<"/v1/intelligence/edge-case">>
|
|
92
|
+
|
|
93
|
+
export type ProjectionsPortfolioRequest = ReqOf<Post<"/v1/projections/portfolio">>
|
|
94
|
+
export type ProjectionsPortfolioResponse = OkOf<Post<"/v1/projections/portfolio">>
|
|
95
|
+
|
|
96
|
+
export type AdaptationReportRequest = ReqOf<Post<"/v1/projections/adaptation-report">>
|
|
97
|
+
export type AdaptationReportResponse = OkOf<Post<"/v1/projections/adaptation-report">>
|
|
98
|
+
|
|
99
|
+
// ── underwriting policy lifecycle ─────────────────────────────────────────
|
|
100
|
+
export type QuoteByIdResponse = OkOf<Get<"/v1/underwriting/quote/{id}">>
|
|
101
|
+
|
|
102
|
+
export type BindPolicyRequest = ReqOf<Post<"/v1/underwriting/policy/bind">>
|
|
103
|
+
export type BindPolicyResponse = OkOf<Post<"/v1/underwriting/policy/bind">>
|
|
104
|
+
|
|
105
|
+
export type ListPoliciesQuery = QueryOf<Get<"/v1/underwriting/policy">>
|
|
106
|
+
export type ListPoliciesResponse = OkOf<Get<"/v1/underwriting/policy">>
|
|
107
|
+
|
|
108
|
+
export type PolicyResponse = OkOf<Get<"/v1/underwriting/policy/{policyId}">>
|
|
109
|
+
|
|
110
|
+
export type EvaluatePolicyResponse = OkOf<Post<"/v1/underwriting/policy/{policyId}/evaluate">>
|
|
111
|
+
|
|
112
|
+
export type SettlePolicyRequest = ReqOf<Post<"/v1/underwriting/policy/{policyId}/settle">>
|
|
113
|
+
export type SettlePolicyResponse = OkOf<Post<"/v1/underwriting/policy/{policyId}/settle">>
|
|
114
|
+
|
|
115
|
+
/** Serialised parametric policy record + payout event, reused across the lifecycle. */
|
|
116
|
+
export type SerialisedPolicy = components["schemas"]["SerialisedPolicy"]
|
|
117
|
+
export type SerialisedPayoutEvent = components["schemas"]["SerialisedPayoutEvent"]
|
|
118
|
+
|
|
119
|
+
// ── observations (L5.3) ───────────────────────────────────────────────────
|
|
120
|
+
export type CreateStationRequest = ReqOf<Post<"/v1/observations/stations">>
|
|
121
|
+
export type CreateStationResponse = OkOf<Post<"/v1/observations/stations">>
|
|
122
|
+
|
|
123
|
+
export type ListStationsResponse = OkOf<Get<"/v1/observations/stations">>
|
|
124
|
+
|
|
125
|
+
export type UpdateStationRequest = ReqOf<Patch<"/v1/observations/stations/{stationId}">>
|
|
126
|
+
export type UpdateStationResponse = OkOf<Patch<"/v1/observations/stations/{stationId}">>
|
|
127
|
+
|
|
128
|
+
export type SubmitObservationsRequest = ReqOf<Post<"/v1/observations">>
|
|
129
|
+
export type SubmitObservationsResponse = OkOf<Post<"/v1/observations">>
|
|
130
|
+
|
|
131
|
+
export type RecentObservationsQuery = QueryOf<Get<"/v1/observations/stations/{stationId}/recent">>
|
|
132
|
+
export type RecentObservationsResponse = OkOf<Get<"/v1/observations/stations/{stationId}/recent">>
|
|
133
|
+
|
|
134
|
+
// ── public / research (no-auth) ───────────────────────────────────────────
|
|
135
|
+
export type SustainabilityIndexQuery = QueryOf<Get<"/v1/public/sustainability-index">>
|
|
136
|
+
export type SustainabilityIndexResponse = OkOf<Get<"/v1/public/sustainability-index">>
|
|
137
|
+
|
|
138
|
+
export type VerificationExportQuery = QueryOf<Get<"/v1/research/verification/export">>
|
|
139
|
+
|
|
140
|
+
export type PublicSignupRequest = ReqOf<Post<"/v1/public/signup">>
|
|
141
|
+
export type PublicSignupResponse = OkOf<Post<"/v1/public/signup">>
|
|
142
|
+
|
|
143
|
+
export type CatalogStatsResponse = OkOf<Get<"/v1/public/catalog-stats">>
|
|
144
|
+
|
|
145
|
+
// ── webhooks ──────────────────────────────────────────────────────────────
|
|
146
|
+
/** Every webhook event the platform can deliver (from the OpenAPI enum). */
|
|
147
|
+
export type WebhookEventType = components["schemas"]["WebhookEvent"]
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A webhook delivery body, POSTed to a tenant's registered endpoint. The
|
|
151
|
+
* envelope shape is stable; `data` is per-event and best-effort — narrow it
|
|
152
|
+
* with `if (delivery.type === "underwriting.policy.bound") { ... }`. Field
|
|
153
|
+
* names mirror the deliverer exactly (`id` / `type` / `created`).
|
|
154
|
+
*/
|
|
155
|
+
export interface WebhookDelivery<T = Record<string, unknown>> {
|
|
156
|
+
id: string
|
|
157
|
+
type: WebhookEventType
|
|
158
|
+
created: string
|
|
159
|
+
data: T
|
|
160
|
+
}
|
|
161
|
+
|
|
64
162
|
export type HealthResponse = ResOf<paths["/v1/health"] extends { get: infer O } ? O : never, 200>
|
|
65
163
|
|
|
66
164
|
// ── SDK-specific result types (not wire schemas) ─────────────────────────
|