@insurup/sdk 0.1.1 → 0.1.2
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 +102 -3
- package/dist/index.cjs +1280 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1539 -20
- package/dist/index.d.ts +1539 -20
- package/dist/index.js +1263 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
[](package.json)
|
|
7
7
|
|
|
8
|
-
Type-safe TypeScript SDK for the InsurUp insurance platform. Zero dependencies, tree-shakeable, works everywhere.
|
|
8
|
+
Type-safe TypeScript SDK for the InsurUp insurance platform with GraphQL support. Zero dependencies, tree-shakeable, works everywhere.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ Type-safe TypeScript SDK for the InsurUp insurance platform. Zero dependencies,
|
|
|
15
15
|
- [Quick Start](#quick-start)
|
|
16
16
|
- [Architecture](#architecture)
|
|
17
17
|
- [Result Handling](#result-handling)
|
|
18
|
+
- [GraphQL Queries](#graphql-queries)
|
|
18
19
|
- [Configuration](#configuration)
|
|
19
20
|
- [Interceptors](#interceptors)
|
|
20
21
|
- [API Clients](#api-clients)
|
|
@@ -64,6 +65,7 @@ graph TB
|
|
|
64
65
|
subgraph SDK[DefaultInsurUpClient]
|
|
65
66
|
direction TB
|
|
66
67
|
HTTP[HttpTransport]
|
|
68
|
+
GQL[GraphQLTransport]
|
|
67
69
|
|
|
68
70
|
subgraph Clients[Specialized Clients]
|
|
69
71
|
direction LR
|
|
@@ -81,14 +83,17 @@ graph TB
|
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
App[Your Application] --> SDK
|
|
84
|
-
HTTP --> API[InsurUp API]
|
|
86
|
+
HTTP --> API[InsurUp REST API]
|
|
87
|
+
GQL --> GQLAPI[InsurUp GraphQL API]
|
|
85
88
|
Clients --> HTTP
|
|
89
|
+
Clients --> GQL
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
The SDK uses a **compositional architecture**:
|
|
89
93
|
|
|
90
94
|
- `DefaultInsurUpClient` aggregates 17 specialized clients
|
|
91
|
-
- All clients share
|
|
95
|
+
- All clients share `HttpTransport` and `GraphQLTransport` instances
|
|
96
|
+
- GraphQL queries support filtering, searching, sorting, and type-safe field selection
|
|
92
97
|
- Request/response interceptors hook into the transport layer
|
|
93
98
|
- Results use discriminated unions for type-safe error handling
|
|
94
99
|
|
|
@@ -133,6 +138,100 @@ const customer = getDataOrThrow(await client.customers.getCustomer('id'));
|
|
|
133
138
|
|
|
134
139
|
---
|
|
135
140
|
|
|
141
|
+
## GraphQL Queries
|
|
142
|
+
|
|
143
|
+
The SDK includes built-in GraphQL support for querying entities with advanced filtering, searching, sorting, and type-safe field selection.
|
|
144
|
+
|
|
145
|
+
### Available GraphQL Methods
|
|
146
|
+
|
|
147
|
+
| Client | Method | Description |
|
|
148
|
+
|--------|--------|-------------|
|
|
149
|
+
| `customers` | `getCustomers()` | Query customers with filters |
|
|
150
|
+
| `policies` | `getPolicies()` | Query policies with filters |
|
|
151
|
+
| `policies` | `getPolicyTransfers()` | Query policy transfers |
|
|
152
|
+
| `policies` | `getFilePolicyTransfers()` | Query file-based policy transfers |
|
|
153
|
+
| `proposals` | `getProposals()` | Query proposals with filters |
|
|
154
|
+
| `cases` | `getCases()` | Query cases with filters |
|
|
155
|
+
| `agentUsers` | `getAgentUsers()` | Query agent users with filters |
|
|
156
|
+
| `webhooks` | `getWebhookDeliveries()` | Query webhook deliveries |
|
|
157
|
+
|
|
158
|
+
### Basic Usage
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Query with pagination
|
|
162
|
+
const result = await client.customers.getCustomers({
|
|
163
|
+
first: 10,
|
|
164
|
+
after: 'cursor-string',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (result.isSuccess) {
|
|
168
|
+
console.log(result.data.nodes); // Customer[]
|
|
169
|
+
console.log(result.data.totalCount); // Total count
|
|
170
|
+
console.log(result.data.pageInfo); // Pagination info
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Type-Safe Field Selection
|
|
175
|
+
|
|
176
|
+
Select only the fields you need — the return type automatically narrows:
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const result = await client.policies.getPolicies({
|
|
180
|
+
select: ['id', 'productBranch', 'grossPremium', 'state'] as const,
|
|
181
|
+
first: 10,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// result.data.nodes[0] is typed as:
|
|
185
|
+
// { id: string; productBranch: ProductBranch; grossPremium: number | null; state: PolicyState }
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Filtering
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { ProductBranch, PolicyState } from '@insurup/sdk';
|
|
192
|
+
|
|
193
|
+
const result = await client.policies.getPolicies({
|
|
194
|
+
first: 20,
|
|
195
|
+
filter: {
|
|
196
|
+
productBranch: { eq: ProductBranch.Traffic },
|
|
197
|
+
state: { eq: PolicyState.Active },
|
|
198
|
+
grossPremium: { gte: 1000 },
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Searching
|
|
204
|
+
|
|
205
|
+
Full-text search with score boosting:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
const result = await client.customers.getCustomers({
|
|
209
|
+
first: 10,
|
|
210
|
+
search: {
|
|
211
|
+
name: {
|
|
212
|
+
text: { value: 'John' },
|
|
213
|
+
score: { boost: 2 },
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Sorting
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { SortEnumType } from '@insurup/sdk';
|
|
223
|
+
|
|
224
|
+
const result = await client.cases.getCases({
|
|
225
|
+
first: 20,
|
|
226
|
+
order: [
|
|
227
|
+
{ priorityScore: SortEnumType.Desc },
|
|
228
|
+
{ createdAt: SortEnumType.Desc },
|
|
229
|
+
],
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
136
235
|
## Configuration
|
|
137
236
|
|
|
138
237
|
```typescript
|