teak-sdk 1.0.86 → 1.0.88
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 +3 -3
- package/{dist/sdk.js → index.js} +277 -60
- package/package.json +3 -18
- package/{dist/types/client → types}/authDiscovery.d.ts +3 -3
- package/{dist/types → types/convex}/devUrls.d.ts +0 -1
- package/{dist/types → types/convex}/shared/constants.d.ts +11 -36
- package/types/convex/shared/filesOrigins.d.ts +4 -0
- package/types/convex/shared/folders.d.ts +27 -0
- package/types/convex/shared/oauthSurfaces.d.ts +2 -0
- package/types/convex/shared/oauthUrl.d.ts +2 -0
- package/types/convex/shared/tags.d.ts +37 -0
- package/types/convex/shared/utils/codePoints.d.ts +2 -0
- package/types/convex/shared/utils/formatBytes.d.ts +1 -0
- package/types/convex/shared/workosResources.d.ts +7 -0
- package/types/index.d.ts +569 -0
- package/types/oauthCredentials.d.ts +10 -0
- package/dist/types/client/sdk.d.ts +0 -253
- package/dist/types/shared/workosResources.d.ts +0 -4
- /package/{dist/types → types/convex}/shared/boundedResponse.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/fileFormats.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/markdown.d.ts +0 -0
- /package/{dist/types/client → types}/workosConnect.d.ts +0 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
export { formatBytes } from "./convex/shared/utils/formatBytes.js";
|
|
2
|
+
export { type AuthDiscovery, discoverAuthServer, type OAuthSurface, validateOAuthUrl, } from "./authDiscovery.js";
|
|
3
|
+
export { type CredentialBinding, isRefreshTokenDead, isWorkosCredential, matchesBinding, refreshAndSave, } from "./oauthCredentials.js";
|
|
4
|
+
export { type ConnectTokenResult, type ConnectTokens, createConnectAuthorizeUrl, createPkceChallenge, disconnectConnectGrant, fetchConnectOwnerId, randomBase64Url, requestConnectTokens, WORKOS_CONNECT_SCOPE, } from "./workosConnect.js";
|
|
5
|
+
import { type CardType } from "./convex/shared/constants.js";
|
|
6
|
+
import type { FileKind, FilePreviewFacts } from "./convex/shared/fileFormats.js";
|
|
7
|
+
import type { FOLDER_COLORS } from "./convex/shared/folders.js";
|
|
8
|
+
export type { CardType } from "./convex/shared/constants.js";
|
|
9
|
+
export declare const CARD_TYPES: readonly ["text", "link", "image", "video", "audio", "document", "palette", "quote"];
|
|
10
|
+
export declare const CARD_SORTS: readonly ["newest", "oldest", "relevance", "shuffle"];
|
|
11
|
+
export declare const ERROR_CODES: readonly ["AUTH_REQUIRED", "BAD_REQUEST", "CARD_LIMIT_REACHED", "CONFIG_ERROR", "CONFLICT", "CONTENT_TOO_LARGE", "FILE_TOO_LARGE", "FOLDER_LIMIT", "FORBIDDEN", "IN_PROGRESS", "INTERNAL_ERROR", "INVALID_API_KEY", "INVALID_INPUT", "INVALID_STORAGE_KEY", "INVALID_UTF8", "LIMIT_REACHED", "METHOD_NOT_ALLOWED", "NETWORK_ERROR", "NOT_FOUND", "NO_CONTENT", "NOT_IN_TRASH", "PARSE_ERROR", "RATE_LIMITED", "REQUEST_FAILED", "SERVICE_UNAVAILABLE", "SMART_FOLDER", "TAG_EXISTS", "TAG_OPERATION_RUNNING", "TIMEOUT", "TYPE_MISMATCH", "UNAUTHORIZED", "UNSUPPORTED_TYPE"];
|
|
12
|
+
export type CardSort = (typeof CARD_SORTS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* How a search finds cards: `hybrid` (the API's default) matches words and
|
|
15
|
+
* meaning, `keyword` words only, `semantic` meaning only.
|
|
16
|
+
*/
|
|
17
|
+
export type SearchMode = "hybrid" | "keyword" | "semantic";
|
|
18
|
+
export type TeakApiErrorCode = (typeof ERROR_CODES)[number];
|
|
19
|
+
export type FetchLike = typeof fetch;
|
|
20
|
+
export interface TokenProvider {
|
|
21
|
+
getAccessToken: () => Promise<string | null> | string | null;
|
|
22
|
+
onUnauthorized?: (rejectedToken: string) => Promise<string | null> | string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface Card {
|
|
25
|
+
aiSummary: string | null;
|
|
26
|
+
aiTags: string[];
|
|
27
|
+
aiTranscript: string | null;
|
|
28
|
+
appUrl: string;
|
|
29
|
+
/** When the card was archived, or null. */
|
|
30
|
+
archivedAt: number | null;
|
|
31
|
+
/** Bar heights 0-100: 45 for a grid card, 200 for a player. */
|
|
32
|
+
audioWaveform: {
|
|
33
|
+
detail: number[];
|
|
34
|
+
grid: number[];
|
|
35
|
+
} | null;
|
|
36
|
+
/** Your cards that link to this one, most recently updated first. */
|
|
37
|
+
backlinks?: CardLinkRef[];
|
|
38
|
+
backlinksTruncated?: boolean;
|
|
39
|
+
colors: Array<{
|
|
40
|
+
hex: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
}>;
|
|
43
|
+
compactUrl: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* When the link was marked read, watched, bought or done, or null.
|
|
46
|
+
* Servers that predate done states leave it out.
|
|
47
|
+
*/
|
|
48
|
+
completedAt?: number | null;
|
|
49
|
+
content: string;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
detailUrl: string | null;
|
|
52
|
+
fileExtension: string | null;
|
|
53
|
+
fileKind: FileKind | null;
|
|
54
|
+
fileLanguage: string | null;
|
|
55
|
+
fileName: string | null;
|
|
56
|
+
filePreview: FilePreviewFacts | null;
|
|
57
|
+
fileSize: number | null;
|
|
58
|
+
fileUrl: string | null;
|
|
59
|
+
/** Ids of the folders the card is in. */
|
|
60
|
+
folderIds: string[];
|
|
61
|
+
id: string;
|
|
62
|
+
/** Archived cards are hidden from the library but still count. */
|
|
63
|
+
isArchived: boolean;
|
|
64
|
+
isDeleted: boolean;
|
|
65
|
+
isFavorited: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tagged `secret` or `hidden`: left out of lists and searches unless the
|
|
68
|
+
* search names one of those tags (`#secret`). Servers that
|
|
69
|
+
* predate hidden cards leave it out.
|
|
70
|
+
*/
|
|
71
|
+
isHidden?: boolean;
|
|
72
|
+
linkAuthor: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* What a link is (`article`, `movie`, `product`…), or null. A plain
|
|
75
|
+
* string: new categories are added over time.
|
|
76
|
+
*/
|
|
77
|
+
linkCategory?: string | null;
|
|
78
|
+
linkFacts: Array<{
|
|
79
|
+
label: string;
|
|
80
|
+
value: string;
|
|
81
|
+
}>;
|
|
82
|
+
linkPreviewImageUrl: string | null;
|
|
83
|
+
linkPreviewMedia: Array<{
|
|
84
|
+
type: "image" | "video";
|
|
85
|
+
url: string;
|
|
86
|
+
contentType?: string;
|
|
87
|
+
width?: number;
|
|
88
|
+
height?: number;
|
|
89
|
+
posterUrl?: string;
|
|
90
|
+
posterContentType?: string;
|
|
91
|
+
posterWidth?: number;
|
|
92
|
+
posterHeight?: number;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* A product link's price: `amount` in the page's currency, `currency` an
|
|
96
|
+
* ISO 4217 code or null. Null for cards without a price.
|
|
97
|
+
*/
|
|
98
|
+
linkPrice: {
|
|
99
|
+
amount: number;
|
|
100
|
+
currency: string | null;
|
|
101
|
+
} | null;
|
|
102
|
+
linkPublishedAt: string | null;
|
|
103
|
+
linkPublisher: string | null;
|
|
104
|
+
linkSiteName: string | null;
|
|
105
|
+
/**
|
|
106
|
+
* Cards this card links to with `[[Title|teak:<id>]]`, in order. Only on
|
|
107
|
+
* single-card responses (`cards.get`, update, favorite, done, create).
|
|
108
|
+
*/
|
|
109
|
+
links?: CardLinkRef[];
|
|
110
|
+
linksTruncated?: boolean;
|
|
111
|
+
metadataDescription: string | null;
|
|
112
|
+
metadataStatus: string | null;
|
|
113
|
+
metadataTitle: string | null;
|
|
114
|
+
mimeType: string | null;
|
|
115
|
+
notes: string | null;
|
|
116
|
+
placeholderUrl: string | null;
|
|
117
|
+
processingStatus: Record<string, unknown> | null;
|
|
118
|
+
screenshotUrl: string | null;
|
|
119
|
+
/**
|
|
120
|
+
* The title of the page in `sourceUrl`. Servers that predate sources
|
|
121
|
+
* leave it out.
|
|
122
|
+
*/
|
|
123
|
+
sourceTitle?: string | null;
|
|
124
|
+
/**
|
|
125
|
+
* The page the card was saved from, such as the page a quote was selected
|
|
126
|
+
* on. Servers that predate sources leave it out.
|
|
127
|
+
*/
|
|
128
|
+
sourceUrl?: string | null;
|
|
129
|
+
tags: string[];
|
|
130
|
+
/** True when linkPreviewImageUrl is an image chosen for the link. */
|
|
131
|
+
thumbnailOverridden: boolean;
|
|
132
|
+
thumbnailUrl: string | null;
|
|
133
|
+
type: CardType | string;
|
|
134
|
+
updatedAt: number;
|
|
135
|
+
url: string | null;
|
|
136
|
+
/** Hover preview strip, `frames * frameWidth` wide; the URL expires. */
|
|
137
|
+
videoScrub: {
|
|
138
|
+
frameHeight: number;
|
|
139
|
+
frameWidth: number;
|
|
140
|
+
frames: number;
|
|
141
|
+
url: string;
|
|
142
|
+
} | null;
|
|
143
|
+
}
|
|
144
|
+
/** A linked card; `missing` when it's in Trash, deleted or not yours. */
|
|
145
|
+
export interface CardLinkRef {
|
|
146
|
+
id: string;
|
|
147
|
+
missing: boolean;
|
|
148
|
+
title: string | null;
|
|
149
|
+
type: CardType | string | null;
|
|
150
|
+
}
|
|
151
|
+
export interface CardLinks {
|
|
152
|
+
backlinks: CardLinkRef[];
|
|
153
|
+
backlinksTruncated: boolean;
|
|
154
|
+
links: CardLinkRef[];
|
|
155
|
+
linksTruncated: boolean;
|
|
156
|
+
}
|
|
157
|
+
export type CardListItem = Partial<Card> & Pick<Card, "aiTags" | "appUrl" | "createdAt" | "id" | "isFavorited" | "tags" | "type" | "updatedAt">;
|
|
158
|
+
export interface PageInfo {
|
|
159
|
+
hasMore: boolean;
|
|
160
|
+
nextCursor: string | null;
|
|
161
|
+
}
|
|
162
|
+
export interface CardsPage {
|
|
163
|
+
items: CardListItem[];
|
|
164
|
+
pageInfo: PageInfo;
|
|
165
|
+
/** With a query and `sort: "relevance"`: whether the top results were scored. */
|
|
166
|
+
relevanceRanked?: boolean;
|
|
167
|
+
/** With a query: the mode that ran (`keyword` when meaning search could not). */
|
|
168
|
+
searchMode?: SearchMode;
|
|
169
|
+
/**
|
|
170
|
+
* For similar cards: `pending` while the card is still being read, and
|
|
171
|
+
* `unavailable` for a card in Trash or not found.
|
|
172
|
+
*/
|
|
173
|
+
similarity?: "ok" | "pending" | "unavailable";
|
|
174
|
+
}
|
|
175
|
+
export interface CardChangesResponse {
|
|
176
|
+
deletedIds: string[];
|
|
177
|
+
items: Card[];
|
|
178
|
+
pageInfo: PageInfo;
|
|
179
|
+
}
|
|
180
|
+
export interface TagSummary {
|
|
181
|
+
count: number;
|
|
182
|
+
name: string;
|
|
183
|
+
}
|
|
184
|
+
export type FolderColor = (typeof FOLDER_COLORS)[number];
|
|
185
|
+
export interface Folder {
|
|
186
|
+
/**
|
|
187
|
+
* Cards in a manual folder that are not archived or in Trash; null for a
|
|
188
|
+
* smart folder, whose cards are found when listed.
|
|
189
|
+
*/
|
|
190
|
+
cardCount: number | null;
|
|
191
|
+
color: FolderColor | null;
|
|
192
|
+
createdAt: number;
|
|
193
|
+
id: string;
|
|
194
|
+
/** Manual folders hold the cards put in them; smart ones save a search. */
|
|
195
|
+
kind: "manual" | "smart";
|
|
196
|
+
name: string;
|
|
197
|
+
/** A smart folder's search; null for a manual folder. */
|
|
198
|
+
query: string | null;
|
|
199
|
+
updatedAt: number;
|
|
200
|
+
}
|
|
201
|
+
export type TagOperationKind = "rename" | "merge" | "delete";
|
|
202
|
+
export type TagOperationStatus = "running" | "completed" | "failed";
|
|
203
|
+
/** A library-wide tag rename, merge or delete, finished in the background. */
|
|
204
|
+
export interface TagOperation {
|
|
205
|
+
/** Cards rewritten so far. */
|
|
206
|
+
changed: number;
|
|
207
|
+
completedAt: number | null;
|
|
208
|
+
createdAt: number;
|
|
209
|
+
error: string | null;
|
|
210
|
+
/** The tag being changed, lowercased. */
|
|
211
|
+
from: string;
|
|
212
|
+
id: string;
|
|
213
|
+
kind: TagOperationKind;
|
|
214
|
+
/** Cards looked at so far. */
|
|
215
|
+
processed: number;
|
|
216
|
+
status: TagOperationStatus;
|
|
217
|
+
/** The new name (rename) or the tag merged into (merge). */
|
|
218
|
+
to: string | null;
|
|
219
|
+
/** Cards carrying the tag when the change started. */
|
|
220
|
+
total: number;
|
|
221
|
+
updatedAt: number;
|
|
222
|
+
}
|
|
223
|
+
export interface FolderCardsResult {
|
|
224
|
+
failedIds: string[];
|
|
225
|
+
/** Failed cards that are already in the most folders a card can be in. */
|
|
226
|
+
folderLimitIds: string[];
|
|
227
|
+
updatedIds: string[];
|
|
228
|
+
}
|
|
229
|
+
export interface CreateCardInput {
|
|
230
|
+
/**
|
|
231
|
+
* Optional card type: `text`, `link`, `image`, `video`, `audio`,
|
|
232
|
+
* `document`, `palette` or `quote`. Set it to `text` to store raw Markdown
|
|
233
|
+
* exactly; omit it to keep automatic URL, quote, and palette detection.
|
|
234
|
+
* @default inferred
|
|
235
|
+
*/
|
|
236
|
+
cardType?: CardType;
|
|
237
|
+
/**
|
|
238
|
+
* Markdown or plain text body for the card. Prefer this for notes; use `url`
|
|
239
|
+
* when saving a link.
|
|
240
|
+
*/
|
|
241
|
+
content?: string;
|
|
242
|
+
/** The `ETag` the upload `PUT` returned, for a file card. */
|
|
243
|
+
fileEtag?: string;
|
|
244
|
+
/** The `fileKey` from `uploads.create`, for a file card. */
|
|
245
|
+
fileKey?: string;
|
|
246
|
+
/** The uploaded file's name, for a file card. */
|
|
247
|
+
fileName?: string;
|
|
248
|
+
/** The uploaded file's size in bytes, for a file card. */
|
|
249
|
+
fileSize?: number;
|
|
250
|
+
/** The uploaded file's MIME type, for a file card. */
|
|
251
|
+
mimeType?: string;
|
|
252
|
+
/** Free-form notes attached to the card. */
|
|
253
|
+
notes?: string | null;
|
|
254
|
+
/**
|
|
255
|
+
* A free label for what saved the card (extension, CLI, API, and so on),
|
|
256
|
+
* kept in its metadata. For the page the card came from, use `sourceUrl`.
|
|
257
|
+
*/
|
|
258
|
+
source?: string;
|
|
259
|
+
/** The page's title, beside `sourceUrl`; cut to 300 characters. */
|
|
260
|
+
sourceTitle?: string;
|
|
261
|
+
/**
|
|
262
|
+
* The page the card came from, such as the page a quote was selected on:
|
|
263
|
+
* an http or https URL of at most 2,048 characters. Unlike `url`, it never
|
|
264
|
+
* makes the card a link.
|
|
265
|
+
*/
|
|
266
|
+
sourceUrl?: string;
|
|
267
|
+
/** Tags to apply on create. */
|
|
268
|
+
tags?: string[];
|
|
269
|
+
/**
|
|
270
|
+
* URL to save as a link card. Teak may classify the type automatically when
|
|
271
|
+
* `cardType` is omitted.
|
|
272
|
+
*/
|
|
273
|
+
url?: string;
|
|
274
|
+
}
|
|
275
|
+
export interface UpdateCardInput {
|
|
276
|
+
content?: string;
|
|
277
|
+
/** Replaces the card's folders; an empty list takes it out of every folder. */
|
|
278
|
+
folderIds?: string[];
|
|
279
|
+
isArchived?: boolean;
|
|
280
|
+
metadataTitle?: string | null;
|
|
281
|
+
notes?: string | null;
|
|
282
|
+
/** AI tags to drop. `tags` replaces only the card's own tags. */
|
|
283
|
+
removeAiTags?: string[];
|
|
284
|
+
tags?: string[];
|
|
285
|
+
url?: string;
|
|
286
|
+
}
|
|
287
|
+
export interface Me {
|
|
288
|
+
cardCount: number;
|
|
289
|
+
/** Null on Pro, which has no card limit. */
|
|
290
|
+
cardLimit: number | null;
|
|
291
|
+
email: string;
|
|
292
|
+
id: string;
|
|
293
|
+
name?: string;
|
|
294
|
+
plan: "free" | "pro";
|
|
295
|
+
settingsUrl: string;
|
|
296
|
+
}
|
|
297
|
+
export interface ExportJob {
|
|
298
|
+
cardCount: number | null;
|
|
299
|
+
completedAt: number | null;
|
|
300
|
+
createdAt: number;
|
|
301
|
+
downloadUrl: string | null;
|
|
302
|
+
expiresAt: number | null;
|
|
303
|
+
failureClass: string | null;
|
|
304
|
+
filesIncluded: number | null;
|
|
305
|
+
filesOmitted: number | null;
|
|
306
|
+
id: string;
|
|
307
|
+
processedCount: number | null;
|
|
308
|
+
sizeBytes: number | null;
|
|
309
|
+
stage: "snapshotting" | "archiving" | null;
|
|
310
|
+
status: "pending" | "running" | "ready" | "failed" | "canceled" | "expired";
|
|
311
|
+
updatedAt: number;
|
|
312
|
+
}
|
|
313
|
+
export interface LatestExport {
|
|
314
|
+
canStartNew: boolean;
|
|
315
|
+
job: ExportJob | null;
|
|
316
|
+
nextAvailableAt: number | null;
|
|
317
|
+
}
|
|
318
|
+
export interface RequestOptions {
|
|
319
|
+
/** Makes a retried create or bulk request safe to repeat. */
|
|
320
|
+
idempotencyKey?: string;
|
|
321
|
+
}
|
|
322
|
+
export interface CreateUploadInput {
|
|
323
|
+
fileName: string;
|
|
324
|
+
fileSize: number;
|
|
325
|
+
mimeType: string;
|
|
326
|
+
}
|
|
327
|
+
/** A link image upload: JPEG, PNG, WebP, GIF or AVIF, under 20 MB. */
|
|
328
|
+
export interface CreateThumbnailUploadInput {
|
|
329
|
+
fileSize: number;
|
|
330
|
+
mimeType: string;
|
|
331
|
+
}
|
|
332
|
+
export interface CreateUploadResponse {
|
|
333
|
+
expiresIn: number;
|
|
334
|
+
fileKey: string;
|
|
335
|
+
maxFileSize: number;
|
|
336
|
+
method: "PUT";
|
|
337
|
+
uploadUrl: string;
|
|
338
|
+
}
|
|
339
|
+
export interface CreateCardResponse {
|
|
340
|
+
appUrl: string;
|
|
341
|
+
card?: Card;
|
|
342
|
+
cardId: string;
|
|
343
|
+
status: "created";
|
|
344
|
+
}
|
|
345
|
+
export interface RefreshCardResponse {
|
|
346
|
+
cardId: string;
|
|
347
|
+
requestedAt: number;
|
|
348
|
+
status: "queued";
|
|
349
|
+
}
|
|
350
|
+
/** An arXiv link's PDF saved as a document card (POST /v1/cards/:id/save-pdf). */
|
|
351
|
+
export interface SavedPdf {
|
|
352
|
+
/** The document card holding the PDF. */
|
|
353
|
+
cardId: string;
|
|
354
|
+
/** False when an earlier save already made that card. */
|
|
355
|
+
created: boolean;
|
|
356
|
+
}
|
|
357
|
+
/** A card's full stored text (GET /v1/cards/:id/content). */
|
|
358
|
+
export interface CardContent {
|
|
359
|
+
cardId: string;
|
|
360
|
+
/** Characters in the full stored text. */
|
|
361
|
+
charCount: number;
|
|
362
|
+
/**
|
|
363
|
+
* document: extracted from the card's file; transcript: its speech;
|
|
364
|
+
* content: a text or quote card's written text.
|
|
365
|
+
*/
|
|
366
|
+
kind: "document" | "transcript" | "content";
|
|
367
|
+
text: string;
|
|
368
|
+
/** The document is longer than Teak keeps. */
|
|
369
|
+
truncated: boolean;
|
|
370
|
+
}
|
|
371
|
+
export type BulkCardsOperation = "create" | "update" | "favorite" | "delete" | "archive" | "unarchive" | "addTags" | "removeTags" | "restore";
|
|
372
|
+
export interface BulkCardsResponse {
|
|
373
|
+
/** The `cardId` of every item that failed, to retry just those. */
|
|
374
|
+
failedIds: string[];
|
|
375
|
+
operation: BulkCardsOperation;
|
|
376
|
+
results: unknown[];
|
|
377
|
+
summary: {
|
|
378
|
+
failed: number;
|
|
379
|
+
succeeded: number;
|
|
380
|
+
total: number;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/** Archived cards outside Trash: left out by default. */
|
|
384
|
+
export type ArchivedFilter = "exclude" | "only" | "include";
|
|
385
|
+
export declare class TeakApiError extends Error {
|
|
386
|
+
code: TeakApiErrorCode;
|
|
387
|
+
requestId?: string;
|
|
388
|
+
retryAt?: number;
|
|
389
|
+
status?: number;
|
|
390
|
+
constructor(code: TeakApiErrorCode, message?: string, init?: {
|
|
391
|
+
requestId?: string;
|
|
392
|
+
retryAt?: number;
|
|
393
|
+
status?: number;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export declare const staticTokenProvider: (token: string) => TokenProvider;
|
|
397
|
+
export declare const normalizeLimit: (limit?: number) => number;
|
|
398
|
+
export declare const buildCardsSearchParams: (input: {
|
|
399
|
+
archived?: ArchivedFilter;
|
|
400
|
+
/** Only cards in this folder id. */
|
|
401
|
+
folder?: string;
|
|
402
|
+
createdAfter?: number;
|
|
403
|
+
createdBefore?: number;
|
|
404
|
+
cursor?: string;
|
|
405
|
+
favorited?: boolean;
|
|
406
|
+
hex?: string | readonly string[];
|
|
407
|
+
hue?: string | readonly string[];
|
|
408
|
+
include?: string;
|
|
409
|
+
limit?: number;
|
|
410
|
+
/** How `query` finds cards; the API defaults to `hybrid`. */
|
|
411
|
+
mode?: SearchMode;
|
|
412
|
+
/**
|
|
413
|
+
* Search text. Accepts qualifiers: `tag:design` or `#design`, `type:link`,
|
|
414
|
+
* `is:fav`, `is:archived`, `site:github.com`, `folder:"Reading list"`,
|
|
415
|
+
* `price:<100` (also `>`, `<=`, `>=` and `=`), `text:"total due"` (only
|
|
416
|
+
* the words Teak read in images, video thumbnails, link previews and scanned
|
|
417
|
+
* PDFs) and `"quoted phrases"`.
|
|
418
|
+
*/
|
|
419
|
+
query?: string;
|
|
420
|
+
/** Required with `sort: "shuffle"`: the same seed gives the same order. */
|
|
421
|
+
shuffleSeed?: number;
|
|
422
|
+
/** A card id: only the cards closest to it in meaning. */
|
|
423
|
+
similarTo?: string;
|
|
424
|
+
sort?: CardSort;
|
|
425
|
+
style?: string | readonly string[];
|
|
426
|
+
tag?: string;
|
|
427
|
+
trashed?: boolean;
|
|
428
|
+
type?: CardType | string | readonly (CardType | string)[];
|
|
429
|
+
}) => string;
|
|
430
|
+
export declare const createTeakClient: (options: {
|
|
431
|
+
baseUrl?: string;
|
|
432
|
+
fetch?: FetchLike;
|
|
433
|
+
timeoutMs?: number;
|
|
434
|
+
tokenProvider: TokenProvider;
|
|
435
|
+
userAgent?: string;
|
|
436
|
+
}) => {
|
|
437
|
+
cards: {
|
|
438
|
+
bulk: (operation: BulkCardsOperation, items: unknown[], requestOptions?: RequestOptions) => Promise<BulkCardsResponse>;
|
|
439
|
+
changes: (input: {
|
|
440
|
+
cursor?: string;
|
|
441
|
+
limit?: number;
|
|
442
|
+
since: number;
|
|
443
|
+
}) => Promise<CardChangesResponse>;
|
|
444
|
+
create: (input: CreateCardInput, requestOptions?: RequestOptions) => Promise<CreateCardResponse>;
|
|
445
|
+
/**
|
|
446
|
+
* The card's full stored text: document text, transcript, or a text
|
|
447
|
+
* card's content. Throws NO_CONTENT when the card has none.
|
|
448
|
+
*/
|
|
449
|
+
content: (id: string) => Promise<CardContent>;
|
|
450
|
+
/** Moves the card to Trash, or deletes it for good with `permanent`. */
|
|
451
|
+
delete: (id: string, deleteOptions?: {
|
|
452
|
+
permanent?: boolean;
|
|
453
|
+
}) => Promise<null>;
|
|
454
|
+
/** The ID of a saved card with exactly this URL, or null. */
|
|
455
|
+
duplicate: (url: string) => Promise<string | null>;
|
|
456
|
+
favorites: (input?: Parameters<(params: Parameters<typeof buildCardsSearchParams>[0]) => string>[0]) => Promise<CardsPage>;
|
|
457
|
+
get: (id: string) => Promise<Card>;
|
|
458
|
+
/** Cards this card links to with `[[…]]`, and cards linking to it. */
|
|
459
|
+
links: (id: string) => Promise<CardLinks>;
|
|
460
|
+
list: (input?: Parameters<(params: Parameters<typeof buildCardsSearchParams>[0]) => string>[0]) => Promise<CardsPage>;
|
|
461
|
+
/**
|
|
462
|
+
* A signed URL for a link card's new image; `setThumbnail` with bytes
|
|
463
|
+
* does this for you.
|
|
464
|
+
*/
|
|
465
|
+
createThumbnailUpload: (id: string, input: CreateThumbnailUploadInput) => Promise<CreateUploadResponse>;
|
|
466
|
+
/** Refreshes summary, tags and link preview; it finishes in the background. */
|
|
467
|
+
refresh: (id: string) => Promise<RefreshCardResponse>;
|
|
468
|
+
/**
|
|
469
|
+
* Goes back to the image Teak found for a link card and deletes the one
|
|
470
|
+
* that replaced it. Changes nothing when the card has its own image.
|
|
471
|
+
*/
|
|
472
|
+
resetThumbnail: (id: string) => Promise<Card>;
|
|
473
|
+
restore: (id: string) => Promise<null>;
|
|
474
|
+
/** The cards closest in meaning to one card; never the card itself. */
|
|
475
|
+
similar: (id: string, input?: Parameters<(params: Parameters<typeof buildCardsSearchParams>[0]) => string>[0]) => Promise<CardsPage>;
|
|
476
|
+
search: (input?: Parameters<(params: Parameters<typeof buildCardsSearchParams>[0]) => string>[0]) => Promise<CardsPage>;
|
|
477
|
+
/** Archives the card (hidden from the library, not deleted) or returns it. */
|
|
478
|
+
setArchived: (id: string, isArchived: boolean) => Promise<Card>;
|
|
479
|
+
/**
|
|
480
|
+
* Replaces a link card's image: uploads `bytes` (JPEG, PNG, WebP, GIF or
|
|
481
|
+
* AVIF, under 20 MB) and applies them. Pass `{ fileKey }` instead to
|
|
482
|
+
* apply an upload made with `createThumbnailUpload`.
|
|
483
|
+
*/
|
|
484
|
+
setThumbnail: (id: string, image: BodyInit | {
|
|
485
|
+
fileKey: string;
|
|
486
|
+
}, mimeType?: string) => Promise<Card>;
|
|
487
|
+
/**
|
|
488
|
+
* Saves an arXiv link's paper as its own document card. Saving the same
|
|
489
|
+
* link again returns that card with `created: false`.
|
|
490
|
+
*/
|
|
491
|
+
savePdf: (id: string) => Promise<SavedPdf>;
|
|
492
|
+
/**
|
|
493
|
+
* Marks a link card read, watched, bought or done (`done: true`), or
|
|
494
|
+
* not; repeating a call changes nothing. Only link cards can be marked.
|
|
495
|
+
*/
|
|
496
|
+
setDone: (id: string, done: boolean) => Promise<Card>;
|
|
497
|
+
setFavorite: (id: string, isFavorited: boolean) => Promise<Card>;
|
|
498
|
+
update: (id: string, input: UpdateCardInput) => Promise<Card>;
|
|
499
|
+
};
|
|
500
|
+
exports: {
|
|
501
|
+
latest: () => Promise<LatestExport>;
|
|
502
|
+
start: () => Promise<ExportJob>;
|
|
503
|
+
};
|
|
504
|
+
folders: {
|
|
505
|
+
/**
|
|
506
|
+
* Adds up to 100 cards; cards already in the folder are left as they
|
|
507
|
+
* are. A smart folder refuses cards (409 SMART_FOLDER).
|
|
508
|
+
*/
|
|
509
|
+
addCards: (id: string, cardIds: string[]) => Promise<FolderCardsResult>;
|
|
510
|
+
/**
|
|
511
|
+
* Creates a folder; `{ kind: "smart", query }` saves a search, whose
|
|
512
|
+
* cards are whatever matches it when listed.
|
|
513
|
+
*/
|
|
514
|
+
create: (input: {
|
|
515
|
+
color?: FolderColor;
|
|
516
|
+
kind?: "manual";
|
|
517
|
+
name: string;
|
|
518
|
+
} | {
|
|
519
|
+
color?: FolderColor;
|
|
520
|
+
kind: "smart";
|
|
521
|
+
name: string;
|
|
522
|
+
query: string;
|
|
523
|
+
}) => Promise<Folder>;
|
|
524
|
+
/** Deletes the folder; its cards are kept. */
|
|
525
|
+
delete: (id: string) => Promise<null>;
|
|
526
|
+
get: (id: string) => Promise<Folder>;
|
|
527
|
+
/** Every folder, sorted by name. */
|
|
528
|
+
list: () => Promise<{
|
|
529
|
+
items: Folder[];
|
|
530
|
+
}>;
|
|
531
|
+
removeCards: (id: string, cardIds: string[]) => Promise<FolderCardsResult>;
|
|
532
|
+
/**
|
|
533
|
+
* Renames or recolors; `color: null` clears the color. `query` changes
|
|
534
|
+
* a smart folder's search.
|
|
535
|
+
*/
|
|
536
|
+
update: (id: string, input: {
|
|
537
|
+
color?: FolderColor | null;
|
|
538
|
+
name?: string;
|
|
539
|
+
query?: string;
|
|
540
|
+
}) => Promise<Folder>;
|
|
541
|
+
};
|
|
542
|
+
me: () => Promise<Me>;
|
|
543
|
+
tags: {
|
|
544
|
+
/**
|
|
545
|
+
* Deletes a tag from every card, including cards in Trash and Archive.
|
|
546
|
+
* It finishes in the background; poll with `operation`.
|
|
547
|
+
*/
|
|
548
|
+
delete: (tag: string) => Promise<TagOperation>;
|
|
549
|
+
list: () => Promise<{
|
|
550
|
+
items: TagSummary[];
|
|
551
|
+
}>;
|
|
552
|
+
/** Replaces `from` with `into` on every card; it finishes in the background. */
|
|
553
|
+
merge: (from: string, into: string) => Promise<TagOperation>;
|
|
554
|
+
/** A tag change's progress. */
|
|
555
|
+
operation: (id: string) => Promise<TagOperation>;
|
|
556
|
+
/** Renames a tag on every card; it finishes in the background. */
|
|
557
|
+
rename: (from: string, to: string) => Promise<TagOperation>;
|
|
558
|
+
};
|
|
559
|
+
uploads: {
|
|
560
|
+
create: (input: CreateUploadInput) => Promise<CreateUploadResponse>;
|
|
561
|
+
putFile: (uploadUrl: string, bytes: BodyInit, mimeType: string) => Promise<{
|
|
562
|
+
fileEtag: string | undefined;
|
|
563
|
+
}>;
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
export type TeakClient = ReturnType<typeof createTeakClient>;
|
|
567
|
+
export declare const parseTags: (value: string | undefined) => string[] | undefined;
|
|
568
|
+
export declare const isCardType: (value: string) => value is CardType;
|
|
569
|
+
export declare const isStringList: (value: unknown) => value is string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConnectTokenResult } from "./workosConnect.js";
|
|
2
|
+
export interface CredentialBinding {
|
|
3
|
+
clientId: string;
|
|
4
|
+
issuer: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const isWorkosCredential: (saved: Partial<CredentialBinding> | undefined) => saved is CredentialBinding;
|
|
8
|
+
export declare const matchesBinding: (saved: Partial<CredentialBinding> | undefined, current: CredentialBinding) => boolean;
|
|
9
|
+
export declare const isRefreshTokenDead: (result: ConnectTokenResult) => boolean;
|
|
10
|
+
export declare const refreshAndSave: <T>(refresh: () => Promise<T>, save: (renewed: NonNullable<T>) => unknown) => Promise<T>;
|