@delegance/sdk 0.1.0 → 0.2.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 +96 -8
- package/dist/index.d.mts +947 -68
- package/dist/index.d.ts +947 -68
- package/dist/index.js +658 -14
- package/dist/index.mjs +639 -13
- package/package.json +20 -19
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
interface DeleganceClientConfig {
|
|
8
8
|
/** API key for authentication (format: dlg_xxx_sk_xxx) */
|
|
9
9
|
apiKey: string;
|
|
10
|
-
/** Base URL for the Delegance API (default: https://
|
|
10
|
+
/** Base URL for the Delegance API (default: https://portal.delegancebrokerage.com) */
|
|
11
11
|
baseUrl?: string;
|
|
12
12
|
/** Request timeout in milliseconds (default: 30000) */
|
|
13
13
|
timeout?: number;
|
|
@@ -31,14 +31,32 @@ interface PaginatedResponse<T> extends APIResponse<T[]> {
|
|
|
31
31
|
hasMore: boolean;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
declare const CompanySizeSchema: z.ZodEnum<
|
|
34
|
+
declare const CompanySizeSchema: z.ZodEnum<{
|
|
35
|
+
0: "0";
|
|
36
|
+
1: "1";
|
|
37
|
+
"2-10": "2-10";
|
|
38
|
+
"11-25": "11-25";
|
|
39
|
+
"26-50": "26-50";
|
|
40
|
+
"51-100": "51-100";
|
|
41
|
+
"100-499": "100-499";
|
|
42
|
+
"500+": "500+";
|
|
43
|
+
}>;
|
|
35
44
|
type CompanySize = z.infer<typeof CompanySizeSchema>;
|
|
36
45
|
declare const CreateCompanySchema: z.ZodObject<{
|
|
37
46
|
name: z.ZodString;
|
|
38
47
|
legalName: z.ZodOptional<z.ZodString>;
|
|
39
48
|
dba: z.ZodOptional<z.ZodString>;
|
|
40
49
|
industry: z.ZodString;
|
|
41
|
-
companySize: z.ZodEnum<
|
|
50
|
+
companySize: z.ZodEnum<{
|
|
51
|
+
0: "0";
|
|
52
|
+
1: "1";
|
|
53
|
+
"2-10": "2-10";
|
|
54
|
+
"11-25": "11-25";
|
|
55
|
+
"26-50": "26-50";
|
|
56
|
+
"51-100": "51-100";
|
|
57
|
+
"100-499": "100-499";
|
|
58
|
+
"500+": "500+";
|
|
59
|
+
}>;
|
|
42
60
|
yearEstablished: z.ZodOptional<z.ZodString>;
|
|
43
61
|
website: z.ZodOptional<z.ZodString>;
|
|
44
62
|
fein: z.ZodOptional<z.ZodString>;
|
|
@@ -52,66 +70,10 @@ declare const CreateCompanySchema: z.ZodObject<{
|
|
|
52
70
|
city: z.ZodString;
|
|
53
71
|
state: z.ZodString;
|
|
54
72
|
zip: z.ZodString;
|
|
55
|
-
},
|
|
56
|
-
street: string;
|
|
57
|
-
city: string;
|
|
58
|
-
state: string;
|
|
59
|
-
zip: string;
|
|
60
|
-
suite?: string | undefined;
|
|
61
|
-
}, {
|
|
62
|
-
street: string;
|
|
63
|
-
city: string;
|
|
64
|
-
state: string;
|
|
65
|
-
zip: string;
|
|
66
|
-
suite?: string | undefined;
|
|
67
|
-
}>>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
68
74
|
externalId: z.ZodOptional<z.ZodString>;
|
|
69
75
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
70
|
-
},
|
|
71
|
-
name: string;
|
|
72
|
-
industry: string;
|
|
73
|
-
companySize: "1" | "2-10" | "11-25" | "26-50" | "51-100" | "100-499" | "500+";
|
|
74
|
-
contactEmail: string;
|
|
75
|
-
legalName?: string | undefined;
|
|
76
|
-
dba?: string | undefined;
|
|
77
|
-
yearEstablished?: string | undefined;
|
|
78
|
-
website?: string | undefined;
|
|
79
|
-
fein?: string | undefined;
|
|
80
|
-
companyStructure?: string | undefined;
|
|
81
|
-
description?: string | undefined;
|
|
82
|
-
contactPhone?: string | undefined;
|
|
83
|
-
address?: {
|
|
84
|
-
street: string;
|
|
85
|
-
city: string;
|
|
86
|
-
state: string;
|
|
87
|
-
zip: string;
|
|
88
|
-
suite?: string | undefined;
|
|
89
|
-
} | undefined;
|
|
90
|
-
externalId?: string | undefined;
|
|
91
|
-
metadata?: Record<string, unknown> | undefined;
|
|
92
|
-
}, {
|
|
93
|
-
name: string;
|
|
94
|
-
industry: string;
|
|
95
|
-
companySize: "1" | "2-10" | "11-25" | "26-50" | "51-100" | "100-499" | "500+";
|
|
96
|
-
contactEmail: string;
|
|
97
|
-
legalName?: string | undefined;
|
|
98
|
-
dba?: string | undefined;
|
|
99
|
-
yearEstablished?: string | undefined;
|
|
100
|
-
website?: string | undefined;
|
|
101
|
-
fein?: string | undefined;
|
|
102
|
-
companyStructure?: string | undefined;
|
|
103
|
-
description?: string | undefined;
|
|
104
|
-
contactPhone?: string | undefined;
|
|
105
|
-
address?: {
|
|
106
|
-
street: string;
|
|
107
|
-
city: string;
|
|
108
|
-
state: string;
|
|
109
|
-
zip: string;
|
|
110
|
-
suite?: string | undefined;
|
|
111
|
-
} | undefined;
|
|
112
|
-
externalId?: string | undefined;
|
|
113
|
-
metadata?: Record<string, unknown> | undefined;
|
|
114
|
-
}>;
|
|
76
|
+
}, z.core.$strip>;
|
|
115
77
|
type CreateCompanyInput = z.infer<typeof CreateCompanySchema>;
|
|
116
78
|
interface Company {
|
|
117
79
|
id: string;
|
|
@@ -123,9 +85,26 @@ interface Company {
|
|
|
123
85
|
website?: string;
|
|
124
86
|
createdAt: string;
|
|
125
87
|
}
|
|
126
|
-
declare const DocumentTypeSchema: z.ZodEnum<
|
|
88
|
+
declare const DocumentTypeSchema: z.ZodEnum<{
|
|
89
|
+
policy: "policy";
|
|
90
|
+
loss_run: "loss_run";
|
|
91
|
+
financial_statement: "financial_statement";
|
|
92
|
+
sov: "sov";
|
|
93
|
+
application: "application";
|
|
94
|
+
certificate: "certificate";
|
|
95
|
+
endorsement: "endorsement";
|
|
96
|
+
bor: "bor";
|
|
97
|
+
other: "other";
|
|
98
|
+
}>;
|
|
127
99
|
type DocumentType = z.infer<typeof DocumentTypeSchema>;
|
|
128
|
-
declare const DocumentStatusSchema: z.ZodEnum<
|
|
100
|
+
declare const DocumentStatusSchema: z.ZodEnum<{
|
|
101
|
+
error: "error";
|
|
102
|
+
pending: "pending";
|
|
103
|
+
processing: "processing";
|
|
104
|
+
completed: "completed";
|
|
105
|
+
processed: "processed";
|
|
106
|
+
failed: "failed";
|
|
107
|
+
}>;
|
|
129
108
|
type DocumentStatus = z.infer<typeof DocumentStatusSchema>;
|
|
130
109
|
interface UploadDocumentInput {
|
|
131
110
|
/** Company ID to associate the document with */
|
|
@@ -200,6 +179,10 @@ declare class DeleganceError extends Error {
|
|
|
200
179
|
statusCode: number;
|
|
201
180
|
traceId?: string | undefined;
|
|
202
181
|
details?: unknown | undefined;
|
|
182
|
+
/** Machine-readable `reason` from the error body, when the server sent one. */
|
|
183
|
+
reason?: string;
|
|
184
|
+
/** The parsed error body, for fields a caller needs (portalUrl, hint). */
|
|
185
|
+
body?: Record<string, unknown>;
|
|
203
186
|
constructor(message: string, statusCode: number, traceId?: string | undefined, details?: unknown | undefined);
|
|
204
187
|
}
|
|
205
188
|
declare class AuthenticationError extends DeleganceError {
|
|
@@ -215,6 +198,16 @@ declare class RateLimitError extends DeleganceError {
|
|
|
215
198
|
retryAfter?: number | undefined;
|
|
216
199
|
constructor(message: string, retryAfter?: number | undefined, traceId?: string);
|
|
217
200
|
}
|
|
201
|
+
declare class ForbiddenError extends DeleganceError {
|
|
202
|
+
constructor(message: string, traceId?: string);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The server recognised the request but the capability is not live yet
|
|
206
|
+
* (HTTP 501). Permanent for the current deployment, so it is never retried.
|
|
207
|
+
*/
|
|
208
|
+
declare class NotImplementedError extends DeleganceError {
|
|
209
|
+
constructor(message: string, traceId?: string);
|
|
210
|
+
}
|
|
218
211
|
|
|
219
212
|
/**
|
|
220
213
|
* HTTP Client utilities for the Delegance SDK
|
|
@@ -229,7 +222,18 @@ interface RequestOptions {
|
|
|
229
222
|
/** If true, body is FormData and shouldn't be JSON stringified */
|
|
230
223
|
isFormData?: boolean;
|
|
231
224
|
}
|
|
232
|
-
|
|
225
|
+
/** Kept equal to package.json "version"; a unit test fails on drift. */
|
|
226
|
+
declare const SDK_VERSION = "0.2.0";
|
|
227
|
+
/**
|
|
228
|
+
* Canonical default API origin (WS0/WS1 shared constant, the SDK-package
|
|
229
|
+
* source of truth; the CLI mirror lives in cli/src/utils/config.ts).
|
|
230
|
+
*
|
|
231
|
+
* Decided for the 0.2.0 publish (2026-09-24): the prod portal is the default
|
|
232
|
+
* host. Callers override it with `baseUrl` or DELEGANCE_BASE_URL. Changing
|
|
233
|
+
* the host is exactly two lines (this constant + the CLI mirror) plus
|
|
234
|
+
* regenerated docs.
|
|
235
|
+
*/
|
|
236
|
+
declare const DEFAULT_BASE_URL = "https://portal.delegancebrokerage.com";
|
|
233
237
|
declare class HttpClient {
|
|
234
238
|
private config;
|
|
235
239
|
constructor(config: DeleganceClientConfig);
|
|
@@ -829,6 +833,49 @@ interface ListPoliciesResponse {
|
|
|
829
833
|
count: number;
|
|
830
834
|
traceId: string;
|
|
831
835
|
}
|
|
836
|
+
type CancellationReason = 'replaced' | 'business_closed' | 'sold' | 'not_needed' | 'other';
|
|
837
|
+
interface CancellationRequestInput {
|
|
838
|
+
/** YYYY-MM-DD; coverage ends at 12:01 AM that day. */
|
|
839
|
+
requestedEffectiveDate: string;
|
|
840
|
+
reason: CancellationReason;
|
|
841
|
+
/** Required when reason is 'replaced'. */
|
|
842
|
+
replacementPolicyId?: string;
|
|
843
|
+
}
|
|
844
|
+
interface CancellationSignInput {
|
|
845
|
+
signerName: string;
|
|
846
|
+
signerTitle: string;
|
|
847
|
+
/** The signer attests they may bind the named insured. Must be true. */
|
|
848
|
+
attestAuthority: true;
|
|
849
|
+
/** From the 202 that emailed the code. Omit both to (re)send a code. */
|
|
850
|
+
stepUpId?: string;
|
|
851
|
+
/** The 6-digit code from the email. */
|
|
852
|
+
code?: string;
|
|
853
|
+
}
|
|
854
|
+
/** 202: a code went to the signer's email. 200: signed. */
|
|
855
|
+
type CancellationSignResult = {
|
|
856
|
+
stepUpRequired: true;
|
|
857
|
+
stepUpId: string;
|
|
858
|
+
action: 'sign';
|
|
859
|
+
channel: 'email';
|
|
860
|
+
sentTo: string;
|
|
861
|
+
expiresAt: string | null;
|
|
862
|
+
requestId: string;
|
|
863
|
+
} | {
|
|
864
|
+
status: 'signed';
|
|
865
|
+
requestId: string;
|
|
866
|
+
};
|
|
867
|
+
interface CancellationStatus {
|
|
868
|
+
id: string;
|
|
869
|
+
policyId?: string;
|
|
870
|
+
status: string;
|
|
871
|
+
requestedEffectiveDate: string;
|
|
872
|
+
reason: string;
|
|
873
|
+
/** Claims-made continuity verdict: 'continuous', 'prior_acts_gap', 'unknown', ... */
|
|
874
|
+
continuity: string;
|
|
875
|
+
confirmedEffectiveDate?: string | null;
|
|
876
|
+
confirmationNumber?: string | null;
|
|
877
|
+
updatedAt?: string;
|
|
878
|
+
}
|
|
832
879
|
declare class PoliciesModule {
|
|
833
880
|
private http;
|
|
834
881
|
constructor(http: HttpClient);
|
|
@@ -865,6 +912,28 @@ declare class PoliciesModule {
|
|
|
865
912
|
policy: Policy;
|
|
866
913
|
coverages: PolicyCoverage[];
|
|
867
914
|
} | null>;
|
|
915
|
+
/**
|
|
916
|
+
* Ask to cancel a policy. The request waits for the insured's signature,
|
|
917
|
+
* collected at `signatureUrl` by an owner or admin; a broker reviews the
|
|
918
|
+
* claims-made continuity check before anything reaches the carrier.
|
|
919
|
+
*/
|
|
920
|
+
requestCancellation(policyId: string, input: CancellationRequestInput, opts?: {
|
|
921
|
+
idempotencyKey?: string;
|
|
922
|
+
}): Promise<{
|
|
923
|
+
request: CancellationStatus;
|
|
924
|
+
signatureUrl: string;
|
|
925
|
+
signEndpoint?: string;
|
|
926
|
+
}>;
|
|
927
|
+
/**
|
|
928
|
+
* Sign a cancellation request as an owner or admin. Signing needs a step-up
|
|
929
|
+
* code: call once without `code` to email it (202 with `stepUpId`), then
|
|
930
|
+
* again with `stepUpId` and `code`.
|
|
931
|
+
*/
|
|
932
|
+
signCancellation(requestId: string, input: CancellationSignInput, opts?: {
|
|
933
|
+
idempotencyKey?: string;
|
|
934
|
+
}): Promise<CancellationSignResult>;
|
|
935
|
+
/** One cancellation request's status. */
|
|
936
|
+
getCancellation(requestId: string): Promise<CancellationStatus>;
|
|
868
937
|
}
|
|
869
938
|
|
|
870
939
|
/**
|
|
@@ -1136,9 +1205,12 @@ interface RotateResult {
|
|
|
1136
1205
|
rotationId: string;
|
|
1137
1206
|
status: 'rotating';
|
|
1138
1207
|
}
|
|
1208
|
+
/** Scopes the server accepts. `appetite:read` and `mcp:*` are opt-in and never implied. */
|
|
1209
|
+
type ApiKeyScope = 'read' | 'write' | 'admin' | 'appetite:read' | 'mcp:read' | 'mcp:orin';
|
|
1210
|
+
declare const API_KEY_SCOPES: readonly ApiKeyScope[];
|
|
1139
1211
|
interface CreateApiKeyInput {
|
|
1140
1212
|
name: string;
|
|
1141
|
-
scopes:
|
|
1213
|
+
scopes: ApiKeyScope[];
|
|
1142
1214
|
expiresInDays?: number;
|
|
1143
1215
|
}
|
|
1144
1216
|
interface ListApiKeysOptions {
|
|
@@ -1492,6 +1564,23 @@ interface OnboardingStatus {
|
|
|
1492
1564
|
*/
|
|
1493
1565
|
nextStep: OnboardingNextStep | null;
|
|
1494
1566
|
}
|
|
1567
|
+
/** The five onboarding states of the frozen WS1 contract. */
|
|
1568
|
+
type OnboardingState = 'created' | 'awaiting_verification' | 'documents_pending' | 'processing' | 'ready';
|
|
1569
|
+
/** Data payload of `GET /api/v1/onboarding/state`. */
|
|
1570
|
+
interface OnboardingStateData {
|
|
1571
|
+
state: OnboardingState;
|
|
1572
|
+
verified: boolean;
|
|
1573
|
+
capabilities: string[];
|
|
1574
|
+
verification: {
|
|
1575
|
+
challengeIssued: boolean;
|
|
1576
|
+
sentTo: string | null;
|
|
1577
|
+
};
|
|
1578
|
+
documents: {
|
|
1579
|
+
total: number;
|
|
1580
|
+
processing: number;
|
|
1581
|
+
processed: number;
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1495
1584
|
declare class OnboardingModule {
|
|
1496
1585
|
private http;
|
|
1497
1586
|
constructor(http: HttpClient);
|
|
@@ -1514,6 +1603,749 @@ declare class OnboardingModule {
|
|
|
1514
1603
|
* ```
|
|
1515
1604
|
*/
|
|
1516
1605
|
status(): Promise<OnboardingStatus>;
|
|
1606
|
+
/** Poll the canonical onboarding state machine. Callable pre-verification. */
|
|
1607
|
+
state(): Promise<OnboardingStateData>;
|
|
1608
|
+
/**
|
|
1609
|
+
* Issue (or re-issue) the human verification challenge. Delegance emails a
|
|
1610
|
+
* confirmation link to the company contact email. Hand that link to a human;
|
|
1611
|
+
* the agent cannot self-verify.
|
|
1612
|
+
*/
|
|
1613
|
+
requestVerification(): Promise<{
|
|
1614
|
+
state: OnboardingState;
|
|
1615
|
+
sentTo: string;
|
|
1616
|
+
}>;
|
|
1617
|
+
/** Poll state() until `target` is reached or `timeoutMs` elapses. */
|
|
1618
|
+
waitForState(target: OnboardingState, options?: {
|
|
1619
|
+
intervalMs?: number;
|
|
1620
|
+
timeoutMs?: number;
|
|
1621
|
+
}): Promise<OnboardingStateData>;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Appetite Module
|
|
1626
|
+
*
|
|
1627
|
+
* Carrier appetite matching: which carriers will write a given risk.
|
|
1628
|
+
*
|
|
1629
|
+
* Contract (POST /api/v1/appetite/match):
|
|
1630
|
+
* - warm cache hit -> 200 with the full validated result
|
|
1631
|
+
* - cold -> 202 with a job id; poll GET /api/v1/appetite/match/:jobId
|
|
1632
|
+
*
|
|
1633
|
+
* Requires an API key carrying the `appetite:read` scope. That scope is not
|
|
1634
|
+
* implied by `read` or `write`. The endpoint answers 404 while the partner
|
|
1635
|
+
* API is disabled for the deployment.
|
|
1636
|
+
*/
|
|
1637
|
+
|
|
1638
|
+
interface AppetiteMatchInput {
|
|
1639
|
+
/** Two-letter US state code (required). */
|
|
1640
|
+
state: string;
|
|
1641
|
+
/** One of industry, businessDescription, naicsCode, or sicCode is required. */
|
|
1642
|
+
industry?: string;
|
|
1643
|
+
businessDescription?: string;
|
|
1644
|
+
naicsCode?: string;
|
|
1645
|
+
sicCode?: string;
|
|
1646
|
+
coverageTypes?: string[];
|
|
1647
|
+
carriers?: string[];
|
|
1648
|
+
marketSize?: 'Small Business' | 'Middle Market';
|
|
1649
|
+
productFilter?: 'off' | 'boost' | 'strict';
|
|
1650
|
+
annualRevenue?: number;
|
|
1651
|
+
annualPayroll?: number;
|
|
1652
|
+
propertyValue?: number;
|
|
1653
|
+
/** Callers may only raise the quality floor. */
|
|
1654
|
+
minFit?: 'possible' | 'strong';
|
|
1655
|
+
topK?: number;
|
|
1656
|
+
minScore?: number;
|
|
1657
|
+
}
|
|
1658
|
+
interface AppetiteMatch {
|
|
1659
|
+
carrier: string;
|
|
1660
|
+
classDescription: string;
|
|
1661
|
+
industryCategory: string;
|
|
1662
|
+
product: string;
|
|
1663
|
+
appetite: 'Target' | 'Acceptable' | 'Limited' | 'Not Available';
|
|
1664
|
+
score: number;
|
|
1665
|
+
matchDetails: {
|
|
1666
|
+
codeMatchScore: number;
|
|
1667
|
+
semanticScore: number;
|
|
1668
|
+
stateMatch: boolean;
|
|
1669
|
+
};
|
|
1670
|
+
classCode: string;
|
|
1671
|
+
sicCode: string;
|
|
1672
|
+
naicsCode: string;
|
|
1673
|
+
limits: string;
|
|
1674
|
+
notes: string;
|
|
1675
|
+
marketSize: string;
|
|
1676
|
+
}
|
|
1677
|
+
interface CarrierAppetiteResult {
|
|
1678
|
+
carrier: string;
|
|
1679
|
+
overallStatus: 'acceptable' | 'targeted' | 'limited' | 'declined' | 'unknown';
|
|
1680
|
+
confidence: number;
|
|
1681
|
+
bestMatch: AppetiteMatch;
|
|
1682
|
+
allMatches: AppetiteMatch[];
|
|
1683
|
+
productsAvailable: string[];
|
|
1684
|
+
warnings: string[];
|
|
1685
|
+
}
|
|
1686
|
+
interface AppetiteMatchResult {
|
|
1687
|
+
matches: AppetiteMatch[];
|
|
1688
|
+
carrierResults: CarrierAppetiteResult[];
|
|
1689
|
+
suggestedCarriers: string[];
|
|
1690
|
+
warnings: string[];
|
|
1691
|
+
metadata: Record<string, unknown> & {
|
|
1692
|
+
validated?: boolean;
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
/** Result of `appetite.match()`: either a finished result or a queued job. */
|
|
1696
|
+
type AppetiteMatchStart = ({
|
|
1697
|
+
status: 'succeeded';
|
|
1698
|
+
cached: true;
|
|
1699
|
+
jobId: null;
|
|
1700
|
+
traceId: string;
|
|
1701
|
+
} & AppetiteMatchResult) | {
|
|
1702
|
+
status: 'queued';
|
|
1703
|
+
jobId: string;
|
|
1704
|
+
statusUrl: string;
|
|
1705
|
+
estimatedSeconds: number;
|
|
1706
|
+
traceId: string;
|
|
1707
|
+
};
|
|
1708
|
+
type AppetiteJobStatus = {
|
|
1709
|
+
status: 'queued' | 'running';
|
|
1710
|
+
jobId: string;
|
|
1711
|
+
estimatedSeconds: number;
|
|
1712
|
+
traceId: string;
|
|
1713
|
+
} | ({
|
|
1714
|
+
status: 'succeeded';
|
|
1715
|
+
jobId: string;
|
|
1716
|
+
cached: false;
|
|
1717
|
+
traceId: string;
|
|
1718
|
+
} & AppetiteMatchResult) | {
|
|
1719
|
+
status: 'failed';
|
|
1720
|
+
jobId: string;
|
|
1721
|
+
errorCode: string;
|
|
1722
|
+
retryable: boolean;
|
|
1723
|
+
retryAfterSeconds?: number;
|
|
1724
|
+
traceId: string;
|
|
1725
|
+
};
|
|
1726
|
+
interface WaitForMatchOptions {
|
|
1727
|
+
intervalMs?: number;
|
|
1728
|
+
timeoutMs?: number;
|
|
1729
|
+
}
|
|
1730
|
+
declare class AppetiteModule {
|
|
1731
|
+
private http;
|
|
1732
|
+
constructor(http: HttpClient);
|
|
1733
|
+
/**
|
|
1734
|
+
* Start an appetite match. Returns the result directly on a warm cache hit,
|
|
1735
|
+
* or a queued job to poll with `getMatch()`.
|
|
1736
|
+
*
|
|
1737
|
+
* @example
|
|
1738
|
+
* ```typescript
|
|
1739
|
+
* const start = await client.appetite.match({ state: 'CA', industry: 'restaurant' });
|
|
1740
|
+
* const result = start.status === 'succeeded'
|
|
1741
|
+
* ? start
|
|
1742
|
+
* : await client.appetite.waitForMatch(start.jobId);
|
|
1743
|
+
* ```
|
|
1744
|
+
*/
|
|
1745
|
+
match(input: AppetiteMatchInput): Promise<AppetiteMatchStart>;
|
|
1746
|
+
/** Read a match job. Unknown, expired, and other-tenant ids all raise NotFoundError. */
|
|
1747
|
+
getMatch(jobId: string): Promise<AppetiteJobStatus>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Poll a job until it succeeds. Throws on a failed job (with the sanitized
|
|
1750
|
+
* errorCode) or on timeout.
|
|
1751
|
+
*/
|
|
1752
|
+
waitForMatch(jobId: string, options?: WaitForMatchOptions): Promise<Extract<AppetiteJobStatus, {
|
|
1753
|
+
status: 'succeeded';
|
|
1754
|
+
}>>;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* Leads Module
|
|
1759
|
+
*
|
|
1760
|
+
* Send a prospect business to Delegance (POST /api/v1/leads). Needs the
|
|
1761
|
+
* `write` scope. Idempotent on `externalId`, and a lead whose contact email
|
|
1762
|
+
* already belongs to a company returns that company instead of a duplicate.
|
|
1763
|
+
*/
|
|
1764
|
+
|
|
1765
|
+
interface LeadAddress {
|
|
1766
|
+
street: string;
|
|
1767
|
+
suite?: string;
|
|
1768
|
+
city: string;
|
|
1769
|
+
/** Two-letter state code. */
|
|
1770
|
+
state: string;
|
|
1771
|
+
/** 5-digit or ZIP+4. */
|
|
1772
|
+
zip: string;
|
|
1773
|
+
}
|
|
1774
|
+
interface CreateLeadInput {
|
|
1775
|
+
name: string;
|
|
1776
|
+
contactEmail: string;
|
|
1777
|
+
legalName?: string;
|
|
1778
|
+
industry?: string;
|
|
1779
|
+
contactPhone?: string;
|
|
1780
|
+
website?: string;
|
|
1781
|
+
companySize?: string;
|
|
1782
|
+
description?: string;
|
|
1783
|
+
sicCode?: string;
|
|
1784
|
+
naicsCode?: string;
|
|
1785
|
+
state?: string;
|
|
1786
|
+
address?: LeadAddress;
|
|
1787
|
+
externalId?: string;
|
|
1788
|
+
source?: string;
|
|
1789
|
+
sourceDetail?: Record<string, unknown>;
|
|
1790
|
+
notes?: string;
|
|
1791
|
+
metadata?: Record<string, unknown>;
|
|
1792
|
+
}
|
|
1793
|
+
interface CreateLeadResult {
|
|
1794
|
+
success: boolean;
|
|
1795
|
+
companyId: string;
|
|
1796
|
+
message: string;
|
|
1797
|
+
traceId: string;
|
|
1798
|
+
}
|
|
1799
|
+
declare class LeadsModule {
|
|
1800
|
+
private http;
|
|
1801
|
+
constructor(http: HttpClient);
|
|
1802
|
+
/**
|
|
1803
|
+
* Create a lead.
|
|
1804
|
+
*
|
|
1805
|
+
* @example
|
|
1806
|
+
* ```typescript
|
|
1807
|
+
* const { companyId } = await client.leads.create({
|
|
1808
|
+
* name: 'Riverbend Bakery',
|
|
1809
|
+
* contactEmail: 'owner@riverbend.example',
|
|
1810
|
+
* state: 'TX',
|
|
1811
|
+
* externalId: 'crm-4411',
|
|
1812
|
+
* });
|
|
1813
|
+
* ```
|
|
1814
|
+
*/
|
|
1815
|
+
create(input: CreateLeadInput): Promise<CreateLeadResult>;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
/**
|
|
1819
|
+
* Instant Quotes Module: real carrier premiums over the API.
|
|
1820
|
+
*
|
|
1821
|
+
* Needs a key with a person behind it (from `delegance signup`, or created in
|
|
1822
|
+
* the portal while signed in). Flow: `start` returns the questions, `submit`
|
|
1823
|
+
* files the answers with the carriers, `status` / `waitForQuotes` return
|
|
1824
|
+
* premiums as carriers answer, `bind` requests a bind on one offer.
|
|
1825
|
+
*
|
|
1826
|
+
* `submit` and `bind` send an Idempotency-Key. Pass your own to make a retry
|
|
1827
|
+
* across process restarts land on the same request; otherwise one is made per
|
|
1828
|
+
* call and reused by the SDK's own retries.
|
|
1829
|
+
*/
|
|
1830
|
+
|
|
1831
|
+
interface InstantQuestionOption {
|
|
1832
|
+
value: string;
|
|
1833
|
+
label: string;
|
|
1834
|
+
}
|
|
1835
|
+
interface InstantQuestion {
|
|
1836
|
+
id: string;
|
|
1837
|
+
label: string;
|
|
1838
|
+
type: string;
|
|
1839
|
+
options?: InstantQuestionOption[];
|
|
1840
|
+
required: boolean;
|
|
1841
|
+
group?: string;
|
|
1842
|
+
/** Answered from the insured's own account data. Shown and editable. */
|
|
1843
|
+
prefill?: unknown;
|
|
1844
|
+
/** Inferred by a source. Counts only after the insured confirms it. */
|
|
1845
|
+
suggested?: {
|
|
1846
|
+
value: unknown;
|
|
1847
|
+
route?: string;
|
|
1848
|
+
confidence?: string;
|
|
1849
|
+
};
|
|
1850
|
+
/** Required only while visible. */
|
|
1851
|
+
requiredIfShown?: boolean;
|
|
1852
|
+
/** Shown only when the named question's answer is one of `equals`. */
|
|
1853
|
+
showIf?: {
|
|
1854
|
+
questionId: string;
|
|
1855
|
+
equals: string[];
|
|
1856
|
+
};
|
|
1857
|
+
[key: string]: unknown;
|
|
1858
|
+
}
|
|
1859
|
+
interface InstantSession {
|
|
1860
|
+
submissionId: string;
|
|
1861
|
+
sessionVersion: string;
|
|
1862
|
+
decision: string;
|
|
1863
|
+
eligibleCarriers: {
|
|
1864
|
+
carrierId: string;
|
|
1865
|
+
name: string;
|
|
1866
|
+
}[];
|
|
1867
|
+
questions: InstantQuestion[];
|
|
1868
|
+
}
|
|
1869
|
+
interface InstantSubmitResult {
|
|
1870
|
+
quotes: {
|
|
1871
|
+
carrierId: string;
|
|
1872
|
+
carrierName: string;
|
|
1873
|
+
premium: number | null;
|
|
1874
|
+
status: string;
|
|
1875
|
+
}[];
|
|
1876
|
+
/** `missing` names the value that would bring a carrier dropped by a data floor back. */
|
|
1877
|
+
partialFailures: {
|
|
1878
|
+
carrierId: string;
|
|
1879
|
+
reason: string;
|
|
1880
|
+
missing?: string;
|
|
1881
|
+
}[];
|
|
1882
|
+
acordCoverages: string[];
|
|
1883
|
+
status: 'submitted' | 'acord_pending' | 'no_carriers';
|
|
1884
|
+
/** The broker task, when ACORD lines were queued (`acord_pending`). */
|
|
1885
|
+
brokerTaskId?: string;
|
|
1886
|
+
/** On a replace: the earlier requests closed on our side, per coverage. */
|
|
1887
|
+
superseded?: {
|
|
1888
|
+
policyType: string;
|
|
1889
|
+
submissionIds: string[];
|
|
1890
|
+
carriers: string[];
|
|
1891
|
+
}[];
|
|
1892
|
+
/** On a replace: coverages whose earlier request stayed open (nothing new was filed for them). */
|
|
1893
|
+
restored?: string[];
|
|
1894
|
+
replaceNotice?: string;
|
|
1895
|
+
}
|
|
1896
|
+
interface CarrierQuote {
|
|
1897
|
+
opportunityId: string;
|
|
1898
|
+
carrierId: string;
|
|
1899
|
+
carrierName: string;
|
|
1900
|
+
coverage: string | null;
|
|
1901
|
+
state: string;
|
|
1902
|
+
marketStatus: string;
|
|
1903
|
+
premium: number | null;
|
|
1904
|
+
quoteNumber: string | null;
|
|
1905
|
+
bindable: boolean | null;
|
|
1906
|
+
}
|
|
1907
|
+
interface InstantQuoteStatus {
|
|
1908
|
+
submissionId: string;
|
|
1909
|
+
coverages: string[];
|
|
1910
|
+
expiresAt: string | null;
|
|
1911
|
+
submitted: boolean;
|
|
1912
|
+
submitStatus: 'not_submitted' | 'in_progress' | 'completed';
|
|
1913
|
+
carrierQuotes: CarrierQuote[];
|
|
1914
|
+
allCarriersResolved: boolean;
|
|
1915
|
+
awaitingBrokerReviewCount: number;
|
|
1916
|
+
/** The newest broker task on this submission; null when none. Absent when the server could not read it. */
|
|
1917
|
+
brokerReview?: {
|
|
1918
|
+
taskId: string;
|
|
1919
|
+
status: string;
|
|
1920
|
+
createdAt: string;
|
|
1921
|
+
} | null;
|
|
1922
|
+
}
|
|
1923
|
+
/** ACORD questions a broker needs after a `no_carriers` result. */
|
|
1924
|
+
interface BrokerHandoffQuestions {
|
|
1925
|
+
submissionId: string;
|
|
1926
|
+
coverages: string[];
|
|
1927
|
+
questions: InstantQuestion[];
|
|
1928
|
+
/** True when this submission is already with a broker; `questions` is empty. */
|
|
1929
|
+
alreadyHandedOff: boolean;
|
|
1930
|
+
brokerTaskId?: string | null;
|
|
1931
|
+
}
|
|
1932
|
+
interface BrokerHandoffResult {
|
|
1933
|
+
status: 'broker_review';
|
|
1934
|
+
submissionId: string;
|
|
1935
|
+
brokerTaskId: string | null;
|
|
1936
|
+
coverages: string[];
|
|
1937
|
+
/** Required questions left blank. The broker asks them. */
|
|
1938
|
+
unansweredRequired: number;
|
|
1939
|
+
alreadyHandedOff: boolean;
|
|
1940
|
+
}
|
|
1941
|
+
interface BindRequestResult {
|
|
1942
|
+
bindRequestId: string;
|
|
1943
|
+
status: string;
|
|
1944
|
+
carrierName: string;
|
|
1945
|
+
coverage: string;
|
|
1946
|
+
premium: number | null;
|
|
1947
|
+
existing: boolean;
|
|
1948
|
+
next: string;
|
|
1949
|
+
/** Fast bind only: 'A' opens the carrier's own checkout, 'C' goes to a broker. */
|
|
1950
|
+
tier?: 'A' | 'C';
|
|
1951
|
+
/** Tier C: why the offer could not use the carrier checkout. */
|
|
1952
|
+
reasons?: string[];
|
|
1953
|
+
/** Tier A: the carrier's checkout page. The policy is bound only when the carrier confirms. */
|
|
1954
|
+
checkoutUrl?: string;
|
|
1955
|
+
}
|
|
1956
|
+
/** The first fast-bind call emails a code; send it back with `stepUpId`. */
|
|
1957
|
+
interface BindStepUpRequired {
|
|
1958
|
+
stepUpRequired: true;
|
|
1959
|
+
stepUpId: string;
|
|
1960
|
+
channel: 'email';
|
|
1961
|
+
sentTo: string;
|
|
1962
|
+
expiresAt: string | null;
|
|
1963
|
+
}
|
|
1964
|
+
interface FastBindInput {
|
|
1965
|
+
/** You confirm the application answers are accurate. Required by fast bind. */
|
|
1966
|
+
attest?: boolean;
|
|
1967
|
+
stepUpId?: string;
|
|
1968
|
+
code?: string;
|
|
1969
|
+
idempotencyKey?: string;
|
|
1970
|
+
}
|
|
1971
|
+
declare class InstantQuotesModule {
|
|
1972
|
+
private http;
|
|
1973
|
+
constructor(http: HttpClient);
|
|
1974
|
+
/**
|
|
1975
|
+
* `fresh: true` always mints a new submission instead of reusing a warm
|
|
1976
|
+
* session for the same coverages. Use it with `submit({ replace: true })`
|
|
1977
|
+
* to re-quote coverage that already has a request with carriers.
|
|
1978
|
+
*/
|
|
1979
|
+
start(coverages: string[], opts?: {
|
|
1980
|
+
fresh?: boolean;
|
|
1981
|
+
}): Promise<InstantSession>;
|
|
1982
|
+
submit(input: {
|
|
1983
|
+
submissionId: string;
|
|
1984
|
+
sessionVersion: string;
|
|
1985
|
+
answers: Record<string, unknown>;
|
|
1986
|
+
/**
|
|
1987
|
+
* Close the earlier request for the same coverage and re-quote. Without
|
|
1988
|
+
* it, a submit while one is with carriers returns 409
|
|
1989
|
+
* `active_request_exists`. A carrier may still see the earlier
|
|
1990
|
+
* application: CoverForce has no withdraw call.
|
|
1991
|
+
*/
|
|
1992
|
+
replace?: boolean;
|
|
1993
|
+
}, opts?: {
|
|
1994
|
+
idempotencyKey?: string;
|
|
1995
|
+
}): Promise<InstantSubmitResult>;
|
|
1996
|
+
status(submissionId: string): Promise<InstantQuoteStatus>;
|
|
1997
|
+
/** Polls `status` until every visible carrier resolved, or the timeout. */
|
|
1998
|
+
waitForQuotes(submissionId: string, opts?: {
|
|
1999
|
+
timeoutMs?: number;
|
|
2000
|
+
intervalMs?: number;
|
|
2001
|
+
onPoll?: (s: InstantQuoteStatus) => void;
|
|
2002
|
+
}): Promise<InstantQuoteStatus>;
|
|
2003
|
+
/**
|
|
2004
|
+
* After a `no_carriers` submit: the ACORD questions a broker needs to place
|
|
2005
|
+
* the risk with a non-instant market. Pass the answers you submitted so
|
|
2006
|
+
* facts you already gave are not asked again.
|
|
2007
|
+
*/
|
|
2008
|
+
brokerHandoffQuestions(submissionId: string, instantAnswers?: Record<string, unknown>): Promise<BrokerHandoffQuestions>;
|
|
2009
|
+
/**
|
|
2010
|
+
* Hands a `no_carriers` submission to a Delegance broker as a non-instant
|
|
2011
|
+
* request, with whatever ACORD answers you have. `complete: false` says you
|
|
2012
|
+
* stopped early; the broker asks the rest. A repeat call returns the same
|
|
2013
|
+
* broker task.
|
|
2014
|
+
*/
|
|
2015
|
+
brokerHandoff(submissionId: string, input: {
|
|
2016
|
+
answers: Record<string, unknown>;
|
|
2017
|
+
instantAnswers?: Record<string, unknown>;
|
|
2018
|
+
complete?: boolean;
|
|
2019
|
+
}, opts?: {
|
|
2020
|
+
idempotencyKey?: string;
|
|
2021
|
+
}): Promise<BrokerHandoffResult>;
|
|
2022
|
+
/** Requests a bind on one offer. A licensed broker reviews it; nothing is charged. */
|
|
2023
|
+
bind(submissionId: string, opportunityId: string, opts?: {
|
|
2024
|
+
idempotencyKey?: string;
|
|
2025
|
+
}): Promise<BindRequestResult>;
|
|
2026
|
+
/**
|
|
2027
|
+
* Bind through fast bind: an owner or admin attests the answers, gets a
|
|
2028
|
+
* 6-digit code by email (the first call returns `stepUpRequired`), then calls
|
|
2029
|
+
* again with `stepUpId` and `code`. A tier A offer returns `checkoutUrl`;
|
|
2030
|
+
* any other offer goes to a broker.
|
|
2031
|
+
*/
|
|
2032
|
+
bindWithStepUp(submissionId: string, opportunityId: string, input?: FastBindInput): Promise<BindRequestResult | BindStepUpRequired>;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* Payments Module: premium payment requests and Stripe checkout links.
|
|
2037
|
+
*
|
|
2038
|
+
* A payment request exists after a broker reviews a bind and records the
|
|
2039
|
+
* carrier's final premium. `checkout` returns a hosted Stripe URL to pay it.
|
|
2040
|
+
*/
|
|
2041
|
+
|
|
2042
|
+
interface PaymentRequest {
|
|
2043
|
+
id: string;
|
|
2044
|
+
/** Cents. */
|
|
2045
|
+
amount: number;
|
|
2046
|
+
currency: string;
|
|
2047
|
+
description: string | null;
|
|
2048
|
+
status: string;
|
|
2049
|
+
dueDate?: string;
|
|
2050
|
+
createdAt: string;
|
|
2051
|
+
payable: boolean;
|
|
2052
|
+
}
|
|
2053
|
+
declare class PaymentsModule {
|
|
2054
|
+
private http;
|
|
2055
|
+
constructor(http: HttpClient);
|
|
2056
|
+
list(): Promise<PaymentRequest[]>;
|
|
2057
|
+
checkout(paymentRequestId: string, opts?: {
|
|
2058
|
+
idempotencyKey?: string;
|
|
2059
|
+
}): Promise<{
|
|
2060
|
+
checkoutUrl: string;
|
|
2061
|
+
}>;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
/**
|
|
2065
|
+
* Bonds Module: surety bond quotes.
|
|
2066
|
+
*
|
|
2067
|
+
* `start` matches the bond and returns its questions, `answer` submits them
|
|
2068
|
+
* (starting pricing when complete), `status` returns the premium and the
|
|
2069
|
+
* surety's apply link. Buying a bond is never automated: a quoted bond hands
|
|
2070
|
+
* off to the surety's apply page.
|
|
2071
|
+
*
|
|
2072
|
+
* Responses pass through the bond quote service as-is (snake_case fields such
|
|
2073
|
+
* as `session_id`, `missing_required`, `apply_url`).
|
|
2074
|
+
*/
|
|
2075
|
+
|
|
2076
|
+
interface StartBondQuoteInput {
|
|
2077
|
+
/** Two-letter state, e.g. 'TX'. */
|
|
2078
|
+
state?: string;
|
|
2079
|
+
/** Bond name or keyword, e.g. 'notary', 'contractor license'. */
|
|
2080
|
+
bondName?: string;
|
|
2081
|
+
entityId?: string;
|
|
2082
|
+
contractAmount?: string | number;
|
|
2083
|
+
bondAmount?: string | number;
|
|
2084
|
+
}
|
|
2085
|
+
type BondToolResult = Record<string, unknown>;
|
|
2086
|
+
declare class BondsModule {
|
|
2087
|
+
private http;
|
|
2088
|
+
constructor(http: HttpClient);
|
|
2089
|
+
start(input: StartBondQuoteInput): Promise<BondToolResult>;
|
|
2090
|
+
answer(sessionId: string, answers: Record<string, unknown>, opts?: {
|
|
2091
|
+
idempotencyKey?: string;
|
|
2092
|
+
}): Promise<BondToolResult>;
|
|
2093
|
+
status(sessionId: string): Promise<BondToolResult>;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* Claims Module: file and track claims.
|
|
2098
|
+
*
|
|
2099
|
+
* Needs a key with the `claims:write` scope, minted by `delegance signup` or
|
|
2100
|
+
* by a signed-in portal user. The claims disclaimer must be accepted once in
|
|
2101
|
+
* the portal by the key's user; until then `file` throws with
|
|
2102
|
+
* reason `gate_not_acknowledged` and `body.portalUrl`.
|
|
2103
|
+
*/
|
|
2104
|
+
|
|
2105
|
+
interface ClaimSummary {
|
|
2106
|
+
claimId: string;
|
|
2107
|
+
status: 'open' | 'in_progress' | 'resolved' | string;
|
|
2108
|
+
summary: string | null;
|
|
2109
|
+
incidentDate: string | null;
|
|
2110
|
+
policyId: string | null;
|
|
2111
|
+
openedAt: string;
|
|
2112
|
+
lastActivityAt: string;
|
|
2113
|
+
resolvedAt: string | null;
|
|
2114
|
+
}
|
|
2115
|
+
interface FileClaimInput {
|
|
2116
|
+
description: string;
|
|
2117
|
+
/** YYYY-MM-DD. */
|
|
2118
|
+
incidentDate?: string;
|
|
2119
|
+
policyId?: string;
|
|
2120
|
+
}
|
|
2121
|
+
declare class ClaimsModule {
|
|
2122
|
+
private http;
|
|
2123
|
+
constructor(http: HttpClient);
|
|
2124
|
+
file(input: FileClaimInput, opts?: {
|
|
2125
|
+
idempotencyKey?: string;
|
|
2126
|
+
}): Promise<ClaimSummary & {
|
|
2127
|
+
created: boolean;
|
|
2128
|
+
portalUrl: string;
|
|
2129
|
+
message: string;
|
|
2130
|
+
}>;
|
|
2131
|
+
list(opts?: {
|
|
2132
|
+
status?: 'open' | 'in_progress' | 'resolved';
|
|
2133
|
+
limit?: number;
|
|
2134
|
+
}): Promise<ClaimSummary[]>;
|
|
2135
|
+
get(claimId: string): Promise<ClaimSummary>;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* Feedback Module: report a bug, an idea, or a question to Delegance.
|
|
2140
|
+
*
|
|
2141
|
+
* Any API key may report. The server scrubs credentials from the message and
|
|
2142
|
+
* keeps only known context fields, but send no secrets: the context is for
|
|
2143
|
+
* the command name, exit code, trace id, and versions.
|
|
2144
|
+
*/
|
|
2145
|
+
|
|
2146
|
+
type FeedbackType = 'bug' | 'idea' | 'question';
|
|
2147
|
+
/** Matches the server cap; longer messages are refused, not cut. */
|
|
2148
|
+
declare const FEEDBACK_MESSAGE_MAX = 500;
|
|
2149
|
+
interface FeedbackContext {
|
|
2150
|
+
/** Command path only, e.g. "quote submit". Never arguments. */
|
|
2151
|
+
command?: string;
|
|
2152
|
+
exitCode?: number;
|
|
2153
|
+
/** The traceId from an error response, if the failure returned one. */
|
|
2154
|
+
traceId?: string;
|
|
2155
|
+
/** ISO timestamp of the failed command. */
|
|
2156
|
+
at?: string;
|
|
2157
|
+
cliVersion?: string;
|
|
2158
|
+
sdkVersion?: string;
|
|
2159
|
+
}
|
|
2160
|
+
interface SubmitFeedbackInput {
|
|
2161
|
+
/** Defaults to 'bug'. */
|
|
2162
|
+
type?: FeedbackType;
|
|
2163
|
+
message: string;
|
|
2164
|
+
context?: FeedbackContext;
|
|
2165
|
+
}
|
|
2166
|
+
declare class FeedbackModule {
|
|
2167
|
+
private http;
|
|
2168
|
+
constructor(http: HttpClient);
|
|
2169
|
+
/**
|
|
2170
|
+
* File a report. Returns the reference id Delegance uses to find it.
|
|
2171
|
+
*
|
|
2172
|
+
* Each call sends one Idempotency-Key, and the client's automatic retries of
|
|
2173
|
+
* that call reuse it, so a lost response never files the report twice. Pass
|
|
2174
|
+
* your own key to make a retry of your own (a second call) safe as well.
|
|
2175
|
+
*/
|
|
2176
|
+
submit(input: SubmitFeedbackInput, opts?: {
|
|
2177
|
+
idempotencyKey?: string;
|
|
2178
|
+
}): Promise<{
|
|
2179
|
+
id: string;
|
|
2180
|
+
}>;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* Signup Module: commercial insurance from a terminal, step one.
|
|
2185
|
+
*
|
|
2186
|
+
* Signup is a device-code exchange. No API key exists yet, so this module
|
|
2187
|
+
* runs unauthenticated except for `enroll` and `requestVerification`, which
|
|
2188
|
+
* use the one-time bootstrap key the signup returns.
|
|
2189
|
+
*
|
|
2190
|
+
* 1. createAccount unverified company + bootstrap key
|
|
2191
|
+
* 2. enroll register SHA-256(deviceSecret) against that key
|
|
2192
|
+
* 3. requestVerification emails the confirm link to the contact email
|
|
2193
|
+
* 4. exchange poll with the plaintext deviceSecret; after the human
|
|
2194
|
+
* clicks the link it returns a user-bound API key
|
|
2195
|
+
*
|
|
2196
|
+
* The device secret never leaves the terminal except to `exchange`, and the
|
|
2197
|
+
* bootstrap key is revoked server-side once the email is confirmed.
|
|
2198
|
+
*/
|
|
2199
|
+
|
|
2200
|
+
interface CreateAccountInput {
|
|
2201
|
+
name: string;
|
|
2202
|
+
contactEmail: string;
|
|
2203
|
+
industry: string;
|
|
2204
|
+
/** Employee band: '0', '1', '2-10', '11-25', '26-50', '51-100', '100-499', '500+'. */
|
|
2205
|
+
companySize: string;
|
|
2206
|
+
/** One or two sentences on what the business does; feeds carrier class matching. */
|
|
2207
|
+
description?: string;
|
|
2208
|
+
website?: string;
|
|
2209
|
+
contactPhone?: string;
|
|
2210
|
+
address?: {
|
|
2211
|
+
street: string;
|
|
2212
|
+
suite?: string;
|
|
2213
|
+
city: string;
|
|
2214
|
+
state: string;
|
|
2215
|
+
zip: string;
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
interface CreateAccountResult {
|
|
2219
|
+
companyId: string;
|
|
2220
|
+
bootstrapKey: string;
|
|
2221
|
+
/** e.g. 'address_not_saved': the account exists but the server could not store part of it. */
|
|
2222
|
+
warnings?: string[];
|
|
2223
|
+
}
|
|
2224
|
+
interface EnrollResult {
|
|
2225
|
+
enrollmentId: string;
|
|
2226
|
+
expiresAt: string;
|
|
2227
|
+
}
|
|
2228
|
+
type ExchangeResult = {
|
|
2229
|
+
status: 'pending';
|
|
2230
|
+
} | {
|
|
2231
|
+
status: 'ready';
|
|
2232
|
+
apiKey: string;
|
|
2233
|
+
keyPrefix: string;
|
|
2234
|
+
companyId: string;
|
|
2235
|
+
};
|
|
2236
|
+
/** 32 random bytes as hex, and its SHA-256. */
|
|
2237
|
+
declare function newDeviceSecret(): {
|
|
2238
|
+
secret: string;
|
|
2239
|
+
hash: string;
|
|
2240
|
+
};
|
|
2241
|
+
declare class SignupModule {
|
|
2242
|
+
private makeHttp;
|
|
2243
|
+
constructor(makeHttp: (apiKey: string) => HttpClient);
|
|
2244
|
+
/** Creates the unverified company. Retries safely: sends an Idempotency-Key. */
|
|
2245
|
+
createAccount(input: CreateAccountInput, opts?: {
|
|
2246
|
+
idempotencyKey?: string;
|
|
2247
|
+
}): Promise<CreateAccountResult>;
|
|
2248
|
+
enroll(bootstrapKey: string, input: {
|
|
2249
|
+
deviceSecretHash: string;
|
|
2250
|
+
firstName: string;
|
|
2251
|
+
lastName: string;
|
|
2252
|
+
}): Promise<EnrollResult>;
|
|
2253
|
+
requestVerification(bootstrapKey: string): Promise<{
|
|
2254
|
+
sentTo?: string;
|
|
2255
|
+
}>;
|
|
2256
|
+
/**
|
|
2257
|
+
* One poll. `pending` until the email link is clicked. Throws with
|
|
2258
|
+
* `reason` = already_collected | account_exists (409) or expired (410).
|
|
2259
|
+
*/
|
|
2260
|
+
exchange(enrollmentId: string, deviceSecret: string): Promise<ExchangeResult>;
|
|
2261
|
+
/**
|
|
2262
|
+
* Polls `exchange` until the key is ready or `timeoutMs` passes. A 429 waits
|
|
2263
|
+
* the server's Retry-After and keeps polling.
|
|
2264
|
+
*/
|
|
2265
|
+
waitForKey(enrollmentId: string, deviceSecret: string, opts?: {
|
|
2266
|
+
timeoutMs?: number;
|
|
2267
|
+
intervalMs?: number;
|
|
2268
|
+
onPoll?: () => void;
|
|
2269
|
+
}): Promise<ExchangeResult>;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
interface PollOptions {
|
|
2273
|
+
timeoutMs?: number;
|
|
2274
|
+
intervalMs?: number;
|
|
2275
|
+
onPoll?: () => void;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* Auth Module: sign a terminal in with the browser, and inspect or refresh
|
|
2280
|
+
* the key it holds.
|
|
2281
|
+
*
|
|
2282
|
+
* Browser login is a device authorization (the same device-secret exchange
|
|
2283
|
+
* as signup):
|
|
2284
|
+
*
|
|
2285
|
+
* 1. start send SHA-256(deviceSecret); get a short code and a portal URL
|
|
2286
|
+
* 2. (human) a signed-in portal user opens the URL and approves the code
|
|
2287
|
+
* 3. waitForKey poll with the plaintext deviceSecret until the key is ready
|
|
2288
|
+
*
|
|
2289
|
+
* The device secret never leaves the terminal except to the token poll, and
|
|
2290
|
+
* the key can be collected once.
|
|
2291
|
+
*/
|
|
2292
|
+
|
|
2293
|
+
interface DeviceLoginStart {
|
|
2294
|
+
loginId: string;
|
|
2295
|
+
/** Shown as XXXX-XXXX; the portal page asks the human to match it. */
|
|
2296
|
+
userCode: string;
|
|
2297
|
+
verificationUri: string;
|
|
2298
|
+
verificationUriComplete: string;
|
|
2299
|
+
expiresAt: string;
|
|
2300
|
+
/** Seconds between polls. */
|
|
2301
|
+
interval: number;
|
|
2302
|
+
}
|
|
2303
|
+
type DeviceLoginPoll = {
|
|
2304
|
+
status: 'pending';
|
|
2305
|
+
} | {
|
|
2306
|
+
status: 'ready';
|
|
2307
|
+
apiKey: string;
|
|
2308
|
+
keyPrefix: string;
|
|
2309
|
+
companyId: string;
|
|
2310
|
+
scopes: string[];
|
|
2311
|
+
expiresAt: string | null;
|
|
2312
|
+
};
|
|
2313
|
+
interface ApiKeyInfo {
|
|
2314
|
+
keyPrefix: string;
|
|
2315
|
+
origin: string | null;
|
|
2316
|
+
scopes: string[];
|
|
2317
|
+
companyId: string;
|
|
2318
|
+
userBound: boolean;
|
|
2319
|
+
/** ISO time, or null for a key that never expires. */
|
|
2320
|
+
expiresAt: string | null;
|
|
2321
|
+
/** True for CLI keys, which `refresh()` can extend. */
|
|
2322
|
+
refreshable: boolean;
|
|
2323
|
+
createdAt: string | null;
|
|
2324
|
+
}
|
|
2325
|
+
declare class DeviceLoginModule {
|
|
2326
|
+
private makeHttp;
|
|
2327
|
+
constructor(makeHttp: (apiKey: string) => HttpClient);
|
|
2328
|
+
start(input: {
|
|
2329
|
+
deviceSecretHash: string;
|
|
2330
|
+
deviceName: string;
|
|
2331
|
+
}): Promise<DeviceLoginStart>;
|
|
2332
|
+
/**
|
|
2333
|
+
* One poll. `pending` until the portal user approves. Throws with `reason`
|
|
2334
|
+
* = access_denied (403), already_collected (409), or expired (410).
|
|
2335
|
+
*/
|
|
2336
|
+
poll(loginId: string, deviceSecret: string): Promise<DeviceLoginPoll>;
|
|
2337
|
+
/** Polls until the key is ready or `timeoutMs` passes (then returns `pending`). */
|
|
2338
|
+
waitForKey(loginId: string, deviceSecret: string, opts?: PollOptions): Promise<DeviceLoginPoll>;
|
|
2339
|
+
}
|
|
2340
|
+
declare class AuthModule {
|
|
2341
|
+
private http;
|
|
2342
|
+
constructor(http: HttpClient);
|
|
2343
|
+
/** The calling key: prefix, origin, scopes, company, and expiry. */
|
|
2344
|
+
keyInfo(): Promise<ApiKeyInfo>;
|
|
2345
|
+
/** Extend a CLI key to 90 days from now. Throws `not_refreshable` (400) for portal keys. */
|
|
2346
|
+
refresh(): Promise<{
|
|
2347
|
+
expiresAt: string;
|
|
2348
|
+
}>;
|
|
1517
2349
|
}
|
|
1518
2350
|
|
|
1519
2351
|
/**
|
|
@@ -1527,7 +2359,7 @@ declare class OnboardingModule {
|
|
|
1527
2359
|
*
|
|
1528
2360
|
* const client = new DeleganceClient({
|
|
1529
2361
|
* apiKey: 'dlg_xxx_sk_xxx',
|
|
1530
|
-
* baseUrl: 'https://
|
|
2362
|
+
* baseUrl: 'https://portal.delegancebrokerage.com'
|
|
1531
2363
|
* });
|
|
1532
2364
|
*
|
|
1533
2365
|
* // Create a company
|
|
@@ -1574,6 +2406,22 @@ declare class DeleganceClient {
|
|
|
1574
2406
|
readonly knowledge: KnowledgeModule;
|
|
1575
2407
|
/** Onboarding module for checking developer setup status */
|
|
1576
2408
|
readonly onboarding: OnboardingModule;
|
|
2409
|
+
/** Appetite module for carrier appetite matching (needs the appetite:read scope) */
|
|
2410
|
+
readonly appetite: AppetiteModule;
|
|
2411
|
+
/** Leads module for sending prospect businesses to Delegance */
|
|
2412
|
+
readonly leads: LeadsModule;
|
|
2413
|
+
/** Instant quotes: questions, carrier premiums, and bind requests */
|
|
2414
|
+
readonly instantQuotes: InstantQuotesModule;
|
|
2415
|
+
/** Premium payment requests and Stripe checkout links */
|
|
2416
|
+
readonly payments: PaymentsModule;
|
|
2417
|
+
/** Surety bond quotes */
|
|
2418
|
+
readonly bonds: BondsModule;
|
|
2419
|
+
/** File and track claims (needs the claims:write scope) */
|
|
2420
|
+
readonly claims: ClaimsModule;
|
|
2421
|
+
/** Report a bug, an idea, or a question to Delegance */
|
|
2422
|
+
readonly feedback: FeedbackModule;
|
|
2423
|
+
/** The calling key: info and refresh */
|
|
2424
|
+
readonly auth: AuthModule;
|
|
1577
2425
|
/**
|
|
1578
2426
|
* Create a new Delegance client
|
|
1579
2427
|
*
|
|
@@ -1603,7 +2451,7 @@ declare class DeleganceClient {
|
|
|
1603
2451
|
*
|
|
1604
2452
|
* Reads from:
|
|
1605
2453
|
* - DELEGANCE_API_KEY - Required API key
|
|
1606
|
-
* - DELEGANCE_BASE_URL - Optional base URL (default: https://
|
|
2454
|
+
* - DELEGANCE_BASE_URL - Optional base URL (default: https://portal.delegancebrokerage.com)
|
|
1607
2455
|
*
|
|
1608
2456
|
* @example
|
|
1609
2457
|
* ```typescript
|
|
@@ -1612,5 +2460,36 @@ declare class DeleganceClient {
|
|
|
1612
2460
|
* ```
|
|
1613
2461
|
*/
|
|
1614
2462
|
declare function createClientFromEnv(): DeleganceClient;
|
|
2463
|
+
/**
|
|
2464
|
+
* Signup runs before any API key exists, so it lives outside DeleganceClient.
|
|
2465
|
+
*
|
|
2466
|
+
* @example
|
|
2467
|
+
* ```typescript
|
|
2468
|
+
* const signup = createSignup();
|
|
2469
|
+
* const { bootstrapKey } = await signup.createAccount({ ... });
|
|
2470
|
+
* ```
|
|
2471
|
+
*/
|
|
2472
|
+
declare function createSignup(config?: {
|
|
2473
|
+
baseUrl?: string;
|
|
2474
|
+
timeout?: number;
|
|
2475
|
+
retries?: number;
|
|
2476
|
+
}): SignupModule;
|
|
2477
|
+
/**
|
|
2478
|
+
* Browser login for an existing customer (`delegance auth login`). No API key
|
|
2479
|
+
* yet: the device secret is the credential.
|
|
2480
|
+
*
|
|
2481
|
+
* ```typescript
|
|
2482
|
+
* const login = createDeviceLogin();
|
|
2483
|
+
* const device = newDeviceSecret();
|
|
2484
|
+
* const start = await login.start({ deviceSecretHash: device.hash, deviceName: 'laptop' });
|
|
2485
|
+
* // show start.userCode and open start.verificationUriComplete
|
|
2486
|
+
* const result = await login.waitForKey(start.loginId, device.secret);
|
|
2487
|
+
* ```
|
|
2488
|
+
*/
|
|
2489
|
+
declare function createDeviceLogin(config?: {
|
|
2490
|
+
baseUrl?: string;
|
|
2491
|
+
timeout?: number;
|
|
2492
|
+
retries?: number;
|
|
2493
|
+
}): DeviceLoginModule;
|
|
1615
2494
|
|
|
1616
|
-
export { type APIKey, type APIResponse, type ApiKey, ApiKeysModule, AuthenticationError, type COI, COIModule, type Carrier, type CertificateHolder, type ChatMessage, ChatModule, type ChatOptions, type ChatResponse, CompaniesModule, type Company, type CompanySize, CompanySizeSchema, type CreateAPIKeyInput, type CreateApiKeyInput, type CreateCompanyInput, CreateCompanySchema, type CreatedAPIKey, type CreatedApiKey, type DailyUsage, type DailyUsageOptions, DeleganceClient, type DeleganceClientConfig, DeleganceError, type Document, type DocumentFacts, type DocumentStatus, DocumentStatusSchema, type DocumentType, DocumentTypeSchema, type DocumentWithExtraction, DocumentsModule, type ExtractedPolicy, type GenerateCOIRequest, type GenerateCOIResponse, type GetPolicyResponse, type GetQuoteResponse, type GetSOVResponse, type IdempotencyOptions, KnowledgeModule, type KnowledgeSearchResult, type ListApiKeysOptions, type ListCOIsResponse, type ListCarriersResponse, type ListCompaniesOptions, type ListDocumentsOptions, type ListNotecardsOptions, type ListPoliciesOptions, type ListPoliciesResponse, type ListQuotesOptions, type ListQuotesResponse, type ListSOVsOptions, type ListSOVsResponse, type MeterUsage, NotFoundError, type Notecard, OnboardingModule, type OnboardingNextStep, type OnboardingStatus, type PaginatedResponse, PoliciesModule, type Policy, type PolicyCoverage, type Quote, type QuoteRequest, QuotesModule, RateLimitError, type RateLimitStatus, type RotateResult, SDK_VERSION, type SOV, type SOVLocation, SOVModule, type SearchInput, type SubmitQuoteResponse, type UploadDocumentInput, type UploadSOVRequest, type UploadSOVResponse, UsageModule, type UsageSummary, ValidationError, type WaitForExtractionOptions, createClientFromEnv };
|
|
2495
|
+
export { type APIKey, type APIResponse, API_KEY_SCOPES, type ApiKey, type ApiKeyInfo, type ApiKeyScope, ApiKeysModule, type AppetiteJobStatus, type AppetiteMatch, type AppetiteMatchInput, type AppetiteMatchResult, type AppetiteMatchStart, AppetiteModule, AuthModule, AuthenticationError, type BindRequestResult, type BindStepUpRequired, type BondToolResult, BondsModule, type BrokerHandoffQuestions, type BrokerHandoffResult, type COI, COIModule, type CancellationReason, type CancellationRequestInput, type CancellationSignInput, type CancellationSignResult, type CancellationStatus, type Carrier, type CarrierAppetiteResult, type CarrierQuote, type CertificateHolder, type ChatMessage, ChatModule, type ChatOptions, type ChatResponse, type ClaimSummary, ClaimsModule, CompaniesModule, type Company, type CompanySize, CompanySizeSchema, type CreateAPIKeyInput, type CreateAccountInput, type CreateAccountResult, type CreateApiKeyInput, type CreateCompanyInput, CreateCompanySchema, type CreateLeadInput, type CreateLeadResult, type CreatedAPIKey, type CreatedApiKey, DEFAULT_BASE_URL, type DailyUsage, type DailyUsageOptions, DeleganceClient, type DeleganceClientConfig, DeleganceError, DeviceLoginModule, type DeviceLoginPoll, type DeviceLoginStart, type Document, type DocumentFacts, type DocumentStatus, DocumentStatusSchema, type DocumentType, DocumentTypeSchema, type DocumentWithExtraction, DocumentsModule, type EnrollResult, type ExchangeResult, type ExtractedPolicy, FEEDBACK_MESSAGE_MAX, type FastBindInput, type FeedbackContext, FeedbackModule, type FeedbackType, type FileClaimInput, ForbiddenError, type GenerateCOIRequest, type GenerateCOIResponse, type GetPolicyResponse, type GetQuoteResponse, type GetSOVResponse, type IdempotencyOptions, type InstantQuestion, type InstantQuestionOption, type InstantQuoteStatus, InstantQuotesModule, type InstantSession, type InstantSubmitResult, KnowledgeModule, type KnowledgeSearchResult, type LeadAddress, LeadsModule, type ListApiKeysOptions, type ListCOIsResponse, type ListCarriersResponse, type ListCompaniesOptions, type ListDocumentsOptions, type ListNotecardsOptions, type ListPoliciesOptions, type ListPoliciesResponse, type ListQuotesOptions, type ListQuotesResponse, type ListSOVsOptions, type ListSOVsResponse, type MeterUsage, NotFoundError, NotImplementedError, type Notecard, OnboardingModule, type OnboardingNextStep, type OnboardingState, type OnboardingStateData, type OnboardingStatus, type PaginatedResponse, type PaymentRequest, PaymentsModule, PoliciesModule, type Policy, type PolicyCoverage, type Quote, type QuoteRequest, QuotesModule, RateLimitError, type RateLimitStatus, type RotateResult, SDK_VERSION, type SOV, type SOVLocation, SOVModule, type SearchInput, SignupModule, type StartBondQuoteInput, type SubmitFeedbackInput, type SubmitQuoteResponse, type UploadDocumentInput, type UploadSOVRequest, type UploadSOVResponse, UsageModule, type UsageSummary, ValidationError, type WaitForExtractionOptions, type WaitForMatchOptions, createClientFromEnv, createDeviceLogin, createSignup, newDeviceSecret };
|