@proveanything/smartlinks 1.1.23 → 1.1.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.1.23 | Generated: 2026-01-07T13:11:08.113Z
3
+ Version: 1.1.24 | Generated: 2026-01-11T11:29:10.460Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -125,15 +125,84 @@ interface AppConfigurationResponse {
125
125
 
126
126
  ### asset
127
127
 
128
- **AssetResponse** (interface)
128
+ **Asset** (interface)
129
129
  ```typescript
130
- interface AssetResponse {
130
+ interface Asset {
131
131
  id: string
132
- name: string
133
132
  url: string
133
+ name: string
134
+ mimeType?: string
135
+ size?: number
136
+ createdAt?: string
137
+ metadata?: Record<string, any>
138
+ assetType?: string
139
+ type?: string
140
+ collectionId?: string
141
+ hash?: string
142
+ thumbnails?: {
143
+ x100?: string
144
+ x200?: string
145
+ x512?: string
146
+ [key: string]: string | undefined
147
+ }
148
+ site?: string
149
+ cleanName?: string
150
+ }
151
+ ```
152
+
153
+ **UploadAssetOptions** (interface)
154
+ ```typescript
155
+ interface UploadAssetOptions {
156
+ file: File
157
+ scope:
158
+ | { type: 'collection'; collectionId: string }
159
+ | { type: 'product'; collectionId: string; productId: string }
160
+ | { type: 'proof'; collectionId: string; productId: string; proofId: string }
161
+ name?: string
162
+ metadata?: Record<string, any>
163
+ onProgress?: (percent: number) => void
164
+ appId?: string
134
165
  }
135
166
  ```
136
167
 
168
+ **ListAssetsOptions** (interface)
169
+ ```typescript
170
+ interface ListAssetsOptions {
171
+ scope:
172
+ | { type: 'collection'; collectionId: string }
173
+ | { type: 'product'; collectionId: string; productId: string }
174
+ | { type: 'proof'; collectionId: string; productId: string; proofId: string }
175
+ appId?: string
176
+ mimeTypePrefix?: string
177
+ limit?: number
178
+ offset?: number
179
+ }
180
+ ```
181
+
182
+ **GetAssetOptions** (interface)
183
+ ```typescript
184
+ interface GetAssetOptions {
185
+ assetId: string
186
+ scope:
187
+ | { type: 'collection'; collectionId: string }
188
+ | { type: 'product'; collectionId: string; productId: string }
189
+ | { type: 'proof'; collectionId: string; productId: string; proofId: string }
190
+ }
191
+ ```
192
+
193
+ **RemoveAssetOptions** (interface)
194
+ ```typescript
195
+ interface RemoveAssetOptions {
196
+ assetId: string
197
+ scope:
198
+ | { type: 'collection'; collectionId: string }
199
+ | { type: 'product'; collectionId: string; productId: string }
200
+ | { type: 'proof'; collectionId: string; productId: string; proofId: string }
201
+ }
202
+ ```
203
+
204
+ **AssetResponse** = `Asset`
205
+
137
206
  ### attestation
138
207
 
139
208
  **AttestationResponse** (interface)
@@ -1552,12 +1621,18 @@ interface TemplateBase {
1552
1621
  collectionId: string
1553
1622
  name: string
1554
1623
  description?: string
1555
- type: string
1624
+ type: 'pdf' | 'email' | 'multichannel' | 'label'
1556
1625
  resizeMode?: string
1557
1626
  pdf?: {
1558
1627
  base: { url: string }
1559
1628
  orientation: 'portrait' | 'landscape'
1560
1629
  }
1630
+ channels?: {
1631
+ email?: {subject: string; body: string},
1632
+ sms?: { body: string },
1633
+ push: { title: string; body: string, url?: string, iconUrl?: string },
1634
+ wallet?: { header: string; body: string; imageUri?: string }
1635
+ }
1561
1636
  subject?: string
1562
1637
  body?: string
1563
1638
  css?: string
@@ -1794,27 +1869,36 @@ Post a chat message to the AI (admin or public)
1794
1869
 
1795
1870
  ### asset
1796
1871
 
1872
+ **upload**(options: UploadAssetOptions) → `Promise<Asset>`
1873
+ Upload an asset file
1874
+
1797
1875
  **getForCollection**(collectionId: string,
1798
1876
  assetId: string) → `Promise<AssetResponse>`
1877
+ Upload an asset file
1799
1878
 
1800
1879
  **listForCollection**(collectionId: string) → `Promise<AssetResponse[]>`
1880
+ Upload an asset file
1801
1881
 
1802
1882
  **getForProduct**(collectionId: string,
1803
1883
  productId: string,
1804
1884
  assetId: string) → `Promise<AssetResponse>`
1885
+ Upload an asset file
1805
1886
 
1806
1887
  **listForProduct**(collectionId: string,
1807
1888
  productId: string) → `Promise<AssetResponse[]>`
1889
+ Upload an asset file
1808
1890
 
1809
1891
  **getForProof**(collectionId: string,
1810
1892
  productId: string,
1811
1893
  proofId: string,
1812
1894
  assetId: string) → `Promise<AssetResponse>`
1895
+ Upload an asset file
1813
1896
 
1814
1897
  **listForProof**(collectionId: string,
1815
1898
  productId: string,
1816
1899
  proofId: string,
1817
1900
  appId?: string) → `Promise<AssetResponse[]>`
1901
+ Upload an asset file
1818
1902
 
1819
1903
  **uploadAsset**(collectionId: string,
1820
1904
  productId: string,
@@ -1824,6 +1908,15 @@ Post a chat message to the AI (admin or public)
1824
1908
  onProgress?: (percent: number) → `void`
1825
1909
  Uploads an asset file to a proof, with optional extraData as JSON. Supports progress reporting via onProgress callback (browser only).
1826
1910
 
1911
+ **list**(options: ListAssetsOptions) → `Promise<Asset[]>`
1912
+ List assets for a given scope
1913
+
1914
+ **get**(options: GetAssetOptions) → `Promise<Asset>`
1915
+ Get an asset by id within a scope (public)
1916
+
1917
+ **remove**(options: RemoveAssetOptions) → `Promise<void>`
1918
+ Remove an asset by id within a scope (admin)
1919
+
1827
1920
  ### async
1828
1921
 
1829
1922
  **enqueueAsyncJob**(collectionId: string,
package/README.md CHANGED
@@ -96,22 +96,88 @@ await product.update('collectionId', 'productId', { description: 'Updated' })
96
96
  await product.remove('collectionId', 'productId')
97
97
  ```
98
98
 
99
- ### Assets (upload)
99
+ ### Assets
100
100
 
101
- Browser-side upload to a proof with progress callback:
101
+ Upload, list, get, and remove assets within a scope (collection/product/proof).
102
+
103
+ #### Upload (new)
102
104
 
103
105
  ```ts
104
106
  import { asset } from '@proveanything/smartlinks'
105
107
 
106
- const result = await asset.uploadAsset(
107
- 'collectionId',
108
- 'productId',
109
- 'proofId',
108
+ const uploaded = await asset.upload({
110
109
  file, // File from an <input type="file">
111
- { description: 'Uploaded via SDK' },
112
- (progress) => console.log(`Upload: ${progress}%`)
113
- )
114
- console.log('Uploaded asset:', result)
110
+ scope: { type: 'proof', collectionId, productId, proofId },
111
+ name: 'hero.png',
112
+ metadata: { description: 'Uploaded via SDK' },
113
+ onProgress: (p) => console.log(`Upload: ${p}%`),
114
+ // appId: 'microapp-123' // optional
115
+ })
116
+ console.log('Uploaded asset:', uploaded)
117
+ ```
118
+
119
+ Deprecated upload helper (wraps to the new `upload` internally):
120
+
121
+ ```ts
122
+ // @deprecated Use asset.upload(options)
123
+ const legacy = await asset.uploadAsset(collectionId, productId, proofId, file)
124
+ ```
125
+
126
+ #### List
127
+
128
+ ```ts
129
+ // Collection assets, first 20 images
130
+ const list1 = await asset.list({
131
+ scope: { type: 'collection', collectionId },
132
+ mimeTypePrefix: 'image/',
133
+ limit: 20,
134
+ })
135
+
136
+ // Product assets, filter by appId
137
+ const list2 = await asset.list({
138
+ scope: { type: 'product', collectionId, productId },
139
+ appId: 'microapp-123',
140
+ })
141
+ ```
142
+
143
+ #### Get (scoped)
144
+
145
+ ```ts
146
+ const a = await asset.get({
147
+ assetId,
148
+ scope: { type: 'proof', collectionId, productId, proofId },
149
+ })
150
+ ```
151
+
152
+ #### Remove (scoped, admin)
153
+
154
+ ```ts
155
+ await asset.remove({
156
+ assetId,
157
+ scope: { type: 'product', collectionId, productId },
158
+ })
159
+ ```
160
+
161
+ #### Asset response example
162
+
163
+ ```json
164
+ {
165
+ "name": "Screenshot 2025-09-15 at 15.21.14",
166
+ "assetType": "Image",
167
+ "type": "png",
168
+ "collectionId": "ChaseAtlantic",
169
+ "url": "https://cdn.smartlinks.app/sites%2FChaseAtlantic%2Fimages%2F2025%2F9%2FScreenshot%202025-09-15%20at%2015%2C21%2C14-1757946214537.png",
170
+ "createdAt": "2005-10-10T23:15:03",
171
+ "hash": "fb98140a6b41ee69b824f29cc8b6795444246f871e4ab2379528b34a4d16284e",
172
+ "thumbnails": {
173
+ "x100": "https://cdn.smartlinks.app/..._100x100.png",
174
+ "x200": "https://cdn.smartlinks.app/..._200x200.png",
175
+ "x512": "https://cdn.smartlinks.app/..._512x512.png"
176
+ },
177
+ "id": "7k1cGErrlmQ94J8yDlVj",
178
+ "site": "ChaseAtlantic",
179
+ "cleanName": "Screenshot 2025-09-15 at 15.21"
180
+ }
115
181
  ```
116
182
 
117
183
  ### AI helpers
@@ -1,5 +1,19 @@
1
- import { AssetResponse } from "../types/asset";
1
+ import { Asset, AssetResponse, UploadAssetOptions, ListAssetsOptions, GetAssetOptions, RemoveAssetOptions } from "../types/asset";
2
2
  export declare namespace asset {
3
+ /**
4
+ * Error type for asset uploads
5
+ */
6
+ class AssetUploadError extends Error {
7
+ readonly code: 'FILE_TOO_LARGE' | 'INVALID_TYPE' | 'NETWORK_ERROR' | 'UNAUTHORIZED' | 'QUOTA_EXCEEDED' | 'UNKNOWN';
8
+ readonly details?: Record<string, any> | undefined;
9
+ constructor(message: string, code: 'FILE_TOO_LARGE' | 'INVALID_TYPE' | 'NETWORK_ERROR' | 'UNAUTHORIZED' | 'QUOTA_EXCEEDED' | 'UNKNOWN', details?: Record<string, any> | undefined);
10
+ }
11
+ /**
12
+ * Upload an asset file
13
+ * @returns The uploaded asset with its public URL
14
+ * @throws AssetUploadError if upload fails
15
+ */
16
+ function upload(options: UploadAssetOptions): Promise<Asset>;
3
17
  function getForCollection(collectionId: string, assetId: string): Promise<AssetResponse>;
4
18
  function listForCollection(collectionId: string): Promise<AssetResponse[]>;
5
19
  function getForProduct(collectionId: string, productId: string, assetId: string): Promise<AssetResponse>;
@@ -8,6 +22,7 @@ export declare namespace asset {
8
22
  function listForProof(collectionId: string, productId: string, proofId: string, appId?: string): Promise<AssetResponse[]>;
9
23
  /**
10
24
  * Uploads an asset file to a proof, with optional extraData as JSON.
25
+ * @deprecated Use `asset.upload(options)` instead.
11
26
  * Supports progress reporting via onProgress callback (browser only).
12
27
  * @param collectionId - The collection ID
13
28
  * @param productId - The product ID
@@ -18,4 +33,16 @@ export declare namespace asset {
18
33
  * @returns Promise resolving to an AssetResponse object
19
34
  */
20
35
  function uploadAsset(collectionId: string, productId: string, proofId: string, file: File, extraData?: Record<string, any>, onProgress?: (percent: number) => void): Promise<AssetResponse>;
36
+ /**
37
+ * List assets for a given scope
38
+ */
39
+ function list(options: ListAssetsOptions): Promise<Asset[]>;
40
+ /**
41
+ * Get an asset by id within a scope (public)
42
+ */
43
+ function get(options: GetAssetOptions): Promise<Asset>;
44
+ /**
45
+ * Remove an asset by id within a scope (admin)
46
+ */
47
+ function remove(options: RemoveAssetOptions): Promise<void>;
21
48
  }
package/dist/api/asset.js CHANGED
@@ -1,6 +1,114 @@
1
- import { request, getApiHeaders } from "../http";
1
+ import { request, post, del, getApiHeaders } from "../http";
2
2
  export var asset;
3
3
  (function (asset) {
4
+ /**
5
+ * Error type for asset uploads
6
+ */
7
+ class AssetUploadError extends Error {
8
+ constructor(message, code, details) {
9
+ super(message);
10
+ this.code = code;
11
+ this.details = details;
12
+ this.name = 'AssetUploadError';
13
+ }
14
+ }
15
+ asset.AssetUploadError = AssetUploadError;
16
+ function buildScopeBase(scope) {
17
+ if (scope.type === 'collection') {
18
+ return `/public/collection/${encodeURIComponent(scope.collectionId)}`;
19
+ }
20
+ if (scope.type === 'product') {
21
+ return `/public/collection/${encodeURIComponent(scope.collectionId)}/product/${encodeURIComponent(scope.productId)}`;
22
+ }
23
+ // proof
24
+ return `/public/collection/${encodeURIComponent(scope.collectionId)}/product/${encodeURIComponent(scope.productId)}/proof/${encodeURIComponent(scope.proofId)}`;
25
+ }
26
+ /**
27
+ * Upload an asset file
28
+ * @returns The uploaded asset with its public URL
29
+ * @throws AssetUploadError if upload fails
30
+ */
31
+ async function upload(options) {
32
+ const base = buildScopeBase(options.scope);
33
+ let path = `${base}/asset`;
34
+ if (options.appId) {
35
+ const qp = new URLSearchParams({ appId: options.appId });
36
+ path += `?${qp.toString()}`;
37
+ }
38
+ const formData = new FormData();
39
+ formData.append("file", options.file);
40
+ if (options.name)
41
+ formData.append("name", options.name);
42
+ if (options.metadata)
43
+ formData.append("metadata", JSON.stringify(options.metadata));
44
+ // If progress callback provided, use XHR for progress events (browser-only)
45
+ if (options.onProgress && typeof window !== "undefined") {
46
+ const url = (typeof window !== "undefined" && window.SMARTLINKS_API_BASEURL)
47
+ ? window.SMARTLINKS_API_BASEURL + path
48
+ : path;
49
+ const headers = getApiHeaders ? getApiHeaders() : {};
50
+ return new Promise((resolve, reject) => {
51
+ const xhr = new XMLHttpRequest();
52
+ xhr.open("POST", url);
53
+ for (const [key, value] of Object.entries(headers))
54
+ xhr.setRequestHeader(key, value);
55
+ xhr.upload.onprogress = (event) => {
56
+ if (options.onProgress && event.lengthComputable) {
57
+ const percent = Math.round((event.loaded / event.total) * 100);
58
+ options.onProgress(percent);
59
+ }
60
+ };
61
+ xhr.onload = () => {
62
+ const status = xhr.status;
63
+ const text = xhr.responseText;
64
+ if (status >= 200 && status < 300) {
65
+ try {
66
+ resolve(JSON.parse(text));
67
+ }
68
+ catch (e) {
69
+ reject(new AssetUploadError("Failed to parse server response", 'UNKNOWN'));
70
+ }
71
+ }
72
+ else {
73
+ try {
74
+ const errBody = JSON.parse(text);
75
+ const code = mapStatusToUploadErrorCode(status, errBody === null || errBody === void 0 ? void 0 : errBody.code);
76
+ reject(new AssetUploadError((errBody === null || errBody === void 0 ? void 0 : errBody.message) || `Upload failed (${status})`, code, errBody));
77
+ }
78
+ catch (_a) {
79
+ const code = mapStatusToUploadErrorCode(status);
80
+ reject(new AssetUploadError(`Asset upload failed with status ${status}`, code));
81
+ }
82
+ }
83
+ };
84
+ xhr.onerror = () => reject(new AssetUploadError("Network error during asset upload", 'NETWORK_ERROR'));
85
+ xhr.send(formData);
86
+ });
87
+ }
88
+ // Otherwise use fetch helper
89
+ try {
90
+ return await post(path, formData);
91
+ }
92
+ catch (e) {
93
+ // Map generic Error to AssetUploadError
94
+ const msg = (e === null || e === void 0 ? void 0 : e.message) || 'Upload failed';
95
+ throw new AssetUploadError(msg, 'UNKNOWN');
96
+ }
97
+ }
98
+ asset.upload = upload;
99
+ function mapStatusToUploadErrorCode(status, serverCode) {
100
+ if (status === 401 || status === 403)
101
+ return 'UNAUTHORIZED';
102
+ if (status === 413)
103
+ return 'FILE_TOO_LARGE';
104
+ if (status === 415)
105
+ return 'INVALID_TYPE';
106
+ if (status === 429)
107
+ return 'QUOTA_EXCEEDED';
108
+ if (status === 0)
109
+ return 'NETWORK_ERROR';
110
+ return 'UNKNOWN';
111
+ }
4
112
  // Collection-level
5
113
  async function getForCollection(collectionId, assetId) {
6
114
  const path = `/public/collection/${encodeURIComponent(collectionId)}/asset/${encodeURIComponent(assetId)}`;
@@ -39,6 +147,7 @@ export var asset;
39
147
  asset.listForProof = listForProof;
40
148
  /**
41
149
  * Uploads an asset file to a proof, with optional extraData as JSON.
150
+ * @deprecated Use `asset.upload(options)` instead.
42
151
  * Supports progress reporting via onProgress callback (browser only).
43
152
  * @param collectionId - The collection ID
44
153
  * @param productId - The product ID
@@ -49,52 +158,60 @@ export var asset;
49
158
  * @returns Promise resolving to an AssetResponse object
50
159
  */
51
160
  async function uploadAsset(collectionId, productId, proofId, file, extraData, onProgress) {
52
- const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/proof/${encodeURIComponent(proofId)}/asset`;
53
- const url = (typeof window !== "undefined" && window.SMARTLINKS_API_BASEURL)
54
- ? window.SMARTLINKS_API_BASEURL + path
55
- : path; // fallback for SSR or Node
56
- const formData = new FormData();
57
- formData.append("file", file);
58
- if (extraData) {
59
- formData.append("extraData", JSON.stringify(extraData));
60
- }
61
- // Use getApiHeaders from http module
62
- const headers = getApiHeaders ? getApiHeaders() : {};
63
- return new Promise((resolve, reject) => {
64
- const xhr = new XMLHttpRequest();
65
- xhr.open("POST", url);
66
- // Set headers for API key and bearer token if available
67
- for (const [key, value] of Object.entries(headers)) {
68
- xhr.setRequestHeader(key, value);
69
- }
70
- xhr.upload.onprogress = (event) => {
71
- if (onProgress && event.lengthComputable) {
72
- const percent = Math.round((event.loaded / event.total) * 100);
73
- onProgress(percent);
74
- }
75
- };
76
- xhr.onload = () => {
77
- if (xhr.status >= 200 && xhr.status < 300) {
78
- try {
79
- resolve(JSON.parse(xhr.responseText));
80
- }
81
- catch (e) {
82
- reject(new Error("Failed to parse server response"));
83
- }
84
- }
85
- else {
86
- try {
87
- const errBody = JSON.parse(xhr.responseText);
88
- reject(new Error(`Error ${errBody.code}: ${errBody.message}`));
89
- }
90
- catch (_a) {
91
- reject(new Error(`Asset upload failed with status ${xhr.status}`));
92
- }
93
- }
94
- };
95
- xhr.onerror = () => reject(new Error("Network error during asset upload"));
96
- xhr.send(formData);
161
+ // Route through new upload API for backward compatibility
162
+ const res = await upload({
163
+ file,
164
+ name: file === null || file === void 0 ? void 0 : file.name,
165
+ metadata: extraData,
166
+ onProgress,
167
+ scope: { type: 'proof', collectionId, productId, proofId },
97
168
  });
169
+ return res;
98
170
  }
99
171
  asset.uploadAsset = uploadAsset;
172
+ /**
173
+ * List assets for a given scope
174
+ */
175
+ async function list(options) {
176
+ const base = buildScopeBase(options.scope);
177
+ const params = new URLSearchParams();
178
+ if (options.appId)
179
+ params.set('appId', options.appId);
180
+ if (options.mimeTypePrefix)
181
+ params.set('mimeTypePrefix', options.mimeTypePrefix);
182
+ if (typeof options.limit === 'number')
183
+ params.set('limit', String(options.limit));
184
+ if (typeof options.offset === 'number')
185
+ params.set('offset', String(options.offset));
186
+ const path = `${base}/asset${params.toString() ? `?${params}` : ''}`;
187
+ return request(path);
188
+ }
189
+ asset.list = list;
190
+ /**
191
+ * Get an asset by id within a scope (public)
192
+ */
193
+ async function get(options) {
194
+ const base = buildScopeBase(options.scope);
195
+ const path = `${base}/asset/${encodeURIComponent(options.assetId)}`;
196
+ return request(path);
197
+ }
198
+ asset.get = get;
199
+ /**
200
+ * Remove an asset by id within a scope (admin)
201
+ */
202
+ async function remove(options) {
203
+ const scope = options.scope;
204
+ let path;
205
+ if (scope.type === 'collection') {
206
+ path = `/admin/collection/${encodeURIComponent(scope.collectionId)}/asset/${encodeURIComponent(options.assetId)}`;
207
+ }
208
+ else if (scope.type === 'product') {
209
+ path = `/admin/collection/${encodeURIComponent(scope.collectionId)}/product/${encodeURIComponent(scope.productId)}/asset/${encodeURIComponent(options.assetId)}`;
210
+ }
211
+ else {
212
+ path = `/admin/collection/${encodeURIComponent(scope.collectionId)}/product/${encodeURIComponent(scope.productId)}/proof/${encodeURIComponent(scope.proofId)}/asset/${encodeURIComponent(options.assetId)}`;
213
+ }
214
+ return del(path);
215
+ }
216
+ asset.remove = remove;
100
217
  })(asset || (asset = {}));
@@ -1,8 +1,142 @@
1
+ /**
2
+ * Response from any asset upload or retrieval operation
3
+ */
1
4
  /**
2
5
  * Represents an Asset object.
6
+ *
7
+ * Example server response shape:
8
+ * @example
9
+ * {
10
+ * "name": "Screenshot 2025-09-15 at 15.21.14",
11
+ * "assetType": "Image",
12
+ * "type": "png",
13
+ * "collectionId": "myCollection",
14
+ * "url": "https://cdn.smartlinks.app/s25-09-15%20at14537.png",
15
+ * "createdAt": "2005-10-10T23:15:03",
16
+ * "hash": "fb98140a6b41ee69b824f29cc8b6795444246f871e4ab2379528b34a4d16284e",
17
+ * "thumbnails": {
18
+ * "x100": "https://cdn.smartlinks.app/sit2F..._100x100.png",
19
+ * "x200": "https://cdn.smartlinks.app/sit2F..._200x200.png",
20
+ * "x512": "https://cdn.smartlinks.app/sit2F..._512x512.png"
21
+ * },
22
+ * "id": "7k1cGErrlmQ94J8yDlVj",
23
+ * "site": "ChaseAtlantic",
24
+ * "cleanName": "Screenshot 2025-09-15 at 15.21"
25
+ * }
3
26
  */
4
- export interface AssetResponse {
27
+ export interface Asset {
28
+ /** Unique identifier for the asset */
5
29
  id: string;
6
- name: string;
30
+ /** The public URL to access the asset */
7
31
  url: string;
32
+ /** Original filename */
33
+ name: string;
34
+ /** MIME type (e.g., 'image/jpeg', 'video/mp4') */
35
+ mimeType?: string;
36
+ /** File size in bytes */
37
+ size?: number;
38
+ /** When the asset was uploaded */
39
+ createdAt?: string;
40
+ /** Any custom metadata attached during upload */
41
+ metadata?: Record<string, any>;
42
+ /** Optional: broader classification like 'Image' or 'Video' */
43
+ assetType?: string;
44
+ /** Optional: file extension/type shorthand (e.g., 'png') */
45
+ type?: string;
46
+ /** Optional: owning collection identifier */
47
+ collectionId?: string;
48
+ /** Optional: content hash */
49
+ hash?: string;
50
+ /** Optional: CDN thumbnail URLs */
51
+ thumbnails?: {
52
+ x100?: string;
53
+ x200?: string;
54
+ x512?: string;
55
+ [key: string]: string | undefined;
56
+ };
57
+ /** Optional: site identifier alias */
58
+ site?: string;
59
+ /** Optional: prettified name */
60
+ cleanName?: string;
61
+ }
62
+ export type AssetResponse = Asset;
63
+ export interface UploadAssetOptions {
64
+ /** The file to upload (from input[type="file"] or drag-drop) */
65
+ file: File;
66
+ /** Where to attach the asset */
67
+ scope: {
68
+ type: 'collection';
69
+ collectionId: string;
70
+ } | {
71
+ type: 'product';
72
+ collectionId: string;
73
+ productId: string;
74
+ } | {
75
+ type: 'proof';
76
+ collectionId: string;
77
+ productId: string;
78
+ proofId: string;
79
+ };
80
+ /** Optional: Custom filename (defaults to file.name) */
81
+ name?: string;
82
+ /** Optional: Custom metadata to store with the asset */
83
+ metadata?: Record<string, any>;
84
+ /** Optional: Progress callback (0-100) */
85
+ onProgress?: (percent: number) => void;
86
+ /** Optional: App ID for scoping to a specific microapp */
87
+ appId?: string;
88
+ }
89
+ export interface ListAssetsOptions {
90
+ scope: {
91
+ type: 'collection';
92
+ collectionId: string;
93
+ } | {
94
+ type: 'product';
95
+ collectionId: string;
96
+ productId: string;
97
+ } | {
98
+ type: 'proof';
99
+ collectionId: string;
100
+ productId: string;
101
+ proofId: string;
102
+ };
103
+ /** Filter by app ID */
104
+ appId?: string;
105
+ /** Filter by MIME type prefix (e.g., 'image/', 'video/') */
106
+ mimeTypePrefix?: string;
107
+ /** Pagination */
108
+ limit?: number;
109
+ offset?: number;
110
+ }
111
+ export interface GetAssetOptions {
112
+ assetId: string;
113
+ scope: {
114
+ type: 'collection';
115
+ collectionId: string;
116
+ } | {
117
+ type: 'product';
118
+ collectionId: string;
119
+ productId: string;
120
+ } | {
121
+ type: 'proof';
122
+ collectionId: string;
123
+ productId: string;
124
+ proofId: string;
125
+ };
126
+ }
127
+ export interface RemoveAssetOptions {
128
+ assetId: string;
129
+ scope: {
130
+ type: 'collection';
131
+ collectionId: string;
132
+ } | {
133
+ type: 'product';
134
+ collectionId: string;
135
+ productId: string;
136
+ } | {
137
+ type: 'proof';
138
+ collectionId: string;
139
+ productId: string;
140
+ proofId: string;
141
+ };
8
142
  }
@@ -3,7 +3,7 @@ export interface TemplateBase {
3
3
  collectionId: string;
4
4
  name: string;
5
5
  description?: string;
6
- type: string;
6
+ type: 'pdf' | 'email' | 'multichannel' | 'label';
7
7
  resizeMode?: string;
8
8
  pdf?: {
9
9
  base: {
@@ -11,6 +11,26 @@ export interface TemplateBase {
11
11
  };
12
12
  orientation: 'portrait' | 'landscape';
13
13
  };
14
+ channels?: {
15
+ email?: {
16
+ subject: string;
17
+ body: string;
18
+ };
19
+ sms?: {
20
+ body: string;
21
+ };
22
+ push: {
23
+ title: string;
24
+ body: string;
25
+ url?: string;
26
+ iconUrl?: string;
27
+ };
28
+ wallet?: {
29
+ header: string;
30
+ body: string;
31
+ imageUri?: string;
32
+ };
33
+ };
14
34
  subject?: string;
15
35
  body?: string;
16
36
  css?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",