@proveanything/smartlinks 1.0.4 → 1.0.6

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.
Files changed (67) hide show
  1. package/dist/api/appConfiguration.d.ts +11 -0
  2. package/dist/api/appConfiguration.js +17 -0
  3. package/dist/api/asset.d.ts +9 -0
  4. package/dist/api/asset.js +40 -0
  5. package/dist/api/collection.d.ts +10 -0
  6. package/dist/api/collection.js +16 -0
  7. package/dist/api/index.d.ts +5 -0
  8. package/dist/api/index.js +7 -0
  9. package/dist/api/product.d.ts +18 -0
  10. package/dist/api/product.js +28 -0
  11. package/dist/api/proof.d.ts +11 -0
  12. package/dist/api/proof.js +17 -0
  13. package/dist/http.d.ts +18 -0
  14. package/dist/http.js +54 -0
  15. package/dist/index.d.ts +3 -113
  16. package/dist/index.js +5 -105
  17. package/dist/types/appConfiguration.d.ts +11 -0
  18. package/dist/types/appConfiguration.js +1 -0
  19. package/dist/types/asset.d.ts +8 -0
  20. package/dist/types/asset.js +1 -0
  21. package/dist/types/collection.d.ts +13 -0
  22. package/dist/types/collection.js +1 -0
  23. package/dist/types/error.d.ts +9 -0
  24. package/dist/types/error.js +1 -0
  25. package/dist/types/index.d.ts +6 -0
  26. package/dist/types/index.js +8 -0
  27. package/dist/types/product.d.ts +13 -0
  28. package/dist/types/product.js +1 -0
  29. package/dist/types/proof.d.ts +19 -0
  30. package/dist/types/proof.js +1 -0
  31. package/docs/assets/navigation.js +1 -1
  32. package/docs/assets/search.js +1 -1
  33. package/docs/documentation.json +1092 -279
  34. package/docs/functions/appConfiguration.get.html +1 -1
  35. package/docs/functions/asset.getAllForCollection.html +1 -0
  36. package/docs/functions/asset.getAllForProduct.html +1 -0
  37. package/docs/functions/asset.getAllForProof.html +1 -0
  38. package/docs/functions/asset.getForCollection.html +1 -0
  39. package/docs/functions/asset.getForProduct.html +1 -0
  40. package/docs/functions/asset.getForProof.html +1 -0
  41. package/docs/functions/collection.get.html +1 -1
  42. package/docs/functions/initializeApi.html +1 -1
  43. package/docs/functions/product.get.html +1 -1
  44. package/docs/functions/product.getAll.html +1 -1
  45. package/docs/functions/proof.get.html +1 -1
  46. package/docs/functions/request.html +1 -1
  47. package/docs/index.html +50 -29
  48. package/docs/interfaces/AppConfigurationResponse.html +4 -4
  49. package/docs/interfaces/AssetResponse.html +5 -0
  50. package/docs/interfaces/CollectionResponse.html +5 -5
  51. package/docs/interfaces/ErrorResponse.html +3 -3
  52. package/docs/interfaces/ProductResponse.html +5 -5
  53. package/docs/interfaces/ProofResponse.html +8 -8
  54. package/docs/modules/appConfiguration.html +1 -1
  55. package/docs/modules/asset.html +7 -0
  56. package/docs/modules/collection.html +1 -1
  57. package/docs/modules/product.html +1 -1
  58. package/docs/modules/proof.html +1 -1
  59. package/docs/modules.html +2 -0
  60. package/examples/browser-demo.html +20 -9
  61. package/examples/node-demo.ts +18 -10
  62. package/examples/react-demo.tsx +29 -15
  63. package/package.json +1 -1
  64. package/src/api/asset.ts +60 -0
  65. package/src/api/index.ts +1 -0
  66. package/src/types/asset.ts +9 -0
  67. package/src/types/index.ts +1 -0
@@ -1,25 +1,37 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { ApiClient, CollectionResponse, ProductResponse } from '@smartlinks/sdk';
2
+ import { initializeApi } from '../dist/index';
3
+ import { collection } from '../dist/api/collection';
4
+ import { product } from '../dist/api/product';
5
+ import { proof } from '../dist/api/proof';
6
+ import type { CollectionResponse } from '../dist/types/collection';
7
+ import type { ProductResponse } from '../dist/types/product';
8
+ import type { ProofResponse } from '../dist/types/proof';
3
9
 
4
10
  // You can provide either or both of these values:
5
- const apiKey = 'YOUR_API_KEY'; // sent as X-API-Key header (optional)
6
- const bearerToken = 'YOUR_BEARER_TOKEN'; // sent as AUTHORIZATION: Bearer ... (optional)
11
+ const apiKey = 'YOUR_API_KEY'; // optional
12
+ const bearerToken = 'YOUR_BEARER_TOKEN'; // optional
7
13
 
8
- // Example: with both headers
9
- const client = new ApiClient('https://smartlinks.app/api/v1', apiKey, bearerToken);
14
+ initializeApi({
15
+ baseURL: 'https://smartlinks.app/api/v1',
16
+ apiKey,
17
+ bearerToken,
18
+ });
10
19
 
