@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 +1 -0
- package/dist/adminViews.d.ts +6 -1
- package/dist/adminViews.js +17 -0
- package/dist/api/asset.js +2 -0
- package/dist/api/files.d.ts +69 -0
- package/dist/api/files.js +81 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/docs/API_SUMMARY.md +123 -1
- package/dist/docs/admin-views.md +14 -0
- package/dist/docs/assets.md +4 -0
- package/dist/docs/files.md +69 -0
- package/dist/docs/overview.md +482 -481
- package/dist/docs/server-functions.md +1219 -1197
- package/dist/openapi.yaml +166 -0
- package/dist/types/asset.d.ts +17 -0
- package/dist/types/files.d.ts +78 -0
- package/dist/types/files.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/docs/API_SUMMARY.md +123 -1
- package/docs/admin-views.md +14 -0
- package/docs/assets.md +4 -0
- package/docs/files.md +69 -0
- package/docs/overview.md +482 -481
- package/docs/server-functions.md +1219 -1197
- package/openapi.yaml +166 -0
- package/package.json +1 -1
package/dist/openapi.yaml
CHANGED
|
@@ -273,6 +273,16 @@ paths:
|
|
|
273
273
|
required: false
|
|
274
274
|
schema:
|
|
275
275
|
type: number
|
|
276
|
+
- name: include
|
|
277
|
+
in: query
|
|
278
|
+
required: false
|
|
279
|
+
schema:
|
|
280
|
+
type: array
|
|
281
|
+
items:
|
|
282
|
+
type: string
|
|
283
|
+
enum:
|
|
284
|
+
- temporary
|
|
285
|
+
- derived
|
|
276
286
|
- name: collectionId
|
|
277
287
|
in: query
|
|
278
288
|
required: false
|
|
@@ -24226,6 +24236,26 @@ components:
|
|
|
24226
24236
|
type: string
|
|
24227
24237
|
uploaderIp:
|
|
24228
24238
|
type: string
|
|
24239
|
+
retention:
|
|
24240
|
+
type: string
|
|
24241
|
+
enum:
|
|
24242
|
+
- permanent
|
|
24243
|
+
- temporary
|
|
24244
|
+
expiresAt:
|
|
24245
|
+
type: string
|
|
24246
|
+
origin:
|
|
24247
|
+
type: string
|
|
24248
|
+
enum:
|
|
24249
|
+
- upload
|
|
24250
|
+
- fetched
|
|
24251
|
+
- derived
|
|
24252
|
+
- generated
|
|
24253
|
+
sourceKey:
|
|
24254
|
+
type: string
|
|
24255
|
+
derivedFromId:
|
|
24256
|
+
type: string
|
|
24257
|
+
variant:
|
|
24258
|
+
type: string
|
|
24229
24259
|
status:
|
|
24230
24260
|
type: string
|
|
24231
24261
|
enum:
|
|
@@ -24378,6 +24408,13 @@ components:
|
|
|
24378
24408
|
type: number
|
|
24379
24409
|
offset:
|
|
24380
24410
|
type: number
|
|
24411
|
+
include:
|
|
24412
|
+
type: array
|
|
24413
|
+
items:
|
|
24414
|
+
type: string
|
|
24415
|
+
enum:
|
|
24416
|
+
- temporary
|
|
24417
|
+
- derived
|
|
24381
24418
|
required:
|
|
24382
24419
|
- collectionId
|
|
24383
24420
|
AdminListAssetsResponse:
|
|
@@ -30603,6 +30640,135 @@ components:
|
|
|
30603
30640
|
type: boolean
|
|
30604
30641
|
FacetValueDefinition:
|
|
30605
30642
|
$ref: "#/components/schemas/FacetValue"
|
|
30643
|
+
PutFileRequest:
|
|
30644
|
+
type: object
|
|
30645
|
+
properties:
|
|
30646
|
+
name:
|
|
30647
|
+
type: string
|
|
30648
|
+
text:
|
|
30649
|
+
type: string
|
|
30650
|
+
base64:
|
|
30651
|
+
type: string
|
|
30652
|
+
json: {}
|
|
30653
|
+
contentType:
|
|
30654
|
+
type: string
|
|
30655
|
+
ttl:
|
|
30656
|
+
$ref: "#/components/schemas/FileTtl"
|
|
30657
|
+
appId:
|
|
30658
|
+
type: string
|
|
30659
|
+
required:
|
|
30660
|
+
- name
|
|
30661
|
+
FetchFileRequest:
|
|
30662
|
+
type: object
|
|
30663
|
+
properties:
|
|
30664
|
+
url:
|
|
30665
|
+
type: string
|
|
30666
|
+
ttl:
|
|
30667
|
+
$ref: "#/components/schemas/FileTtl"
|
|
30668
|
+
maxAge:
|
|
30669
|
+
$ref: "#/components/schemas/FileTtl"
|
|
30670
|
+
force:
|
|
30671
|
+
type: boolean
|
|
30672
|
+
appId:
|
|
30673
|
+
type: string
|
|
30674
|
+
required:
|
|
30675
|
+
- url
|
|
30676
|
+
FetchedFile:
|
|
30677
|
+
type: object
|
|
30678
|
+
properties:
|
|
30679
|
+
cached:
|
|
30680
|
+
type: boolean
|
|
30681
|
+
unchanged:
|
|
30682
|
+
type: boolean
|
|
30683
|
+
required:
|
|
30684
|
+
- cached
|
|
30685
|
+
ListFilesQuery:
|
|
30686
|
+
type: object
|
|
30687
|
+
properties:
|
|
30688
|
+
origin:
|
|
30689
|
+
type: object
|
|
30690
|
+
additionalProperties: true
|
|
30691
|
+
retention:
|
|
30692
|
+
type: object
|
|
30693
|
+
additionalProperties: true
|
|
30694
|
+
appId:
|
|
30695
|
+
type: string
|
|
30696
|
+
derivedFromId:
|
|
30697
|
+
type: string
|
|
30698
|
+
limit:
|
|
30699
|
+
type: number
|
|
30700
|
+
ExtractFileRequest:
|
|
30701
|
+
type: object
|
|
30702
|
+
properties:
|
|
30703
|
+
variant:
|
|
30704
|
+
$ref: "#/components/schemas/FileExtractVariant"
|
|
30705
|
+
schema:
|
|
30706
|
+
type: object
|
|
30707
|
+
additionalProperties: true
|
|
30708
|
+
prompt:
|
|
30709
|
+
type: string
|
|
30710
|
+
force:
|
|
30711
|
+
type: boolean
|
|
30712
|
+
required:
|
|
30713
|
+
- variant
|
|
30714
|
+
ExtractFileResponse:
|
|
30715
|
+
type: object
|
|
30716
|
+
properties:
|
|
30717
|
+
ok:
|
|
30718
|
+
type: object
|
|
30719
|
+
additionalProperties: true
|
|
30720
|
+
file:
|
|
30721
|
+
$ref: "#/components/schemas/FileRecord"
|
|
30722
|
+
text:
|
|
30723
|
+
type: string
|
|
30724
|
+
data: {}
|
|
30725
|
+
cached:
|
|
30726
|
+
type: boolean
|
|
30727
|
+
required:
|
|
30728
|
+
- ok
|
|
30729
|
+
- file
|
|
30730
|
+
- cached
|
|
30731
|
+
ReadFileResponse:
|
|
30732
|
+
type: object
|
|
30733
|
+
properties:
|
|
30734
|
+
ok:
|
|
30735
|
+
type: object
|
|
30736
|
+
additionalProperties: true
|
|
30737
|
+
text:
|
|
30738
|
+
type: string
|
|
30739
|
+
base64:
|
|
30740
|
+
type: string
|
|
30741
|
+
contentType:
|
|
30742
|
+
type: string
|
|
30743
|
+
size:
|
|
30744
|
+
type: number
|
|
30745
|
+
required:
|
|
30746
|
+
- ok
|
|
30747
|
+
- contentType
|
|
30748
|
+
- size
|
|
30749
|
+
FileLinkResponse:
|
|
30750
|
+
type: object
|
|
30751
|
+
properties:
|
|
30752
|
+
ok:
|
|
30753
|
+
type: object
|
|
30754
|
+
additionalProperties: true
|
|
30755
|
+
url:
|
|
30756
|
+
type: string
|
|
30757
|
+
expiresAt:
|
|
30758
|
+
type: string
|
|
30759
|
+
permanent:
|
|
30760
|
+
type: boolean
|
|
30761
|
+
required:
|
|
30762
|
+
- ok
|
|
30763
|
+
- url
|
|
30764
|
+
FileRecord:
|
|
30765
|
+
$ref: "#/components/schemas/Asset"
|
|
30766
|
+
FileTtl:
|
|
30767
|
+
type: object
|
|
30768
|
+
additionalProperties: true
|
|
30769
|
+
FileExtractVariant:
|
|
30770
|
+
type: object
|
|
30771
|
+
additionalProperties: true
|
|
30606
30772
|
AppDataField:
|
|
30607
30773
|
type: object
|
|
30608
30774
|
properties:
|
package/dist/types/asset.d.ts
CHANGED
|
@@ -98,6 +98,18 @@ export interface Asset {
|
|
|
98
98
|
/** Upload token used for public uploads */
|
|
99
99
|
uploadTokenId: string | null;
|
|
100
100
|
uploaderIp: string | null;
|
|
101
|
+
/** `temporary` files are removed at `expiresAt` and stay out of asset lists. Default `permanent`. */
|
|
102
|
+
retention?: 'permanent' | 'temporary';
|
|
103
|
+
/** When a temporary file goes. */
|
|
104
|
+
expiresAt?: string | null;
|
|
105
|
+
/** Where it came from: uploaded, fetched from an address, extracted from another file, or made by something. */
|
|
106
|
+
origin?: 'upload' | 'fetched' | 'derived' | 'generated';
|
|
107
|
+
/** What it is a copy or extract of (an address key, or `<fileId>:<variant>:<version>`). */
|
|
108
|
+
sourceKey?: string | null;
|
|
109
|
+
/** The file this was extracted from. */
|
|
110
|
+
derivedFromId?: string | null;
|
|
111
|
+
/** How it was extracted: `text`, `markdown`, `ocr`, `json`. */
|
|
112
|
+
variant?: string | null;
|
|
101
113
|
status: 'active' | 'pending_review' | 'deleted';
|
|
102
114
|
createdAt: string;
|
|
103
115
|
updatedAt: string;
|
|
@@ -239,6 +251,11 @@ export interface AdminListAssetsOptions {
|
|
|
239
251
|
order?: 'asc' | 'desc';
|
|
240
252
|
limit?: number;
|
|
241
253
|
offset?: number;
|
|
254
|
+
/**
|
|
255
|
+
* Also list files that are normally left out: `temporary` (not kept yet) and `derived` (text, Markdown or fields
|
|
256
|
+
* extracted from another file). Lists show only what people put there unless asked.
|
|
257
|
+
*/
|
|
258
|
+
include?: Array<'temporary' | 'derived'>;
|
|
242
259
|
}
|
|
243
260
|
export interface AdminListAssetsResponse {
|
|
244
261
|
data: Asset[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Asset } from "./asset.js";
|
|
2
|
+
/**
|
|
3
|
+
* A file: an asset that's temporary, fetched from an address, extracted from another file, or made by something.
|
|
4
|
+
* Files are private until kept, and stay out of asset lists (pickers, the Hub, the portal) unless kept.
|
|
5
|
+
*/
|
|
6
|
+
export type FileRecord = Asset;
|
|
7
|
+
/** How long a file lives: `1h` to `30d` (default `1d`). Kept files are permanent (see `files.keep`). */
|
|
8
|
+
export type FileTtl = `${number}h` | `${number}d` | number;
|
|
9
|
+
export type FileExtractVariant = "text" | "markdown" | "ocr" | "json";
|
|
10
|
+
export interface PutFileRequest {
|
|
11
|
+
name: string;
|
|
12
|
+
/** One of text, base64 or json. */
|
|
13
|
+
text?: string;
|
|
14
|
+
base64?: string;
|
|
15
|
+
json?: unknown;
|
|
16
|
+
contentType?: string;
|
|
17
|
+
ttl?: FileTtl;
|
|
18
|
+
appId?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FetchFileRequest {
|
|
21
|
+
/** A public web address (http/https). Private and internal addresses are refused. */
|
|
22
|
+
url: string;
|
|
23
|
+
ttl?: FileTtl;
|
|
24
|
+
/** How old a cached copy can be before the source is asked again (default: the ttl). */
|
|
25
|
+
maxAge?: FileTtl;
|
|
26
|
+
/** Ask the source again now (an unchanged page keeps the same file). */
|
|
27
|
+
force?: boolean;
|
|
28
|
+
appId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FetchedFile extends FileRecord {
|
|
31
|
+
/** True when this address was already here and fresh enough, or the source said it hasn't changed. */
|
|
32
|
+
cached: boolean;
|
|
33
|
+
/** True when the source answered "not changed" (the same file is returned). */
|
|
34
|
+
unchanged?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ListFilesQuery {
|
|
37
|
+
origin?: "upload" | "fetched" | "derived" | "generated";
|
|
38
|
+
retention?: "temporary" | "permanent";
|
|
39
|
+
appId?: string;
|
|
40
|
+
/** The results extracted from one file. */
|
|
41
|
+
derivedFromId?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ExtractFileRequest {
|
|
45
|
+
variant: FileExtractVariant;
|
|
46
|
+
/** For `json`: a JSON schema of the fields to pull out. */
|
|
47
|
+
schema?: Record<string, any>;
|
|
48
|
+
/** For `json`: what to look for, in words. */
|
|
49
|
+
prompt?: string;
|
|
50
|
+
/** Read the file again even if it was already read this way. */
|
|
51
|
+
force?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ExtractFileResponse {
|
|
54
|
+
ok: true;
|
|
55
|
+
/** The derived file holding the result (hidden from lists; lives as long as its source). */
|
|
56
|
+
file: FileRecord;
|
|
57
|
+
/** text / markdown / ocr */
|
|
58
|
+
text?: string;
|
|
59
|
+
/** json */
|
|
60
|
+
data?: any;
|
|
61
|
+
/** True when this file had already been read this way. */
|
|
62
|
+
cached: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface ReadFileResponse {
|
|
65
|
+
ok: true;
|
|
66
|
+
text?: string;
|
|
67
|
+
base64?: string;
|
|
68
|
+
contentType: string | null;
|
|
69
|
+
size: number;
|
|
70
|
+
}
|
|
71
|
+
export interface FileLinkResponse {
|
|
72
|
+
ok: true;
|
|
73
|
+
url: string;
|
|
74
|
+
/** When the signed link stops working (private files). */
|
|
75
|
+
expiresAt?: string;
|
|
76
|
+
/** True for a kept file: `url` is its permanent address. */
|
|
77
|
+
permanent?: boolean;
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
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>`
|
package/docs/admin-views.md
CHANGED
|
@@ -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` |
|
package/docs/assets.md
CHANGED
|
@@ -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
|
|
package/docs/files.md
ADDED
|
@@ -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.
|