@proveanything/smartlinks 1.8.12 → 1.9.0
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/facets.d.ts +26 -0
- package/dist/api/facets.js +106 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/product.d.ts +52 -3
- package/dist/api/product.js +103 -0
- package/dist/api/products.d.ts +21 -0
- package/dist/api/products.js +114 -0
- package/dist/docs/API_SUMMARY.md +517 -31
- package/dist/docs/PRODUCT_FACETS_SDK.md +347 -0
- package/dist/http.d.ts +2 -1
- package/dist/http.js +3 -2
- package/dist/iframeResponder.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/openapi.yaml +4442 -2475
- package/dist/types/facets.d.ts +126 -0
- package/dist/types/facets.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/product.d.ts +161 -48
- package/dist/utils/paths.js +3 -2
- package/docs/API_SUMMARY.md +517 -31
- package/docs/PRODUCT_FACETS_SDK.md +347 -0
- package/openapi.yaml +4442 -2475
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetQueryRequest, FacetQueryResponse, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams } from "../types/facets";
|
|
2
|
+
/**
|
|
3
|
+
* Facet management and aggregation endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Facets are collection-scoped resources mounted directly under `/facets`.
|
|
6
|
+
* Use this namespace to manage facet definitions and values, and to fetch
|
|
7
|
+
* aggregation buckets for browse and filter UIs.
|
|
8
|
+
*/
|
|
9
|
+
export declare namespace facets {
|
|
10
|
+
function list(collectionId: string, params?: FacetListParams): Promise<FacetListResponse>;
|
|
11
|
+
function create(collectionId: string, data: FacetDefinitionWriteInput): Promise<FacetDefinition>;
|
|
12
|
+
function get(collectionId: string, facetKey: string, params?: FacetGetParams): Promise<FacetDefinition>;
|
|
13
|
+
function update(collectionId: string, facetKey: string, data: FacetDefinitionWriteInput): Promise<FacetDefinition>;
|
|
14
|
+
function remove(collectionId: string, facetKey: string): Promise<void>;
|
|
15
|
+
function listValues(collectionId: string, facetKey: string, params?: FacetValueListParams): Promise<FacetValueListResponse>;
|
|
16
|
+
function createValue(collectionId: string, facetKey: string, data: FacetValueWriteInput): Promise<FacetValueResponse>;
|
|
17
|
+
function getValue(collectionId: string, facetKey: string, valueKey: string, params?: FacetValueGetParams): Promise<FacetValueResponse>;
|
|
18
|
+
function updateValue(collectionId: string, facetKey: string, valueKey: string, data: FacetValueWriteInput): Promise<FacetValueResponse>;
|
|
19
|
+
function removeValue(collectionId: string, facetKey: string, valueKey: string): Promise<void>;
|
|
20
|
+
function query(collectionId: string, body: FacetQueryRequest): Promise<FacetQueryResponse>;
|
|
21
|
+
function publicList(collectionId: string, params?: PublicFacetListParams): Promise<FacetListResponse>;
|
|
22
|
+
function publicGet(collectionId: string, facetKey: string, params?: PublicFacetListParams): Promise<FacetDefinition>;
|
|
23
|
+
function publicListValues(collectionId: string, facetKey: string): Promise<FacetValueListResponse>;
|
|
24
|
+
function publicGetValue(collectionId: string, facetKey: string, valueKey: string): Promise<FacetValueResponse>;
|
|
25
|
+
function publicQuery(collectionId: string, body: FacetQueryRequest): Promise<FacetQueryResponse>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { del, post, put, request } from "../http";
|
|
2
|
+
function appendSearchParam(searchParams, key, value) {
|
|
3
|
+
if (value === undefined || value === null)
|
|
4
|
+
return;
|
|
5
|
+
searchParams.set(key, String(value));
|
|
6
|
+
}
|
|
7
|
+
function buildQueryString(params) {
|
|
8
|
+
if (!params)
|
|
9
|
+
return "";
|
|
10
|
+
const searchParams = new URLSearchParams();
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
appendSearchParam(searchParams, key, value);
|
|
13
|
+
}
|
|
14
|
+
const query = searchParams.toString();
|
|
15
|
+
return query ? `?${query}` : "";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Facet management and aggregation endpoints.
|
|
19
|
+
*
|
|
20
|
+
* Facets are collection-scoped resources mounted directly under `/facets`.
|
|
21
|
+
* Use this namespace to manage facet definitions and values, and to fetch
|
|
22
|
+
* aggregation buckets for browse and filter UIs.
|
|
23
|
+
*/
|
|
24
|
+
export var facets;
|
|
25
|
+
(function (facets) {
|
|
26
|
+
async function list(collectionId, params) {
|
|
27
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets${buildQueryString(params)}`;
|
|
28
|
+
return request(path);
|
|
29
|
+
}
|
|
30
|
+
facets.list = list;
|
|
31
|
+
async function create(collectionId, data) {
|
|
32
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets`;
|
|
33
|
+
return post(path, data);
|
|
34
|
+
}
|
|
35
|
+
facets.create = create;
|
|
36
|
+
async function get(collectionId, facetKey, params) {
|
|
37
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}${buildQueryString(params)}`;
|
|
38
|
+
return request(path);
|
|
39
|
+
}
|
|
40
|
+
facets.get = get;
|
|
41
|
+
async function update(collectionId, facetKey, data) {
|
|
42
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}`;
|
|
43
|
+
return put(path, data);
|
|
44
|
+
}
|
|
45
|
+
facets.update = update;
|
|
46
|
+
async function remove(collectionId, facetKey) {
|
|
47
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}`;
|
|
48
|
+
return del(path);
|
|
49
|
+
}
|
|
50
|
+
facets.remove = remove;
|
|
51
|
+
async function listValues(collectionId, facetKey, params) {
|
|
52
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values${buildQueryString(params)}`;
|
|
53
|
+
return request(path);
|
|
54
|
+
}
|
|
55
|
+
facets.listValues = listValues;
|
|
56
|
+
async function createValue(collectionId, facetKey, data) {
|
|
57
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values`;
|
|
58
|
+
return post(path, data);
|
|
59
|
+
}
|
|
60
|
+
facets.createValue = createValue;
|
|
61
|
+
async function getValue(collectionId, facetKey, valueKey, params) {
|
|
62
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}${buildQueryString(params)}`;
|
|
63
|
+
return request(path);
|
|
64
|
+
}
|
|
65
|
+
facets.getValue = getValue;
|
|
66
|
+
async function updateValue(collectionId, facetKey, valueKey, data) {
|
|
67
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
68
|
+
return put(path, data);
|
|
69
|
+
}
|
|
70
|
+
facets.updateValue = updateValue;
|
|
71
|
+
async function removeValue(collectionId, facetKey, valueKey) {
|
|
72
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
73
|
+
return del(path);
|
|
74
|
+
}
|
|
75
|
+
facets.removeValue = removeValue;
|
|
76
|
+
async function query(collectionId, body) {
|
|
77
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/query`;
|
|
78
|
+
return post(path, body);
|
|
79
|
+
}
|
|
80
|
+
facets.query = query;
|
|
81
|
+
async function publicList(collectionId, params) {
|
|
82
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets${buildQueryString(params)}`;
|
|
83
|
+
return request(path);
|
|
84
|
+
}
|
|
85
|
+
facets.publicList = publicList;
|
|
86
|
+
async function publicGet(collectionId, facetKey, params) {
|
|
87
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}${buildQueryString(params)}`;
|
|
88
|
+
return request(path);
|
|
89
|
+
}
|
|
90
|
+
facets.publicGet = publicGet;
|
|
91
|
+
async function publicListValues(collectionId, facetKey) {
|
|
92
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values`;
|
|
93
|
+
return request(path);
|
|
94
|
+
}
|
|
95
|
+
facets.publicListValues = publicListValues;
|
|
96
|
+
async function publicGetValue(collectionId, facetKey, valueKey) {
|
|
97
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
98
|
+
return request(path);
|
|
99
|
+
}
|
|
100
|
+
facets.publicGetValue = publicGetValue;
|
|
101
|
+
async function publicQuery(collectionId, body) {
|
|
102
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/query`;
|
|
103
|
+
return post(path, body);
|
|
104
|
+
}
|
|
105
|
+
facets.publicQuery = publicQuery;
|
|
106
|
+
})(facets || (facets = {}));
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { collection } from "./collection";
|
|
2
|
+
export { facets } from "./facets";
|
|
2
3
|
export { product } from "./product";
|
|
4
|
+
export { products } from "./products";
|
|
3
5
|
export { proof } from "./proof";
|
|
4
6
|
export { appConfiguration, userAppData } from "./appConfiguration";
|
|
5
7
|
export { asset } from "./asset";
|
package/dist/api/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/api/index.ts
|
|
2
2
|
// Re-export all resource namespaces so the consumer can import them in one line.
|
|
3
3
|
export { collection } from "./collection";
|
|
4
|
+
export { facets } from "./facets";
|
|
4
5
|
export { product } from "./product";
|
|
6
|
+
export { products } from "./products";
|
|
5
7
|
export { proof } from "./proof";
|
|
6
8
|
export { appConfiguration, userAppData } from "./appConfiguration";
|
|
7
9
|
export { asset } from "./asset";
|
package/dist/api/product.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryRequest, ProductQueryResponse, ProductResponse, ProductUpdateRequest } from "../types/product";
|
|
2
|
+
type ProductPublicFindParams = Record<string, string | number | boolean | null | undefined | Array<string | number | boolean>>;
|
|
2
3
|
export declare namespace product {
|
|
3
4
|
/**
|
|
5
|
+
* @deprecated Use `products.get(...)`.
|
|
4
6
|
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
5
7
|
* @param collectionId – Identifier of the parent collection
|
|
6
8
|
* @param productId – Identifier of the product item
|
|
@@ -10,6 +12,7 @@ export declare namespace product {
|
|
|
10
12
|
*/
|
|
11
13
|
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
12
14
|
/**
|
|
15
|
+
* @deprecated Use `products.list(...)`.
|
|
13
16
|
* List all Product Items for a Collection.
|
|
14
17
|
* @param collectionId – Identifier of the parent collection
|
|
15
18
|
* @param admin – If true, use admin endpoint; otherwise, use public
|
|
@@ -18,6 +21,7 @@ export declare namespace product {
|
|
|
18
21
|
*/
|
|
19
22
|
function list(collectionId: string, admin?: boolean): Promise<ProductResponse[]>;
|
|
20
23
|
/**
|
|
24
|
+
* @deprecated Use `products.create(...)`.
|
|
21
25
|
* Create a new product for a collection (admin only).
|
|
22
26
|
* The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
|
|
23
27
|
*
|
|
@@ -45,6 +49,7 @@ export declare namespace product {
|
|
|
45
49
|
*/
|
|
46
50
|
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
47
51
|
/**
|
|
52
|
+
* @deprecated Use `products.update(...)`.
|
|
48
53
|
* Update a product for a collection (admin only).
|
|
49
54
|
* The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
|
|
50
55
|
*
|
|
@@ -69,6 +74,7 @@ export declare namespace product {
|
|
|
69
74
|
*/
|
|
70
75
|
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
71
76
|
/**
|
|
77
|
+
* @deprecated Use `products.remove(...)`.
|
|
72
78
|
* Delete a product for a collection (admin only).
|
|
73
79
|
* @param collectionId – Identifier of the parent collection
|
|
74
80
|
* @param productId – Identifier of the product
|
|
@@ -77,6 +83,39 @@ export declare namespace product {
|
|
|
77
83
|
*/
|
|
78
84
|
function remove(collectionId: string, productId: string): Promise<void>;
|
|
79
85
|
/**
|
|
86
|
+
* @deprecated Use `products.query(...)`.
|
|
87
|
+
*/
|
|
88
|
+
function query(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Use `products.find(...)` for admin or `products.publicFind(...)` for public access.
|
|
91
|
+
*/
|
|
92
|
+
function find(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Use `products.publicFind(...)`.
|
|
95
|
+
*/
|
|
96
|
+
function publicFind(collectionId: string, params?: ProductPublicFindParams): Promise<ProductResponse[]>;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use `products.clone(...)`.
|
|
99
|
+
*/
|
|
100
|
+
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use `products.listAssets(...)`.
|
|
103
|
+
*/
|
|
104
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use `products.createClaimWindow(...)`.
|
|
107
|
+
*/
|
|
108
|
+
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated Use `products.updateClaimWindow(...)`.
|
|
111
|
+
*/
|
|
112
|
+
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `products.refresh(...)`.
|
|
115
|
+
*/
|
|
116
|
+
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use `products.getSN(...)`.
|
|
80
119
|
* Get serial numbers for a product (admin only).
|
|
81
120
|
* @param collectionId - Identifier of the parent collection
|
|
82
121
|
* @param productId - Identifier of the product
|
|
@@ -85,8 +124,9 @@ export declare namespace product {
|
|
|
85
124
|
* @returns Promise resolving to serial number data
|
|
86
125
|
* @throws ErrorResponse if the request fails
|
|
87
126
|
*/
|
|
88
|
-
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<
|
|
127
|
+
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<unknown>;
|
|
89
128
|
/**
|
|
129
|
+
* @deprecated Use `products.lookupSN(...)`.
|
|
90
130
|
* Look up a serial number by code for a product (admin only).
|
|
91
131
|
* @param collectionId - Identifier of the parent collection
|
|
92
132
|
* @param productId - Identifier of the product
|
|
@@ -94,5 +134,14 @@ export declare namespace product {
|
|
|
94
134
|
* @returns Promise resolving to serial number lookup data
|
|
95
135
|
* @throws ErrorResponse if the request fails
|
|
96
136
|
*/
|
|
97
|
-
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<
|
|
137
|
+
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<unknown>;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use `products.publicLookupClaim(...)`.
|
|
140
|
+
*/
|
|
141
|
+
function publicLookupClaim(collectionId: string, productId: string, claimId: string): Promise<unknown>;
|
|
142
|
+
/**
|
|
143
|
+
* @deprecated Use `products.publicCreateClaim(...)`.
|
|
144
|
+
*/
|
|
145
|
+
function publicCreateClaim(collectionId: string, productId: string, body: ProductClaimCreateRequestBody): Promise<unknown>;
|
|
98
146
|
}
|
|
147
|
+
export {};
|
package/dist/api/product.js
CHANGED
|
@@ -3,6 +3,7 @@ import { request, post, put, del } from "../http";
|
|
|
3
3
|
export var product;
|
|
4
4
|
(function (product) {
|
|
5
5
|
/**
|
|
6
|
+
* @deprecated Use `products.get(...)`.
|
|
6
7
|
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
7
8
|
* @param collectionId – Identifier of the parent collection
|
|
8
9
|
* @param productId – Identifier of the product item
|
|
@@ -17,6 +18,7 @@ export var product;
|
|
|
17
18
|
}
|
|
18
19
|
product.get = get;
|
|
19
20
|
/**
|
|
21
|
+
* @deprecated Use `products.list(...)`.
|
|
20
22
|
* List all Product Items for a Collection.
|
|
21
23
|
* @param collectionId – Identifier of the parent collection
|
|
22
24
|
* @param admin – If true, use admin endpoint; otherwise, use public
|
|
@@ -30,6 +32,7 @@ export var product;
|
|
|
30
32
|
}
|
|
31
33
|
product.list = list;
|
|
32
34
|
/**
|
|
35
|
+
* @deprecated Use `products.create(...)`.
|
|
33
36
|
* Create a new product for a collection (admin only).
|
|
34
37
|
* The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
|
|
35
38
|
*
|
|
@@ -61,6 +64,7 @@ export var product;
|
|
|
61
64
|
}
|
|
62
65
|
product.create = create;
|
|
63
66
|
/**
|
|
67
|
+
* @deprecated Use `products.update(...)`.
|
|
64
68
|
* Update a product for a collection (admin only).
|
|
65
69
|
* The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
|
|
66
70
|
*
|
|
@@ -89,6 +93,7 @@ export var product;
|
|
|
89
93
|
}
|
|
90
94
|
product.update = update;
|
|
91
95
|
/**
|
|
96
|
+
* @deprecated Use `products.remove(...)`.
|
|
92
97
|
* Delete a product for a collection (admin only).
|
|
93
98
|
* @param collectionId – Identifier of the parent collection
|
|
94
99
|
* @param productId – Identifier of the product
|
|
@@ -101,6 +106,87 @@ export var product;
|
|
|
101
106
|
}
|
|
102
107
|
product.remove = remove;
|
|
103
108
|
/**
|
|
109
|
+
* @deprecated Use `products.query(...)`.
|
|
110
|
+
*/
|
|
111
|
+
async function query(collectionId, body) {
|
|
112
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/query`;
|
|
113
|
+
return post(path, body);
|
|
114
|
+
}
|
|
115
|
+
product.query = query;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated Use `products.find(...)` for admin or `products.publicFind(...)` for public access.
|
|
118
|
+
*/
|
|
119
|
+
async function find(collectionId, body) {
|
|
120
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/find`;
|
|
121
|
+
return post(path, body);
|
|
122
|
+
}
|
|
123
|
+
product.find = find;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use `products.publicFind(...)`.
|
|
126
|
+
*/
|
|
127
|
+
async function publicFind(collectionId, params) {
|
|
128
|
+
const searchParams = new URLSearchParams();
|
|
129
|
+
if (params) {
|
|
130
|
+
for (const [key, value] of Object.entries(params)) {
|
|
131
|
+
if (value === undefined || value === null)
|
|
132
|
+
continue;
|
|
133
|
+
if (Array.isArray(value)) {
|
|
134
|
+
for (const item of value)
|
|
135
|
+
searchParams.append(key, String(item));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
searchParams.set(key, String(value));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const query = searchParams.toString();
|
|
143
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/find${query ? `?${query}` : ''}`;
|
|
144
|
+
return request(path);
|
|
145
|
+
}
|
|
146
|
+
product.publicFind = publicFind;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use `products.clone(...)`.
|
|
149
|
+
*/
|
|
150
|
+
async function clone(collectionId, productId, body = {}) {
|
|
151
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/clone`;
|
|
152
|
+
return post(path, body);
|
|
153
|
+
}
|
|
154
|
+
product.clone = clone;
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use `products.listAssets(...)`.
|
|
157
|
+
*/
|
|
158
|
+
async function listAssets(collectionId, productId, admin) {
|
|
159
|
+
const base = admin ? '/admin' : '/public';
|
|
160
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset`;
|
|
161
|
+
return request(path);
|
|
162
|
+
}
|
|
163
|
+
product.listAssets = listAssets;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use `products.createClaimWindow(...)`.
|
|
166
|
+
*/
|
|
167
|
+
async function createClaimWindow(collectionId, productId, body) {
|
|
168
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/claimWindow`;
|
|
169
|
+
return post(path, body);
|
|
170
|
+
}
|
|
171
|
+
product.createClaimWindow = createClaimWindow;
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated Use `products.updateClaimWindow(...)`.
|
|
174
|
+
*/
|
|
175
|
+
async function updateClaimWindow(collectionId, productId, claimId, body) {
|
|
176
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/claimWindow/${encodeURIComponent(claimId)}`;
|
|
177
|
+
return put(path, body);
|
|
178
|
+
}
|
|
179
|
+
product.updateClaimWindow = updateClaimWindow;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated Use `products.refresh(...)`.
|
|
182
|
+
*/
|
|
183
|
+
async function refresh(collectionId, productId) {
|
|
184
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/refresh`;
|
|
185
|
+
return request(path);
|
|
186
|
+
}
|
|
187
|
+
product.refresh = refresh;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use `products.getSN(...)`.
|
|
104
190
|
* Get serial numbers for a product (admin only).
|
|
105
191
|
* @param collectionId - Identifier of the parent collection
|
|
106
192
|
* @param productId - Identifier of the product
|
|
@@ -119,6 +205,7 @@ export var product;
|
|
|
119
205
|
}
|
|
120
206
|
product.getSN = getSN;
|
|
121
207
|
/**
|
|
208
|
+
* @deprecated Use `products.lookupSN(...)`.
|
|
122
209
|
* Look up a serial number by code for a product (admin only).
|
|
123
210
|
* @param collectionId - Identifier of the parent collection
|
|
124
211
|
* @param productId - Identifier of the product
|
|
@@ -131,4 +218,20 @@ export var product;
|
|
|
131
218
|
return request(path);
|
|
132
219
|
}
|
|
133
220
|
product.lookupSN = lookupSN;
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use `products.publicLookupClaim(...)`.
|
|
223
|
+
*/
|
|
224
|
+
async function publicLookupClaim(collectionId, productId, claimId) {
|
|
225
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/lookupClaim/${encodeURIComponent(claimId)}`;
|
|
226
|
+
return request(path);
|
|
227
|
+
}
|
|
228
|
+
product.publicLookupClaim = publicLookupClaim;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use `products.publicCreateClaim(...)`.
|
|
231
|
+
*/
|
|
232
|
+
async function publicCreateClaim(collectionId, productId, body) {
|
|
233
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/createClaim`;
|
|
234
|
+
return post(path, body);
|
|
235
|
+
}
|
|
236
|
+
product.publicCreateClaim = publicCreateClaim;
|
|
134
237
|
})(product || (product = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryRequest, ProductQueryResponse, ProductResponse, ProductUpdateRequest } from "../types/product";
|
|
2
|
+
export type ProductPublicFindParams = Record<string, string | number | boolean | null | undefined | Array<string | number | boolean>>;
|
|
3
|
+
export declare namespace products {
|
|
4
|
+
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
5
|
+
function list(collectionId: string, admin?: boolean): Promise<ProductResponse[]>;
|
|
6
|
+
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
7
|
+
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
8
|
+
function remove(collectionId: string, productId: string): Promise<void>;
|
|
9
|
+
function query(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
10
|
+
function find(collectionId: string, body: ProductQueryRequest | Record<string, JsonValue>): Promise<ProductQueryResponse>;
|
|
11
|
+
function publicFind(collectionId: string, params?: ProductPublicFindParams): Promise<ProductResponse[]>;
|
|
12
|
+
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
13
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<unknown>;
|
|
14
|
+
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
15
|
+
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
16
|
+
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
17
|
+
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<unknown>;
|
|
18
|
+
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<unknown>;
|
|
19
|
+
function publicLookupClaim(collectionId: string, productId: string, claimId: string): Promise<unknown>;
|
|
20
|
+
function publicCreateClaim(collectionId: string, productId: string, body: ProductClaimCreateRequestBody): Promise<unknown>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { del, post, put, request } from "../http";
|
|
2
|
+
function buildQueryString(params) {
|
|
3
|
+
if (!params)
|
|
4
|
+
return '';
|
|
5
|
+
const searchParams = new URLSearchParams();
|
|
6
|
+
for (const [key, value] of Object.entries(params)) {
|
|
7
|
+
if (value === undefined || value === null)
|
|
8
|
+
continue;
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
for (const item of value) {
|
|
11
|
+
searchParams.append(key, String(item));
|
|
12
|
+
}
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
searchParams.set(key, String(value));
|
|
16
|
+
}
|
|
17
|
+
const query = searchParams.toString();
|
|
18
|
+
return query ? `?${query}` : '';
|
|
19
|
+
}
|
|
20
|
+
export var products;
|
|
21
|
+
(function (products) {
|
|
22
|
+
async function get(collectionId, productId, admin) {
|
|
23
|
+
const base = admin ? '/admin' : '/public';
|
|
24
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}`;
|
|
25
|
+
return request(path);
|
|
26
|
+
}
|
|
27
|
+
products.get = get;
|
|
28
|
+
async function list(collectionId, admin) {
|
|
29
|
+
const base = admin ? '/admin' : '/public';
|
|
30
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/products`;
|
|
31
|
+
return request(path);
|
|
32
|
+
}
|
|
33
|
+
products.list = list;
|
|
34
|
+
async function create(collectionId, data) {
|
|
35
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products`;
|
|
36
|
+
return post(path, data);
|
|
37
|
+
}
|
|
38
|
+
products.create = create;
|
|
39
|
+
async function update(collectionId, productId, data) {
|
|
40
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}`;
|
|
41
|
+
return put(path, data);
|
|
42
|
+
}
|
|
43
|
+
products.update = update;
|
|
44
|
+
async function remove(collectionId, productId) {
|
|
45
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}`;
|
|
46
|
+
return del(path);
|
|
47
|
+
}
|
|
48
|
+
products.remove = remove;
|
|
49
|
+
async function query(collectionId, body) {
|
|
50
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/query`;
|
|
51
|
+
return post(path, body);
|
|
52
|
+
}
|
|
53
|
+
products.query = query;
|
|
54
|
+
async function find(collectionId, body) {
|
|
55
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/find`;
|
|
56
|
+
return post(path, body);
|
|
57
|
+
}
|
|
58
|
+
products.find = find;
|
|
59
|
+
async function publicFind(collectionId, params) {
|
|
60
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/products/find${buildQueryString(params)}`;
|
|
61
|
+
return request(path);
|
|
62
|
+
}
|
|
63
|
+
products.publicFind = publicFind;
|
|
64
|
+
async function clone(collectionId, productId, body = {}) {
|
|
65
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/clone`;
|
|
66
|
+
return post(path, body);
|
|
67
|
+
}
|
|
68
|
+
products.clone = clone;
|
|
69
|
+
async function listAssets(collectionId, productId, admin) {
|
|
70
|
+
const base = admin ? '/admin' : '/public';
|
|
71
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/asset`;
|
|
72
|
+
return request(path);
|
|
73
|
+
}
|
|
74
|
+
products.listAssets = listAssets;
|
|
75
|
+
async function createClaimWindow(collectionId, productId, body) {
|
|
76
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/claimWindow`;
|
|
77
|
+
return post(path, body);
|
|
78
|
+
}
|
|
79
|
+
products.createClaimWindow = createClaimWindow;
|
|
80
|
+
async function updateClaimWindow(collectionId, productId, claimId, body) {
|
|
81
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/claimWindow/${encodeURIComponent(claimId)}`;
|
|
82
|
+
return put(path, body);
|
|
83
|
+
}
|
|
84
|
+
products.updateClaimWindow = updateClaimWindow;
|
|
85
|
+
async function refresh(collectionId, productId) {
|
|
86
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/refresh`;
|
|
87
|
+
return request(path);
|
|
88
|
+
}
|
|
89
|
+
products.refresh = refresh;
|
|
90
|
+
async function getSN(collectionId, productId, startIndex = 0, count = 10) {
|
|
91
|
+
const queryParams = new URLSearchParams({
|
|
92
|
+
startIndex: startIndex.toString(),
|
|
93
|
+
count: count.toString(),
|
|
94
|
+
});
|
|
95
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/getSN?${queryParams}`;
|
|
96
|
+
return request(path);
|
|
97
|
+
}
|
|
98
|
+
products.getSN = getSN;
|
|
99
|
+
async function lookupSN(collectionId, productId, codeId) {
|
|
100
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/lookupSN/${encodeURIComponent(codeId)}`;
|
|
101
|
+
return request(path);
|
|
102
|
+
}
|
|
103
|
+
products.lookupSN = lookupSN;
|
|
104
|
+
async function publicLookupClaim(collectionId, productId, claimId) {
|
|
105
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/lookupClaim/${encodeURIComponent(claimId)}`;
|
|
106
|
+
return request(path);
|
|
107
|
+
}
|
|
108
|
+
products.publicLookupClaim = publicLookupClaim;
|
|
109
|
+
async function publicCreateClaim(collectionId, productId, body) {
|
|
110
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/products/${encodeURIComponent(productId)}/createClaim`;
|
|
111
|
+
return post(path, body);
|
|
112
|
+
}
|
|
113
|
+
products.publicCreateClaim = publicCreateClaim;
|
|
114
|
+
})(products || (products = {}));
|