@proveanything/smartlinks 2.0.66 → 2.0.68

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.
@@ -66,7 +66,7 @@ deterministically. A connector's `shape` and `serialize` must be deterministic t
66
66
  "aiGuide": "connector-ai-guide.md"
67
67
  },
68
68
  "functions": {
69
- "files": { "js": { "umd": "dist/functions.umd.js" } },
69
+ "files": { "js": { "umd": "functions.umd.js" } },
70
70
  "definitions": [
71
71
  { "name": "testConnection", "trigger": { "type": "http", "method": "POST" },
72
72
  "visibility": "admin", "authority": "collection",
@@ -33,7 +33,7 @@ in a bundle alongside your widgets/containers:
33
33
  ```jsonc
34
34
  {
35
35
  "functions": {
36
- "files": { "js": { "umd": "dist/functions.umd.js" } },
36
+ "files": { "js": { "umd": "functions.umd.js" } },
37
37
  "definitions": [
38
38
  {
39
39
  "name": "submitCompetitionEntry",
@@ -98,9 +98,12 @@ export default defineConfig({
98
98
  }
99
99
  ```
100
100
 
101
- That emits `dist/functions.umd.js` (matching `functions.files.js.umd`), whose named exports the
102
- platform pairs with your manifest `definitions`. Then **deploy** it — for dev,
103
- `smartlinks-publish` uploads `dist/` and registers in one step (see
101
+ That emits `dist/functions.umd.js`, whose named exports the platform pairs with your manifest
102
+ `definitions`. In the manifest, `functions.files.js.umd` is **`functions.umd.js`** — relative to the
103
+ published build (the contents of `dist/`), like the widget and container files; not
104
+ `dist/functions.umd.js`. Publishing refuses a release whose functions bundle isn't there.
105
+
106
+ Then **deploy** it — for dev, `smartlinks-publish` uploads `dist/` and registers in one step (see
104
107
  [Deploying & registering](deploying-apps.md)).
105
108
 
106
109
  ---
@@ -169,6 +172,7 @@ Declare the minimum you need.
169
172
  | `network:<host>` | `ctx.fetch` to that host only (repeat for several). Prefer this over blanket `network`. |
170
173
  | `network:*.<domain>` | `ctx.fetch` to any subdomain of `<domain>` (not `<domain>` itself), for a customer's own endpoint at a provider, e.g. `network:*.servicebus.windows.net`. `<domain>` needs at least two labels (`*.com` is not honoured). |
171
174
  | `secrets:<name>` | `ctx.secrets.get('<name>')` for that one secret (see [Secrets](#secrets--api-keys-per-collection)). |
175
+ | `tools:<name>` / `tools:<family>.*` | `ctx.sl.tools.run('<name>', args)` for a platform tool, e.g. `tools:pdf.create`, or `tools:pdf.*` for every PDF tool (see [Platform tools](#platform-tools--pdfs-labels-barcodes)). |
172
176
 
173
177
  If you don't declare `network`, `ctx.fetch` is absent. Reading a secret you didn't declare with
174
178
  `secrets:<name>` throws.
@@ -606,6 +610,58 @@ await ctx.sl.interactions.record({
606
610
 
607
611
  ---
608
612
 
613
+ ## Platform tools — PDFs, labels, barcodes
614
+
615
+ `ctx.sl.tools.run(name, args)` runs one of the platform's deterministic tools from your function: no
616
+ model, no agent loop. Declare each tool as a capability: `tools:pdf.create`, or `tools:pdf.*` for the
617
+ whole family. Open to functions: `pdf.create`, `pdf.merge`, `pdf.fill`, `pdf.inspect`, `pdf.render`,
618
+ `pdf.decodeBarcodes`, `pdf.inspectGraphics`, `pdf.preflight`, `pdf.printReady`, `pdf.edit`,
619
+ `image.transform` (arguments as in [ai.md](ai.md)).
620
+
621
+ - **Identity:** the call runs as the function's collection, whatever the caller. An anonymous caller
622
+ holding only your own key gets the same result; the work is attributed and billed to the collection.
623
+ - **Rate:** per collection (10 calls a second by default); bursts wait rather than fail.
624
+ - **Failure:** throws an `Error` with `code` (`bad_args`, `too_large`, `too_many_pages`,
625
+ `resource_timeout`, `timeout`, `busy`, `TOOL_NOT_AVAILABLE`, or a capability denial).
626
+
627
+ **Labels with `pdf.create`.** Exact page sizes, many pages in one render, and bytes straight back:
628
+
629
+ ```ts
630
+ // capabilities: ["tools:pdf.create", "tools:pdf.decodeBarcodes"]
631
+ export async function printLabel(ctx, event) {
632
+ const { gtin, lot, expiry, qty = 1 } = event.body
633
+ const barcode = bwipjs.toSVG({ bcid: 'gs1-128', text: `(01)${gtin}(10)${lot}(17)${expiry}` }) // inline SVG
634
+ const pdf = await ctx.sl.tools.run('pdf.create', {
635
+ width: 100, height: 50, unit: 'mm', // exact; output is 1:1
636
+ head: '<style>.l{position:absolute;font:3mm Arial}</style>',
637
+ pages: Array.from({ length: qty }, () => `<div class="l" style="left:4mm;top:3mm">Lot ${lot}</div>
638
+ <div style="position:absolute;left:4mm;top:10mm;width:92mm">${barcode}</div>`),
639
+ return: 'base64', // or 'signedUrl' + expiresIn
640
+ })
641
+ return { pdf: pdf.base64, pages: pdf.pageCount }
642
+ }
643
+ ```
644
+
645
+ - **Page size:** `width` + `height` (+ `unit`: mm, cm, in, pt, px) is exact to the point. Otherwise
646
+ `format` ("A4", "Letter"), or the document's own CSS `@page { size }` when neither is given.
647
+ - **Pages:** `pages: [html, …]` lays one fragment per page; with an exact size and no margin each page
648
+ box is that size (overflow hidden), so a long value can't push onto the next label. Up to 2000 pages
649
+ and 10 MB of HTML per render.
650
+ - **Output:** 1:1 at scale 1 with backgrounds; text stays text and SVG stays vector (render barcodes as
651
+ inline SVG, e.g. bwip-js `toSVG`, never as a canvas bitmap). Colour is RGB; for CMYK pass the result
652
+ through `pdf.printReady`.
653
+ - **What loads:** JavaScript does not run. Images, fonts and stylesheets load only from SmartLinks hosts
654
+ (our CDN), Google Fonts or inline `data:` URIs; anything else is skipped and listed in `warnings`.
655
+ Embed brand fonts as `data:` URIs in `@font-face`, or host them on the SmartLinks CDN.
656
+ - **Delivery:** `return: 'base64'` (nothing stored), `'signedUrl'` (private link that expires after
657
+ `expiresIn` seconds, default 900, max 7 days — use this for anything with lot, expiry or serial
658
+ data), or `'url'` (public and permanent — artwork and documents meant to be shared).
659
+ - **Cache:** the same inputs return the earlier render without rendering again (`cached: true`).
660
+ - **Verify:** `pdf.decodeBarcodes` on a `signedUrl` reads the codes back deterministically, so you can
661
+ confirm the digits before answering.
662
+
663
+ ---
664
+
609
665
  ## Worked example — a public competition entry
610
666
 
611
667
  ```ts
package/openapi.yaml CHANGED
@@ -2077,6 +2077,45 @@ paths:
2077
2077
  description: Unauthorized
2078
2078
  404:
2079
2079
  description: Not found
2080
+ /admin/collection/{collectionId}/authKit/{authKitId}/identity:
2081
+ post:
2082
+ tags:
2083
+ - authKit
2084
+ summary: "Give this AuthKit its **own logins** (admin): its members become accounts of this site only — the same email can be a separate account, with its own password, on another site — rather than SmartLinks accounts shared across sites."
2085
+ operationId: authKit_setIdentity
2086
+ security:
2087
+ - bearerAuth: []
2088
+ parameters:
2089
+ - name: collectionId
2090
+ in: path
2091
+ required: true
2092
+ schema:
2093
+ type: string
2094
+ - name: authKitId
2095
+ in: path
2096
+ required: true
2097
+ schema:
2098
+ type: string
2099
+ responses:
2100
+ 200:
2101
+ description: Success
2102
+ content:
2103
+ application/json:
2104
+ schema:
2105
+ $ref: "#/components/schemas/AuthKitSetIdentityResponse"
2106
+ 400:
2107
+ description: Bad request
2108
+ 401:
2109
+ description: Unauthorized
2110
+ 404:
2111
+ description: Not found
2112
+ requestBody:
2113
+ required: true
2114
+ content:
2115
+ application/json:
2116
+ schema:
2117
+ type: object
2118
+ additionalProperties: true
2080
2119
  /admin/collection/{collectionId}/batch:
2081
2120
  get:
2082
2121
  tags:
@@ -3715,7 +3754,7 @@ paths:
3715
3754
  get:
3716
3755
  tags:
3717
3756
  - collection
3718
- summary: "Get the managed-certificate status for a collection's custom domain (admin only)."
3757
+ summary: "Get the certificate status of the collection's own domain (admin only)."
3719
3758
  operationId: collection_getDomainStatus
3720
3759
  security:
3721
3760
  - bearerAuth: []
@@ -3740,7 +3779,7 @@ paths:
3740
3779
  post:
3741
3780
  tags:
3742
3781
  - collection
3743
- summary: Register a custom domain for a collection and provision its managed certificate (admin only).
3782
+ summary: "Connect one of the collection's own domains and start its certificate (admin only)."
3744
3783
  operationId: collection_registerDomain
3745
3784
  security:
3746
3785
  - bearerAuth: []
@@ -8339,7 +8378,7 @@ paths:
8339
8378
  get:
8340
8379
  tags:
8341
8380
  - tags
8342
- summary: Reverse lookup — find all tags linked to a given object (admin).
8381
+ summary: Reverse lookup — find all tags linked to a given object (admin).
8343
8382
  operationId: tags_byRef
8344
8383
  security:
8345
8384
  - bearerAuth: []
@@ -9207,7 +9246,7 @@ paths:
9207
9246
  post:
9208
9247
  tags:
9209
9248
  - authKit
9210
- summary: authKit.linkedInLogin
9249
+ summary: Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public).
9211
9250
  operationId: authKit_linkedInLogin
9212
9251
  security: []
9213
9252
  parameters:
@@ -14108,7 +14147,7 @@ paths:
14108
14147
  get:
14109
14148
  tags:
14110
14149
  - tags
14111
- summary: "Global tag resolve — returns `{ tagId, collectionId }` only."
14150
+ summary: "Global tag resolve — returns `{ tagId, collectionId }` only."
14112
14151
  operationId: tags_resolveTag
14113
14152
  security: []
14114
14153
  parameters:
@@ -17499,14 +17538,74 @@ components:
17499
17538
  properties:
17500
17539
  html:
17501
17540
  type: string
17541
+ pages:
17542
+ type: array
17543
+ items:
17544
+ type: string
17545
+ head:
17546
+ type: string
17547
+ width:
17548
+ type: number
17549
+ height:
17550
+ type: number
17551
+ unit:
17552
+ type: string
17553
+ enum:
17554
+ - mm
17555
+ - cm
17556
+ - in
17557
+ - pt
17558
+ - px
17502
17559
  format:
17503
17560
  type: string
17504
17561
  landscape:
17505
17562
  type: boolean
17506
17563
  margin:
17507
17564
  type: string
17565
+ return:
17566
+ type: string
17567
+ enum:
17568
+ - url
17569
+ - signedUrl
17570
+ - base64
17571
+ expiresIn:
17572
+ type: number
17573
+ filename:
17574
+ type: string
17575
+ cache:
17576
+ type: boolean
17577
+ PdfCreateResult:
17578
+ type: object
17579
+ properties:
17580
+ url:
17581
+ type: string
17582
+ hostedUrl:
17583
+ type: string
17584
+ base64:
17585
+ type: string
17586
+ expiresAt:
17587
+ type: string
17588
+ contentType:
17589
+ type: string
17590
+ enum:
17591
+ - application/pdf
17592
+ size:
17593
+ type: number
17594
+ pageCount:
17595
+ type: number
17596
+ cached:
17597
+ type: boolean
17598
+ renderer:
17599
+ type: string
17600
+ warnings:
17601
+ type: array
17602
+ items:
17603
+ type: string
17508
17604
  required:
17509
- - html
17605
+ - contentType
17606
+ - size
17607
+ - pageCount
17608
+ - cached
17510
17609
  PdfFillArgs:
17511
17610
  type: object
17512
17611
  properties:
@@ -19657,6 +19756,9 @@ components:
19657
19756
  interactions:
19658
19757
  type: object
19659
19758
  additionalProperties: true
19759
+ tools:
19760
+ type: object
19761
+ additionalProperties: true
19660
19762
  products: {}
19661
19763
  attestations: {}
19662
19764
  appData:
@@ -19667,6 +19769,7 @@ components:
19667
19769
  - tags
19668
19770
  - contacts
19669
19771
  - interactions
19772
+ - tools
19670
19773
  - products
19671
19774
  - attestations
19672
19775
  - appData
@@ -23263,8 +23366,38 @@ components:
23263
23366
  type: string
23264
23367
  security:
23265
23368
  $ref: "#/components/schemas/AuthKitSecurityConfig"
23369
+ collectionIds:
23370
+ type: array
23371
+ items:
23372
+ type: string
23373
+ identity:
23374
+ $ref: "#/components/schemas/AuthKitIdentity"
23266
23375
  required:
23267
23376
  - id
23377
+ AuthKitIdentity:
23378
+ type: object
23379
+ properties:
23380
+ mode:
23381
+ type: string
23382
+ enum:
23383
+ - shared
23384
+ - own
23385
+ tenantId:
23386
+ type: string
23387
+ createdAt:
23388
+ type: string
23389
+ required:
23390
+ - mode
23391
+ AuthKitSetIdentityResponse:
23392
+ type: object
23393
+ properties:
23394
+ identity:
23395
+ $ref: "#/components/schemas/AuthKitIdentity"
23396
+ message:
23397
+ type: string
23398
+ required:
23399
+ - identity
23400
+ - message
23268
23401
  AuthKitSecurityConfig:
23269
23402
  type: object
23270
23403
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "2.0.66",
3
+ "version": "2.0.68",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",