@proveanything/smartlinks 1.7.1 → 1.7.3
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/tags.d.ts +160 -132
- package/dist/api/tags.js +206 -167
- package/dist/docs/API_SUMMARY.md +152 -141
- package/dist/docs/scanner-container.md +556 -0
- package/dist/openapi.yaml +266 -145
- package/dist/types/tags.d.ts +116 -113
- package/dist/types/tags.js +3 -2
- package/docs/API_SUMMARY.md +152 -141
- package/docs/scanner-container.md +556 -0
- package/openapi.yaml +266 -145
- package/package.json +1 -1
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3 | Generated: 2026-03-04T13:56:12.543Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -4905,99 +4905,101 @@ interface SegmentRecipientsResponse {
|
|
|
4905
4905
|
**Tag** (interface)
|
|
4906
4906
|
```typescript
|
|
4907
4907
|
interface Tag {
|
|
4908
|
-
id:
|
|
4909
|
-
orgId:
|
|
4910
|
-
tagId:
|
|
4911
|
-
collectionId: string
|
|
4912
|
-
productId
|
|
4913
|
-
variantId
|
|
4914
|
-
batchId
|
|
4915
|
-
proofId
|
|
4916
|
-
* Polymorphic
|
|
4917
|
-
*
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4908
|
+
id: string // Internal UUID
|
|
4909
|
+
orgId: string // Organisation ID
|
|
4910
|
+
tagId: string // Physical tag identifier (NFC UID, QR code, etc.)
|
|
4911
|
+
collectionId: string // Owning collection
|
|
4912
|
+
productId: string | null // Linked product
|
|
4913
|
+
variantId: string | null // Product variant
|
|
4914
|
+
batchId: string | null // Production batch
|
|
4915
|
+
proofId: string | null // Proof / serial number
|
|
4916
|
+
* Polymorphic ref type: `'app_record'`, `'app_case'`, `'app_thread'`, `'container'`, etc.
|
|
4917
|
+
* Always paired with `refId`.
|
|
4918
|
+
refType: string | null
|
|
4919
|
+
refId: string | null
|
|
4920
|
+
metadata: Record<string, any>
|
|
4921
|
+
createdAt: string // ISO 8601
|
|
4922
|
+
updatedAt: string // ISO 8601
|
|
4923
|
+
}
|
|
4924
|
+
```
|
|
4925
|
+
|
|
4926
|
+
**TagIndexEntry** (interface)
|
|
4927
|
+
```typescript
|
|
4928
|
+
interface TagIndexEntry {
|
|
4929
|
+
tagId: string
|
|
4930
|
+
collectionId: string
|
|
4931
|
+
}
|
|
4932
|
+
```
|
|
4933
|
+
|
|
4934
|
+
**TagEmbedded** (interface)
|
|
4935
|
+
```typescript
|
|
4936
|
+
interface TagEmbedded {
|
|
4937
|
+
products?: Record<string, any>
|
|
4938
|
+
* `proofId → proof record or virtual serial-number proof`
|
|
4939
|
+
* (when `embed` includes `'proof'`)
|
|
4940
|
+
proofs?: Record<string, any>
|
|
4941
|
+
* `containerId → Container row`
|
|
4942
|
+
* (for tags where `refType === 'container'`, when `embed` includes `'container'`)
|
|
4943
|
+
containers?: Record<string, any>
|
|
4944
|
+
* `refId → app_record | app_case | app_thread | container`
|
|
4945
|
+
* (when `embed` includes `'ref'`)
|
|
4946
|
+
refs?: Record<string, any>
|
|
4924
4947
|
}
|
|
4925
4948
|
```
|
|
4926
4949
|
|
|
4927
4950
|
**CreateTagRequest** (interface)
|
|
4928
4951
|
```typescript
|
|
4929
4952
|
interface CreateTagRequest {
|
|
4930
|
-
tagId:
|
|
4931
|
-
productId?:
|
|
4932
|
-
variantId?:
|
|
4933
|
-
batchId?:
|
|
4934
|
-
proofId?:
|
|
4935
|
-
useSerialNumber?: boolean
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
metadata?: Record<string, any> // Optional: Additional metadata
|
|
4941
|
-
force?: boolean // Optional: Overwrite if tag exists in same collection (default: false)
|
|
4942
|
-
}
|
|
4943
|
-
```
|
|
4944
|
-
|
|
4945
|
-
**CreateTagsBatchRequest** (interface)
|
|
4946
|
-
```typescript
|
|
4947
|
-
interface CreateTagsBatchRequest {
|
|
4948
|
-
tags: Array<{
|
|
4949
|
-
tagId: string // Required: Unique tag identifier
|
|
4950
|
-
productId: string // Required: Product ID
|
|
4951
|
-
variantId?: string // Optional: Variant ID
|
|
4952
|
-
batchId?: string // Optional: Batch ID
|
|
4953
|
-
proofId?: string // Optional: If omitted, auto-generates serial number
|
|
4954
|
-
metadata?: Record<string, any> // Optional: Additional metadata
|
|
4955
|
-
}>
|
|
4956
|
-
force?: boolean // Optional: Overwrite existing tags in same collection (default: false)
|
|
4953
|
+
tagId: string // Required
|
|
4954
|
+
productId?: string
|
|
4955
|
+
variantId?: string
|
|
4956
|
+
batchId?: string
|
|
4957
|
+
proofId?: string // Required if productId set, unless useSerialNumber=true
|
|
4958
|
+
useSerialNumber?: boolean // Auto-generate a serial number as proofId
|
|
4959
|
+
refType?: string // Must be paired with refId
|
|
4960
|
+
refId?: string // Must be paired with refType
|
|
4961
|
+
metadata?: Record<string, any>
|
|
4962
|
+
force?: boolean // Overwrite if tag already exists in this collection
|
|
4957
4963
|
}
|
|
4958
4964
|
```
|
|
4959
4965
|
|
|
4960
|
-
**
|
|
4966
|
+
**BatchCreateTagRequest** (interface)
|
|
4961
4967
|
```typescript
|
|
4962
|
-
interface
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
created: number // Successfully created
|
|
4966
|
-
updated: number // Successfully updated (with force=true)
|
|
4967
|
-
failed: number // Failed to create/update
|
|
4968
|
-
conflicts: number // Already exist (without force=true)
|
|
4969
|
-
}
|
|
4970
|
-
results: {
|
|
4971
|
-
created: Tag[] // Array of successfully created tags
|
|
4972
|
-
updated: Tag[] // Array of successfully updated tags
|
|
4973
|
-
failed: Array<{
|
|
4974
|
-
tagId: string
|
|
4975
|
-
reason: string // Error code (e.g., "TAG_ASSIGNED_ELSEWHERE", "CREATE_FAILED")
|
|
4976
|
-
message: string // Human-readable error message
|
|
4977
|
-
existingTag?: Tag // Existing tag if applicable
|
|
4978
|
-
}>
|
|
4979
|
-
conflicts: Array<{
|
|
4980
|
-
tagId: string
|
|
4981
|
-
reason: string // "TAG_ALREADY_ASSIGNED"
|
|
4982
|
-
message: string
|
|
4983
|
-
existingTag: Tag // The existing tag
|
|
4984
|
-
}>
|
|
4985
|
-
}
|
|
4968
|
+
interface BatchCreateTagRequest {
|
|
4969
|
+
tags: Omit<CreateTagRequest, 'force'>[]
|
|
4970
|
+
force?: boolean
|
|
4986
4971
|
}
|
|
4987
4972
|
```
|
|
4988
4973
|
|
|
4989
4974
|
**UpdateTagRequest** (interface)
|
|
4990
4975
|
```typescript
|
|
4991
4976
|
interface UpdateTagRequest {
|
|
4992
|
-
productId?:
|
|
4993
|
-
variantId?:
|
|
4994
|
-
batchId?:
|
|
4995
|
-
proofId?:
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
4977
|
+
productId?: string
|
|
4978
|
+
variantId?: string
|
|
4979
|
+
batchId?: string
|
|
4980
|
+
proofId?: string
|
|
4981
|
+
refType?: string | null
|
|
4982
|
+
refId?: string | null
|
|
4983
|
+
metadata?: Record<string, any> // Merged with existing metadata
|
|
4984
|
+
}
|
|
4985
|
+
```
|
|
4986
|
+
|
|
4987
|
+
**BatchCreateResult** (interface)
|
|
4988
|
+
```typescript
|
|
4989
|
+
interface BatchCreateResult {
|
|
4990
|
+
summary: {
|
|
4991
|
+
total: number
|
|
4992
|
+
created: number
|
|
4993
|
+
updated: number
|
|
4994
|
+
failed: number
|
|
4995
|
+
conflicts: number
|
|
4996
|
+
}
|
|
4997
|
+
results: {
|
|
4998
|
+
created: Tag[]
|
|
4999
|
+
updated: Tag[]
|
|
5000
|
+
failed: Array<{ tagId: string; reason: string; message: string }>
|
|
5001
|
+
conflicts: Array<{ tagId: string; reason: string; message: string; existingTag: Tag }>
|
|
5002
|
+
}
|
|
5001
5003
|
}
|
|
5002
5004
|
```
|
|
5003
5005
|
|
|
@@ -5011,73 +5013,73 @@ interface DeleteTagResponse {
|
|
|
5011
5013
|
**ListTagsRequest** (interface)
|
|
5012
5014
|
```typescript
|
|
5013
5015
|
interface ListTagsRequest {
|
|
5014
|
-
limit?:
|
|
5015
|
-
offset?:
|
|
5016
|
-
productId?: string
|
|
5017
|
-
variantId?: string
|
|
5018
|
-
batchId?:
|
|
5019
|
-
refType?:
|
|
5020
|
-
refId?:
|
|
5016
|
+
limit?: number
|
|
5017
|
+
offset?: number
|
|
5018
|
+
productId?: string
|
|
5019
|
+
variantId?: string
|
|
5020
|
+
batchId?: string
|
|
5021
|
+
refType?: string
|
|
5022
|
+
refId?: string
|
|
5021
5023
|
}
|
|
5022
5024
|
```
|
|
5023
5025
|
|
|
5024
5026
|
**ListTagsResponse** (interface)
|
|
5025
5027
|
```typescript
|
|
5026
5028
|
interface ListTagsResponse {
|
|
5027
|
-
tags:
|
|
5028
|
-
limit:
|
|
5029
|
+
tags: Tag[]
|
|
5030
|
+
limit: number
|
|
5029
5031
|
offset: number
|
|
5030
5032
|
}
|
|
5031
5033
|
```
|
|
5032
5034
|
|
|
5033
|
-
**
|
|
5035
|
+
**LookupTagsRequest** (interface)
|
|
5034
5036
|
```typescript
|
|
5035
|
-
interface
|
|
5036
|
-
|
|
5037
|
+
interface LookupTagsRequest {
|
|
5038
|
+
tagIds: string[]
|
|
5039
|
+
embed?: string
|
|
5037
5040
|
}
|
|
5038
5041
|
```
|
|
5039
5042
|
|
|
5040
|
-
**
|
|
5043
|
+
**LookupTagsQueryRequest** (interface)
|
|
5041
5044
|
```typescript
|
|
5042
|
-
interface
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
product?: any // Included if embed contains "product"
|
|
5046
|
-
proof?: any // Included if embed contains "proof"
|
|
5045
|
+
interface LookupTagsQueryRequest {
|
|
5046
|
+
tagIds: string
|
|
5047
|
+
embed?: string
|
|
5047
5048
|
}
|
|
5048
5049
|
```
|
|
5049
5050
|
|
|
5050
|
-
**
|
|
5051
|
+
**ByRefRequest** (interface)
|
|
5051
5052
|
```typescript
|
|
5052
|
-
interface
|
|
5053
|
-
|
|
5054
|
-
|
|
5053
|
+
interface ByRefRequest {
|
|
5054
|
+
refType: string
|
|
5055
|
+
refId: string
|
|
5056
|
+
embed?: string
|
|
5055
5057
|
}
|
|
5056
5058
|
```
|
|
5057
5059
|
|
|
5058
|
-
**
|
|
5060
|
+
**ReverseTagLookupParams** (interface)
|
|
5059
5061
|
```typescript
|
|
5060
|
-
interface
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
proofs?: Record<string, any> // Map: proofId → Proof (if embed=proof)
|
|
5062
|
+
interface ReverseTagLookupParams {
|
|
5063
|
+
refType: string
|
|
5064
|
+
refId: string
|
|
5065
|
+
embed?: string
|
|
5065
5066
|
}
|
|
5066
5067
|
```
|
|
5067
5068
|
|
|
5068
|
-
**
|
|
5069
|
+
**PublicGetTagResponse** (interface)
|
|
5069
5070
|
```typescript
|
|
5070
|
-
interface
|
|
5071
|
-
|
|
5072
|
-
|
|
5071
|
+
interface PublicGetTagResponse {
|
|
5072
|
+
tag: Tag
|
|
5073
|
+
embedded: TagEmbedded
|
|
5073
5074
|
}
|
|
5074
5075
|
```
|
|
5075
5076
|
|
|
5076
|
-
**
|
|
5077
|
+
**TagLookupResponse** (interface)
|
|
5077
5078
|
```typescript
|
|
5078
|
-
interface
|
|
5079
|
-
|
|
5080
|
-
|
|
5079
|
+
interface TagLookupResponse {
|
|
5080
|
+
count: number
|
|
5081
|
+
tags: Tag[]
|
|
5082
|
+
embedded: TagEmbedded
|
|
5081
5083
|
}
|
|
5082
5084
|
```
|
|
5083
5085
|
|
|
@@ -5088,6 +5090,14 @@ interface ReverseTagLookupResponse {
|
|
|
5088
5090
|
}
|
|
5089
5091
|
```
|
|
5090
5092
|
|
|
5093
|
+
**ByRefResponse** (interface)
|
|
5094
|
+
```typescript
|
|
5095
|
+
interface ByRefResponse {
|
|
5096
|
+
tags: Tag[]
|
|
5097
|
+
embedded: TagEmbedded
|
|
5098
|
+
}
|
|
5099
|
+
```
|
|
5100
|
+
|
|
5091
5101
|
### template
|
|
5092
5102
|
|
|
5093
5103
|
**TemplateBase** (interface)
|
|
@@ -6541,55 +6551,56 @@ Get aggregate statistics for records POST /records/aggregate
|
|
|
6541
6551
|
|
|
6542
6552
|
**create**(collectionId: string,
|
|
6543
6553
|
data: CreateTagRequest) → `Promise<CreateTagResponse>`
|
|
6544
|
-
Create a single tag mapping. If
|
|
6554
|
+
Create a single tag mapping (admin). If `productId` is set without `proofId`, a serial number is auto-generated unless `useSerialNumber: true` is explicitly passed. `refType` and `refId` can be set independently of or alongside product/proof. ```typescript // Auto-generate serial number const tag = await tags.create('coll_123', { tagId: 'NFC-001', productId: 'prod_456', batchId: 'batch_2026_01', }) // Explicit proof + polymorphic ref const tag2 = await tags.create('coll_123', { tagId: 'NFC-002', refType: 'container', refId: 'container-uuid', }) ```
|
|
6545
6555
|
|
|
6546
6556
|
**createBatch**(collectionId: string,
|
|
6547
|
-
data:
|
|
6548
|
-
|
|
6557
|
+
data: BatchCreateTagRequest) → `Promise<BatchCreateResult>`
|
|
6558
|
+
Batch-create tags (admin). Tags with `productId` but no `proofId` automatically get serial numbers. Serial number generation is grouped by `(productId, variantId, batchId)` for efficiency. Partial success is possible — check `results` for individual outcomes. ```typescript const result = await tags.createBatch('coll_123', { tags: [ { tagId: 'NFC-001', productId: 'prod_456', batchId: 'batch_2026_01' }, { tagId: 'NFC-002', productId: 'prod_456', batchId: 'batch_2026_01' }, ], }) console.log(`Created: ${result.summary.created}, Conflicts: ${result.summary.conflicts}`) ```
|
|
6559
|
+
|
|
6560
|
+
**get**(collectionId: string,
|
|
6561
|
+
tagId: string) → `Promise<GetTagResponse>`
|
|
6562
|
+
Get a single tag by `tagId` (admin).
|
|
6549
6563
|
|
|
6550
6564
|
**update**(collectionId: string,
|
|
6551
6565
|
tagId: string,
|
|
6552
6566
|
data: UpdateTagRequest) → `Promise<UpdateTagResponse>`
|
|
6553
|
-
Update
|
|
6567
|
+
Update a tag (admin). Partial update — only provided fields are changed. `metadata` is deep-merged with the existing value. Pass `refType: null, refId: null` to clear the polymorphic ref. ```typescript const updated = await tags.update('coll_123', 'NFC-001', { variantId: 'var_premium', metadata: { notes: 'Updated to premium variant' }, }) // Clear polymorphic ref await tags.update('coll_123', 'NFC-001', { refType: null, refId: null }) ```
|
|
6554
6568
|
|
|
6555
6569
|
**remove**(collectionId: string,
|
|
6556
6570
|
tagId: string) → `Promise<DeleteTagResponse>`
|
|
6557
|
-
Delete a tag
|
|
6558
|
-
|
|
6559
|
-
**get**(collectionId: string,
|
|
6560
|
-
tagId: string) → `Promise<GetTagResponse>`
|
|
6561
|
-
Get a single tag mapping by tagId. ```typescript const tag = await tags.get('coll_123', 'TAG001') ```
|
|
6571
|
+
Delete a tag (admin). Permanently removes the tag from the per-org shard and the shared index.
|
|
6562
6572
|
|
|
6563
6573
|
**list**(collectionId: string,
|
|
6564
6574
|
params?: ListTagsRequest) → `Promise<ListTagsResponse>`
|
|
6565
|
-
List
|
|
6575
|
+
List tags with optional filters and pagination (admin). ```typescript // All tags for a product const { tags: list } = await tags.list('coll_123', { productId: 'prod_456' }) // All tags linked to a container const { tags: linked } = await tags.list('coll_123', { refType: 'container', refId: 'container-uuid', }) ```
|
|
6566
6576
|
|
|
6567
6577
|
**byRef**(collectionId: string,
|
|
6568
6578
|
params: ReverseTagLookupParams) → `Promise<ReverseTagLookupResponse>`
|
|
6569
|
-
Reverse lookup
|
|
6579
|
+
Reverse lookup — find all tags linked to a given object (admin). Uses a compound index on `(orgId, refType, refId)` on the per-org shard. No embed support on the admin side. ```typescript const { tags: linked } = await tags.byRef('coll_123', { refType: 'container', refId: 'container-uuid', }) ```
|
|
6570
6580
|
|
|
6571
|
-
**
|
|
6572
|
-
|
|
6573
|
-
Public lookup of a single tag by tagId (global). Optionally embed related collection, product, or proof data. No authentication required. ```typescript // Simple lookup const result = await tags.getTag('TAG001') // With embedded data const withData = await tags.getTag('TAG001', { embed: 'collection,product,proof' }) console.log(withData.tag, withData.collection, withData.product, withData.proof) ```
|
|
6581
|
+
**resolveTag**(tagId: string) → `Promise<TagIndexEntry>`
|
|
6582
|
+
Global tag resolve — returns `{ tagId, collectionId }` only. Use this **only** when you have a raw `tagId` and do not yet know which collection it belongs to. Queries the shared `tag_index` shard. Once `collectionId` is resolved, call `publicGetByCollection` for full data. > The global `/public/tags/by-ref` endpoint has been removed. > Use the collection-scoped `publicByRef` instead. ```typescript // Step 1: resolve collection const { collectionId } = await tags.resolveTag('NFC-001') // Step 2: full lookup with embedded data const { tag, embedded } = await tags.publicGetByCollection( collectionId, 'NFC-001', 'product,proof' ) ```
|
|
6574
6583
|
|
|
6575
|
-
**
|
|
6584
|
+
**publicGetByCollection**(collectionId: string,
|
|
6576
6585
|
tagId: string,
|
|
6577
|
-
|
|
6578
|
-
|
|
6586
|
+
embed?: string) → `Promise<PublicGetTagResponse>`
|
|
6587
|
+
Single tag lookup with optional embedded data (public). `GET /public/collection/:collectionId/tags/:tagId?embed=product,proof,container,ref` Supported `embed` values: `'product'`, `'proof'`, `'container'`, `'ref'` (`'collection'` is not supported — the collection is already known from the URL). ```typescript const { tag, embedded } = await tags.publicGetByCollection( 'coll_123', 'NFC-001', 'product,proof' ) const product = embedded.products?.[tag.productId!] const proof = embedded.proofs?.[tag.proofId!] ```
|
|
6579
6588
|
|
|
6580
|
-
**lookupTags**(
|
|
6581
|
-
|
|
6589
|
+
**lookupTags**(collectionId: string,
|
|
6590
|
+
data: LookupTagsRequest) → `Promise<TagLookupResponse>`
|
|
6591
|
+
Batch tag lookup via POST (public). `POST /public/collection/:collectionId/tags/lookup` Tags not belonging to this collection are filtered out silently. Returns deduplicated embedded objects alongside the tag array. ```typescript const { count, tags: list, embedded } = await tags.lookupTags('coll_123', { tagIds: ['NFC-001', 'NFC-002', 'NFC-003'], embed: 'product,proof', }) ```
|
|
6582
6592
|
|
|
6583
|
-
**
|
|
6584
|
-
|
|
6585
|
-
|
|
6593
|
+
**lookupTagsQuery**(collectionId: string,
|
|
6594
|
+
params: LookupTagsQueryRequest) → `Promise<TagLookupResponse>`
|
|
6595
|
+
Batch tag lookup via GET (public). `GET /public/collection/:collectionId/tags/lookup?tagIds=NFC-001,NFC-002&embed=product`
|
|
6586
6596
|
|
|
6587
|
-
**
|
|
6588
|
-
|
|
6597
|
+
**publicByRef**(collectionId: string,
|
|
6598
|
+
params: ReverseTagLookupParams) → `Promise<ByRefResponse>`
|
|
6599
|
+
Reverse lookup by ref via GET (public). `GET /public/collection/:collectionId/tags/by-ref?refType=container&refId=<uuid>&embed=ref` ```typescript const { tags: linked, embedded } = await tags.publicByRef('coll_123', { refType: 'container', refId: 'container-uuid', embed: 'container', }) const container = embedded.containers?.[containerId] ```
|
|
6589
6600
|
|
|
6590
|
-
**
|
|
6591
|
-
|
|
6592
|
-
|
|
6601
|
+
**publicByRefPost**(collectionId: string,
|
|
6602
|
+
data: ByRefRequest) → `Promise<ByRefResponse>`
|
|
6603
|
+
Reverse lookup by ref via POST (public). `POST /public/collection/:collectionId/tags/by-ref`
|
|
6593
6604
|
|
|
6594
6605
|
### template
|
|
6595
6606
|
|