@proveanything/smartlinks 2.0.32 → 2.0.34
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/dist/ai-tools.d.ts +1 -0
- package/dist/ai-tools.js +4 -1
- package/dist/docs/API_SUMMARY.md +75 -5
- package/dist/docs/ai.md +24 -5
- package/dist/docs/app-objects.md +33 -0
- package/dist/docs/server-functions.md +629 -628
- package/dist/openapi.yaml +112 -4
- package/dist/types/ai.d.ts +76 -2
- package/docs/API_SUMMARY.md +75 -5
- package/docs/ai.md +24 -5
- package/docs/app-objects.md +33 -0
- package/docs/server-functions.md +629 -628
- package/openapi.yaml +112 -4
- package/package.json +1 -1
- package/scripts/publish.mjs +147 -99
package/dist/ai-tools.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const AI_TOOL_NAMES: {
|
|
|
23
23
|
readonly IMAGE_FROM_REFERENCE: "image.fromReference";
|
|
24
24
|
readonly IMAGE_SEARCH_STOCK: "image.searchStock";
|
|
25
25
|
readonly IMAGE_TRANSFORM: "image.transform";
|
|
26
|
+
readonly IMAGE_OCR: "image.ocr";
|
|
26
27
|
readonly PDF_CREATE: "pdf.create";
|
|
27
28
|
readonly PDF_FILL: "pdf.fill";
|
|
28
29
|
readonly PDF_MERGE: "pdf.merge";
|
package/dist/ai-tools.js
CHANGED
|
@@ -20,6 +20,7 @@ export const AI_TOOL_NAMES = {
|
|
|
20
20
|
IMAGE_FROM_REFERENCE: 'image.fromReference',
|
|
21
21
|
IMAGE_SEARCH_STOCK: 'image.searchStock',
|
|
22
22
|
IMAGE_TRANSFORM: 'image.transform',
|
|
23
|
+
IMAGE_OCR: 'image.ocr',
|
|
23
24
|
PDF_CREATE: 'pdf.create',
|
|
24
25
|
PDF_FILL: 'pdf.fill',
|
|
25
26
|
PDF_MERGE: 'pdf.merge',
|
|
@@ -66,7 +67,9 @@ export const BUILTIN_AI_TOOLS = [
|
|
|
66
67
|
{ name: 'pdf.inspect', group: 'media', capabilities: ['web:read'],
|
|
67
68
|
description: 'Cheaply introspect a PDF before any AI call: page count/sizes, whether each page has an extractable text layer, whether a raster image is present, and a routing recommendation (text-native → cheap text pass; curve-only/raster → vision/OCR). Deterministic, no AI.' },
|
|
68
69
|
{ name: 'pdf.render', group: 'media', capabilities: ['web:read'],
|
|
69
|
-
description: 'Rasterize a single PDF page to a PNG at a controllable DPI
|
|
70
|
+
description: 'Rasterize a single PDF page — or just a region (clip {x0,y0,x1,y1}, 0–1 from top-left) — to a PNG at a controllable DPI and return a permanent hosted image URL. Max 40 MP per call; larger requests return code "too_large" with suggestedDpi.' },
|
|
71
|
+
{ name: 'image.ocr', group: 'media', capabilities: ['web:read'],
|
|
72
|
+
description: 'Deterministic OCR (Google Vision, no generative model): exact characters with per-word confidence and pixel boxes, plus lines as printed. Input an imageUrl, or a PDF url + page + dpi + optional clip. For small print and outlined text — never "corrects" misspellings.' },
|
|
70
73
|
{ name: 'pdf.extract', group: 'media', capabilities: ['web:read', 'ai:vision'],
|
|
71
74
|
description: 'Extract typed JSON from a PDF in one call given a schema and/or prompt. Auto-routes: text-layer pages use cheap text extraction; curve-only/raster pages are rendered and read with vision. Optional per-field confidence/source (includeConfidence) and bounding boxes (includeBoxes).' },
|
|
72
75
|
{ name: 'pdf.decodeBarcodes', group: 'media', capabilities: ['web:read'],
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.34 | Generated: 2026-10-02T16:06:32.154Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -1447,10 +1447,32 @@ interface ImageTransformArgs {
|
|
|
1447
1447
|
}
|
|
1448
1448
|
```
|
|
1449
1449
|
|
|
1450
|
+
**ImageOcrArgs** (interface)
|
|
1451
|
+
```typescript
|
|
1452
|
+
interface ImageOcrArgs {
|
|
1453
|
+
imageUrl?: string
|
|
1454
|
+
url?: string
|
|
1455
|
+
page?: number
|
|
1456
|
+
dpi?: number
|
|
1457
|
+
clip?: PdfClip
|
|
1458
|
+
languages?: string[]
|
|
1459
|
+
}
|
|
1460
|
+
```
|
|
1461
|
+
|
|
1462
|
+
**PdfClip** (interface)
|
|
1463
|
+
```typescript
|
|
1464
|
+
interface PdfClip {
|
|
1465
|
+
x0: number; y0: number; x1: number; y1: number
|
|
1466
|
+
}
|
|
1467
|
+
```
|
|
1468
|
+
|
|
1450
1469
|
**PdfCreateArgs** (interface)
|
|
1451
1470
|
```typescript
|
|
1452
1471
|
interface PdfCreateArgs {
|
|
1453
|
-
html: string
|
|
1472
|
+
html: string
|
|
1473
|
+
format?: string
|
|
1474
|
+
landscape?: boolean
|
|
1475
|
+
margin?: string
|
|
1454
1476
|
}
|
|
1455
1477
|
```
|
|
1456
1478
|
|
|
@@ -1478,7 +1500,10 @@ interface PdfInspectArgs {
|
|
|
1478
1500
|
**PdfRenderArgs** (interface)
|
|
1479
1501
|
```typescript
|
|
1480
1502
|
interface PdfRenderArgs {
|
|
1481
|
-
url: string
|
|
1503
|
+
url: string
|
|
1504
|
+
page?: number
|
|
1505
|
+
dpi?: number
|
|
1506
|
+
clip?: PdfClip
|
|
1482
1507
|
}
|
|
1483
1508
|
```
|
|
1484
1509
|
|
|
@@ -1532,6 +1557,7 @@ interface AiToolArgsMap {
|
|
|
1532
1557
|
'image.fromReference': ImageFromReferenceArgs
|
|
1533
1558
|
'image.searchStock': ImageSearchStockArgs
|
|
1534
1559
|
'image.transform': ImageTransformArgs
|
|
1560
|
+
'image.ocr': ImageOcrArgs
|
|
1535
1561
|
'pdf.create': PdfCreateArgs
|
|
1536
1562
|
'pdf.fill': PdfFillArgs
|
|
1537
1563
|
'pdf.merge': PdfMergeArgs
|
|
@@ -1590,7 +1616,7 @@ interface ImageDescribeResult {
|
|
|
1590
1616
|
**HostedAssetResult** (interface)
|
|
1591
1617
|
```typescript
|
|
1592
1618
|
interface HostedAssetResult {
|
|
1593
|
-
|
|
1619
|
+
|
|
1594
1620
|
}
|
|
1595
1621
|
```
|
|
1596
1622
|
|
|
@@ -1625,7 +1651,51 @@ interface PdfInspectResult {
|
|
|
1625
1651
|
**PdfRenderResult** (interface)
|
|
1626
1652
|
```typescript
|
|
1627
1653
|
interface PdfRenderResult {
|
|
1628
|
-
url: string | null; page: number; pageCount: number; dpi: number; width: number; height: number
|
|
1654
|
+
url: string | null; page: number; pageCount: number; dpi: number; width: number; height: number; clip?: PdfClip
|
|
1655
|
+
}
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
**PdfRenderTooLarge** (interface)
|
|
1659
|
+
```typescript
|
|
1660
|
+
interface PdfRenderTooLarge {
|
|
1661
|
+
error: string; code: 'too_large'; requestedPixels: number; maxPixels: number; suggestedDpi: number; width: number; height: number
|
|
1662
|
+
}
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
**OcrBox** (interface)
|
|
1666
|
+
```typescript
|
|
1667
|
+
interface OcrBox {
|
|
1668
|
+
x: number; y: number; w: number; h: number
|
|
1669
|
+
}
|
|
1670
|
+
```
|
|
1671
|
+
|
|
1672
|
+
**OcrWord** (interface)
|
|
1673
|
+
```typescript
|
|
1674
|
+
interface OcrWord {
|
|
1675
|
+
text: string; confidence: number; bbox: OcrBox
|
|
1676
|
+
}
|
|
1677
|
+
```
|
|
1678
|
+
|
|
1679
|
+
**OcrLine** (interface)
|
|
1680
|
+
```typescript
|
|
1681
|
+
interface OcrLine {
|
|
1682
|
+
text: string; confidence: number; bbox: OcrBox
|
|
1683
|
+
}
|
|
1684
|
+
```
|
|
1685
|
+
|
|
1686
|
+
**ImageOcrResult** (interface)
|
|
1687
|
+
```typescript
|
|
1688
|
+
interface ImageOcrResult {
|
|
1689
|
+
words: OcrWord[]
|
|
1690
|
+
lines: OcrLine[]
|
|
1691
|
+
text: string
|
|
1692
|
+
width: number | null
|
|
1693
|
+
height: number | null
|
|
1694
|
+
languages: string[]
|
|
1695
|
+
page?: number
|
|
1696
|
+
dpi?: number
|
|
1697
|
+
clip?: PdfClip
|
|
1698
|
+
engine: string
|
|
1629
1699
|
}
|
|
1630
1700
|
```
|
|
1631
1701
|
|
package/dist/docs/ai.md
CHANGED
|
@@ -327,7 +327,8 @@ in `input`.
|
|
|
327
327
|
| `pdf.fill` | Fill an AcroForm PDF's fields (`{ field: value }`) → hosted URL. |
|
|
328
328
|
| `pdf.merge` | Merge several PDFs into one, in order → hosted URL. |
|
|
329
329
|
| `pdf.inspect` | Cheap, no-AI introspection: page count/sizes, which pages have a real text layer, raster present, and a routing hint (`text` vs `vision`). |
|
|
330
|
-
| `pdf.render` | Rasterize one page to a PNG at a chosen DPI → hosted image URL (
|
|
330
|
+
| `pdf.render` | Rasterize one page — or just a region (`clip: { x0, y0, x1, y1 }`, 0–1 from top-left) — to a PNG at a chosen DPI → hosted image URL (permanent). Max 40 MP per call; larger requests return `code: "too_large"` + `suggestedDpi`. |
|
|
331
|
+
| `image.ocr` | **Deterministic OCR** (Google Vision, no generative model): exact characters with per-word `confidence` (0–1) and pixel `bbox`, plus lines with spacing as printed. Input: `imageUrl`, or a PDF `url` + `page` + `dpi` + optional `clip`. Optional `languages` hints. Use for small print and text outlined to curves. |
|
|
331
332
|
| `pdf.extract` | PDF → typed JSON in one call (schema and/or prompt). Auto-routes text vs vision. Optional per-field `confidence`/`source` (`includeConfidence`) and `bbox` (`includeBoxes`) in `fieldsMeta`. |
|
|
332
333
|
| `pdf.decodeBarcodes` | Deterministically decode barcodes/QR on a page (WASM, no AI) → value + symbology + page + bbox + confidence. Use this for barcode digits, never vision. |
|
|
333
334
|
| `pdf.inspectGraphics` | Prepress inspection: per-page path/image/outlined-text counts + colour spaces, plus named SPOT colours (e.g. "PANTONE 871 C"). No AI. |
|
|
@@ -341,18 +342,36 @@ in `input`.
|
|
|
341
342
|
returns typed JSON). It routes itself, but you can drive the route yourself: call `pdf.inspect`
|
|
342
343
|
first (deterministic, no AI) to see whether each page has a real text layer, then `pdf.extract`
|
|
343
344
|
(cheap text path) or `pdf.render` → `image.describe`/vision for curve-only or raster artwork.
|
|
344
|
-
- **
|
|
345
|
-
the
|
|
345
|
+
- **Read small print exactly** (INCI/allergen lists, net weight, text outlined to curves) → `image.ocr`
|
|
346
|
+
with a PDF `url`, `page`, `dpi: 300–400` and a `clip` around the panel. It returns the characters it
|
|
347
|
+
sees with a per-word confidence — it never "corrects" a misspelling the way a vision model can, so
|
|
348
|
+
flag words below ~0.9 for human review rather than re-reading them with a model.
|
|
349
|
+
- **Zoom in visually** (layout, artwork) → `pdf.render` with `clip` to rasterise just a region at a high
|
|
350
|
+
DPI, instead of the whole sheet. Renders over 40 MP return `code: "too_large"` with `suggestedDpi`
|
|
351
|
+
— retry at that dpi or with a smaller clip, don't blind-retry.
|
|
346
352
|
- **Barcodes / QR** → `pdf.decodeBarcodes` (deterministic WASM decode) — never trust vision for barcode
|
|
347
353
|
digits; it hallucinates them.
|
|
348
354
|
- **Prepress / print QA** (spot colours, colour spaces, vector vs raster) → `pdf.inspectGraphics`.
|
|
349
355
|
- **A review UI that flags guessed fields** → `pdf.extract` with `includeConfidence` (per-field
|
|
350
356
|
confidence + source) and `includeBoxes` (per-field bbox on text-native pages) in `fieldsMeta`.
|
|
351
357
|
- **Produce a PDF** → `pdf.create` (HTML → PDF), `pdf.fill` (populate an AcroForm's fields),
|
|
352
|
-
`pdf.merge` (combine several). These return a hosted `hostedUrl
|
|
358
|
+
`pdf.merge` (combine several). These return a hosted `hostedUrl` (`pdf.create` also returns it as
|
|
359
|
+
`url`). `pdf.create` loads remote `<img>` URLs before rendering and honours `page-break-inside`; pass
|
|
360
|
+
`margin: "0"` when your HTML sets its own body margin (default page margin is 18mm/14mm).
|
|
353
361
|
|
|
354
362
|
Every tool is also directly callable without the model loop via `ai.tools.run(collectionId, name,
|
|
355
|
-
args)` — e.g. render a page or extract fields straight from a UI, no agent round-trip
|
|
363
|
+
args)` — e.g. render a page or extract fields straight from a UI, no agent round-trip:
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
// Read the ingredients panel of a sleeve exactly (deterministic OCR of a clipped region)
|
|
367
|
+
const { result } = await SL.ai.tools.run(collectionId, 'image.ocr', {
|
|
368
|
+
url: sleevePdfUrl, page: 1, dpi: 400,
|
|
369
|
+
clip: { x0: 0.40, y0: 0.20, x1: 0.60, y1: 0.40 },
|
|
370
|
+
languages: ['en', 'fr'],
|
|
371
|
+
})
|
|
372
|
+
// result.lines → [{ text: 'INGREDIENTS: Aqua, Glycerin, …', confidence: 0.97, bbox: {…} }]
|
|
373
|
+
const toReview = result.words.filter((w) => w.confidence < 0.9)
|
|
374
|
+
```
|
|
356
375
|
|
|
357
376
|
Discover tools two ways:
|
|
358
377
|
- **Design time (typed):** import `BUILTIN_AI_TOOLS`, `AI_TOOL_NAMES`, and the per-tool arg types
|
package/dist/docs/app-objects.md
CHANGED
|
@@ -747,6 +747,39 @@ const results = await app.records.list(collectionId, appId, {
|
|
|
747
747
|
|
|
748
748
|
> `q` is not a full-text index and does not return ranked results. For ranked relevance search over large corpora, use the Elasticsearch integration.
|
|
749
749
|
|
|
750
|
+
**Admin: search other data fields (`qFields`).** On the admin endpoint, `qFields` chooses which top-level `data` keys `q` searches (comma-separated, max 5; default `label`):
|
|
751
|
+
|
|
752
|
+
```typescript
|
|
753
|
+
const page = await app.records.list(collectionId, appId, {
|
|
754
|
+
recordType: 'packaging-field',
|
|
755
|
+
q: 'best before',
|
|
756
|
+
qFields: 'value,label', // match data.value OR data.label
|
|
757
|
+
limit: 100, offset: 0,
|
|
758
|
+
}, true);
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### Filtering on data fields (admin)
|
|
762
|
+
|
|
763
|
+
On the admin endpoint, `dataFilter` filters on **top-level `data` keys** — an exact match, an `in:a,b,c` list, or an array (any value matches). Up to 10 keys; combine freely with `recordType`, `status`, `q`/`qFields` and pagination:
|
|
764
|
+
|
|
765
|
+
```typescript
|
|
766
|
+
const page = await app.records.list(collectionId, appId, {
|
|
767
|
+
recordType: 'packaging-field',
|
|
768
|
+
dataFilter: {
|
|
769
|
+
versionId: 'ver_123', // data.versionId = 'ver_123'
|
|
770
|
+
zone: 'in:on_pack,unclear', // data.zone is one of these
|
|
771
|
+
},
|
|
772
|
+
limit: 100, offset: 0,
|
|
773
|
+
}, true);
|
|
774
|
+
|
|
775
|
+
page.pagination.total // matches across all pages
|
|
776
|
+
page.pagination.hasMore // keep paging while true
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
- Values are compared as text (`data->>key`); nested keys and joins aren't supported.
|
|
780
|
+
- `limit` is capped at **100** per page — page with `offset` while `hasMore` is true.
|
|
781
|
+
- `status` also accepts `in:a,b` (e.g. `status: 'in:active,draft'`).
|
|
782
|
+
|
|
750
783
|
### External ID / ETL Workflow
|
|
751
784
|
|
|
752
785
|
`customId` and `sourceSystem` provide a stable external key pair for loading records from external systems (CMS, ERP, PIM, etc.):
|