@proveanything/smartlinks 1.3.29 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { AppManifest } from "../types/appManifest";
1
+ import { AppManifest, CollectionWidgetsResponse, GetCollectionWidgetsOptions } from "../types/appManifest";
2
2
  export type AppConfigOptions = {
3
3
  appId: string;
4
4
  collectionId?: string;
@@ -46,4 +46,46 @@ export declare namespace appConfiguration {
46
46
  * ```
47
47
  */
48
48
  function getManifest(manifestUrl: string, force?: boolean): Promise<AppManifest>;
49
+ /**
50
+ * Fetches ALL widget data (manifests + bundle files) for a collection in one call.
51
+ * Returns everything needed to render widgets with zero additional requests.
52
+ *
53
+ * This is the recommended approach as it solves N+1 query problems and fetches
54
+ * manifests, JavaScript bundles, and CSS files in parallel on the server.
55
+ *
56
+ * @param collectionId - The collection ID
57
+ * @param options - Optional settings (force: bypass cache)
58
+ * @returns Promise resolving to collection widgets with manifests and bundle files
59
+ * @throws ErrorResponse if the request fails
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Fetch all widget data for a collection
64
+ * const { apps } = await Api.AppConfiguration.getCollectionWidgets(collectionId);
65
+ * // Returns: [{ appId, manifestUrl, manifest, bundleSource, bundleCss }, ...]
66
+ *
67
+ * // Convert bundle source to dynamic imports
68
+ * for (const app of apps) {
69
+ * const blob = new Blob([app.bundleSource], { type: 'application/javascript' });
70
+ * const blobUrl = URL.createObjectURL(blob);
71
+ * const widgetModule = await import(blobUrl);
72
+ *
73
+ * // Inject CSS if present
74
+ * if (app.bundleCss) {
75
+ * const styleTag = document.createElement('style');
76
+ * styleTag.textContent = app.bundleCss;
77
+ * document.head.appendChild(styleTag);
78
+ * }
79
+ *
80
+ * // Now use widgetModule components
81
+ * }
82
+ *
83
+ * // Force refresh all widgets
84
+ * const { apps: freshApps } = await Api.AppConfiguration.getCollectionWidgets(
85
+ * collectionId,
86
+ * { force: true }
87
+ * );
88
+ * ```
89
+ */
90
+ function getCollectionWidgets(collectionId: string, options?: GetCollectionWidgetsOptions): Promise<CollectionWidgetsResponse>;
49
91
  }
@@ -121,4 +121,53 @@ export var appConfiguration;
121
121
  return request(path);
122
122
  }
123
123
  appConfiguration.getManifest = getManifest;
124
+ /**
125
+ * Fetches ALL widget data (manifests + bundle files) for a collection in one call.
126
+ * Returns everything needed to render widgets with zero additional requests.
127
+ *
128
+ * This is the recommended approach as it solves N+1 query problems and fetches
129
+ * manifests, JavaScript bundles, and CSS files in parallel on the server.
130
+ *
131
+ * @param collectionId - The collection ID
132
+ * @param options - Optional settings (force: bypass cache)
133
+ * @returns Promise resolving to collection widgets with manifests and bundle files
134
+ * @throws ErrorResponse if the request fails
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * // Fetch all widget data for a collection
139
+ * const { apps } = await Api.AppConfiguration.getCollectionWidgets(collectionId);
140
+ * // Returns: [{ appId, manifestUrl, manifest, bundleSource, bundleCss }, ...]
141
+ *
142
+ * // Convert bundle source to dynamic imports
143
+ * for (const app of apps) {
144
+ * const blob = new Blob([app.bundleSource], { type: 'application/javascript' });
145
+ * const blobUrl = URL.createObjectURL(blob);
146
+ * const widgetModule = await import(blobUrl);
147
+ *
148
+ * // Inject CSS if present
149
+ * if (app.bundleCss) {
150
+ * const styleTag = document.createElement('style');
151
+ * styleTag.textContent = app.bundleCss;
152
+ * document.head.appendChild(styleTag);
153
+ * }
154
+ *
155
+ * // Now use widgetModule components
156
+ * }
157
+ *
158
+ * // Force refresh all widgets
159
+ * const { apps: freshApps } = await Api.AppConfiguration.getCollectionWidgets(
160
+ * collectionId,
161
+ * { force: true }
162
+ * );
163
+ * ```
164
+ */
165
+ async function getCollectionWidgets(collectionId, options) {
166
+ let path = `/v1/public/collection/${encodeURIComponent(collectionId)}/widgets`;
167
+ if (options === null || options === void 0 ? void 0 : options.force) {
168
+ path += '?force=true';
169
+ }
170
+ return request(path);
171
+ }
172
+ appConfiguration.getCollectionWidgets = getCollectionWidgets;
124
173
  })(appConfiguration || (appConfiguration = {}));
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.29 | Generated: 2026-02-14T14:15:49.096Z
3
+ Version: 1.3.30 | Generated: 2026-02-14T14:44:14.267Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -873,6 +873,31 @@ interface AppManifest {
873
873
  }
