@proveanything/smartlinks 2.1.37 → 2.1.39

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 CHANGED
@@ -24,6 +24,7 @@ If you're new to the SDK, this is the easiest path:
24
24
  - [docs/analytics.md](docs/analytics.md) — fire-and-forget web analytics, tag scan telemetry, and dashboard queries
25
25
  - [docs/proof-share-grants.md](docs/proof-share-grants.md) — delegated, scoped, revocable share links for a proof (album sharing, guest comments, proof-of-ownership)
26
26
  - [docs/assets.md](docs/assets.md) — asset uploads, including resumable uploads for large files (video)
27
+ - [docs/files.md](docs/files.md) — temporary files, fetching web pages and documents once, and extracting text, Markdown, OCR or fields from them
27
28
  - [docs/app-objects.md](docs/app-objects.md) — cases, threads (comments), and records
28
29
  - [docs/translations.md](docs/translations.md) — runtime translation lookup, browser-side caching, and translation admin flows
29
30
  - [docs/widgets.md](docs/widgets.md) — embeddable React components
@@ -110,7 +110,7 @@ export interface DestinationInfo {
110
110
  /** The platform's screens any admin screen can open by name. */
111
111
  export declare const DESTINATIONS: DestinationInfo[];
112
112
  /** A destination name. Any string is accepted, so a newer host's names work on an older SDK. */
113
- export type Destination = 'contacts' | 'contact' | 'contact.messages' | 'conversation' | 'segment' | 'message.compose' | 'message.log' | 'campaign.new' | 'campaign' | 'templates' | 'template' | 'product' | 'proof' | 'interaction.type' | 'settings' | 'settings.address' | 'settings.domain' | 'settings.languages' | 'settings.translations' | 'settings.email' | 'settings.team' | 'settings.userGroups' | 'settings.setupLists' | 'settings.portal' | 'settings.hub' | 'settings.signIn' | 'media' | 'app' | (string & {});
113
+ export type Destination = 'contacts' | 'contact' | 'contact.messages' | 'contact.conversations' | 'conversation' | 'segment' | 'loyalty.scheme' | 'message.compose' | 'message.log' | 'campaign.new' | 'campaign' | 'templates' | 'template' | 'product' | 'proof' | 'interaction.type' | 'batch' | 'variant' | 'lot' | 'tags' | 'print' | 'form' | 'assets' | 'asset' | 'asset.history' | 'places' | 'settings.billing' | 'settings.integrations' | 'settings.guide' | 'settings.translationRules' | 'settings' | 'settings.address' | 'settings.domain' | 'settings.languages' | 'settings.translations' | 'settings.email' | 'settings.team' | 'settings.userGroups' | 'settings.setupLists' | 'settings.portal' | 'settings.hub' | 'settings.signIn' | 'media' | 'app' | (string & {});
114
114
  /** What a message is about (the same shape as `comms.sendTransactional`'s `about`). Ids only. */
115
115
  export interface DestinationAbout {
116
116
  appId?: string;
@@ -130,6 +130,11 @@ export interface OpenParams {
130
130
  productId?: string;
131
131
  proofId?: string;
132
132
  interactionId?: string;
133
+ batchId?: string;
134
+ variantId?: string;
135
+ lotId?: string;
136
+ formId?: string;
137
+ schemeId?: string;
133
138
  appId?: string;
134
139
  view?: string;
135
140
  /** `message.compose` / `message.log`: the record the message is about, so it is logged against it. */
@@ -266,6 +266,8 @@ export const DESTINATIONS = [
266
266
  { name: 'contact.messages', required: ['contactId'], description: "A person's messages: the Message log for them." },
267
267
  { name: 'conversation', required: ['conversationId'], description: 'One conversation in Messages.' },
268
268
  { name: 'segment', required: ['segmentId'], description: 'One segment in Customers.' },
269
+ { name: 'contact.conversations', required: ['contactId'], description: "A person's conversations in the Inbox (their messages and replies, with notes)." },
270
+ { name: 'loyalty.scheme', required: ['schemeId'], description: 'One loyalty scheme in Customers.' },
269
271
  // Messages
270
272
  { name: 'message.compose', required: [], optional: ['contactId', 'about'], description: 'The Messages composer: write to one person (or choose who).' },
271
273
  { name: 'message.log', required: [], optional: ['contactId', 'about'], description: 'The Message log, filtered by person or by what the messages were about.' },
@@ -277,6 +279,17 @@ export const DESTINATIONS = [
277
279
  { name: 'product', required: ['productId'], description: 'One product in Items.' },
278
280
  { name: 'proof', required: ['productId', 'proofId'], description: 'One item (proof) of a product.' },
279
281
  { name: 'interaction.type', required: ['interactionId'], description: 'One interaction type in Customers.' },
282
+ { name: 'batch', required: ['productId', 'batchId'], description: 'One batch of a product (Items).' },
283
+ { name: 'variant', required: ['productId', 'variantId'], description: 'One variant of a product (Items).' },
284
+ { name: 'lot', required: ['lotId'], description: 'One lot (Items).' },
285
+ { name: 'tags', required: [], description: 'The tags and codes on items (Items).' },
286
+ { name: 'print', required: ['productId'], optional: ['proofId'], description: 'Print labels and QR codes for a product, or for one item of it (Print Studio).' },
287
+ { name: 'form', required: ['formId'], description: 'One form, open to edit.' },
288
+ // Things the business owns (the Assets app)
289
+ { name: 'assets', required: [], description: 'The asset register: everything the business owns.' },
290
+ { name: 'asset', required: ['productId', 'proofId'], description: 'One asset (productId: its type, proofId: the asset).' },
291
+ { name: 'asset.history', required: ['productId', 'proofId'], description: "One asset's history: moves, checks and changes." },
292
+ { name: 'places', required: [], description: 'The places assets are kept (sites, rooms, stores).' },
280
293
  // Settings
281
294
  { name: 'settings', required: [], description: 'The business settings in Studio.' },
282
295
  { name: 'settings.address', required: [], optional: ['appId'], description: "The business's address: its name, front page, app pages (appId: point at that app's page) and links domain." },
@@ -286,6 +299,10 @@ export const DESTINATIONS = [
286
299
  { name: 'settings.email', required: [], description: 'Email settings: the sending address and its look.' },
287
300
  { name: 'settings.team', required: [], description: 'The people who run the business in Studio.' },
288
301
  { name: 'settings.userGroups', required: [], description: 'User groups.' },
302
+ { name: 'settings.billing', required: [], description: 'Billing: the plan, invoices and AI credits (top up when the allowance is used up).' },
303
+ { name: 'settings.integrations', required: [], description: 'Integrations: connections to other systems.' },
304
+ { name: 'settings.guide', required: [], description: 'The customer guide: the assistant visitors talk to.' },
305
+ { name: 'settings.translationRules', required: [], description: 'Translation rules: the brief, notes per language and terms to keep.' },
289
306
  { name: 'settings.setupLists', required: [], optional: ['appId'], description: "Set-up lists (an app's lists the business keeps)." },
290
307
  { name: 'settings.portal', required: [], description: 'The Portal: what people see when they scan.' },
291
308
  { name: 'settings.hub', required: [], description: 'The Hub: the ready-made site.' },
package/dist/api/asset.js CHANGED
@@ -334,6 +334,8 @@ export var asset;
334
334
  params.set('limit', String(options.limit));
335
335
  if (typeof options.offset === 'number')
336
336
  params.set('offset', String(options.offset));
337
+ if (options.include && options.include.length)
338
+ params.set('include', options.include.join(','));
337
339
  const qs = params.toString();
338
340
  const path = `/admin/collection/${encodeURIComponent(options.collectionId)}/asset${qs ? `?${qs}` : ''}`;
339
341
  return request(path);
@@ -0,0 +1,69 @@
1
+ import type { FileRecord, PutFileRequest, FetchFileRequest, FetchedFile, ListFilesQuery, ExtractFileRequest, ExtractFileResponse, ReadFileResponse, FileLinkResponse } from "../types/files.js";
2
+ /**
3
+ * Files: temporary or kept files, web pages and documents fetched by address, and what's extracted from them
4
+ * (text, Markdown, OCR, typed fields). Files are assets, but private until kept and left out of asset lists, so
5
+ * pickers and the media library never fill up with them.
6
+ *
7
+ * - Fetch once, read many times: the same address returns the same file while it's fresh, and an unchanged page
8
+ * isn't downloaded again.
9
+ * - Extract once: each file is read each way only once; the result is kept beside it.
10
+ * - `keep` makes a file permanent and public (an `assetUrl`), and it then shows in asset lists like any upload.
11
+ *
12
+ * In a server function the same calls are `ctx.sl.files.*` (needs `sl:files:read` / `sl:files:write`).
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const page = await files.fetch('coll_123', { url: 'https://supplier.example/spec.pdf', ttl: '7d' })
17
+ * const { text } = await files.extract('coll_123', page.file.id, { variant: 'markdown' })
18
+ * const { data } = await files.extract('coll_123', page.file.id, {
19
+ * variant: 'json',
20
+ * schema: { type: 'object', properties: { gtin: { type: 'string' }, weightKg: { type: 'number' } } },
21
+ * })
22
+ * ```
23
+ */
24
+ export declare namespace files {
25
+ /** Files on this site that aren't ordinary uploads: temporary, fetched, derived or generated (admin). */
26
+ function list(collectionId: string, query?: ListFilesQuery): Promise<{
27
+ ok: true;
28
+ files: FileRecord[];
29
+ }>;
30
+ /** A new file from text, base64 or JSON. Temporary (default 1 day) and private. */
31
+ function put(collectionId: string, body: PutFileRequest): Promise<{
32
+ ok: true;
33
+ file: FileRecord;
34
+ }>;
35
+ /**
36
+ * A web address's contents as a file, cached by address.
37
+ * @throws `BAD_URL`, `PRIVATE_ADDRESS`, `FETCH_FAILED`, `TOO_LARGE` (over 50 MB)
38
+ */
39
+ function fetch(collectionId: string, body: FetchFileRequest): Promise<{
40
+ ok: true;
41
+ file: FetchedFile;
42
+ }>;
43
+ /** One file. @throws `NOT_FOUND`, `EXPIRED` */
44
+ function get(collectionId: string, fileId: string): Promise<{
45
+ ok: true;
46
+ file: FileRecord;
47
+ }>;
48
+ /** A file's contents, as text (default) or base64 (up to 25 MB). */
49
+ function read(collectionId: string, fileId: string, as?: "text" | "base64"): Promise<ReadFileResponse>;
50
+ /** A signed link to a private file (default 15 minutes), or a kept file's permanent address. */
51
+ function link(collectionId: string, fileId: string, minutes?: number): Promise<FileLinkResponse>;
52
+ /**
53
+ * What's in a file: `text`, `markdown`, `ocr` (images) or `json` (typed fields: give a `schema` and/or a
54
+ * `prompt`). Each file is read each way once; asking again returns the same result (`cached: true`).
55
+ * @throws `BAD_VARIANT`, `SCHEMA_REQUIRED`, `USE_OCR` (text from an image), `NOT_AN_IMAGE`, `NOTHING_FOUND`
56
+ */
57
+ function extract(collectionId: string, fileId: string, body: ExtractFileRequest): Promise<ExtractFileResponse>;
58
+ /** Keep a file: permanent and public, with an `assetUrl`. It then shows in asset lists like any upload. */
59
+ function keep(collectionId: string, fileId: string): Promise<{
60
+ ok: true;
61
+ file: FileRecord;
62
+ }>;
63
+ /** Remove a file (a kept file is deleted like any asset, and can be restored). */
64
+ function remove(collectionId: string, fileId: string): Promise<{
65
+ ok: true;
66
+ removed: boolean;
67
+ softDeleted?: boolean;
68
+ }>;
69
+ }
@@ -0,0 +1,81 @@
1
+ import { request, post, del } from "../http.js";
2
+ /**
3
+ * Files: temporary or kept files, web pages and documents fetched by address, and what's extracted from them
4
+ * (text, Markdown, OCR, typed fields). Files are assets, but private until kept and left out of asset lists, so
5
+ * pickers and the media library never fill up with them.
6
+ *
7
+ * - Fetch once, read many times: the same address returns the same file while it's fresh, and an unchanged page
8
+ * isn't downloaded again.
9
+ * - Extract once: each file is read each way only once; the result is kept beside it.
10
+ * - `keep` makes a file permanent and public (an `assetUrl`), and it then shows in asset lists like any upload.
11
+ *
12
+ * In a server function the same calls are `ctx.sl.files.*` (needs `sl:files:read` / `sl:files:write`).
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const page = await files.fetch('coll_123', { url: 'https://supplier.example/spec.pdf', ttl: '7d' })
17
+ * const { text } = await files.extract('coll_123', page.file.id, { variant: 'markdown' })
18
+ * const { data } = await files.extract('coll_123', page.file.id, {
19
+ * variant: 'json',
20
+ * schema: { type: 'object', properties: { gtin: { type: 'string' }, weightKg: { type: 'number' } } },
21
+ * })
22
+ * ```
23
+ */
24
+ export var files;
25
+ (function (files) {
26
+ const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/files`;
27
+ const one = (collectionId, fileId) => `${adm(collectionId)}/${encodeURIComponent(fileId)}`;
28
+ /** Files on this site that aren't ordinary uploads: temporary, fetched, derived or generated (admin). */
29
+ async function list(collectionId, query = {}) {
30
+ const qs = new URLSearchParams(Object.entries(query).filter(([, v]) => v != null).map(([k, v]) => [k, String(v)])).toString();
31
+ return request(`${adm(collectionId)}${qs ? `?${qs}` : ""}`);
32
+ }
33
+ files.list = list;
34
+ /** A new file from text, base64 or JSON. Temporary (default 1 day) and private. */
35
+ async function put(collectionId, body) {
36
+ return post(adm(collectionId), body);
37
+ }
38
+ files.put = put;
39
+ /**
40
+ * A web address's contents as a file, cached by address.
41
+ * @throws `BAD_URL`, `PRIVATE_ADDRESS`, `FETCH_FAILED`, `TOO_LARGE` (over 50 MB)
42
+ */
43
+ async function fetch(collectionId, body) {
44
+ return post(`${adm(collectionId)}/fetch`, body);
45
+ }
46
+ files.fetch = fetch;
47
+ /** One file. @throws `NOT_FOUND`, `EXPIRED` */
48
+ async function get(collectionId, fileId) {
49
+ return request(one(collectionId, fileId));
50
+ }
51
+ files.get = get;
52
+ /** A file's contents, as text (default) or base64 (up to 25 MB). */
53
+ async function read(collectionId, fileId, as = "text") {
54
+ return request(`${one(collectionId, fileId)}/read?as=${as}`);
55
+ }
56
+ files.read = read;
57
+ /** A signed link to a private file (default 15 minutes), or a kept file's permanent address. */
58
+ async function link(collectionId, fileId, minutes) {
59
+ return request(`${one(collectionId, fileId)}/link${minutes ? `?minutes=${minutes}` : ""}`);
60
+ }
61
+ files.link = link;
62
+ /**
63
+ * What's in a file: `text`, `markdown`, `ocr` (images) or `json` (typed fields: give a `schema` and/or a
64
+ * `prompt`). Each file is read each way once; asking again returns the same result (`cached: true`).
65
+ * @throws `BAD_VARIANT`, `SCHEMA_REQUIRED`, `USE_OCR` (text from an image), `NOT_AN_IMAGE`, `NOTHING_FOUND`
66
+ */
67
+ async function extract(collectionId, fileId, body) {
68
+ return post(`${one(collectionId, fileId)}/extract`, body);
69
+ }
70
+ files.extract = extract;
71
+ /** Keep a file: permanent and public, with an `assetUrl`. It then shows in asset lists like any upload. */
72
+ async function keep(collectionId, fileId) {
73
+ return post(`${one(collectionId, fileId)}/keep`, {});
74
+ }
75
+ files.keep = keep;
76
+ /** Remove a file (a kept file is deleted like any asset, and can be restored). */
77
+ async function remove(collectionId, fileId) {
78
+ return del(one(collectionId, fileId));
79
+ }
80
+ files.remove = remove;
81
+ })(files || (files = {}));
@@ -28,6 +28,7 @@ export { segments } from "./segments.js";
28
28
  export { userGroups } from "./userGroups.js";
29
29
  export { conditions } from "./conditions.js";
30
30
  export { wallet } from "./wallet.js";
31
+ export { files } from "./files.js";
31
32
  export { operations } from "./operations.js";
32
33
  export { journeys } from "./journeys.js";
33
34
  export { journeysAnalytics } from "./journeysAnalytics.js";
package/dist/api/index.js CHANGED
@@ -30,6 +30,7 @@ export { segments } from "./segments.js";
30
30
  export { userGroups } from "./userGroups.js";
31
31
  export { conditions } from "./conditions.js";
32
32
  export { wallet } from "./wallet.js";
33
+ export { files } from "./files.js";
33
34
  export { operations } from "./operations.js";
34
35
  export { journeys } from "./journeys.js";
35
36
  export { journeysAnalytics } from "./journeysAnalytics.js";
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.37 | Generated: 2026-11-21T13:39:32.434Z
3
+ Version: 2.1.39 | Generated: 2026-11-21T14:41:19.071Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -150,6 +150,7 @@ The Smartlinks SDK is organized into the following namespaces:
150
150
  - **containers** - Functions for containers operations
151
151
  - **errors** - Functions for errors operations
152
152
  - **facets** - Functions for facets operations
153
+ - **files** - Functions for files operations
153
154
  - **functions** - Functions for functions operations
154
155
  - **http** - Functions for http operations
155
156
  - **integrations** - Functions for integrations operations
@@ -4210,6 +4211,12 @@ interface Asset {
4210
4211
  uploaderContactId: string | null
4211
4212
  uploadTokenId: string | null
4212
4213
  uploaderIp: string | null
4214
+ retention?: 'permanent' | 'temporary'
4215
+ expiresAt?: string | null
4216
+ origin?: 'upload' | 'fetched' | 'derived' | 'generated'
4217
+ sourceKey?: string | null
4218
+ derivedFromId?: string | null
4219
+ variant?: string | null
4213
4220
  status: 'active' | 'pending_review' | 'deleted'
4214
4221
  createdAt: string
4215
4222
  updatedAt: string
@@ -4304,6 +4311,7 @@ interface AdminListAssetsOptions {
4304
4311
  order?: 'asc' | 'desc'
4305
4312
  limit?: number
4306
4313
  offset?: number
4314
+ include?: Array<'temporary' | 'derived'>
4307
4315
  }
4308
4316
  ```
4309
4317
 
@@ -8352,6 +8360,91 @@ interface FacetValueGetParams {
8352
8360
 
8353
8361
  **FacetValueDefinition** = `FacetValue`
8354
8362
 
8363
+ ### files
8364
+
8365
+ **PutFileRequest** (interface)
8366
+ ```typescript
8367
+ interface PutFileRequest {
8368
+ name: string
8369
+ text?: string
8370
+ base64?: string
8371
+ json?: unknown
8372
+ contentType?: string
8373
+ ttl?: FileTtl
8374
+ appId?: string
8375
+ }
8376
+ ```
8377
+
8378
+ **FetchFileRequest** (interface)
8379
+ ```typescript
8380
+ interface FetchFileRequest {
8381
+ url: string
8382
+ ttl?: FileTtl
8383
+ maxAge?: FileTtl
8384
+ force?: boolean
8385
+ appId?: string
8386
+ }
8387
+ ```
8388
+
8389
+ **ListFilesQuery** (interface)
8390
+ ```typescript
8391
+ interface ListFilesQuery {
8392
+ origin?: "upload" | "fetched" | "derived" | "generated"
8393
+ retention?: "temporary" | "permanent"
8394
+ appId?: string
8395
+ derivedFromId?: string
8396
+ limit?: number
8397
+ }
8398
+ ```
8399
+
8400
+ **ExtractFileRequest** (interface)
8401
+ ```typescript
8402
+ interface ExtractFileRequest {
8403
+ variant: FileExtractVariant
8404
+ schema?: Record<string, any>
8405
+ prompt?: string
8406
+ force?: boolean
8407
+ }
8408
+ ```
8409
+
8410
+ **ExtractFileResponse** (interface)
8411
+ ```typescript
8412
+ interface ExtractFileResponse {
8413
+ ok: true
8414
+ file: FileRecord
8415
+ text?: string
8416
+ data?: any
8417
+ cached: boolean
8418
+ }
8419
+ ```
8420
+
8421
+ **ReadFileResponse** (interface)
8422
+ ```typescript
8423
+ interface ReadFileResponse {
8424
+ ok: true
8425
+ text?: string
8426
+ base64?: string
8427
+ contentType: string | null
8428
+ size: number
8429
+ }
8430
+ ```
8431
+
8432
+ **FileLinkResponse** (interface)
8433
+ ```typescript
8434
+ interface FileLinkResponse {
8435
+ ok: true
8436
+ url: string
8437
+ expiresAt?: string
8438
+ permanent?: boolean
8439
+ }
8440
+ ```
8441
+
8442
+ **FileRecord** = `Asset`
8443
+
8444
+ **FileTtl** = ``${number}h` | `${number}d` | number`
8445
+
8446
+ **FileExtractVariant** = `"text" | "markdown" | "ocr" | "json"`
8447
+
8355
8448
  ### headless
8356
8449
 
8357
8450
  **AppDataField** (interface)
@@ -14746,6 +14839,35 @@ Delete a crate for a collection (admin only). This performs a soft delete. ```ty
14746
14839
 
14747
14840
  **publicNamespaces**(collectionId: string) → `Promise<FacetNamespaceListResponse>`
14748
14841
 
14842
+ ### files
14843
+
14844
+ **list**(collectionId: string, query: ListFilesQuery = {}) → `Promise<`
14845
+ Files on this site that aren't ordinary uploads: temporary, fetched, derived or generated (admin).
14846
+
14847
+ **put**(collectionId: string, body: PutFileRequest) → `Promise<`
14848
+ A new file from text, base64 or JSON. Temporary (default 1 day) and private.
14849
+
14850
+ **fetch**(collectionId: string, body: FetchFileRequest) → `Promise<`
14851
+ A web address's contents as a file, cached by address.
14852
+
14853
+ **get**(collectionId: string, fileId: string) → `Promise<`
14854
+ One file. @throws `NOT_FOUND`, `EXPIRED`
14855
+
14856
+ **read**(collectionId: string, fileId: string, as: "text" | "base64" = "text") → `Promise<ReadFileResponse>`
14857
+ A file's contents, as text (default) or base64 (up to 25 MB).
14858
+
14859
+ **link**(collectionId: string, fileId: string, minutes?: number) → `Promise<FileLinkResponse>`
14860
+ A signed link to a private file (default 15 minutes), or a kept file's permanent address.
14861
+
14862
+ **extract**(collectionId: string, fileId: string, body: ExtractFileRequest) → `Promise<ExtractFileResponse>`
14863
+ What's in a file: `text`, `markdown`, `ocr` (images) or `json` (typed fields: give a `schema` and/or a `prompt`). Each file is read each way once; asking again returns the same result (`cached: true`).
14864
+
14865
+ **keep**(collectionId: string, fileId: string) → `Promise<`
14866
+ Keep a file: permanent and public, with an `assetUrl`. It then shows in asset lists like any upload.
14867
+
14868
+ **remove**(collectionId: string, fileId: string) → `Promise<`
14869
+ Remove a file (a kept file is deleted like any asset, and can be restored).
14870
+
14749
14871
  ### form
14750
14872
 
14751
14873
  **get**(collectionId: string, formId: string, admin?: boolean) → `Promise<any>`
@@ -181,6 +181,8 @@ const canMessage = await SL.adminViews.canOpen('message.compose')
181
181
  | `contact.messages` | **contactId** | The Message log for that person |
182
182
  | `conversation` | **conversationId** | One conversation (Messages) |
183
183
  | `segment` | **segmentId** | One segment (Customers) |
184
+ | `contact.conversations` | **contactId** | Their conversations in the Inbox (Messages) |
185
+ | `loyalty.scheme` | **schemeId** | One loyalty scheme (Customers) |
184
186
  | `message.compose` | contactId, about | The composer, to that person (or choose who) |
185
187
  | `message.log` | contactId, about | The Message log, filtered |
186
188
  | `campaign.new` | segmentId | A new campaign to that segment |
@@ -190,10 +192,22 @@ const canMessage = await SL.adminViews.canOpen('message.compose')
190
192
  | `product` | **productId** | One product (Items) |
191
193
  | `proof` | **productId**, **proofId** | One item of a product |
192
194
  | `interaction.type` | **interactionId** | One interaction type (Customers) |
195
+ | `batch` | **productId**, **batchId** | One batch of a product |
196
+ | `variant` | **productId**, **variantId** | One variant of a product |
197
+ | `lot` | **lotId** | One lot |
198
+ | `tags` | | The tags and codes on items |
199
+ | `print` | **productId**, proofId | Print labels and QR codes for a product, or one item |
200
+ | `form` | **formId** | One form, open to edit |
201
+ | `assets` | | The asset register: what the business owns (Assets) |
202
+ | `asset` · `asset.history` | **productId** (its type), **proofId** | One asset, or its history |
203
+ | `places` | | Where assets are kept |
193
204
  | `settings` | | Studio → Settings |
194
205
  | `settings.address` | `appId`? | Your address: the business's name, front page, app pages (with `appId`, that app's page: where the owner renames it or makes it the front page) and links domain. Put a "Change this address" link beside any link to your app's page. |
195
206
  | `settings.domain` · `.languages` · `.translations` · `.email` · `.team` · `.userGroups` | | That Studio page |
196
207
  | `settings.setupLists` | appId | Set-up lists, for that app |
208
+ | `settings.billing` | | Billing: plan, invoices, AI credits. Link here when the AI allowance is used up |
209
+ | `settings.integrations` | | Connections to other systems |
210
+ | `settings.guide` · `settings.translationRules` | | The customer guide · translation rules |
197
211
  | `settings.portal` · `.hub` · `.signIn` | | The Portal, the Hub, customer sign-in |
198
212
  | `media` | | Images and files |
199
213
  | `app` | **appId**, view, params | Another app at one of its screens, as `openApp` |
@@ -129,6 +129,10 @@ GET /asset
129
129
  | `order` | string | `desc` (default), `asc` |
130
130
  | `limit` | number | Max results (default 50, max 200) |
131
131
  | `offset` | number | Pagination offset |
132
+ | `include` | string | `temporary`, `derived` (comma-separated): also list files that are normally left out |
133
+
134
+ Lists show only what people put there. Temporary files and files extracted from other files (see
135
+ [files.md](files.md)) are left out unless you ask with `include`, so pickers never fill up with them.
132
136
 
133
137
  **Response:**
134
138
 
@@ -0,0 +1,69 @@
1
+ # Files
2
+
3
+ Files are for the things an app or an AI tool needs to hold onto that nobody browses: a supplier's spec sheet fetched
4
+ to read product details from, a web page with a recipe, a deck to summarise, an image to read text from, a JSON result
5
+ to pass between steps.
6
+
7
+ A file is an asset, with three differences:
8
+
9
+ - **It can be temporary.** It's removed at `expiresAt` (`ttl` from `1h` to `30d`, default `1d`).
10
+ - **It's private** until kept. You read it through `files.read` or a signed link from `files.link`.
11
+ - **It stays out of asset lists.** Pickers, the media library, the Hub and the portal never show temporary or
12
+ extracted files. `files.keep` makes a file permanent and public (with an `assetUrl`), and it then shows like any
13
+ upload.
14
+
15
+ ## Fetch once, extract once
16
+
17
+ ```typescript
18
+ import { files } from '@proveanything/smartlinks'
19
+
20
+ // The same address returns the same file while it's fresh; once stale, an unchanged page isn't downloaded again.
21
+ const { file } = await files.fetch(collectionId, { url: 'https://supplier.example/spec.pdf', ttl: '7d' })
22
+
23
+ // Each file is read each way once: asking again returns the same result (cached: true).
24
+ const { text } = await files.extract(collectionId, file.id, { variant: 'markdown' })
25
+
26
+ const { data } = await files.extract(collectionId, file.id, {
27
+ variant: 'json',
28
+ schema: { type: 'object', properties: { gtin: { type: 'string' }, weightKg: { type: 'number' } } },
29
+ })
30
+ ```
31
+
32
+ | Variant | Gives | Works on |
33
+ |---|---|---|
34
+ | `text` | plain text | PDFs, HTML, text, JSON, and web pages / documents |
35
+ | `markdown` | Markdown | web pages, PDFs, decks, documents |
36
+ | `ocr` | text read from an image | images |
37
+ | `json` | typed fields (`schema` and/or `prompt`) | anything readable |
38
+
39
+ What's extracted is kept beside its source as a derived file (`origin: 'derived'`, `derivedFromId`, `variant`) and
40
+ lives as long as the source does.
41
+
42
+ ## Your own files
43
+
44
+ ```typescript
45
+ const { file } = await files.put(collectionId, { name: 'notes.json', json: { step: 2 }, ttl: '1d' })
46
+ const { text } = await files.read(collectionId, file.id) // or 'base64'
47
+ const { url } = await files.link(collectionId, file.id, 15) // a signed link for 15 minutes
48
+ await files.keep(collectionId, file.id) // permanent, public, shows in pickers
49
+ await files.remove(collectionId, file.id)
50
+ const { files: mine } = await files.list(collectionId, { appId: 'my-app', origin: 'fetched' })
51
+ ```
52
+
53
+ ## In a server function
54
+
55
+ The same calls are on `ctx.sl.files` (manifest scopes `sl:files:read` and `sl:files:write`), without the collection
56
+ id. AI tools get `file.fetch`, `file.extract` and `file.read`, which hand back file references rather than pasting
57
+ whole documents into the conversation.
58
+
59
+ ```js
60
+ const page = await ctx.sl.files.fetch('https://cook.example/pancakes', { ttl: '7d' })
61
+ const { data } = await ctx.sl.files.extract(page.id, 'json', { schema })
62
+ ```
63
+
64
+ ## Limits
65
+
66
+ - Fetching: public web addresses only (checked on every redirect), up to 50 MB.
67
+ - Reading contents: up to 25 MB.
68
+ - Temporary files per site: 5,000 files or 2 GB at once; past that the oldest temporary files go first. Kept files
69
+ aren't capped here.