@startsimpli/api 0.2.3 → 0.2.5
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/package.json +6 -12
- package/dist/index.d.mts +0 -2235
- package/dist/index.d.ts +0 -2235
- package/dist/index.js +0 -2092
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2010
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
DELETED
|
@@ -1,2235 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Common API types for Django REST Framework
|
|
5
|
-
*/
|
|
6
|
-
interface PaginatedResponse<T> {
|
|
7
|
-
count: number;
|
|
8
|
-
next: string | null;
|
|
9
|
-
previous: string | null;
|
|
10
|
-
results: T[];
|
|
11
|
-
}
|
|
12
|
-
interface ApiError$1 {
|
|
13
|
-
detail?: string;
|
|
14
|
-
message?: string;
|
|
15
|
-
errors?: Record<string, string[]>;
|
|
16
|
-
status?: number;
|
|
17
|
-
statusText?: string;
|
|
18
|
-
}
|
|
19
|
-
interface PaginationParams {
|
|
20
|
-
page?: number;
|
|
21
|
-
pageSize?: number;
|
|
22
|
-
}
|
|
23
|
-
interface SortParams {
|
|
24
|
-
ordering?: string;
|
|
25
|
-
}
|
|
26
|
-
interface ApiRequestConfig {
|
|
27
|
-
headers?: HeadersInit;
|
|
28
|
-
signal?: AbortSignal;
|
|
29
|
-
}
|
|
30
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
31
|
-
interface FetchOptions extends RequestInit {
|
|
32
|
-
params?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface ApiError {
|
|
36
|
-
code: string;
|
|
37
|
-
message: string;
|
|
38
|
-
details?: unknown;
|
|
39
|
-
}
|
|
40
|
-
interface ApiResponse<T = unknown> {
|
|
41
|
-
success: boolean;
|
|
42
|
-
data?: T;
|
|
43
|
-
error?: ApiError;
|
|
44
|
-
}
|
|
45
|
-
declare enum ErrorCodes {
|
|
46
|
-
UNAUTHORIZED = "UNAUTHORIZED",
|
|
47
|
-
FORBIDDEN = "FORBIDDEN",
|
|
48
|
-
NOT_FOUND = "NOT_FOUND",
|
|
49
|
-
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
50
|
-
CONFLICT = "CONFLICT",
|
|
51
|
-
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
52
|
-
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
|
|
53
|
-
RATE_LIMITED = "RATE_LIMITED"
|
|
54
|
-
}
|
|
55
|
-
type AsyncStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
56
|
-
interface AsyncState<T> {
|
|
57
|
-
status: AsyncStatus;
|
|
58
|
-
data: T | null;
|
|
59
|
-
error: string | null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Entity system types matching Django core models
|
|
64
|
-
*/
|
|
65
|
-
type EntityType$1 = 'contact' | 'organization';
|
|
66
|
-
interface Entity {
|
|
67
|
-
id: string;
|
|
68
|
-
entityType: EntityType$1;
|
|
69
|
-
createdAt: string;
|
|
70
|
-
updatedAt: string;
|
|
71
|
-
tags?: EntityTag[];
|
|
72
|
-
metrics?: Metric[];
|
|
73
|
-
profiles?: Profile[];
|
|
74
|
-
attributes?: Attribute[];
|
|
75
|
-
relationshipsFrom?: Relationship[];
|
|
76
|
-
relationshipsTo?: Relationship[];
|
|
77
|
-
roleAssignments?: RoleAssignment[];
|
|
78
|
-
events?: Event[];
|
|
79
|
-
}
|
|
80
|
-
interface Tag {
|
|
81
|
-
id: number;
|
|
82
|
-
category: string;
|
|
83
|
-
name: string;
|
|
84
|
-
description?: string;
|
|
85
|
-
fullPath: string;
|
|
86
|
-
}
|
|
87
|
-
interface EntityTag {
|
|
88
|
-
id: number;
|
|
89
|
-
category: string;
|
|
90
|
-
name: string;
|
|
91
|
-
tagDescription?: string;
|
|
92
|
-
confidence: number;
|
|
93
|
-
appliedAt: string;
|
|
94
|
-
appliedBy?: string;
|
|
95
|
-
metadata?: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
interface Metric {
|
|
98
|
-
id: number;
|
|
99
|
-
type: string;
|
|
100
|
-
subtype: string;
|
|
101
|
-
value: number | string | null;
|
|
102
|
-
valueNumeric?: number | null;
|
|
103
|
-
valueText?: string | null;
|
|
104
|
-
unit?: string;
|
|
105
|
-
asOfDate?: string;
|
|
106
|
-
periodStart?: string;
|
|
107
|
-
confidence: number;
|
|
108
|
-
metadata?: Record<string, unknown>;
|
|
109
|
-
}
|
|
110
|
-
interface Profile {
|
|
111
|
-
id: number;
|
|
112
|
-
type: string;
|
|
113
|
-
subtype: string;
|
|
114
|
-
identifier: string;
|
|
115
|
-
identifierType: string;
|
|
116
|
-
displayName: string;
|
|
117
|
-
verified: boolean;
|
|
118
|
-
verifiedAt?: string;
|
|
119
|
-
metadata?: Record<string, unknown>;
|
|
120
|
-
}
|
|
121
|
-
interface Attribute {
|
|
122
|
-
id: number;
|
|
123
|
-
type: string;
|
|
124
|
-
subtype: string;
|
|
125
|
-
value: string | Record<string, unknown> | null;
|
|
126
|
-
valueText?: string | null;
|
|
127
|
-
valueJson?: Record<string, unknown> | null;
|
|
128
|
-
valueType: 'text' | 'json';
|
|
129
|
-
validFrom?: string;
|
|
130
|
-
validTo?: string;
|
|
131
|
-
isCurrent: boolean;
|
|
132
|
-
confidence: number;
|
|
133
|
-
metadata?: Record<string, unknown>;
|
|
134
|
-
}
|
|
135
|
-
interface Relationship {
|
|
136
|
-
id: number;
|
|
137
|
-
fromEntityId: string;
|
|
138
|
-
toEntityId: string;
|
|
139
|
-
type: string;
|
|
140
|
-
subtype?: string;
|
|
141
|
-
validFrom?: string;
|
|
142
|
-
validTo?: string;
|
|
143
|
-
isCurrent: boolean;
|
|
144
|
-
durationDays?: number;
|
|
145
|
-
strength?: number;
|
|
146
|
-
confidence: number;
|
|
147
|
-
metadata?: Record<string, unknown>;
|
|
148
|
-
}
|
|
149
|
-
interface RoleAssignment {
|
|
150
|
-
id: number;
|
|
151
|
-
contactId: string;
|
|
152
|
-
orgId: string;
|
|
153
|
-
type: string;
|
|
154
|
-
subtype?: string;
|
|
155
|
-
title?: string;
|
|
156
|
-
seniority?: string;
|
|
157
|
-
validFrom?: string;
|
|
158
|
-
validTo?: string;
|
|
159
|
-
isCurrent: boolean;
|
|
160
|
-
durationDays?: number;
|
|
161
|
-
confidence: number;
|
|
162
|
-
metadata?: Record<string, unknown>;
|
|
163
|
-
}
|
|
164
|
-
interface Event {
|
|
165
|
-
id: number;
|
|
166
|
-
type: string;
|
|
167
|
-
subtype?: string;
|
|
168
|
-
occurredAt?: string;
|
|
169
|
-
announcedAt?: string;
|
|
170
|
-
magnitude?: number;
|
|
171
|
-
confidence: number;
|
|
172
|
-
metadata?: Record<string, unknown>;
|
|
173
|
-
participants?: EventParticipant[];
|
|
174
|
-
}
|
|
175
|
-
interface EventParticipant {
|
|
176
|
-
id: number;
|
|
177
|
-
entityId: string;
|
|
178
|
-
roleType: string;
|
|
179
|
-
roleSubtype?: string;
|
|
180
|
-
metadata?: Record<string, unknown>;
|
|
181
|
-
}
|
|
182
|
-
interface Source {
|
|
183
|
-
id: number;
|
|
184
|
-
type: string;
|
|
185
|
-
subtype?: string;
|
|
186
|
-
identifier: string;
|
|
187
|
-
retrievedAt: string;
|
|
188
|
-
format: string;
|
|
189
|
-
confidence: number;
|
|
190
|
-
cost?: number;
|
|
191
|
-
metadata?: Record<string, unknown>;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Writable assertion formats for POST/PATCH
|
|
195
|
-
*/
|
|
196
|
-
interface WritableAssertions {
|
|
197
|
-
writeTags?: Array<string | {
|
|
198
|
-
category: string;
|
|
199
|
-
name: string;
|
|
200
|
-
confidence?: number;
|
|
201
|
-
}>;
|
|
202
|
-
writeMetrics?: Record<string, number | string>;
|
|
203
|
-
writeProfiles?: Record<string, string>;
|
|
204
|
-
writeAttributes?: Record<string, string | Record<string, unknown>>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Contact types matching Django Contact model
|
|
209
|
-
*/
|
|
210
|
-
|
|
211
|
-
interface Contact extends Entity {
|
|
212
|
-
name: string;
|
|
213
|
-
email?: string | null;
|
|
214
|
-
phone?: string | null;
|
|
215
|
-
title?: string | null;
|
|
216
|
-
companyName?: string | null;
|
|
217
|
-
location?: string | null;
|
|
218
|
-
notes?: string | null;
|
|
219
|
-
tier?: number | null;
|
|
220
|
-
status?: string | null;
|
|
221
|
-
linkedin?: string | null;
|
|
222
|
-
twitter?: string | null;
|
|
223
|
-
website?: string | null;
|
|
224
|
-
firmId?: string | null;
|
|
225
|
-
firmName?: string | null;
|
|
226
|
-
enrichmentScore?: number | null;
|
|
227
|
-
}
|
|
228
|
-
interface CreateContactRequest extends WritableAssertions {
|
|
229
|
-
name: string;
|
|
230
|
-
email?: string;
|
|
231
|
-
phone?: string;
|
|
232
|
-
title?: string;
|
|
233
|
-
companyName?: string;
|
|
234
|
-
location?: string;
|
|
235
|
-
notes?: string;
|
|
236
|
-
}
|
|
237
|
-
interface UpdateContactRequest extends Partial<CreateContactRequest> {
|
|
238
|
-
}
|
|
239
|
-
interface ContactFilters {
|
|
240
|
-
[key: string]: unknown;
|
|
241
|
-
search?: string;
|
|
242
|
-
tier?: number;
|
|
243
|
-
status?: string;
|
|
244
|
-
firmId?: string;
|
|
245
|
-
tagCategory?: string;
|
|
246
|
-
tagName?: string;
|
|
247
|
-
hasEmail?: boolean;
|
|
248
|
-
hasLinkedin?: boolean;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Organization types matching Django Organization model
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
interface Organization extends Entity {
|
|
256
|
-
name: string;
|
|
257
|
-
domain?: string | null;
|
|
258
|
-
description?: string | null;
|
|
259
|
-
location?: string | null;
|
|
260
|
-
tier?: number | null;
|
|
261
|
-
stage?: string | null;
|
|
262
|
-
focusAreas?: string[];
|
|
263
|
-
checkSizeMin?: number | null;
|
|
264
|
-
checkSizeMax?: number | null;
|
|
265
|
-
aum?: number | string | null;
|
|
266
|
-
portfolioCount?: number | null;
|
|
267
|
-
linkedin?: string | null;
|
|
268
|
-
twitter?: string | null;
|
|
269
|
-
crunchbase?: string | null;
|
|
270
|
-
website?: string | null;
|
|
271
|
-
foundedYear?: number | null;
|
|
272
|
-
}
|
|
273
|
-
interface CreateOrganizationRequest extends WritableAssertions {
|
|
274
|
-
name: string;
|
|
275
|
-
domain?: string;
|
|
276
|
-
description?: string;
|
|
277
|
-
location?: string;
|
|
278
|
-
}
|
|
279
|
-
interface UpdateOrganizationRequest extends Partial<CreateOrganizationRequest> {
|
|
280
|
-
}
|
|
281
|
-
interface OrganizationFilters {
|
|
282
|
-
[key: string]: unknown;
|
|
283
|
-
search?: string;
|
|
284
|
-
tier?: number;
|
|
285
|
-
stage?: string;
|
|
286
|
-
focusArea?: string;
|
|
287
|
-
checkSizeMinGte?: number;
|
|
288
|
-
checkSizeMaxLte?: number;
|
|
289
|
-
aumGte?: number;
|
|
290
|
-
location?: string;
|
|
291
|
-
tagCategory?: string;
|
|
292
|
-
tagName?: string;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Funnel types matching Django Funnel models
|
|
297
|
-
*
|
|
298
|
-
* Funnels are brutally generic - they can represent:
|
|
299
|
-
* - Lead scoring funnels
|
|
300
|
-
* - Investor qualification stages
|
|
301
|
-
* - Customer segmentation
|
|
302
|
-
* - Any multi-stage entity classification
|
|
303
|
-
*/
|
|
304
|
-
type FunnelStatus = 'draft' | 'active' | 'archived';
|
|
305
|
-
type EntityType = 'contact' | 'organization';
|
|
306
|
-
/**
|
|
307
|
-
* Filter rule for funnel stage
|
|
308
|
-
*/
|
|
309
|
-
interface FunnelStageRule {
|
|
310
|
-
id: number;
|
|
311
|
-
fieldPath: string;
|
|
312
|
-
operator: 'eq' | 'ne' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'notContains' | 'startswith' | 'endswith' | 'in' | 'notIn' | 'isnull' | 'isnotnull' | 'arrayContains' | 'arrayOverlaps';
|
|
313
|
-
value: string | number | boolean | null;
|
|
314
|
-
logic?: 'AND' | 'OR';
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Funnel stage with rules
|
|
318
|
-
*/
|
|
319
|
-
interface FunnelStage {
|
|
320
|
-
id: number;
|
|
321
|
-
name: string;
|
|
322
|
-
description?: string;
|
|
323
|
-
order: number;
|
|
324
|
-
rules: FunnelStageRule[];
|
|
325
|
-
entityCount?: number;
|
|
326
|
-
createdAt: string;
|
|
327
|
-
updatedAt: string;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Funnel - brutally generic entity classification system
|
|
331
|
-
*/
|
|
332
|
-
interface Funnel {
|
|
333
|
-
id: string;
|
|
334
|
-
name: string;
|
|
335
|
-
description: string;
|
|
336
|
-
status: FunnelStatus;
|
|
337
|
-
tags?: string[];
|
|
338
|
-
entityType: EntityType;
|
|
339
|
-
/**
|
|
340
|
-
* @deprecated Legacy field for backward compatibility
|
|
341
|
-
*/
|
|
342
|
-
inputType?: 'contacts' | 'organizations' | 'both' | 'any';
|
|
343
|
-
stages: FunnelStage[];
|
|
344
|
-
stageCount: number;
|
|
345
|
-
totalRuns: number;
|
|
346
|
-
lastRunAt: string | null;
|
|
347
|
-
createdBy: string;
|
|
348
|
-
createdByName: string | null;
|
|
349
|
-
createdAt: string;
|
|
350
|
-
updatedAt: string;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Funnel result for a specific entity
|
|
354
|
-
*/
|
|
355
|
-
interface FunnelResult {
|
|
356
|
-
id: number;
|
|
357
|
-
funnel: string;
|
|
358
|
-
entity: string;
|
|
359
|
-
entityType: EntityType;
|
|
360
|
-
stage: number | null;
|
|
361
|
-
stageName: string | null;
|
|
362
|
-
score: number | null;
|
|
363
|
-
metadata: Record<string, any>;
|
|
364
|
-
createdAt: string;
|
|
365
|
-
updatedAt: string;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Funnel execution run
|
|
369
|
-
*/
|
|
370
|
-
interface FunnelRun {
|
|
371
|
-
id: string;
|
|
372
|
-
funnel: string;
|
|
373
|
-
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
374
|
-
totalEntities: number;
|
|
375
|
-
processedEntities: number;
|
|
376
|
-
resultsByStage: Record<string, number>;
|
|
377
|
-
startedAt: string | null;
|
|
378
|
-
completedAt: string | null;
|
|
379
|
-
errorMessage: string | null;
|
|
380
|
-
createdBy: string;
|
|
381
|
-
createdAt: string;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Filters for listing funnels
|
|
385
|
-
*/
|
|
386
|
-
interface FunnelFilters {
|
|
387
|
-
status?: FunnelStatus;
|
|
388
|
-
entityType?: EntityType;
|
|
389
|
-
search?: string;
|
|
390
|
-
tags?: string[];
|
|
391
|
-
createdBy?: string;
|
|
392
|
-
page?: number;
|
|
393
|
-
pageSize?: number;
|
|
394
|
-
ordering?: string;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Input for creating a funnel
|
|
398
|
-
*/
|
|
399
|
-
interface CreateFunnelInput {
|
|
400
|
-
name: string;
|
|
401
|
-
description?: string;
|
|
402
|
-
status?: FunnelStatus;
|
|
403
|
-
tags?: string[];
|
|
404
|
-
entityType: EntityType;
|
|
405
|
-
stages?: Omit<FunnelStage, 'id' | 'createdAt' | 'updatedAt' | 'entityCount'>[];
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Input for updating a funnel
|
|
409
|
-
*/
|
|
410
|
-
interface UpdateFunnelInput extends Partial<CreateFunnelInput> {
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Input for executing a funnel
|
|
414
|
-
*/
|
|
415
|
-
interface ExecuteFunnelInput {
|
|
416
|
-
entityIds?: string[];
|
|
417
|
-
filters?: Record<string, any>;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Workflow types matching Django Workflow models
|
|
422
|
-
*
|
|
423
|
-
* Workflows are n8n-style node-based automation flows
|
|
424
|
-
*/
|
|
425
|
-
type WorkflowStatus = 'draft' | 'active' | 'paused';
|
|
426
|
-
interface Workflow$1 {
|
|
427
|
-
id: string;
|
|
428
|
-
name: string;
|
|
429
|
-
description: string;
|
|
430
|
-
team: string;
|
|
431
|
-
createdBy: string | null;
|
|
432
|
-
nodes: any[];
|
|
433
|
-
connections: Record<string, any>;
|
|
434
|
-
settings: Record<string, any>;
|
|
435
|
-
staticData: Record<string, any>;
|
|
436
|
-
isActive: boolean;
|
|
437
|
-
version: number;
|
|
438
|
-
isTemplate: boolean;
|
|
439
|
-
templateSource: string | null;
|
|
440
|
-
executionsCount: number;
|
|
441
|
-
createdAt: string;
|
|
442
|
-
updatedAt: string;
|
|
443
|
-
}
|
|
444
|
-
interface WorkflowExecution$1 {
|
|
445
|
-
id: string;
|
|
446
|
-
workflow: string;
|
|
447
|
-
workflowVersion: number;
|
|
448
|
-
triggeredBy: string;
|
|
449
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'paused';
|
|
450
|
-
mode: 'manual' | 'trigger' | 'webhook';
|
|
451
|
-
contextData: Record<string, any>;
|
|
452
|
-
state: Record<string, any>;
|
|
453
|
-
startedAt: string | null;
|
|
454
|
-
completedAt: string | null;
|
|
455
|
-
waitUntil: string | null;
|
|
456
|
-
errorMessage: string | null;
|
|
457
|
-
createdAt: string;
|
|
458
|
-
updatedAt: string;
|
|
459
|
-
}
|
|
460
|
-
interface WorkflowFilters$1 {
|
|
461
|
-
team?: string;
|
|
462
|
-
isActive?: boolean;
|
|
463
|
-
isTemplate?: boolean;
|
|
464
|
-
page?: number;
|
|
465
|
-
pageSize?: number;
|
|
466
|
-
ordering?: string;
|
|
467
|
-
}
|
|
468
|
-
interface ExecuteWorkflowInput$1 {
|
|
469
|
-
contextData?: Record<string, any>;
|
|
470
|
-
mode?: 'manual' | 'trigger' | 'webhook';
|
|
471
|
-
}
|
|
472
|
-
interface CreateWorkflowInput$1 {
|
|
473
|
-
name: string;
|
|
474
|
-
description?: string;
|
|
475
|
-
team: string;
|
|
476
|
-
nodes?: any[];
|
|
477
|
-
connections?: Record<string, any>;
|
|
478
|
-
settings?: Record<string, any>;
|
|
479
|
-
isActive?: boolean;
|
|
480
|
-
}
|
|
481
|
-
interface UpdateWorkflowInput extends Partial<CreateWorkflowInput$1> {
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Standardized API error response types
|
|
486
|
-
*
|
|
487
|
-
* Provides consistent error handling across frontend and backend
|
|
488
|
-
*/
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Field-level validation error
|
|
492
|
-
*/
|
|
493
|
-
interface FieldError {
|
|
494
|
-
field: string;
|
|
495
|
-
messages: string[];
|
|
496
|
-
code?: string;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Standardized API error response
|
|
500
|
-
*/
|
|
501
|
-
interface StandardErrorResponse {
|
|
502
|
-
/** Main error message (user-friendly) */
|
|
503
|
-
error: string;
|
|
504
|
-
/** Error type/code for programmatic handling */
|
|
505
|
-
code: string;
|
|
506
|
-
/** HTTP status code */
|
|
507
|
-
statusCode: number;
|
|
508
|
-
/** Field-level validation errors */
|
|
509
|
-
fieldErrors?: FieldError[];
|
|
510
|
-
/** Additional error details */
|
|
511
|
-
details?: Record<string, unknown>;
|
|
512
|
-
/** Request ID for debugging */
|
|
513
|
-
requestId?: string;
|
|
514
|
-
/** Timestamp of error */
|
|
515
|
-
timestamp?: string;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Zod schema for runtime validation
|
|
519
|
-
*/
|
|
520
|
-
declare const FieldErrorSchema: z.ZodObject<{
|
|
521
|
-
field: z.ZodString;
|
|
522
|
-
messages: z.ZodArray<z.ZodString, "many">;
|
|
523
|
-
code: z.ZodOptional<z.ZodString>;
|
|
524
|
-
}, "strip", z.ZodTypeAny, {
|
|
525
|
-
field: string;
|
|
526
|
-
messages: string[];
|
|
527
|
-
code?: string | undefined;
|
|
528
|
-
}, {
|
|
529
|
-
field: string;
|
|
530
|
-
messages: string[];
|
|
531
|
-
code?: string | undefined;
|
|
532
|
-
}>;
|
|
533
|
-
declare const StandardErrorResponseSchema: z.ZodObject<{
|
|
534
|
-
error: z.ZodString;
|
|
535
|
-
code: z.ZodString;
|
|
536
|
-
statusCode: z.ZodNumber;
|
|
537
|
-
fieldErrors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
538
|
-
field: z.ZodString;
|
|
539
|
-
messages: z.ZodArray<z.ZodString, "many">;
|
|
540
|
-
code: z.ZodOptional<z.ZodString>;
|
|
541
|
-
}, "strip", z.ZodTypeAny, {
|
|
542
|
-
field: string;
|
|
543
|
-
messages: string[];
|
|
544
|
-
code?: string | undefined;
|
|
545
|
-
}, {
|
|
546
|
-
field: string;
|
|
547
|
-
messages: string[];
|
|
548
|
-
code?: string | undefined;
|
|
549
|
-
}>, "many">>;
|
|
550
|
-
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
551
|
-
requestId: z.ZodOptional<z.ZodString>;
|
|
552
|
-
timestamp: z.ZodOptional<z.ZodString>;
|
|
553
|
-
}, "strip", z.ZodTypeAny, {
|
|
554
|
-
error: string;
|
|
555
|
-
code: string;
|
|
556
|
-
statusCode: number;
|
|
557
|
-
fieldErrors?: {
|
|
558
|
-
field: string;
|
|
559
|
-
messages: string[];
|
|
560
|
-
code?: string | undefined;
|
|
561
|
-
}[] | undefined;
|
|
562
|
-
details?: Record<string, unknown> | undefined;
|
|
563
|
-
requestId?: string | undefined;
|
|
564
|
-
timestamp?: string | undefined;
|
|
565
|
-
}, {
|
|
566
|
-
error: string;
|
|
567
|
-
code: string;
|
|
568
|
-
statusCode: number;
|
|
569
|
-
fieldErrors?: {
|
|
570
|
-
field: string;
|
|
571
|
-
messages: string[];
|
|
572
|
-
code?: string | undefined;
|
|
573
|
-
}[] | undefined;
|
|
574
|
-
details?: Record<string, unknown> | undefined;
|
|
575
|
-
requestId?: string | undefined;
|
|
576
|
-
timestamp?: string | undefined;
|
|
577
|
-
}>;
|
|
578
|
-
/**
|
|
579
|
-
* Common error codes
|
|
580
|
-
*/
|
|
581
|
-
declare enum ErrorCode {
|
|
582
|
-
BAD_REQUEST = "bad_request",
|
|
583
|
-
UNAUTHORIZED = "unauthorized",
|
|
584
|
-
FORBIDDEN = "forbidden",
|
|
585
|
-
NOT_FOUND = "not_found",
|
|
586
|
-
METHOD_NOT_ALLOWED = "method_not_allowed",
|
|
587
|
-
VALIDATION_ERROR = "validation_error",
|
|
588
|
-
CONFLICT = "conflict",
|
|
589
|
-
RATE_LIMITED = "rate_limited",
|
|
590
|
-
INTERNAL_ERROR = "internal_error",
|
|
591
|
-
SERVICE_UNAVAILABLE = "service_unavailable",
|
|
592
|
-
GATEWAY_TIMEOUT = "gateway_timeout",
|
|
593
|
-
NETWORK_ERROR = "network_error",
|
|
594
|
-
TIMEOUT = "timeout",
|
|
595
|
-
UNKNOWN = "unknown"
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Map HTTP status codes to error codes
|
|
599
|
-
*/
|
|
600
|
-
declare function getErrorCodeFromStatus(status: number): ErrorCode;
|
|
601
|
-
/**
|
|
602
|
-
* User-friendly error messages
|
|
603
|
-
*/
|
|
604
|
-
declare const ErrorMessages: Record<ErrorCode, string>;
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Type-safe fetch wrapper for Django REST API
|
|
608
|
-
*/
|
|
609
|
-
|
|
610
|
-
interface FetchWrapperConfig {
|
|
611
|
-
baseUrl?: string;
|
|
612
|
-
getToken?: () => Promise<string | null> | string | null;
|
|
613
|
-
onUnauthorized?: () => void;
|
|
614
|
-
onTokenRefresh?: () => Promise<string | null>;
|
|
615
|
-
defaultHeaders?: HeadersInit;
|
|
616
|
-
}
|
|
617
|
-
declare class FetchWrapper {
|
|
618
|
-
private config;
|
|
619
|
-
private isRefreshing;
|
|
620
|
-
private refreshPromise;
|
|
621
|
-
constructor(config: FetchWrapperConfig);
|
|
622
|
-
/**
|
|
623
|
-
* Build headers with auth token
|
|
624
|
-
*/
|
|
625
|
-
private buildHeaders;
|
|
626
|
-
/**
|
|
627
|
-
* Execute fetch request
|
|
628
|
-
*/
|
|
629
|
-
private execute;
|
|
630
|
-
/**
|
|
631
|
-
* Return a new FetchWrapper with selected config fields overridden.
|
|
632
|
-
*/
|
|
633
|
-
reconfigure(partial: Partial<FetchWrapperConfig>): FetchWrapper;
|
|
634
|
-
/**
|
|
635
|
-
* GET request
|
|
636
|
-
*/
|
|
637
|
-
get<T>(endpoint: string, options?: FetchOptions): Promise<T>;
|
|
638
|
-
/**
|
|
639
|
-
* POST request
|
|
640
|
-
*/
|
|
641
|
-
post<T, D = unknown>(endpoint: string, data?: D, options?: FetchOptions): Promise<T>;
|
|
642
|
-
/**
|
|
643
|
-
* PUT request
|
|
644
|
-
*/
|
|
645
|
-
put<T, D = unknown>(endpoint: string, data?: D, options?: FetchOptions): Promise<T>;
|
|
646
|
-
/**
|
|
647
|
-
* PATCH request
|
|
648
|
-
*/
|
|
649
|
-
patch<T, D = unknown>(endpoint: string, data?: D, options?: FetchOptions): Promise<T>;
|
|
650
|
-
/**
|
|
651
|
-
* DELETE request
|
|
652
|
-
*/
|
|
653
|
-
delete<T>(endpoint: string, options?: FetchOptions): Promise<T>;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Main API client for Django REST API
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
|
-
interface ApiClientConfig {
|
|
661
|
-
baseUrl?: string;
|
|
662
|
-
getToken?: () => Promise<string | null> | string | null;
|
|
663
|
-
onUnauthorized?: () => void;
|
|
664
|
-
onTokenRefresh?: () => Promise<string | null>;
|
|
665
|
-
}
|
|
666
|
-
declare class ApiClient {
|
|
667
|
-
private fetcher;
|
|
668
|
-
readonly baseUrl: string;
|
|
669
|
-
constructor(config: ApiClientConfig);
|
|
670
|
-
/**
|
|
671
|
-
* Get the fetch wrapper instance for direct access
|
|
672
|
-
*/
|
|
673
|
-
get fetch(): FetchWrapper;
|
|
674
|
-
/**
|
|
675
|
-
* Update auth token getter
|
|
676
|
-
*/
|
|
677
|
-
setTokenGetter(getToken: () => Promise<string | null> | string | null): void;
|
|
678
|
-
/**
|
|
679
|
-
* Update unauthorized handler
|
|
680
|
-
*/
|
|
681
|
-
setUnauthorizedHandler(onUnauthorized: () => void): void;
|
|
682
|
-
/**
|
|
683
|
-
* Convenience HTTP methods that delegate to FetchWrapper
|
|
684
|
-
*/
|
|
685
|
-
get<T>(endpoint: string, options?: FetchOptions): Promise<T>;
|
|
686
|
-
post<T, D = unknown>(endpoint: string, data?: D, options?: FetchOptions): Promise<T>;
|
|
687
|
-
patch<T, D = unknown>(endpoint: string, data?: D, options?: FetchOptions): Promise<T>;
|
|
688
|
-
delete<T>(endpoint: string, options?: FetchOptions): Promise<T>;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Create API client instance
|
|
692
|
-
*/
|
|
693
|
-
declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
694
|
-
|
|
695
|
-
/**
|
|
696
|
-
* Contacts API wrapper for /api/v1/contacts/
|
|
697
|
-
*/
|
|
698
|
-
|
|
699
|
-
declare class ContactsApi {
|
|
700
|
-
private client;
|
|
701
|
-
constructor(client: ApiClient);
|
|
702
|
-
/**
|
|
703
|
-
* List contacts with pagination and filters
|
|
704
|
-
*/
|
|
705
|
-
list(filters?: ContactFilters, pagination?: PaginationParams, sorting?: SortParams): Promise<PaginatedResponse<Contact>>;
|
|
706
|
-
/**
|
|
707
|
-
* Get contact by ID
|
|
708
|
-
*/
|
|
709
|
-
get(id: string): Promise<Contact>;
|
|
710
|
-
/**
|
|
711
|
-
* Create new contact
|
|
712
|
-
*/
|
|
713
|
-
create(data: CreateContactRequest): Promise<Contact>;
|
|
714
|
-
/**
|
|
715
|
-
* Update contact
|
|
716
|
-
*/
|
|
717
|
-
update(id: string, data: UpdateContactRequest): Promise<Contact>;
|
|
718
|
-
/**
|
|
719
|
-
* Delete contact
|
|
720
|
-
*/
|
|
721
|
-
delete(id: string): Promise<void>;
|
|
722
|
-
/**
|
|
723
|
-
* Bulk create contacts
|
|
724
|
-
*/
|
|
725
|
-
bulkCreate(data: CreateContactRequest[]): Promise<Contact[]>;
|
|
726
|
-
/**
|
|
727
|
-
* Search contacts by name, email, or company
|
|
728
|
-
*/
|
|
729
|
-
search(query: string, pagination?: PaginationParams): Promise<PaginatedResponse<Contact>>;
|
|
730
|
-
/**
|
|
731
|
-
* Get contacts by tier
|
|
732
|
-
*/
|
|
733
|
-
getByTier(tier: number, pagination?: PaginationParams): Promise<PaginatedResponse<Contact>>;
|
|
734
|
-
/**
|
|
735
|
-
* Get contacts by firm
|
|
736
|
-
*/
|
|
737
|
-
getByFirm(firmId: string, pagination?: PaginationParams): Promise<PaginatedResponse<Contact>>;
|
|
738
|
-
/**
|
|
739
|
-
* Get contacts with LinkedIn profiles
|
|
740
|
-
*/
|
|
741
|
-
getWithLinkedIn(pagination?: PaginationParams): Promise<PaginatedResponse<Contact>>;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Organizations API wrapper for /api/v1/organizations/
|
|
746
|
-
*/
|
|
747
|
-
|
|
748
|
-
declare class OrganizationsApi {
|
|
749
|
-
private client;
|
|
750
|
-
constructor(client: ApiClient);
|
|
751
|
-
/**
|
|
752
|
-
* List organizations with pagination and filters
|
|
753
|
-
*/
|
|
754
|
-
list(filters?: OrganizationFilters, pagination?: PaginationParams, sorting?: SortParams): Promise<PaginatedResponse<Organization>>;
|
|
755
|
-
/**
|
|
756
|
-
* Get organization by ID
|
|
757
|
-
*/
|
|
758
|
-
get(id: string): Promise<Organization>;
|
|
759
|
-
/**
|
|
760
|
-
* Create new organization
|
|
761
|
-
*/
|
|
762
|
-
create(data: CreateOrganizationRequest): Promise<Organization>;
|
|
763
|
-
/**
|
|
764
|
-
* Update organization
|
|
765
|
-
*/
|
|
766
|
-
update(id: string, data: UpdateOrganizationRequest): Promise<Organization>;
|
|
767
|
-
/**
|
|
768
|
-
* Delete organization
|
|
769
|
-
*/
|
|
770
|
-
delete(id: string): Promise<void>;
|
|
771
|
-
/**
|
|
772
|
-
* Bulk create organizations
|
|
773
|
-
*/
|
|
774
|
-
bulkCreate(data: CreateOrganizationRequest[]): Promise<Organization[]>;
|
|
775
|
-
/**
|
|
776
|
-
* Search organizations by name, domain, or location
|
|
777
|
-
*/
|
|
778
|
-
search(query: string, pagination?: PaginationParams): Promise<PaginatedResponse<Organization>>;
|
|
779
|
-
/**
|
|
780
|
-
* Get organizations by tier
|
|
781
|
-
*/
|
|
782
|
-
getByTier(tier: number, pagination?: PaginationParams): Promise<PaginatedResponse<Organization>>;
|
|
783
|
-
/**
|
|
784
|
-
* Get organizations by stage
|
|
785
|
-
*/
|
|
786
|
-
getByStage(stage: string, pagination?: PaginationParams): Promise<PaginatedResponse<Organization>>;
|
|
787
|
-
/**
|
|
788
|
-
* Get organizations by focus area
|
|
789
|
-
*/
|
|
790
|
-
getByFocusArea(focusArea: string, pagination?: PaginationParams): Promise<PaginatedResponse<Organization>>;
|
|
791
|
-
/**
|
|
792
|
-
* Get organizations by check size range
|
|
793
|
-
*/
|
|
794
|
-
getByCheckSizeRange(min?: number, max?: number, pagination?: PaginationParams): Promise<PaginatedResponse<Organization>>;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Core entities API wrapper for /api/v1/core/
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
declare class EntitiesApi {
|
|
802
|
-
private client;
|
|
803
|
-
constructor(client: ApiClient);
|
|
804
|
-
/**
|
|
805
|
-
* Tags
|
|
806
|
-
*/
|
|
807
|
-
listTags(pagination?: PaginationParams): Promise<PaginatedResponse<Tag>>;
|
|
808
|
-
getTag(id: number): Promise<Tag>;
|
|
809
|
-
createTag(data: Partial<Tag>): Promise<Tag>;
|
|
810
|
-
/**
|
|
811
|
-
* Entity Tags
|
|
812
|
-
*/
|
|
813
|
-
listEntityTags(pagination?: PaginationParams, filters?: {
|
|
814
|
-
entityId?: string;
|
|
815
|
-
tagId?: number;
|
|
816
|
-
category?: string;
|
|
817
|
-
}): Promise<PaginatedResponse<EntityTag>>;
|
|
818
|
-
getEntityTag(id: number): Promise<EntityTag>;
|
|
819
|
-
/**
|
|
820
|
-
* Metrics
|
|
821
|
-
*/
|
|
822
|
-
listMetrics(pagination?: PaginationParams, filters?: {
|
|
823
|
-
entityId?: string;
|
|
824
|
-
type?: string;
|
|
825
|
-
subtype?: string;
|
|
826
|
-
}): Promise<PaginatedResponse<Metric>>;
|
|
827
|
-
getMetric(id: number): Promise<Metric>;
|
|
828
|
-
/**
|
|
829
|
-
* Profiles
|
|
830
|
-
*/
|
|
831
|
-
listProfiles(pagination?: PaginationParams, filters?: {
|
|
832
|
-
entityId?: string;
|
|
833
|
-
type?: string;
|
|
834
|
-
subtype?: string;
|
|
835
|
-
}): Promise<PaginatedResponse<Profile>>;
|
|
836
|
-
getProfile(id: number): Promise<Profile>;
|
|
837
|
-
/**
|
|
838
|
-
* Attributes
|
|
839
|
-
*/
|
|
840
|
-
listAttributes(pagination?: PaginationParams, filters?: {
|
|
841
|
-
entityId?: string;
|
|
842
|
-
type?: string;
|
|
843
|
-
subtype?: string;
|
|
844
|
-
isCurrent?: boolean;
|
|
845
|
-
}): Promise<PaginatedResponse<Attribute>>;
|
|
846
|
-
getAttribute(id: number): Promise<Attribute>;
|
|
847
|
-
/**
|
|
848
|
-
* Relationships
|
|
849
|
-
*/
|
|
850
|
-
listRelationships(pagination?: PaginationParams, filters?: {
|
|
851
|
-
fromEntityId?: string;
|
|
852
|
-
toEntityId?: string;
|
|
853
|
-
type?: string;
|
|
854
|
-
isCurrent?: boolean;
|
|
855
|
-
}): Promise<PaginatedResponse<Relationship>>;
|
|
856
|
-
getRelationship(id: number): Promise<Relationship>;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* Workflows API wrapper
|
|
861
|
-
*
|
|
862
|
-
* Provides type-safe access to Django Workflows API
|
|
863
|
-
*/
|
|
864
|
-
|
|
865
|
-
interface Workflow {
|
|
866
|
-
id: string;
|
|
867
|
-
name: string;
|
|
868
|
-
description: string;
|
|
869
|
-
team: string;
|
|
870
|
-
createdBy: string | null;
|
|
871
|
-
nodes: any[];
|
|
872
|
-
connections: Record<string, any>;
|
|
873
|
-
settings: Record<string, any>;
|
|
874
|
-
staticData: Record<string, any>;
|
|
875
|
-
isActive: boolean;
|
|
876
|
-
version: number;
|
|
877
|
-
isTemplate: boolean;
|
|
878
|
-
templateSource: string | null;
|
|
879
|
-
executionsCount: number;
|
|
880
|
-
createdAt: string;
|
|
881
|
-
updatedAt: string;
|
|
882
|
-
}
|
|
883
|
-
interface WorkflowExecution {
|
|
884
|
-
id: string;
|
|
885
|
-
workflow: string;
|
|
886
|
-
workflowVersion: number;
|
|
887
|
-
triggeredBy: string;
|
|
888
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'paused';
|
|
889
|
-
mode: 'manual' | 'trigger' | 'webhook';
|
|
890
|
-
contextData: Record<string, any>;
|
|
891
|
-
state: Record<string, any>;
|
|
892
|
-
startedAt: string | null;
|
|
893
|
-
completedAt: string | null;
|
|
894
|
-
waitUntil: string | null;
|
|
895
|
-
errorMessage: string | null;
|
|
896
|
-
createdAt: string;
|
|
897
|
-
updatedAt: string;
|
|
898
|
-
}
|
|
899
|
-
interface WorkflowFilters {
|
|
900
|
-
team?: string;
|
|
901
|
-
isActive?: boolean;
|
|
902
|
-
isTemplate?: boolean;
|
|
903
|
-
page?: number;
|
|
904
|
-
pageSize?: number;
|
|
905
|
-
ordering?: string;
|
|
906
|
-
}
|
|
907
|
-
interface ExecuteWorkflowInput {
|
|
908
|
-
contextData?: Record<string, any>;
|
|
909
|
-
mode?: 'manual' | 'trigger' | 'webhook';
|
|
910
|
-
}
|
|
911
|
-
interface CreateWorkflowInput {
|
|
912
|
-
name: string;
|
|
913
|
-
description?: string;
|
|
914
|
-
team: string;
|
|
915
|
-
nodes?: any[];
|
|
916
|
-
connections?: Record<string, any>;
|
|
917
|
-
settings?: Record<string, any>;
|
|
918
|
-
isActive?: boolean;
|
|
919
|
-
}
|
|
920
|
-
declare class WorkflowsApi {
|
|
921
|
-
private client;
|
|
922
|
-
constructor(client: ApiClient);
|
|
923
|
-
/**
|
|
924
|
-
* List workflows with optional filters
|
|
925
|
-
*/
|
|
926
|
-
list(filters?: WorkflowFilters): Promise<{
|
|
927
|
-
results: Workflow[];
|
|
928
|
-
count: number;
|
|
929
|
-
next: string | null;
|
|
930
|
-
previous: string | null;
|
|
931
|
-
}>;
|
|
932
|
-
/**
|
|
933
|
-
* Get workflow by ID
|
|
934
|
-
*/
|
|
935
|
-
get(id: string): Promise<Workflow>;
|
|
936
|
-
/**
|
|
937
|
-
* Create a new workflow
|
|
938
|
-
*/
|
|
939
|
-
create(data: CreateWorkflowInput): Promise<Workflow>;
|
|
940
|
-
/**
|
|
941
|
-
* Update workflow
|
|
942
|
-
*/
|
|
943
|
-
update(id: string, data: Partial<CreateWorkflowInput>): Promise<Workflow>;
|
|
944
|
-
/**
|
|
945
|
-
* Delete workflow
|
|
946
|
-
*/
|
|
947
|
-
delete(id: string): Promise<unknown>;
|
|
948
|
-
/**
|
|
949
|
-
* Execute workflow
|
|
950
|
-
*/
|
|
951
|
-
execute(id: string, input?: ExecuteWorkflowInput): Promise<WorkflowExecution>;
|
|
952
|
-
/**
|
|
953
|
-
* Get workflow templates
|
|
954
|
-
*/
|
|
955
|
-
templates(): Promise<Workflow[]>;
|
|
956
|
-
/**
|
|
957
|
-
* List workflow executions
|
|
958
|
-
*/
|
|
959
|
-
listExecutions(filters?: {
|
|
960
|
-
workflow?: string;
|
|
961
|
-
status?: string;
|
|
962
|
-
page?: number;
|
|
963
|
-
pageSize?: number;
|
|
964
|
-
}): Promise<{
|
|
965
|
-
results: WorkflowExecution[];
|
|
966
|
-
count: number;
|
|
967
|
-
}>;
|
|
968
|
-
/**
|
|
969
|
-
* Get workflow execution details
|
|
970
|
-
*/
|
|
971
|
-
getExecution(id: string): Promise<WorkflowExecution>;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
/**
|
|
975
|
-
* Messages API wrapper
|
|
976
|
-
*
|
|
977
|
-
* Provides type-safe access to Django Messages API
|
|
978
|
-
*/
|
|
979
|
-
|
|
980
|
-
type MessageStatus = 'draft' | 'scheduled' | 'sending' | 'sent' | 'failed';
|
|
981
|
-
type MessageContentType = 'text/plain' | 'text/markdown' | 'text/html';
|
|
982
|
-
type RecipientStatus = 'pending' | 'sent' | 'delivered' | 'bounced' | 'opened' | 'clicked';
|
|
983
|
-
interface Message {
|
|
984
|
-
id: string;
|
|
985
|
-
team: string;
|
|
986
|
-
channel: string;
|
|
987
|
-
channelDetails?: {
|
|
988
|
-
key: string;
|
|
989
|
-
name: string;
|
|
990
|
-
description: string;
|
|
991
|
-
icon: string;
|
|
992
|
-
};
|
|
993
|
-
subject: string;
|
|
994
|
-
body: string;
|
|
995
|
-
contentType: MessageContentType;
|
|
996
|
-
fromName: string | null;
|
|
997
|
-
fromEmail: string | null;
|
|
998
|
-
replyTo: string | null;
|
|
999
|
-
status: MessageStatus;
|
|
1000
|
-
scheduledAt: string | null;
|
|
1001
|
-
sentAt: string | null;
|
|
1002
|
-
metadata: Record<string, any>;
|
|
1003
|
-
totalRecipients: number;
|
|
1004
|
-
recipientsSent: number;
|
|
1005
|
-
recipientsDelivered: number;
|
|
1006
|
-
recipientsOpened: number;
|
|
1007
|
-
recipientsClicked: number;
|
|
1008
|
-
recipientsBounced: number;
|
|
1009
|
-
recipientsUnsubscribed: number;
|
|
1010
|
-
openRate: number;
|
|
1011
|
-
clickRate: number;
|
|
1012
|
-
bounceRate: number;
|
|
1013
|
-
errorMessage: string | null;
|
|
1014
|
-
createdAt: string;
|
|
1015
|
-
updatedAt: string;
|
|
1016
|
-
}
|
|
1017
|
-
interface MessageRecipient {
|
|
1018
|
-
id: string;
|
|
1019
|
-
recipientType: string;
|
|
1020
|
-
recipientId: string | null;
|
|
1021
|
-
recipientEmail: string;
|
|
1022
|
-
recipientName: string | null;
|
|
1023
|
-
channelIdentifier: string | null;
|
|
1024
|
-
channelProfiles: Record<string, any>;
|
|
1025
|
-
status: RecipientStatus;
|
|
1026
|
-
sentAt: string | null;
|
|
1027
|
-
deliveredAt: string | null;
|
|
1028
|
-
bouncedAt: string | null;
|
|
1029
|
-
firstOpenedAt: string | null;
|
|
1030
|
-
lastOpenedAt: string | null;
|
|
1031
|
-
firstClickedAt: string | null;
|
|
1032
|
-
lastClickedAt: string | null;
|
|
1033
|
-
openCount: number;
|
|
1034
|
-
clickCount: number;
|
|
1035
|
-
isUnsubscribed: boolean;
|
|
1036
|
-
unsubscribedAt: string | null;
|
|
1037
|
-
errorMessage: string | null;
|
|
1038
|
-
createdAt: string;
|
|
1039
|
-
}
|
|
1040
|
-
interface MessagingChannel {
|
|
1041
|
-
id: string;
|
|
1042
|
-
key: string;
|
|
1043
|
-
name: string;
|
|
1044
|
-
description: string;
|
|
1045
|
-
icon: string;
|
|
1046
|
-
capabilities: {
|
|
1047
|
-
maxContentLength: number;
|
|
1048
|
-
supportsHtml: boolean;
|
|
1049
|
-
supportsMarkdown: boolean;
|
|
1050
|
-
supportsAttachments: boolean;
|
|
1051
|
-
maxAttachments: number;
|
|
1052
|
-
maxAttachmentSize: number;
|
|
1053
|
-
};
|
|
1054
|
-
requirements: {
|
|
1055
|
-
requiresConnection: boolean;
|
|
1056
|
-
requiresOptIn: boolean;
|
|
1057
|
-
authRequirements: Record<string, any>;
|
|
1058
|
-
};
|
|
1059
|
-
rateLimit: {
|
|
1060
|
-
messages: number;
|
|
1061
|
-
seconds: number;
|
|
1062
|
-
scope: string;
|
|
1063
|
-
description: string;
|
|
1064
|
-
};
|
|
1065
|
-
metadata: Record<string, any>;
|
|
1066
|
-
}
|
|
1067
|
-
interface MessageFilters {
|
|
1068
|
-
status?: MessageStatus;
|
|
1069
|
-
contentType?: MessageContentType;
|
|
1070
|
-
scheduledAfter?: string;
|
|
1071
|
-
scheduledBefore?: string;
|
|
1072
|
-
sentAfter?: string;
|
|
1073
|
-
sentBefore?: string;
|
|
1074
|
-
search?: string;
|
|
1075
|
-
page?: number;
|
|
1076
|
-
pageSize?: number;
|
|
1077
|
-
ordering?: string;
|
|
1078
|
-
}
|
|
1079
|
-
interface CreateMessageInput {
|
|
1080
|
-
channel: string;
|
|
1081
|
-
subject: string;
|
|
1082
|
-
body: string;
|
|
1083
|
-
contentType?: MessageContentType;
|
|
1084
|
-
fromName?: string;
|
|
1085
|
-
fromEmail?: string;
|
|
1086
|
-
replyTo?: string;
|
|
1087
|
-
scheduledAt?: string;
|
|
1088
|
-
metadata?: Record<string, any>;
|
|
1089
|
-
recipients?: Array<{
|
|
1090
|
-
recipientType: string;
|
|
1091
|
-
recipientEmail: string;
|
|
1092
|
-
recipientName?: string;
|
|
1093
|
-
channelIdentifier?: string;
|
|
1094
|
-
}>;
|
|
1095
|
-
}
|
|
1096
|
-
interface ScheduleMessageInput {
|
|
1097
|
-
scheduledAt: string;
|
|
1098
|
-
}
|
|
1099
|
-
interface SendTestInput {
|
|
1100
|
-
testEmail?: string;
|
|
1101
|
-
}
|
|
1102
|
-
declare class MessagesApi {
|
|
1103
|
-
private client;
|
|
1104
|
-
constructor(client: ApiClient);
|
|
1105
|
-
/**
|
|
1106
|
-
* List messages with optional filters
|
|
1107
|
-
*/
|
|
1108
|
-
list(filters?: MessageFilters): Promise<{
|
|
1109
|
-
results: Message[];
|
|
1110
|
-
count: number;
|
|
1111
|
-
next: string | null;
|
|
1112
|
-
previous: string | null;
|
|
1113
|
-
}>;
|
|
1114
|
-
/**
|
|
1115
|
-
* Get message by ID
|
|
1116
|
-
*/
|
|
1117
|
-
get(id: string): Promise<Message>;
|
|
1118
|
-
/**
|
|
1119
|
-
* Create a new message
|
|
1120
|
-
*/
|
|
1121
|
-
create(data: CreateMessageInput): Promise<Message>;
|
|
1122
|
-
/**
|
|
1123
|
-
* Update message (draft only)
|
|
1124
|
-
*/
|
|
1125
|
-
update(id: string, data: Partial<CreateMessageInput>): Promise<Message>;
|
|
1126
|
-
/**
|
|
1127
|
-
* Delete message (draft only)
|
|
1128
|
-
*/
|
|
1129
|
-
delete(id: string): Promise<unknown>;
|
|
1130
|
-
/**
|
|
1131
|
-
* Schedule message for future sending
|
|
1132
|
-
*/
|
|
1133
|
-
schedule(id: string, input: ScheduleMessageInput): Promise<{
|
|
1134
|
-
id: string;
|
|
1135
|
-
status: MessageStatus;
|
|
1136
|
-
scheduledAt: string;
|
|
1137
|
-
message: string;
|
|
1138
|
-
}>;
|
|
1139
|
-
/**
|
|
1140
|
-
* Send message immediately
|
|
1141
|
-
*/
|
|
1142
|
-
sendNow(id: string): Promise<{
|
|
1143
|
-
id: string;
|
|
1144
|
-
status: MessageStatus;
|
|
1145
|
-
message: string;
|
|
1146
|
-
}>;
|
|
1147
|
-
/**
|
|
1148
|
-
* Send test message
|
|
1149
|
-
*/
|
|
1150
|
-
sendTest(id: string, input?: SendTestInput): Promise<{
|
|
1151
|
-
id: string;
|
|
1152
|
-
testEmail: string;
|
|
1153
|
-
message: string;
|
|
1154
|
-
}>;
|
|
1155
|
-
/**
|
|
1156
|
-
* Preview message rendering
|
|
1157
|
-
*/
|
|
1158
|
-
preview(id: string): Promise<{
|
|
1159
|
-
subject: string;
|
|
1160
|
-
body: string;
|
|
1161
|
-
previewHtml: string;
|
|
1162
|
-
fromName: string;
|
|
1163
|
-
fromEmail: string;
|
|
1164
|
-
}>;
|
|
1165
|
-
/**
|
|
1166
|
-
* List recipients for a message
|
|
1167
|
-
*/
|
|
1168
|
-
getRecipients(id: string, page?: number, pageSize?: number): Promise<{
|
|
1169
|
-
results: MessageRecipient[];
|
|
1170
|
-
count: number;
|
|
1171
|
-
}>;
|
|
1172
|
-
/**
|
|
1173
|
-
* Add recipients to a message
|
|
1174
|
-
*/
|
|
1175
|
-
addRecipients(id: string, recipients: Array<{
|
|
1176
|
-
recipientType: string;
|
|
1177
|
-
recipientEmail: string;
|
|
1178
|
-
recipientName?: string;
|
|
1179
|
-
channelIdentifier?: string;
|
|
1180
|
-
}>): Promise<{
|
|
1181
|
-
message: string;
|
|
1182
|
-
totalRecipients: number;
|
|
1183
|
-
recipients: MessageRecipient[];
|
|
1184
|
-
}>;
|
|
1185
|
-
/**
|
|
1186
|
-
* Get available messaging channels
|
|
1187
|
-
*/
|
|
1188
|
-
getChannels(): Promise<{
|
|
1189
|
-
channels: MessagingChannel[];
|
|
1190
|
-
count: number;
|
|
1191
|
-
}>;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Funnels API wrapper for /api/v1/funnels/
|
|
1196
|
-
*/
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Returns true when the error is a 409 Conflict from trying to run a funnel that's already running.
|
|
1200
|
-
*/
|
|
1201
|
-
declare function isFunnelRunConflict(error: unknown): boolean;
|
|
1202
|
-
/**
|
|
1203
|
-
* Returns true when the error is a 400 with validation errors (bad stage rules, missing entityType, etc.)
|
|
1204
|
-
*/
|
|
1205
|
-
declare function isFunnelValidationError(error: unknown): boolean;
|
|
1206
|
-
interface FunnelPreviewResult {
|
|
1207
|
-
total: number;
|
|
1208
|
-
matched: number;
|
|
1209
|
-
stages: Array<{
|
|
1210
|
-
stageId: string;
|
|
1211
|
-
stageName: string;
|
|
1212
|
-
inputCount: number;
|
|
1213
|
-
outputCount: number;
|
|
1214
|
-
excluded: number;
|
|
1215
|
-
}>;
|
|
1216
|
-
}
|
|
1217
|
-
interface FunnelRunFilters {
|
|
1218
|
-
page?: number;
|
|
1219
|
-
pageSize?: number;
|
|
1220
|
-
status?: FunnelRun['status'];
|
|
1221
|
-
ordering?: string;
|
|
1222
|
-
funnel?: string;
|
|
1223
|
-
startedAfter?: string;
|
|
1224
|
-
startedBefore?: string;
|
|
1225
|
-
}
|
|
1226
|
-
interface FunnelTemplate {
|
|
1227
|
-
id: string;
|
|
1228
|
-
slug: string;
|
|
1229
|
-
name: string;
|
|
1230
|
-
description: string;
|
|
1231
|
-
category: string;
|
|
1232
|
-
icon: string;
|
|
1233
|
-
isFeatured: boolean;
|
|
1234
|
-
stageCount: number;
|
|
1235
|
-
usageCount: number;
|
|
1236
|
-
}
|
|
1237
|
-
declare class FunnelsApi {
|
|
1238
|
-
private client;
|
|
1239
|
-
constructor(client: ApiClient);
|
|
1240
|
-
/**
|
|
1241
|
-
* List funnels with optional filters.
|
|
1242
|
-
* Tags are passed as repeated query params: ?tags=campaign:abc&tags=product:market-simpli
|
|
1243
|
-
*/
|
|
1244
|
-
list(filters?: FunnelFilters): Promise<PaginatedResponse<Funnel>>;
|
|
1245
|
-
/**
|
|
1246
|
-
* Get funnel by ID
|
|
1247
|
-
*/
|
|
1248
|
-
get(id: string): Promise<Funnel>;
|
|
1249
|
-
/**
|
|
1250
|
-
* Create a new funnel
|
|
1251
|
-
*/
|
|
1252
|
-
create(data: CreateFunnelInput): Promise<Funnel>;
|
|
1253
|
-
/**
|
|
1254
|
-
* Update funnel (partial)
|
|
1255
|
-
*/
|
|
1256
|
-
update(id: string, data: UpdateFunnelInput): Promise<Funnel>;
|
|
1257
|
-
/**
|
|
1258
|
-
* Delete funnel
|
|
1259
|
-
*/
|
|
1260
|
-
delete(id: string): Promise<void>;
|
|
1261
|
-
/**
|
|
1262
|
-
* Execute a funnel run
|
|
1263
|
-
*/
|
|
1264
|
-
run(id: string, input?: ExecuteFunnelInput): Promise<FunnelRun>;
|
|
1265
|
-
/**
|
|
1266
|
-
* List run history for a funnel
|
|
1267
|
-
*/
|
|
1268
|
-
getRuns(funnelId: string, filters?: FunnelRunFilters): Promise<PaginatedResponse<FunnelRun>>;
|
|
1269
|
-
/**
|
|
1270
|
-
* Get a specific run by ID. funnelId param is ignored (runs are accessed globally).
|
|
1271
|
-
*/
|
|
1272
|
-
getRun(_funnelId: string, runId: string): Promise<FunnelRun>;
|
|
1273
|
-
getResults(_funnelId: string, _pagination?: PaginationParams): Promise<PaginatedResponse<FunnelResult>>;
|
|
1274
|
-
preview(_funnelId: string, _stages?: Funnel['stages']): Promise<FunnelPreviewResult>;
|
|
1275
|
-
/**
|
|
1276
|
-
* List all funnel runs globally (across all funnels, scoped to current user)
|
|
1277
|
-
*/
|
|
1278
|
-
listRunsGlobal(filters?: FunnelRunFilters): Promise<PaginatedResponse<FunnelRun>>;
|
|
1279
|
-
/**
|
|
1280
|
-
* Cancel a running funnel run.
|
|
1281
|
-
*/
|
|
1282
|
-
cancelRun(runId: string): Promise<FunnelRun>;
|
|
1283
|
-
/**
|
|
1284
|
-
* List available funnel templates
|
|
1285
|
-
*/
|
|
1286
|
-
listTemplates(filters?: {
|
|
1287
|
-
category?: string;
|
|
1288
|
-
page?: number;
|
|
1289
|
-
pageSize?: number;
|
|
1290
|
-
}): Promise<PaginatedResponse<FunnelTemplate>>;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
* API error handling and normalization
|
|
1295
|
-
*/
|
|
1296
|
-
|
|
1297
|
-
declare class ApiException extends Error {
|
|
1298
|
-
status?: number;
|
|
1299
|
-
statusText?: string;
|
|
1300
|
-
errors?: Record<string, string[]>;
|
|
1301
|
-
detail?: string;
|
|
1302
|
-
constructor(message: string, options?: Partial<ApiError$1>);
|
|
1303
|
-
toJSON(): ApiError$1;
|
|
1304
|
-
}
|
|
1305
|
-
/**
|
|
1306
|
-
* Parse Django REST Framework error response
|
|
1307
|
-
*/
|
|
1308
|
-
declare function parseErrorResponse(response: Response): Promise<ApiError$1>;
|
|
1309
|
-
/**
|
|
1310
|
-
* Handle fetch errors
|
|
1311
|
-
*/
|
|
1312
|
-
declare function handleFetchError(error: unknown): never;
|
|
1313
|
-
/**
|
|
1314
|
-
* Check if error is an API exception
|
|
1315
|
-
*/
|
|
1316
|
-
declare function isApiException(error: unknown): error is ApiException;
|
|
1317
|
-
/**
|
|
1318
|
-
* Check if error is a validation error
|
|
1319
|
-
*/
|
|
1320
|
-
declare function isValidationError(error: unknown): error is ApiException;
|
|
1321
|
-
/**
|
|
1322
|
-
* Check if error is an auth error
|
|
1323
|
-
*/
|
|
1324
|
-
declare function isAuthError(error: unknown): error is ApiException;
|
|
1325
|
-
/**
|
|
1326
|
-
* Check if error is a not found error
|
|
1327
|
-
*/
|
|
1328
|
-
declare function isNotFoundError(error: unknown): error is ApiException;
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* AppError hierarchy for StartSimpli apps
|
|
1332
|
-
*
|
|
1333
|
-
* Provides a standardized error hierarchy with:
|
|
1334
|
-
* - Consistent error codes and messages
|
|
1335
|
-
* - HTTP status code mapping
|
|
1336
|
-
* - Serialization for API responses
|
|
1337
|
-
*
|
|
1338
|
-
* These are server-side application errors (not API client fetch errors).
|
|
1339
|
-
* For API client errors see ./error-handler.ts (ApiException).
|
|
1340
|
-
*/
|
|
1341
|
-
/**
|
|
1342
|
-
* Standard error codes used across the application
|
|
1343
|
-
*/
|
|
1344
|
-
declare enum AppErrorCode {
|
|
1345
|
-
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
1346
|
-
AUTHENTICATION_REQUIRED = "AUTHENTICATION_REQUIRED",
|
|
1347
|
-
INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
|
|
1348
|
-
SESSION_EXPIRED = "SESSION_EXPIRED",
|
|
1349
|
-
FORBIDDEN = "FORBIDDEN",
|
|
1350
|
-
INSUFFICIENT_PERMISSIONS = "INSUFFICIENT_PERMISSIONS",
|
|
1351
|
-
NOT_FOUND = "NOT_FOUND",
|
|
1352
|
-
RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
|
|
1353
|
-
CONFLICT = "CONFLICT",
|
|
1354
|
-
DUPLICATE_RESOURCE = "DUPLICATE_RESOURCE",
|
|
1355
|
-
RATE_LIMITED = "RATE_LIMITED",
|
|
1356
|
-
BAD_REQUEST = "BAD_REQUEST",
|
|
1357
|
-
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
1358
|
-
DATABASE_ERROR = "DATABASE_ERROR",
|
|
1359
|
-
EXTERNAL_SERVICE_ERROR = "EXTERNAL_SERVICE_ERROR",
|
|
1360
|
-
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* Shape of the error envelope returned from AppError.toResponse()
|
|
1364
|
-
*/
|
|
1365
|
-
interface AppErrorResponse {
|
|
1366
|
-
error: {
|
|
1367
|
-
code: AppErrorCode;
|
|
1368
|
-
message: string;
|
|
1369
|
-
details?: Record<string, unknown>;
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
/**
|
|
1373
|
-
* Base application error class.
|
|
1374
|
-
* All custom errors should extend this class.
|
|
1375
|
-
*/
|
|
1376
|
-
declare class AppError extends Error {
|
|
1377
|
-
readonly code: AppErrorCode;
|
|
1378
|
-
readonly statusCode: number;
|
|
1379
|
-
readonly details?: Record<string, unknown>;
|
|
1380
|
-
readonly isOperational: boolean;
|
|
1381
|
-
constructor(message: string, code?: AppErrorCode, statusCode?: number, details?: Record<string, unknown>, isOperational?: boolean);
|
|
1382
|
-
/**
|
|
1383
|
-
* Serialize error for API response
|
|
1384
|
-
*/
|
|
1385
|
-
toResponse(): AppErrorResponse;
|
|
1386
|
-
/**
|
|
1387
|
-
* Check if an error is an operational error (expected) vs programming error
|
|
1388
|
-
*/
|
|
1389
|
-
static isOperationalError(error: unknown): error is AppError;
|
|
1390
|
-
}
|
|
1391
|
-
/**
|
|
1392
|
-
* Validation error for invalid request data
|
|
1393
|
-
* HTTP 400 Bad Request
|
|
1394
|
-
*/
|
|
1395
|
-
declare class ValidationError extends AppError {
|
|
1396
|
-
readonly fieldErrors: Record<string, string[]>;
|
|
1397
|
-
constructor(message?: string, fieldErrors?: Record<string, string[]>);
|
|
1398
|
-
/**
|
|
1399
|
-
* Create from Zod error
|
|
1400
|
-
*/
|
|
1401
|
-
static fromZodError(zodError: {
|
|
1402
|
-
errors: Array<{
|
|
1403
|
-
path: (string | number)[];
|
|
1404
|
-
message: string;
|
|
1405
|
-
}>;
|
|
1406
|
-
}): ValidationError;
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Authentication error for unauthenticated requests
|
|
1410
|
-
* HTTP 401 Unauthorized
|
|
1411
|
-
*/
|
|
1412
|
-
declare class AuthenticationError extends AppError {
|
|
1413
|
-
constructor(message?: string, code?: AppErrorCode);
|
|
1414
|
-
/**
|
|
1415
|
-
* Create for invalid credentials
|
|
1416
|
-
*/
|
|
1417
|
-
static invalidCredentials(): AuthenticationError;
|
|
1418
|
-
/**
|
|
1419
|
-
* Create for expired session
|
|
1420
|
-
*/
|
|
1421
|
-
static sessionExpired(): AuthenticationError;
|
|
1422
|
-
}
|
|
1423
|
-
/**
|
|
1424
|
-
* Authorization error for forbidden access
|
|
1425
|
-
* HTTP 403 Forbidden
|
|
1426
|
-
*/
|
|
1427
|
-
declare class AuthorizationError extends AppError {
|
|
1428
|
-
constructor(message?: string, code?: AppErrorCode);
|
|
1429
|
-
/**
|
|
1430
|
-
* Create for insufficient permissions
|
|
1431
|
-
*/
|
|
1432
|
-
static insufficientPermissions(requiredPermission?: string): AuthorizationError;
|
|
1433
|
-
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Not found error for missing resources
|
|
1436
|
-
* HTTP 404 Not Found
|
|
1437
|
-
*/
|
|
1438
|
-
declare class NotFoundError extends AppError {
|
|
1439
|
-
readonly resourceType?: string;
|
|
1440
|
-
readonly resourceId?: string;
|
|
1441
|
-
constructor(message?: string, resourceType?: string, resourceId?: string);
|
|
1442
|
-
/**
|
|
1443
|
-
* Create for a specific resource
|
|
1444
|
-
*/
|
|
1445
|
-
static forResource(resourceType: string, resourceId?: string): NotFoundError;
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* Conflict error for duplicate or conflicting resources
|
|
1449
|
-
* HTTP 409 Conflict
|
|
1450
|
-
*/
|
|
1451
|
-
declare class ConflictError extends AppError {
|
|
1452
|
-
readonly conflictingField?: string;
|
|
1453
|
-
constructor(message?: string, conflictingField?: string);
|
|
1454
|
-
/**
|
|
1455
|
-
* Create for duplicate resource
|
|
1456
|
-
*/
|
|
1457
|
-
static duplicate(resourceType: string, field?: string): ConflictError;
|
|
1458
|
-
}
|
|
1459
|
-
/**
|
|
1460
|
-
* Rate limit error for too many requests
|
|
1461
|
-
* HTTP 429 Too Many Requests
|
|
1462
|
-
*/
|
|
1463
|
-
declare class RateLimitError extends AppError {
|
|
1464
|
-
readonly retryAfter?: number;
|
|
1465
|
-
constructor(message?: string, retryAfter?: number);
|
|
1466
|
-
}
|
|
1467
|
-
/**
|
|
1468
|
-
* Database error for database-related failures
|
|
1469
|
-
* HTTP 500 Internal Server Error
|
|
1470
|
-
*/
|
|
1471
|
-
declare class DatabaseError extends AppError {
|
|
1472
|
-
constructor(message?: string, details?: Record<string, unknown>);
|
|
1473
|
-
/**
|
|
1474
|
-
* Create from Prisma error
|
|
1475
|
-
*/
|
|
1476
|
-
static fromPrismaError(error: {
|
|
1477
|
-
code?: string;
|
|
1478
|
-
meta?: Record<string, unknown>;
|
|
1479
|
-
}): DatabaseError;
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* External service error for third-party API failures
|
|
1483
|
-
* HTTP 502 Bad Gateway
|
|
1484
|
-
*/
|
|
1485
|
-
declare class ExternalServiceError extends AppError {
|
|
1486
|
-
readonly serviceName: string;
|
|
1487
|
-
constructor(serviceName: string, message?: string, details?: Record<string, unknown>);
|
|
1488
|
-
}
|
|
1489
|
-
/**
|
|
1490
|
-
* Type guard to check if an error has a code property (like Prisma errors)
|
|
1491
|
-
*/
|
|
1492
|
-
declare function isPrismaError(error: unknown): error is {
|
|
1493
|
-
code: string;
|
|
1494
|
-
meta?: Record<string, unknown>;
|
|
1495
|
-
};
|
|
1496
|
-
/**
|
|
1497
|
-
* Convert any error to an AppError.
|
|
1498
|
-
* Useful for catch blocks to ensure consistent error handling.
|
|
1499
|
-
*/
|
|
1500
|
-
declare function toAppError(error: unknown): AppError;
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* XSS Protection - sanitize HTML content
|
|
1504
|
-
*
|
|
1505
|
-
* Strips all tags except a safe allowlist and removes dangerous attributes.
|
|
1506
|
-
*/
|
|
1507
|
-
declare function sanitizeHtml(input: string): string;
|
|
1508
|
-
/**
|
|
1509
|
-
* Validate and sanitize a search query string.
|
|
1510
|
-
*
|
|
1511
|
-
* Trims whitespace, escapes regex special characters, and limits length to 100 chars.
|
|
1512
|
-
*/
|
|
1513
|
-
declare function sanitizeSearchQuery(query: string): string;
|
|
1514
|
-
/**
|
|
1515
|
-
* Validate that a string is a safe SQL/API identifier.
|
|
1516
|
-
*
|
|
1517
|
-
* Only allows alphanumeric characters, underscores, and hyphens.
|
|
1518
|
-
*/
|
|
1519
|
-
declare function validateIdentifier(input: string): boolean;
|
|
1520
|
-
|
|
1521
|
-
/**
|
|
1522
|
-
* Input Sanitization for LLM Prompts
|
|
1523
|
-
*
|
|
1524
|
-
* Provides protection against prompt injection attacks by sanitizing
|
|
1525
|
-
* user input before including it in LLM prompts.
|
|
1526
|
-
*/
|
|
1527
|
-
/**
|
|
1528
|
-
* Maximum allowed length for user prompts (characters)
|
|
1529
|
-
*/
|
|
1530
|
-
declare const MAX_PROMPT_LENGTH = 2000;
|
|
1531
|
-
/**
|
|
1532
|
-
* Maximum allowed length for chat messages (characters)
|
|
1533
|
-
*/
|
|
1534
|
-
declare const MAX_CHAT_MESSAGE_LENGTH = 1000;
|
|
1535
|
-
/**
|
|
1536
|
-
* Sanitize user input for inclusion in LLM prompts
|
|
1537
|
-
*
|
|
1538
|
-
* @param input - Raw user input
|
|
1539
|
-
* @param maxLength - Maximum allowed length (defaults to MAX_PROMPT_LENGTH)
|
|
1540
|
-
* @returns Sanitized input safe for prompt inclusion
|
|
1541
|
-
*/
|
|
1542
|
-
declare function sanitizeUserInput(input: string, maxLength?: number): string;
|
|
1543
|
-
/**
|
|
1544
|
-
* Sanitize chat message input (shorter limit, same rules)
|
|
1545
|
-
*/
|
|
1546
|
-
declare function sanitizeChatMessage(input: string): string;
|
|
1547
|
-
|
|
1548
|
-
/**
|
|
1549
|
-
* CORS utilities for Next.js API routes
|
|
1550
|
-
*
|
|
1551
|
-
* Framework-agnostic header generation with an optional Next.js
|
|
1552
|
-
* middleware wrapper for apps that need it.
|
|
1553
|
-
*/
|
|
1554
|
-
interface CorsOptions {
|
|
1555
|
-
/** Allowed origins. Use '*' for wildcard. */
|
|
1556
|
-
origins: string[] | '*';
|
|
1557
|
-
/** Allowed HTTP methods. Defaults to common REST methods. */
|
|
1558
|
-
methods?: string[];
|
|
1559
|
-
/** Allowed request headers. Defaults to common headers. */
|
|
1560
|
-
headers?: string[];
|
|
1561
|
-
/** Whether to allow credentials. Defaults to true when origins is a list. */
|
|
1562
|
-
credentials?: boolean;
|
|
1563
|
-
/** Preflight cache duration in seconds. Defaults to 86400 (24h). */
|
|
1564
|
-
maxAge?: number;
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Build the CORS headers for a given request origin.
|
|
1568
|
-
*
|
|
1569
|
-
* Returns an empty object when the origin is not permitted so callers
|
|
1570
|
-
* can decide whether to reject or silently omit the headers.
|
|
1571
|
-
*/
|
|
1572
|
-
declare function getCorsHeaders(origin: string | null | undefined, options: CorsOptions): Record<string, string>;
|
|
1573
|
-
/**
|
|
1574
|
-
* Apply CORS headers to an existing Headers object in-place.
|
|
1575
|
-
*/
|
|
1576
|
-
declare function applyCorsHeaders(responseHeaders: Headers, origin: string | null | undefined, options: CorsOptions): void;
|
|
1577
|
-
/**
|
|
1578
|
-
* Create a CORS middleware function for use in Next.js middleware.ts files.
|
|
1579
|
-
*
|
|
1580
|
-
* Returns a function that accepts a Request and returns a Response (for
|
|
1581
|
-
* preflight OPTIONS) or null (for all other requests, letting the chain
|
|
1582
|
-
* continue after headers are applied via getCorsHeaders).
|
|
1583
|
-
*
|
|
1584
|
-
* Usage in middleware.ts:
|
|
1585
|
-
*
|
|
1586
|
-
* ```ts
|
|
1587
|
-
* import { createCorsMiddleware } from '@startsimpli/api';
|
|
1588
|
-
* import { NextResponse } from 'next/server';
|
|
1589
|
-
*
|
|
1590
|
-
* const corsMiddleware = createCorsMiddleware({
|
|
1591
|
-
* origins: [process.env.NEXT_PUBLIC_BASE_URL ?? 'http://localhost:3000'],
|
|
1592
|
-
* });
|
|
1593
|
-
*
|
|
1594
|
-
* export function middleware(request: Request) {
|
|
1595
|
-
* const preflightResponse = corsMiddleware(request);
|
|
1596
|
-
* if (preflightResponse) return preflightResponse;
|
|
1597
|
-
*
|
|
1598
|
-
* const response = NextResponse.next();
|
|
1599
|
-
* const origin = request.headers.get('origin');
|
|
1600
|
-
* applyCorsHeaders(response.headers, origin, corsOptions);
|
|
1601
|
-
* return response;
|
|
1602
|
-
* }
|
|
1603
|
-
* ```
|
|
1604
|
-
*/
|
|
1605
|
-
declare function createCorsMiddleware(options: CorsOptions): (request: Request) => Response | null;
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
* In-memory rate limiter for Next.js API routes.
|
|
1609
|
-
*
|
|
1610
|
-
* Fixed-window counter with periodic cleanup.
|
|
1611
|
-
* Resets on server restart and does not share state across multiple instances.
|
|
1612
|
-
* For multi-instance production use, back the store with Redis/Upstash instead.
|
|
1613
|
-
*/
|
|
1614
|
-
interface RateLimitOptions {
|
|
1615
|
-
/** Duration of the rate limit window in milliseconds */
|
|
1616
|
-
windowMs: number;
|
|
1617
|
-
/** Maximum number of requests allowed per window */
|
|
1618
|
-
maxRequests: number;
|
|
1619
|
-
/** Optional prefix for keys (useful when sharing a single limiter across routes) */
|
|
1620
|
-
keyPrefix?: string;
|
|
1621
|
-
}
|
|
1622
|
-
interface RateLimitResult {
|
|
1623
|
-
/** Whether the request is within the allowed limit */
|
|
1624
|
-
success: boolean;
|
|
1625
|
-
/** Requests remaining in the current window */
|
|
1626
|
-
remaining: number;
|
|
1627
|
-
/** Timestamp (ms since epoch) when the current window resets */
|
|
1628
|
-
resetAt: number;
|
|
1629
|
-
/** Seconds to wait before retrying, present only when success is false */
|
|
1630
|
-
retryAfter?: number;
|
|
1631
|
-
}
|
|
1632
|
-
/**
|
|
1633
|
-
* Factory that returns a rate-check function backed by an isolated in-memory store.
|
|
1634
|
-
*
|
|
1635
|
-
* @example
|
|
1636
|
-
* const check = createRateLimiter({ windowMs: 60_000, maxRequests: 10 });
|
|
1637
|
-
* const result = check('user:123');
|
|
1638
|
-
* if (!result.success) { // respond 429 }
|
|
1639
|
-
*/
|
|
1640
|
-
declare function createRateLimiter(options: RateLimitOptions): (key: string) => RateLimitResult;
|
|
1641
|
-
/**
|
|
1642
|
-
* Extract the client IP address from a Web API Request or NextRequest.
|
|
1643
|
-
* Respects x-forwarded-for and x-real-ip proxy headers.
|
|
1644
|
-
*/
|
|
1645
|
-
declare function getClientIP(request: Request): string;
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* In-memory LRU cache store with TTL expiry.
|
|
1649
|
-
*
|
|
1650
|
-
* A minimal, zero-dependency cache for server-side caching in Next.js apps.
|
|
1651
|
-
* State is in-memory and resets on server restart — not suitable for
|
|
1652
|
-
* multi-instance production deployments without a shared backend (e.g. Redis).
|
|
1653
|
-
*/
|
|
1654
|
-
interface CacheStoreConfig {
|
|
1655
|
-
/** Maximum number of entries before LRU eviction (default: 1000) */
|
|
1656
|
-
maxSize: number;
|
|
1657
|
-
/** Default TTL in milliseconds (default: 60 seconds) */
|
|
1658
|
-
defaultTTL: number;
|
|
1659
|
-
}
|
|
1660
|
-
declare class CacheStore<T = unknown> {
|
|
1661
|
-
private cache;
|
|
1662
|
-
private config;
|
|
1663
|
-
private hits;
|
|
1664
|
-
private misses;
|
|
1665
|
-
private accessCounter;
|
|
1666
|
-
constructor(config?: Partial<CacheStoreConfig>);
|
|
1667
|
-
get(key: string): T | undefined;
|
|
1668
|
-
set(key: string, value: T, ttl?: number): void;
|
|
1669
|
-
has(key: string): boolean;
|
|
1670
|
-
delete(key: string): boolean;
|
|
1671
|
-
/** Delete all keys matching a string prefix or RegExp pattern */
|
|
1672
|
-
deletePattern(pattern: string | RegExp): number;
|
|
1673
|
-
clear(): void;
|
|
1674
|
-
/** Remove expired entries and return count removed */
|
|
1675
|
-
cleanup(): number;
|
|
1676
|
-
getStats(): {
|
|
1677
|
-
size: number;
|
|
1678
|
-
maxSize: number;
|
|
1679
|
-
hits: number;
|
|
1680
|
-
misses: number;
|
|
1681
|
-
hitRate: number;
|
|
1682
|
-
};
|
|
1683
|
-
private evictLRU;
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Cache manager built on top of CacheStore.
|
|
1688
|
-
*
|
|
1689
|
-
* Provides a cache-aside pattern (getOrSet), pattern-based invalidation,
|
|
1690
|
-
* and separate entity/query stores — ready for use in Next.js API routes
|
|
1691
|
-
* and server-side data fetching.
|
|
1692
|
-
*/
|
|
1693
|
-
|
|
1694
|
-
interface CacheManagerConfig {
|
|
1695
|
-
entity?: Partial<CacheStoreConfig>;
|
|
1696
|
-
query?: Partial<CacheStoreConfig>;
|
|
1697
|
-
}
|
|
1698
|
-
declare class CacheManager {
|
|
1699
|
-
readonly entity: CacheStore;
|
|
1700
|
-
readonly query: CacheStore;
|
|
1701
|
-
private enabled;
|
|
1702
|
-
constructor(enabled?: boolean, config?: CacheManagerConfig);
|
|
1703
|
-
/**
|
|
1704
|
-
* Cache-aside: return the cached value if present, otherwise call fetchFn,
|
|
1705
|
-
* store the result, and return it.
|
|
1706
|
-
*/
|
|
1707
|
-
getOrSet<T>(key: string, ttlMs: number, fetchFn: () => Promise<T>): Promise<T>;
|
|
1708
|
-
/** Invalidate a specific key in the query cache */
|
|
1709
|
-
invalidateKey(key: string): void;
|
|
1710
|
-
/** Invalidate all query cache keys matching a string prefix or RegExp */
|
|
1711
|
-
invalidatePattern(pattern: string | RegExp): void;
|
|
1712
|
-
/** Invalidate all entity and query cache entries for the given prefix */
|
|
1713
|
-
invalidateAll(prefix: string): void;
|
|
1714
|
-
setEnabled(enabled: boolean): void;
|
|
1715
|
-
isEnabled(): boolean;
|
|
1716
|
-
/** Remove expired entries from both stores */
|
|
1717
|
-
maintenance(): {
|
|
1718
|
-
entityRemoved: number;
|
|
1719
|
-
queryRemoved: number;
|
|
1720
|
-
};
|
|
1721
|
-
clear(): void;
|
|
1722
|
-
getStats(): {
|
|
1723
|
-
entity: ReturnType<CacheStore['getStats']>;
|
|
1724
|
-
query: ReturnType<CacheStore['getStats']>;
|
|
1725
|
-
};
|
|
1726
|
-
}
|
|
1727
|
-
declare function getCacheManager(config?: CacheManagerConfig): CacheManager;
|
|
1728
|
-
declare function resetCacheManager(): void;
|
|
1729
|
-
|
|
1730
|
-
/**
|
|
1731
|
-
* URL construction utilities for Django REST API
|
|
1732
|
-
*/
|
|
1733
|
-
interface UrlBuilderOptions {
|
|
1734
|
-
baseUrl: string;
|
|
1735
|
-
endpoint: string;
|
|
1736
|
-
params?: Record<string, unknown>;
|
|
1737
|
-
id?: string | number;
|
|
1738
|
-
}
|
|
1739
|
-
/**
|
|
1740
|
-
* Build API URL with query parameters
|
|
1741
|
-
*/
|
|
1742
|
-
declare function buildUrl({ baseUrl, endpoint, params, id }: UrlBuilderOptions): string;
|
|
1743
|
-
/**
|
|
1744
|
-
* Build query string from params object
|
|
1745
|
-
*/
|
|
1746
|
-
declare function buildQueryString(params: Record<string, unknown>): string;
|
|
1747
|
-
/**
|
|
1748
|
-
* Resolve a full or partial API path to a final URL.
|
|
1749
|
-
*
|
|
1750
|
-
* Handles four cases:
|
|
1751
|
-
* - Absolute input URL → returned unchanged
|
|
1752
|
-
* - Absolute baseUrl → joined via URL constructor
|
|
1753
|
-
* - Relative baseUrl → string concatenation
|
|
1754
|
-
* - Empty / undefined baseUrl → path returned as-is (suits Next.js proxy pattern)
|
|
1755
|
-
*/
|
|
1756
|
-
declare function resolveApiUrl(path: string, baseUrl?: string): string;
|
|
1757
|
-
/**
|
|
1758
|
-
* Extract ID from URL or return as-is
|
|
1759
|
-
*/
|
|
1760
|
-
declare function normalizeId(id: string | number): string | number;
|
|
1761
|
-
|
|
1762
|
-
/**
|
|
1763
|
-
* Django query parameter helpers
|
|
1764
|
-
*/
|
|
1765
|
-
|
|
1766
|
-
interface DjangoFilterParams extends PaginationParams, SortParams {
|
|
1767
|
-
search?: string;
|
|
1768
|
-
[key: string]: unknown;
|
|
1769
|
-
}
|
|
1770
|
-
/**
|
|
1771
|
-
* Build Django filter params from filters object
|
|
1772
|
-
*/
|
|
1773
|
-
declare function buildFilterParams<T extends Record<string, unknown>>(filters: T): Record<string, unknown>;
|
|
1774
|
-
/**
|
|
1775
|
-
* Build Django ordering param from sort config
|
|
1776
|
-
*/
|
|
1777
|
-
declare function buildOrderingParam(field?: string, direction?: 'asc' | 'desc'): string | undefined;
|
|
1778
|
-
/**
|
|
1779
|
-
* Merge pagination, sorting, and filter params
|
|
1780
|
-
*/
|
|
1781
|
-
declare function mergeQueryParams(pagination?: PaginationParams, sorting?: SortParams, filters?: Record<string, unknown>): Record<string, unknown>;
|
|
1782
|
-
|
|
1783
|
-
/**
|
|
1784
|
-
* Runtime API response validation
|
|
1785
|
-
*
|
|
1786
|
-
* Validates responses against Zod schemas but NEVER throws.
|
|
1787
|
-
* On mismatch: logs a warning, returns original data cast to expected type.
|
|
1788
|
-
* Schema drift should not crash the app.
|
|
1789
|
-
*/
|
|
1790
|
-
|
|
1791
|
-
/**
|
|
1792
|
-
* Validate an API response against a Zod schema.
|
|
1793
|
-
*
|
|
1794
|
-
* - On success: returns parsed (cleaned) data
|
|
1795
|
-
* - On failure: logs a warning with `context` label, returns the raw data
|
|
1796
|
-
* cast as T. **The return value is NOT guaranteed to satisfy T on
|
|
1797
|
-
* validation failure** — callers must tolerate schema drift at runtime.
|
|
1798
|
-
*
|
|
1799
|
-
* This is intentional — schema drift should degrade gracefully,
|
|
1800
|
-
* not crash the app. Pass a unique `context` string so mismatches
|
|
1801
|
-
* can be traced in logs (e.g. `"contacts.list"`, `"campaigns.get"`).
|
|
1802
|
-
*/
|
|
1803
|
-
declare function validateApiResponse<T>(data: unknown, schema: z.ZodSchema<T>, context?: string): T;
|
|
1804
|
-
|
|
1805
|
-
/**
|
|
1806
|
-
* Generic Entity Query Builder
|
|
1807
|
-
*
|
|
1808
|
-
* Builds server-side query parameters for entity filtering.
|
|
1809
|
-
* Supports tags, metrics, profiles, attributes, pagination, search, sorting, and date ranges.
|
|
1810
|
-
*
|
|
1811
|
-
* Usage:
|
|
1812
|
-
* const params = new EntityQueryBuilder()
|
|
1813
|
-
* .withTags('quality:tier_1', 'status:prospect')
|
|
1814
|
-
* .withMetrics('financial:aum__gte:100000000')
|
|
1815
|
-
* .paginate(1, 25)
|
|
1816
|
-
* .search('acme')
|
|
1817
|
-
* .sort('name', 'asc')
|
|
1818
|
-
* .build()
|
|
1819
|
-
*/
|
|
1820
|
-
declare class EntityQueryBuilder {
|
|
1821
|
-
private params;
|
|
1822
|
-
/**
|
|
1823
|
-
* Filter by entity type
|
|
1824
|
-
*/
|
|
1825
|
-
entityType(type: 'CONTACT' | 'ORGANIZATION'): this;
|
|
1826
|
-
/**
|
|
1827
|
-
* Add tag filters (compact format: "category:name")
|
|
1828
|
-
*
|
|
1829
|
-
* @example
|
|
1830
|
-
* .withTags('quality:tier_1', 'status:prospect')
|
|
1831
|
-
* // produces: tags=quality:tier_1,status:prospect
|
|
1832
|
-
*/
|
|
1833
|
-
withTags(...tags: string[]): this;
|
|
1834
|
-
/**
|
|
1835
|
-
* Add metric filters (compact format: "type:subtype__operator:value")
|
|
1836
|
-
*
|
|
1837
|
-
* @example
|
|
1838
|
-
* .withMetrics('financial:aum__gte:100000000', 'check_size:min__gte:1000000')
|
|
1839
|
-
*/
|
|
1840
|
-
withMetrics(...metrics: string[]): this;
|
|
1841
|
-
/**
|
|
1842
|
-
* Add profile filters (compact format: "type:subtype")
|
|
1843
|
-
*
|
|
1844
|
-
* @example
|
|
1845
|
-
* .withProfiles('professional:linkedin', 'social:twitter')
|
|
1846
|
-
*/
|
|
1847
|
-
withProfiles(...profiles: string[]): this;
|
|
1848
|
-
/**
|
|
1849
|
-
* Add attribute filters (compact format: "type:subtype:value")
|
|
1850
|
-
*
|
|
1851
|
-
* @example
|
|
1852
|
-
* .withAttributes('demographic:location:san_francisco')
|
|
1853
|
-
*/
|
|
1854
|
-
withAttributes(...attrs: string[]): this;
|
|
1855
|
-
/**
|
|
1856
|
-
* Set pagination parameters
|
|
1857
|
-
*/
|
|
1858
|
-
paginate(page: number, pageSize: number): this;
|
|
1859
|
-
/**
|
|
1860
|
-
* Set search query
|
|
1861
|
-
*/
|
|
1862
|
-
search(query: string): this;
|
|
1863
|
-
/**
|
|
1864
|
-
* Set sort field and direction (maps to Django's `ordering` param)
|
|
1865
|
-
*/
|
|
1866
|
-
sort(field: string, direction?: 'asc' | 'desc'): this;
|
|
1867
|
-
/**
|
|
1868
|
-
* Add a date range filter on a given field
|
|
1869
|
-
*
|
|
1870
|
-
* @example
|
|
1871
|
-
* .withDateRange('created', new Date('2024-01-01'), new Date('2024-12-31'))
|
|
1872
|
-
* // produces: created_after=2024-01-01&created_before=2024-12-31
|
|
1873
|
-
*/
|
|
1874
|
-
withDateRange(field: string, from?: Date, to?: Date): this;
|
|
1875
|
-
/**
|
|
1876
|
-
* Set an arbitrary query parameter
|
|
1877
|
-
*/
|
|
1878
|
-
param(key: string, value: string): this;
|
|
1879
|
-
/**
|
|
1880
|
-
* Build as a plain object (suitable for URLSearchParams or fetch helpers)
|
|
1881
|
-
*/
|
|
1882
|
-
build(): Record<string, string>;
|
|
1883
|
-
/**
|
|
1884
|
-
* Build as a query string (includes leading `?`)
|
|
1885
|
-
* Returns empty string if no params.
|
|
1886
|
-
*/
|
|
1887
|
-
toQueryString(): string;
|
|
1888
|
-
/**
|
|
1889
|
-
* Reset all parameters
|
|
1890
|
-
*/
|
|
1891
|
-
clear(): this;
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
/**
|
|
1895
|
-
* Django REST Framework response transformations
|
|
1896
|
-
*
|
|
1897
|
-
* Normalizes DRF paginated responses into a frontend-friendly shape.
|
|
1898
|
-
*/
|
|
1899
|
-
/**
|
|
1900
|
-
* Raw DRF paginated response shape
|
|
1901
|
-
*/
|
|
1902
|
-
interface DRFPaginatedResponse<T> {
|
|
1903
|
-
count: number;
|
|
1904
|
-
next: string | null;
|
|
1905
|
-
previous: string | null;
|
|
1906
|
-
results: T[];
|
|
1907
|
-
}
|
|
1908
|
-
/**
|
|
1909
|
-
* Normalized paginated response for frontend consumption
|
|
1910
|
-
*/
|
|
1911
|
-
interface NormalizedPaginatedResponse<T> {
|
|
1912
|
-
items: T[];
|
|
1913
|
-
total: number;
|
|
1914
|
-
page: number;
|
|
1915
|
-
pageSize: number;
|
|
1916
|
-
hasNext: boolean;
|
|
1917
|
-
hasPrev: boolean;
|
|
1918
|
-
}
|
|
1919
|
-
/**
|
|
1920
|
-
* Normalize a DRF paginated response into a frontend-friendly format.
|
|
1921
|
-
*
|
|
1922
|
-
* @param response - Raw DRF paginated response
|
|
1923
|
-
* @param page - Current page number (1-based)
|
|
1924
|
-
* @param pageSize - Items per page
|
|
1925
|
-
*/
|
|
1926
|
-
declare function normalizePaginated<T>(response: DRFPaginatedResponse<T>, page: number, pageSize: number): NormalizedPaginatedResponse<T>;
|
|
1927
|
-
/**
|
|
1928
|
-
* Check if a response is a DRF paginated response
|
|
1929
|
-
*/
|
|
1930
|
-
declare function isDRFPaginatedResponse<T = unknown>(response: unknown): response is DRFPaginatedResponse<T>;
|
|
1931
|
-
|
|
1932
|
-
/**
|
|
1933
|
-
* Django REST API endpoint constants
|
|
1934
|
-
*/
|
|
1935
|
-
declare const ENDPOINTS: {
|
|
1936
|
-
readonly CONTACTS: "contacts";
|
|
1937
|
-
readonly CONTACTS_BULK: "contacts/bulk";
|
|
1938
|
-
readonly CONTACT: (id: string) => string;
|
|
1939
|
-
readonly ORGANIZATIONS: "organizations";
|
|
1940
|
-
readonly ORGANIZATIONS_BULK: "organizations/bulk";
|
|
1941
|
-
readonly ORGANIZATION: (id: string) => string;
|
|
1942
|
-
readonly TAGS: "core/tags";
|
|
1943
|
-
readonly TAG: (id: string) => string;
|
|
1944
|
-
readonly ENTITY_TAGS: "core/entity-tags";
|
|
1945
|
-
readonly ENTITY_TAG: (id: string) => string;
|
|
1946
|
-
readonly METRICS: "core/metrics";
|
|
1947
|
-
readonly METRIC: (id: string) => string;
|
|
1948
|
-
readonly PROFILES: "core/profiles";
|
|
1949
|
-
readonly PROFILE: (id: string) => string;
|
|
1950
|
-
readonly ATTRIBUTES: "core/attributes";
|
|
1951
|
-
readonly ATTRIBUTE: (id: string) => string;
|
|
1952
|
-
readonly RELATIONSHIPS: "core/relationships";
|
|
1953
|
-
readonly RELATIONSHIP: (id: string) => string;
|
|
1954
|
-
readonly WORKFLOWS: "workflows";
|
|
1955
|
-
readonly WORKFLOW: (id: string) => string;
|
|
1956
|
-
readonly WORKFLOW_EXECUTE: (id: string) => string;
|
|
1957
|
-
readonly MESSAGES: "messages";
|
|
1958
|
-
readonly MESSAGE: (id: string) => string;
|
|
1959
|
-
readonly MESSAGE_SEND: (id: string) => string;
|
|
1960
|
-
readonly FUNNELS: "funnels";
|
|
1961
|
-
readonly FUNNEL: (id: string) => string;
|
|
1962
|
-
readonly FUNNEL_RUN: (id: string) => string;
|
|
1963
|
-
readonly FUNNEL_RUNS: (id: string) => string;
|
|
1964
|
-
readonly FUNNEL_RUN_ITEM: (funnelId: string, runId: string) => string;
|
|
1965
|
-
readonly FUNNEL_PREVIEW: (id: string) => string;
|
|
1966
|
-
readonly FUNNEL_RESULTS: (id: string) => string;
|
|
1967
|
-
readonly FUNNEL_TEMPLATES: "funnels/templates";
|
|
1968
|
-
readonly FUNNEL_RUN_BY_ID: (runId: string) => string;
|
|
1969
|
-
readonly FUNNEL_RUN_CANCEL: (runId: string) => string;
|
|
1970
|
-
readonly FUNNEL_RUNS_GLOBAL: "funnel-runs";
|
|
1971
|
-
};
|
|
1972
|
-
|
|
1973
|
-
/**
|
|
1974
|
-
* Shared CRM option constants for dropdown fields.
|
|
1975
|
-
*
|
|
1976
|
-
* Used across market-simpli and raise-simpli for company/contact field dropdowns.
|
|
1977
|
-
*/
|
|
1978
|
-
interface SelectOption<T extends string = string> {
|
|
1979
|
-
value: T;
|
|
1980
|
-
label: string;
|
|
1981
|
-
}
|
|
1982
|
-
declare const COMPANY_SIZE_OPTIONS: [{
|
|
1983
|
-
readonly value: "startup";
|
|
1984
|
-
readonly label: "Startup (1-10)";
|
|
1985
|
-
}, {
|
|
1986
|
-
readonly value: "small";
|
|
1987
|
-
readonly label: "Small (11-50)";
|
|
1988
|
-
}, {
|
|
1989
|
-
readonly value: "smb";
|
|
1990
|
-
readonly label: "SMB (51-200)";
|
|
1991
|
-
}, {
|
|
1992
|
-
readonly value: "mid_market";
|
|
1993
|
-
readonly label: "Mid-Market (201-1000)";
|
|
1994
|
-
}, {
|
|
1995
|
-
readonly value: "enterprise";
|
|
1996
|
-
readonly label: "Enterprise (1000+)";
|
|
1997
|
-
}];
|
|
1998
|
-
declare const LIFECYCLE_STAGE_OPTIONS: [{
|
|
1999
|
-
readonly value: "subscriber";
|
|
2000
|
-
readonly label: "Subscriber";
|
|
2001
|
-
}, {
|
|
2002
|
-
readonly value: "lead";
|
|
2003
|
-
readonly label: "Lead";
|
|
2004
|
-
}, {
|
|
2005
|
-
readonly value: "mql";
|
|
2006
|
-
readonly label: "MQL";
|
|
2007
|
-
}, {
|
|
2008
|
-
readonly value: "sql";
|
|
2009
|
-
readonly label: "SQL";
|
|
2010
|
-
}, {
|
|
2011
|
-
readonly value: "opportunity";
|
|
2012
|
-
readonly label: "Opportunity";
|
|
2013
|
-
}, {
|
|
2014
|
-
readonly value: "customer";
|
|
2015
|
-
readonly label: "Customer";
|
|
2016
|
-
}, {
|
|
2017
|
-
readonly value: "evangelist";
|
|
2018
|
-
readonly label: "Evangelist";
|
|
2019
|
-
}];
|
|
2020
|
-
declare const REVENUE_RANGE_OPTIONS: [{
|
|
2021
|
-
readonly value: "pre_revenue";
|
|
2022
|
-
readonly label: "Pre-revenue";
|
|
2023
|
-
}, {
|
|
2024
|
-
readonly value: "0_1m";
|
|
2025
|
-
readonly label: "$0-$1M";
|
|
2026
|
-
}, {
|
|
2027
|
-
readonly value: "1m_10m";
|
|
2028
|
-
readonly label: "$1M-$10M";
|
|
2029
|
-
}, {
|
|
2030
|
-
readonly value: "10m_50m";
|
|
2031
|
-
readonly label: "$10M-$50M";
|
|
2032
|
-
}, {
|
|
2033
|
-
readonly value: "50m_plus";
|
|
2034
|
-
readonly label: "$50M+";
|
|
2035
|
-
}];
|
|
2036
|
-
declare const ACTIVITY_TYPE_OPTIONS: [{
|
|
2037
|
-
readonly value: "call";
|
|
2038
|
-
readonly label: "Call";
|
|
2039
|
-
}, {
|
|
2040
|
-
readonly value: "email";
|
|
2041
|
-
readonly label: "Email";
|
|
2042
|
-
}, {
|
|
2043
|
-
readonly value: "meeting";
|
|
2044
|
-
readonly label: "Meeting";
|
|
2045
|
-
}, {
|
|
2046
|
-
readonly value: "demo";
|
|
2047
|
-
readonly label: "Demo";
|
|
2048
|
-
}, {
|
|
2049
|
-
readonly value: "note";
|
|
2050
|
-
readonly label: "Note";
|
|
2051
|
-
}, {
|
|
2052
|
-
readonly value: "task";
|
|
2053
|
-
readonly label: "Task";
|
|
2054
|
-
}];
|
|
2055
|
-
declare const ACTIVITY_OUTCOME_OPTIONS: [{
|
|
2056
|
-
readonly value: "scheduled_demo";
|
|
2057
|
-
readonly label: "Scheduled Demo";
|
|
2058
|
-
}, {
|
|
2059
|
-
readonly value: "scheduled_meeting";
|
|
2060
|
-
readonly label: "Scheduled Meeting";
|
|
2061
|
-
}, {
|
|
2062
|
-
readonly value: "callback_later";
|
|
2063
|
-
readonly label: "Callback Later";
|
|
2064
|
-
}, {
|
|
2065
|
-
readonly value: "left_voicemail";
|
|
2066
|
-
readonly label: "Left Voicemail";
|
|
2067
|
-
}, {
|
|
2068
|
-
readonly value: "no_answer";
|
|
2069
|
-
readonly label: "No Answer";
|
|
2070
|
-
}, {
|
|
2071
|
-
readonly value: "not_interested";
|
|
2072
|
-
readonly label: "Not Interested";
|
|
2073
|
-
}, {
|
|
2074
|
-
readonly value: "successful";
|
|
2075
|
-
readonly label: "Successful";
|
|
2076
|
-
}, {
|
|
2077
|
-
readonly value: "unsuccessful";
|
|
2078
|
-
readonly label: "Unsuccessful";
|
|
2079
|
-
}];
|
|
2080
|
-
declare const LOSS_REASON_OPTIONS: [{
|
|
2081
|
-
readonly value: "price";
|
|
2082
|
-
readonly label: "Price / Budget";
|
|
2083
|
-
}, {
|
|
2084
|
-
readonly value: "timing";
|
|
2085
|
-
readonly label: "Bad Timing";
|
|
2086
|
-
}, {
|
|
2087
|
-
readonly value: "competitor";
|
|
2088
|
-
readonly label: "Chose Competitor";
|
|
2089
|
-
}, {
|
|
2090
|
-
readonly value: "no_need";
|
|
2091
|
-
readonly label: "No Need";
|
|
2092
|
-
}, {
|
|
2093
|
-
readonly value: "no_response";
|
|
2094
|
-
readonly label: "No Response";
|
|
2095
|
-
}, {
|
|
2096
|
-
readonly value: "other";
|
|
2097
|
-
readonly label: "Other";
|
|
2098
|
-
}];
|
|
2099
|
-
declare const DEAL_STAGE_OPTIONS: [{
|
|
2100
|
-
readonly value: "qualification";
|
|
2101
|
-
readonly label: "Qualification";
|
|
2102
|
-
}, {
|
|
2103
|
-
readonly value: "discovery";
|
|
2104
|
-
readonly label: "Discovery";
|
|
2105
|
-
}, {
|
|
2106
|
-
readonly value: "demo";
|
|
2107
|
-
readonly label: "Demo";
|
|
2108
|
-
}, {
|
|
2109
|
-
readonly value: "proposal";
|
|
2110
|
-
readonly label: "Proposal";
|
|
2111
|
-
}, {
|
|
2112
|
-
readonly value: "negotiation";
|
|
2113
|
-
readonly label: "Negotiation";
|
|
2114
|
-
}, {
|
|
2115
|
-
readonly value: "closed_won";
|
|
2116
|
-
readonly label: "Closed Won";
|
|
2117
|
-
}, {
|
|
2118
|
-
readonly value: "closed_lost";
|
|
2119
|
-
readonly label: "Closed Lost";
|
|
2120
|
-
}];
|
|
2121
|
-
type CompanySize = (typeof COMPANY_SIZE_OPTIONS)[number]['value'];
|
|
2122
|
-
type LifecycleStage = (typeof LIFECYCLE_STAGE_OPTIONS)[number]['value'];
|
|
2123
|
-
type RevenueRange = (typeof REVENUE_RANGE_OPTIONS)[number]['value'];
|
|
2124
|
-
type ActivityType = (typeof ACTIVITY_TYPE_OPTIONS)[number]['value'];
|
|
2125
|
-
type ActivityOutcome = (typeof ACTIVITY_OUTCOME_OPTIONS)[number]['value'];
|
|
2126
|
-
type LossReason = (typeof LOSS_REASON_OPTIONS)[number]['value'];
|
|
2127
|
-
type DealStage = (typeof DEAL_STAGE_OPTIONS)[number]['value'];
|
|
2128
|
-
|
|
2129
|
-
interface ServerListOptions {
|
|
2130
|
-
pageSize?: number;
|
|
2131
|
-
initialPage?: number;
|
|
2132
|
-
initialSearch?: string;
|
|
2133
|
-
initialSortField?: string;
|
|
2134
|
-
initialSortDir?: 'asc' | 'desc';
|
|
2135
|
-
/** Extra static query params to append on every request */
|
|
2136
|
-
params?: Record<string, string | number | boolean>;
|
|
2137
|
-
/** Disable auto-fetch on mount */
|
|
2138
|
-
disabled?: boolean;
|
|
2139
|
-
/** Custom fetch function (defaults to global fetch). Use authFetch from @startsimpli/auth for authenticated calls. */
|
|
2140
|
-
fetcher?: typeof fetch;
|
|
2141
|
-
}
|
|
2142
|
-
interface ServerListResult<T> {
|
|
2143
|
-
data: T[];
|
|
2144
|
-
total: number;
|
|
2145
|
-
loading: boolean;
|
|
2146
|
-
error: string | null;
|
|
2147
|
-
page: number;
|
|
2148
|
-
pageSize: number;
|
|
2149
|
-
search: string;
|
|
2150
|
-
sortField: string;
|
|
2151
|
-
sortDir: 'asc' | 'desc';
|
|
2152
|
-
setPage: (page: number) => void;
|
|
2153
|
-
setPageSize: (size: number) => void;
|
|
2154
|
-
setSearch: (search: string) => void;
|
|
2155
|
-
setSort: (field: string, dir?: 'asc' | 'desc') => void;
|
|
2156
|
-
refresh: () => void;
|
|
2157
|
-
}
|
|
2158
|
-
/**
|
|
2159
|
-
* Hook for server-side paginated list fetching.
|
|
2160
|
-
* Sends ?page=N&pageSize=Y&sortField=Z&sortDirection=asc|desc&search=Q
|
|
2161
|
-
* to the provided endpoint.
|
|
2162
|
-
*
|
|
2163
|
-
* @example
|
|
2164
|
-
* import { useServerList } from '@startsimpli/api'
|
|
2165
|
-
* import { authFetch } from '@startsimpli/auth'
|
|
2166
|
-
*
|
|
2167
|
-
* const { data, total, loading, page, setPage, setSearch } = useServerList<Email>(
|
|
2168
|
-
* '/api/v1/emails/',
|
|
2169
|
-
* { fetcher: authFetch, pageSize: 25 }
|
|
2170
|
-
* )
|
|
2171
|
-
*/
|
|
2172
|
-
declare function useServerList<T>(endpoint: string, options?: ServerListOptions): ServerListResult<T>;
|
|
2173
|
-
|
|
2174
|
-
interface ServerDetailOptions {
|
|
2175
|
-
/** Custom fetch function. Use authFetch from @startsimpli/auth for authenticated calls. */
|
|
2176
|
-
fetcher?: typeof fetch;
|
|
2177
|
-
/** Pass null to skip fetching (e.g., when ID is not yet known) */
|
|
2178
|
-
disabled?: boolean;
|
|
2179
|
-
}
|
|
2180
|
-
interface ServerDetailResult<T> {
|
|
2181
|
-
data: T | null;
|
|
2182
|
-
loading: boolean;
|
|
2183
|
-
error: string | null;
|
|
2184
|
-
refresh: () => void;
|
|
2185
|
-
}
|
|
2186
|
-
/**
|
|
2187
|
-
* Hook for fetching a single resource.
|
|
2188
|
-
*
|
|
2189
|
-
* @example
|
|
2190
|
-
* import { useServerDetail } from '@startsimpli/api'
|
|
2191
|
-
* import { authFetch } from '@startsimpli/auth'
|
|
2192
|
-
*
|
|
2193
|
-
* const { data, loading, error } = useServerDetail<User>(
|
|
2194
|
-
* '/api/v1/users/',
|
|
2195
|
-
* userId,
|
|
2196
|
-
* { fetcher: authFetch }
|
|
2197
|
-
* )
|
|
2198
|
-
*/
|
|
2199
|
-
declare function useServerDetail<T>(endpoint: string, id?: string | number | null, options?: ServerDetailOptions): ServerDetailResult<T>;
|
|
2200
|
-
|
|
2201
|
-
/**
|
|
2202
|
-
* Environment variable utilities for server-side use.
|
|
2203
|
-
*
|
|
2204
|
-
* These are generic helpers for accessing process.env safely.
|
|
2205
|
-
* App-specific schema validation (via zod) lives in each app's src/lib/env.ts.
|
|
2206
|
-
*/
|
|
2207
|
-
/**
|
|
2208
|
-
* Returns the value of an environment variable, throwing if it is missing or empty.
|
|
2209
|
-
*/
|
|
2210
|
-
declare function getRequiredEnv(key: string): string;
|
|
2211
|
-
/**
|
|
2212
|
-
* Returns the value of an environment variable, or a default if it is missing.
|
|
2213
|
-
*/
|
|
2214
|
-
declare function getOptionalEnv(key: string, defaultValue?: string): string | undefined;
|
|
2215
|
-
/**
|
|
2216
|
-
* Asserts that all listed environment variable keys are present and non-empty.
|
|
2217
|
-
* Throws a single error listing every missing variable instead of failing on the first one.
|
|
2218
|
-
*/
|
|
2219
|
-
declare function validateEnvVars(required: string[]): void;
|
|
2220
|
-
|
|
2221
|
-
/**
|
|
2222
|
-
* Create a complete API client with all endpoints.
|
|
2223
|
-
* All config fields are optional — baseUrl defaults to '' (relative URLs via Next.js proxy).
|
|
2224
|
-
*/
|
|
2225
|
-
declare function createStartSimpliApi(config?: ApiClientConfig): {
|
|
2226
|
-
client: ApiClient;
|
|
2227
|
-
contacts: ContactsApi;
|
|
2228
|
-
organizations: OrganizationsApi;
|
|
2229
|
-
entities: EntitiesApi;
|
|
2230
|
-
workflows: WorkflowsApi;
|
|
2231
|
-
messages: MessagesApi;
|
|
2232
|
-
funnels: FunnelsApi;
|
|
2233
|
-
};
|
|
2234
|
-
|
|
2235
|
-
export { ACTIVITY_OUTCOME_OPTIONS, ACTIVITY_TYPE_OPTIONS, type ActivityOutcome, type ActivityType, ApiClient, type ApiClientConfig, type ApiError, ApiException, type ApiRequestConfig, type ApiResponse, AppError, AppErrorCode, type AppErrorResponse, type AsyncState, type AsyncStatus, type Attribute, AuthenticationError, AuthorizationError, COMPANY_SIZE_OPTIONS, CacheManager, type CacheManagerConfig, CacheStore, type CacheStoreConfig, type CompanySize, ConflictError, type Contact, type ContactFilters, ContactsApi, type CorsOptions, type CreateContactRequest, type CreateFunnelInput, type CreateOrganizationRequest, type CreateWorkflowInput$1 as CreateWorkflowInput, DEAL_STAGE_OPTIONS, type ApiError$1 as DRFApiError, type DRFPaginatedResponse, DatabaseError, type DealStage, type DjangoFilterParams, ENDPOINTS, EntitiesApi, type Entity, EntityQueryBuilder, type EntityTag, type EntityType$1 as EntityType, ErrorCode, ErrorCodes, ErrorMessages, type Event, type EventParticipant, type ExecuteFunnelInput, type ExecuteWorkflowInput$1 as ExecuteWorkflowInput, ExternalServiceError, type FetchOptions, FetchWrapper, type FetchWrapperConfig, type FieldError, FieldErrorSchema, type Funnel, type FunnelFilters, type FunnelPreviewResult, type FunnelResult, type FunnelRun, type FunnelRunFilters, type FunnelStage, type FunnelStageRule, type FunnelStatus, type FunnelTemplate, FunnelsApi, type HttpMethod, LIFECYCLE_STAGE_OPTIONS, LOSS_REASON_OPTIONS, type LifecycleStage, type LossReason, MAX_CHAT_MESSAGE_LENGTH, MAX_PROMPT_LENGTH, type Message, type MessageStatus as MessageApiStatus, type MessageRecipient, MessagesApi, type MessagingChannel as MessagingChannelType, type Metric, type NormalizedPaginatedResponse, NotFoundError, type Organization, type OrganizationFilters, OrganizationsApi, type PaginatedResponse, type PaginationParams, type Profile, REVENUE_RANGE_OPTIONS, RateLimitError, type RateLimitOptions, type RateLimitResult, type Relationship, type RevenueRange, type RoleAssignment, type SelectOption, type ServerDetailResult, type ServerListOptions, type ServerListResult, type SortParams, type Source, type StandardErrorResponse, StandardErrorResponseSchema, type Tag, type UpdateContactRequest, type UpdateFunnelInput, type UpdateOrganizationRequest, type UpdateWorkflowInput, type UrlBuilderOptions, ValidationError, type Workflow$1 as Workflow, type WorkflowExecution$1 as WorkflowExecution, type WorkflowFilters$1 as WorkflowFilters, type WorkflowStatus, WorkflowsApi, type WritableAssertions, applyCorsHeaders, buildFilterParams, buildOrderingParam, buildQueryString, buildUrl, createApiClient, createCorsMiddleware, createRateLimiter, createStartSimpliApi, getCacheManager, getClientIP, getCorsHeaders, getErrorCodeFromStatus, getOptionalEnv, getRequiredEnv, handleFetchError, isApiException, isAuthError, isDRFPaginatedResponse, isFunnelRunConflict, isFunnelValidationError, isNotFoundError, isPrismaError, isValidationError, mergeQueryParams, normalizeId, normalizePaginated, parseErrorResponse, resetCacheManager, resolveApiUrl, sanitizeChatMessage, sanitizeHtml, sanitizeSearchQuery, sanitizeUserInput, toAppError, useServerDetail, useServerList, validateApiResponse, validateEnvVars, validateIdentifier };
|