874
874
  ```
875
875
 
876
+ **CollectionWidget** (interface)
877
+ ```typescript
878
+ interface CollectionWidget {
879
+ appId: string;
880
+ manifestUrl: string;
881
+ manifest: AppManifest;
882
+ bundleSource: string;
883
+ bundleCss?: string; // Optional CSS file
884
+ }
885
+ ```
886
+
887
+ **CollectionWidgetsResponse** (interface)
888
+ ```typescript
889
+ interface CollectionWidgetsResponse {
890
+ apps: CollectionWidget[];
891
+ }
892
+ ```
893
+
894
+ **GetCollectionWidgetsOptions** (interface)
895
+ ```typescript
896
+ interface GetCollectionWidgetsOptions {
897
+ force?: boolean; // Bypass cache and fetch fresh data
898
+ }
899
+ ```
900
+
876
901
  ### asset
877
902
 
878
903
  **Asset** (interface)
@@ -3910,6 +3935,10 @@ Post a chat message to the AI (admin or public)
3910
3935
  **getManifest**(manifestUrl: string, force?: boolean) → `Promise<AppManifest>`
3911
3936
  Fetches an app's manifest file through the proxy API. The manifest is cached on the server for 5 minutes. ```typescript // Use with appsConfig const appsConfig = await Api.Collection.Public.getAppsConfig(collectionId); const app = appsConfig.apps[0]; if (app.manifestUrl) { const manifest = await Api.AppConfiguration.getManifest(app.manifestUrl); if (manifest.widgets) { console.log('Available widgets:', manifest.widgets); } } // Force refresh const freshManifest = await Api.AppConfiguration.getManifest(app.manifestUrl, true); ```
3912
3937
 
3938
+ **getCollectionWidgets**(collectionId: string,
3939
+ options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
3940
+ Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This is the recommended approach as it solves N+1 query problems and fetches manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getCollectionWidgets(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); } // Now use widgetModule components } // Force refresh all widgets const { apps: freshApps } = await Api.AppConfiguration.getCollectionWidgets( collectionId, { force: true } ); ```
3941
+
3913
3942
  ### appRecord
3914
3943
 
3915
3944
  **get**(collectionId: string, appId: string) → `Promise<any>`
@@ -78,3 +78,25 @@ export interface AppManifest {
78
78
  };
79
79
  [key: string]: any;
80
80
  }
81
+ /**
82
+ * Single app widget data with manifest and bundle files
83
+ */
84
+ export interface CollectionWidget {
85
+ appId: string;
86
+ manifestUrl: string;
87
+ manifest: AppManifest;
88
+ bundleSource: string;
89
+ bundleCss?: string;
90
+ }
91
+ /**
92
+ * Response from collection widgets endpoint
93
+ */
94
+ export interface CollectionWidgetsResponse {
95
+ apps: CollectionWidget[];
96
+ }
97
+ /**
98
+ * Options for fetching collection widgets
99
+ */
100
+ export interface GetCollectionWidgetsOptions {
101
+ force?: boolean;
102
+ }
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.3.29 | Generated: 2026-02-14T14:15:49.096Z
3
+ Version: 1.3.30 | Generated: 2026-02-14T14:44:14.267Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -873,6 +873,31 @@ interface AppManifest {
873
873
  }
874
874
  ```
875
875
 
876
+ **CollectionWidget** (interface)
877
+ ```typescript
878
+ interface CollectionWidget {
879
+ appId: string;
880
+ manifestUrl: string;
881
+ manifest: AppManifest;
882
+ bundleSource: string;
883
+ bundleCss?: string; // Optional CSS file
884
+ }
885
+ ```
886
+
887
+ **CollectionWidgetsResponse** (interface)
888
+ ```typescript
889
+ interface CollectionWidgetsResponse {
890
+ apps: CollectionWidget[];
891
+ }
892
+ ```
893
+
894
+ **GetCollectionWidgetsOptions** (interface)
895
+ ```typescript
896
+ interface GetCollectionWidgetsOptions {
897
+ force?: boolean; // Bypass cache and fetch fresh data
898
+ }
899
+ ```
900
+
876
901
  ### asset
877
902
 
878
903
  **Asset** (interface)
@@ -3910,6 +3935,10 @@ Post a chat message to the AI (admin or public)
3910
3935
  **getManifest**(manifestUrl: string, force?: boolean) → `Promise<AppManifest>`
3911
3936
  Fetches an app's manifest file through the proxy API. The manifest is cached on the server for 5 minutes. ```typescript // Use with appsConfig const appsConfig = await Api.Collection.Public.getAppsConfig(collectionId); const app = appsConfig.apps[0]; if (app.manifestUrl) { const manifest = await Api.AppConfiguration.getManifest(app.manifestUrl); if (manifest.widgets) { console.log('Available widgets:', manifest.widgets); } } // Force refresh const freshManifest = await Api.AppConfiguration.getManifest(app.manifestUrl, true); ```
3912
3937
 
3938
+ **getCollectionWidgets**(collectionId: string,
3939
+ options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
3940
+ Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This is the recommended approach as it solves N+1 query problems and fetches manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getCollectionWidgets(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); } // Now use widgetModule components } // Force refresh all widgets const { apps: freshApps } = await Api.AppConfiguration.getCollectionWidgets( collectionId, { force: true } ); ```
3941
+
3913
3942
  ### appRecord
3914
3943
 
3915
3944
  **get**(collectionId: string, appId: string) → `Promise<any>`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.3.29",
3
+ "version": "1.3.30",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",