@coreviz/sdk 1.0.19 → 1.1.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/README.md +430 -83
- package/dist/coreviz.d.ts +205 -0
- package/dist/coreviz.js +236 -8
- package/dist/coreviz.native.d.ts +126 -0
- package/dist/coreviz.native.js +139 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.native.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,160 +64,507 @@ Notes:
|
|
|
64
64
|
|
|
65
65
|
## Configuration
|
|
66
66
|
|
|
67
|
-
To use the AI features, you need to instantiate the `CoreViz` class with your API key.
|
|
68
|
-
|
|
69
67
|
```typescript
|
|
70
68
|
import { CoreViz } from '@coreviz/sdk';
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
// External use — API key
|
|
71
|
+
const coreviz = new CoreViz({ apiKey: process.env.COREVIZ_API_KEY });
|
|
72
|
+
|
|
73
|
+
// CLI / server — session token
|
|
74
|
+
const coreviz = new CoreViz({ token: 'your_session_token' });
|
|
75
|
+
|
|
76
|
+
// Self-hosted or local dev — override base URL
|
|
77
|
+
const coreviz = new CoreViz({ apiKey: '...', baseUrl: 'http://localhost:3000' });
|
|
78
|
+
|
|
79
|
+
// Browser same-origin — no credentials needed; session cookie is used automatically
|
|
80
|
+
const coreviz = new CoreViz({ baseUrl: window.location.origin });
|
|
75
81
|
```
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Vision AI Methods
|
|
78
86
|
|
|
79
87
|
### `coreviz.describe(image)`
|
|
80
88
|
|
|
81
89
|
Generates a detailed text description of an image.
|
|
82
90
|
|
|
83
91
|
**Parameters:**
|
|
84
|
-
- `image` (string):
|
|
85
|
-
|
|
86
|
-
**Returns:**
|
|
87
|
-
- `Promise<string>`: A text description of the image.
|
|
92
|
+
- `image` (string): Base64 data URL or remote URL.
|
|
88
93
|
|
|
89
|
-
**
|
|
94
|
+
**Returns:** `Promise<string>`
|
|
90
95
|
|
|
91
96
|
```typescript
|
|
92
97
|
const description = await coreviz.describe('https://example.com/image.jpg');
|
|
93
|
-
console.log(description);
|
|
94
98
|
```
|
|
95
99
|
|
|
100
|
+
---
|
|
101
|
+
|
|
96
102
|
### `coreviz.tag(image, options)`
|
|
97
103
|
|
|
98
|
-
Analyzes an image and returns
|
|
104
|
+
Analyzes an image and returns tags or classifications based on a prompt.
|
|
99
105
|
|
|
100
106
|
**Parameters:**
|
|
101
|
-
- `image` (string):
|
|
102
|
-
- `options
|
|
103
|
-
- `prompt` (string):
|
|
104
|
-
- `options` (string[], optional):
|
|
105
|
-
- `multiple` (boolean, optional):
|
|
106
|
-
|
|
107
|
-
**Returns:**
|
|
108
|
-
- `Promise<TagResponse>`: An object containing:
|
|
109
|
-
- `tags` (string[]): The list of identified tags.
|
|
110
|
-
- `raw` (unknown): The raw API response.
|
|
107
|
+
- `image` (string): Base64 data URL or remote URL.
|
|
108
|
+
- `options`:
|
|
109
|
+
- `prompt` (string): Question to guide tagging (e.g. `"What color is the car?"`).
|
|
110
|
+
- `options` (string[], optional): Restrict answers to this list.
|
|
111
|
+
- `multiple` (boolean, optional): Allow multiple tags (default: `true`).
|
|
112
|
+
- `mode` (`'api' | 'local'`, optional): `'local'` runs fully in-browser via transformers.js.
|
|
111
113
|
|
|
112
|
-
**
|
|
114
|
+
**Returns:** `Promise<TagResponse>` — `{ tags: string[], raw }`
|
|
113
115
|
|
|
114
116
|
```typescript
|
|
115
|
-
const
|
|
116
|
-
prompt:
|
|
117
|
-
options: [
|
|
118
|
-
multiple: false
|
|
117
|
+
const { tags } = await coreviz.tag(imageUrl, {
|
|
118
|
+
prompt: 'Is this indoor or outdoor?',
|
|
119
|
+
options: ['indoor', 'outdoor'],
|
|
120
|
+
multiple: false,
|
|
119
121
|
});
|
|
120
|
-
console.log(result.tags); // ["indoor"]
|
|
121
122
|
```
|
|
122
123
|
|
|
124
|
+
---
|
|
125
|
+
|
|
123
126
|
### `coreviz.edit(image, options)`
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
Edits an image using a generative AI prompt.
|
|
126
129
|
|
|
127
130
|
**Parameters:**
|
|
128
|
-
- `image` (string):
|
|
129
|
-
- `options
|
|
131
|
+
- `image` (string): Base64 data URL or remote URL.
|
|
132
|
+
- `options`:
|
|
130
133
|
- `prompt` (string): Description of the desired edit.
|
|
131
|
-
- `aspectRatio` (string, optional):
|
|
132
|
-
- `outputFormat` (
|
|
133
|
-
- `model` (string, optional):
|
|
134
|
+
- `aspectRatio` (string, optional): `'match_input_image'` | `'1:1'` | `'16:9'` | `'9:16'` | `'4:3'` | `'3:4'`.
|
|
135
|
+
- `outputFormat` (`'jpg' | 'png'`, optional).
|
|
136
|
+
- `model` (string, optional): `'flux-kontext-max'` | `'google/nano-banana'` | `'seedream-4'`. Default: `'flux-kontext-max'`.
|
|
134
137
|
|
|
135
|
-
**Returns:**
|
|
136
|
-
- `Promise<string>`: The edited image as a base64 string or URL.
|
|
137
|
-
|
|
138
|
-
**Example:**
|
|
138
|
+
**Returns:** `Promise<string>` — edited image URL or base64.
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
|
-
const
|
|
142
|
-
prompt:
|
|
143
|
-
aspectRatio:
|
|
141
|
+
const edited = await coreviz.edit('https://example.com/photo.jpg', {
|
|
142
|
+
prompt: 'Make it look like a watercolor painting',
|
|
143
|
+
aspectRatio: '1:1',
|
|
144
144
|
});
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
---
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
### `coreviz.generate(prompt, options?)`
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
- `prompt` (string): The text description of the image(s) to generate.
|
|
153
|
-
- `options` (object, optional):
|
|
154
|
-
- `referenceImages` (string[], optional): Array of reference images (URL/base64) to guide generation.
|
|
155
|
-
- `aspectRatio` (string, optional): Target aspect ratio (e.g., `'1:1'`, `'16:9'`, `'4:3'`).
|
|
156
|
-
- `model` (string, optional): The model to use (default: `'google/nano-banana-pro'`).
|
|
151
|
+
Generates an image from a text prompt, optionally guided by reference images.
|
|
157
152
|
|
|
158
|
-
**
|
|
159
|
-
- `string
|
|
153
|
+
**Parameters:**
|
|
154
|
+
- `prompt` (string): Text description.
|
|
155
|
+
- `options` (optional):
|
|
156
|
+
- `referenceImages` (string[]): Reference images (URL/base64) to guide style or structure.
|
|
157
|
+
- `aspectRatio` (string): e.g. `'1:1'`, `'16:9'`, `'4:3'`.
|
|
158
|
+
- `model` (string): `'google/nano-banana'` | `'google/nano-banana-pro'` | `'seedream-4'` | `'flux-kontext-max'`. Default: `'google/nano-banana-pro'`.
|
|
160
159
|
|
|
161
|
-
**
|
|
160
|
+
**Returns:** `Promise<string>` — generated image URL.
|
|
162
161
|
|
|
163
162
|
```typescript
|
|
164
|
-
const
|
|
165
|
-
aspectRatio: "16:9"
|
|
166
|
-
});
|
|
163
|
+
const image = await coreviz.generate('A futuristic city at dusk', { aspectRatio: '16:9' });
|
|
167
164
|
```
|
|
168
165
|
|
|
166
|
+
---
|
|
167
|
+
|
|
169
168
|
### `coreviz.embed(input, options?)`
|
|
170
169
|
|
|
171
170
|
Generates embeddings for image or text inputs, enabling semantic search and similarity comparison. Use with `coreviz.similarity(embeddingA, embeddingB)` to compare two images or an image and a text.
|
|
172
171
|
|
|
173
172
|
**Parameters:**
|
|
174
|
-
- `input` (string):
|
|
175
|
-
- `options` (
|
|
176
|
-
- `type` ('image' | 'text'
|
|
177
|
-
- `mode` ('api' | 'local'
|
|
173
|
+
- `input` (string): Text string, image URL, or base64 data URL.
|
|
174
|
+
- `options` (optional):
|
|
175
|
+
- `type` (`'image' | 'text'`): Explicit type hint (auto-detected if omitted).
|
|
176
|
+
- `mode` (`'api' | 'local'`): `'local'` runs in-browser using transformers.js. Default: `'api'`.
|
|
178
177
|
|
|
179
|
-
**Returns:**
|
|
180
|
-
- `Promise<EmbedResponse>`: An object containing:
|
|
181
|
-
- `embedding` (number[]): The high-dimensional vector representation.
|
|
182
|
-
|
|
183
|
-
**Example:**
|
|
178
|
+
**Returns:** `Promise<EmbedResponse>` — `{ embedding: number[] }`
|
|
184
179
|
|
|
185
180
|
```typescript
|
|
186
|
-
const { embedding } = await coreviz.embed('A photo of a
|
|
181
|
+
const { embedding } = await coreviz.embed('A photo of a red sneaker');
|
|
187
182
|
```
|
|
188
183
|
|
|
189
|
-
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### `coreviz.similarity(vecA, vecB)`
|
|
190
187
|
|
|
191
188
|
Calculates the degree of similarity between two embeddings.
|
|
192
189
|
|
|
193
190
|
**Parameters:**
|
|
194
|
-
- `
|
|
195
|
-
- `embeddingB` (number[]): The second image/text embedding.
|
|
191
|
+
- `vecA`, `vecB` (number[]): Embedding vectors from `embed()`.
|
|
196
192
|
|
|
197
|
-
**Returns:**
|
|
198
|
-
- `number`: A similarity score between -1 and 1.
|
|
199
|
-
|
|
200
|
-
**Example:**
|
|
193
|
+
**Returns:** `number` — score between -1 and 1.
|
|
201
194
|
|
|
202
195
|
```typescript
|
|
203
|
-
const
|
|
196
|
+
const score = coreviz.similarity(embeddingA, embeddingB);
|
|
204
197
|
```
|
|
205
198
|
|
|
199
|
+
---
|
|
200
|
+
|
|
206
201
|
### `coreviz.resize(input, maxWidth?, maxHeight?)`
|
|
207
202
|
|
|
208
|
-
|
|
203
|
+
Resizes an image client-side (canvas) or server-side (Sharp). Also available as a standalone import.
|
|
204
|
+
|
|
205
|
+
**Returns:** `Promise<string>` — base64 data URL.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
const resized = await coreviz.resize(file, 800, 600);
|
|
209
|
+
// or: import { resize } from '@coreviz/sdk';
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Library Management API
|
|
215
|
+
|
|
216
|
+
The SDK also exposes namespaced methods for programmatically managing your CoreViz visual library — browsing collections, searching media, organizing folders, and managing tags. These require authentication via a user token (from `coreviz login`) or an API key.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Collections
|
|
221
|
+
|
|
222
|
+
### `coreviz.collections.list(organizationId?)`
|
|
223
|
+
|
|
224
|
+
List all collections in an organization.
|
|
225
|
+
|
|
226
|
+
- `organizationId` (string, optional): Pass explicitly to skip the `/api/me` round-trip.
|
|
227
|
+
|
|
228
|
+
**Returns:** `Promise<Collection[]>`
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
const collections = await coreviz.collections.list();
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### `coreviz.collections.get(collectionId)`
|
|
237
|
+
|
|
238
|
+
Get a single collection by ID.
|
|
239
|
+
|
|
240
|
+
**Returns:** `Promise<Collection>`
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
const collection = await coreviz.collections.get('abc123');
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
### `coreviz.collections.create(name, icon?)`
|
|
249
|
+
|
|
250
|
+
Create a new collection.
|
|
251
|
+
|
|
252
|
+
**Returns:** `Promise<Collection>`
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
const collection = await coreviz.collections.create('Product Photos', '📦');
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### `coreviz.collections.update(collectionId, updates)`
|
|
261
|
+
|
|
262
|
+
Update a collection's name or icon.
|
|
263
|
+
|
|
264
|
+
**Parameters:**
|
|
265
|
+
- `updates`: `{ name?: string; icon?: string }`
|
|
266
|
+
|
|
267
|
+
**Returns:** `Promise<Collection>`
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
await coreviz.collections.update('abc123', { name: 'Campaign Assets 2025' });
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Media
|
|
276
|
+
|
|
277
|
+
### `coreviz.media.browse(collectionId, options?)`
|
|
278
|
+
|
|
279
|
+
List media and folders inside a collection. Supports browsing, filtering, searching, and similarity queries all through the same method.
|
|
280
|
+
|
|
281
|
+
**Options:**
|
|
282
|
+
| Field | Type | Description |
|
|
283
|
+
|---|---|---|
|
|
284
|
+
| `path` | string | ltree path to list (e.g. `"collId.folderId"`). Defaults to collection root. |
|
|
285
|
+
| `limit` / `offset` | number | Pagination. |
|
|
286
|
+
| `type` | `'image' \| 'video' \| 'folder' \| 'all'` | Filter by media type. |
|
|
287
|
+
| `dateFrom` / `dateTo` | string | Date range filter (`YYYY-MM-DD`). |
|
|
288
|
+
| `sortBy` / `sortDirection` | string | Sort field and direction (`'asc' \| 'desc'`). |
|
|
289
|
+
| `tagFilters` | `Record<string, string[]>` | AND between groups, OR within group. |
|
|
290
|
+
| `q` | string | Text/semantic search query (triggers scored mode). |
|
|
291
|
+
| `similarToObjectId` | string | Find visually similar media by detected object ID. |
|
|
292
|
+
| `similarToObjectModel` | string | Vision model for similarity scoring. |
|
|
293
|
+
| `tags` | string | Comma-separated tag label filter. |
|
|
294
|
+
| `mediaId` | string | Filter to a specific media item. |
|
|
295
|
+
| `clusterId` | string | Filter to a specific object cluster. |
|
|
296
|
+
| `recursive` | boolean | List all descendants recursively (flattened view). |
|
|
297
|
+
|
|
298
|
+
**Returns:** `Promise<BrowseResult>` — `{ media: Media[], pagination }`
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
// Browse a folder
|
|
302
|
+
const { media } = await coreviz.media.browse('collId', { path: 'collId.folderXyz', limit: 50 });
|
|
303
|
+
|
|
304
|
+
// In-folder semantic search
|
|
305
|
+
const { media: results } = await coreviz.media.browse('collId', { q: 'red shoes' });
|
|
306
|
+
|
|
307
|
+
// Find similar media by object
|
|
308
|
+
const { media: similar } = await coreviz.media.browse('collId', { similarToObjectId: 'objId' });
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
### `coreviz.media.search(query, options?)`
|
|
314
|
+
|
|
315
|
+
Semantically search across all media in the organization.
|
|
316
|
+
|
|
317
|
+
**Options:**
|
|
318
|
+
- `limit` (number): Max results.
|
|
319
|
+
- `organizationId` (string): Pass explicitly to skip the `/api/me` round-trip.
|
|
320
|
+
|
|
321
|
+
**Returns:** `Promise<SearchResult[]>` — each result includes `mediaId`, `blobUrl`, `objects`, `rank`, `caption`.
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
const results = await coreviz.media.search('sunset over water', { limit: 10 });
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
### `coreviz.media.get(mediaId)`
|
|
330
|
+
|
|
331
|
+
Get full details for a media item including blob URL, dimensions, metadata, detected objects, and frames.
|
|
332
|
+
|
|
333
|
+
**Returns:** `Promise<Media>`
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
const item = await coreviz.media.get('mediaId123');
|
|
337
|
+
console.log(item.blob, item.metadata?.tags, item.frames);
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### `coreviz.media.rename(mediaId, name)`
|
|
343
|
+
|
|
344
|
+
Rename a media item.
|
|
345
|
+
|
|
346
|
+
**Returns:** `Promise<Media>`
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
await coreviz.media.rename('mediaId123', 'hero-shot-final.jpg');
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### `coreviz.media.move(mediaId, destinationPath)`
|
|
355
|
+
|
|
356
|
+
Move a media item to a different folder within the same collection.
|
|
357
|
+
|
|
358
|
+
- `destinationPath` (string): ltree path of the destination folder.
|
|
359
|
+
|
|
360
|
+
**Returns:** `Promise<{ id, newPath }>`
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
await coreviz.media.move('mediaId123', 'collId.archiveFolder');
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
### `coreviz.media.delete(mediaId)`
|
|
369
|
+
|
|
370
|
+
Permanently delete a media item.
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
await coreviz.media.delete('mediaId123');
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
### `coreviz.media.upload(file, options)`
|
|
379
|
+
|
|
380
|
+
Upload a photo or video.
|
|
381
|
+
|
|
382
|
+
**Parameters:**
|
|
383
|
+
- `file`: Local file path string (Node.js), `File` (browser), or `Blob`.
|
|
384
|
+
- `options`:
|
|
385
|
+
- `collectionId` (string, required)
|
|
386
|
+
- `path` (string, optional): Destination ltree folder path.
|
|
387
|
+
- `name` (string, optional): Override stored file name.
|
|
388
|
+
|
|
389
|
+
**Returns:** `Promise<UploadResult>` — `{ mediaId, url, message }`
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
// Node.js
|
|
393
|
+
const result = await coreviz.media.upload('/path/to/photo.jpg', { collectionId: 'abc123' });
|
|
394
|
+
|
|
395
|
+
// Browser
|
|
396
|
+
const result = await coreviz.media.upload(file, { collectionId: 'abc123', path: 'abc123.folder' });
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
> File path strings are not supported on React Native / Expo. Pass a `File` or `Blob` instead.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Tags
|
|
404
|
+
|
|
405
|
+
### `coreviz.media.addTag(mediaId, label, value)`
|
|
406
|
+
|
|
407
|
+
Add a tag to a media item. Tags are `label` (group) + `value` pairs.
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
await coreviz.media.addTag('mediaId123', 'color', 'red');
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
### `coreviz.media.removeTag(mediaId, label, value)`
|
|
416
|
+
|
|
417
|
+
Remove a specific tag value from a media item.
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
await coreviz.media.removeTag('mediaId123', 'color', 'red');
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
### `coreviz.media.removeTagGroup(mediaId, label)`
|
|
426
|
+
|
|
427
|
+
Remove an entire tag group (all values under that label) from a media item.
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
await coreviz.media.removeTagGroup('mediaId123', 'color');
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
### `coreviz.media.renameTagGroup(mediaId, oldLabel, newLabel)`
|
|
436
|
+
|
|
437
|
+
Rename a tag group on a media item, preserving all its values.
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
await coreviz.media.renameTagGroup('mediaId123', 'colour', 'color');
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
### `coreviz.tags.list(collectionId)`
|
|
446
|
+
|
|
447
|
+
Aggregate all tag groups and values across an entire collection.
|
|
448
|
+
|
|
449
|
+
**Returns:** `Promise<Record<string, string[]>>`
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
const tags = await coreviz.tags.list('collId');
|
|
453
|
+
// { color: ['red', 'blue'], category: ['product', 'lifestyle'] }
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Versions
|
|
459
|
+
|
|
460
|
+
Media items in CoreViz track edit history as versions. Each AI edit or bulk operation creates a new version linked to the original.
|
|
461
|
+
|
|
462
|
+
### `coreviz.media.listVersions(mediaId)`
|
|
463
|
+
|
|
464
|
+
List all versions of a media item (original + all AI-edited derivatives).
|
|
465
|
+
|
|
466
|
+
**Returns:** `Promise<Media[]>`
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
const versions = await coreviz.media.listVersions('mediaId123');
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
### `coreviz.media.selectVersion(versionId)`
|
|
475
|
+
|
|
476
|
+
Mark a version as the active/current version.
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
await coreviz.media.selectVersion('versionId456');
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
### `coreviz.media.deleteVersion(rootMediaId, versionId)`
|
|
485
|
+
|
|
486
|
+
Delete a specific version. If the deleted version was active, the server promotes another version automatically.
|
|
487
|
+
|
|
488
|
+
**Returns:** `Promise<{ deletedId: string; promotedId: string | null }>`
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
const { promotedId } = await coreviz.media.deleteVersion('rootMediaId', 'versionId456');
|
|
492
|
+
if (promotedId) {
|
|
493
|
+
// navigate to promoted version
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## Similarity Search
|
|
500
|
+
|
|
501
|
+
### `coreviz.media.findSimilar(collectionId, objectId, options?)`
|
|
502
|
+
|
|
503
|
+
Find visually similar media using a detected object ID (from `media.get()` frames).
|
|
504
|
+
|
|
505
|
+
**Options:**
|
|
506
|
+
- `limit` (number)
|
|
507
|
+
- `model` (string): e.g. `'faces'`, `'objects'`, `'shoeprints'`.
|
|
508
|
+
|
|
509
|
+
**Returns:** `Promise<BrowseResult>`
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
const { media } = await coreviz.media.findSimilar('collId', 'objectId456', { model: 'faces' });
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Folders
|
|
518
|
+
|
|
519
|
+
### `coreviz.folders.create(collectionId, name, path?, reuse?)`
|
|
520
|
+
|
|
521
|
+
Create a new folder inside a collection.
|
|
522
|
+
|
|
523
|
+
- `path` (string, optional): Parent ltree path. Defaults to collection root.
|
|
524
|
+
- `reuse` (boolean, optional): When `true`, returns the existing folder if one with the same name already exists at that path (upsert behavior).
|
|
525
|
+
|
|
526
|
+
**Returns:** `Promise<Folder>`
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
const folder = await coreviz.folders.create('collId', 'Spring 2025', 'collId.campaigns');
|
|
530
|
+
|
|
531
|
+
// Upsert — safe to call repeatedly
|
|
532
|
+
const folder = await coreviz.folders.create('collId', 'Imports', undefined, true);
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
### `coreviz.folders.get(folderId)`
|
|
538
|
+
|
|
539
|
+
Get a folder by ID.
|
|
540
|
+
|
|
541
|
+
**Returns:** `Promise<Folder>`
|
|
542
|
+
|
|
543
|
+
```typescript
|
|
544
|
+
const folder = await coreviz.folders.get('folderId123');
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
### `coreviz.folders.update(folderId, updates)`
|
|
550
|
+
|
|
551
|
+
Update a folder's name or metadata.
|
|
209
552
|
|
|
210
553
|
**Parameters:**
|
|
211
|
-
- `
|
|
212
|
-
|
|
213
|
-
|
|
554
|
+
- `updates`: `{ name?: string; metadata?: Record<string, unknown> }`
|
|
555
|
+
|
|
556
|
+
**Returns:** `Promise<Folder>`
|
|
557
|
+
|
|
558
|
+
```typescript
|
|
559
|
+
await coreviz.folders.update('folderId123', { name: 'Archived Campaign' });
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
---
|
|
214
563
|
|
|
215
|
-
|
|
216
|
-
- `Promise<string>`: The resized image as a base64 string.
|
|
564
|
+
### `coreviz.folders.delete(folderId)`
|
|
217
565
|
|
|
218
|
-
|
|
566
|
+
Delete a folder and all its contents.
|
|
219
567
|
|
|
220
568
|
```typescript
|
|
221
|
-
|
|
222
|
-
// or import { resize } from '@coreviz/sdk';
|
|
569
|
+
await coreviz.folders.delete('folderId123');
|
|
223
570
|
```
|