@proveanything/smartlinks 1.9.0 → 1.9.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.
- package/dist/api/product.d.ts +2 -7
- package/dist/api/product.js +2 -11
- package/dist/api/products.d.ts +0 -3
- package/dist/api/products.js +0 -28
- package/dist/docs/API_SUMMARY.md +3 -24
- package/dist/docs/utils.md +55 -4
- package/dist/index.d.ts +1 -1
- package/dist/openapi.yaml +8 -142
- package/dist/types/product.d.ts +2 -18
- package/dist/utils/conditions.d.ts +9 -1
- package/dist/utils/conditions.js +442 -115
- package/docs/API_SUMMARY.md +3 -24
- package/docs/utils.md +55 -4
- package/openapi.yaml +8 -142
- package/package.json +1 -1
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.2 | Generated: 2026-03-23T18:11:56.796Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -5849,10 +5849,6 @@ interface ProductQueryRequest {
|
|
|
5849
5849
|
query?: {
|
|
5850
5850
|
search?: string
|
|
5851
5851
|
status?: string[]
|
|
5852
|
-
category?: string[]
|
|
5853
|
-
type?: string[]
|
|
5854
|
-
schemaType?: string[]
|
|
5855
|
-
tags?: string[]
|
|
5856
5852
|
productIds?: string[]
|
|
5857
5853
|
sku?: string
|
|
5858
5854
|
gtin?: string
|
|
@@ -5885,17 +5881,13 @@ interface ProductWriteInput {
|
|
|
5885
5881
|
ownGtin?: boolean | null
|
|
5886
5882
|
additionalGtins?: AdditionalGtin[]
|
|
5887
5883
|
sku?: string | null
|
|
5888
|
-
schemaType?: string | null
|
|
5889
|
-
type?: string | null
|
|
5890
|
-
category?: string | null
|
|
5891
5884
|
label?: string | null
|
|
5892
5885
|
status?: string | null
|
|
5893
5886
|
sortOrder?: number | null
|
|
5894
5887
|
heroImage?: ProductImage | ProductImageUrlInput | string | null
|
|
5895
5888
|
facets?: ProductFacetMap
|
|
5896
|
-
tags?: Record<string, boolean>
|
|
5897
5889
|
data?: Record<string, JsonValue>
|
|
5898
|
-
admin?:
|
|
5890
|
+
admin?: Record<string, JsonValue>
|
|
5899
5891
|
extra?: Record<string, JsonValue>
|
|
5900
5892
|
validCollections?: string[]
|
|
5901
5893
|
}
|
|
@@ -6420,10 +6412,6 @@ type VerifyTokenResponse = {
|
|
|
6420
6412
|
}
|
|
6421
6413
|
```
|
|
6422
6414
|
|
|
6423
|
-
### products (api)
|
|
6424
|
-
|
|
6425
|
-
**ProductPublicFindParams** = `Record<`
|
|
6426
|
-
|
|
6427
6415
|
## API Functions
|
|
6428
6416
|
|
|
6429
6417
|
### analytics.admin
|
|
@@ -7836,7 +7824,7 @@ List all Product Items for a Collection.
|
|
|
7836
7824
|
|
|
7837
7825
|
**create**(collectionId: string,
|
|
7838
7826
|
data: ProductCreateRequest) → `Promise<ProductResponse>`
|
|
7839
|
-
Create a new product for a collection (admin only). The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`. **Hero Image Auto-Fetch:** You can pass `heroImage` as either: - A full asset object: `{ url: '...', thumbnails: {...} }` - A string URL: The system automatically fetches and stores the image ```typescript // Using a URL - auto-fetched and stored const product = await product.create(collectionId, { name: 'Wine Bottle', description: 'Premium red wine', heroImage: 'https://example.com/wine.jpg', // Auto-fetched!
|
|
7827
|
+
Create a new product for a collection (admin only). The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`. **Hero Image Auto-Fetch:** You can pass `heroImage` as either: - A full asset object: `{ url: '...', thumbnails: {...} }` - A string URL: The system automatically fetches and stores the image ```typescript // Using a URL - auto-fetched and stored const product = await product.create(collectionId, { name: 'Wine Bottle', description: 'Premium red wine', heroImage: 'https://example.com/wine.jpg', // Auto-fetched! data: {} }); ```
|
|
7840
7828
|
|
|
7841
7829
|
**update**(collectionId: string,
|
|
7842
7830
|
productId: string,
|
|
@@ -7847,9 +7835,6 @@ Update a product for a collection (admin only). The `data` payload is a partial
|
|
|
7847
7835
|
productId: string) → `Promise<void>`
|
|
7848
7836
|
Delete a product for a collection (admin only).
|
|
7849
7837
|
|
|
7850
|
-
**query**(collectionId: string,
|
|
7851
|
-
body: ProductQueryRequest) → `Promise<ProductQueryResponse>`
|
|
7852
|
-
|
|
7853
7838
|
**find**(collectionId: string,
|
|
7854
7839
|
body: ProductQueryRequest) → `Promise<ProductQueryResponse>`
|
|
7855
7840
|
|
|
@@ -7917,12 +7902,6 @@ Look up a serial number by code for a product (admin only).
|
|
|
7917
7902
|
**query**(collectionId: string,
|
|
7918
7903
|
body: ProductQueryRequest) → `Promise<ProductQueryResponse>`
|
|
7919
7904
|
|
|
7920
|
-
**find**(collectionId: string,
|
|
7921
|
-
body: ProductQueryRequest | Record<string, JsonValue>) → `Promise<ProductQueryResponse>`
|
|
7922
|
-
|
|
7923
|
-
**publicFind**(collectionId: string,
|
|
7924
|
-
params?: ProductPublicFindParams) → `Promise<ProductResponse[]>`
|
|
7925
|
-
|
|
7926
7905
|
**clone**(collectionId: string,
|
|
7927
7906
|
productId: string,
|
|
7928
7907
|
body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
|
package/docs/utils.md
CHANGED
|
@@ -280,6 +280,8 @@ const path = utils.buildPortalPath(params)
|
|
|
280
280
|
|
|
281
281
|
The `validateCondition` function helps determine if content should be shown or hidden based on various criteria like geography, device type, user status, dates, and more.
|
|
282
282
|
|
|
283
|
+
Enable verbose tracing per invocation with `debugConditions`, or set `globalThis.SMARTLINKS_CONDITION_DEBUG = true` in a browser/devtools session to trace every evaluation.
|
|
284
|
+
|
|
283
285
|
### Basic Usage
|
|
284
286
|
|
|
285
287
|
```typescript
|
|
@@ -291,7 +293,6 @@ const canShow = await utils.validateCondition({
|
|
|
291
293
|
type: 'and',
|
|
292
294
|
conditions: [{
|
|
293
295
|
type: 'country',
|
|
294
|
-
useRegions: true,
|
|
295
296
|
regions: ['eu'],
|
|
296
297
|
contains: true
|
|
297
298
|
}]
|
|
@@ -328,7 +329,6 @@ await utils.validateCondition({
|
|
|
328
329
|
type: 'and',
|
|
329
330
|
conditions: [{
|
|
330
331
|
type: 'country',
|
|
331
|
-
useRegions: true,
|
|
332
332
|
regions: ['eu', 'uk'],
|
|
333
333
|
contains: true // true = show IN these regions, false = hide IN these regions
|
|
334
334
|
}]
|
|
@@ -336,6 +336,20 @@ await utils.validateCondition({
|
|
|
336
336
|
user: { valid: true, location: { country: 'FR' } }
|
|
337
337
|
})
|
|
338
338
|
|
|
339
|
+
// Regions and explicit countries can be combined
|
|
340
|
+
await utils.validateCondition({
|
|
341
|
+
condition: {
|
|
342
|
+
type: 'and',
|
|
343
|
+
conditions: [{
|
|
344
|
+
type: 'country',
|
|
345
|
+
regions: ['eu'],
|
|
346
|
+
countries: ['CH'],
|
|
347
|
+
contains: true
|
|
348
|
+
}]
|
|
349
|
+
},
|
|
350
|
+
user: { valid: true, location: { country: 'CH' } }
|
|
351
|
+
})
|
|
352
|
+
|
|
339
353
|
// Or specific countries
|
|
340
354
|
await utils.validateCondition({
|
|
341
355
|
condition: {
|
|
@@ -582,7 +596,7 @@ await utils.validateCondition({
|
|
|
582
596
|
conditions: [
|
|
583
597
|
{ type: 'user', userType: 'valid' },
|
|
584
598
|
{ type: 'device', displays: ['mobile'], contains: true },
|
|
585
|
-
{ type: 'country',
|
|
599
|
+
{ type: 'country', regions: ['eu'], contains: true }
|
|
586
600
|
]
|
|
587
601
|
},
|
|
588
602
|
user: { valid: true, location: { country: 'FR' } },
|
|
@@ -630,12 +644,49 @@ const showNewFeature = await utils.validateCondition({
|
|
|
630
644
|
condition: {
|
|
631
645
|
type: 'and',
|
|
632
646
|
conditions: [
|
|
633
|
-
{ type: 'country',
|
|
647
|
+
{ type: 'country', regions: ['northamerica'], contains: true },
|
|
634
648
|
{ type: 'date', dateTest: 'after', afterDate: '2026-03-01' }
|
|
635
649
|
]
|
|
636
650
|
},
|
|
637
651
|
user: { valid: true, location: { country: 'US' } }
|
|
638
652
|
})
|
|
653
|
+
|
|
654
|
+
### Debug Logging
|
|
655
|
+
|
|
656
|
+
Trace which condition is being evaluated, whether it passed, and why:
|
|
657
|
+
|
|
658
|
+
```typescript
|
|
659
|
+
await utils.validateCondition({
|
|
660
|
+
condition: {
|
|
661
|
+
type: 'and',
|
|
662
|
+
conditions: [
|
|
663
|
+
{ type: 'user', userType: 'valid' },
|
|
664
|
+
{ type: 'country', regions: ['eu'], contains: true }
|
|
665
|
+
]
|
|
666
|
+
},
|
|
667
|
+
user: { valid: true, location: { country: 'DE' } },
|
|
668
|
+
debugConditions: true
|
|
669
|
+
})
|
|
670
|
+
|
|
671
|
+
// Or enable globally in the browser console/devtools
|
|
672
|
+
globalThis.SMARTLINKS_CONDITION_DEBUG = true
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
If you want to route logs somewhere specific, pass a logger:
|
|
676
|
+
|
|
677
|
+
```typescript
|
|
678
|
+
await utils.validateCondition({
|
|
679
|
+
condition: {
|
|
680
|
+
type: 'and',
|
|
681
|
+
conditions: [{ type: 'user', userType: 'valid' }]
|
|
682
|
+
},
|
|
683
|
+
user: { valid: true },
|
|
684
|
+
debugConditions: {
|
|
685
|
+
label: 'checkout-gate',
|
|
686
|
+
logger: (...args) => console.log(...args)
|
|
687
|
+
}
|
|
688
|
+
})
|
|
689
|
+
```
|
|
639
690
|
```
|
|
640
691
|
|
|
641
692
|
#### Mobile-Only Features
|
package/openapi.yaml
CHANGED
|
@@ -5433,7 +5433,7 @@ paths:
|
|
|
5433
5433
|
post:
|
|
5434
5434
|
tags:
|
|
5435
5435
|
- product
|
|
5436
|
-
summary: product.
|
|
5436
|
+
summary: Create a new product for a collection (admin only).
|
|
5437
5437
|
operationId: product_create
|
|
5438
5438
|
security:
|
|
5439
5439
|
- bearerAuth: []
|
|
@@ -5495,39 +5495,6 @@ paths:
|
|
|
5495
5495
|
application/json:
|
|
5496
5496
|
schema:
|
|
5497
5497
|
$ref: "#/components/schemas/ProductQueryRequest"
|
|
5498
|
-
/admin/collection/{collectionId}/product/query:
|
|
5499
|
-
post:
|
|
5500
|
-
tags:
|
|
5501
|
-
- product
|
|
5502
|
-
summary: Delete a product for a collection (admin only).
|
|
5503
|
-
operationId: product_query
|
|
5504
|
-
security:
|
|
5505
|
-
- bearerAuth: []
|
|
5506
|
-
parameters:
|
|
5507
|
-
- name: collectionId
|
|
5508
|
-
in: path
|
|
5509
|
-
required: true
|
|
5510
|
-
schema:
|
|
5511
|
-
type: string
|
|
5512
|
-
responses:
|
|
5513
|
-
200:
|
|
5514
|
-
description: Success
|
|
5515
|
-
content:
|
|
5516
|
-
application/json:
|
|
5517
|
-
schema:
|
|
5518
|
-
$ref: "#/components/schemas/ProductQueryResponse"
|
|
5519
|
-
400:
|
|
5520
|
-
description: Bad request
|
|
5521
|
-
401:
|
|
5522
|
-
description: Unauthorized
|
|
5523
|
-
404:
|
|
5524
|
-
description: Not found
|
|
5525
|
-
requestBody:
|
|
5526
|
-
required: true
|
|
5527
|
-
content:
|
|
5528
|
-
application/json:
|
|
5529
|
-
schema:
|
|
5530
|
-
$ref: "#/components/schemas/ProductQueryRequest"
|
|
5531
5498
|
/admin/collection/{collectionId}/product/{productId}:
|
|
5532
5499
|
put:
|
|
5533
5500
|
tags:
|
|
@@ -6231,40 +6198,6 @@ paths:
|
|
|
6231
6198
|
application/json:
|
|
6232
6199
|
schema:
|
|
6233
6200
|
$ref: "#/components/schemas/ProductCreateRequest"
|
|
6234
|
-
/admin/collection/{collectionId}/products/find:
|
|
6235
|
-
post:
|
|
6236
|
-
tags:
|
|
6237
|
-
- products
|
|
6238
|
-
summary: products.find
|
|
6239
|
-
operationId: products_find
|
|
6240
|
-
security:
|
|
6241
|
-
- bearerAuth: []
|
|
6242
|
-
parameters:
|
|
6243
|
-
- name: collectionId
|
|
6244
|
-
in: path
|
|
6245
|
-
required: true
|
|
6246
|
-
schema:
|
|
6247
|
-
type: string
|
|
6248
|
-
responses:
|
|
6249
|
-
200:
|
|
6250
|
-
description: Success
|
|
6251
|
-
content:
|
|
6252
|
-
application/json:
|
|
6253
|
-
schema:
|
|
6254
|
-
$ref: "#/components/schemas/ProductQueryResponse"
|
|
6255
|
-
400:
|
|
6256
|
-
description: Bad request
|
|
6257
|
-
401:
|
|
6258
|
-
description: Unauthorized
|
|
6259
|
-
404:
|
|
6260
|
-
description: Not found
|
|
6261
|
-
requestBody:
|
|
6262
|
-
required: true
|
|
6263
|
-
content:
|
|
6264
|
-
application/json:
|
|
6265
|
-
schema:
|
|
6266
|
-
type: object
|
|
6267
|
-
additionalProperties: true
|
|
6268
6201
|
/admin/collection/{collectionId}/products/query:
|
|
6269
6202
|
post:
|
|
6270
6203
|
tags:
|
|
@@ -10005,7 +9938,7 @@ paths:
|
|
|
10005
9938
|
get:
|
|
10006
9939
|
tags:
|
|
10007
9940
|
- product
|
|
10008
|
-
summary: "/ export async function
|
|
9941
|
+
summary: "/ export async function find( collectionId: string, body: ProductQueryRequest ): Promise<ProductQueryResponse> { const p"
|
|
10009
9942
|
operationId: product_publicFind
|
|
10010
9943
|
security: []
|
|
10011
9944
|
parameters:
|
|
@@ -10496,34 +10429,6 @@ paths:
|
|
|
10496
10429
|
application/json:
|
|
10497
10430
|
schema:
|
|
10498
10431
|
$ref: "#/components/schemas/ProofClaimRequest"
|
|
10499
|
-
/public/collection/{collectionId}/products/find:
|
|
10500
|
-
get:
|
|
10501
|
-
tags:
|
|
10502
|
-
- products
|
|
10503
|
-
summary: products.publicFind
|
|
10504
|
-
operationId: products_publicFind
|
|
10505
|
-
security: []
|
|
10506
|
-
parameters:
|
|
10507
|
-
- name: collectionId
|
|
10508
|
-
in: path
|
|
10509
|
-
required: true
|
|
10510
|
-
schema:
|
|
10511
|
-
type: string
|
|
10512
|
-
responses:
|
|
10513
|
-
200:
|
|
10514
|
-
description: Success
|
|
10515
|
-
content:
|
|
10516
|
-
application/json:
|
|
10517
|
-
schema:
|
|
10518
|
-
type: array
|
|
10519
|
-
items:
|
|
10520
|
-
$ref: "#/components/schemas/ProductResponse"
|
|
10521
|
-
400:
|
|
10522
|
-
description: Bad request
|
|
10523
|
-
401:
|
|
10524
|
-
description: Unauthorized
|
|
10525
|
-
404:
|
|
10526
|
-
description: Not found
|
|
10527
10432
|
/public/collection/{collectionId}/products/{productId}/createClaim:
|
|
10528
10433
|
post:
|
|
10529
10434
|
tags:
|
|
@@ -20140,22 +20045,6 @@ components:
|
|
|
20140
20045
|
type: array
|
|
20141
20046
|
items:
|
|
20142
20047
|
type: string
|
|
20143
|
-
category:
|
|
20144
|
-
type: array
|
|
20145
|
-
items:
|
|
20146
|
-
type: string
|
|
20147
|
-
type:
|
|
20148
|
-
type: array
|
|
20149
|
-
items:
|
|
20150
|
-
type: string
|
|
20151
|
-
schemaType:
|
|
20152
|
-
type: array
|
|
20153
|
-
items:
|
|
20154
|
-
type: string
|
|
20155
|
-
tags:
|
|
20156
|
-
type: array
|
|
20157
|
-
items:
|
|
20158
|
-
type: string
|
|
20159
20048
|
productIds:
|
|
20160
20049
|
type: array
|
|
20161
20050
|
items:
|
|
@@ -20200,13 +20089,6 @@ components:
|
|
|
20200
20089
|
required:
|
|
20201
20090
|
- field
|
|
20202
20091
|
- direction
|
|
20203
|
-
ProductAdminData:
|
|
20204
|
-
type: object
|
|
20205
|
-
properties:
|
|
20206
|
-
allowAutoGenerateClaims:
|
|
20207
|
-
type: boolean
|
|
20208
|
-
lastSerialId:
|
|
20209
|
-
type: number
|
|
20210
20092
|
Product:
|
|
20211
20093
|
type: object
|
|
20212
20094
|
properties:
|
|
@@ -20226,12 +20108,6 @@ components:
|
|
|
20226
20108
|
$ref: "#/components/schemas/AdditionalGtin"
|
|
20227
20109
|
sku:
|
|
20228
20110
|
type: string
|
|
20229
|
-
schemaType:
|
|
20230
|
-
type: string
|
|
20231
|
-
type:
|
|
20232
|
-
type: string
|
|
20233
|
-
category:
|
|
20234
|
-
type: string
|
|
20235
20111
|
label:
|
|
20236
20112
|
type: string
|
|
20237
20113
|
status:
|
|
@@ -20242,16 +20118,14 @@ components:
|
|
|
20242
20118
|
$ref: "#/components/schemas/ProductImage"
|
|
20243
20119
|
facets:
|
|
20244
20120
|
$ref: "#/components/schemas/ProductFacetMap"
|
|
20245
|
-
tags:
|
|
20246
|
-
type: object
|
|
20247
|
-
additionalProperties:
|
|
20248
|
-
type: boolean
|
|
20249
20121
|
data:
|
|
20250
20122
|
type: object
|
|
20251
20123
|
additionalProperties:
|
|
20252
20124
|
$ref: "#/components/schemas/JsonValue"
|
|
20253
20125
|
admin:
|
|
20254
|
-
|
|
20126
|
+
type: object
|
|
20127
|
+
additionalProperties:
|
|
20128
|
+
$ref: "#/components/schemas/JsonValue"
|
|
20255
20129
|
extra:
|
|
20256
20130
|
type: object
|
|
20257
20131
|
additionalProperties:
|
|
@@ -20293,12 +20167,6 @@ components:
|
|
|
20293
20167
|
$ref: "#/components/schemas/AdditionalGtin"
|
|
20294
20168
|
sku:
|
|
20295
20169
|
type: string
|
|
20296
|
-
schemaType:
|
|
20297
|
-
type: string
|
|
20298
|
-
type:
|
|
20299
|
-
type: string
|
|
20300
|
-
category:
|
|
20301
|
-
type: string
|
|
20302
20170
|
label:
|
|
20303
20171
|
type: string
|
|
20304
20172
|
status:
|
|
@@ -20310,16 +20178,14 @@ components:
|
|
|
20310
20178
|
additionalProperties: true
|
|
20311
20179
|
facets:
|
|
20312
20180
|
$ref: "#/components/schemas/ProductFacetMap"
|
|
20313
|
-
tags:
|
|
20314
|
-
type: object
|
|
20315
|
-
additionalProperties:
|
|
20316
|
-
type: boolean
|
|
20317
20181
|
data:
|
|
20318
20182
|
type: object
|
|
20319
20183
|
additionalProperties:
|
|
20320
20184
|
$ref: "#/components/schemas/JsonValue"
|
|
20321
20185
|
admin:
|
|
20322
|
-
|
|
20186
|
+
type: object
|
|
20187
|
+
additionalProperties:
|
|
20188
|
+
$ref: "#/components/schemas/JsonValue"
|
|
20323
20189
|
extra:
|
|
20324
20190
|
type: object
|
|
20325
20191
|
additionalProperties:
|