@proveanything/smartlinks 1.7.1 → 1.7.2

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.
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.7.1 | Generated: 2026-03-03T15:26:20.065Z
3
+ Version: 1.7.2 | Generated: 2026-03-04T07:38:45.571Z
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: string // UUID
4909
- orgId: string // Organization ID
4910
- tagId: string // Unique tag identifier (globally unique)
4911
- collectionId: string // Collection ID
4912
- productId?: string // Product ID (optional — may be a ref-only tag)
4913
- variantId?: string | null // Optional: Variant ID
4914
- batchId?: string | null // Optional: Batch ID
4915
- proofId?: string // Proof ID (serial number or explicit)
4916
- * Polymorphic reference type linking the tag to any app object, e.g.
4917
- * `'app_record'`, `'app_case'`, `'container'`, etc.
4918
- * Must always be paired with `refId`.
4919
- refType?: string
4920
- refId?: string
4921
- metadata: Record<string, any> // Additional metadata (e.g., serialIndex)
4922
- createdAt: string // ISO 8601 timestamp
4923
- updatedAt: string // ISO 8601 timestamp
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: string // Required: Unique tag identifier
4931
- productId?: string // Optional: Product ID (required when proofId is set without useSerialNumber)
4932
- variantId?: string // Optional: Variant ID
4933
- batchId?: string // Optional: Batch ID
4934
- proofId?: string // Optional: Explicit proof ID (if omitted with productId, auto-generates serial)
4935
- useSerialNumber?: boolean // Optional: Explicitly request serial number generation
4936
- * Polymorphic ref type linking this tag to any app object (e.g. `'app_record'`, `'container'`).
4937
- * Must be paired with `refId`. A tag can simultaneously have a product/proof AND a ref.
4938
- refType?: string
4939
- refId?: string
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
- **CreateTagsBatchResponse** (interface)
4966
+ **BatchCreateTagRequest** (interface)
4961
4967
  ```typescript
4962
- interface CreateTagsBatchResponse {
4963
- summary: {
4964
- total: number // Total tags in request
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?: string // Optional: Update product ID
4993
- variantId?: string | null // Optional: Update variant ID (null to clear)
4994
- batchId?: string | null // Optional: Update batch ID (null to clear)
4995
- proofId?: string // Optional: Update proof ID
4996
- * Polymorphic ref type. Must be paired with `refId`.
4997
- * Set both to `null` / omit to leave unchanged.
4998
- refType?: string
4999
- refId?: string
5000
- metadata?: Record<string, any> // Optional: Merge with existing metadata
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?: number // Optional: Max results (default: 100)
5015
- offset?: number // Optional: Pagination offset (default: 0)
5016
- productId?: string // Optional: Filter by product ID
5017
- variantId?: string // Optional: Filter by variant ID
5018
- batchId?: string // Optional: Filter by batch ID
5019
- refType?: string
5020
- refId?: string
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: Tag[]
5028
- limit: number
5029
+ tags: Tag[]
5030
+ limit: number
5029
5031
  offset: number
5030
5032
  }
5031
5033
  ```
5032
5034
 
5033
- **PublicGetTagRequest** (interface)
5035
+ **LookupTagsRequest** (interface)
5034
5036
  ```typescript
5035
- interface PublicGetTagRequest {
5036
- embed?: string // Optional: Comma-separated values: "collection", "product", "proof"
5037
+ interface LookupTagsRequest {
5038
+ tagIds: string[]
5039
+ embed?: string
5037
5040
  }
5038
5041
  ```
5039
5042
 
5040
- **PublicGetTagResponse** (interface)
5043
+ **LookupTagsQueryRequest** (interface)
5041
5044
  ```typescript
5042
- interface PublicGetTagResponse {
5043
- tag: Tag
5044
- collection?: any // Included if embed contains "collection"
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
- **PublicBatchLookupRequest** (interface)
5051
+ **ByRefRequest** (interface)
5051
5052
  ```typescript
