@insurup/sdk 0.1.13 → 0.1.14
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 +55 -58
- package/dist/client/client.d.ts +153 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/graphql.d.ts +51 -0
- package/dist/client/graphql.d.ts.map +1 -0
- package/dist/client/http.d.ts +173 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/clients/agent.d.ts +121 -0
- package/dist/clients/agent.d.ts.map +1 -0
- package/dist/clients/agentBranch.d.ts +61 -0
- package/dist/clients/agentBranch.d.ts.map +1 -0
- package/dist/clients/agentRole.d.ts +60 -0
- package/dist/clients/agentRole.d.ts.map +1 -0
- package/dist/clients/agentSetup.d.ts +34 -0
- package/dist/clients/agentSetup.d.ts.map +1 -0
- package/dist/clients/agentUser.d.ts +176 -0
- package/dist/clients/agentUser.d.ts.map +1 -0
- package/dist/clients/case.d.ts +232 -0
- package/dist/clients/case.d.ts.map +1 -0
- package/dist/clients/coverage.d.ts +98 -0
- package/dist/clients/coverage.d.ts.map +1 -0
- package/dist/clients/customer.d.ts +216 -0
- package/dist/clients/customer.d.ts.map +1 -0
- package/dist/clients/file.d.ts +30 -0
- package/dist/clients/file.d.ts.map +1 -0
- package/dist/clients/insurance.d.ts +105 -0
- package/dist/clients/insurance.d.ts.map +1 -0
- package/dist/clients/language.d.ts +27 -0
- package/dist/clients/language.d.ts.map +1 -0
- package/dist/clients/policy.d.ts +251 -0
- package/dist/clients/policy.d.ts.map +1 -0
- package/dist/clients/property.d.ts +163 -0
- package/dist/clients/property.d.ts.map +1 -0
- package/dist/clients/proposal.d.ts +232 -0
- package/dist/clients/proposal.d.ts.map +1 -0
- package/dist/clients/template.d.ts +73 -0
- package/dist/clients/template.d.ts.map +1 -0
- package/dist/clients/vehicle.d.ts +112 -0
- package/dist/clients/vehicle.d.ts.map +1 -0
- package/dist/clients/webhook.d.ts +106 -0
- package/dist/clients/webhook.d.ts.map +1 -0
- package/dist/core/config.d.ts +38 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/endpoints.d.ts +1331 -0
- package/dist/core/endpoints.d.ts.map +1 -0
- package/dist/core/error-types.d.ts +66 -0
- package/dist/core/error-types.d.ts.map +1 -0
- package/dist/core/errors.d.ts +42 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/options.d.ts +221 -0
- package/dist/core/options.d.ts.map +1 -0
- package/dist/core/result.d.ts +183 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/retry.d.ts +15 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +144 -506
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +31 -4225
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +144 -506
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +16 -13
- package/dist/index.d.cts +0 -4226
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ graph TB
|
|
|
66
66
|
direction TB
|
|
67
67
|
HTTP[HttpTransport]
|
|
68
68
|
GQL[GraphQLTransport]
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
subgraph Clients[Specialized Clients]
|
|
71
71
|
direction LR
|
|
72
72
|
C1[customers]
|
|
@@ -81,7 +81,7 @@ graph TB
|
|
|
81
81
|
C10[...]
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
App[Your Application] --> SDK
|
|
86
86
|
HTTP --> API[InsurUp REST API]
|
|
87
87
|
GQL --> GQLAPI[InsurUp GraphQL API]
|
|
@@ -131,10 +131,10 @@ const customer = getDataOrThrow(await client.customers.getCustomer('id'));
|
|
|
131
131
|
|
|
132
132
|
### Error Types
|
|
133
133
|
|
|
134
|
-
| Kind
|
|
135
|
-
|
|
134
|
+
| Kind | Types |
|
|
135
|
+
| -------------- | ------------------------------------------------------------------------------------------------------- |
|
|
136
136
|
| `server-error` | `Unauthorized`, `AccessDenied`, `ResourceNotFound`, `InputValidation`, `BusinessValidation`, `Upstream` |
|
|
137
|
-
| `client-error` | `Timeout`, `HttpRequestFailed`, `JsonDeserialization`, `NullResponse`
|
|
137
|
+
| `client-error` | `Timeout`, `HttpRequestFailed`, `JsonDeserialization`, `NullResponse` |
|
|
138
138
|
|
|
139
139
|
---
|
|
140
140
|
|
|
@@ -144,16 +144,16 @@ The SDK includes built-in GraphQL support for querying entities with advanced fi
|
|
|
144
144
|
|
|
145
145
|
### Available GraphQL Methods
|
|
146
146
|
|
|
147
|
-
| Client
|
|
148
|
-
|
|
149
|
-
| `customers`
|
|
150
|
-
| `policies`
|
|
151
|
-
| `policies`
|
|
152
|
-
| `policies`
|
|
153
|
-
| `proposals`
|
|
154
|
-
| `cases`
|
|
155
|
-
| `agentUsers` | `getAgentUsers()`
|
|
156
|
-
| `webhooks`
|
|
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
157
|
|
|
158
158
|
### Basic Usage
|
|
159
159
|
|
|
@@ -165,9 +165,9 @@ const result = await client.customers.getCustomers({
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
if (result.isSuccess) {
|
|
168
|
-
console.log(result.data.nodes);
|
|
168
|
+
console.log(result.data.nodes); // Customer[]
|
|
169
169
|
console.log(result.data.totalCount); // Total count
|
|
170
|
-
console.log(result.data.pageInfo);
|
|
170
|
+
console.log(result.data.pageInfo); // Pagination info
|
|
171
171
|
}
|
|
172
172
|
```
|
|
173
173
|
|
|
@@ -208,7 +208,7 @@ Full-text search with score boosting:
|
|
|
208
208
|
const result = await client.customers.getCustomers({
|
|
209
209
|
first: 10,
|
|
210
210
|
search: {
|
|
211
|
-
name: {
|
|
211
|
+
name: {
|
|
212
212
|
text: { value: 'John' },
|
|
213
213
|
score: { boost: 2 },
|
|
214
214
|
},
|
|
@@ -223,10 +223,7 @@ import { SortEnumType } from '@insurup/sdk';
|
|
|
223
223
|
|
|
224
224
|
const result = await client.cases.getCases({
|
|
225
225
|
first: 20,
|
|
226
|
-
order: [
|
|
227
|
-
{ priorityScore: SortEnumType.Desc },
|
|
228
|
-
{ createdAt: SortEnumType.Desc },
|
|
229
|
-
],
|
|
226
|
+
order: [{ priorityScore: SortEnumType.Desc }, { createdAt: SortEnumType.Desc }],
|
|
230
227
|
});
|
|
231
228
|
```
|
|
232
229
|
|
|
@@ -246,15 +243,15 @@ const client = new DefaultInsurUpClient({
|
|
|
246
243
|
});
|
|
247
244
|
```
|
|
248
245
|
|
|
249
|
-
| Option
|
|
250
|
-
|
|
251
|
-
| `baseUrl`
|
|
252
|
-
| `tokenProvider` | `() => string \| Promise<string>` | —
|
|
253
|
-
| `timeoutMs`
|
|
254
|
-
| `customHeaders` | `Record<string, string>`
|
|
255
|
-
| `retry`
|
|
256
|
-
| `onRequest`
|
|
257
|
-
| `onResponse`
|
|
246
|
+
| Option | Type | Default | Description |
|
|
247
|
+
| --------------- | --------------------------------- | ------------------------------ | ------------------------ |
|
|
248
|
+
| `baseUrl` | `string` | `https://api.insurup.com/api/` | API base URL |
|
|
249
|
+
| `tokenProvider` | `() => string \| Promise<string>` | — | OAuth token provider |
|
|
250
|
+
| `timeoutMs` | `number` | `30000` | Request timeout |
|
|
251
|
+
| `customHeaders` | `Record<string, string>` | — | Headers for all requests |
|
|
252
|
+
| `retry` | `RetryOptions` | — | Retry configuration |
|
|
253
|
+
| `onRequest` | `RequestInterceptor` | — | Pre-request hook |
|
|
254
|
+
| `onResponse` | `ResponseInterceptor` | — | Post-response hook |
|
|
258
255
|
|
|
259
256
|
---
|
|
260
257
|
|
|
@@ -265,7 +262,7 @@ Add logging, correlation IDs, or transform requests/responses:
|
|
|
265
262
|
```typescript
|
|
266
263
|
const client = new DefaultInsurUpClient({
|
|
267
264
|
tokenProvider: () => token,
|
|
268
|
-
|
|
265
|
+
|
|
269
266
|
onRequest: (config) => {
|
|
270
267
|
console.log(`→ ${config.method} ${config.url}`);
|
|
271
268
|
return {
|
|
@@ -273,7 +270,7 @@ const client = new DefaultInsurUpClient({
|
|
|
273
270
|
headers: { ...config.headers, 'X-Correlation-ID': crypto.randomUUID() },
|
|
274
271
|
};
|
|
275
272
|
},
|
|
276
|
-
|
|
273
|
+
|
|
277
274
|
onResponse: (result, config) => {
|
|
278
275
|
console.log(`← ${config.url} ${result.isSuccess ? '✓' : '✗'}`);
|
|
279
276
|
return result;
|
|
@@ -287,36 +284,36 @@ const client = new DefaultInsurUpClient({
|
|
|
287
284
|
|
|
288
285
|
Access specialized clients through the main client instance:
|
|
289
286
|
|
|
290
|
-
| Client
|
|
291
|
-
|
|
292
|
-
| `client.customers`
|
|
293
|
-
| `client.policies`
|
|
294
|
-
| `client.proposals`
|
|
295
|
-
| `client.vehicles`
|
|
296
|
-
| `client.properties`
|
|
297
|
-
| `client.coverage`
|
|
298
|
-
| `client.cases`
|
|
299
|
-
| `client.agents`
|
|
300
|
-
| `client.agentBranches` | Branch management
|
|
301
|
-
| `client.agentRoles`
|
|
302
|
-
| `client.agentUsers`
|
|
303
|
-
| `client.agentSetup`
|
|
304
|
-
| `client.webhooks`
|
|
305
|
-
| `client.insurance`
|
|
306
|
-
| `client.files`
|
|
307
|
-
| `client.languages`
|
|
308
|
-
| `client.templates`
|
|
287
|
+
| Client | Description |
|
|
288
|
+
| ---------------------- | -------------------------------------------- |
|
|
289
|
+
| `client.customers` | Customer profiles, contact info, health data |
|
|
290
|
+
| `client.policies` | Policy details, documents, representatives |
|
|
291
|
+
| `client.proposals` | Insurance proposals, comparisons, purchasing |
|
|
292
|
+
| `client.vehicles` | Vehicle data, brand/model lookups |
|
|
293
|
+
| `client.properties` | Property data, DASK earthquake insurance |
|
|
294
|
+
| `client.coverage` | Coverage configuration, coverage groups |
|
|
295
|
+
| `client.cases` | Service requests, claims, complaints |
|
|
296
|
+
| `client.agents` | Agent profiles, company connections |
|
|
297
|
+
| `client.agentBranches` | Branch management |
|
|
298
|
+
| `client.agentRoles` | Role-based access control |
|
|
299
|
+
| `client.agentUsers` | Agency staff management |
|
|
300
|
+
| `client.agentSetup` | Agent onboarding |
|
|
301
|
+
| `client.webhooks` | Event notifications, integrations |
|
|
302
|
+
| `client.insurance` | Companies, products, resource keys |
|
|
303
|
+
| `client.files` | File uploads and management |
|
|
304
|
+
| `client.languages` | Localization support |
|
|
305
|
+
| `client.templates` | Document and email templates |
|
|
309
306
|
|
|
310
307
|
---
|
|
311
308
|
|
|
312
309
|
## Compatibility
|
|
313
310
|
|
|
314
|
-
| Environment | Support
|
|
315
|
-
|
|
316
|
-
| Node.js
|
|
317
|
-
| Browsers
|
|
318
|
-
| Bun
|
|
319
|
-
| Deno
|
|
311
|
+
| Environment | Support |
|
|
312
|
+
| ----------- | --------------------------------------------- |
|
|
313
|
+
| Node.js | 18+ |
|
|
314
|
+
| Browsers | ES2022+ (Chrome 94+, Firefox 93+, Safari 15+) |
|
|
315
|
+
| Bun | ✓ |
|
|
316
|
+
| Deno | ✓ |
|
|
320
317
|
|
|
321
318
|
Dual ESM/CJS builds included. Full tree-shaking support.
|
|
322
319
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Default InsurUp Client - Main SDK client implementation
|
|
3
|
+
* @description Main SDK client implementation
|
|
4
|
+
*/
|
|
5
|
+
import type { InsurUpClientOptions } from '../core/options.js';
|
|
6
|
+
import { InsurUpAgentClient } from '../clients/agent.js';
|
|
7
|
+
import { InsurUpAgentBranchClient } from '../clients/agentBranch.js';
|
|
8
|
+
import { InsurUpAgentRoleClient } from '../clients/agentRole.js';
|
|
9
|
+
import { InsurUpAgentSetupClient } from '../clients/agentSetup.js';
|
|
10
|
+
import { InsurUpAgentUserClient } from '../clients/agentUser.js';
|
|
11
|
+
import { InsurUpCustomerClient } from '../clients/customer.js';
|
|
12
|
+
import { InsurUpVehicleClient } from '../clients/vehicle.js';
|
|
13
|
+
import { InsurUpPropertyClient } from '../clients/property.js';
|
|
14
|
+
import { InsurUpPolicyClient } from '../clients/policy.js';
|
|
15
|
+
import { InsurUpCaseClient } from '../clients/case.js';
|
|
16
|
+
import { InsurUpWebhookClient } from '../clients/webhook.js';
|
|
17
|
+
import { InsurUpCoverageClient } from '../clients/coverage.js';
|
|
18
|
+
import { InsurUpInsuranceClient } from '../clients/insurance.js';
|
|
19
|
+
import { InsurUpProposalClient } from '../clients/proposal.js';
|
|
20
|
+
import { InsurUpFileClient } from '../clients/file.js';
|
|
21
|
+
import { InsurUpLanguageClient } from '../clients/language.js';
|
|
22
|
+
import { InsurUpTemplateClient } from '../clients/template.js';
|
|
23
|
+
/**
|
|
24
|
+
* Main unified client providing comprehensive access to all InsurUp platform operations.
|
|
25
|
+
* Aggregates specialized client interfaces for authentication, agent management, customer operations,
|
|
26
|
+
* vehicle and property insurance, coverage management, and policy administration.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DefaultInsurUpClient {
|
|
29
|
+
private readonly http;
|
|
30
|
+
private readonly graphql;
|
|
31
|
+
/**
|
|
32
|
+
* Agent Management Client
|
|
33
|
+
*
|
|
34
|
+
* Provides agent management operations for handling agent profiles, insurance company connections,
|
|
35
|
+
* and business relationships within the insurance ecosystem.
|
|
36
|
+
*/
|
|
37
|
+
readonly agents: InsurUpAgentClient;
|
|
38
|
+
/**
|
|
39
|
+
* Agent Branch Management Client
|
|
40
|
+
*
|
|
41
|
+
* Provides branch management operations for insurance agents, enabling the creation and administration
|
|
42
|
+
* of organizational branches within agency structures.
|
|
43
|
+
*/
|
|
44
|
+
readonly agentBranches: InsurUpAgentBranchClient;
|
|
45
|
+
/**
|
|
46
|
+
* Agent Role Management Client
|
|
47
|
+
*
|
|
48
|
+
* Provides role management operations for insurance agents, enabling the creation and administration
|
|
49
|
+
* of role-based access control within agency hierarchies and permission structures.
|
|
50
|
+
*/
|
|
51
|
+
readonly agentRoles: InsurUpAgentRoleClient;
|
|
52
|
+
/**
|
|
53
|
+
* Agent Setup Client
|
|
54
|
+
*
|
|
55
|
+
* Provides agent onboarding and setup operations for new insurance agents joining the InsurUp platform,
|
|
56
|
+
* facilitating the complete registration and configuration process required for business operations.
|
|
57
|
+
*/
|
|
58
|
+
readonly agentSetup: InsurUpAgentSetupClient;
|
|
59
|
+
/**
|
|
60
|
+
* Agent User Management Client
|
|
61
|
+
*
|
|
62
|
+
* Provides comprehensive user management operations for insurance agency staff, enabling agencies to manage
|
|
63
|
+
* their team members, permissions, and access control within the InsurUp platform ecosystem.
|
|
64
|
+
*/
|
|
65
|
+
readonly agentUsers: InsurUpAgentUserClient;
|
|
66
|
+
/**
|
|
67
|
+
* Customer Management Client
|
|
68
|
+
*
|
|
69
|
+
* Provides comprehensive customer management operations for handling customer profiles, contact information,
|
|
70
|
+
* health data, communication flows, and external customer data integration.
|
|
71
|
+
*/
|
|
72
|
+
readonly customers: InsurUpCustomerClient;
|
|
73
|
+
/**
|
|
74
|
+
* Vehicle Management Client
|
|
75
|
+
*
|
|
76
|
+
* Provides comprehensive vehicle management operations for handling customer vehicles, vehicle data lookups,
|
|
77
|
+
* brand and model queries, and vehicle-based insurance operations within the automotive insurance ecosystem.
|
|
78
|
+
*/
|
|
79
|
+
readonly vehicles: InsurUpVehicleClient;
|
|
80
|
+
/**
|
|
81
|
+
* Property Management Client
|
|
82
|
+
*
|
|
83
|
+
* Provides comprehensive property management operations for handling customer properties, Turkish address hierarchy queries,
|
|
84
|
+
* DASK earthquake insurance lookups, and property-based insurance operations within the real estate insurance ecosystem.
|
|
85
|
+
*/
|
|
86
|
+
readonly properties: InsurUpPropertyClient;
|
|
87
|
+
/**
|
|
88
|
+
* Policy Management Client
|
|
89
|
+
*
|
|
90
|
+
* Provides comprehensive policy management operations for handling insurance policies, policy documents,
|
|
91
|
+
* representative assignments, and policy administration.
|
|
92
|
+
*/
|
|
93
|
+
readonly policies: InsurUpPolicyClient;
|
|
94
|
+
/**
|
|
95
|
+
* Case Management Client
|
|
96
|
+
*
|
|
97
|
+
* Provides comprehensive case management operations for handling customer service requests, claims processing,
|
|
98
|
+
* sales opportunities, and complaint resolution within the insurance workflow.
|
|
99
|
+
*/
|
|
100
|
+
readonly cases: InsurUpCaseClient;
|
|
101
|
+
/**
|
|
102
|
+
* Webhook Management Client
|
|
103
|
+
*
|
|
104
|
+
* Provides comprehensive webhook management operations for configuring event notifications, monitoring delivery status,
|
|
105
|
+
* and managing external system integrations within the InsurUp platform ecosystem.
|
|
106
|
+
*/
|
|
107
|
+
readonly webhooks: InsurUpWebhookClient;
|
|
108
|
+
/**
|
|
109
|
+
* Coverage Management Client
|
|
110
|
+
*
|
|
111
|
+
* Provides coverage management operations for configuring insurance product coverages, managing coverage groups,
|
|
112
|
+
* and retrieving available coverage options for different insurance branches within the InsurUp platform.
|
|
113
|
+
*/
|
|
114
|
+
readonly coverage: InsurUpCoverageClient;
|
|
115
|
+
/**
|
|
116
|
+
* Insurance Industry Data Client
|
|
117
|
+
*
|
|
118
|
+
* Provides comprehensive insurance industry data access for retrieving insurance companies, products, resource keys,
|
|
119
|
+
* release notes, and financial institution information essential for platform operations and integrations.
|
|
120
|
+
*/
|
|
121
|
+
readonly insurance: InsurUpInsuranceClient;
|
|
122
|
+
/**
|
|
123
|
+
* Proposal Management Client
|
|
124
|
+
*
|
|
125
|
+
* Provides comprehensive proposal management operations for creating insurance proposals, managing proposal lifecycle,
|
|
126
|
+
* document generation, product purchasing, and comparison tools within the insurance sales process.
|
|
127
|
+
*/
|
|
128
|
+
readonly proposals: InsurUpProposalClient;
|
|
129
|
+
/**
|
|
130
|
+
* File Management Client
|
|
131
|
+
*
|
|
132
|
+
* Provides file management operations for the InsurUp platform, enabling agents to upload and manage files
|
|
133
|
+
* within the insurance ecosystem.
|
|
134
|
+
*/
|
|
135
|
+
readonly files: InsurUpFileClient;
|
|
136
|
+
/**
|
|
137
|
+
* Language Management Client
|
|
138
|
+
*
|
|
139
|
+
* Provides language and localization operations for retrieving available languages in the InsurUp platform.
|
|
140
|
+
* Essential for multi-language support and internationalization features.
|
|
141
|
+
*/
|
|
142
|
+
readonly languages: InsurUpLanguageClient;
|
|
143
|
+
/**
|
|
144
|
+
* Template Management Client
|
|
145
|
+
*
|
|
146
|
+
* Provides template management operations for the InsurUp platform, enabling agents to retrieve and update
|
|
147
|
+
* document templates, email templates, and other content templates used in insurance workflows.
|
|
148
|
+
*/
|
|
149
|
+
readonly templates: InsurUpTemplateClient;
|
|
150
|
+
readonly options: InsurUpClientOptions;
|
|
151
|
+
constructor(options?: InsurUpClientOptions);
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EA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EAAE,mBAAmB,CAAC;IAE9C;;;;;OAKG;IACH,SAAgB,KAAK,EAAE,iBAAiB,CAAC;IAEzC;;;;;OAKG;IACH,SAAgB,QAAQ,EAAE,oBAAoB,CAAC;IAE/C;;;;;OAKG;IACH,SAAgB,QAAQ,EAAE,qBAAqB,CAAC;IAEhD;;;;;OAKG;IACH,SAAgB,SAAS,EAAE,sBAAsB,CAAC;IAElD;;;;;OAKG;IACH,SAAgB,SAAS,EAAE,qBAAqB,CAAC;IAEjD;;;;;OAKG;IACH,SAAgB,KAAK,EAAE,iBAAiB,CAAC;IAEzC;;;;;OAKG;IACH,SAAgB,SAAS,EAAE,qBAAqB,CAAC;IAEjD;;;;;OAKG;IACH,SAAgB,SAAS,EAAE,qBAAqB,CAAC;IAEjD,SAAgB,OAAO,EAAE,oBAAoB,CAAC;gBAElC,OAAO,CAAC,EAAE,oBAAoB;CAwB3C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GraphQL Transport Layer - Fetch-based GraphQL client
|
|
3
|
+
* @description GraphQL transport with error handling and type safety
|
|
4
|
+
*/
|
|
5
|
+
import type { InsurUpGraphQLResult } from '../core/result.js';
|
|
6
|
+
import type { RequestOptions } from '../core/options.js';
|
|
7
|
+
import type { HttpTransport } from './http.js';
|
|
8
|
+
/**
|
|
9
|
+
* Raw GraphQL error from the server response
|
|
10
|
+
*/
|
|
11
|
+
interface RawGraphQLError {
|
|
12
|
+
message: string;
|
|
13
|
+
locations?: Array<{
|
|
14
|
+
line: number;
|
|
15
|
+
column: number;
|
|
16
|
+
}>;
|
|
17
|
+
path?: (string | number)[];
|
|
18
|
+
extensions?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* GraphQL response structure
|
|
22
|
+
*/
|
|
23
|
+
export interface GraphQLResponse<T> {
|
|
24
|
+
data?: T;
|
|
25
|
+
errors?: RawGraphQLError[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* GraphQL request payload
|
|
29
|
+
*/
|
|
30
|
+
export interface GraphQLRequest {
|
|
31
|
+
query: string;
|
|
32
|
+
variables?: Record<string, unknown>;
|
|
33
|
+
operationName?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* GraphQL transport class providing typed query execution
|
|
37
|
+
*/
|
|
38
|
+
export declare class GraphQLTransport {
|
|
39
|
+
private readonly http;
|
|
40
|
+
constructor(http: HttpTransport);
|
|
41
|
+
/**
|
|
42
|
+
* Executes a GraphQL query or mutation
|
|
43
|
+
* @param query The GraphQL query string
|
|
44
|
+
* @param variables Optional variables for the query
|
|
45
|
+
* @param options Optional request options
|
|
46
|
+
* @returns Promise resolving to InsurUpGraphQLResult<T>
|
|
47
|
+
*/
|
|
48
|
+
query<T>(query: string, variables?: Record<string, unknown>, options?: RequestOptions): Promise<InsurUpGraphQLResult<T>>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/client/graphql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAIrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAyFD;;GAEG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;;OAMG;IACG,KAAK,CAAC,CAAC,EACX,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;CAgCpC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HTTP Transport Layer - Fetch-based HTTP client
|
|
3
|
+
* @description Cross-environment HTTP transport with timeout support and error handling
|
|
4
|
+
*/
|
|
5
|
+
import type { InsurUpResult } from '../core/result.js';
|
|
6
|
+
import type { InsurUpClientOptions, RequestOptions } from '../core/options.js';
|
|
7
|
+
/**
|
|
8
|
+
* HTTP method types
|
|
9
|
+
*/
|
|
10
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
11
|
+
/**
|
|
12
|
+
* Valid request body types for HTTP requests
|
|
13
|
+
*/
|
|
14
|
+
export type RequestBody = unknown | FormData;
|
|
15
|
+
/**
|
|
16
|
+
* HTTP transport class providing fetch-based request capabilities
|
|
17
|
+
* with environment detection and timeout support
|
|
18
|
+
*/
|
|
19
|
+
export declare class HttpTransport {
|
|
20
|
+
private readonly options;
|
|
21
|
+
constructor(options?: InsurUpClientOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Sends an HTTP request and returns the parsed result
|
|
24
|
+
* @template T The expected response type (void for no-content operations)
|
|
25
|
+
* @param method HTTP method
|
|
26
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
27
|
+
* @param body Optional request body
|
|
28
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
29
|
+
* @param expectContent Whether the response should contain data (internal use)
|
|
30
|
+
* @returns Promise resolving to InsurUpResult<T>
|
|
31
|
+
*/
|
|
32
|
+
private sendInternal;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a single HTTP request without retry logic
|
|
35
|
+
*/
|
|
36
|
+
private sendSingleRequest;
|
|
37
|
+
/**
|
|
38
|
+
* Convenience method for GET requests - always expects content
|
|
39
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
40
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
41
|
+
*/
|
|
42
|
+
get<T>(path: string, options?: RequestOptions): Promise<InsurUpResult<T>>;
|
|
43
|
+
/**
|
|
44
|
+
* POST request expecting a response with data
|
|
45
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
46
|
+
* @param data Optional request body
|
|
47
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
48
|
+
* @returns Promise resolving to InsurUpResult<T> with response data
|
|
49
|
+
*/
|
|
50
|
+
post<T>(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult<T>>;
|
|
51
|
+
/**
|
|
52
|
+
* POST request expecting no response content (204 No Content)
|
|
53
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
54
|
+
* @param data Optional request body
|
|
55
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
56
|
+
* @returns Promise resolving to InsurUpResult (no data)
|
|
57
|
+
*/
|
|
58
|
+
postNoContent(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult>;
|
|
59
|
+
/**
|
|
60
|
+
* PUT request expecting a response with data
|
|
61
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
62
|
+
* @param data Optional request body
|
|
63
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
64
|
+
* @returns Promise resolving to InsurUpResult<T> with response data
|
|
65
|
+
*/
|
|
66
|
+
put<T>(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* PUT request expecting no response content (204 No Content)
|
|
69
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
70
|
+
* @param data Optional request body
|
|
71
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
72
|
+
* @returns Promise resolving to InsurUpResult (no data)
|
|
73
|
+
*/
|
|
74
|
+
putNoContent(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult>;
|
|
75
|
+
/**
|
|
76
|
+
* PATCH request expecting a response with data
|
|
77
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
78
|
+
* @param data Optional request body
|
|
79
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
80
|
+
* @returns Promise resolving to InsurUpResult<T> with response data
|
|
81
|
+
*/
|
|
82
|
+
patch<T>(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult<T>>;
|
|
83
|
+
/**
|
|
84
|
+
* PATCH request expecting no response content (204 No Content)
|
|
85
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
86
|
+
* @param data Optional request body
|
|
87
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
88
|
+
* @returns Promise resolving to InsurUpResult (no data)
|
|
89
|
+
*/
|
|
90
|
+
patchNoContent(path: string, data?: RequestBody, options?: RequestOptions): Promise<InsurUpResult>;
|
|
91
|
+
/**
|
|
92
|
+
* DELETE request expecting a response with data
|
|
93
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
94
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
95
|
+
* @returns Promise resolving to InsurUpResult<T> with response data
|
|
96
|
+
*/
|
|
97
|
+
delete<T>(path: string, options?: RequestOptions): Promise<InsurUpResult<T>>;
|
|
98
|
+
/**
|
|
99
|
+
* DELETE request expecting no response content (204 No Content)
|
|
100
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
101
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
102
|
+
* @returns Promise resolving to InsurUpResult (no data)
|
|
103
|
+
*/
|
|
104
|
+
deleteNoContent(path: string, options?: RequestOptions): Promise<InsurUpResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Downloads a binary file as a Blob
|
|
107
|
+
* Use this for downloading documents, images, or other binary content
|
|
108
|
+
* @param path Relative path (will be prefixed with baseUrl)
|
|
109
|
+
* @param options Optional request options (headers, signal, timeoutMs)
|
|
110
|
+
* @returns Promise resolving to InsurUpResult<Blob>
|
|
111
|
+
*/
|
|
112
|
+
getBlob(path: string, options?: RequestOptions): Promise<InsurUpResult<Blob>>;
|
|
113
|
+
/**
|
|
114
|
+
* Builds request headers including defaults and custom headers
|
|
115
|
+
* Invokes token provider if available and adds Authorization header
|
|
116
|
+
*/
|
|
117
|
+
private buildHeaders;
|
|
118
|
+
/**
|
|
119
|
+
* Checks if Content-Type header is present (case-insensitive)
|
|
120
|
+
*/
|
|
121
|
+
private hasContentTypeHeader;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if a content type is a valid JSON content type
|
|
124
|
+
*/
|
|
125
|
+
private isJsonContentType;
|
|
126
|
+
/**
|
|
127
|
+
* Handles HTTP response and converts to InsurUpResult
|
|
128
|
+
* @param response The fetch Response object
|
|
129
|
+
* @param expectContent Whether the caller expects response data
|
|
130
|
+
*/
|
|
131
|
+
private handleResponse;
|
|
132
|
+
/**
|
|
133
|
+
* Parses successful JSON response body
|
|
134
|
+
*/
|
|
135
|
+
private parseSuccessResponse;
|
|
136
|
+
/**
|
|
137
|
+
* Determines if a result should be retried
|
|
138
|
+
*/
|
|
139
|
+
private shouldRetryResult;
|
|
140
|
+
/**
|
|
141
|
+
* Logs outgoing request details
|
|
142
|
+
*/
|
|
143
|
+
private logRequest;
|
|
144
|
+
/**
|
|
145
|
+
* Logs response details
|
|
146
|
+
*/
|
|
147
|
+
private logResponse;
|
|
148
|
+
/**
|
|
149
|
+
* Logs retry attempt
|
|
150
|
+
*/
|
|
151
|
+
private logRetry;
|
|
152
|
+
/**
|
|
153
|
+
* Sanitizes headers for logging (removes sensitive information)
|
|
154
|
+
*/
|
|
155
|
+
private sanitizeHeaders;
|
|
156
|
+
/**
|
|
157
|
+
* Sanitizes request body for logging with memory-efficient handling
|
|
158
|
+
*/
|
|
159
|
+
private sanitizeBody;
|
|
160
|
+
/**
|
|
161
|
+
* Efficiently estimates if an object is large without full serialization
|
|
162
|
+
*/
|
|
163
|
+
private isLargeObject;
|
|
164
|
+
/**
|
|
165
|
+
* Sanitizes response data for logging with memory-efficient handling
|
|
166
|
+
*/
|
|
167
|
+
private sanitizeResponseData;
|
|
168
|
+
/**
|
|
169
|
+
* Sanitizes error information for logging
|
|
170
|
+
*/
|
|
171
|
+
private sanitizeError;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/client/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASvD,OAAO,KAAK,EAAE,oBAAoB,EAAiB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAI9F;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;AAU7C;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;gBAEpC,OAAO,CAAC,EAAE,oBAAoB;IAI1C;;;;;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