@proveanything/smartlinks 1.0.29 → 1.0.30
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/API_SUMMARY.md +672 -213
- package/README.md +430 -0
- package/dist/http.d.ts +5 -3
- package/dist/http.js +5 -3
- package/package.json +19 -3
- package/build-docs.ts +0 -69
- package/debug.log +0 -6
- package/examples/browser-demo.html +0 -43
- package/examples/node-demo.ts +0 -50
- package/examples/react-demo.tsx +0 -58
- package/generate-api-summary.js +0 -279
- package/generate-api-summary.ts +0 -83
- package/openapi.yaml +0 -130
- package/scripts/copy-docs.js +0 -11
- package/src/api/appConfiguration.ts +0 -104
- package/src/api/asset.ts +0 -133
- package/src/api/attestation.ts +0 -69
- package/src/api/auth.ts +0 -103
- package/src/api/batch.ts +0 -173
- package/src/api/claimSet.ts +0 -131
- package/src/api/collection.ts +0 -117
- package/src/api/crate.ts +0 -43
- package/src/api/form.ts +0 -57
- package/src/api/index.ts +0 -14
- package/src/api/product.ts +0 -128
- package/src/api/proof.ts +0 -32
- package/src/api/serialNumber.ts +0 -0
- package/src/api/variant.ts +0 -173
- package/src/http.ts +0 -363
- package/src/index.ts +0 -29
- package/src/types/appConfiguration.ts +0 -12
- package/src/types/asset.ts +0 -9
- package/src/types/attestation.ts +0 -19
- package/src/types/batch.ts +0 -15
- package/src/types/collection.ts +0 -68
- package/src/types/error.ts +0 -10
- package/src/types/index.ts +0 -11
- package/src/types/product.ts +0 -33
- package/src/types/proof.ts +0 -20
- package/src/types/serialNumber.ts +0 -0
- package/src/types/variant.ts +0 -15
- package/tsconfig.json +0 -15
- package/typedoc.json +0 -18
package/src/api/asset.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { request, post, getApiHeaders } 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 listForCollection(
|
|
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 listForProduct(
|
|
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
|
-
productId: string,
|
|
43
|
-
proofId: string,
|
|
44
|
-
assetId: string
|
|
45
|
-
): Promise<AssetResponse> {
|
|
46
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset/${encodeURIComponent(assetId)}`
|
|
47
|
-
return request<AssetResponse>(path)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export async function listForProof(
|
|
51
|
-
collectionId: string,
|
|
52
|
-
productId: string,
|
|
53
|
-
proofId: string,
|
|
54
|
-
appId?: string
|
|
55
|
-
): Promise<AssetResponse[]> {
|
|
56
|
-
let path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset`
|
|
57
|
-
if (appId) {
|
|
58
|
-
path += `?appId=${encodeURIComponent(appId)}`
|
|
59
|
-
}
|
|
60
|
-
return request<AssetResponse[]>(path)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Uploads an asset file to a proof, with optional extraData as JSON.
|
|
65
|
-
* Supports progress reporting via onProgress callback (browser only).
|
|
66
|
-
* @param collectionId - The collection ID
|
|
67
|
-
* @param productId - The product ID
|
|
68
|
-
* @param proofId - The proof ID
|
|
69
|
-
* @param file - The file to upload
|
|
70
|
-
* @param extraData - Arbitrary extra data to include (will be stringified as JSON)
|
|
71
|
-
* @param onProgress - Optional callback for upload progress (0-100)
|
|
72
|
-
* @returns Promise resolving to an AssetResponse object
|
|
73
|
-
*/
|
|
74
|
-
export async function uploadAsset(
|
|
75
|
-
collectionId: string,
|
|
76
|
-
productId: string,
|
|
77
|
-
proofId: string,
|
|
78
|
-
file: File,
|
|
79
|
-
extraData?: Record<string, any>,
|
|
80
|
-
onProgress?: (percent: number) => void
|
|
81
|
-
): Promise<AssetResponse> {
|
|
82
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset`
|
|
83
|
-
const url = (typeof window !== "undefined" && (window as any).SMARTLINKS_API_BASEURL)
|
|
84
|
-
? (window as any).SMARTLINKS_API_BASEURL + path
|
|
85
|
-
: path // fallback for SSR or Node
|
|
86
|
-
|
|
87
|
-
const formData = new FormData()
|
|
88
|
-
formData.append("file", file)
|
|
89
|
-
if (extraData) {
|
|
90
|
-
formData.append("extraData", JSON.stringify(extraData))
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Use getApiHeaders from http module
|
|
94
|
-
const headers = getApiHeaders ? getApiHeaders() : {}
|
|
95
|
-
|
|
96
|
-
return new Promise<AssetResponse>((resolve, reject) => {
|
|
97
|
-
const xhr = new XMLHttpRequest()
|
|
98
|
-
xhr.open("POST", url)
|
|
99
|
-
|
|
100
|
-
// Set headers for API key and bearer token if available
|
|
101
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
102
|
-
xhr.setRequestHeader(key, value)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
xhr.upload.onprogress = (event) => {
|
|
106
|
-
if (onProgress && event.lengthComputable) {
|
|
107
|
-
const percent = Math.round((event.loaded / event.total) * 100)
|
|
108
|
-
onProgress(percent)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
xhr.onload = () => {
|
|
113
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
114
|
-
try {
|
|
115
|
-
resolve(JSON.parse(xhr.responseText) as AssetResponse)
|
|
116
|
-
} catch (e) {
|
|
117
|
-
reject(new Error("Failed to parse server response"))
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
try {
|
|
121
|
-
const errBody = JSON.parse(xhr.responseText)
|
|
122
|
-
reject(new Error(`Error ${errBody.code}: ${errBody.message}`))
|
|
123
|
-
} catch {
|
|
124
|
-
reject(new Error(`Asset upload failed with status ${xhr.status}`))
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
xhr.onerror = () => reject(new Error("Network error during asset upload"))
|
|
130
|
-
xhr.send(formData)
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
}
|
package/src/api/attestation.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { request, post, put, del } from "../http"
|
|
2
|
-
import type { AttestationResponse, AttestationCreateRequest, AttestationUpdateRequest } from "../types/attestation"
|
|
3
|
-
|
|
4
|
-
export namespace attestation {
|
|
5
|
-
/**
|
|
6
|
-
* List all attestations for a proof.
|
|
7
|
-
*/
|
|
8
|
-
export async function list(
|
|
9
|
-
collectionId: string,
|
|
10
|
-
productId: string,
|
|
11
|
-
proofId: string
|
|
12
|
-
): Promise<AttestationResponse[]> {
|
|
13
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation`
|
|
14
|
-
return request<AttestationResponse[]>(path)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Get a single attestation by ID.
|
|
19
|
-
*/
|
|
20
|
-
export async function get(
|
|
21
|
-
collectionId: string,
|
|
22
|
-
productId: string,
|
|
23
|
-
proofId: string,
|
|
24
|
-
attestationId: string
|
|
25
|
-
): Promise<AttestationResponse> {
|
|
26
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`
|
|
27
|
-
return request<AttestationResponse>(path)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Create a new attestation for a proof.
|
|
32
|
-
*/
|
|
33
|
-
export async function create(
|
|
34
|
-
collectionId: string,
|
|
35
|
-
productId: string,
|
|
36
|
-
proofId: string,
|
|
37
|
-
data: AttestationCreateRequest
|
|
38
|
-
): Promise<AttestationResponse> {
|
|
39
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation`
|
|
40
|
-
return post<AttestationResponse>(path, data)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Update an attestation.
|
|
45
|
-
*/
|
|
46
|
-
export async function update(
|
|
47
|
-
collectionId: string,
|
|
48
|
-
productId: string,
|
|
49
|
-
proofId: string,
|
|
50
|
-
attestationId: string,
|
|
51
|
-
data: AttestationUpdateRequest
|
|
52
|
-
): Promise<AttestationResponse> {
|
|
53
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`
|
|
54
|
-
return put<AttestationResponse>(path, data)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Delete an attestation.
|
|
59
|
-
*/
|
|
60
|
-
export async function remove(
|
|
61
|
-
collectionId: string,
|
|
62
|
-
productId: string,
|
|
63
|
-
proofId: string,
|
|
64
|
-
attestationId: string
|
|
65
|
-
): Promise<void> {
|
|
66
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/attestation/${encodeURIComponent(attestationId)}`
|
|
67
|
-
return del<void>(path)
|
|
68
|
-
}
|
|
69
|
-
}
|
package/src/api/auth.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { post, request, setBearerToken, getApiHeaders } from "../http"
|
|
2
|
-
|
|
3
|
-
export type LoginResponse = {
|
|
4
|
-
id: string
|
|
5
|
-
name: string
|
|
6
|
-
email: string
|
|
7
|
-
bearerToken: string
|
|
8
|
-
account: Record<string, any>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type VerifyTokenResponse = {
|
|
12
|
-
valid: boolean
|
|
13
|
-
id?: string
|
|
14
|
-
name?: string
|
|
15
|
-
email?: string
|
|
16
|
-
account?: Record<string, any>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type AccountInfoResponse = {
|
|
20
|
-
accessType: string;
|
|
21
|
-
analyticsCode: string;
|
|
22
|
-
analyticsId: string;
|
|
23
|
-
auth_time: number;
|
|
24
|
-
baseCollectionId: string;
|
|
25
|
-
clientType: string;
|
|
26
|
-
email: string;
|
|
27
|
-
email_verified: boolean;
|
|
28
|
-
features: {
|
|
29
|
-
actionLogger: boolean;
|
|
30
|
-
adminCollections: boolean;
|
|
31
|
-
adminApps: boolean;
|
|
32
|
-
apiKeys: boolean;
|
|
33
|
-
adminUsers: boolean;
|
|
34
|
-
[key: string]: boolean;
|
|
35
|
-
};
|
|
36
|
-
iat: number;
|
|
37
|
-
id: string;
|
|
38
|
-
iss: string;
|
|
39
|
-
location: string | null;
|
|
40
|
-
name: string;
|
|
41
|
-
picture: string;
|
|
42
|
-
sites: {
|
|
43
|
-
[siteName: string]: boolean;
|
|
44
|
-
};
|
|
45
|
-
sub: string;
|
|
46
|
-
uid: string;
|
|
47
|
-
user_id: string;
|
|
48
|
-
whitelabel: {
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
user: Record<string, any>
|
|
56
|
-
owner: Record<string, any>
|
|
57
|
-
account: Record<string, any>
|
|
58
|
-
location: Record<string, any>
|
|
59
|
-
}
|
|
60
|
-
*/
|
|
61
|
-
export namespace auth {
|
|
62
|
-
/**
|
|
63
|
-
* Login with email and password.
|
|
64
|
-
* Sets the bearerToken for subsequent API calls.
|
|
65
|
-
*/
|
|
66
|
-
export async function login(email: string, password: string): Promise<LoginResponse> {
|
|
67
|
-
const res = await post<LoginResponse>("/public/auth/login", { email, password })
|
|
68
|
-
setBearerToken(res.bearerToken)
|
|
69
|
-
return res
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Logout (clears bearerToken for future API calls).
|
|
74
|
-
*/
|
|
75
|
-
export function logout(): void {
|
|
76
|
-
setBearerToken(undefined)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Verifies the current bearerToken (or a provided token).
|
|
81
|
-
* Returns user/account info if valid.
|
|
82
|
-
*/
|
|
83
|
-
export async function verifyToken(token?: string): Promise<VerifyTokenResponse> {
|
|
84
|
-
// Use the provided token, or the one from getApiHeaders
|
|
85
|
-
const headers = { ...getApiHeaders() }
|
|
86
|
-
if (token) {
|
|
87
|
-
headers["AUTHORIZATION"] = `Bearer ${token}`
|
|
88
|
-
}
|
|
89
|
-
const result = await post<VerifyTokenResponse>("/public/auth/verify", {}, headers)
|
|
90
|
-
if (token && result.valid) {
|
|
91
|
-
setBearerToken(token)
|
|
92
|
-
}
|
|
93
|
-
return result
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Gets current account information for the logged in user.
|
|
98
|
-
* Returns user, owner, account, and location objects.
|
|
99
|
-
*/
|
|
100
|
-
export async function getAccount(): Promise<AccountInfoResponse> {
|
|
101
|
-
return request<AccountInfoResponse>("/public/auth/account")
|
|
102
|
-
}
|
|
103
|
-
}
|
package/src/api/batch.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// src/api/batch.ts
|
|
2
|
-
import { request, post, put, del } from "../http"
|
|
3
|
-
import { BatchResponse, BatchCreateRequest, BatchUpdateRequest } from "../types/batch"
|
|
4
|
-
|
|
5
|
-
export namespace batch {
|
|
6
|
-
// Admin CRUD operations
|
|
7
|
-
/**
|
|
8
|
-
* Get a single batch by ID for a collection and product (admin only).
|
|
9
|
-
* @param collectionId - Identifier of the parent collection
|
|
10
|
-
* @param productId - Identifier of the parent product
|
|
11
|
-
* @param batchId - Identifier of the batch
|
|
12
|
-
* @returns Promise resolving to a BatchResponse object
|
|
13
|
-
* @throws ErrorResponse if the request fails
|
|
14
|
-
*/
|
|
15
|
-
export async function get(
|
|
16
|
-
collectionId: string,
|
|
17
|
-
productId: string,
|
|
18
|
-
batchId: string
|
|
19
|
-
): Promise<BatchResponse> {
|
|
20
|
-
const path = `/admin/collection/${encodeURIComponent(
|
|
21
|
-
collectionId
|
|
22
|
-
)}/product/${encodeURIComponent(
|
|
23
|
-
productId
|
|
24
|
-
)}/batch/${encodeURIComponent(batchId)}`
|
|
25
|
-
return request<BatchResponse>(path)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* List all batches for a collection and product (admin only).
|
|
30
|
-
* @param collectionId - Identifier of the parent collection
|
|
31
|
-
* @param productId - Identifier of the parent product
|
|
32
|
-
* @returns Promise resolving to an array of BatchResponse objects
|
|
33
|
-
* @throws ErrorResponse if the request fails
|
|
34
|
-
*/
|
|
35
|
-
export async function list(
|
|
36
|
-
collectionId: string,
|
|
37
|
-
productId: string
|
|
38
|
-
): Promise<BatchResponse[]> {
|
|
39
|
-
const path = `/admin/collection/${encodeURIComponent(
|
|
40
|
-
collectionId
|
|
41
|
-
)}/product/${encodeURIComponent(productId)}/batch`
|
|
42
|
-
return request<BatchResponse[]>(path)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Create a new batch for a collection and product (admin only).
|
|
47
|
-
* @param collectionId - Identifier of the parent collection
|
|
48
|
-
* @param productId - Identifier of the parent product
|
|
49
|
-
* @param data - Batch creation data
|
|
50
|
-
* @returns Promise resolving to a BatchResponse object
|
|
51
|
-
* @throws ErrorResponse if the request fails
|
|
52
|
-
*/
|
|
53
|
-
export async function create(
|
|
54
|
-
collectionId: string,
|
|
55
|
-
productId: string,
|
|
56
|
-
data: BatchCreateRequest
|
|
57
|
-
): Promise<BatchResponse> {
|
|
58
|
-
const path = `/admin/collection/${encodeURIComponent(
|
|
59
|
-
collectionId
|
|
60
|
-
)}/product/${encodeURIComponent(productId)}/batch`
|
|
61
|
-
return post<BatchResponse>(path, data)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Update a batch for a collection and product (admin only).
|
|
66
|
-
* @param collectionId - Identifier of the parent collection
|
|
67
|
-
* @param productId - Identifier of the parent product
|
|
68
|
-
* @param batchId - Identifier of the batch
|
|
69
|
-
* @param data - Batch update data
|
|
70
|
-
* @returns Promise resolving to a BatchResponse object
|
|
71
|
-
* @throws ErrorResponse if the request fails
|
|
72
|
-
*/
|
|
73
|
-
export async function update(
|
|
74
|
-
collectionId: string,
|
|
75
|
-
productId: string,
|
|
76
|
-
batchId: string,
|
|
77
|
-
data: BatchUpdateRequest
|
|
78
|
-
): Promise<BatchResponse> {
|
|
79
|
-
const path = `/admin/collection/${encodeURIComponent(
|
|
80
|
-
collectionId
|
|
81
|
-
)}/product/${encodeURIComponent(
|
|
82
|
-
productId
|
|
83
|
-
)}/batch/${encodeURIComponent(batchId)}`
|
|
84
|
-
return put<BatchResponse>(path, data)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Delete a batch for a collection and product (admin only).
|
|
89
|
-
* @param collectionId - Identifier of the parent collection
|
|
90
|
-
* @param productId - Identifier of the parent product
|
|
91
|
-
* @param batchId - Identifier of the batch
|
|
92
|
-
* @returns Promise resolving to void
|
|
93
|
-
* @throws ErrorResponse if the request fails
|
|
94
|
-
*/
|
|
95
|
-
export async function remove(
|
|
96
|
-
collectionId: string,
|
|
97
|
-
productId: string,
|
|
98
|
-
batchId: string
|
|
99
|
-
): Promise<void> {
|
|
100
|
-
const path = `/admin/collection/${encodeURIComponent(
|
|
101
|
-
collectionId
|
|
102
|
-
)}/product/${encodeURIComponent(
|
|
103
|
-
productId
|
|
104
|
-
)}/batch/${encodeURIComponent(batchId)}`
|
|
105
|
-
return del<void>(path)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Public read-only operation
|
|
109
|
-
/**
|
|
110
|
-
* Get a single batch by ID for a collection and product (public endpoint).
|
|
111
|
-
* @param collectionId - Identifier of the parent collection
|
|
112
|
-
* @param productId - Identifier of the parent product
|
|
113
|
-
* @param batchId - Identifier of the batch
|
|
114
|
-
* @returns Promise resolving to a BatchResponse object
|
|
115
|
-
* @throws ErrorResponse if the request fails
|
|
116
|
-
*/
|
|
117
|
-
export async function getPublic(
|
|
118
|
-
collectionId: string,
|
|
119
|
-
productId: string,
|
|
120
|
-
batchId: string
|
|
121
|
-
): Promise<BatchResponse> {
|
|
122
|
-
const path = `/public/collection/${encodeURIComponent(
|
|
123
|
-
collectionId
|
|
124
|
-
)}/product/${encodeURIComponent(
|
|
125
|
-
productId
|
|
126
|
-
)}/batch/${encodeURIComponent(batchId)}`
|
|
127
|
-
return request<BatchResponse>(path)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get serial numbers for a batch (admin only).
|
|
132
|
-
* @param collectionId - Identifier of the parent collection
|
|
133
|
-
* @param productId - Identifier of the parent product
|
|
134
|
-
* @param batchId - Identifier of the batch
|
|
135
|
-
* @param startIndex - Starting index for pagination (default: 0)
|
|
136
|
-
* @param count - Number of serial numbers to retrieve (default: 10)
|
|
137
|
-
* @returns Promise resolving to serial number data
|
|
138
|
-
* @throws ErrorResponse if the request fails
|
|
139
|
-
*/
|
|
140
|
-
export async function getSN(
|
|
141
|
-
collectionId: string,
|
|
142
|
-
productId: string,
|
|
143
|
-
batchId: string,
|
|
144
|
-
startIndex: number = 0,
|
|
145
|
-
count: number = 10
|
|
146
|
-
): Promise<any> {
|
|
147
|
-
const queryParams = new URLSearchParams({
|
|
148
|
-
startIndex: startIndex.toString(),
|
|
149
|
-
count: count.toString()
|
|
150
|
-
})
|
|
151
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/batch/${encodeURIComponent(batchId)}/getSN?${queryParams}`
|
|
152
|
-
return request<any>(path)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Look up a serial number by code for a batch (admin only).
|
|
157
|
-
* @param collectionId - Identifier of the parent collection
|
|
158
|
-
* @param productId - Identifier of the parent product
|
|
159
|
-
* @param batchId - Identifier of the batch
|
|
160
|
-
* @param codeId - The serial number code to look up
|
|
161
|
-
* @returns Promise resolving to serial number lookup data
|
|
162
|
-
* @throws ErrorResponse if the request fails
|
|
163
|
-
*/
|
|
164
|
-
export async function lookupSN(
|
|
165
|
-
collectionId: string,
|
|
166
|
-
productId: string,
|
|
167
|
-
batchId: string,
|
|
168
|
-
codeId: string
|
|
169
|
-
): Promise<any> {
|
|
170
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/batch/${encodeURIComponent(batchId)}/lookupSN/${encodeURIComponent(codeId)}`
|
|
171
|
-
return request<any>(path)
|
|
172
|
-
}
|
|
173
|
-
}
|
package/src/api/claimSet.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { request, post, put } from "../http";
|
|
2
|
-
|
|
3
|
-
export namespace claimSet {
|
|
4
|
-
/**
|
|
5
|
-
* Get all claim sets for a collection.
|
|
6
|
-
* @param collectionId – The collection identifier
|
|
7
|
-
* @returns Promise resolving to an array of claim sets
|
|
8
|
-
*/
|
|
9
|
-
export async function getAllForCollection(collectionId: string): Promise<any[]> {
|
|
10
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet`;
|
|
11
|
-
return request<any[]>(path);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get a specific claim set for a collection.
|
|
16
|
-
* @param collectionId – The collection identifier
|
|
17
|
-
* @param claimSetId – The claim set identifier
|
|
18
|
-
* @returns Promise resolving to a claim set object
|
|
19
|
-
*/
|
|
20
|
-
export async function getForCollection(collectionId: string, claimSetId: string): Promise<any> {
|
|
21
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(claimSetId)}`;
|
|
22
|
-
return request<any>(path);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get all tags for a claim set.
|
|
27
|
-
* @param collectionId – The collection identifier
|
|
28
|
-
* @param claimSetId – The claim set identifier
|
|
29
|
-
* @returns Promise resolving to an array of tags
|
|
30
|
-
*/
|
|
31
|
-
export async function getAllTags(collectionId: string, claimSetId: string): Promise<any[]> {
|
|
32
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(claimSetId)}/tags`;
|
|
33
|
-
return request<any[]>(path);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get a report for a claim set.
|
|
38
|
-
* @param collectionId – The collection identifier
|
|
39
|
-
* @param claimSetId – The claim set identifier
|
|
40
|
-
* @returns Promise resolving to a report object
|
|
41
|
-
*/
|
|
42
|
-
export async function getReport(collectionId: string, claimSetId: string): Promise<any> {
|
|
43
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(claimSetId)}/report`;
|
|
44
|
-
return request<any>(path);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get assigned tags for a claim set.
|
|
49
|
-
* @param collectionId – The collection identifier
|
|
50
|
-
* @param claimSetId – The claim set identifier
|
|
51
|
-
* @returns Promise resolving to assigned tags
|
|
52
|
-
*/
|
|
53
|
-
export async function getAssignedTags(collectionId: string, claimSetId: string): Promise<any> {
|
|
54
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(claimSetId)}/assignedTags`;
|
|
55
|
-
return request<any>(path);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get tag summary for a collection.
|
|
60
|
-
* @param collectionId – The collection identifier
|
|
61
|
-
* @returns Promise resolving to tag summary
|
|
62
|
-
*/
|
|
63
|
-
export async function getTagSummary(collectionId: string): Promise<any> {
|
|
64
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/tagSummary`;
|
|
65
|
-
return request<any>(path);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Perform a tag query for a collection.
|
|
70
|
-
* @param collectionId – The collection identifier
|
|
71
|
-
* @param data – The query data
|
|
72
|
-
* @returns Promise resolving to query results
|
|
73
|
-
*/
|
|
74
|
-
export async function tagQuery(collectionId: string, data: any): Promise<any> {
|
|
75
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/tagQuery`;
|
|
76
|
-
return post<any>(path, data);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Create a new claim set for a collection.
|
|
81
|
-
* @param collectionId – The collection identifier
|
|
82
|
-
* @param params – The claim set creation parameters
|
|
83
|
-
* @returns Promise resolving to the created claim set
|
|
84
|
-
*/
|
|
85
|
-
export async function createForCollection(collectionId: string, params: any): Promise<any> {
|
|
86
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet`;
|
|
87
|
-
return post<any>(path, params);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Update a claim set for a collection.
|
|
92
|
-
* @param collectionId – The collection identifier
|
|
93
|
-
* @param params – The claim set update parameters (must include id)
|
|
94
|
-
* @returns Promise resolving to the updated claim set
|
|
95
|
-
*/
|
|
96
|
-
export async function updateForCollection(collectionId: string, params: any): Promise<any> {
|
|
97
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(params.id)}`;
|
|
98
|
-
return put<any>(path, params);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Make a claim for a claim set.
|
|
103
|
-
* @param collectionId – The collection identifier
|
|
104
|
-
* @param params – The claim parameters (must include id)
|
|
105
|
-
* @returns Promise resolving to the claim result
|
|
106
|
-
*/
|
|
107
|
-
export async function makeClaim(collectionId: string, params: any): Promise<any> {
|
|
108
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(params.id)}/makeClaim`;
|
|
109
|
-
return post<any>(path, params);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Assign claims to a claim set.
|
|
114
|
-
* @param collectionId – The collection identifier
|
|
115
|
-
* @param data – The claims data to assign
|
|
116
|
-
*/
|
|
117
|
-
export async function assignClaims(collectionId: string, data: any): Promise<any> {
|
|
118
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/${encodeURIComponent(data.id)}/assignClaims`;
|
|
119
|
-
return post<any>(path, data);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Update claim data for a collection.
|
|
124
|
-
* @param collectionId – The collection identifier
|
|
125
|
-
* @param data – The claim data to update
|
|
126
|
-
*/
|
|
127
|
-
export async function updateClaimData(collectionId: string, data: any): Promise<any> {
|
|
128
|
-
const path = `/admin/collection/${encodeURIComponent(collectionId)}/claimSet/updateClaimData`;
|
|
129
|
-
return post<any>(path, data);
|
|
130
|
-
}
|
|
131
|
-
}
|