@delegance/sdk 0.2.0 → 0.3.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 +245 -249
- package/dist/index.d.mts +148 -21
- package/dist/index.d.ts +148 -21
- package/dist/index.js +58 -20
- package/dist/index.mjs +57 -20
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
SDK_VERSION: () => SDK_VERSION,
|
|
56
56
|
SOVModule: () => SOVModule,
|
|
57
57
|
SignupModule: () => SignupModule,
|
|
58
|
+
TermsModule: () => TermsModule,
|
|
58
59
|
UsageModule: () => UsageModule,
|
|
59
60
|
ValidationError: () => ValidationError,
|
|
60
61
|
createClientFromEnv: () => createClientFromEnv,
|
|
@@ -157,7 +158,7 @@ var NotImplementedError = class extends DeleganceError {
|
|
|
157
158
|
};
|
|
158
159
|
|
|
159
160
|
// src/utils/http.ts
|
|
160
|
-
var SDK_VERSION = "0.
|
|
161
|
+
var SDK_VERSION = "0.3.0";
|
|
161
162
|
var DEFAULT_BASE_URL = "https://portal.delegancebrokerage.com";
|
|
162
163
|
function isRetryableStatus(status) {
|
|
163
164
|
return status >= 500 && status !== 501;
|
|
@@ -253,6 +254,7 @@ var HttpClient = class {
|
|
|
253
254
|
if (!response.ok) {
|
|
254
255
|
const err = this.handleErrorResponse(response.status, data, traceId);
|
|
255
256
|
if (typeof data.reason === "string") err.reason = data.reason;
|
|
257
|
+
if (typeof data.code === "string") err.code = data.code;
|
|
256
258
|
if (data && typeof data === "object") err.body = data;
|
|
257
259
|
if (err instanceof RateLimitError && err.retryAfter === void 0) {
|
|
258
260
|
const header = Number(response.headers?.get?.("Retry-After"));
|
|
@@ -319,7 +321,11 @@ var CompaniesModule = class {
|
|
|
319
321
|
this.http = http;
|
|
320
322
|
}
|
|
321
323
|
/**
|
|
322
|
-
* Create a new company
|
|
324
|
+
* Create a new company.
|
|
325
|
+
*
|
|
326
|
+
* @deprecated A customer API key cannot create companies (403
|
|
327
|
+
* `tenant_key_cannot_create`). To open a new account, use
|
|
328
|
+
* `createSignup().createAccount()`.
|
|
323
329
|
*
|
|
324
330
|
* @example
|
|
325
331
|
* ```typescript
|
|
@@ -348,14 +354,11 @@ var CompaniesModule = class {
|
|
|
348
354
|
return response.company;
|
|
349
355
|
}
|
|
350
356
|
/**
|
|
351
|
-
* List
|
|
352
|
-
*
|
|
357
|
+
* List the company this API key belongs to. A key belongs to one company.
|
|
358
|
+
*
|
|
353
359
|
* @example
|
|
354
360
|
* ```typescript
|
|
355
|
-
* const
|
|
356
|
-
*
|
|
357
|
-
* // Include companies created via this API key
|
|
358
|
-
* const allCompanies = await client.companies.list({ includeCreated: true });
|
|
361
|
+
* const [company] = await client.companies.list();
|
|
359
362
|
* ```
|
|
360
363
|
*/
|
|
361
364
|
async list(options = {}) {
|
|
@@ -372,7 +375,10 @@ var CompaniesModule = class {
|
|
|
372
375
|
return response.companies;
|
|
373
376
|
}
|
|
374
377
|
/**
|
|
375
|
-
* Get a company by ID
|
|
378
|
+
* Get a company by ID.
|
|
379
|
+
*
|
|
380
|
+
* @deprecated The server has no `GET /api/v1/companies/{id}` route, so this
|
|
381
|
+
* returns 404. Use `list()`, which returns the key's own company.
|
|
376
382
|
*
|
|
377
383
|
* @example
|
|
378
384
|
* ```typescript
|
|
@@ -387,7 +393,10 @@ var CompaniesModule = class {
|
|
|
387
393
|
return response.company;
|
|
388
394
|
}
|
|
389
395
|
/**
|
|
390
|
-
* Create a company if it doesn't exist (using externalId for deduplication)
|
|
396
|
+
* Create a company if it doesn't exist (using externalId for deduplication).
|
|
397
|
+
*
|
|
398
|
+
* @deprecated A customer API key cannot create companies. Use
|
|
399
|
+
* `createSignup().createAccount()` for a new account.
|
|
391
400
|
*
|
|
392
401
|
* @example
|
|
393
402
|
* ```typescript
|
|
@@ -433,7 +442,6 @@ var DocumentsModule = class {
|
|
|
433
442
|
* import fs from 'fs';
|
|
434
443
|
*
|
|
435
444
|
* const doc = await client.documents.upload({
|
|
436
|
-
* companyId: 'company-uuid',
|
|
437
445
|
* file: fs.readFileSync('./policy.pdf'),
|
|
438
446
|
* fileName: 'GL-2025.pdf',
|
|
439
447
|
* documentType: 'policy'
|
|
@@ -443,9 +451,6 @@ var DocumentsModule = class {
|
|
|
443
451
|
* ```
|
|
444
452
|
*/
|
|
445
453
|
async upload(input) {
|
|
446
|
-
if (!input.companyId) {
|
|
447
|
-
throw new ValidationError("companyId is required");
|
|
448
|
-
}
|
|
449
454
|
if (!input.file) {
|
|
450
455
|
throw new ValidationError("file is required");
|
|
451
456
|
}
|
|
@@ -458,9 +463,10 @@ var DocumentsModule = class {
|
|
|
458
463
|
} else {
|
|
459
464
|
fileData = input.file;
|
|
460
465
|
}
|
|
461
|
-
const additionalFields = {
|
|
462
|
-
|
|
463
|
-
|
|
466
|
+
const additionalFields = {};
|
|
467
|
+
if (input.companyId) {
|
|
468
|
+
additionalFields.companyId = input.companyId;
|
|
469
|
+
}
|
|
464
470
|
if (input.documentType) {
|
|
465
471
|
additionalFields.documentType = input.documentType;
|
|
466
472
|
}
|
|
@@ -484,8 +490,8 @@ var DocumentsModule = class {
|
|
|
484
490
|
* @example
|
|
485
491
|
* ```typescript
|
|
486
492
|
* const docs = await client.documents.uploadBatch([
|
|
487
|
-
* {
|
|
488
|
-
* {
|
|
493
|
+
* { file: buffer1, fileName: 'policy1.pdf' },
|
|
494
|
+
* { file: buffer2, fileName: 'policy2.pdf' }
|
|
489
495
|
* ]);
|
|
490
496
|
* ```
|
|
491
497
|
*/
|
|
@@ -1159,7 +1165,7 @@ var SOVModule = class {
|
|
|
1159
1165
|
};
|
|
1160
1166
|
|
|
1161
1167
|
// src/modules/api-keys.ts
|
|
1162
|
-
var API_KEY_SCOPES = ["read", "write", "admin", "appetite:read", "mcp:read", "mcp:orin"];
|
|
1168
|
+
var API_KEY_SCOPES = ["read", "write", "admin", "appetite:read", "mcp:read", "mcp:orin", "claims:write"];
|
|
1163
1169
|
var ApiKeysModule = class {
|
|
1164
1170
|
constructor(http) {
|
|
1165
1171
|
this.http = http;
|
|
@@ -1845,6 +1851,27 @@ var FeedbackModule = class {
|
|
|
1845
1851
|
}
|
|
1846
1852
|
};
|
|
1847
1853
|
|
|
1854
|
+
// src/modules/terms.ts
|
|
1855
|
+
var TermsModule = class {
|
|
1856
|
+
constructor(http) {
|
|
1857
|
+
this.http = http;
|
|
1858
|
+
}
|
|
1859
|
+
/** The current version, the Terms / Privacy / SLA links, and the summaries to show. */
|
|
1860
|
+
async get() {
|
|
1861
|
+
const res = await this.http.request({ method: "GET", path: "/api/v1/legal/terms" });
|
|
1862
|
+
return res.data;
|
|
1863
|
+
}
|
|
1864
|
+
/** Accept `version` (it must be the current one; read it with `get`). */
|
|
1865
|
+
async accept(version) {
|
|
1866
|
+
const res = await this.http.request({
|
|
1867
|
+
method: "POST",
|
|
1868
|
+
path: "/api/v1/legal/terms/accept",
|
|
1869
|
+
body: { termsAccepted: true, termsVersion: version }
|
|
1870
|
+
});
|
|
1871
|
+
return res.data;
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1848
1875
|
// src/modules/signup.ts
|
|
1849
1876
|
var import_crypto7 = require("crypto");
|
|
1850
1877
|
|
|
@@ -1896,6 +1923,15 @@ var SignupModule = class {
|
|
|
1896
1923
|
...res.warnings?.length ? { warnings: res.warnings } : {}
|
|
1897
1924
|
};
|
|
1898
1925
|
}
|
|
1926
|
+
/** The current Terms of Service version and links. Public: no key. */
|
|
1927
|
+
async getTerms() {
|
|
1928
|
+
const res = await this.makeHttp("").request({ method: "GET", path: "/api/v1/legal/terms" });
|
|
1929
|
+
return res.data;
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Register this terminal. The server refuses without `termsAccepted: true`
|
|
1933
|
+
* and the CURRENT `termsVersion` (from `getTerms`).
|
|
1934
|
+
*/
|
|
1899
1935
|
async enroll(bootstrapKey, input) {
|
|
1900
1936
|
const res = await this.makeHttp(bootstrapKey).request({
|
|
1901
1937
|
method: "POST",
|
|
@@ -2026,6 +2062,7 @@ var DeleganceClient = class {
|
|
|
2026
2062
|
this.claims = new ClaimsModule(this.http);
|
|
2027
2063
|
this.feedback = new FeedbackModule(this.http);
|
|
2028
2064
|
this.auth = new AuthModule(this.http);
|
|
2065
|
+
this.terms = new TermsModule(this.http);
|
|
2029
2066
|
}
|
|
2030
2067
|
/**
|
|
2031
2068
|
* Get the SDK version
|
|
@@ -2109,6 +2146,7 @@ function createDeviceLogin(config = {}) {
|
|
|
2109
2146
|
SDK_VERSION,
|
|
2110
2147
|
SOVModule,
|
|
2111
2148
|
SignupModule,
|
|
2149
|
+
TermsModule,
|
|
2112
2150
|
UsageModule,
|
|
2113
2151
|
ValidationError,
|
|
2114
2152
|
createClientFromEnv,
|
package/dist/index.mjs
CHANGED
|
@@ -91,7 +91,7 @@ var NotImplementedError = class extends DeleganceError {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// src/utils/http.ts
|
|
94
|
-
var SDK_VERSION = "0.
|
|
94
|
+
var SDK_VERSION = "0.3.0";
|
|
95
95
|
var DEFAULT_BASE_URL = "https://portal.delegancebrokerage.com";
|
|
96
96
|
function isRetryableStatus(status) {
|
|
97
97
|
return status >= 500 && status !== 501;
|
|
@@ -187,6 +187,7 @@ var HttpClient = class {
|
|
|
187
187
|
if (!response.ok) {
|
|
188
188
|
const err = this.handleErrorResponse(response.status, data, traceId);
|
|
189
189
|
if (typeof data.reason === "string") err.reason = data.reason;
|
|
190
|
+
if (typeof data.code === "string") err.code = data.code;
|
|
190
191
|
if (data && typeof data === "object") err.body = data;
|
|
191
192
|
if (err instanceof RateLimitError && err.retryAfter === void 0) {
|
|
192
193
|
const header = Number(response.headers?.get?.("Retry-After"));
|
|
@@ -253,7 +254,11 @@ var CompaniesModule = class {
|
|
|
253
254
|
this.http = http;
|
|
254
255
|
}
|
|
255
256
|
/**
|
|
256
|
-
* Create a new company
|
|
257
|
+
* Create a new company.
|
|
258
|
+
*
|
|
259
|
+
* @deprecated A customer API key cannot create companies (403
|
|
260
|
+
* `tenant_key_cannot_create`). To open a new account, use
|
|
261
|
+
* `createSignup().createAccount()`.
|
|
257
262
|
*
|
|
258
263
|
* @example
|
|
259
264
|
* ```typescript
|
|
@@ -282,14 +287,11 @@ var CompaniesModule = class {
|
|
|
282
287
|
return response.company;
|
|
283
288
|
}
|
|
284
289
|
/**
|
|
285
|
-
* List
|
|
286
|
-
*
|
|
290
|
+
* List the company this API key belongs to. A key belongs to one company.
|
|
291
|
+
*
|
|
287
292
|
* @example
|
|
288
293
|
* ```typescript
|
|
289
|
-
* const
|
|
290
|
-
*
|
|
291
|
-
* // Include companies created via this API key
|
|
292
|
-
* const allCompanies = await client.companies.list({ includeCreated: true });
|
|
294
|
+
* const [company] = await client.companies.list();
|
|
293
295
|
* ```
|
|
294
296
|
*/
|
|
295
297
|
async list(options = {}) {
|
|
@@ -306,7 +308,10 @@ var CompaniesModule = class {
|
|
|
306
308
|
return response.companies;
|
|
307
309
|
}
|
|
308
310
|
/**
|
|
309
|
-
* Get a company by ID
|
|
311
|
+
* Get a company by ID.
|
|
312
|
+
*
|
|
313
|
+
* @deprecated The server has no `GET /api/v1/companies/{id}` route, so this
|
|
314
|
+
* returns 404. Use `list()`, which returns the key's own company.
|
|
310
315
|
*
|
|
311
316
|
* @example
|
|
312
317
|
* ```typescript
|
|
@@ -321,7 +326,10 @@ var CompaniesModule = class {
|
|
|
321
326
|
return response.company;
|
|
322
327
|
}
|
|
323
328
|
/**
|
|
324
|
-
* Create a company if it doesn't exist (using externalId for deduplication)
|
|
329
|
+
* Create a company if it doesn't exist (using externalId for deduplication).
|
|
330
|
+
*
|
|
331
|
+
* @deprecated A customer API key cannot create companies. Use
|
|
332
|
+
* `createSignup().createAccount()` for a new account.
|
|
325
333
|
*
|
|
326
334
|
* @example
|
|
327
335
|
* ```typescript
|
|
@@ -367,7 +375,6 @@ var DocumentsModule = class {
|
|
|
367
375
|
* import fs from 'fs';
|
|
368
376
|
*
|
|
369
377
|
* const doc = await client.documents.upload({
|
|
370
|
-
* companyId: 'company-uuid',
|
|
371
378
|
* file: fs.readFileSync('./policy.pdf'),
|
|
372
379
|
* fileName: 'GL-2025.pdf',
|
|
373
380
|
* documentType: 'policy'
|
|
@@ -377,9 +384,6 @@ var DocumentsModule = class {
|
|
|
377
384
|
* ```
|
|
378
385
|
*/
|
|
379
386
|
async upload(input) {
|
|
380
|
-
if (!input.companyId) {
|
|
381
|
-
throw new ValidationError("companyId is required");
|
|
382
|
-
}
|
|
383
387
|
if (!input.file) {
|
|
384
388
|
throw new ValidationError("file is required");
|
|
385
389
|
}
|
|
@@ -392,9 +396,10 @@ var DocumentsModule = class {
|
|
|
392
396
|
} else {
|
|
393
397
|
fileData = input.file;
|
|
394
398
|
}
|
|
395
|
-
const additionalFields = {
|
|
396
|
-
|
|
397
|
-
|
|
399
|
+
const additionalFields = {};
|
|
400
|
+
if (input.companyId) {
|
|
401
|
+
additionalFields.companyId = input.companyId;
|
|
402
|
+
}
|
|
398
403
|
if (input.documentType) {
|
|
399
404
|
additionalFields.documentType = input.documentType;
|
|
400
405
|
}
|
|
@@ -418,8 +423,8 @@ var DocumentsModule = class {
|
|
|
418
423
|
* @example
|
|
419
424
|
* ```typescript
|
|
420
425
|
* const docs = await client.documents.uploadBatch([
|
|
421
|
-
* {
|
|
422
|
-
* {
|
|
426
|
+
* { file: buffer1, fileName: 'policy1.pdf' },
|
|
427
|
+
* { file: buffer2, fileName: 'policy2.pdf' }
|
|
423
428
|
* ]);
|
|
424
429
|
* ```
|
|
425
430
|
*/
|
|
@@ -1093,7 +1098,7 @@ var SOVModule = class {
|
|
|
1093
1098
|
};
|
|
1094
1099
|
|
|
1095
1100
|
// src/modules/api-keys.ts
|
|
1096
|
-
var API_KEY_SCOPES = ["read", "write", "admin", "appetite:read", "mcp:read", "mcp:orin"];
|
|
1101
|
+
var API_KEY_SCOPES = ["read", "write", "admin", "appetite:read", "mcp:read", "mcp:orin", "claims:write"];
|
|
1097
1102
|
var ApiKeysModule = class {
|
|
1098
1103
|
constructor(http) {
|
|
1099
1104
|
this.http = http;
|
|
@@ -1779,6 +1784,27 @@ var FeedbackModule = class {
|
|
|
1779
1784
|
}
|
|
1780
1785
|
};
|
|
1781
1786
|
|
|
1787
|
+
// src/modules/terms.ts
|
|
1788
|
+
var TermsModule = class {
|
|
1789
|
+
constructor(http) {
|
|
1790
|
+
this.http = http;
|
|
1791
|
+
}
|
|
1792
|
+
/** The current version, the Terms / Privacy / SLA links, and the summaries to show. */
|
|
1793
|
+
async get() {
|
|
1794
|
+
const res = await this.http.request({ method: "GET", path: "/api/v1/legal/terms" });
|
|
1795
|
+
return res.data;
|
|
1796
|
+
}
|
|
1797
|
+
/** Accept `version` (it must be the current one; read it with `get`). */
|
|
1798
|
+
async accept(version) {
|
|
1799
|
+
const res = await this.http.request({
|
|
1800
|
+
method: "POST",
|
|
1801
|
+
path: "/api/v1/legal/terms/accept",
|
|
1802
|
+
body: { termsAccepted: true, termsVersion: version }
|
|
1803
|
+
});
|
|
1804
|
+
return res.data;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1782
1808
|
// src/modules/signup.ts
|
|
1783
1809
|
import { createHash, randomBytes, randomUUID as randomUUID7 } from "crypto";
|
|
1784
1810
|
|
|
@@ -1830,6 +1856,15 @@ var SignupModule = class {
|
|
|
1830
1856
|
...res.warnings?.length ? { warnings: res.warnings } : {}
|
|
1831
1857
|
};
|
|
1832
1858
|
}
|
|
1859
|
+
/** The current Terms of Service version and links. Public: no key. */
|
|
1860
|
+
async getTerms() {
|
|
1861
|
+
const res = await this.makeHttp("").request({ method: "GET", path: "/api/v1/legal/terms" });
|
|
1862
|
+
return res.data;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Register this terminal. The server refuses without `termsAccepted: true`
|
|
1866
|
+
* and the CURRENT `termsVersion` (from `getTerms`).
|
|
1867
|
+
*/
|
|
1833
1868
|
async enroll(bootstrapKey, input) {
|
|
1834
1869
|
const res = await this.makeHttp(bootstrapKey).request({
|
|
1835
1870
|
method: "POST",
|
|
@@ -1960,6 +1995,7 @@ var DeleganceClient = class {
|
|
|
1960
1995
|
this.claims = new ClaimsModule(this.http);
|
|
1961
1996
|
this.feedback = new FeedbackModule(this.http);
|
|
1962
1997
|
this.auth = new AuthModule(this.http);
|
|
1998
|
+
this.terms = new TermsModule(this.http);
|
|
1963
1999
|
}
|
|
1964
2000
|
/**
|
|
1965
2001
|
* Get the SDK version
|
|
@@ -2042,6 +2078,7 @@ export {
|
|
|
2042
2078
|
SDK_VERSION,
|
|
2043
2079
|
SOVModule,
|
|
2044
2080
|
SignupModule,
|
|
2081
|
+
TermsModule,
|
|
2045
2082
|
UsageModule,
|
|
2046
2083
|
ValidationError,
|
|
2047
2084
|
createClientFromEnv,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delegance/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript SDK for
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Get commercial insurance quotes from your code: TypeScript SDK for the Delegance API (instant quotes, signup, policies, certificates)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"insurance-quote",
|
|
37
37
|
"brokerage",
|
|
38
38
|
"sdk",
|
|
39
|
-
"api"
|
|
39
|
+
"api",
|
|
40
|
+
"ai-agent",
|
|
41
|
+
"mcp"
|
|
40
42
|
],
|
|
41
43
|
"author": "Delegance Inc.",
|
|
42
44
|
"license": "MIT",
|
|
43
|
-
"homepage": "https://delegancebrokerage.com",
|
|
45
|
+
"homepage": "https://portal.delegancebrokerage.com/docs/sdk",
|
|
44
46
|
"bugs": {
|
|
45
47
|
"email": "support@delegancebrokerage.com"
|
|
46
48
|
},
|
|
@@ -66,5 +68,8 @@
|
|
|
66
68
|
"typescript": {
|
|
67
69
|
"optional": true
|
|
68
70
|
}
|
|
71
|
+
},
|
|
72
|
+
"overrides": {
|
|
73
|
+
"esbuild": "^0.28.1"
|
|
69
74
|
}
|
|
70
75
|
}
|