@proveanything/smartlinks 1.3.33 → 1.3.34
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/appRecord.js +4 -4
- package/dist/api/asset.d.ts +29 -1
- package/dist/api/asset.js +52 -0
- package/dist/docs/API_SUMMARY.md +39 -7
- package/dist/types/ai.d.ts +5 -1
- package/dist/types/asset.d.ts +30 -0
- package/docs/API_SUMMARY.md +39 -7
- package/package.json +1 -1
package/dist/api/appRecord.js
CHANGED
|
@@ -4,25 +4,25 @@ export var appRecord;
|
|
|
4
4
|
(function (appRecord) {
|
|
5
5
|
// Get app record (admin only)
|
|
6
6
|
async function get(collectionId, appId) {
|
|
7
|
-
const path = `/
|
|
7
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
8
8
|
return request(path);
|
|
9
9
|
}
|
|
10
10
|
appRecord.get = get;
|
|
11
11
|
// Create app record (admin only)
|
|
12
12
|
async function create(collectionId, appId, data) {
|
|
13
|
-
const path = `/
|
|
13
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
14
14
|
return post(path, data);
|
|
15
15
|
}
|
|
16
16
|
appRecord.create = create;
|
|
17
17
|
// Update app record (admin only)
|
|
18
18
|
async function update(collectionId, appId, data) {
|
|
19
|
-
const path = `/
|
|
19
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
20
20
|
return put(path, data);
|
|
21
21
|
}
|
|
22
22
|
appRecord.update = update;
|
|
23
23
|
// Delete app record (admin only)
|
|
24
24
|
async function remove(collectionId, appId) {
|
|
25
|
-
const path = `/
|
|
25
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}`;
|
|
26
26
|
return del(path);
|
|
27
27
|
}
|
|
28
28
|
appRecord.remove = remove;
|
package/dist/api/asset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Asset, AssetResponse, UploadAssetOptions, ListAssetsOptions, GetAssetOptions, RemoveAssetOptions } from "../types/asset";
|
|
1
|
+
import { Asset, AssetResponse, UploadAssetOptions, UploadFromUrlOptions, ListAssetsOptions, GetAssetOptions, RemoveAssetOptions } from "../types/asset";
|
|
2
2
|
export declare namespace asset {
|
|
3
3
|
/**
|
|
4
4
|
* Error type for asset uploads
|
|
@@ -14,6 +14,34 @@ export declare namespace asset {
|
|
|
14
14
|
* @throws AssetUploadError if upload fails
|
|
15
15
|
*/
|
|
16
16
|
function upload(options: UploadAssetOptions): Promise<Asset>;
|
|
17
|
+
/**
|
|
18
|
+
* Upload an asset from a URL
|
|
19
|
+
* The server will fetch the file from the provided URL and store it permanently in your CDN.
|
|
20
|
+
* This solves CORS issues and ensures files are permanently stored.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Upload options including URL and scope
|
|
23
|
+
* @returns The uploaded asset with its CDN URL
|
|
24
|
+
* @throws AssetUploadError if upload fails
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Upload AI-generated image
|
|
29
|
+
* const asset = await asset.uploadFromUrl({
|
|
30
|
+
* url: 'https://oaidalleapiprodscus.blob.core.windows.net/...',
|
|
31
|
+
* scope: { type: 'collection', collectionId: 'my-collection' },
|
|
32
|
+
* metadata: { name: 'AI Generated Image', app: 'gallery' }
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Upload stock photo
|
|
36
|
+
* const asset = await asset.uploadFromUrl({
|
|
37
|
+
* url: 'https://images.unsplash.com/photo-...',
|
|
38
|
+
* scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' },
|
|
39
|
+
* folder: 'images',
|
|
40
|
+
* metadata: { name: 'Product Photo' }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function uploadFromUrl(options: UploadFromUrlOptions): Promise<Asset>;
|
|
17
45
|
function getForCollection(collectionId: string, assetId: string): Promise<AssetResponse>;
|
|
18
46
|
function listForCollection(collectionId: string): Promise<AssetResponse[]>;
|
|
19
47
|
function getForProduct(collectionId: string, productId: string, assetId: string): Promise<AssetResponse>;
|
package/dist/api/asset.js
CHANGED
|
@@ -107,6 +107,58 @@ export var asset;
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
asset.upload = upload;
|
|
110
|
+
/**
|
|
111
|
+
* Upload an asset from a URL
|
|
112
|
+
* The server will fetch the file from the provided URL and store it permanently in your CDN.
|
|
113
|
+
* This solves CORS issues and ensures files are permanently stored.
|
|
114
|
+
*
|
|
115
|
+
* @param options - Upload options including URL and scope
|
|
116
|
+
* @returns The uploaded asset with its CDN URL
|
|
117
|
+
* @throws AssetUploadError if upload fails
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // Upload AI-generated image
|
|
122
|
+
* const asset = await asset.uploadFromUrl({
|
|
123
|
+
* url: 'https://oaidalleapiprodscus.blob.core.windows.net/...',
|
|
124
|
+
* scope: { type: 'collection', collectionId: 'my-collection' },
|
|
125
|
+
* metadata: { name: 'AI Generated Image', app: 'gallery' }
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Upload stock photo
|
|
129
|
+
* const asset = await asset.uploadFromUrl({
|
|
130
|
+
* url: 'https://images.unsplash.com/photo-...',
|
|
131
|
+
* scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' },
|
|
132
|
+
* folder: 'images',
|
|
133
|
+
* metadata: { name: 'Product Photo' }
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
async function uploadFromUrl(options) {
|
|
138
|
+
const base = buildScopeBase(options.scope, !!options.admin);
|
|
139
|
+
let path = `${base}/asset`;
|
|
140
|
+
if (options.appId) {
|
|
141
|
+
const qp = new URLSearchParams({ appId: options.appId });
|
|
142
|
+
path += `?${qp.toString()}`;
|
|
143
|
+
}
|
|
144
|
+
const body = {
|
|
145
|
+
url: options.url
|
|
146
|
+
};
|
|
147
|
+
if (options.folder) {
|
|
148
|
+
body.folder = options.folder;
|
|
149
|
+
}
|
|
150
|
+
if (options.metadata) {
|
|
151
|
+
body.extraData = options.metadata;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
return await post(path, body);
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
const msg = (e === null || e === void 0 ? void 0 : e.message) || 'URL upload failed';
|
|
158
|
+
throw new AssetUploadError(msg, 'UNKNOWN');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
asset.uploadFromUrl = uploadFromUrl;
|
|
110
162
|
function mapStatusToUploadErrorCode(status, serverCode) {
|
|
111
163
|
if (status === 401 || status === 403)
|
|
112
164
|
return 'UNAUTHORIZED';
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.34 | Generated: 2026-02-16T09:46:01.466Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -29,6 +29,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
29
29
|
- **batch** - Group products into batches; manage serial number ranges and lookups.
|
|
30
30
|
- **crate** - Organize products in containers/crates for logistics and grouping.
|
|
31
31
|
- **form** - Build and manage dynamic forms used by apps and workflows.
|
|
32
|
+
- **appRecord** - Store and retrieve application-level records tied to a collection.
|
|
32
33
|
- **appConfiguration** - Read/write app configuration and scoped data (collection/product/proof).
|
|
33
34
|
|
|
34
35
|
— Identity & Access —
|
|
@@ -753,6 +754,9 @@ interface AIGenerateImageRequest {
|
|
|
753
754
|
prompt: string
|
|
754
755
|
provider?: string
|
|
755
756
|
model?: string
|
|
757
|
+
* Requested image size.
|
|
758
|
+
* OpenAI supported values: '1024x1024', '1024x1792', '1792x1024'
|
|
759
|
+
* Other providers may support different sizes.
|
|
756
760
|
size?: string
|
|
757
761
|
[key: string]: any
|
|
758
762
|
}
|
|
@@ -940,6 +944,21 @@ interface UploadAssetOptions {
|
|
|
940
944
|
}
|
|
941
945
|
```
|
|
942
946
|
|
|
947
|
+
**UploadFromUrlOptions** (interface)
|
|
948
|
+
```typescript
|
|
949
|
+
interface UploadFromUrlOptions {
|
|
950
|
+
url: string
|
|
951
|
+
scope:
|
|
952
|
+
| { type: 'collection'; collectionId: string }
|
|
953
|
+
| { type: 'product'; collectionId: string; productId: string }
|
|
954
|
+
| { type: 'proof'; collectionId: string; productId: string; proofId: string }
|
|
955
|
+
folder?: 'images' | 'videos' | 'documents'
|
|
956
|
+
metadata?: Record<string, any>
|
|
957
|
+
appId?: string
|
|
958
|
+
admin?: boolean
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
943
962
|
**ListAssetsOptions** (interface)
|
|
944
963
|
```typescript
|
|
945
964
|
interface ListAssetsOptions {
|
|
@@ -3935,38 +3954,51 @@ Post a chat message to the AI (admin or public)
|
|
|
3935
3954
|
options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
|
|
3936
3955
|
Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This solves N+1 query problems by fetching manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getWidgets(collectionId); // Returns: [{ appId, manifestUrl, manifest, bundleSource, bundleCss }, ...] // Convert bundle source to dynamic imports for (const app of apps) { const blob = new Blob([app.bundleSource], { type: 'application/javascript' }); const blobUrl = URL.createObjectURL(blob); const widgetModule = await import(blobUrl); // Inject CSS if present if (app.bundleCss) { const styleTag = document.createElement('style'); styleTag.textContent = app.bundleCss; document.head.appendChild(styleTag); } } // Force refresh all widgets const { apps } = await Api.AppConfiguration.getWidgets(collectionId, { force: true }); ```
|
|
3937
3956
|
|
|
3957
|
+
### appRecord
|
|
3958
|
+
|
|
3959
|
+
**get**(collectionId: string, appId: string) → `Promise<any>`
|
|
3960
|
+
|
|
3961
|
+
**create**(collectionId: string, appId: string, data: any) → `Promise<any>`
|
|
3962
|
+
|
|
3963
|
+
**update**(collectionId: string, appId: string, data: any) → `Promise<any>`
|
|
3964
|
+
|
|
3965
|
+
**remove**(collectionId: string, appId: string) → `Promise<void>`
|
|
3966
|
+
|
|
3938
3967
|
### asset
|
|
3939
3968
|
|
|
3940
3969
|
**upload**(options: UploadAssetOptions) → `Promise<Asset>`
|
|
3941
3970
|
Upload an asset file
|
|
3942
3971
|
|
|
3972
|
+
**uploadFromUrl**(options: UploadFromUrlOptions) → `Promise<Asset>`
|
|
3973
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3974
|
+
|
|
3943
3975
|
**getForCollection**(collectionId: string,
|
|
3944
3976
|
assetId: string) → `Promise<AssetResponse>`
|
|
3945
|
-
Upload an asset file
|
|
3977
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3946
3978
|
|
|
3947
3979
|
**listForCollection**(collectionId: string) → `Promise<AssetResponse[]>`
|
|
3948
|
-
Upload an asset file
|
|
3980
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3949
3981
|
|
|
3950
3982
|
**getForProduct**(collectionId: string,
|
|
3951
3983
|
productId: string,
|
|
3952
3984
|
assetId: string) → `Promise<AssetResponse>`
|
|
3953
|
-
Upload an asset file
|
|
3985
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3954
3986
|
|
|
3955
3987
|
**listForProduct**(collectionId: string,
|
|
3956
3988
|
productId: string) → `Promise<AssetResponse[]>`
|
|
3957
|
-
Upload an asset file
|
|
3989
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3958
3990
|
|
|
3959
3991
|
**getForProof**(collectionId: string,
|
|
3960
3992
|
productId: string,
|
|
3961
3993
|
proofId: string,
|
|
3962
3994
|
assetId: string) → `Promise<AssetResponse>`
|
|
3963
|
-
Upload an asset file
|
|
3995
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3964
3996
|
|
|
3965
3997
|
**listForProof**(collectionId: string,
|
|
3966
3998
|
productId: string,
|
|
3967
3999
|
proofId: string,
|
|
3968
4000
|
appId?: string) → `Promise<AssetResponse[]>`
|
|
3969
|
-
Upload an asset file
|
|
4001
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3970
4002
|
|
|
3971
4003
|
**uploadAsset**(collectionId: string,
|
|
3972
4004
|
productId: string,
|
package/dist/types/ai.d.ts
CHANGED
|
@@ -348,7 +348,11 @@ export interface AIGenerateImageRequest {
|
|
|
348
348
|
provider?: string;
|
|
349
349
|
/** Optional model name to use for image generation */
|
|
350
350
|
model?: string;
|
|
351
|
-
/**
|
|
351
|
+
/**
|
|
352
|
+
* Requested image size.
|
|
353
|
+
* OpenAI supported values: '1024x1024', '1024x1792', '1792x1024'
|
|
354
|
+
* Other providers may support different sizes.
|
|
355
|
+
*/
|
|
352
356
|
size?: string;
|
|
353
357
|
/** Additional provider/model-specific options */
|
|
354
358
|
[key: string]: any;
|
package/dist/types/asset.d.ts
CHANGED
|
@@ -88,6 +88,36 @@ export interface UploadAssetOptions {
|
|
|
88
88
|
/** Optional: Upload via admin route instead of public */
|
|
89
89
|
admin?: boolean;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Options for uploading an asset from a URL
|
|
93
|
+
* The server will fetch the file from the URL and store it in your CDN
|
|
94
|
+
*/
|
|
95
|
+
export interface UploadFromUrlOptions {
|
|
96
|
+
/** The URL of the file to fetch and upload */
|
|
97
|
+
url: string;
|
|
98
|
+
/** Where to attach the asset */
|
|
99
|
+
scope: {
|
|
100
|
+
type: 'collection';
|
|
101
|
+
collectionId: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: 'product';
|
|
104
|
+
collectionId: string;
|
|
105
|
+
productId: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'proof';
|
|
108
|
+
collectionId: string;
|
|
109
|
+
productId: string;
|
|
110
|
+
proofId: string;
|
|
111
|
+
};
|
|
112
|
+
/** Optional: Storage folder ('images', 'videos', 'documents') */
|
|
113
|
+
folder?: 'images' | 'videos' | 'documents';
|
|
114
|
+
/** Optional: Custom metadata to store with the asset */
|
|
115
|
+
metadata?: Record<string, any>;
|
|
116
|
+
/** Optional: App ID for scoping to a specific microapp */
|
|
117
|
+
appId?: string;
|
|
118
|
+
/** Optional: Upload via admin route instead of public */
|
|
119
|
+
admin?: boolean;
|
|
120
|
+
}
|
|
91
121
|
export interface ListAssetsOptions {
|
|
92
122
|
scope: {
|
|
93
123
|
type: 'collection';
|
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.34 | Generated: 2026-02-16T09:46:01.466Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -29,6 +29,7 @@ The Smartlinks SDK is organized into the following namespaces:
|
|
|
29
29
|
- **batch** - Group products into batches; manage serial number ranges and lookups.
|
|
30
30
|
- **crate** - Organize products in containers/crates for logistics and grouping.
|
|
31
31
|
- **form** - Build and manage dynamic forms used by apps and workflows.
|
|
32
|
+
- **appRecord** - Store and retrieve application-level records tied to a collection.
|
|
32
33
|
- **appConfiguration** - Read/write app configuration and scoped data (collection/product/proof).
|
|
33
34
|
|
|
34
35
|
— Identity & Access —
|
|
@@ -753,6 +754,9 @@ interface AIGenerateImageRequest {
|
|
|
753
754
|
prompt: string
|
|
754
755
|
provider?: string
|
|
755
756
|
model?: string
|
|
757
|
+
* Requested image size.
|
|
758
|
+
* OpenAI supported values: '1024x1024', '1024x1792', '1792x1024'
|
|
759
|
+
* Other providers may support different sizes.
|
|
756
760
|
size?: string
|
|
757
761
|
[key: string]: any
|
|
758
762
|
}
|
|
@@ -940,6 +944,21 @@ interface UploadAssetOptions {
|
|
|
940
944
|
}
|
|
941
945
|
```
|
|
942
946
|
|
|
947
|
+
**UploadFromUrlOptions** (interface)
|
|
948
|
+
```typescript
|
|
949
|
+
interface UploadFromUrlOptions {
|
|
950
|
+
url: string
|
|
951
|
+
scope:
|
|
952
|
+
| { type: 'collection'; collectionId: string }
|
|
953
|
+
| { type: 'product'; collectionId: string; productId: string }
|
|
954
|
+
| { type: 'proof'; collectionId: string; productId: string; proofId: string }
|
|
955
|
+
folder?: 'images' | 'videos' | 'documents'
|
|
956
|
+
metadata?: Record<string, any>
|
|
957
|
+
appId?: string
|
|
958
|
+
admin?: boolean
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
943
962
|
**ListAssetsOptions** (interface)
|
|
944
963
|
```typescript
|
|
945
964
|
interface ListAssetsOptions {
|
|
@@ -3935,38 +3954,51 @@ Post a chat message to the AI (admin or public)
|
|
|
3935
3954
|
options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
|
|
3936
3955
|
Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This solves N+1 query problems by fetching manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getWidgets(collectionId); // Returns: [{ appId, manifestUrl, manifest, bundleSource, bundleCss }, ...] // Convert bundle source to dynamic imports for (const app of apps) { const blob = new Blob([app.bundleSource], { type: 'application/javascript' }); const blobUrl = URL.createObjectURL(blob); const widgetModule = await import(blobUrl); // Inject CSS if present if (app.bundleCss) { const styleTag = document.createElement('style'); styleTag.textContent = app.bundleCss; document.head.appendChild(styleTag); } } // Force refresh all widgets const { apps } = await Api.AppConfiguration.getWidgets(collectionId, { force: true }); ```
|
|
3937
3956
|
|
|
3957
|
+
### appRecord
|
|
3958
|
+
|
|
3959
|
+
**get**(collectionId: string, appId: string) → `Promise<any>`
|
|
3960
|
+
|
|
3961
|
+
**create**(collectionId: string, appId: string, data: any) → `Promise<any>`
|
|
3962
|
+
|
|
3963
|
+
**update**(collectionId: string, appId: string, data: any) → `Promise<any>`
|
|
3964
|
+
|
|
3965
|
+
**remove**(collectionId: string, appId: string) → `Promise<void>`
|
|
3966
|
+
|
|
3938
3967
|
### asset
|
|
3939
3968
|
|
|
3940
3969
|
**upload**(options: UploadAssetOptions) → `Promise<Asset>`
|
|
3941
3970
|
Upload an asset file
|
|
3942
3971
|
|
|
3972
|
+
**uploadFromUrl**(options: UploadFromUrlOptions) → `Promise<Asset>`
|
|
3973
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3974
|
+
|
|
3943
3975
|
**getForCollection**(collectionId: string,
|
|
3944
3976
|
assetId: string) → `Promise<AssetResponse>`
|
|
3945
|
-
Upload an asset file
|
|
3977
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3946
3978
|
|
|
3947
3979
|
**listForCollection**(collectionId: string) → `Promise<AssetResponse[]>`
|
|
3948
|
-
Upload an asset file
|
|
3980
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3949
3981
|
|
|
3950
3982
|
**getForProduct**(collectionId: string,
|
|
3951
3983
|
productId: string,
|
|
3952
3984
|
assetId: string) → `Promise<AssetResponse>`
|
|
3953
|
-
Upload an asset file
|
|
3985
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3954
3986
|
|
|
3955
3987
|
**listForProduct**(collectionId: string,
|
|
3956
3988
|
productId: string) → `Promise<AssetResponse[]>`
|
|
3957
|
-
Upload an asset file
|
|
3989
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3958
3990
|
|
|
3959
3991
|
**getForProof**(collectionId: string,
|
|
3960
3992
|
productId: string,
|
|
3961
3993
|
proofId: string,
|
|
3962
3994
|
assetId: string) → `Promise<AssetResponse>`
|
|
3963
|
-
Upload an asset file
|
|
3995
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3964
3996
|
|
|
3965
3997
|
**listForProof**(collectionId: string,
|
|
3966
3998
|
productId: string,
|
|
3967
3999
|
proofId: string,
|
|
3968
4000
|
appId?: string) → `Promise<AssetResponse[]>`
|
|
3969
|
-
Upload an asset file
|
|
4001
|
+
Upload an asset from a URL The server will fetch the file from the provided URL and store it permanently in your CDN. This solves CORS issues and ensures files are permanently stored. ```typescript // Upload AI-generated image const asset = await asset.uploadFromUrl({ url: 'https://oaidalleapiprodscus.blob.core.windows.net/...', scope: { type: 'collection', collectionId: 'my-collection' }, metadata: { name: 'AI Generated Image', app: 'gallery' } }); // Upload stock photo const asset = await asset.uploadFromUrl({ url: 'https://images.unsplash.com/photo-...', scope: { type: 'product', collectionId: 'my-collection', productId: 'wine-bottle' }, folder: 'images', metadata: { name: 'Product Photo' } }); ```
|
|
3970
4002
|
|
|
3971
4003
|
**uploadAsset**(collectionId: string,
|
|
3972
4004
|
productId: string,
|