@stackbit/types
Version:
Types for Stackbit config and Content Source Interface
90 lines (82 loc) • 2.41 kB
text/typescript
import { Logger } from './logger';
export type AssetSource = AssetSourceCloudinary | AssetSourceBynder | AssetSourceAprimo | AssetSourceIframe;
export type AssetSourceFunctionOptions = {
assetData: any;
getLogger: () => Logger;
};
export interface AssetSourceCloudinary {
type: 'cloudinary';
/**
* if not specified defaults to 'cloudinary'
*/
name?: string;
/**
* Cloudinary asset preview function
* If not specified will default to:
* ({ value }) => {
* title: value?.public_id,
* image: value?.derived?.[0]?.secure_url ?? value?.secure_url
* }
*/
preview?: AssetPreview;
/**
* asset transform function, if not specified will use the asset "as is"
*/
transform?: (options: AssetSourceFunctionOptions) => any;
}
export interface AssetSourceBynder {
type: 'bynder';
/**
* if not specified defaults to 'bynder'
*/
name?: string;
/**
* Bynder asset preview function
* If not specified will default to:
* ({ value }) => {
* title: value?.public_id,
* image: value?.derived?.[0]?.secure_url ?? value?.secure_url
* }
*/
preview?: AssetPreview;
/**
* asset transform function, if not specified will use the asset "as is"
*/
transform?: (options: AssetSourceFunctionOptions) => any;
}
export interface AssetSourceAprimo {
type: 'aprimo';
/**
* if not specified defaults to 'aprimo'
*/
name?: string;
/**
* Aprimo asset preview function
* If not specified will default to:
* ({ value }) => {
* title: value?.title,
* image: value?.rendition?.publicuri
* }
*/
preview?: AssetPreview;
/**
* asset transform function, if not specified will use the asset "as is"
*/
transform?: (options: AssetSourceFunctionOptions) => any;
}
export interface AssetSourceIframe {
type: 'iframe';
name: string;
url: string;
preview: AssetPreview;
/**
* asset transform function, if not specified will use the asset "as is"
*/
transform?: (options: AssetSourceFunctionOptions) => any;
}
export type AssetPreview = AssetPreviewFunction | AssetPreviewFields;
export type AssetPreviewFunction = (options: AssetSourceFunctionOptions) => AssetPreviewFields;
export interface AssetPreviewFields {
title?: string;
image: string;
}