@proveanything/smartlinks 1.0.4 → 1.0.5
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/collection.d.ts +10 -0
- package/dist/api/collection.js +16 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +6 -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/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 +5 -0
- package/dist/types/index.js +7 -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/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppConfigurationResponse } from "../types/appConfiguration";
|
|
2
|
+
export declare namespace appConfiguration {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a single App Configuration by Collection ID and App ID.
|
|
5
|
+
* @param collectionId – Identifier of the parent collection
|
|
6
|
+
* @param appId – Identifier of the app configuration
|
|
7
|
+
* @returns Promise resolving to an AppConfigurationResponse object
|
|
8
|
+
* @throws ErrorResponse if the request fails
|
|
9
|
+
*/
|
|
10
|
+
function get(collectionId: string, appId: string): Promise<AppConfigurationResponse>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/api/appConfiguration.ts
|
|
2
|
+
import { request } from "../http";
|
|
3
|
+
export var appConfiguration;
|
|
4
|
+
(function (appConfiguration) {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves a single App Configuration by Collection ID and App ID.
|
|
7
|
+
* @param collectionId – Identifier of the parent collection
|
|
8
|
+
* @param appId – Identifier of the app configuration
|
|
9
|
+
* @returns Promise resolving to an AppConfigurationResponse object
|
|
10
|
+
* @throws ErrorResponse if the request fails
|
|
11
|
+
*/
|
|
12
|
+
async function get(collectionId, appId) {
|
|
13
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
14
|
+
return request(path);
|
|
15
|
+
}
|
|
16
|
+
appConfiguration.get = get;
|
|
17
|
+
})(appConfiguration || (appConfiguration = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CollectionResponse } from "../types/collection";
|
|
2
|
+
export declare namespace collection {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a single Collection by its ID.
|
|
5
|
+
* @param collectionId – Identifier of the collection
|
|
6
|
+
* @returns Promise resolving to a CollectionResponse object
|
|
7
|
+
* @throws ErrorResponse if the request fails
|
|
8
|
+
*/
|
|
9
|
+
function get(collectionId: string): Promise<CollectionResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/api/collection.ts
|
|
2
|
+
import { request } from "../http";
|
|
3
|
+
export var collection;
|
|
4
|
+
(function (collection) {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves a single Collection by its ID.
|
|
7
|
+
* @param collectionId – Identifier of the collection
|
|
8
|
+
* @returns Promise resolving to a CollectionResponse object
|
|
9
|
+
* @throws ErrorResponse if the request fails
|
|
10
|
+
*/
|
|
11
|
+
async function get(collectionId) {
|
|
12
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}`;
|
|
13
|
+
return request(path);
|
|
14
|
+
}
|
|
15
|
+
collection.get = get;
|
|
16
|
+
})(collection || (collection = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/api/index.ts
|
|
2
|
+
// Re-export all resource namespaces so the consumer can import them in one line.
|
|
3
|
+
export { collection } from "./collection";
|
|
4
|
+
export { product } from "./product";
|
|
5
|
+
export { proof } from "./proof";
|
|
6
|
+
export { appConfiguration } from "./appConfiguration";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ProductResponse } from "../types/product";
|
|
2
|
+
export declare namespace product {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
5
|
+
* @param collectionId – Identifier of the parent collection
|
|
6
|
+
* @param productId – Identifier of the product item
|
|
7
|
+
* @returns Promise resolving to a ProductResponse object
|
|
8
|
+
* @throws ErrorResponse if the request fails
|
|
9
|
+
*/
|
|
10
|
+
function get(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves all Product Items for a Collection.
|
|
13
|
+
* @param collectionId – Identifier of the parent collection
|
|
14
|
+
* @returns Promise resolving to an array of ProductResponse objects
|
|
15
|
+
* @throws ErrorResponse if the request fails
|
|
16
|
+
*/
|
|
17
|
+
function getAll(collectionId: string): Promise<ProductResponse[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/api/product.ts
|
|
2
|
+
import { request } from "../http";
|
|
3
|
+
export var product;
|
|
4
|
+
(function (product) {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
7
|
+
* @param collectionId – Identifier of the parent collection
|
|
8
|
+
* @param productId – Identifier of the product item
|
|
9
|
+
* @returns Promise resolving to a ProductResponse object
|
|
10
|
+
* @throws ErrorResponse if the request fails
|
|
11
|
+
*/
|
|
12
|
+
async function get(collectionId, productId) {
|
|
13
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}`;
|
|
14
|
+
return request(path);
|
|
15
|
+
}
|
|
16
|
+
product.get = get;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves all Product Items for a Collection.
|
|
19
|
+
* @param collectionId – Identifier of the parent collection
|
|
20
|
+
* @returns Promise resolving to an array of ProductResponse objects
|
|
21
|
+
* @throws ErrorResponse if the request fails
|
|
22
|
+
*/
|
|
23
|
+
async function getAll(collectionId) {
|
|
24
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product`;
|
|
25
|
+
return request(path);
|
|
26
|
+
}
|
|
27
|
+
product.getAll = getAll;
|
|
28
|
+
})(product || (product = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProofResponse } from "../types/proof";
|
|
2
|
+
export declare namespace proof {
|
|
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
|
|
9
|
+
*/
|
|
10
|
+
function get(collectionId: string, proofId: string): Promise<ProofResponse>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/api/proof.ts
|
|
2
|
+
import { request } from "../http";
|
|
3
|
+
export var proof;
|
|
4
|
+
(function (proof) {
|
|
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
|
|
11
|
+
*/
|
|
12
|
+
async function get(collectionId, proofId) {
|
|
13
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/proof/${encodeURIComponent(proofId)}`;
|
|
14
|
+
return request(path);
|
|
15
|
+
}
|
|
16
|
+
proof.get = get;
|
|
17
|
+
})(proof || (proof = {}));
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call this once (e.g. at app startup) to configure baseURL/auth.
|
|
3
|
+
*
|
|
4
|
+
* @param options.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
|
|
5
|
+
* @param options.apiKey - (Optional) API key for X-API-Key header
|
|
6
|
+
* @param options.bearerToken - (Optional) Bearer token for AUTHORIZATION header
|
|
7
|
+
*/
|
|
8
|
+
export declare function initializeApi(options: {
|
|
9
|
+
baseURL: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
bearerToken?: string;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* Internal helper that performs a GET request to \`\${baseURL}\${path}\`,
|
|
15
|
+
* injecting headers for apiKey or bearerToken if present.
|
|
16
|
+
* Returns the parsed JSON as T, or throws an Error.
|
|
17
|
+
*/
|
|
18
|
+
export declare function request<T>(path: string): Promise<T>;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/http.ts
|
|
2
|
+
// This module replaces the ApiClient constructor. It keeps baseURL, apiKey, bearerToken
|
|
3
|
+
// in module-scope variables, and provides a shared `request<T>(path)` helper that will
|
|
4
|
+
// be used by all namespaced files (collection.ts, product.ts, etc.).
|
|
5
|
+
let baseURL = null;
|
|
6
|
+
let apiKey = undefined;
|
|
7
|
+
let bearerToken = undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Call this once (e.g. at app startup) to configure baseURL/auth.
|
|
10
|
+
*
|
|
11
|
+
* @param options.baseURL - The root URL of the Smartlinks API (e.g. "https://smartlinks.app/api/v1")
|
|
12
|
+
* @param options.apiKey - (Optional) API key for X-API-Key header
|
|
13
|
+
* @param options.bearerToken - (Optional) Bearer token for AUTHORIZATION header
|
|
14
|
+
*/
|
|
15
|
+
export function initializeApi(options) {
|
|
16
|
+
baseURL = options.baseURL.replace(/\/+\$/, ""); // trim trailing slash
|
|
17
|
+
apiKey = options.apiKey;
|
|
18
|
+
bearerToken = options.bearerToken;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Internal helper that performs a GET request to \`\${baseURL}\${path}\`,
|
|
22
|
+
* injecting headers for apiKey or bearerToken if present.
|
|
23
|
+
* Returns the parsed JSON as T, or throws an Error.
|
|
24
|
+
*/
|
|
25
|
+
export async function request(path) {
|
|
26
|
+
if (!baseURL) {
|
|
27
|
+
throw new Error("HTTP client is not initialized. Call initializeApi(...) first.");
|
|
28
|
+
}
|
|
29
|
+
const url = `${baseURL}${path}`;
|
|
30
|
+
const headers = {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
};
|
|
33
|
+
if (apiKey) {
|
|
34
|
+
headers["X-API-Key"] = apiKey;
|
|
35
|
+
}
|
|
36
|
+
if (bearerToken) {
|
|
37
|
+
headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
|
|
38
|
+
}
|
|
39
|
+
const response = await fetch(url, {
|
|
40
|
+
method: "GET",
|
|
41
|
+
headers,
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
// Try to parse ErrorResponse; if that fails, throw generic
|
|
45
|
+
try {
|
|
46
|
+
const errBody = (await response.json());
|
|
47
|
+
throw new Error(`Error ${errBody.code}: ${errBody.message}`);
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
throw new Error(`Request to ${url} failed with status ${response.status}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return (await response.json());
|
|
54
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
export interface CollectionResponse {
|
|
5
|
-
/** Unique identifier for the collection */
|
|
6
|
-
id: string;
|
|
7
|
-
/** Machine‐readable name of the collection */
|
|
8
|
-
name: string;
|
|
9
|
-
/** Human‐readable title of the collection */
|
|
10
|
-
title: string;
|
|
11
|
-
/** URL to the collection’s logo image */
|
|
12
|
-
logoImage: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Represents a Product Item object.
|
|
16
|
-
*/
|
|
17
|
-
export interface ProductResponse {
|
|
18
|
-
/** Unique identifier for the product */
|
|
19
|
-
id: string;
|
|
20
|
-
/** Name of the product */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Detailed description of the product */
|
|
23
|
-
description: string;
|
|
24
|
-
/** URL to the product’s hero image */
|
|
25
|
-
heroImage: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Represents an App Configuration object.
|
|
29
|
-
*/
|
|
30
|
-
export interface AppConfigurationResponse {
|
|
31
|
-
/** Unique identifier for the app configuration */
|
|
32
|
-
id: string;
|
|
33
|
-
/** Name of the app configuration */
|
|
34
|
-
name: string;
|
|
35
|
-
/** Key‐value pairs representing configuration settings */
|
|
36
|
-
settings?: Record<string, any>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Represents a standardized error response.
|
|
40
|
-
*/
|
|
41
|
-
export interface ErrorResponse {
|
|
42
|
-
/** Numeric error code */
|
|
43
|
-
code: number;
|
|
44
|
-
/** Human‐readable error message */
|
|
45
|
-
message: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* ApiClient for the Smartlinks API.
|
|
49
|
-
* Supports both browser (native fetch) and Node (using cross-fetch).
|
|
50
|
-
*/
|
|
51
|
-
export declare class ApiClient {
|
|
52
|
-
private baseURL;
|
|
53
|
-
private apiKey?;
|
|
54
|
-
private bearerToken?;
|
|
55
|
-
/**
|
|
56
|
-
* Creates an instance of ApiClient.
|
|
57
|
-
* @param baseURL - The base URL of the Smartlinks API (e.g., https://smartlinks.app/api/v1)
|
|
58
|
-
* @param apiKey - (Optional) API key for X-API-Key header
|
|
59
|
-
* @param bearerToken - (Optional) Bearer token for AUTHORIZATION header
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* // With both API key and bearer token
|
|
63
|
-
* const client = new ApiClient(
|
|
64
|
-
* 'https://smartlinks.app/api/v1',
|
|
65
|
-
* 'your-api-key',
|
|
66
|
-
* 'your-bearer-token'
|
|
67
|
-
* );
|
|
68
|
-
*
|
|
69
|
-
* // With only API key
|
|
70
|
-
* const client = new ApiClient(
|
|
71
|
-
* 'https://smartlinks.app/api/v1',
|
|
72
|
-
* 'your-api-key'
|
|
73
|
-
* );
|
|
74
|
-
*
|
|
75
|
-
* // With only bearer token
|
|
76
|
-
* const client = new ApiClient(
|
|
77
|
-
* 'https://smartlinks.app/api/v1',
|
|
78
|
-
* undefined,
|
|
79
|
-
* 'your-bearer-token'
|
|
80
|
-
* );
|
|
81
|
-
*/
|
|
82
|
-
constructor(baseURL: string, apiKey?: string, bearerToken?: string);
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves a single Collection by its ID.
|
|
85
|
-
* @param collectionId - Identifier of the collection
|
|
86
|
-
* @returns Promise resolving to a CollectionResponse object
|
|
87
|
-
* @throws ErrorResponse if the request fails
|
|
88
|
-
*/
|
|
89
|
-
getCollection(collectionId: string): Promise<CollectionResponse>;
|
|
90
|
-
/**
|
|
91
|
-
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
92
|
-
* @param collectionId - Identifier of the parent collection
|
|
93
|
-
* @param productId - Identifier of the product item
|
|
94
|
-
* @returns Promise resolving to a ProductResponse object
|
|
95
|
-
* @throws ErrorResponse if the request fails
|
|
96
|
-
*/
|
|
97
|
-
getProductItem(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
98
|
-
/**
|
|
99
|
-
* Retrieves a single App Configuration by Collection ID and App ID.
|
|
100
|
-
* @param collectionId - Identifier of the parent collection
|
|
101
|
-
* @param appId - Identifier of the app configuration
|
|
102
|
-
* @returns Promise resolving to an AppConfigurationResponse object
|
|
103
|
-
* @throws ErrorResponse if the request fails
|
|
104
|
-
*/
|
|
105
|
-
getAppConfiguration(collectionId: string, appId: string): Promise<AppConfigurationResponse>;
|
|
106
|
-
/**
|
|
107
|
-
* Internal helper to perform a GET request and parse JSON.
|
|
108
|
-
* @param path - The path (relative to baseURL) to request
|
|
109
|
-
* @returns Promise resolving to the parsed JSON of type T
|
|
110
|
-
* @throws Error if network error or a non-2xx response is returned
|
|
111
|
-
*/
|
|
112
|
-
private request;
|
|
113
|
-
}
|
|
1
|
+
export { initializeApi, request } from "./http";
|
|
2
|
+
export * from "./api";
|
|
3
|
+
export * from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1,105 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* ApiClient for the Smartlinks API.
|
|
7
|
-
* Supports both browser (native fetch) and Node (using cross-fetch).
|
|
8
|
-
*/
|
|
9
|
-
export class ApiClient {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of ApiClient.
|
|
12
|
-
* @param baseURL - The base URL of the Smartlinks API (e.g., https://smartlinks.app/api/v1)
|
|
13
|
-
* @param apiKey - (Optional) API key for X-API-Key header
|
|
14
|
-
* @param bearerToken - (Optional) Bearer token for AUTHORIZATION header
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* // With both API key and bearer token
|
|
18
|
-
* const client = new ApiClient(
|
|
19
|
-
* 'https://smartlinks.app/api/v1',
|
|
20
|
-
* 'your-api-key',
|
|
21
|
-
* 'your-bearer-token'
|
|
22
|
-
* );
|
|
23
|
-
*
|
|
24
|
-
* // With only API key
|
|
25
|
-
* const client = new ApiClient(
|
|
26
|
-
* 'https://smartlinks.app/api/v1',
|
|
27
|
-
* 'your-api-key'
|
|
28
|
-
* );
|
|
29
|
-
*
|
|
30
|
-
* // With only bearer token
|
|
31
|
-
* const client = new ApiClient(
|
|
32
|
-
* 'https://smartlinks.app/api/v1',
|
|
33
|
-
* undefined,
|
|
34
|
-
* 'your-bearer-token'
|
|
35
|
-
* );
|
|
36
|
-
*/
|
|
37
|
-
constructor(baseURL, apiKey, bearerToken) {
|
|
38
|
-
this.baseURL = baseURL.replace(/\/+$/, ''); // Trim trailing slash
|
|
39
|
-
this.apiKey = apiKey;
|
|
40
|
-
this.bearerToken = bearerToken;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Retrieves a single Collection by its ID.
|
|
44
|
-
* @param collectionId - Identifier of the collection
|
|
45
|
-
* @returns Promise resolving to a CollectionResponse object
|
|
46
|
-
* @throws ErrorResponse if the request fails
|
|
47
|
-
*/
|
|
48
|
-
async getCollection(collectionId) {
|
|
49
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}`;
|
|
50
|
-
return this.request(path);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
54
|
-
* @param collectionId - Identifier of the parent collection
|
|
55
|
-
* @param productId - Identifier of the product item
|
|
56
|
-
* @returns Promise resolving to a ProductResponse object
|
|
57
|
-
* @throws ErrorResponse if the request fails
|
|
58
|
-
*/
|
|
59
|
-
async getProductItem(collectionId, productId) {
|
|
60
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}`;
|
|
61
|
-
return this.request(path);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Retrieves a single App Configuration by Collection ID and App ID.
|
|
65
|
-
* @param collectionId - Identifier of the parent collection
|
|
66
|
-
* @param appId - Identifier of the app configuration
|
|
67
|
-
* @returns Promise resolving to an AppConfigurationResponse object
|
|
68
|
-
* @throws ErrorResponse if the request fails
|
|
69
|
-
*/
|
|
70
|
-
async getAppConfiguration(collectionId, appId) {
|
|
71
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
72
|
-
return this.request(path);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Internal helper to perform a GET request and parse JSON.
|
|
76
|
-
* @param path - The path (relative to baseURL) to request
|
|
77
|
-
* @returns Promise resolving to the parsed JSON of type T
|
|
78
|
-
* @throws Error if network error or a non-2xx response is returned
|
|
79
|
-
*/
|
|
80
|
-
async request(path) {
|
|
81
|
-
const url = `${this.baseURL}${path}`;
|
|
82
|
-
const headers = {
|
|
83
|
-
'Content-Type': 'application/json',
|
|
84
|
-
};
|
|
85
|
-
if (this.apiKey) {
|
|
86
|
-
headers['X-API-Key'] = this.apiKey;
|
|
87
|
-
}
|
|
88
|
-
if (this.bearerToken) {
|
|
89
|
-
headers['AUTHORIZATION'] = `Bearer ${this.bearerToken}`;
|
|
90
|
-
}
|
|
91
|
-
const response = await fetch(url, { method: 'GET', headers });
|
|
92
|
-
if (!response.ok) {
|
|
93
|
-
// Attempt to parse error body; if it fails, throw generic
|
|
94
|
-
let errorBody;
|
|
95
|
-
try {
|
|
96
|
-
errorBody = (await response.json());
|
|
97
|
-
}
|
|
98
|
-
catch (_a) {
|
|
99
|
-
throw new Error(`Request failed with status ${response.status}`);
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`Error ${errorBody.code}: ${errorBody.message}`);
|
|
102
|
-
}
|
|
103
|
-
return (await response.json());
|
|
104
|
-
}
|
|
105
|
-
}
|
|
1
|
+
// src/index.ts
|
|
2
|
+
// Top-level entrypoint of the npm package. Re-export initializeApi + all namespaces.
|
|
3
|
+
export { initializeApi, request } from "./http";
|
|
4
|
+
export * from "./api";
|
|
5
|
+
export * from "./types";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an App Configuration object.
|
|
3
|
+
*/
|
|
4
|
+
export interface AppConfigurationResponse {
|
|
5
|
+
/** Unique identifier for the app configuration */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Name of the app configuration */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Key-value pairs representing configuration settings */
|
|
10
|
+
settings?: Record<string, any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Collection object.
|
|
3
|
+
*/
|
|
4
|
+
export interface CollectionResponse {
|
|
5
|
+
/** Unique identifier for the collection */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Machine-readable name of the collection */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Human-readable title of the collection */
|
|
10
|
+
title: string;
|
|
11
|
+
/** URL to the collection’s logo image */
|
|
12
|
+
logoImage: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Product Item object.
|
|
3
|
+
*/
|
|
4
|
+
export interface ProductResponse {
|
|
5
|
+
/** Unique identifier for the product */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Name of the product */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Detailed description of the product */
|
|
10
|
+
description: string;
|
|
11
|
+
/** URL to the product’s hero image */
|
|
12
|
+
heroImage: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Proof object.
|
|
3
|
+
*/
|
|
4
|
+
export interface ProofResponse {
|
|
5
|
+
/** Unique identifier for the collection */
|
|
6
|
+
collectionId: string;
|
|
7
|
+
/** Creation timestamp */
|
|
8
|
+
createdAt: string;
|
|
9
|
+
/** Unique identifier for the proof */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Unique identifier for the product */
|
|
12
|
+
productId: string;
|
|
13
|
+
/** Unique identifier for the token */
|
|
14
|
+
tokenId: string;
|
|
15
|
+
/** Unique identifier for the user */
|
|
16
|
+
userId: string;
|
|
17
|
+
/** Arbitrary key-value pairs for proof values */
|
|
18
|
+
values: Record<string, any>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|