@wral/sdk-dam
v1.1.4
Published
A Software Development Kit for working with the Digital Asset Manager (DAM)
Downloads
2
Keywords
Readme
dam-sdk
The dam-sdk
is a JavaScript SDK (Software Development Kit) designed to
interact with a Digital Asset Management (DAM) API. This SDK provides a set
of functions to simplify common operations related to managing digital
assets such as uploading files, fetching asset details, updating metadata,
and searching assets.
Installation
You can install the dam-sdk
package via npm:
npm install dam-sdk
Usage
To use the dam-sdk
, you first need to import it into your JavaScript or
TypeScript project:
import { createClient } from '@wral/dam-sdk/v1';
// Or import everything:
// import * as v1 from '@wral/dam-sdk/v1';
Alternatively, you can import the whole sdk and use multiple versions:
import dam from '@wral/dam-sdk';
// Then use it with dam.v1.createClient(), etc.
Then, you can create a client instance with your configuration:
const config = {
apiKey: 'YOUR_API_KEY',
baseUrl: 'YOUR_BASE_URL', // Base URL of your DAM API (without version)
};
const client = createClient(config);
After creating the client instance, you can use its methods to interact with the DAM API. Here are some examples:
// Fetch asset details by ID
const assetDetails = await client.getAssetById({ id: 'ASSET_ID' });
// Delete asset by ID
await client.deleteAssetById({ id: 'ASSET_ID' });
// Generate upload URL for an asset
const uploadUrl = await client.generateUploadUrl({ id: 'ASSET_ID', metadata: { /* Metadata object */ } });
// Upload an asset
const uploadResult = await client.uploadAsset({ id: 'ASSET_ID', data: 'FILE_DATA', metadata: { /* Metadata object */ } });
// Fetch asset metadata by ID
const metadata = await client.getAssetMetadata({ id: 'ASSET_ID' });
// Replace asset metadata
await client.replaceAssetMetadata({ id: 'ASSET_ID', metadata: { /* Updated metadata object */ } });
// Update asset metadata with a patch
await client.updateAssetMetadata({ id: 'ASSET_ID', metadata: { /* Metadata patch object */ } });
// Search assets
const searchResults = await client.search({ query: 'SEARCH_QUERY' });
API
createClient(config)
Creates a new client instance with the provided configuration.
config
: An object containing API configuration parameters:apiKey
: The API key for authentication.baseUrl
: The base URL of the DAM API.
Returns a client instance with methods for interacting with the DAM API.
Methods
getAssetById({ id })
: Fetches asset details by ID.deleteAssetById({ id })
: Deletes an asset by ID.generateUploadUrl({ id, metadata })
: Generates an upload URL for an asset.uploadAsset({ id, data, metadata })
: Uploads an asset.getAssetMetadata({ id })
: Fetches asset metadata by ID.replaceAssetMetadata({ id, metadata })
: Replaces asset metadata.updateAssetMetadata({ id, metadata })
: Updates asset metadata with a patch.search({ query })
: Searches for assets based on a query.