@proveanything/smartlinks 1.0.32 → 1.0.34

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,4 +1,4 @@
1
- import { ProductResponse } from "../types/product";
1
+ import { ProductResponse, ProductCreateRequest, ProductUpdateRequest } from "../types/product";
2
2
  export declare namespace product {
3
3
  /**
4
4
  * Retrieves a single Product Item by Collection ID and Product ID.
@@ -19,21 +19,23 @@ export declare namespace product {
19
19
  function list(collectionId: string, admin?: boolean): Promise<ProductResponse[]>;
20
20
  /**
21
21
  * Create a new product for a collection (admin only).
22
+ * The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
22
23
  * @param collectionId – Identifier of the parent collection
23
- * @param data – Product creation data
24
+ * @param data – Product creation data (see ProductCreateRequest)
24
25
  * @returns Promise resolving to a ProductResponse object
25
26
  * @throws ErrorResponse if the request fails
26
27
  */
27
- function create(collectionId: string, data: any): Promise<ProductResponse>;
28
+ function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
28
29
  /**
29
30
  * Update a product for a collection (admin only).
31
+ * The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
30
32
  * @param collectionId – Identifier of the parent collection
31
33
  * @param productId – Identifier of the product
32
- * @param data – Product update data
34
+ * @param data – Product update data (see ProductUpdateRequest)
33
35
  * @returns Promise resolving to a ProductResponse object
34
36
  * @throws ErrorResponse if the request fails
35
37
  */
36
- function update(collectionId: string, productId: string, data: any): Promise<ProductResponse>;
38
+ function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
37
39
  /**
38
40
  * Delete a product for a collection (admin only).
39
41
  * @param collectionId – Identifier of the parent collection
@@ -31,8 +31,9 @@ export var product;
31
31
  product.list = list;
32
32
  /**
33
33
  * Create a new product for a collection (admin only).
34
+ * The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
34
35
  * @param collectionId – Identifier of the parent collection
35
- * @param data – Product creation data
36
+ * @param data – Product creation data (see ProductCreateRequest)
36
37
  * @returns Promise resolving to a ProductResponse object
37
38
  * @throws ErrorResponse if the request fails
38
39
  */
@@ -43,9 +44,10 @@ export var product;
43
44
  product.create = create;
44
45
  /**
45
46
  * Update a product for a collection (admin only).
47
+ * The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
46
48
  * @param collectionId – Identifier of the parent collection
47
49
  * @param productId – Identifier of the product
48
- * @param data – Product update data
50
+ * @param data – Product update data (see ProductUpdateRequest)
49
51
  * @returns Promise resolving to a ProductResponse object
50
52
  * @throws ErrorResponse if the request fails
51
53
  */
@@ -1,15 +1,42 @@
1
1
  import { ProofResponse } from "../types/proof";
2
2
  export declare namespace proof {
3
3
  /**
4
- * Retrieves a single Proof by Collection ID and Proof ID.
5
- * @param collectionId Identifier of the parent collection
6
- * @param proofId – Identifier of the proof
7
- * @returns Promise resolving to a ProofResponse object
8
- * @throws ErrorResponse if the request fails
4
+ * Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
5
+ * Both public and admin endpoints now include productId in the path.
9
6
  */
10
- function get(collectionId: string, proofId: string): Promise<ProofResponse>;
7
+ function get(collectionId: string, productId: string, proofId: string, admin?: boolean): Promise<ProofResponse>;
11
8
  /**
12
9
  * List all Proofs for a Collection.
13
10
  */
14
11
  function list(collectionId: string): Promise<ProofResponse[]>;
12
+ /**
13
+ * Create a proof for a product (admin only).
14
+ * POST /admin/collection/:collectionId/product/:productId/proof
15
+ */
16
+ function create(collectionId: string, productId: string, values: any): Promise<ProofResponse>;
17
+ /**
18
+ * Update a proof for a product (admin only).
19
+ * PUT /admin/collection/:collectionId/product/:productId/proof/:proofId
20
+ */
21
+ function update(collectionId: string, productId: string, proofId: string, values: any): Promise<ProofResponse>;
22
+ /**
23
+ * Get proofs for a user in a collection (admin only).
24
+ * GET /admin/collection/:collectionId/proof/findByUser/:userId
25
+ */
26
+ function getByUser(collectionId: string, userId: string): Promise<ProofResponse[]>;
27
+ /**
28
+ * Get proofs for a product (admin only).
29
+ * GET /admin/collection/:collectionId/product/:productId/proof
30
+ */
31
+ function getByProduct(collectionId: string, productId: string): Promise<ProofResponse[]>;
32
+ /**
33
+ * Find proofs for a product (admin only).
34
+ * POST /admin/collection/:collectionId/product/:productId/proof/find
35
+ */
36
+ function findByProduct(collectionId: string, productId: string, query: any): Promise<ProofResponse[]>;
37
+ /**
38
+ * Get proofs for a batch (admin only).
39
+ * GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
40
+ */
41
+ function getByBatch(collectionId: string, productId: string, batchId: string): Promise<ProofResponse[]>;
15
42
  }
package/dist/api/proof.js CHANGED
@@ -1,16 +1,14 @@
1
1
  // src/api/proof.ts
2
- import { request } from "../http";
2
+ import { request, post, put } from "../http";
3
3
  export var proof;
4
4
  (function (proof) {
5
5
  /**
6
- * Retrieves a single Proof by Collection ID and Proof ID.
7
- * @param collectionId Identifier of the parent collection
8
- * @param proofId – Identifier of the proof
9
- * @returns Promise resolving to a ProofResponse object
10
- * @throws ErrorResponse if the request fails
6
+ * Retrieves a single Proof by Collection ID, Product ID, and Proof ID.
7
+ * Both public and admin endpoints now include productId in the path.
11
8
  */
12
- async function get(collectionId, proofId) {
13
- const path = `/public/collection/${encodeURIComponent(collectionId)}/proof/${encodeURIComponent(proofId)}`;
9
+ async function get(collectionId, productId, proofId, admin) {
10
+ const base = admin ? '/admin' : '/public';
11
+ const path = `${base}/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}`;
14
12
  return request(path);
15
13
  }
16
14
  proof.get = get;
@@ -22,4 +20,59 @@ export var proof;
22
20
  return request(path);
23
21
  }
24
22
  proof.list = list;
23
+ // -------------------- Admin functions (legacy parity) --------------------
24
+ /**
25
+ * Create a proof for a product (admin only).
26
+ * POST /admin/collection/:collectionId/product/:productId/proof
27
+ */
28
+ async function create(collectionId, productId, values) {
29
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof`;
30
+ return post(path, values);
31
+ }
32
+ proof.create = create;
33
+ /**
34
+ * Update a proof for a product (admin only).
35
+ * PUT /admin/collection/:collectionId/product/:productId/proof/:proofId
36
+ */
37
+ async function update(collectionId, productId, proofId, values) {
38
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}`;
39
+ return put(path, values);
40
+ }
41
+ proof.update = update;
42
+ /**
43
+ * Get proofs for a user in a collection (admin only).
44
+ * GET /admin/collection/:collectionId/proof/findByUser/:userId
45
+ */
46
+ async function getByUser(collectionId, userId) {
47
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/proof/findByUser/${encodeURIComponent(userId)}`;
48
+ return request(path);
49
+ }
50
+ proof.getByUser = getByUser;
51
+ /**
52
+ * Get proofs for a product (admin only).
53
+ * GET /admin/collection/:collectionId/product/:productId/proof
54
+ */
55
+ async function getByProduct(collectionId, productId) {
56
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof`;
57
+ return request(path);
58
+ }
59
+ proof.getByProduct = getByProduct;
60
+ /**
61
+ * Find proofs for a product (admin only).
62
+ * POST /admin/collection/:collectionId/product/:productId/proof/find
63
+ */
64
+ async function findByProduct(collectionId, productId, query) {
65
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/find`;
66
+ return post(path, query);
67
+ }
68
+ proof.findByProduct = findByProduct;
69
+ /**
70
+ * Get proofs for a batch (admin only).
71
+ * GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
72
+ */
73
+ async function getByBatch(collectionId, productId, batchId) {
74
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/batch/${encodeURIComponent(batchId)}/proof`;
75
+ return request(path);
76
+ }
77
+ proof.getByBatch = getByBatch;
25
78
  })(proof || (proof = {}));
package/dist/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRe
6
6
  export type { BatchResponse, BatchCreateRequest, BatchUpdateRequest, } from "./types/batch";
7
7
  export type { VariantResponse, VariantCreateRequest, VariantUpdateRequest, } from "./types/variant";
8
8
  export type { AppConfigOptions } from "./api/appConfiguration";
9
+ export type { ProductCreateRequest, ProductUpdateRequest, } from "./types/product";
@@ -30,3 +30,5 @@ export interface ProductResponse {
30
30
  [key: string]: any;
31
31
  };
32
32
  }
33
+ export type ProductCreateRequest = Omit<ProductResponse, 'id' | 'collectionId'>;
34
+ export type ProductUpdateRequest = Partial<Omit<ProductResponse, 'id' | 'collectionId'>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",