conare 0.29.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -8
- package/dist/index.d.ts +536 -26
- package/dist/index.js +347 -44
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.33.0";
|
|
2
2
|
/** A metadata value: string, number, boolean or an array of strings. */
|
|
3
3
|
export type MetadataValue = string | number | boolean | string[];
|
|
4
4
|
export type Metadata = Record<string, MetadataValue>;
|
|
@@ -83,6 +83,34 @@ export interface DocumentInput {
|
|
|
83
83
|
*/
|
|
84
84
|
image?: string;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* What a billable call counted toward your bill, in the units of `GET /usage`: multiply each by its price in
|
|
88
|
+
* `GET /billing`'s `prices` for the cost. A server older than these answers none (`usage` is then undefined).
|
|
89
|
+
*/
|
|
90
|
+
export interface SearchUsage {
|
|
91
|
+
/** 1 a search; 0 a later page of `queryPages`, which costs nothing. */
|
|
92
|
+
queries: number;
|
|
93
|
+
}
|
|
94
|
+
/** What a write counted: the documents created or updated, and the tokens embedded to index them (an `unchanged` document counts in neither). */
|
|
95
|
+
export interface WriteUsage {
|
|
96
|
+
documentsWritten: number;
|
|
97
|
+
indexTokens: number;
|
|
98
|
+
}
|
|
99
|
+
/** What `parse` counted: the PDF pages, image frames and slides it read, blank ones included (0 for a file without pages). */
|
|
100
|
+
export interface ParseUsage {
|
|
101
|
+
pages: number;
|
|
102
|
+
/** The index tokens those pages count as: each page or image is a fixed number of tokens, OCR included. */
|
|
103
|
+
indexTokens?: number;
|
|
104
|
+
}
|
|
105
|
+
/** What `embed` counted: the tokens embedded (a repeat of an `idempotencyKey` answers the same and counts nothing again). */
|
|
106
|
+
export interface EmbedUsage {
|
|
107
|
+
embedTokens: number;
|
|
108
|
+
}
|
|
109
|
+
/** What `rerank` counted: the tokens of the query and documents read, and the rerank calls billed. */
|
|
110
|
+
export interface RerankUsage {
|
|
111
|
+
rerankTokens: number;
|
|
112
|
+
rerankCalls: number;
|
|
113
|
+
}
|
|
86
114
|
/** What a write did with one document. */
|
|
87
115
|
export type WriteOutcome = "created" | "updated" | "unchanged" | "stale";
|
|
88
116
|
export interface WriteResult {
|
|
@@ -103,8 +131,12 @@ export interface WriteResult {
|
|
|
103
131
|
/** The document's `image` was embedded with its text (absent without one, or where its namespace reads none). */
|
|
104
132
|
imageEmbedded?: boolean;
|
|
105
133
|
}
|
|
134
|
+
/** `write`'s results, in order, and what the write counted (summed over its batches; undefined from an older server). */
|
|
135
|
+
export type WriteResults = WriteResult[] & {
|
|
136
|
+
usage?: WriteUsage;
|
|
137
|
+
};
|
|
106
138
|
/** A file type `uploadFile` can declare: the file is read as that type (`jpg` and `tif` are accepted too). */
|
|
107
|
-
export type FileType = "pdf" | "xlsx" | "docx" | "pptx" | "csv" | "tsv" | "txt" | "md" | "png" | "jpeg" | "webp" | "tiff" | "gif" | "bmp" | "heic";
|
|
139
|
+
export type FileType = "pdf" | "xlsx" | "docx" | "pptx" | "csv" | "tsv" | "txt" | "md" | "html" | "png" | "jpeg" | "webp" | "tiff" | "gif" | "bmp" | "heic";
|
|
108
140
|
/**
|
|
109
141
|
* A picture of a Word document or deck that OCR did not turn into text. Every raster picture is read except an
|
|
110
142
|
* icon or a decoration: under 64 pixels on both sides, under 16 pixels on its shorter side, or drawn under half
|
|
@@ -127,7 +159,7 @@ export interface PictureWithoutText {
|
|
|
127
159
|
*/
|
|
128
160
|
reason: "too_small" | "not_raster" | "unreadable" | "not_read" | "no_text";
|
|
129
161
|
}
|
|
130
|
-
/** Options of `parse` and `uploadFile`: which pages, a password, the page layout and how long to wait. */
|
|
162
|
+
/** Options of `parse` and `uploadFile`: which pages, a password, the page layout, a workbook's sheets, cells and formulas, figure descriptions, and how long to wait. */
|
|
131
163
|
export interface ParseOptions {
|
|
132
164
|
/** The file's type: it is read as that type. Unset: the bytes say, then the name. */
|
|
133
165
|
type?: FileType;
|
|
@@ -137,6 +169,27 @@ export interface ParseOptions {
|
|
|
137
169
|
password?: string;
|
|
138
170
|
/** Each part OCR read carries `blocks`, its page's regions. */
|
|
139
171
|
layout?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* A workbook's sheets to read (.xlsx, .xlsm, .xls, .ods), by name, whatever their case; the others, their charts
|
|
174
|
+
* included, are not read. A name the workbook does not have throws 400 naming its sheets.
|
|
175
|
+
*/
|
|
176
|
+
sheets?: string[];
|
|
177
|
+
/** The cells to read of each sheet read, an A1 range: `"A1:F40"`, `"A:F"` or `"3:40"`. Rows and columns keep their numbers and letters. */
|
|
178
|
+
range?: string;
|
|
179
|
+
/**
|
|
180
|
+
* On an .xlsx or .xlsm: each sheet as its grid (a header of column letters, every row under its number), a cell with
|
|
181
|
+
* a formula as its saved value then the formula as inline code, e.g. ``110 `=B2*1.1` ``. Other files throw 400.
|
|
182
|
+
*/
|
|
183
|
+
formulas?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Each chart, diagram and picture OCR reads is described in one line `> **Figure description:** ...` at its place, and
|
|
186
|
+
* every part says whether it holds one (`vision`); a picture with no text but a description is a part, not 422
|
|
187
|
+
* `no_text`. A description is written by a model: it describes what the chart, diagram or picture shows and is not
|
|
188
|
+
* text from the page; it can be wrong, and two reads of the same file may word it differently; numbers a chart prints
|
|
189
|
+
* are in the page's text as before. Up to six figures a page are described, the largest; a figure the model does not
|
|
190
|
+
* describe has no line. A deployment that does not offer it answers 400 `invalid_request`.
|
|
191
|
+
*/
|
|
192
|
+
vision?: boolean;
|
|
140
193
|
/**
|
|
141
194
|
* Seconds to wait for OCR before the answer is pending (0-300, default 60; the answer comes within 105 s
|
|
142
195
|
* whatever it says). `true` is 60. On `uploadFile`, `false` answers once the text layers are stored.
|
|
@@ -153,6 +206,8 @@ export interface ParseBlock {
|
|
|
153
206
|
content: string;
|
|
154
207
|
/** The mean probability of its tokens; null when none was given. */
|
|
155
208
|
conf: number | null;
|
|
209
|
+
/** With `vision: true`, on an `image` or `chart` region: its description, written by a model ("" when none). */
|
|
210
|
+
description?: string;
|
|
156
211
|
}
|
|
157
212
|
/** One part of a parsed file: a page, slide, picture, sheet or Word part. */
|
|
158
213
|
export interface ParsePart {
|
|
@@ -161,6 +216,8 @@ export interface ParsePart {
|
|
|
161
216
|
markdown: string;
|
|
162
217
|
/** Read by OCR from the page's image, not its text layer. */
|
|
163
218
|
ocr: boolean;
|
|
219
|
+
/** With `vision: true` only: its `markdown` holds a figure description, written by a model and not text from the page. */
|
|
220
|
+
vision?: boolean;
|
|
164
221
|
/** The mean probability (0-1) of the tokens OCR wrote for it; null when OCR did not read it or gave no probabilities. */
|
|
165
222
|
confidence: number | null;
|
|
166
223
|
/** With `layout: true`, on a part OCR read with its layout. */
|
|
@@ -179,8 +236,14 @@ export interface ParseResult {
|
|
|
179
236
|
state: "done";
|
|
180
237
|
type: FileUpload["type"];
|
|
181
238
|
name: string;
|
|
239
|
+
/** A page parsed by its URL: its title (HTML) or first heading (Markdown); absent when it has none. */
|
|
240
|
+
title?: string;
|
|
241
|
+
/** A file parsed by its URL: the address the fetch landed on after its redirects. */
|
|
242
|
+
sourceUrl?: string;
|
|
182
243
|
/** A PDF's pages, an image's frames, a deck's slides or a workbook's sheets (null for other files). */
|
|
183
244
|
pages: number | null;
|
|
245
|
+
/** A workbook's: the names of all its sheets in order, hidden ones included, whatever `sheets` selected. */
|
|
246
|
+
sheets?: string[];
|
|
184
247
|
/** The whole document: `<!-- page 3 -->`, `<!-- slide 4 -->` and `<!-- sheet "Q3" -->` start each page, slide and sheet. */
|
|
185
248
|
markdown: string;
|
|
186
249
|
parts: ParsePart[];
|
|
@@ -190,11 +253,18 @@ export interface ParseResult {
|
|
|
190
253
|
* parsing the file again can read them. Empty when OCR read them all.
|
|
191
254
|
*/
|
|
192
255
|
ocrFailed: number[];
|
|
256
|
+
/**
|
|
257
|
+
* What the parse counted, OCR's pages included. Absent for a file the parse worker read (over 20 MiB or 2,000
|
|
258
|
+
* pages, or over 100 pages for OCR) and from `uploadFile`, whose pages are counted as the worker reads them.
|
|
259
|
+
*/
|
|
260
|
+
usage?: ParseUsage;
|
|
193
261
|
}
|
|
194
262
|
/** A parse OCR was still reading after `wait`: `getParse(id)` answers the result (kept 24 hours). */
|
|
195
263
|
export interface ParsePending {
|
|
196
264
|
id: string;
|
|
197
265
|
state: "parsing";
|
|
266
|
+
/** What the parse counted, as on `ParseResult`. */
|
|
267
|
+
usage?: ParseUsage;
|
|
198
268
|
}
|
|
199
269
|
/** A parse `getParse` found failed: `error` is what it would have thrown. */
|
|
200
270
|
export interface ParseFailed {
|
|
@@ -203,6 +273,7 @@ export interface ParseFailed {
|
|
|
203
273
|
error: {
|
|
204
274
|
code: string;
|
|
205
275
|
message: string;
|
|
276
|
+
details?: ErrorDetails;
|
|
206
277
|
};
|
|
207
278
|
}
|
|
208
279
|
/** What `uploadFile` stored. */
|
|
@@ -289,6 +360,58 @@ export interface DocumentSummary {
|
|
|
289
360
|
user?: string;
|
|
290
361
|
seq?: number;
|
|
291
362
|
}
|
|
363
|
+
/** A row of `Namespace.changes`: a document created, changed or deleted, with its address and fields as they were then. */
|
|
364
|
+
export interface DocumentChange {
|
|
365
|
+
/** The document: a page's or file's, `<sourceId>:<fileId>`. */
|
|
366
|
+
id: string;
|
|
367
|
+
/** `changed`: its text or parts changed. A page or file read again unchanged adds no row. */
|
|
368
|
+
change: "created" | "changed" | "deleted";
|
|
369
|
+
/** When it was recorded. */
|
|
370
|
+
at: Date;
|
|
371
|
+
/** The document's `url` field, else the address it was read from (a web page, a `gs://` object); absent on a delete. */
|
|
372
|
+
url?: string;
|
|
373
|
+
/** The document's fields then, with `file`, `file_id` and `file_type`; absent on a delete. */
|
|
374
|
+
metadata?: Metadata;
|
|
375
|
+
/** On a web page's `changed` row, how it changed; absent on a file's, and when its earlier version could not be compared. */
|
|
376
|
+
diff?: DocumentDiff;
|
|
377
|
+
}
|
|
378
|
+
/** How a web page changed against the version the row before recorded. */
|
|
379
|
+
export interface DocumentDiff {
|
|
380
|
+
/**
|
|
381
|
+
* `content`: its text changed, as `hunks` say. `reader`: it reads as it did; only how Conare reads web pages
|
|
382
|
+
* changed. `fields`: it reads as it did; only its fields changed.
|
|
383
|
+
*/
|
|
384
|
+
cause: "content" | "reader" | "fields";
|
|
385
|
+
/** Where its text changed, in the page's order (at most 24): the lines removed where the lines added are now. The title is the line `Title: ...`. */
|
|
386
|
+
hunks?: Array<{
|
|
387
|
+
removed?: string[];
|
|
388
|
+
added?: string[];
|
|
389
|
+
}>;
|
|
390
|
+
/** Lines or hunks were left out to keep it in bounds. */
|
|
391
|
+
truncated?: boolean;
|
|
392
|
+
}
|
|
393
|
+
/** What `Namespace.changes` lists: from a cursor, of one source, in a time window. */
|
|
394
|
+
export interface ChangesOptions extends RequestOptions {
|
|
395
|
+
/** A previous page's `nextCursor`; omit it to list from the start. Pass the same filters with it. */
|
|
396
|
+
cursor?: string;
|
|
397
|
+
/** Rows per page, 1-1000 (default 100). */
|
|
398
|
+
limit?: number;
|
|
399
|
+
/** Only the documents of this source (its id). */
|
|
400
|
+
source?: string;
|
|
401
|
+
/** Only rows recorded at or after this time. */
|
|
402
|
+
since?: Date | string;
|
|
403
|
+
/** Only rows recorded before this time. */
|
|
404
|
+
until?: Date | string;
|
|
405
|
+
}
|
|
406
|
+
/** One page of `Namespace.changes`. */
|
|
407
|
+
export interface ChangesPage {
|
|
408
|
+
/** Oldest first. */
|
|
409
|
+
changes: DocumentChange[];
|
|
410
|
+
/** Where the next call starts, also when this page is empty: keep it and pass it as `cursor`. */
|
|
411
|
+
nextCursor: string;
|
|
412
|
+
/** More rows follow this page: call again at once. */
|
|
413
|
+
hasMore: boolean;
|
|
414
|
+
}
|
|
292
415
|
export interface QueryResult {
|
|
293
416
|
id: string;
|
|
294
417
|
/**
|
|
@@ -325,6 +448,12 @@ export interface QueryOptions extends RequestOptions {
|
|
|
325
448
|
/** 2 searches again from the best results, for answers that span documents (not with `queryPages`). */
|
|
326
449
|
hops?: 1 | 2;
|
|
327
450
|
}
|
|
451
|
+
/** The options of `Namespace.count`: a query's filter and user scoping (no `$ne`, `$nin` or `$text`). */
|
|
452
|
+
export interface CountOptions extends RequestOptions {
|
|
453
|
+
filter?: Filter;
|
|
454
|
+
user?: string;
|
|
455
|
+
userPrefix?: string;
|
|
456
|
+
}
|
|
328
457
|
export interface GrepOptions extends RequestOptions {
|
|
329
458
|
filter?: Filter;
|
|
330
459
|
user?: string;
|
|
@@ -346,6 +475,8 @@ export interface GrepPage {
|
|
|
346
475
|
matches: GrepMatch[];
|
|
347
476
|
/** Where the next page starts; null on the last page. A page can stop short of `limit`. */
|
|
348
477
|
nextCursor: string | null;
|
|
478
|
+
/** What the call counted (undefined from an older server). */
|
|
479
|
+
usage?: SearchUsage;
|
|
349
480
|
}
|
|
350
481
|
/**
|
|
351
482
|
* A search's results, best first, and what the search lost on the way (the values of the `Conare-Degraded`
|
|
@@ -354,6 +485,7 @@ export interface GrepPage {
|
|
|
354
485
|
*/
|
|
355
486
|
export type QueryResults = QueryResult[] & {
|
|
356
487
|
degraded: string[];
|
|
488
|
+
usage?: SearchUsage;
|
|
357
489
|
};
|
|
358
490
|
/** One page of `Namespace.queryPages`. */
|
|
359
491
|
export interface QueryPage {
|
|
@@ -362,6 +494,92 @@ export interface QueryPage {
|
|
|
362
494
|
degraded: string[];
|
|
363
495
|
/** Where the next page starts (`queryPages`'s `cursor`); null on the last page. */
|
|
364
496
|
nextCursor: string | null;
|
|
497
|
+
/** What this page counted: the first page 1 query, later ones 0 (undefined from an older server). */
|
|
498
|
+
usage?: SearchUsage;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* A field of a record's schema (`Namespace.queryRecord`). Say in `description` what it holds and in what form
|
|
502
|
+
* (up to 1,000 characters): the model reads it. A string may list its values in `enum` (1-50, each up to 100
|
|
503
|
+
* characters); an array is a list of strings.
|
|
504
|
+
*/
|
|
505
|
+
export type RecordField = {
|
|
506
|
+
type: "string";
|
|
507
|
+
description?: string;
|
|
508
|
+
enum?: readonly string[];
|
|
509
|
+
title?: string;
|
|
510
|
+
} | {
|
|
511
|
+
type: "number" | "integer" | "boolean";
|
|
512
|
+
description?: string;
|
|
513
|
+
title?: string;
|
|
514
|
+
} | {
|
|
515
|
+
type: "array";
|
|
516
|
+
items: {
|
|
517
|
+
type: "string";
|
|
518
|
+
enum?: readonly string[];
|
|
519
|
+
description?: string;
|
|
520
|
+
title?: string;
|
|
521
|
+
};
|
|
522
|
+
description?: string;
|
|
523
|
+
title?: string;
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* A record's schema, a JSON Schema: an object of 1-32 fields, each name 1-64 characters of `[A-Za-z0-9_]`, not
|
|
527
|
+
* starting with a digit. `title`, `description`, `required`, `additionalProperties` and `$schema` change nothing.
|
|
528
|
+
*/
|
|
529
|
+
export interface RecordSchema {
|
|
530
|
+
type: "object";
|
|
531
|
+
properties: {
|
|
532
|
+
readonly [name: string]: RecordField;
|
|
533
|
+
};
|
|
534
|
+
title?: string;
|
|
535
|
+
description?: string;
|
|
536
|
+
required?: readonly string[];
|
|
537
|
+
additionalProperties?: boolean;
|
|
538
|
+
$schema?: string;
|
|
539
|
+
}
|
|
540
|
+
/** The value a field of a record holds: an `enum` field one of its values. */
|
|
541
|
+
export type RecordFieldValue<F extends RecordField> = F extends {
|
|
542
|
+
type: "string";
|
|
543
|
+
enum: readonly (infer E extends string)[];
|
|
544
|
+
} ? E : F extends {
|
|
545
|
+
type: "string";
|
|
546
|
+
} ? string : F extends {
|
|
547
|
+
type: "number" | "integer";
|
|
548
|
+
} ? number : F extends {
|
|
549
|
+
type: "boolean";
|
|
550
|
+
} ? boolean : F extends {
|
|
551
|
+
type: "array";
|
|
552
|
+
items: {
|
|
553
|
+
enum: readonly (infer E extends string)[];
|
|
554
|
+
};
|
|
555
|
+
} ? E[] : F extends {
|
|
556
|
+
type: "array";
|
|
557
|
+
} ? string[] : never;
|
|
558
|
+
/** A filled record: every field of the schema, its value, or null when no passage the search read states it. */
|
|
559
|
+
export type RecordOf<S extends RecordSchema> = {
|
|
560
|
+
-readonly [K in keyof S["properties"]]: RecordFieldValue<S["properties"][K]> | null;
|
|
561
|
+
};
|
|
562
|
+
/** Where a record's value is from. */
|
|
563
|
+
export interface RecordSource {
|
|
564
|
+
/** The document that states the value. */
|
|
565
|
+
id: string;
|
|
566
|
+
/** The address the document was read from, when it has one (a web page, a synced record's link). */
|
|
567
|
+
url?: string;
|
|
568
|
+
/** The words of the document that state the value. */
|
|
569
|
+
quote: string;
|
|
570
|
+
}
|
|
571
|
+
/** What `Namespace.queryRecord` answers. */
|
|
572
|
+
export interface QueryRecord<S extends RecordSchema> {
|
|
573
|
+
/** Every field of the schema, its value or null; null itself when the answer model was unavailable (the results alone). */
|
|
574
|
+
record: RecordOf<S> | null;
|
|
575
|
+
/** For each field with a value, the document, address and words it is from. */
|
|
576
|
+
sources: {
|
|
577
|
+
[K in keyof S["properties"]]?: RecordSource;
|
|
578
|
+
};
|
|
579
|
+
/** The search's results, best first (`topK`), and what it lost (`degraded`). */
|
|
580
|
+
results: QueryResults;
|
|
581
|
+
/** Each passage a source is that `results` does not hold (the record reads past `topK`); empty when they hold them all. */
|
|
582
|
+
sourcePassages: QueryResult[];
|
|
365
583
|
}
|
|
366
584
|
export interface NamespaceInfo {
|
|
367
585
|
name: string;
|
|
@@ -387,6 +605,11 @@ export interface RerankResult {
|
|
|
387
605
|
/** Rerank results, best first, and the indexes of the documents no window read (the budget ended, or their window failed); those are not in the results. */
|
|
388
606
|
export type RerankResults = RerankResult[] & {
|
|
389
607
|
unscored: number[];
|
|
608
|
+
usage?: RerankUsage;
|
|
609
|
+
};
|
|
610
|
+
/** Float embeddings, one per text, and what the call counted (undefined from an older server). */
|
|
611
|
+
export type Embeddings = number[][] & {
|
|
612
|
+
usage?: EmbedUsage;
|
|
390
613
|
};
|
|
391
614
|
export interface EmbedOptions {
|
|
392
615
|
type?: "document" | "query";
|
|
@@ -399,7 +622,29 @@ export interface EmbedOptions {
|
|
|
399
622
|
export interface Int8Embeddings {
|
|
400
623
|
values: Int8Array[];
|
|
401
624
|
scales: number[];
|
|
625
|
+
usage?: EmbedUsage;
|
|
402
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Both parts of the embedding model (`embed(..., { tokenEmbeddings: true })`): each text's vector and, beside
|
|
629
|
+
* it, a vector per token. Rank a document for a query with `hybridScore`, which blends the two scores by
|
|
630
|
+
* `denseWeight`; either part also ranks alone.
|
|
631
|
+
*/
|
|
632
|
+
export interface HybridEmbeddings {
|
|
633
|
+
/** One vector per text, unit length. */
|
|
634
|
+
embeddings: number[][];
|
|
635
|
+
/** Per text, its token embeddings: rows of `tokenDimensions` floats. */
|
|
636
|
+
tokenEmbeddings: number[][][];
|
|
637
|
+
tokenDimensions: number;
|
|
638
|
+
/** The share of the `embeddings` score in the blended score, between 0 and 1. */
|
|
639
|
+
denseWeight: number;
|
|
640
|
+
usage?: EmbedUsage;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Text `d` of `documents` scored for text `q` of `query` (one embedded with type "query", the other with
|
|
644
|
+
* "document", both with `tokenEmbeddings: true`): denseWeight × dot(the two vectors) + (1 − denseWeight) ×
|
|
645
|
+
* the mean, over the query's token embeddings, of each one's best dot product among the document's.
|
|
646
|
+
*/
|
|
647
|
+
export declare function hybridScore(query: HybridEmbeddings, documents: HybridEmbeddings, q?: number, d?: number): number;
|
|
403
648
|
/** The float vectors int8 embeddings stand for: values × scale. */
|
|
404
649
|
export declare function dequantize(embeddings: Int8Embeddings): number[][];
|
|
405
650
|
export type SourceStatus = "connecting" | "syncing" | "ready" | "error";
|
|
@@ -487,6 +732,8 @@ export interface CustomSource {
|
|
|
487
732
|
};
|
|
488
733
|
documents: number | null;
|
|
489
734
|
documentsVerifiedAt: Date | null;
|
|
735
|
+
/** A Google Cloud Storage, web or files source deleted with a grace: when its documents go (`sources.restore` until then). */
|
|
736
|
+
deletesAt?: Date;
|
|
490
737
|
createdAt: Date;
|
|
491
738
|
updatedAt: Date;
|
|
492
739
|
}
|
|
@@ -515,6 +762,70 @@ export interface GCSSource extends Omit<CustomSource, "kind" | "type" | "app" |
|
|
|
515
762
|
/** Objects it holds no current document for. */
|
|
516
763
|
failures: number;
|
|
517
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* Pages of public websites Conare keeps in step with their sites: each is read again every
|
|
767
|
+
* `config.syncIntervalSeconds`, and parsed again only when it changed. `failures` counts the pages it could not
|
|
768
|
+
* read (the site refuses crawlers, wants a sign-in, the page needs a browser to show its text or holds none): every
|
|
769
|
+
* page it lists is stored or one of them.
|
|
770
|
+
*/
|
|
771
|
+
/** A page of a web source: its address, or its address with your fields, which every document of the page carries. */
|
|
772
|
+
export type WebPage = string | {
|
|
773
|
+
url: string;
|
|
774
|
+
metadata?: Record<string, string | number | boolean | string[]>;
|
|
775
|
+
};
|
|
776
|
+
export interface WebSource extends Omit<CustomSource, "kind" | "type" | "app" | "user"> {
|
|
777
|
+
kind: "web";
|
|
778
|
+
type: "web";
|
|
779
|
+
app: null;
|
|
780
|
+
user: null;
|
|
781
|
+
/**
|
|
782
|
+
* `urls`: the source's pages, from `get()` (`list()` leaves them out: a site holds thousands). For a source of a
|
|
783
|
+
* `site`, the pages its last sync found there, of at most `maxPages`. `pages`: how many it has, from both.
|
|
784
|
+
*/
|
|
785
|
+
config: {
|
|
786
|
+
urls?: string[];
|
|
787
|
+
pages: number;
|
|
788
|
+
syncIntervalSeconds: number;
|
|
789
|
+
site?: string;
|
|
790
|
+
maxPages?: number;
|
|
791
|
+
};
|
|
792
|
+
/** Pages it could not read or holds no current document for. */
|
|
793
|
+
failures: number;
|
|
794
|
+
}
|
|
795
|
+
/** How many sources (`sources.summary()`), how many of them fail and sync now, and their newest successful sync. */
|
|
796
|
+
export interface SourceCounts {
|
|
797
|
+
sources: number;
|
|
798
|
+
failing: number;
|
|
799
|
+
syncing: number;
|
|
800
|
+
lastSuccessAt: string | null;
|
|
801
|
+
}
|
|
802
|
+
/** `sources.summary()`: every namespace a source writes into, by name, with its sources by type; and all of them. */
|
|
803
|
+
export interface SourceSummary extends SourceCounts {
|
|
804
|
+
namespaces: Array<SourceCounts & {
|
|
805
|
+
namespace: string;
|
|
806
|
+
types: Array<SourceCounts & {
|
|
807
|
+
type: string;
|
|
808
|
+
}>;
|
|
809
|
+
}>;
|
|
810
|
+
}
|
|
811
|
+
/** One object of a Google Cloud Storage source, or one page of a web source, it could not keep, whole or in part. */
|
|
812
|
+
export interface SourceFailure {
|
|
813
|
+
/** The object (`gs://...`) or the page's address. */
|
|
814
|
+
externalId: string;
|
|
815
|
+
key: string;
|
|
816
|
+
/** The version that failed; empty for a page that was not read. */
|
|
817
|
+
version: string;
|
|
818
|
+
/**
|
|
819
|
+
* Why: a parse's code (`unsupported_file`, `too_large`, `pages_unread`, ...), or for a page what its site did
|
|
820
|
+
* (`refused`, `slow_down`, `robots_disallowed`, `sign_in_required`, `gone`, `unreachable`, `needs_javascript`).
|
|
821
|
+
*/
|
|
822
|
+
code: string;
|
|
823
|
+
message: string;
|
|
824
|
+
runId: string | null;
|
|
825
|
+
/** How many times in a row it failed this way. */
|
|
826
|
+
attempts: number;
|
|
827
|
+
failedAt: Date;
|
|
828
|
+
}
|
|
518
829
|
/** A document of a custom source to push. */
|
|
519
830
|
export interface CustomDocumentInput {
|
|
520
831
|
/** Your id for the document; its `key` is derived from it. */
|
|
@@ -573,6 +884,12 @@ export interface Run {
|
|
|
573
884
|
sweep: "none" | "applied" | "held" | "blocked";
|
|
574
885
|
sweepReason: string | null;
|
|
575
886
|
expected: number | null;
|
|
887
|
+
/**
|
|
888
|
+
* What the run did: `seen`, `deleted`; an import's `created`, `updated`, `rejected`; a web source's sync's `created`
|
|
889
|
+
* (pages stored the first time) and `updated` (stored again). Of a source of a `site`: `named` (every page the site
|
|
890
|
+
* named) = `found` (kept) + `skipped_robots` + `skipped_translation` + `skipped_max_pages`; `listed` = `found` +
|
|
891
|
+
* `carried`.
|
|
892
|
+
*/
|
|
576
893
|
counts: Record<string, number>;
|
|
577
894
|
error: {
|
|
578
895
|
code: string;
|
|
@@ -635,17 +952,21 @@ export interface OrganizationSpend {
|
|
|
635
952
|
/** Every organization of your customer, and how many cost anything. */
|
|
636
953
|
count: number;
|
|
637
954
|
active: number;
|
|
955
|
+
/** How many organizations have a spend cap of their own. */
|
|
956
|
+
capped: number;
|
|
638
957
|
/** Every organization's charges, whatever the search. */
|
|
639
958
|
total: OrganizationCharges;
|
|
640
959
|
/** The ten most expensive organizations' part of the total, 0 to 1. */
|
|
641
960
|
top10Share: number;
|
|
642
961
|
/** How many organizations `q` kept. */
|
|
643
962
|
matched: number;
|
|
963
|
+
/** `spendCapMicros`: the organization's own monthly spend cap (`setOrganizationSpendCap()`), null for none. */
|
|
644
964
|
rows: Array<{
|
|
645
965
|
id: string;
|
|
646
966
|
name: string;
|
|
647
967
|
externalId?: string;
|
|
648
968
|
charges: OrganizationCharges;
|
|
969
|
+
spendCapMicros: number | null;
|
|
649
970
|
}>;
|
|
650
971
|
/** The matches after this page, as one sum. */
|
|
651
972
|
rest: {
|
|
@@ -666,6 +987,8 @@ export interface Organization {
|
|
|
666
987
|
default?: boolean;
|
|
667
988
|
/** When it was made (a customer key's `organizations()`). */
|
|
668
989
|
createdAt?: string;
|
|
990
|
+
/** Its own monthly spend cap in whole dollars (a customer key; `setOrganizationSpendCap()`); absent: none. */
|
|
991
|
+
spendCapUsd?: number;
|
|
669
992
|
}
|
|
670
993
|
/** An API key (`createKey()`, `keys()`). Its secret is shown once, by `createKey()`. */
|
|
671
994
|
export interface ApiKey {
|
|
@@ -676,6 +999,10 @@ export interface ApiKey {
|
|
|
676
999
|
/** The key's scope; null reaches every namespace. */
|
|
677
1000
|
namespaces: string[] | null;
|
|
678
1001
|
modelsOnly: boolean;
|
|
1002
|
+
/** A read-only key: every call that changes something stored answers 403 `read_only_key`. */
|
|
1003
|
+
readOnly: boolean;
|
|
1004
|
+
/** The key's cap, a percent (1-100) of each of its organization's rate limits; null: the organization's limits alone. */
|
|
1005
|
+
rateLimitPercent: number | null;
|
|
679
1006
|
/** The organizations it acts for, its own first. */
|
|
680
1007
|
organizations: string[];
|
|
681
1008
|
createdAt: string;
|
|
@@ -701,12 +1028,32 @@ export interface RequestOptions {
|
|
|
701
1028
|
*/
|
|
702
1029
|
idempotencyKey?: string;
|
|
703
1030
|
}
|
|
704
|
-
/**
|
|
1031
|
+
/** Facts some errors carry beside their message. */
|
|
1032
|
+
export interface ErrorDetails {
|
|
1033
|
+
/** A URL's fetch (`parse({ url })`, `uploadFile({ url })`): the HTTP status the URL's site answered. */
|
|
1034
|
+
status?: number;
|
|
1035
|
+
/** A site that answered `slow_down`: the seconds it asked to wait. */
|
|
1036
|
+
retryAfterSeconds?: number;
|
|
1037
|
+
/**
|
|
1038
|
+
* `source_deleting` (a connect of a source in its grace, an upload to a namespace whose files source is
|
|
1039
|
+
* deleted): the source. `sources.restore(sourceId)` brings it back while `deletesAt` is set, or
|
|
1040
|
+
* `sources.delete(sourceId, { graceSeconds: 0 })` deletes it now.
|
|
1041
|
+
*/
|
|
1042
|
+
sourceId?: string;
|
|
1043
|
+
/** `source_deleting` of a source in its grace: when its documents go. Absent once its delete has started. */
|
|
1044
|
+
deletesAt?: Date;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Every failure the SDK throws. `status` is 0 when no response arrived. `details` is what the error
|
|
1048
|
+
* carries beside its message, when it does: for a URL the API fetched, the status its site answered; for
|
|
1049
|
+
* `source_deleting`, the source and when it is deleted.
|
|
1050
|
+
*/
|
|
705
1051
|
export declare class ConareError extends Error {
|
|
706
1052
|
readonly status: number;
|
|
707
1053
|
readonly code: string;
|
|
708
1054
|
readonly requestId: string | null;
|
|
709
|
-
|
|
1055
|
+
readonly details: ErrorDetails | null;
|
|
1056
|
+
constructor(status: number, code: string, message: string, requestId?: string | null, details?: ErrorDetails | null);
|
|
710
1057
|
}
|
|
711
1058
|
/**
|
|
712
1059
|
* The Conare client.
|
|
@@ -755,17 +1102,26 @@ export declare class Conare {
|
|
|
755
1102
|
/**
|
|
756
1103
|
* A new organization of your customer, with a customer key: one per company you serve, with its own
|
|
757
1104
|
* namespaces, keys, sources, usage and limits. `externalId` is your own id for it, unique within your
|
|
758
|
-
* customer: a create with one already used answers that organization and makes none
|
|
759
|
-
*
|
|
1105
|
+
* customer: a create with one already used answers that organization and makes none (its spend cap as it
|
|
1106
|
+
* is). `spendCapUsd` is its own monthly spend cap (`setOrganizationSpendCap()`). Mint the key its traffic
|
|
1107
|
+
* runs on with `createKey()` on a client whose `organization` is its `id`.
|
|
760
1108
|
*/
|
|
761
1109
|
createOrganization(input: {
|
|
762
1110
|
name: string;
|
|
763
1111
|
externalId?: string;
|
|
1112
|
+
spendCapUsd?: number;
|
|
764
1113
|
}, options?: RequestOptions): Promise<Organization>;
|
|
765
1114
|
/** One organization of your customer, with a customer key. */
|
|
766
1115
|
getOrganization(id: string, options?: RequestOptions): Promise<Organization>;
|
|
767
1116
|
/** Renames one organization of your customer, with a customer key. */
|
|
768
1117
|
renameOrganization(id: string, name: string, options?: RequestOptions): Promise<Organization>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Sets one organization's own monthly spend cap in whole dollars (1-10,000,000), or removes it with null,
|
|
1120
|
+
* with a customer key; your customer's default organization takes one too. Once the organization's
|
|
1121
|
+
* charges this month reach it, its billed calls fail with a ConareError 402 `spend_cap_reached` and your
|
|
1122
|
+
* other organizations are still served.
|
|
1123
|
+
*/
|
|
1124
|
+
setOrganizationSpendCap(id: string, usd: number | null, options?: RequestOptions): Promise<Organization>;
|
|
769
1125
|
/**
|
|
770
1126
|
* Deletes one organization of your customer for good, with a customer key. Delete its namespaces and
|
|
771
1127
|
* sources first (a client whose `organization` is its `id`): until then it answers 409 `conflict`.
|
|
@@ -786,12 +1142,17 @@ export declare class Conare {
|
|
|
786
1142
|
/**
|
|
787
1143
|
* A key of this client's `organization`, with a customer key: the key a company's traffic runs on,
|
|
788
1144
|
* reaching that organization alone. `namespaces` scopes it (exact names, or prefixes ending in `*`),
|
|
789
|
-
* `modelsOnly` keeps it to the model routes, `
|
|
1145
|
+
* `modelsOnly` keeps it to the model routes, `readOnly` to the calls that change nothing stored
|
|
1146
|
+
* (every write answers 403 `read_only_key`), `rateLimitPercent` (1-100) caps it at that percent of each of the
|
|
1147
|
+
* organization's rate limits (past it, 429 `rate_limited` for this key alone), `expiresAt` ends it. The secret is in
|
|
1148
|
+
* this answer only.
|
|
790
1149
|
*/
|
|
791
1150
|
createKey(input: {
|
|
792
1151
|
name: string;
|
|
793
1152
|
namespaces?: string[];
|
|
794
1153
|
modelsOnly?: boolean;
|
|
1154
|
+
readOnly?: boolean;
|
|
1155
|
+
rateLimitPercent?: number;
|
|
795
1156
|
expiresAt?: Date | string;
|
|
796
1157
|
}, options?: RequestOptions): Promise<{
|
|
797
1158
|
key: ApiKey;
|
|
@@ -804,14 +1165,21 @@ export declare class Conare {
|
|
|
804
1165
|
/**
|
|
805
1166
|
* Embed texts. Use type "query" for search queries and "document" (default) for stored text.
|
|
806
1167
|
* `outputDtype: "int8"` returns each vector as int8 values and one scale (vector ≈ values × scale),
|
|
807
|
-
* a quarter of the bytes; `dequantize` turns them back into floats.
|
|
1168
|
+
* a quarter of the bytes; `dequantize` turns them back into floats. `tokenEmbeddings: true` returns both
|
|
1169
|
+
* parts of the model, for up to 16 texts a call (`HybridEmbeddings`, scored with `hybridScore`).
|
|
808
1170
|
*/
|
|
809
1171
|
embed(input: string | string[], options?: RequestOptions & EmbedOptions & {
|
|
810
1172
|
outputDtype?: "float";
|
|
811
|
-
|
|
1173
|
+
tokenEmbeddings?: false;
|
|
1174
|
+
}): Promise<Embeddings>;
|
|
812
1175
|
embed(input: string | string[], options: RequestOptions & EmbedOptions & {
|
|
813
1176
|
outputDtype: "int8";
|
|
1177
|
+
tokenEmbeddings?: false;
|
|
814
1178
|
}): Promise<Int8Embeddings>;
|
|
1179
|
+
embed(input: string | string[], options: RequestOptions & EmbedOptions & {
|
|
1180
|
+
outputDtype?: "float";
|
|
1181
|
+
tokenEmbeddings: true;
|
|
1182
|
+
}): Promise<HybridEmbeddings>;
|
|
815
1183
|
/**
|
|
816
1184
|
* Rerank 1-100 documents against a query, best first. Each document is 1-24,000 characters, the query at
|
|
817
1185
|
* most 8,192, and all of them together at most 256,000; more than 100 documents is a 400 `invalid_request`.
|
|
@@ -822,7 +1190,13 @@ export declare class Conare {
|
|
|
822
1190
|
}): Promise<RerankResults>;
|
|
823
1191
|
/**
|
|
824
1192
|
* Parses a file to Markdown and stores nothing: the same parser, options and result as `uploadFile`.
|
|
825
|
-
* `file` is its bytes, or `{ url }` (an https URL on a public address, fetched by the API
|
|
1193
|
+
* `file` is its bytes, or `{ url }` (an http or https URL on a public address, fetched by the API, which
|
|
1194
|
+
* reads the one page named and does not consult robots.txt; the result then carries `sourceUrl` and a page's
|
|
1195
|
+
* `title`). A URL that does not answer its file throws what its site did (`gone`, `refused`, `slow_down`,
|
|
1196
|
+
* `unreachable`, ...) with `details.status`; a page that holds no text until a browser runs its scripts
|
|
1197
|
+
* throws 422 `needs_javascript`, which `render: true` asks to have read through a browser. `links: true`
|
|
1198
|
+
* writes a web page's links as Markdown links (its menus' and footer's too); `mainContent: true` reads its
|
|
1199
|
+
* main content alone. A file OCR
|
|
826
1200
|
* reads answers once OCR is done within `wait` seconds (default 60), else `{ id, state: "parsing" }`:
|
|
827
1201
|
* `getParse(id)` answers the result (kept 24 hours). Any API key can parse, a models-only key too.
|
|
828
1202
|
*/
|
|
@@ -830,6 +1204,9 @@ export declare class Conare {
|
|
|
830
1204
|
url: string;
|
|
831
1205
|
}, options?: RequestOptions & ParseOptions & {
|
|
832
1206
|
name?: string;
|
|
1207
|
+
render?: boolean;
|
|
1208
|
+
links?: boolean;
|
|
1209
|
+
mainContent?: boolean;
|
|
833
1210
|
}): Promise<ParseResult | ParsePending>;
|
|
834
1211
|
/** A parse that answered `state: "parsing"`: still parsing, done with its result, or failed. 404 `parse_not_found` after 24 hours. */
|
|
835
1212
|
getParse(id: string, options?: RequestOptions): Promise<ParseResult | ParsePending | ParseFailed>;
|
|
@@ -873,7 +1250,7 @@ export declare class Namespace {
|
|
|
873
1250
|
* from its own first attempt. `version` is null when the server did not answer one (a server older than versions): never
|
|
874
1251
|
* pass it as `ifVersion`.
|
|
875
1252
|
*/
|
|
876
|
-
write(documents: DocumentInput | DocumentInput[], options?: RequestOptions): Promise<
|
|
1253
|
+
write(documents: DocumentInput | DocumentInput[], options?: RequestOptions): Promise<WriteResults>;
|
|
877
1254
|
/**
|
|
878
1255
|
* Store a file, up to 512 MiB, in one call: a PDF, a Word document (.docx), a PowerPoint deck (.pptx),
|
|
879
1256
|
* an Excel workbook (.xlsx), a CSV or TSV, a text or Markdown file, or an image (PNG, JPEG, WebP,
|
|
@@ -910,6 +1287,25 @@ export declare class Namespace {
|
|
|
910
1287
|
* `userPrefix` is a 400, never "every user". `excludeIds` keeps those documents out.
|
|
911
1288
|
*/
|
|
912
1289
|
query(query: string, options?: QueryOptions): Promise<QueryResults>;
|
|
1290
|
+
/**
|
|
1291
|
+
* A search answered as a record: the fields `schema` names, each filled from the passages the search read (`topK`
|
|
1292
|
+
* of them, at least 20 and at most 50) with the document, address and words that state it, or null when no passage states
|
|
1293
|
+
* it (every field null when nothing matched). `record` is null when the answer model was unavailable; `results`
|
|
1294
|
+
* are the search's. Pass the schema inline, or declared `as const`, to type each value: an `enum` field is one of
|
|
1295
|
+
* its values.
|
|
1296
|
+
*/
|
|
1297
|
+
queryRecord<const S extends RecordSchema>(query: string, schema: S, options?: QueryOptions): Promise<QueryRecord<S>>;
|
|
1298
|
+
/**
|
|
1299
|
+
* A page of the namespace's changes after `cursor`, oldest first: the documents created, changed and deleted as
|
|
1300
|
+
* its website, Cloud Storage and file sources read them (and deleted their documents). Without `cursor`, from the
|
|
1301
|
+
* start: every document it holds. Keep `nextCursor` and pass it as `cursor` next time; while `hasMore`, call
|
|
1302
|
+
* again at once. `limit` is 1-1000 rows, default 100. Rows are kept 90 days, a live document's latest whatever
|
|
1303
|
+
* its age; a cursor whose unread rows were dropped throws 410 `cursor_expired`: list again without it. Documents
|
|
1304
|
+
* written with `add` or `write` are not listed. `source` keeps the rows to one source's documents, `since` and
|
|
1305
|
+
* `until` to a time window: one re-read of a website is `{ source, since: <its sync's start> }`. A web page's
|
|
1306
|
+
* `changed` row says how it changed (`diff`).
|
|
1307
|
+
*/
|
|
1308
|
+
changes(options?: ChangesOptions): Promise<ChangesPage>;
|
|
913
1309
|
/**
|
|
914
1310
|
* The documents whose text matches a regular expression, or a near spelling (`{ query, max_distance }`),
|
|
915
1311
|
* with the lines that match, in id order. A match lies inside one passage. Pass `nextCursor` as `cursor`
|
|
@@ -929,10 +1325,22 @@ export declare class Namespace {
|
|
|
929
1325
|
}): AsyncGenerator<QueryPage>;
|
|
930
1326
|
/** One document by id, or null if it does not exist. */
|
|
931
1327
|
get(id: string, options?: RequestOptions): Promise<Document | null>;
|
|
932
|
-
/**
|
|
1328
|
+
/**
|
|
1329
|
+
* Every document (id, metadata, updatedAt), fetched page by page as you iterate. `limit` is the page size: 1-100, default 50.
|
|
1330
|
+
* `order` is `"id"` (the default) or `"newest"`: newest first by the document's date (its `date`, else its `created_at`),
|
|
1331
|
+
* else when it was last written. A namespace of more than 10,000 documents that holds documents written before
|
|
1332
|
+
* 2026-11-14 and not indexed by date since throws 400 `order_unavailable`: list it by `"id"`.
|
|
1333
|
+
*/
|
|
933
1334
|
list(options?: RequestOptions & {
|
|
934
1335
|
limit?: number;
|
|
1336
|
+
order?: "id" | "newest";
|
|
935
1337
|
}): AsyncGenerator<DocumentSummary>;
|
|
1338
|
+
/**
|
|
1339
|
+
* How many documents match `filter`, `user` and `userPrefix` (a query's), exactly; with none, the namespace's.
|
|
1340
|
+
* A document counts once, however long. `$ne`, `$nin` and `$text` throw 400 `invalid_filter`; a filter too many
|
|
1341
|
+
* documents match to count exactly throws 400 `invalid_request`: narrow it.
|
|
1342
|
+
*/
|
|
1343
|
+
count(options?: CountOptions): Promise<number>;
|
|
936
1344
|
/** Delete one document. Throws a ConareError with status 404 (`document_not_found`) if it does not exist. */
|
|
937
1345
|
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
938
1346
|
/**
|
|
@@ -963,6 +1371,19 @@ export declare class Sources {
|
|
|
963
1371
|
/**
|
|
964
1372
|
* Create a custom source: a set of documents you push into `namespace`, keyed by your own ids.
|
|
965
1373
|
* With `user`, `users.delete(user)` deletes it with the user's documents.
|
|
1374
|
+
*
|
|
1375
|
+
* With `type: "web"`, create a web source instead: Conare reads the pages at `urls` (HTML pages, PDFs and the
|
|
1376
|
+
* other file types it parses), keeps them in `namespace` and reads each again every `syncIntervalSeconds`
|
|
1377
|
+
* (a day by default, an hour at least). `failures(id)` lists the pages it could not read.
|
|
1378
|
+
* A page is never followed: the source is the pages you name.
|
|
1379
|
+
*
|
|
1380
|
+
* With `site` in place of `urls`, the source is a whole website: every sync finds the site's pages itself (its
|
|
1381
|
+
* sitemaps, feeds and links, on the site, its `docs.`, `blog.` and like hosts and the other hosts of its domain
|
|
1382
|
+
* its first page links to, but sign-ins, accounts, status pages, forums and shops; an address with a path keeps
|
|
1383
|
+
* to the section it answers at once redirects are followed, or, when that section holds no other page, to the
|
|
1384
|
+
* pages of its host it links to, with what lies under those beside it), new ones included, and keeps at most `maxPages` (2,000 by default, 5,000 at most).
|
|
1385
|
+
* Each page's documents carry `page_type` (`pricing`, `blog`, `changelog`, `docs` ...) and, when the page states
|
|
1386
|
+
* one, a `published` date, so `filter` can keep a search to them.
|
|
966
1387
|
*/
|
|
967
1388
|
create(params: {
|
|
968
1389
|
type: "custom";
|
|
@@ -970,6 +1391,21 @@ export declare class Sources {
|
|
|
970
1391
|
name?: string;
|
|
971
1392
|
user?: string;
|
|
972
1393
|
}, options?: RequestOptions): Promise<CustomSource>;
|
|
1394
|
+
create(params: {
|
|
1395
|
+
type: "web";
|
|
1396
|
+
namespace: string;
|
|
1397
|
+
urls: WebPage[];
|
|
1398
|
+
name?: string;
|
|
1399
|
+
syncIntervalSeconds?: number;
|
|
1400
|
+
}, options?: RequestOptions): Promise<WebSource>;
|
|
1401
|
+
create(params: {
|
|
1402
|
+
type: "web";
|
|
1403
|
+
namespace: string;
|
|
1404
|
+
site: string;
|
|
1405
|
+
maxPages?: number;
|
|
1406
|
+
name?: string;
|
|
1407
|
+
syncIntervalSeconds?: number;
|
|
1408
|
+
}, options?: RequestOptions): Promise<WebSource>;
|
|
973
1409
|
/**
|
|
974
1410
|
* Start connecting an app. Send the app owner to `connectUrl`; they come back to `redirectUrl`.
|
|
975
1411
|
* For your own users, connect each one into their own namespace, e.g. "user-42".
|
|
@@ -991,23 +1427,75 @@ export declare class Sources {
|
|
|
991
1427
|
source: Source;
|
|
992
1428
|
connectUrl: string | null;
|
|
993
1429
|
}>;
|
|
994
|
-
/** Set how often a connected app syncs: seconds from 300 (5 minutes) to 2592000 (30 days), or null for automatic. */
|
|
995
|
-
update(id: string, params: {
|
|
996
|
-
syncIntervalSeconds: number | null;
|
|
997
|
-
}, options?: RequestOptions): Promise<Source>;
|
|
998
1430
|
/**
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1431
|
+
* Set how often a source syncs. A connected app: seconds from 300 (5 minutes) to 2592000 (30 days), or null for
|
|
1432
|
+
* automatic. A web source (`update<WebSource>`): 3600 to 604800, or null for a day; each website is its own
|
|
1433
|
+
* source with its own interval. A Google Cloud Storage source (`update<GCSSource>`): 900 to 604800, or null for
|
|
1434
|
+
* an hour.
|
|
1435
|
+
*
|
|
1436
|
+
* A web source of `urls` takes new pages: `urls` is the whole list afterwards (as `connect` takes it), or
|
|
1437
|
+
* `addUrls` and `removeUrls` change the list it has. Its next sync starts now: a new page is read, a page it keeps
|
|
1438
|
+
* keeps its documents and is read again only when it changed, and a page taken off loses its documents.
|
|
1439
|
+
*
|
|
1440
|
+
* A web source of a `site` takes a new `maxPages` (1 to 5,000): its next sync starts now and keeps at most that
|
|
1441
|
+
* many pages; with a smaller number, the documents of the pages it no longer keeps are removed.
|
|
1442
|
+
*/
|
|
1443
|
+
update<T extends Source | GCSSource | WebSource = Source>(id: string, params: {
|
|
1444
|
+
syncIntervalSeconds?: number | null;
|
|
1445
|
+
urls?: WebPage[];
|
|
1446
|
+
addUrls?: WebPage[];
|
|
1447
|
+
removeUrls?: string[];
|
|
1448
|
+
maxPages?: number;
|
|
1449
|
+
}, options?: RequestOptions): Promise<T>;
|
|
1450
|
+
/**
|
|
1451
|
+
* One page of sources, not every source: on the first page the connected apps, then the custom, files, Google
|
|
1452
|
+
* Cloud Storage and web sources, newest first, which carry their `kind` (`custom`, `files`, `gcs`, `web`); a
|
|
1453
|
+
* connected app has none. `limit` (1-200, default 100) counts the sources with a `kind`; the connected apps all
|
|
1454
|
+
* come on the first page. `namespace`, `user` and `type` keep the sources whose field equals the value;
|
|
1455
|
+
* `health: "failing"` keeps the sources that need you (a failing source, an app whose status is `error`).
|
|
1456
|
+
* `nextCursor` is the next page's `cursor` (pass the same filters with it), null on the last. `total`, on the
|
|
1457
|
+
* first page, is how many sources every page holds: `list({ limit: 1 })` reads how many there are. A web source
|
|
1458
|
+
* comes with how many pages it has (`config.pages`), not its `urls`: `get()` answers them. For every source,
|
|
1459
|
+
* iterate `all()`, which follows `nextCursor` page by page.
|
|
1001
1460
|
*/
|
|
1002
|
-
list(
|
|
1461
|
+
list(params?: {
|
|
1462
|
+
namespace?: string;
|
|
1463
|
+
user?: string;
|
|
1464
|
+
type?: string;
|
|
1465
|
+
health?: "failing";
|
|
1466
|
+
limit?: number;
|
|
1467
|
+
cursor?: string;
|
|
1468
|
+
}, options?: RequestOptions): Promise<{
|
|
1469
|
+
data: Array<Source | CustomSource | FilesSource | GCSSource | WebSource>;
|
|
1470
|
+
nextCursor: string | null;
|
|
1471
|
+
total?: number;
|
|
1472
|
+
}>;
|
|
1473
|
+
/** Every source `list()` pages through, fetched page by page as you iterate, with its filters and page size. */
|
|
1474
|
+
all(params?: {
|
|
1475
|
+
namespace?: string;
|
|
1476
|
+
user?: string;
|
|
1477
|
+
type?: string;
|
|
1478
|
+
health?: "failing";
|
|
1479
|
+
limit?: number;
|
|
1480
|
+
}, options?: RequestOptions): AsyncGenerator<Source | CustomSource | FilesSource | GCSSource | WebSource>;
|
|
1481
|
+
/**
|
|
1482
|
+
* How many sources write into each namespace, by type, and how many of them fail or sync now: the sources
|
|
1483
|
+
* `list()` pages through, counted, without the sources themselves (one read, however many there are). A source
|
|
1484
|
+
* fails as `list({ health: "failing" })` lists it; one syncs while a sync of it runs, or while a connected app is
|
|
1485
|
+
* `syncing` or `connecting`. `namespace` counts that namespace's alone. Namespaces come by name, each one's types
|
|
1486
|
+
* the most sources first.
|
|
1487
|
+
*/
|
|
1488
|
+
summary(params?: {
|
|
1489
|
+
namespace?: string;
|
|
1490
|
+
}, options?: RequestOptions): Promise<SourceSummary>;
|
|
1003
1491
|
/** One source by id. */
|
|
1004
|
-
get(id: string, options?: RequestOptions): Promise<Source | CustomSource | FilesSource | GCSSource>;
|
|
1492
|
+
get(id: string, options?: RequestOptions): Promise<Source | CustomSource | FilesSource | GCSSource | WebSource>;
|
|
1005
1493
|
/**
|
|
1006
1494
|
* Start a sync now. `full: true` re-reads everything the app holds instead of what changed: documents
|
|
1007
1495
|
* that changed are rewritten and ones Conare no longer keeps are deleted. It is for Gmail and the apps
|
|
1008
|
-
* Conare reads itself (other apps answer 400), and
|
|
1496
|
+
* Conare reads itself (other apps answer 400), and only documents that changed are indexed again (rows cost what `cost.usdPerMillionRows` says: nothing where connectors are free).
|
|
1009
1497
|
*
|
|
1010
|
-
* A connected app answers the `Source`, due to sync now. A Google Cloud Storage source answers the sync
|
|
1498
|
+
* A connected app answers the `Source`, due to sync now. A Google Cloud Storage or web source answers the sync
|
|
1011
1499
|
* `Run` it queued (409 `run_active` while one is queued or running). A custom or files source has nothing
|
|
1012
1500
|
* to sync: 409 `push_source`. A `Run` has `state` and a `Source` has `status`: `"state" in result` tells
|
|
1013
1501
|
* them apart.
|
|
@@ -1015,15 +1503,37 @@ export declare class Sources {
|
|
|
1015
1503
|
sync(id: string, options?: RequestOptions & {
|
|
1016
1504
|
full?: boolean;
|
|
1017
1505
|
}): Promise<Source | Run>;
|
|
1506
|
+
/**
|
|
1507
|
+
* What a Google Cloud Storage or web source could not keep, in key order: `nextCursor` is the next page's
|
|
1508
|
+
* `cursor`, null at the end.
|
|
1509
|
+
*/
|
|
1510
|
+
failures(id: string, params?: {
|
|
1511
|
+
cursor?: string;
|
|
1512
|
+
limit?: number;
|
|
1513
|
+
}, options?: RequestOptions): Promise<{
|
|
1514
|
+
data: SourceFailure[];
|
|
1515
|
+
nextCursor: string | null;
|
|
1516
|
+
}>;
|
|
1018
1517
|
/**
|
|
1019
1518
|
* Disconnect a source. Pass `deleteDocuments: true` to also delete what it synced; without it a
|
|
1020
|
-
* connected app's and a custom source's documents stay. A Google Cloud Storage
|
|
1021
|
-
* source's documents always go with it
|
|
1022
|
-
*
|
|
1519
|
+
* connected app's and a custom source's documents stay. A Google Cloud Storage, web or files
|
|
1520
|
+
* source's documents always go with it, at the end of its grace: an hour, or `graceSeconds` (0 to
|
|
1521
|
+
* 86,400; 0 deletes them now). Until its `deletesAt` they stay searchable and `restore` brings it
|
|
1522
|
+
* back. Deleted again in its grace, `graceSeconds: 0` deletes it now (it can no longer be restored); another
|
|
1523
|
+
* value brings `deletesAt` nearer, never later. A custom source's delete is a run, which `runs.get` follows
|
|
1524
|
+
* until the source is `deleted`. It needs a key that writes (in the console, an organization admin).
|
|
1023
1525
|
*/
|
|
1024
1526
|
delete(id: string, options?: RequestOptions & {
|
|
1025
1527
|
deleteDocuments?: boolean;
|
|
1528
|
+
graceSeconds?: number;
|
|
1026
1529
|
}): Promise<void>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Bring back a Google Cloud Storage, web or files source deleted with a grace, before its
|
|
1532
|
+
* `deletesAt`: active again with every document it held, its next sync due now. An active source
|
|
1533
|
+
* is answered as it is; once its delete has started it answers 409 `delete_started`. It takes what
|
|
1534
|
+
* `delete` takes: a key that writes (in the console, an organization admin).
|
|
1535
|
+
*/
|
|
1536
|
+
restore(id: string, options?: RequestOptions): Promise<CustomSource | FilesSource | GCSSource | WebSource>;
|
|
1027
1537
|
/** The apps you can connect. */
|
|
1028
1538
|
types(options?: RequestOptions): Promise<SourceType[]>;
|
|
1029
1539
|
}
|