@proteos/sdk 0.93.1 → 0.94.1
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/dist/{chunk-DXF354K4.js → chunk-TJGUHXZP.js} +5 -3
- package/dist/chunk-TJGUHXZP.js.map +1 -0
- package/dist/{chunk-SUS4QR63.cjs → chunk-VKCPXFOR.cjs} +5 -2
- package/dist/chunk-VKCPXFOR.cjs.map +1 -0
- package/dist/index.cjs +487 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1125 -19
- package/dist/index.d.ts +1125 -19
- package/dist/index.js +358 -49
- package/dist/index.js.map +1 -1
- package/dist/meta/index.cjs +100 -96
- package/dist/meta/index.d.cts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.js +1 -1
- package/dist/{types-BbiiuHnH.d.cts → types-UHBpVQQI.d.cts} +19 -1
- package/dist/{types-BbiiuHnH.d.ts → types-UHBpVQQI.d.ts} +19 -1
- package/package.json +1 -1
- package/src/auth/platform-entities.ts +9 -0
- package/src/conversation/types.ts +10 -0
- package/src/data/index.ts +10 -0
- package/src/data/record-drafts.ts +38 -7
- package/src/data/types.ts +135 -9
- package/src/enrichment/index.ts +512 -0
- package/src/enrichment/types.ts +836 -0
- package/src/index.ts +104 -0
- package/src/meta/index.ts +2 -0
- package/src/meta/types.ts +18 -0
- package/dist/chunk-DXF354K4.js.map +0 -1
- package/dist/chunk-SUS4QR63.cjs.map +0 -1
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import type { FilterGroup } from '../meta/filters.js'
|
|
2
|
+
import type { AttributeType } from '../meta/types.js'
|
|
3
|
+
import type { ListResult, UserRef } from '../types/common.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* enrichment-service types — filling attributes from providers (LeadMagic,
|
|
7
|
+
* Icypeas, Exa, …) through waterfalls. Mirror of the wire shapes of
|
|
8
|
+
* services/enrichment-service, which keeps its model to itself.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** How an attribute, or one provider call, ended. */
|
|
12
|
+
export type EnrichmentOutcome = 'pending' | 'hit' | 'miss' | 'error' | 'skipped'
|
|
13
|
+
/** The trust in a returned value. */
|
|
14
|
+
export type EnrichmentConfidence = 'high' | 'medium' | 'low'
|
|
15
|
+
/** What a run over records did with a value it found. */
|
|
16
|
+
export type EnrichmentApplied = 'filled' | 'suggested' | 'unchanged' | 'previously_rejected'
|
|
17
|
+
export type EnrichmentRunKind = 'single' | 'batch'
|
|
18
|
+
export type EnrichmentRunStatus = 'running' | 'completed' | 'failed' | 'cancelled'
|
|
19
|
+
export type EnrichmentItemStatus =
|
|
20
|
+
| 'pending'
|
|
21
|
+
| 'running'
|
|
22
|
+
| 'waiting'
|
|
23
|
+
| 'completed'
|
|
24
|
+
| 'failed'
|
|
25
|
+
| 'cancelled'
|
|
26
|
+
/** What starts an enrichment by itself. A manual start always works. */
|
|
27
|
+
export type EnrichmentTrigger = 'on_create' | 'on_update' | 'on_schedule'
|
|
28
|
+
/**
|
|
29
|
+
* What happens to a value that was found: `suggest` proposes it in a record
|
|
30
|
+
* draft, `fill_empty` writes it when the attribute is empty, `fill` writes it
|
|
31
|
+
* over what is there. A value below `fill_min_confidence` is suggested.
|
|
32
|
+
*/
|
|
33
|
+
export type EnrichmentApplyLevel = 'suggest' | 'fill_empty' | 'fill'
|
|
34
|
+
/**
|
|
35
|
+
* `provider` and `web` steps name a provider that runs on a platform key. A
|
|
36
|
+
* `connection` step names an enrichment connection instead: it runs on the
|
|
37
|
+
* org's own account (its Clay).
|
|
38
|
+
*/
|
|
39
|
+
export type WaterfallStepKind = 'provider' | 'web' | 'connection'
|
|
40
|
+
export type WaterfallStopCondition = 'first_hit' | 'first_validated_hit'
|
|
41
|
+
export type WaterfallStatus = 'active' | 'inactive'
|
|
42
|
+
|
|
43
|
+
/** A value to fill, defined inline in a request. */
|
|
44
|
+
export interface EnrichmentAttribute {
|
|
45
|
+
name: string
|
|
46
|
+
type: AttributeType
|
|
47
|
+
description?: string
|
|
48
|
+
meta?: unknown
|
|
49
|
+
/**
|
|
50
|
+
* The vendor meaning (`work_email`, …); `path` picks one property when the
|
|
51
|
+
* type returns an object. Without them the attribute is researched on the
|
|
52
|
+
* web from its name, type and description.
|
|
53
|
+
*/
|
|
54
|
+
enrichment_type?: string
|
|
55
|
+
path?: string
|
|
56
|
+
/** Pins a waterfall, ahead of every default. */
|
|
57
|
+
waterfall_id?: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Body of `POST /enrich`. The subject is described by `input`, or by a record
|
|
62
|
+
* (`entity_slug` and `record_id`) whose values are read through the entity's
|
|
63
|
+
* enrichment mapping. An entry of `attributes` is the name of a mapped target
|
|
64
|
+
* of the entity (a string) or an inline definition. Without `attributes`,
|
|
65
|
+
* every mapped target of `entity_slug` is filled.
|
|
66
|
+
*/
|
|
67
|
+
export interface EnrichRequest {
|
|
68
|
+
input?: Record<string, string>
|
|
69
|
+
entity_slug?: string
|
|
70
|
+
record_id?: string
|
|
71
|
+
attributes?: Array<string | EnrichmentAttribute>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** One source of a value a web step found. */
|
|
75
|
+
export interface EnrichmentCitation {
|
|
76
|
+
url: string
|
|
77
|
+
title?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Identifies a waterfall step. */
|
|
81
|
+
export interface EnrichmentResultStep {
|
|
82
|
+
kind: WaterfallStepKind
|
|
83
|
+
provider: string
|
|
84
|
+
source: string
|
|
85
|
+
waterfall_id: string
|
|
86
|
+
step_index: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** What was found for one attribute. */
|
|
90
|
+
export interface EnrichmentAttributeResult {
|
|
91
|
+
value: unknown
|
|
92
|
+
outcome: EnrichmentOutcome
|
|
93
|
+
/** The value came from a call another attribute of the same item already made. */
|
|
94
|
+
is_reused?: boolean
|
|
95
|
+
confidence?: EnrichmentConfidence
|
|
96
|
+
/** Set by a run over records for a value it found. */
|
|
97
|
+
applied?: EnrichmentApplied
|
|
98
|
+
citations?: EnrichmentCitation[]
|
|
99
|
+
/** The step that answered, or the last one tried. */
|
|
100
|
+
step?: EnrichmentResultStep
|
|
101
|
+
enrichment_attempt_id?: string
|
|
102
|
+
/** Why the attribute has no value when its outcome is `error` or `skipped`. */
|
|
103
|
+
error_code?: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The values `POST /enrich` found. Nothing is written to a record. */
|
|
107
|
+
export interface EnrichResponse {
|
|
108
|
+
enrichment_run_id: string
|
|
109
|
+
enrichment_item_id: string
|
|
110
|
+
status: EnrichmentItemStatus
|
|
111
|
+
results: Record<string, EnrichmentAttributeResult>
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Body of `POST /enrichment-runs`: the records of one entity to enrich as its
|
|
116
|
+
* mapping defines, listed in `record_ids` or selected by `records_query`,
|
|
117
|
+
* never both.
|
|
118
|
+
*/
|
|
119
|
+
export interface CreateEnrichmentRunRequest {
|
|
120
|
+
entity_slug: string
|
|
121
|
+
record_ids?: string[]
|
|
122
|
+
/** A filter group in the platform's own dialect, the one data-service takes as `_filter`. */
|
|
123
|
+
records_query?: { filter: FilterGroup }
|
|
124
|
+
/** The mapped targets to fill; without it, all of them. */
|
|
125
|
+
attributes?: string[]
|
|
126
|
+
/** How long (0–30) the request waits for the run to finish. */
|
|
127
|
+
wait_seconds?: number
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface EnrichmentRunResponse {
|
|
131
|
+
enrichment_run_id: string
|
|
132
|
+
status: EnrichmentRunStatus
|
|
133
|
+
record_draft_ids: string[]
|
|
134
|
+
item_count: number
|
|
135
|
+
completed_count: number
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** What started a run that no person started. */
|
|
139
|
+
export interface EnrichmentRunOrigin {
|
|
140
|
+
record_event_id?: string
|
|
141
|
+
/** The refresh schedule started the run. */
|
|
142
|
+
is_scheduled_refresh?: boolean
|
|
143
|
+
/** The research run that fills a row it found. */
|
|
144
|
+
research_run_id?: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Why a run started: a request (`manual`, or `workflow` for one a workflow
|
|
149
|
+
* made), a trigger of the entity's enrichment mapping (`on_create`,
|
|
150
|
+
* `on_update`, `on_schedule`), or a research run that fills what it found.
|
|
151
|
+
*/
|
|
152
|
+
export type EnrichmentRunTrigger =
|
|
153
|
+
| 'manual'
|
|
154
|
+
| 'on_create'
|
|
155
|
+
| 'on_update'
|
|
156
|
+
| 'on_schedule'
|
|
157
|
+
| 'workflow'
|
|
158
|
+
| 'research'
|
|
159
|
+
| 'signal'
|
|
160
|
+
|
|
161
|
+
/** One enrichment request as stored. */
|
|
162
|
+
export interface EnrichmentRun {
|
|
163
|
+
id: string
|
|
164
|
+
org_id: string
|
|
165
|
+
kind: EnrichmentRunKind
|
|
166
|
+
status: EnrichmentRunStatus
|
|
167
|
+
entity_slug?: string
|
|
168
|
+
attributes?: string[]
|
|
169
|
+
/** The snapshot of what the run fills and how, as the service stored it. */
|
|
170
|
+
resolved_attributes?: unknown
|
|
171
|
+
origin?: EnrichmentRunOrigin
|
|
172
|
+
trigger: EnrichmentRunTrigger
|
|
173
|
+
record_draft_ids?: string[]
|
|
174
|
+
item_count: number
|
|
175
|
+
completed_count: number
|
|
176
|
+
created_at: string
|
|
177
|
+
created_by: UserRef
|
|
178
|
+
updated_at: string
|
|
179
|
+
updated_by: UserRef
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Filters and paging of `GET /enrichment-runs`. Pages are counted from 0. */
|
|
183
|
+
export interface ListEnrichmentRunsQuery {
|
|
184
|
+
/** `single` is an ad-hoc `enrich` call, `batch` a run over records. */
|
|
185
|
+
kind?: EnrichmentRunKind
|
|
186
|
+
status?: EnrichmentRunStatus
|
|
187
|
+
entity_slug?: string
|
|
188
|
+
page?: number
|
|
189
|
+
/** 25 by default, 100 at most. */
|
|
190
|
+
page_size?: number
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** One page of an org's runs, newest first. The runs come without `resolved_attributes`. */
|
|
194
|
+
export type EnrichmentRunList = ListResult<EnrichmentRun>
|
|
195
|
+
|
|
196
|
+
/** One record of a run, with what was found for it. */
|
|
197
|
+
export interface EnrichmentItem {
|
|
198
|
+
id: string
|
|
199
|
+
org_id: string
|
|
200
|
+
enrichment_run_id: string
|
|
201
|
+
record_id?: string
|
|
202
|
+
record_draft_id?: string
|
|
203
|
+
transaction_id?: string
|
|
204
|
+
input: Record<string, string>
|
|
205
|
+
status: EnrichmentItemStatus
|
|
206
|
+
results: Record<string, EnrichmentAttributeResult>
|
|
207
|
+
error?: string
|
|
208
|
+
waiting_since?: string
|
|
209
|
+
created_at: string
|
|
210
|
+
updated_at: string
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Where one value of a record came from. */
|
|
214
|
+
export interface EnrichmentAttributeProvenance {
|
|
215
|
+
value: unknown
|
|
216
|
+
/** How the value reached the record: the run wrote it, or a reviewer accepted it in `record_draft_id`. */
|
|
217
|
+
applied: 'filled' | 'suggested'
|
|
218
|
+
confidence?: EnrichmentConfidence
|
|
219
|
+
citations?: EnrichmentCitation[]
|
|
220
|
+
/** The waterfall step that answered. */
|
|
221
|
+
step?: EnrichmentResultStep
|
|
222
|
+
enrichment_run_id: string
|
|
223
|
+
enrichment_item_id: string
|
|
224
|
+
enrichment_attempt_id?: string
|
|
225
|
+
record_draft_id?: string
|
|
226
|
+
/** When the run found the value. */
|
|
227
|
+
enriched_at: string
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Answer of `GET /provenance`: per attribute of one record, the enrichment
|
|
232
|
+
* its current value came from. An attribute whose value no enrichment put
|
|
233
|
+
* there, or that someone changed since, is not listed.
|
|
234
|
+
*/
|
|
235
|
+
export interface EnrichmentProvenance {
|
|
236
|
+
entity_slug: string
|
|
237
|
+
record_id: string
|
|
238
|
+
provenance: Record<string, EnrichmentAttributeProvenance>
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* What one attribute does in enrichment: a target (a value to fill), an input
|
|
243
|
+
* (a value providers are called with), or both. On a relation it names the
|
|
244
|
+
* inputs the related record lends.
|
|
245
|
+
*/
|
|
246
|
+
export interface EnrichmentBlock {
|
|
247
|
+
enrichment_type?: string
|
|
248
|
+
path?: string
|
|
249
|
+
waterfall_id?: string
|
|
250
|
+
triggers?: EnrichmentTrigger[]
|
|
251
|
+
/** Set by the service; a caller's value is ignored. */
|
|
252
|
+
triggers_since?: Partial<Record<EnrichmentTrigger, string>>
|
|
253
|
+
/** The attributes whose change starts `on_update`. */
|
|
254
|
+
when_changed?: string[]
|
|
255
|
+
refresh_every_days?: number
|
|
256
|
+
apply?: EnrichmentApplyLevel
|
|
257
|
+
fill_min_confidence?: EnrichmentConfidence
|
|
258
|
+
/** How long a value is not enriched, or paid for, again. */
|
|
259
|
+
max_age_days?: number
|
|
260
|
+
/** The input key the attribute's value provides. */
|
|
261
|
+
input?: string
|
|
262
|
+
/** The company input keys the related record lends. */
|
|
263
|
+
inputs_from_related?: string[]
|
|
264
|
+
/** Set by the service; a caller's value is ignored. */
|
|
265
|
+
related_entity_slug?: string
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** One attribute's block as the API shows it. */
|
|
269
|
+
export interface EnrichmentEntry extends EnrichmentBlock {
|
|
270
|
+
/** The entity's schema no longer backs the entry. Read-only. */
|
|
271
|
+
orphaned?: boolean
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** An entity's enrichment mapping. */
|
|
275
|
+
export interface EnrichmentMapping {
|
|
276
|
+
id: string
|
|
277
|
+
org_id: string
|
|
278
|
+
entity_slug: string
|
|
279
|
+
module_slug: string
|
|
280
|
+
enrichment: Record<string, EnrichmentEntry>
|
|
281
|
+
created_at: string
|
|
282
|
+
created_by: UserRef
|
|
283
|
+
updated_at: string
|
|
284
|
+
updated_by: UserRef
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Replaces an entity's whole mapping. `updated_at` is the `updated_at` of the
|
|
289
|
+
* mapping that was read: left out for an entity without a mapping, and
|
|
290
|
+
* matching the stored one otherwise (else 409).
|
|
291
|
+
*/
|
|
292
|
+
export interface ReplaceEnrichmentMappingRequest {
|
|
293
|
+
enrichment: Record<string, EnrichmentEntry>
|
|
294
|
+
updated_at?: string
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface WaterfallStep {
|
|
298
|
+
kind: WaterfallStepKind
|
|
299
|
+
provider?: string
|
|
300
|
+
/** The enrichment connection of a `connection` step. */
|
|
301
|
+
enrichment_connection_id?: string
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Checks every hit through the default waterfall of another enrichment type. */
|
|
305
|
+
export interface WaterfallValidation {
|
|
306
|
+
enrichment_type: string
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The ordered steps that fill one enrichment type or one entity attribute.
|
|
311
|
+
* `org_id` `''` marks a platform default, which is read-only.
|
|
312
|
+
*/
|
|
313
|
+
export interface Waterfall {
|
|
314
|
+
id: string
|
|
315
|
+
org_id: string
|
|
316
|
+
name: string
|
|
317
|
+
enrichment_type?: string
|
|
318
|
+
entity_slug?: string
|
|
319
|
+
attribute?: string
|
|
320
|
+
steps: WaterfallStep[]
|
|
321
|
+
validation?: WaterfallValidation
|
|
322
|
+
stop_condition: WaterfallStopCondition
|
|
323
|
+
is_default: boolean
|
|
324
|
+
status: WaterfallStatus
|
|
325
|
+
created_at: string
|
|
326
|
+
created_by: UserRef
|
|
327
|
+
updated_at: string
|
|
328
|
+
updated_by: UserRef
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface CreateWaterfallRequest {
|
|
332
|
+
name: string
|
|
333
|
+
enrichment_type?: string
|
|
334
|
+
entity_slug?: string
|
|
335
|
+
attribute?: string
|
|
336
|
+
steps: WaterfallStep[]
|
|
337
|
+
validation?: WaterfallValidation
|
|
338
|
+
/** `first_hit` when left out. */
|
|
339
|
+
stop_condition?: WaterfallStopCondition
|
|
340
|
+
is_default?: boolean
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Changes the members it names. `validation: null` takes the validation away. */
|
|
344
|
+
export interface PatchWaterfallRequest {
|
|
345
|
+
name?: string
|
|
346
|
+
steps?: WaterfallStep[]
|
|
347
|
+
validation?: WaterfallValidation | null
|
|
348
|
+
stop_condition?: WaterfallStopCondition
|
|
349
|
+
is_default?: boolean
|
|
350
|
+
status?: WaterfallStatus
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** One thing that can be asked for. */
|
|
354
|
+
export interface EnrichmentType {
|
|
355
|
+
key: string
|
|
356
|
+
/** The sets of input keys any one of which is enough. */
|
|
357
|
+
input_schema: string[][]
|
|
358
|
+
output_schema: {
|
|
359
|
+
type: string
|
|
360
|
+
paths?: Array<{ name: string; type: string }>
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** The catalog of enrichment types, with the input keys an entity's attributes can provide. */
|
|
365
|
+
export interface EnrichmentTypesResponse {
|
|
366
|
+
data: EnrichmentType[]
|
|
367
|
+
input_keys: string[]
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** One enrichment type a provider supplies. */
|
|
371
|
+
export interface EnrichmentProviderOffering {
|
|
372
|
+
enrichment_type: string
|
|
373
|
+
required_inputs: string[][]
|
|
374
|
+
paths?: string[]
|
|
375
|
+
charge_policy: 'per_call' | 'per_hit'
|
|
376
|
+
is_async: boolean
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** One vendor of the catalog. It carries no credentials and no costs. */
|
|
380
|
+
export interface EnrichmentProvider {
|
|
381
|
+
key: string
|
|
382
|
+
title: string
|
|
383
|
+
logo_url: string
|
|
384
|
+
offerings: EnrichmentProviderOffering[]
|
|
385
|
+
/** Set on a provider that can research attributes on the web. */
|
|
386
|
+
web?: EnrichmentProviderOffering
|
|
387
|
+
/**
|
|
388
|
+
* Set on a provider that runs on the org's own connection of that
|
|
389
|
+
* connector, through an enrichment connection. Such a provider lists no
|
|
390
|
+
* offerings: what it supplies is up to the routine each enrichment
|
|
391
|
+
* connection names.
|
|
392
|
+
*/
|
|
393
|
+
connector_key?: string
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** The service sets `error` when the connection's credential stopped working; setting `active` tries it again. */
|
|
397
|
+
export type EnrichmentConnectionStatus = 'active' | 'inactive' | 'error'
|
|
398
|
+
|
|
399
|
+
/** Which routine to run and how its inputs and results line up with what a waterfall works with. */
|
|
400
|
+
export interface EnrichmentConnectionConfig {
|
|
401
|
+
routine_id: string
|
|
402
|
+
/** The routine's input per input key: `{ company_domain: 'domain' }`. The step needs every key it lists. */
|
|
403
|
+
input_mapping: Record<string, string>
|
|
404
|
+
/**
|
|
405
|
+
* Where in the routine's result each part of the enrichment type's output
|
|
406
|
+
* is found, as a dotted path: `{ value: 'email' }` for a type with a single
|
|
407
|
+
* value, or `{ title: 'job.title' }` by output path for a profile.
|
|
408
|
+
*/
|
|
409
|
+
output_mapping: Record<string, string>
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* An org's binding to one of its connector-service connections (its own Clay
|
|
414
|
+
* key) and to the routine a waterfall's `connection` step runs. The
|
|
415
|
+
* credential stays in connector-service.
|
|
416
|
+
*/
|
|
417
|
+
export interface EnrichmentConnection {
|
|
418
|
+
id: string
|
|
419
|
+
org_id: string
|
|
420
|
+
name: string
|
|
421
|
+
connection_id: string
|
|
422
|
+
connector_key: string
|
|
423
|
+
config: EnrichmentConnectionConfig
|
|
424
|
+
status: EnrichmentConnectionStatus
|
|
425
|
+
status_detail?: string
|
|
426
|
+
created_at: string
|
|
427
|
+
created_by: UserRef
|
|
428
|
+
updated_at: string
|
|
429
|
+
updated_by: UserRef
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export interface CreateEnrichmentConnectionRequest {
|
|
433
|
+
name: string
|
|
434
|
+
connection_id: string
|
|
435
|
+
config: EnrichmentConnectionConfig
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** Changes the members it names. `status` takes `active` or `inactive`. */
|
|
439
|
+
export interface PatchEnrichmentConnectionRequest {
|
|
440
|
+
name?: string
|
|
441
|
+
config?: EnrichmentConnectionConfig
|
|
442
|
+
status?: 'active' | 'inactive'
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export type ResearchDefinitionStatus = 'active' | 'inactive'
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* What a found row proposes for a record it matches: `fill_empty` (the
|
|
449
|
+
* default) only the attributes the record holds nothing under, `overwrite`
|
|
450
|
+
* every attribute whose found value differs from the record's.
|
|
451
|
+
*/
|
|
452
|
+
export type ResearchUpdatePolicy = 'fill_empty' | 'overwrite'
|
|
453
|
+
|
|
454
|
+
/** What to find. */
|
|
455
|
+
export interface ResearchCriteria {
|
|
456
|
+
/** Describes the rows in plain words. */
|
|
457
|
+
query: string
|
|
458
|
+
/** How many rows one run looks for at most: 10 by default, 100 at most. */
|
|
459
|
+
count?: number
|
|
460
|
+
/** Conditions every row must meet, at most 5. */
|
|
461
|
+
criteria?: string[]
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** Maps the found rows onto one entity. */
|
|
465
|
+
export interface ResearchEntityRule {
|
|
466
|
+
entity_slug: string
|
|
467
|
+
/**
|
|
468
|
+
* The attribute a found row is compared by with the entity's records; one
|
|
469
|
+
* of `criteria_fields`. Without one every row is proposed as a new record.
|
|
470
|
+
*/
|
|
471
|
+
match_key?: string
|
|
472
|
+
update_policy?: ResearchUpdatePolicy
|
|
473
|
+
/** The attributes filled from the discovery itself. */
|
|
474
|
+
criteria_fields: string[]
|
|
475
|
+
/**
|
|
476
|
+
* The attributes filled through their waterfalls. Left out or `null`, every
|
|
477
|
+
* mapped target of the entity that is no criteria field is filled; an empty
|
|
478
|
+
* list fills none.
|
|
479
|
+
*/
|
|
480
|
+
fields?: Array<{ attribute: string }> | null
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/** Maps people found for a company onto an entity whose records belong to the company's record. */
|
|
484
|
+
export interface ResearchChildRule extends ResearchEntityRule {
|
|
485
|
+
/** The child entity's relation to the root entity. */
|
|
486
|
+
relation_attribute: string
|
|
487
|
+
/** Whom to look for, such as "Head of Sales". */
|
|
488
|
+
description: string
|
|
489
|
+
/** How many people are found per company: 1 by default, 5 at most. */
|
|
490
|
+
max_per_parent?: number
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface ResearchEntityMapping {
|
|
494
|
+
root: ResearchEntityRule
|
|
495
|
+
children?: ResearchChildRule[]
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** How often an `on_schedule` research runs. */
|
|
499
|
+
export interface ResearchSchedule {
|
|
500
|
+
every_days: number
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Where a research finds its rows when that is not the platform's web
|
|
505
|
+
* search: in the database of a vendor the org connected with its own account.
|
|
506
|
+
* Such a search runs on the org's own key and spends its quota at the vendor.
|
|
507
|
+
*/
|
|
508
|
+
export interface ResearchSource {
|
|
509
|
+
/** The org's connection at connector-service. */
|
|
510
|
+
connection_id: string
|
|
511
|
+
/** The connection's connector, such as `clay`. The service sets it. */
|
|
512
|
+
connector_key?: string
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** What to find, how it maps onto entities, and when to look again. */
|
|
516
|
+
export interface ResearchDefinition {
|
|
517
|
+
id: string
|
|
518
|
+
org_id: string
|
|
519
|
+
name: string
|
|
520
|
+
/** Absent for the platform's web search. */
|
|
521
|
+
source?: ResearchSource
|
|
522
|
+
criteria: ResearchCriteria
|
|
523
|
+
entity_mapping: ResearchEntityMapping
|
|
524
|
+
/** `on_schedule` or nothing. A run can always be started by hand. */
|
|
525
|
+
triggers: string[]
|
|
526
|
+
schedule?: ResearchSchedule
|
|
527
|
+
next_run_at?: string
|
|
528
|
+
status: ResearchDefinitionStatus
|
|
529
|
+
created_at: string
|
|
530
|
+
created_by: UserRef
|
|
531
|
+
updated_at: string
|
|
532
|
+
updated_by: UserRef
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export interface CreateResearchDefinitionRequest {
|
|
536
|
+
name: string
|
|
537
|
+
/**
|
|
538
|
+
* One of the org's own connections to search instead of the web.
|
|
539
|
+
* `criteria.query` is then written in the vendor's query language.
|
|
540
|
+
*/
|
|
541
|
+
source?: ResearchSource
|
|
542
|
+
criteria: ResearchCriteria
|
|
543
|
+
entity_mapping: ResearchEntityMapping
|
|
544
|
+
triggers?: string[]
|
|
545
|
+
schedule?: ResearchSchedule
|
|
546
|
+
status?: ResearchDefinitionStatus
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Changes the members it names; `criteria` and `entity_mapping` are replaced
|
|
551
|
+
* whole. An empty `triggers` list takes the schedule away. A `source` with an
|
|
552
|
+
* empty `connection_id` goes back to the web search.
|
|
553
|
+
*/
|
|
554
|
+
export interface PatchResearchDefinitionRequest {
|
|
555
|
+
name?: string
|
|
556
|
+
source?: ResearchSource
|
|
557
|
+
criteria?: ResearchCriteria
|
|
558
|
+
entity_mapping?: ResearchEntityMapping
|
|
559
|
+
triggers?: string[]
|
|
560
|
+
schedule?: ResearchSchedule
|
|
561
|
+
status?: ResearchDefinitionStatus
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/** One execution of a research definition. */
|
|
565
|
+
export interface ResearchRun {
|
|
566
|
+
id: string
|
|
567
|
+
org_id: string
|
|
568
|
+
research_definition_id: string
|
|
569
|
+
trigger: 'manual' | 'on_schedule'
|
|
570
|
+
/** The part of the definition the run works from, as it was when the run started. */
|
|
571
|
+
definition: {
|
|
572
|
+
source?: ResearchSource
|
|
573
|
+
criteria: ResearchCriteria
|
|
574
|
+
entity_mapping: ResearchEntityMapping
|
|
575
|
+
}
|
|
576
|
+
/** The discovery provider's id of the search. */
|
|
577
|
+
provider_ref?: string
|
|
578
|
+
status: EnrichmentRunStatus
|
|
579
|
+
record_draft_ids: string[]
|
|
580
|
+
/** How many rows were found. */
|
|
581
|
+
result_count: number
|
|
582
|
+
/** How many of them are in a record draft. */
|
|
583
|
+
proposed_count: number
|
|
584
|
+
error?: string
|
|
585
|
+
created_at: string
|
|
586
|
+
created_by: UserRef
|
|
587
|
+
updated_at: string
|
|
588
|
+
updated_by: UserRef
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export interface ListResearchRunsQuery {
|
|
592
|
+
research_definition_id?: string
|
|
593
|
+
page?: number
|
|
594
|
+
/** 25 by default, 100 at most. */
|
|
595
|
+
page_size?: number
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** One page of an org's research runs, newest first. */
|
|
599
|
+
export type ResearchRunList = ListResult<ResearchRun>
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* `proposed` waits for a reviewer; `accepted`, `edited` and `rejected` are
|
|
603
|
+
* what the reviewer decided; `unchanged` matched a record and had nothing new
|
|
604
|
+
* for it; `skipped` was rejected in an earlier run and is not proposed again.
|
|
605
|
+
*/
|
|
606
|
+
export type ResearchResultStatus =
|
|
607
|
+
| 'pending'
|
|
608
|
+
| 'proposed'
|
|
609
|
+
| 'accepted'
|
|
610
|
+
| 'edited'
|
|
611
|
+
| 'rejected'
|
|
612
|
+
| 'unchanged'
|
|
613
|
+
| 'skipped'
|
|
614
|
+
| 'failed'
|
|
615
|
+
|
|
616
|
+
/** Where one value of a found row came from. */
|
|
617
|
+
export interface ResearchEvidence {
|
|
618
|
+
/** `Research`, or the provider whose waterfall step answered. */
|
|
619
|
+
label?: string
|
|
620
|
+
citations?: EnrichmentCitation[]
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** One found row. */
|
|
624
|
+
export interface ResearchResult {
|
|
625
|
+
id: string
|
|
626
|
+
org_id: string
|
|
627
|
+
research_run_id: string
|
|
628
|
+
research_definition_id: string
|
|
629
|
+
/** Set on a person: the row of the company they were found for. */
|
|
630
|
+
parent_research_result_id?: string
|
|
631
|
+
entity_slug: string
|
|
632
|
+
/** The discovery provider's id of the row. */
|
|
633
|
+
provider_ref?: string
|
|
634
|
+
raw?: unknown
|
|
635
|
+
/**
|
|
636
|
+
* The attribute values the row is proposed with; for a row that proposes
|
|
637
|
+
* nothing, what was found. A person's relation to a company that is no
|
|
638
|
+
* record yet reads `{ research_result_id: '<id>' }`.
|
|
639
|
+
*/
|
|
640
|
+
values: Record<string, unknown>
|
|
641
|
+
evidence?: Record<string, ResearchEvidence>
|
|
642
|
+
/** The row's value under the entity's match key. */
|
|
643
|
+
match_value?: string
|
|
644
|
+
matched_record_id?: string
|
|
645
|
+
proposed_intent: 'create' | 'update' | 'none'
|
|
646
|
+
record_draft_id?: string
|
|
647
|
+
transaction_id?: string
|
|
648
|
+
/** The record an accepted row became, or the one it matched. */
|
|
649
|
+
record_id?: string
|
|
650
|
+
status: ResearchResultStatus
|
|
651
|
+
error?: string
|
|
652
|
+
created_at: string
|
|
653
|
+
updated_at: string
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* What a signal is about. A scheduled refresh detects `field_change`,
|
|
658
|
+
* `job_change` and `headcount_change`; a web monitor looks for
|
|
659
|
+
* `funding`, `news` and `hiring`. The set is open: a signal mapping exists
|
|
660
|
+
* per kind.
|
|
661
|
+
*/
|
|
662
|
+
export type SignalKind =
|
|
663
|
+
| 'field_change'
|
|
664
|
+
| 'job_change'
|
|
665
|
+
| 'headcount_change'
|
|
666
|
+
| 'funding'
|
|
667
|
+
| 'news'
|
|
668
|
+
| 'hiring'
|
|
669
|
+
| (string & {})
|
|
670
|
+
|
|
671
|
+
/** One detected change about a record. */
|
|
672
|
+
export interface Signal {
|
|
673
|
+
id: string
|
|
674
|
+
org_id: string
|
|
675
|
+
kind: SignalKind
|
|
676
|
+
/** The source: a monitor, or the scheduled refresh run that found the change. */
|
|
677
|
+
signal_monitor_id?: string
|
|
678
|
+
enrichment_run_id?: string
|
|
679
|
+
/** The record the signal is about, and the attribute that changed. */
|
|
680
|
+
entity_slug?: string
|
|
681
|
+
record_id?: string
|
|
682
|
+
field?: string
|
|
683
|
+
previous_value?: unknown
|
|
684
|
+
value?: unknown
|
|
685
|
+
summary: string
|
|
686
|
+
evidence?: EnrichmentCitation[]
|
|
687
|
+
enrichment_attempt_id?: string
|
|
688
|
+
/** The draft the kind's signal mapping proposed. Absent for a kind without a mapping. */
|
|
689
|
+
record_draft_id?: string
|
|
690
|
+
dedupe_key: string
|
|
691
|
+
detected_at: string
|
|
692
|
+
created_at: string
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** Filters `signals.list`. Every member narrows the list. */
|
|
696
|
+
export interface ListSignalsQuery {
|
|
697
|
+
kind?: string
|
|
698
|
+
entity_slug?: string
|
|
699
|
+
record_id?: string
|
|
700
|
+
signal_monitor_id?: string
|
|
701
|
+
enrichment_run_id?: string
|
|
702
|
+
page?: number
|
|
703
|
+
/** 25 by default, 100 at most. */
|
|
704
|
+
page_size?: number
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** One page of an org's signals, newest first. */
|
|
708
|
+
export type SignalList = ListResult<Signal>
|
|
709
|
+
|
|
710
|
+
export type SignalUpdatePolicy = 'fill_empty' | 'overwrite'
|
|
711
|
+
|
|
712
|
+
/** A record a signal creates. */
|
|
713
|
+
export interface SignalCreateEffect {
|
|
714
|
+
/** Names the record for the relations of later creates. */
|
|
715
|
+
ref?: string
|
|
716
|
+
entity_slug: string
|
|
717
|
+
/**
|
|
718
|
+
* The record's values by attribute. A text may hold the placeholders
|
|
719
|
+
* `{{summary}}`, `{{value}}`, `{{previous_value}}`, `{{evidence}}` and
|
|
720
|
+
* `{{detected_at}}`.
|
|
721
|
+
*/
|
|
722
|
+
values?: Record<string, unknown>
|
|
723
|
+
/** By relation attribute, what the record points at: `subject`, or the ref of an earlier create. */
|
|
724
|
+
relations?: Record<string, string>
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** What a signal proposes to change on the record it is about. */
|
|
728
|
+
export interface SignalUpdateEffect {
|
|
729
|
+
target: 'subject'
|
|
730
|
+
attributes: Record<string, unknown>
|
|
731
|
+
update_policy?: SignalUpdatePolicy
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export interface SignalEffects {
|
|
735
|
+
create: SignalCreateEffect[]
|
|
736
|
+
update: SignalUpdateEffect[]
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/** An org's record effects for one signal kind. */
|
|
740
|
+
export interface SignalMapping {
|
|
741
|
+
id: string
|
|
742
|
+
org_id: string
|
|
743
|
+
kind: SignalKind
|
|
744
|
+
module_slug: string
|
|
745
|
+
effects: SignalEffects
|
|
746
|
+
/** The parts of the effects that no longer fit the org's entities, such as `create[0].values.type`. */
|
|
747
|
+
orphaned?: string[]
|
|
748
|
+
created_at: string
|
|
749
|
+
created_by: UserRef
|
|
750
|
+
updated_at: string
|
|
751
|
+
updated_by: UserRef
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export interface PutSignalMappingRequest {
|
|
755
|
+
effects: SignalEffects
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* `web` looks on the web on a schedule. `connection` takes the events a vendor
|
|
760
|
+
* pushes at one of the org's own connections.
|
|
761
|
+
*/
|
|
762
|
+
export type SignalMonitorKind = 'web' | 'connection'
|
|
763
|
+
export type SignalMonitorStatus = 'active' | 'inactive'
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Which records a monitor covers: one of `record_ids` and `records_query`, of
|
|
767
|
+
* one entity. A `connection` monitor takes neither: it covers every record of
|
|
768
|
+
* the entity an event is about.
|
|
769
|
+
*/
|
|
770
|
+
export interface SignalMonitorSubject {
|
|
771
|
+
entity_slug: string
|
|
772
|
+
record_ids?: string[]
|
|
773
|
+
records_query?: { filter: FilterGroup }
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export interface SignalMonitorConfig {
|
|
777
|
+
/**
|
|
778
|
+
* What a `web` monitor looks for: `news`, `funding`, `hiring`. A
|
|
779
|
+
* `connection` monitor takes the kinds listed, and every kind the vendor
|
|
780
|
+
* pushes when none is.
|
|
781
|
+
*/
|
|
782
|
+
signal_kinds?: string[]
|
|
783
|
+
/** The org's connection whose pushed events a `connection` monitor takes. */
|
|
784
|
+
connection_id?: string
|
|
785
|
+
/** The connection's connector, such as `clay`. The service sets it. */
|
|
786
|
+
connector_key?: string
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/** How often a `web` monitor checks. A `connection` monitor has none: `every_days` is 0. */
|
|
790
|
+
export interface SignalMonitorSchedule {
|
|
791
|
+
every_days: number
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* A standing monitor for events about records: one that looks on the web on a
|
|
796
|
+
* schedule, or one that takes what a vendor pushes.
|
|
797
|
+
*/
|
|
798
|
+
export interface SignalMonitor {
|
|
799
|
+
id: string
|
|
800
|
+
org_id: string
|
|
801
|
+
name: string
|
|
802
|
+
kind: SignalMonitorKind
|
|
803
|
+
subject: SignalMonitorSubject
|
|
804
|
+
config: SignalMonitorConfig
|
|
805
|
+
schedule: SignalMonitorSchedule
|
|
806
|
+
provider_ref?: string
|
|
807
|
+
status: SignalMonitorStatus
|
|
808
|
+
/** Why the last check failed. Absent otherwise. */
|
|
809
|
+
status_detail?: string
|
|
810
|
+
/** The last check that worked. */
|
|
811
|
+
last_run_at?: string
|
|
812
|
+
next_run_at?: string
|
|
813
|
+
created_at: string
|
|
814
|
+
created_by: UserRef
|
|
815
|
+
updated_at: string
|
|
816
|
+
updated_by: UserRef
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
export interface CreateSignalMonitorRequest {
|
|
820
|
+
name: string
|
|
821
|
+
kind: SignalMonitorKind
|
|
822
|
+
subject: SignalMonitorSubject
|
|
823
|
+
config: SignalMonitorConfig
|
|
824
|
+
schedule: SignalMonitorSchedule
|
|
825
|
+
/** Active unless it says inactive. */
|
|
826
|
+
status?: SignalMonitorStatus
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/** Only the members it names change; a monitor's kind is fixed. */
|
|
830
|
+
export interface PatchSignalMonitorRequest {
|
|
831
|
+
name?: string
|
|
832
|
+
subject?: SignalMonitorSubject
|
|
833
|
+
config?: SignalMonitorConfig
|
|
834
|
+
schedule?: SignalMonitorSchedule
|
|
835
|
+
status?: SignalMonitorStatus
|
|
836
|
+
}
|