SDK Reference
@proveanything/smartlinks
Namespaces
appConfiguration
Read/write app configuration and scoped data (collection/product/proof); hosts the deep-link registry.
getConfig
Get app configuration for a collection/product scope. Public reads return the public view of the config. If the stored config contains a top-level admin object, that block is omitted from public responses and included when opts.admin === true. typescript const config = await appConfiguration.getConfig({ appId: 'warranty-portal', collectionId: 'my-collection' });
getConfig(opts: ) → Promise<any>getWidgetInstance
Resolve a configured widget instance by ID from an app's stored config. This is a thin convenience wrapper over getConfig() that reads config.widgets[widgetId]. typescript const widget = await appConfiguration.getWidgetInstance({ collectionId: 'my-collection', appId: 'widget-toolkit', widgetId: 'launch-countdown' })
getWidgetInstance(opts: ) → Promise<WidgetInstance<TWidget>>listWidgetInstances
List configured widget instances for an app. Useful for picker UIs, setup schemas, and widget-to-widget references. typescript const widgets = await appConfiguration.listWidgetInstances({ collectionId: 'my-collection', appId: 'widget-toolkit' })
listWidgetInstances(opts: Omit<, 'widgetId'>) → Promise<[]>setConfig
Set app configuration for a collection/product scope. Requires admin authentication. Writing through the admin endpoint does not make every root-level field private. Use config.admin for confidential values that should only be returned on admin reads. typescript await appConfiguration.setConfig({ appId: 'warranty-portal', collectionId: 'my-collection', admin: true, config: { warrantyPeriod: 24, supportEmail: 'support@example.com' } });
setConfig(opts: ) → Promise<any>deleteConfig
Delete app configuration for a collection/product scope. Requires admin authentication. typescript await appConfiguration.deleteConfig({ appId: 'warranty-portal', collectionId: 'my-collection', admin: true });
deleteConfig(opts: ) → Promise<void>getData
Get all keyed data items for an app within a scope. Best for a small set of standalone documents such as FAQs, menus, lookup tables, or content fragments where the caller typically knows the item IDs. If you are modelling richer app entities that need filtering, lifecycle fields, visibility, ownership, or relationships, prefer app.records, app.cases, or app.threads instead. typescript const items = await appConfiguration.getData({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123' });
getData(opts: ) → Promise<any[]>getDataItem
Get a single keyed data item by ID within a scope. This is ideal when you already know the exact ID of a simple scoped document. For richer domain objects that users browse or query, prefer app.records, app.cases, or app.threads. typescript const item = await appConfiguration.getDataItem({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123', itemId: 'manual-1' });
getDataItem(opts: ) → Promise<any>setDataItem
Set/create a keyed data item within a scope. Requires admin authentication. Use this for simple scoped documents attached to a collection/product/variant/batch, especially when you want a small number of items with stable IDs. Do not treat this as the default write path for every app-owned entity. If the data starts behaving like a real object with lifecycle, filtering, visibility, ownership, history, or relationships, prefer app.records, app.cases, or app.threads. typescript await appConfiguration.setDataItem({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123', admin: true, data: { id: 'manual-1', title: 'User Manual', url: 'https://...' } });
setDataItem(opts: ) → Promise<any>deleteDataItem
Delete a keyed data item by ID within a scope. Requires admin authentication. typescript await appConfiguration.deleteDataItem({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123', admin: true, itemId: 'manual-1' });
deleteDataItem(opts: ) → Promise<void>getWidgets
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 });
getWidgets(collectionId: string,
options?: ) → Promise<>