11
20
  const ReactDemo: React.FC = () => {
12
- const [collection, setCollection] = useState<CollectionResponse | null>(null);
13
- const [product, setProduct] = useState<ProductResponse | null>(null);
21
+ const [collectionData, setCollection] = useState<CollectionResponse | null>(null);
22
+ const [productData, setProduct] = useState<ProductResponse | null>(null);
23
+ const [proofData, setProof] = useState<ProofResponse | null>(null);
14
24
  const [error, setError] = useState<string | null>(null);
15
25
 
16
26
  useEffect(() => {
17
27
  async function fetchData() {
18
28
  try {
19
- const col = await client.getCollection('abc123');
20
- const prod = await client.getProductItem('abc123', 'prod789');
29
+ const col = await collection.get('abc123');
30
+ const prod = await product.get('abc123', 'prod789');
31
+ const prf = await proof.get('abc123', 'proof456');
21
32
  setCollection(col);
22
33
  setProduct(prod);
34
+ setProof(prf);
23
35
  } catch (err) {
24
36
  setError((err as Error).message);
25
37
  }
@@ -28,15 +40,17 @@ const ReactDemo: React.FC = () => {
28
40
  }, []);
29
41
 
30
42
  if (error) return <div>Error: {error}</div>;
31
- if (!collection || !product) return <div>Loading...</div>;
43
+ if (!collectionData || !productData || !proofData) return <div>Loading...</div>;
32
44
 
33
45
  return (
34
46
  <div>
35
- <h1>{collection.title}</h1>
36
- <img src={collection.logoImage} alt={collection.title} width="100" />
37
- <h2>{product.name}</h2>
38
- <img src={product.heroImage} alt={product.name} width="100" />
39
- <p>{product.description}</p>
47
+ <h1>{collectionData.title}</h1>
48
+ <img src={collectionData.logoImage} alt={collectionData.title} width="100" />
49
+ <h2>{productData.name}</h2>
50
+ <img src={productData.heroImage} alt={productData.name} width="100" />
51
+ <p>{productData.description}</p>
52
+ <h3>Proof</h3>
53
+ <pre>{JSON.stringify(proofData, null, 2)}</pre>
40
54
  </div>
41
55
  );
42
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,60 @@
1
+ import { request } from "../http"
2
+ import { AssetResponse } from "../types/asset"
3
+
4
+ export namespace asset {
5
+ // Collection-level
6
+ export async function getForCollection(
7
+ collectionId: string,
8
+ assetId: string
9
+ ): Promise<AssetResponse> {
10
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/asset/${encodeURIComponent(assetId)}`
11
+ return request<AssetResponse>(path)
12
+ }
13
+
14
+ export async function getAllForCollection(
15
+ collectionId: string
16
+ ): Promise<AssetResponse[]> {
17
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/asset`
18
+ return request<AssetResponse[]>(path)
19
+ }
20
+
21
+ // Product-level
22
+ export async function getForProduct(
23
+ collectionId: string,
24
+ productId: string,
25
+ assetId: string
26
+ ): Promise<AssetResponse> {
27
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset/${encodeURIComponent(assetId)}`
28
+ return request<AssetResponse>(path)
29
+ }
30
+
31
+ export async function getAllForProduct(
32
+ collectionId: string,
33
+ productId: string
34
+ ): Promise<AssetResponse[]> {
35
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset`
36
+ return request<AssetResponse[]>(path)
37
+ }
38
+
39
+ // Proof-level
40
+ export async function getForProof(
41
+ collectionId: string,
42
+ proofId: string,
43
+ assetId: string
44
+ ): Promise<AssetResponse> {
45
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/proof/${encodeURIComponent(proofId)}/asset/${encodeURIComponent(assetId)}`
46
+ return request<AssetResponse>(path)
47
+ }
48
+
49
+ export async function getAllForProof(
50
+ collectionId: string,
51
+ proofId: string,
52
+ appId?: string
53
+ ): Promise<AssetResponse[]> {
54
+ let path = `/public/collection/${encodeURIComponent(collectionId)}/proof/${encodeURIComponent(proofId)}/asset`
55
+ if (appId) {
56
+ path += `?appId=${encodeURIComponent(appId)}`
57
+ }
58
+ return request<AssetResponse[]>(path)
59
+ }
60
+ }
package/src/api/index.ts CHANGED
@@ -4,3 +4,4 @@ export { collection } from "./collection"
4
4
  export { product } from "./product"
5
5
  export { proof } from "./proof"
6
6
  export { appConfiguration } from "./appConfiguration"
7
+ export { asset } from "./asset"
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Represents an Asset object.
3
+ */
4
+ export interface AssetResponse {
5
+ id: string
6
+ name: string
7
+ url: string
8
+ // ...add more fields as needed...
9
+ }
@@ -6,3 +6,4 @@ export * from "./product"
6
6
  export * from "./proof"
7
7
  export * from "./appConfiguration"
8
8
  export * from "./error"
9
+ export * from "./asset"