The implementation of Assets 10 plug-ins is very similar to the implementation of Assets 6 (external) plug-ins that make use of the SDK, but with some major differences.
This article highlights the differences between the plug-ins of the two versions and what changes need to be made to an external plug-in for Assets 6 so that it can be used in Assets 10.
Self-hosted plug-ins only
With Assets 10 it is no longer possible to host the plug-ins as part of Assets server; the plug-ins need to be hosted externally by yourself.
Connecting to the SDK
Asset 10 plug-ins require to include the @woodwing/a10-client-sdk to be able to make a connection with the client.
The documentation of the npm package describes how to set up the connection.
Copy, move, and remove
The copy, move, and remove operations are always asynchronous, meaning that you fire off the process and it directly returns. The process will then continue in the background.
If you need to wait for the process to finish or you want to show a progress bar in the plug-in, it is possible to supply a processCallback handler. This is a function that takes a ProcessInfoUpdatePayload:
id: string;
state: string;
progress: number;
total: number;
errorCount: number;
The state can be one of the following:
PENDING,
RUNNING,
COMPLETED,
COMPLETED_WITH_ERRORS,
FAILED,
CANCELLED,
UNKNOWN
Update bulk
For the update and update bulk operations we supply two version where you can change metadata of assets or Collections in bulk.
One operation is specific for updating assets by their ID, the other operation is for updating assets by using a query.
client.updateBulkByQuery(queryString: string, metadata: Record<string, unknown>)
client.updateBulkById(assetIds: string[], metadata: Record<string, unknown>)
If you need to update metadata of a single asset, provide an array containing the assetId.
Importing an asset
It is possible to let the user upload a file of choice through the plug-in by calling client.openUploadDialog(uploadFolderPath: string).
The client will handle the rest of the upload.
If you need to upload from an external source (URL or stream), we recommend to use a separate self-hosted service that makes use of the API endpoints that we also provide. The same goes for uploading a new version of an asset.
Relations
Assets 10 currently only has relations for Collections implemented. The functionality to create a relation between two assets is therefore not available through the SDK.
Adding assets to a Collection can be achieved by updating the metadata of an asset with the correct container ID.
This is done by obtaining the ID of the Collection and then updating the assets you want to add to the Collection by using the UpdateMetadataBulk API client.updateBulkById(assetIds: string[], metadata: Record<string, unknown>) as metadata, provide { “parentContainerIds”: “+${id}” } where ${id} is the ID of the Collection.
The + sign tells the server to add the new ID rather than to override the existing ones, which would break the Collection relations.
Plug-in context
The plug-in context is stripped down to contain app and configProperties.
The configProperties are configured in the Management Console and make it possible to pass environment specific values to the plug-in.
The app is an object containing:
queryString: string;
userProfile: UserProfile;
folderSelection: PartialFolder[];
assetSelection: Asset[];
These are automatically updated when they change in the client.
The activeTab and basketSelection objects that were available in Assets 6 have been removed as they don’t apply to Assets 10.
As for information on the plug-in itself, we assume that the plug-in already knows this information or it can be provided as separate information using the configuration properties.
Most of the functions that the plug-inContext provided have been moved to the Assets client.
Selection
The assetSelection operation automatically updates in the plug-in context, but if you want to react to selection updates directly you can do so by supplying a function that can handle the selected items.
client.onSelectionUpdate((payload: SelectedItem[]) => { /* do something */ })
Selected items consist of the assets ID and all the metadata that the user has the rights for to view.
Free use of the API
APIs are no longer directly exposed to the plug-in. If you need to use the public API endpoints, you can do so from a self-hosted service or a WoodWing Connect integration.
If certain client functionality is required for your plug-in, please reach out to your contact at WoodWing for a feature request.
Configuration in the Management Console
The filter expression is replaced with a selection of AssetDomains that are supported for the plug-in: the basic permissions an asset needs to have.
The enabled expression is replaced with three options:
- Always enabled, regardless of what is selected and filtered.
- One asset selected: only enabled when one asset is selected (after permission / assetDomain filter).
- Any filtered selection: enabled when one or more assets are selected (after permission / assetDomain filter).
For more information about configuring plug-ins, see:
Comments
0 comments
Please sign in to leave a comment.