5052
- interface PublicBatchLookupRequest {
5053
- tagIds: string[] // Array of tag IDs to lookup
5054
- embed?: string // Optional: Comma-separated: "collection", "product", "proof"
5053
+ interface ByRefRequest {
5054
+ refType: string
5055
+ refId: string
5056
+ embed?: string
5055
5057
  }
5056
5058
  ```
5057
5059
 
5058
- **PublicBatchLookupResponse** (interface)
5060
+ **ReverseTagLookupParams** (interface)
5059
5061
  ```typescript
5060
- interface PublicBatchLookupResponse {
5061
- tags: Record<string, Tag> // Map: tagId → Tag object
5062
- collections?: Record<string, any> // Map: collectionId → Collection (if embed=collection)
5063
- products?: Record<string, any> // Map: productId → Product (if embed=product)
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
- **PublicBatchLookupQueryRequest** (interface)
5069
+ **PublicGetTagResponse** (interface)
5069
5070
  ```typescript
5070
- interface PublicBatchLookupQueryRequest {
5071
- tagIds: string // Comma-separated tag IDs
5072
- embed?: string // Optional: Comma-separated: "collection", "product", "proof"
5071
+ interface PublicGetTagResponse {
5072
+ tag: Tag
5073
+ embedded: TagEmbedded
5073
5074
  }
5074
5075
  ```
5075
5076
 
5076
- **ReverseTagLookupParams** (interface)
5077
+ **TagLookupResponse** (interface)
5077
5078
  ```typescript
5078
- interface ReverseTagLookupParams {
5079
- refType: string
5080
- refId: string
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 proofId is not provided, automatically generates a serial number. ```typescript // Auto-generate serial number const tag = await tags.create('coll_123', { tagId: 'TAG001', productId: 'prod_456', variantId: 'var_789' }) // Use explicit proof ID const tag2 = await tags.create('coll_123', { tagId: 'TAG002', productId: 'prod_456', proofId: 'proof_explicit_123' }) ```
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: CreateTagsBatchRequest) → `Promise<CreateTagsBatchResponse>`
6548
- Create multiple tag mappings efficiently in a batch operation. By default, auto-generates serial numbers for all tags without explicit proofId. Tags are grouped by product/variant/batch and serial numbers are generated in a single transaction per group for optimal performance. ```typescript const result = await tags.createBatch('coll_123', { tags: [ { tagId: 'TAG001', productId: 'prod_456', variantId: 'var_789' }, { tagId: 'TAG002', productId: 'prod_456', variantId: 'var_789' }, { tagId: 'TAG003', productId: 'prod_456', batchId: 'batch_100' } ] }) console.log(`Created: ${result.summary.created}, Failed: ${result.summary.failed}`) ```
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 an existing tag mapping. ```typescript const updated = await tags.update('coll_123', 'TAG001', { variantId: 'var_999', metadata: { notes: 'Updated variant' } }) ```
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 mapping. ```typescript await tags.remove('coll_123', 'TAG001') ```
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 all tags for a collection with optional filters and pagination. ```typescript // List all tags const all = await tags.list('coll_123') // List with filters const filtered = await tags.list('coll_123', { productId: 'prod_456', variantId: 'var_789', limit: 50, offset: 0 }) ```
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 find all tags linked to a given app object (admin). Uses a global cross-shard index keyed on `(orgId, refType, refId)`, so it is safe to call without knowing which collection the object belongs to. ```typescript const { tags: linked } = await tags.byRef('coll_123', { refType: 'container', refId: 'container-uuid', }) ```
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
- **getTag**(tagId: string,
6572
- params?: PublicGetTagRequest) `Promise<PublicGetTagResponse>`
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
- **publicGet**(_collectionId: string,
6584
+ **publicGetByCollection**(collectionId: string,
6576
6585
  tagId: string,
6577
- params?: PublicGetTagRequest) → `Promise<PublicGetTagResponse>`
6578
- Backward-compat: Public lookup with collectionId parameter (ignored). Calls global route under /public/tags/:tagId.
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**(data: PublicBatchLookupRequest) → `Promise<PublicBatchLookupResponse>`
6581
- Public batch lookup of multiple tags in a single request (POST). Only returns tags from the specified collection. Optionally embed related data. Related data is deduplicated and batch-fetched. No authentication required. ```typescript const result = await tags.publicBatchLookup('coll_123', { tagIds: ['TAG001', 'TAG002', 'TAG003'], embed: 'collection,product' }) // Access tags and deduplicated collections/products console.log(result.tags['TAG001']) console.log(result.collections) console.log(result.products) ```
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
- **publicBatchLookup**(_collectionId: string,
6584
- data: PublicBatchLookupRequest) → `Promise<PublicBatchLookupResponse>`
6585
- Backward-compat: Public batch lookup with collectionId parameter (ignored). Calls global route under /public/tags/lookup.
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
- **lookupTagsQuery**(params: PublicBatchLookupQueryRequest) → `Promise<PublicBatchLookupQueryResponse>`
6588
- Public batch lookup of multiple tags using query parameters (GET). Only returns tags from the specified collection. Alternative to publicBatchLookup for simple GET requests. No authentication required. ```typescript const result = await tags.publicBatchLookupQuery('coll_123', { tagIds: 'TAG001,TAG002,TAG003', embed: 'collection' }) ```
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
- **publicBatchLookupQuery**(_collectionId: string,
6591
- params: PublicBatchLookupQueryRequest) → `Promise<PublicBatchLookupQueryResponse>`
6592
- Backward-compat: Public batch lookup (GET) with collectionId parameter (ignored). Calls global route under /public/tags/lookup.
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