@proveanything/smartlinks 2.1.24 → 2.1.28
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/api/claimSet.d.ts +8 -2
- package/dist/api/claimSet.js +11 -3
- package/dist/api/containers.d.ts +1 -1
- package/dist/api/containers.js +1 -1
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/places.d.ts +16 -0
- package/dist/api/places.js +16 -0
- package/dist/api/tagCodes.d.ts +17 -0
- package/dist/api/tagCodes.js +28 -0
- package/dist/api/wallet.d.ts +93 -0
- package/dist/api/wallet.js +86 -0
- package/dist/docs/API_SUMMARY.md +192 -1
- package/dist/docs/i18n.md +68 -1
- package/dist/docs/tag-codes.md +97 -0
- package/dist/docs/wallet-passes.md +87 -0
- package/dist/i18n.d.ts +49 -0
- package/dist/i18n.js +298 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/openapi.yaml +324 -0
- package/dist/types/claimSet.d.ts +106 -1
- package/dist/types/containers.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/wallet.d.ts +92 -0
- package/dist/types/wallet.js +1 -0
- package/docs/API_SUMMARY.md +192 -1
- package/docs/i18n.md +68 -1
- package/docs/tag-codes.md +97 -0
- package/docs/wallet-passes.md +87 -0
- package/openapi.yaml +324 -0
- package/package.json +1 -1
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.28 | Generated: 2026-11-20T09:02:04.143Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -160,14 +160,17 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
160
160
|
- **operations** - Functions for operations operations
|
|
161
161
|
- **order** - Functions for order operations
|
|
162
162
|
- **partner** - Functions for partner operations
|
|
163
|
+
- **places** - Functions for places operations
|
|
163
164
|
- **products** - Functions for products operations
|
|
164
165
|
- **realtime** - Functions for realtime operations
|
|
165
166
|
- **research** - Functions for research operations
|
|
166
167
|
- **secrets** - Functions for secrets operations
|
|
168
|
+
- **tagCodes** - Functions for tagCodes operations
|
|
167
169
|
- **tags** - Functions for tags operations
|
|
168
170
|
- **template** - Functions for template operations
|
|
169
171
|
- **translations** - Functions for translations operations
|
|
170
172
|
- **userGroups** - Functions for userGroups operations
|
|
173
|
+
- **wallet** - Functions for wallet operations
|
|
171
174
|
|
|
172
175
|
## HTTP Utilities
|
|
173
176
|
|
|
@@ -6278,6 +6281,7 @@ interface AssignClaimSetRangeRequest {
|
|
|
6278
6281
|
```typescript
|
|
6279
6282
|
interface AssignClaimSetRangeResponse {
|
|
6280
6283
|
changed: number
|
|
6284
|
+
wholeRange?: boolean
|
|
6281
6285
|
skipped: Array<{ code: string; index: number; reason: 'other_range' | 'has_proof' | 'assigned_elsewhere'; collectionId?: string }>
|
|
6282
6286
|
range: ClaimSetRange
|
|
6283
6287
|
}
|
|
@@ -6319,6 +6323,10 @@ interface PartnerClaimSet {
|
|
|
6319
6323
|
tapDomain: string
|
|
6320
6324
|
owner: { type: 'platform' | 'partner' | 'collection' | 'user'; id: string | null }
|
|
6321
6325
|
codes: number
|
|
6326
|
+
codeSource?: 'stored' | 'computed'
|
|
6327
|
+
sigBits?: number
|
|
6328
|
+
bareCodes?: boolean
|
|
6329
|
+
unassignedUrl?: string | null
|
|
6322
6330
|
deleted: boolean
|
|
6323
6331
|
createdAt: string | null
|
|
6324
6332
|
}
|
|
@@ -6342,6 +6350,47 @@ interface CreatePartnerClaimSetRequest {
|
|
|
6342
6350
|
name: string
|
|
6343
6351
|
tagType: ClaimSetTagType
|
|
6344
6352
|
tapDomain?: string
|
|
6353
|
+
codeSource?: 'stored' | 'computed'
|
|
6354
|
+
sigBits?: number
|
|
6355
|
+
bareCodes?: boolean
|
|
6356
|
+
unassignedUrl?: string
|
|
6357
|
+
}
|
|
6358
|
+
```
|
|
6359
|
+
|
|
6360
|
+
**TagCodeRef** (interface)
|
|
6361
|
+
```typescript
|
|
6362
|
+
interface TagCodeRef {
|
|
6363
|
+
scan?: string
|
|
6364
|
+
url?: string
|
|
6365
|
+
claimSetId?: string
|
|
6366
|
+
code?: string
|
|
6367
|
+
tagId?: string
|
|
6368
|
+
}
|
|
6369
|
+
```
|
|
6370
|
+
|
|
6371
|
+
**TagCodeState** (interface)
|
|
6372
|
+
```typescript
|
|
6373
|
+
interface TagCodeState {
|
|
6374
|
+
kind: 'claim' | 'chip'
|
|
6375
|
+
claimSetId?: string
|
|
6376
|
+
code?: string
|
|
6377
|
+
url?: string
|
|
6378
|
+
computed?: boolean
|
|
6379
|
+
tagId?: string
|
|
6380
|
+
tagType: ClaimSetTagType | 'chip'
|
|
6381
|
+
status: 'free' | 'attached' | 'elsewhere'
|
|
6382
|
+
on?: TagCodeOn | null
|
|
6383
|
+
productId?: string | null
|
|
6384
|
+
proofId?: string | null
|
|
6385
|
+
}
|
|
6386
|
+
```
|
|
6387
|
+
|
|
6388
|
+
**PlaceMoveResult** (interface)
|
|
6389
|
+
```typescript
|
|
6390
|
+
interface PlaceMoveResult {
|
|
6391
|
+
moved: Array<{ item: PlaceMoveItem; from: string | null; to: string | null }>
|
|
6392
|
+
unchanged: PlaceMoveItem[]
|
|
6393
|
+
refused: Array<{ item: PlaceMoveItem; errorCode: string; errorText: string }>
|
|
6345
6394
|
}
|
|
6346
6395
|
```
|
|
6347
6396
|
|
|
@@ -6360,6 +6409,13 @@ type ClaimSetScope = { collectionId: string }
|
|
|
6360
6409
|
|
|
6361
6410
|
**ClaimSetImportResult** = ``
|
|
6362
6411
|
|
|
6412
|
+
**TagCodeOn** = ``
|
|
6413
|
+
|
|
6414
|
+
**PlaceMoveItem** (type)
|
|
6415
|
+
```typescript
|
|
6416
|
+
type PlaceMoveItem = { productId: string; proofId: string }
|
|
6417
|
+
```
|
|
6418
|
+
|
|
6363
6419
|
### clientLog
|
|
6364
6420
|
|
|
6365
6421
|
**ClientErrorReport** (interface)
|
|
@@ -7882,6 +7938,7 @@ interface PublicListContainersResponse {
|
|
|
7882
7938
|
**FindContainersForItemResponse** (interface)
|
|
7883
7939
|
```typescript
|
|
7884
7940
|
interface FindContainersForItemResponse {
|
|
7941
|
+
items: ContainerItem[]
|
|
7885
7942
|
containers: Container[]
|
|
7886
7943
|
}
|
|
7887
7944
|
```
|
|
@@ -12200,6 +12257,92 @@ interface VariantUpdateRequest {
|
|
|
12200
12257
|
}
|
|
12201
12258
|
```
|
|
12202
12259
|
|
|
12260
|
+
### wallet
|
|
12261
|
+
|
|
12262
|
+
**WalletPassRef** (interface)
|
|
12263
|
+
```typescript
|
|
12264
|
+
interface WalletPassRef {
|
|
12265
|
+
type: 'booking' | 'contact' | string
|
|
12266
|
+
id: string
|
|
12267
|
+
}
|
|
12268
|
+
```
|
|
12269
|
+
|
|
12270
|
+
**WalletPassContent** (interface)
|
|
12271
|
+
```typescript
|
|
12272
|
+
interface WalletPassContent {
|
|
12273
|
+
kind: WalletPassKind
|
|
12274
|
+
title: string
|
|
12275
|
+
subtitle?: string
|
|
12276
|
+
start?: string
|
|
12277
|
+
end?: string
|
|
12278
|
+
timezone?: string
|
|
12279
|
+
venue?: { name?: string; address?: string; lat?: number; lng?: number }
|
|
12280
|
+
holder?: string
|
|
12281
|
+
number?: string
|
|
12282
|
+
level?: string
|
|
12283
|
+
points?: number
|
|
12284
|
+
validUntil?: string
|
|
12285
|
+
fields?: Array<{ label: string; value: string }>
|
|
12286
|
+
back?: Array<{ label: string; value: string }>
|
|
12287
|
+
image?: string
|
|
12288
|
+
url?: string
|
|
12289
|
+
barcode?: string
|
|
12290
|
+
}
|
|
12291
|
+
```
|
|
12292
|
+
|
|
12293
|
+
**WalletPassLinks** (interface)
|
|
12294
|
+
```typescript
|
|
12295
|
+
interface WalletPassLinks {
|
|
12296
|
+
google?: string
|
|
12297
|
+
apple?: string
|
|
12298
|
+
}
|
|
12299
|
+
```
|
|
12300
|
+
|
|
12301
|
+
**WalletPassSummary** (interface)
|
|
12302
|
+
```typescript
|
|
12303
|
+
interface WalletPassSummary {
|
|
12304
|
+
id: string
|
|
12305
|
+
kind: WalletPassKind
|
|
12306
|
+
ref: WalletPassRef
|
|
12307
|
+
title?: string
|
|
12308
|
+
start?: string
|
|
12309
|
+
links: WalletPassLinks
|
|
12310
|
+
}
|
|
12311
|
+
```
|
|
12312
|
+
|
|
12313
|
+
**WalletPass** (interface)
|
|
12314
|
+
```typescript
|
|
12315
|
+
interface WalletPass {
|
|
12316
|
+
id: string
|
|
12317
|
+
collectionId: string
|
|
12318
|
+
kind: WalletPassKind
|
|
12319
|
+
ref: WalletPassRef
|
|
12320
|
+
contactId?: string | null
|
|
12321
|
+
status: 'active' | 'voided'
|
|
12322
|
+
issuedBy?: string | null
|
|
12323
|
+
model: WalletPassContent
|
|
12324
|
+
code: string
|
|
12325
|
+
version: number
|
|
12326
|
+
notice?: { header: string; body: string; at: string }
|
|
12327
|
+
voidReason?: string | null
|
|
12328
|
+
links?: WalletPassLinks
|
|
12329
|
+
createdAt?: string
|
|
12330
|
+
updatedAt?: string
|
|
12331
|
+
}
|
|
12332
|
+
```
|
|
12333
|
+
|
|
12334
|
+
**IssueWalletPassRequest** (interface)
|
|
12335
|
+
```typescript
|
|
12336
|
+
interface IssueWalletPassRequest {
|
|
12337
|
+
ref: WalletPassRef
|
|
12338
|
+
contactId?: string
|
|
12339
|
+
appId?: string
|
|
12340
|
+
pass: WalletPassContent
|
|
12341
|
+
}
|
|
12342
|
+
```
|
|
12343
|
+
|
|
12344
|
+
**WalletPassKind** = `'event' | 'booking' | 'membership' | 'loyalty'`
|
|
12345
|
+
|
|
12203
12346
|
### widgets
|
|
12204
12347
|
|
|
12205
12348
|
**NavigationRequest** (interface)
|
|
@@ -14784,6 +14927,11 @@ Find a tag across the partner's sets by its chip UID (8 or 14 hex) or its code (
|
|
|
14784
14927
|
**tagAttempts**(partnerId: string, uid: string) → `Promise<ClientErrorEvent[]>`
|
|
14785
14928
|
What phones reported about one chip (errors.report with entityType 'tag'), newest first: a tag that failed to program or register, with the host's NFC log in context. For a chip in the partner's sets, or attempts that named one of them.
|
|
14786
14929
|
|
|
14930
|
+
### places
|
|
14931
|
+
|
|
14932
|
+
**move**(collectionId: string, params: { to: string | null; items: PlaceMoveItem[]; note?: string }) → `Promise<PlaceMoveResult>`
|
|
14933
|
+
Move items (by membership), chips without an item (by membership) or containers (re-parented) into `to`, or out of every place with `to: null`. Each move leaves a history line on what moved. Up to 500 at a time.
|
|
14934
|
+
|
|
14787
14935
|
### podcast
|
|
14788
14936
|
|
|
14789
14937
|
**generate**(collectionId: string,
|
|
@@ -15231,6 +15379,17 @@ List the skills apps can invoke (name, description, input/output schema).
|
|
|
15231
15379
|
**run**(collectionId: string, name: string, input: Record<string, any> = {}) → `Promise<T>`
|
|
15232
15380
|
Invoke a skill by name with structured input — the app-facing verb; no prompt-shaping. POST /admin/collection/:collectionId/ai/skills/:name/run
|
|
15233
15381
|
|
|
15382
|
+
### tagCodes
|
|
15383
|
+
|
|
15384
|
+
**lookup**(collectionId: string, tag: TagCodeRef) → `Promise<TagCodeState>`
|
|
15385
|
+
What a tag is, as far as this collection may know: free, attached here (to what), or elsewhere.
|
|
15386
|
+
|
|
15387
|
+
**attach**(collectionId: string, params: TagCodeAttachRequest) → `Promise<TagCodeState>`
|
|
15388
|
+
Put a tag on an asset: its asset type (productId) and the asset itself (proofId). Refused when the tag belongs to another organisation, or is already on another asset (detach it first).
|
|
15389
|
+
|
|
15390
|
+
**detach**(collectionId: string, tag: TagCodeRef) → `Promise<TagCodeState>`
|
|
15391
|
+
Take a tag off its asset. It stays this collection's, free to go on another.
|
|
15392
|
+
|
|
15234
15393
|
### tags
|
|
15235
15394
|
|
|
15236
15395
|
**create**(collectionId: string,
|
|
@@ -15484,3 +15643,35 @@ Listen for voice input
|
|
|
15484
15643
|
**speak**(text: string, options?: { voice?: string; rate?: number }) → `Promise<void>`
|
|
15485
15644
|
Speak text
|
|
15486
15645
|
|
|
15646
|
+
### wallet
|
|
15647
|
+
|
|
15648
|
+
**addLinks**(collectionId: string, ref: WalletPassRef) → `Promise<`
|
|
15649
|
+
"Add to Wallet" links for the signed-in person's pass about `ref` (made on first ask for a booking or a membership card). ```typescript const { pass } = await wallet.addLinks('coll_123', { type: 'booking', id: booking.id }) if (pass.links.apple) appleButton.href = pass.links.apple if (pass.links.google) googleButton.href = pass.links.google ```
|
|
15650
|
+
|
|
15651
|
+
**mine**(collectionId: string) → `Promise<`
|
|
15652
|
+
The signed-in person's active passes on this site, with their links.
|
|
15653
|
+
|
|
15654
|
+
**status**(collectionId: string) → `Promise<`
|
|
15655
|
+
Which wallets are switched on (admin).
|
|
15656
|
+
|
|
15657
|
+
**list**(collectionId: string, query: { refType?: string; refId?: string; contactId?: string; includeVoided?: boolean }) → `Promise<`
|
|
15658
|
+
Passes for one thing (`refType` + `refId`) or one person (`contactId`) (admin).
|
|
15659
|
+
|
|
15660
|
+
**get**(collectionId: string, passId: string) → `Promise<`
|
|
15661
|
+
One pass, with its links (admin).
|
|
15662
|
+
|
|
15663
|
+
**byCode**(collectionId: string, code: string) → `Promise<`
|
|
15664
|
+
The pass whose QR this is, for checking a ticket at the door (admin). `valid` is false for a voided pass. ```typescript const { pass, valid } = await wallet.byCode('coll_123', scannedValue) ```
|
|
15665
|
+
|
|
15666
|
+
**issue**(collectionId: string, input: IssueWalletPassRequest) → `Promise<`
|
|
15667
|
+
Issue a pass (admin). Issuing again for the same thing, person and kind changes the existing pass.
|
|
15668
|
+
|
|
15669
|
+
**update**(collectionId: string, passId: string, fields: Partial<Omit<WalletPassContent, "kind">>) → `Promise<`
|
|
15670
|
+
Change what a pass shows; both wallets follow (admin).
|
|
15671
|
+
|
|
15672
|
+
**voidPass**(collectionId: string, passId: string, reason?: string) → `Promise<`
|
|
15673
|
+
The pass no longer counts: shown as void on the phone (admin).
|
|
15674
|
+
|
|
15675
|
+
**message**(collectionId: string, passId: string, msg: { header?: string; body: string }) → `Promise<`
|
|
15676
|
+
A lock-screen message on the pass (admin).
|
|
15677
|
+
|
package/docs/i18n.md
CHANGED
|
@@ -1,4 +1,71 @@
|
|
|
1
|
-
# Internationalization (i18n)
|
|
1
|
+
# Internationalization (i18n): an app's own words
|
|
2
|
+
|
|
3
|
+
**Use the SDK's `i18n` helper** (SDK 2.1.27+). The copied-in `src/i18n/LanguageContext` scaffold further
|
|
4
|
+
down is the older way; new apps and upgrades use the helper.
|
|
5
|
+
|
|
6
|
+
## How it works
|
|
7
|
+
|
|
8
|
+
1. **Your app keeps its English as keys** in `public/i18n/en.json`. The build ships it at
|
|
9
|
+
`<bundle>/i18n/en.json`. That is your only translation job: don't hard-code English in components.
|
|
10
|
+
2. **The platform translates.** When your app is published, SmartLinks translates the English into the
|
|
11
|
+
admin languages it supports (Simplified Chinese first) and adds `<bundle>/i18n/<lang>.json`. Keys whose
|
|
12
|
+
English hasn't changed keep their earlier (possibly human-reviewed) translation. If you ship your own
|
|
13
|
+
`public/i18n/<lang>.json`, its keys win and the platform fills only the gaps.
|
|
14
|
+
3. **The host says which language.** Studio passes the person's own Studio language as `?lang=`, and later
|
|
15
|
+
changes arrive live (`smartlinks:root-state` with `lang`). A key with no translation shows its English.
|
|
16
|
+
|
|
17
|
+
In an admin app, `lang` is the person's **Studio language** (buttons and labels). The site's content
|
|
18
|
+
language arrives separately as `contentLang`: use it for the language your product data is written in.
|
|
19
|
+
|
|
20
|
+
## Using it (React)
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// src/i18n.ts
|
|
24
|
+
import { useSyncExternalStore } from 'react'
|
|
25
|
+
import { i18n } from '@proveanything/smartlinks'
|
|
26
|
+
|
|
27
|
+
export const i18nReady = i18n.init() // await before first render (main.tsx)
|
|
28
|
+
export function useT() {
|
|
29
|
+
useSyncExternalStore(i18n.subscribe, i18n.snapshot)
|
|
30
|
+
return i18n.t
|
|
31
|
+
}
|
|
32
|
+
export const fmt = i18n.format // dates and numbers in the current language
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
const t = useT()
|
|
37
|
+
<Button>{t('contacts.add')}</Button>
|
|
38
|
+
<span>{t('contacts.count', { count: rows.length })}</span>
|
|
39
|
+
<span>{fmt.date(contact.createdAt)}</span>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`public/i18n/en.json`:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"contacts": {
|
|
47
|
+
"add": "Add contact",
|
|
48
|
+
"count_one": "{{count}} contact",
|
|
49
|
+
"count_other": "{{count}} contacts"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- Nested keys are read with dots; group them by screen.
|
|
55
|
+
- `{{name}}` is filled from the values. With `count`, the language's plural form is picked
|
|
56
|
+
(`_one` / `_other` in English; Chinese uses only `_other`).
|
|
57
|
+
- Outside components, call `i18n.t(...)` at the moment the text is shown (not at module load), so a
|
|
58
|
+
language switch takes effect.
|
|
59
|
+
- Don't translate data (names from the server, ids, codes), or text you send to an AI model as
|
|
60
|
+
instructions.
|
|
61
|
+
- `i18n.language()` is the language in use; `i18n.setLanguage(code)` switches; `i18n.has(key)` says
|
|
62
|
+
whether a real translation exists.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# The older scaffold (superseded)
|
|
67
|
+
|
|
68
|
+
## Internationalization (i18n) System
|
|
2
69
|
|
|
3
70
|
This document explains the i18n system for SmartLinks apps, covering URL-based language selection, static translations, and dynamic overrides.
|
|
4
71
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Tag codes: attaching a scanned tag to an asset
|
|
2
|
+
|
|
3
|
+
`SL.tagCodes` lets an admin app (Core Assets, Sidekick, a custom app) work with the tags on a collection's
|
|
4
|
+
things: what a scanned tag is, putting it on an asset, and taking it off. The same three calls work for
|
|
5
|
+
every claim-set tag:
|
|
6
|
+
|
|
7
|
+
- **printed QR codes from a computed claim set**: bought runs, and codes a business prints itself;
|
|
8
|
+
- **NFC tags and older QR sets**, whose codes are stored.
|
|
9
|
+
|
|
10
|
+
An *asset* is a proof; its *asset type* is the proof's product. Design note: prove
|
|
11
|
+
`server/docs/design/asset-tags-and-printed-codes.md`.
|
|
12
|
+
|
|
13
|
+
## The calls
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import * as SL from '@proveanything/smartlinks'
|
|
17
|
+
|
|
18
|
+
// What was scanned: the address on the tag (or { claimSetId, code })
|
|
19
|
+
const tag = await SL.tagCodes.lookup(collectionId, { url: 'https://atag.co/4fK2qPx' })
|
|
20
|
+
// → { claimSetId, code, url, computed: true, tagType: 'qr', status: 'free' }
|
|
21
|
+
|
|
22
|
+
await SL.tagCodes.attach(collectionId, { url, productId: 'bed-sb755', proofId: 'bed14' })
|
|
23
|
+
// → { …, status: 'attached', productId: 'bed-sb755', proofId: 'bed14' }
|
|
24
|
+
|
|
25
|
+
await SL.tagCodes.detach(collectionId, { url })
|
|
26
|
+
// → { …, status: 'free', proofId: null }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`status`:
|
|
30
|
+
|
|
31
|
+
| Status | Meaning |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `free` | not on anything; this collection may attach it |
|
|
34
|
+
| `attached` | on one of this collection's assets (`productId`, `proofId` say which) |
|
|
35
|
+
| `elsewhere` | another organisation's tag; nothing more is shown |
|
|
36
|
+
|
|
37
|
+
## The rules
|
|
38
|
+
|
|
39
|
+
- Admins of the collection only.
|
|
40
|
+
- Refused with `OTHER_ORGANISATION` when the tag's set belongs to another collection, or the run it's in was
|
|
41
|
+
sold to another collection.
|
|
42
|
+
- Refused with `ASSIGNED_ELSEWHERE` when the tag is already in use by another collection.
|
|
43
|
+
- Refused with `ALREADY_ATTACHED` when it's on another asset: `detach` first.
|
|
44
|
+
- After `attach`, scanning the tag opens the asset's page.
|
|
45
|
+
|
|
46
|
+
## Computed claim sets (for whoever makes tags)
|
|
47
|
+
|
|
48
|
+
A claim set created with `codeSource: 'computed'` (QR only) stores nothing per code: each code is worked out from
|
|
49
|
+
its index with a signature (24 bits by default, `sigBits` 16 to 32). A run in such a set can hold up to
|
|
50
|
+
1,000,000 tags. Its printer file downloads in parts:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
await SL.claimSet.ranges.exportFile(scope, claimSetId, rangeId, { from: 1, to: 200000 })
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
A computed set with `bareCodes: true` answers bare codes on its tap domain: `https://{domain}/{code}`.
|
|
57
|
+
Each domain has at most one such set. Assigning a **whole** computed run to a collection
|
|
58
|
+
(`ranges.assign` without `start`/`end`) is one write on the range, however many tags it holds; the response
|
|
59
|
+
says `wholeRange: true`.
|
|
60
|
+
|
|
61
|
+
## Chips and boxes (2.1.26)
|
|
62
|
+
|
|
63
|
+
The same three calls take an RFID or NFC chip by its id (`tagId`), or whatever a scanner read (`scan`: an address
|
|
64
|
+
is read as a claim code, anything else as a chip id):
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
await SL.tagCodes.lookup(collectionId, { scan: 'E28011700000020F1E2D3C4B' })
|
|
68
|
+
// → { kind: 'chip', tagId, tagType: 'chip', status: 'free', on: null }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
A tag goes on **an item** or **a container** (it's the label on a box, a bag, a shelf, a cask), never both:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
await SL.tagCodes.attach(collectionId, { url, productId, proofId }) // on an item
|
|
75
|
+
await SL.tagCodes.attach(collectionId, { tagId, containerId }) // the label on an existing container
|
|
76
|
+
await SL.tagCodes.attach(collectionId, { url, container: { name: 'Box 12', parentContainerId: storeRoomId } }) // a new box
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`on` says what a tag is on: `{ type: 'item', productId, proofId }`, `{ type: 'container', containerId, name }`, or
|
|
80
|
+
for older RFID tags tagged only to a product, `{ type: 'product', productId }` (which can still be attached to an
|
|
81
|
+
item). A chip's label is recorded as the tag row's `refType: 'container'` (the label on that container, never
|
|
82
|
+
where the tag is); a claim code's in its own row.
|
|
83
|
+
|
|
84
|
+
## Moving things
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
await SL.places.move(collectionId, { to: vanId, items: [{ productId, proofId }, { containerId: boxId }], note: 'Acme job' })
|
|
88
|
+
// → { moved: [...], unchanged: [...], refused: [...] }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- An item, or a chip without an item, is taken out of every place it's in and put in `to` (membership).
|
|
92
|
+
- A container is re-parented to `to`. A place can't go inside itself (`INSIDE_ITSELF`).
|
|
93
|
+
- `to: null` takes things out of every place.
|
|
94
|
+
- Each move leaves a history line: `asset.moved` on an item, `tag.moved` on a chip, `container.moved` on a container.
|
|
95
|
+
|
|
96
|
+
Where something is: an item's place is `containers.findForItem(cid, { itemType: 'proof', itemId })` (its
|
|
97
|
+
membership rows and the containers); a container's is its `parentContainerId`.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Wallet passes
|
|
2
|
+
|
|
3
|
+
Put an **event ticket**, a **booking**, a **membership card** or a **loyalty card** in the person's Apple Wallet or
|
|
4
|
+
Google Wallet. SmartLinks is the issuer and signs the passes. Each pass is branded from your site's name, logo and
|
|
5
|
+
colour, and your app decides what it says.
|
|
6
|
+
|
|
7
|
+
- **Who gets one:** only someone the business knows. A pass is issued to the signed-in owner of what it's for, or
|
|
8
|
+
by your app's own server function.
|
|
9
|
+
- **What the phone does:** the pass shows its QR code offline, appears near the time (and place, if you give
|
|
10
|
+
`venue.lat` / `lng`), and updates when you change it.
|
|
11
|
+
- **Bookings look after themselves:** when a booking is moved its pass shows the new time, and when it's cancelled
|
|
12
|
+
the pass is voided.
|
|
13
|
+
|
|
14
|
+
## In a page: "Add to Wallet"
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { wallet } from '@proveanything/smartlinks'
|
|
18
|
+
|
|
19
|
+
// The signed-in person's booking, membership card, or a pass your app issued them
|
|
20
|
+
const { pass } = await wallet.addLinks(collectionId, { type: 'booking', id: booking.id })
|
|
21
|
+
// pass.links.apple → opens the .pkpass on an iPhone
|
|
22
|
+
// pass.links.google → opens Google's "Save to Google Wallet" page
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `{ type: 'booking', id }` and `{ type: 'contact', id: 'me' }` are made on first ask:
|
|
26
|
+
- a booking pass, from the booking's date and time
|
|
27
|
+
- a membership card, from the person's `level` and `memberUntil` fields
|
|
28
|
+
- For anything else (an event ticket with your own title, a loyalty card with points), issue the pass in your server
|
|
29
|
+
function first. `addLinks` then returns that pass for its owner.
|
|
30
|
+
- Show the official "Add to Apple Wallet" and "Add to Google Wallet" badges, and only the one that suits the
|
|
31
|
+
device. A wallet that isn't set up yet is left out of `links`.
|
|
32
|
+
- `wallet.mine(collectionId)` lists the person's passes.
|
|
33
|
+
|
|
34
|
+
## In a server function: issue, change, void, message
|
|
35
|
+
|
|
36
|
+
Declare `sl:wallet:write` in the function's capabilities.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// An event ticket
|
|
40
|
+
const pass = await ctx.sl.wallet.issue({
|
|
41
|
+
ref: { type: 'booking', id: booking.id }, // what it's for; issuing again changes the same pass
|
|
42
|
+
pass: {
|
|
43
|
+
kind: 'event',
|
|
44
|
+
title: 'Jazz on the Terrace',
|
|
45
|
+
start: '2026-12-24T19:00:00Z', end: '2026-12-24T22:00:00Z', timezone: 'Europe/London',
|
|
46
|
+
venue: { name: 'The Terrace', address: '1 High St, Bath', lat: 51.38, lng: -2.36 },
|
|
47
|
+
holder: 'Sam Lee', number: 'T-0042',
|
|
48
|
+
fields: [{ label: 'Seat', value: 'Table 6' }],
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
return { links: pass.links } // hand these to the page
|
|
52
|
+
|
|
53
|
+
// A loyalty card, kept up to date
|
|
54
|
+
await ctx.sl.wallet.issue({ ref: { type: 'loyalty', id: accountId }, pass: { kind: 'loyalty', title: 'Bloom Rewards', points: 120, holder: 'Sam' } })
|
|
55
|
+
await ctx.sl.wallet.update(passId, { points: 145 })
|
|
56
|
+
|
|
57
|
+
await ctx.sl.wallet.void(passId, 'refunded')
|
|
58
|
+
await ctx.sl.wallet.message(passId, { header: 'Doors open', body: 'Doors open at 7pm. See you soon!' })
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **Contact:** `contactId` defaults to the caller's contact.
|
|
62
|
+
- **Reading:** `ctx.sl.wallet.get(passId)`, `forRef(ref)`, `byCode(code)` and `mine()` need only `sl:wallet:read`.
|
|
63
|
+
- **Messages:** you can also send a message to wallet with `ctx.sl.messages` and `channel: 'wallet'`. It goes to the
|
|
64
|
+
person's passes about the message's `about`, otherwise to your app's own passes for them. It's worded from the
|
|
65
|
+
template's push version.
|
|
66
|
+
|
|
67
|
+
## Checking a pass at the door
|
|
68
|
+
|
|
69
|
+
The QR holds the pass's own code, never an id. Scan it, then:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const { pass, valid } = await wallet.byCode(collectionId, scanned) // admin
|
|
73
|
+
// or in a function: await ctx.sl.wallet.byCode(scanned)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## What a pass can show
|
|
77
|
+
|
|
78
|
+
| Field | Use |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `kind` | `event`, `booking`, `membership` or `loyalty` |
|
|
81
|
+
| `title` / `subtitle` | the main line and a second line |
|
|
82
|
+
| `start` / `end` / `timezone` | when; the pass surfaces near `start` |
|
|
83
|
+
| `venue` | `name`, `address`, and `lat` / `lng` for the lock screen nearby |
|
|
84
|
+
| `holder`, `number`, `level`, `points`, `validUntil` | the person, a reference or member number, a level, a balance, an end date |
|
|
85
|
+
| `fields` (up to 4), `back` | extra lines on the front and the back |
|
|
86
|
+
| `image`, `url` | https only: a picture, a link back to your site |
|
|
87
|
+
| `barcode` | your own QR value, instead of the pass's code |
|