@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.
- package/dist/api/appConfiguration.d.ts +11 -0
- package/dist/api/appConfiguration.js +17 -0
- package/dist/api/asset.d.ts +9 -0
- package/dist/api/asset.js +40 -0
- package/dist/api/collection.d.ts +10 -0
- package/dist/api/collection.js +16 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +7 -0
- package/dist/api/product.d.ts +18 -0
- package/dist/api/product.js +28 -0
- package/dist/api/proof.d.ts +11 -0
- package/dist/api/proof.js +17 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.js +54 -0
- package/dist/index.d.ts +3 -113
- package/dist/index.js +5 -105
- package/dist/types/appConfiguration.d.ts +11 -0
- package/dist/types/appConfiguration.js +1 -0
- package/dist/types/asset.d.ts +8 -0
- package/dist/types/asset.js +1 -0
- package/dist/types/collection.d.ts +13 -0
- package/dist/types/collection.js +1 -0
- package/dist/types/error.d.ts +9 -0
- package/dist/types/error.js +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +8 -0
- package/dist/types/product.d.ts +13 -0
- package/dist/types/product.js +1 -0
- package/dist/types/proof.d.ts +19 -0
- package/dist/types/proof.js +1 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/documentation.json +1092 -279
- package/docs/functions/appConfiguration.get.html +1 -1
- package/docs/functions/asset.getAllForCollection.html +1 -0
- package/docs/functions/asset.getAllForProduct.html +1 -0
- package/docs/functions/asset.getAllForProof.html +1 -0
- package/docs/functions/asset.getForCollection.html +1 -0
- package/docs/functions/asset.getForProduct.html +1 -0
- package/docs/functions/asset.getForProof.html +1 -0
- package/docs/functions/collection.get.html +1 -1
- package/docs/functions/initializeApi.html +1 -1
- package/docs/functions/product.get.html +1 -1
- package/docs/functions/product.getAll.html +1 -1
- package/docs/functions/proof.get.html +1 -1
- package/docs/functions/request.html +1 -1
- package/docs/index.html +50 -29
- package/docs/interfaces/AppConfigurationResponse.html +4 -4
- package/docs/interfaces/AssetResponse.html +5 -0
- package/docs/interfaces/CollectionResponse.html +5 -5
- package/docs/interfaces/ErrorResponse.html +3 -3
- package/docs/interfaces/ProductResponse.html +5 -5
- package/docs/interfaces/ProofResponse.html +8 -8
- package/docs/modules/appConfiguration.html +1 -1
- package/docs/modules/asset.html +7 -0
- package/docs/modules/collection.html +1 -1
- package/docs/modules/product.html +1 -1
- package/docs/modules/proof.html +1 -1
- package/docs/modules.html +2 -0
- package/examples/browser-demo.html +20 -9
- package/examples/node-demo.ts +18 -10
- package/examples/react-demo.tsx +29 -15
- package/package.json +1 -1
- package/src/api/asset.ts +60 -0
- package/src/api/index.ts +1 -0
- package/src/types/asset.ts +9 -0
- package/src/types/index.ts +1 -0
package/examples/react-demo.tsx
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
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'; //
|
|
6
|
-
const bearerToken = 'YOUR_BEARER_TOKEN'; //
|
|
11
|
+
const apiKey = 'YOUR_API_KEY'; // optional
|
|
12
|
+
const bearerToken = 'YOUR_BEARER_TOKEN'; // optional
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
initializeApi({
|
|
15
|
+
baseURL: 'https://smartlinks.app/api/v1',
|
|
16
|
+
apiKey,
|
|
17
|
+
bearerToken,
|
|
18
|
+
});
|
|
10
19
|
|
|
11
20
|
const ReactDemo: React.FC = () => {
|
|
12
|
-
const [
|
|
13
|
-
const [
|
|
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
|
|
20
|
-
const prod = await
|
|
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 (!
|
|
43
|
+
if (!collectionData || !productData || !proofData) return <div>Loading...</div>;
|
|
32
44
|
|
|
33
45
|
return (
|
|
34
46
|
<div>
|
|
35
|
-
<h1>{
|
|
36
|
-
<img src={
|
|
37
|
-
<h2>{
|
|
38
|
-
<img src={
|
|
39
|
-
<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
package/src/api/asset.ts
ADDED
|
@@ -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
package/src/types/index.ts
CHANGED