PluginOptions
PluginOptions:
object
Type declaration
allowedFileExtensions?
optional
allowedFileExtensions:string
[]
the list of allowed file extensions
generation?
optional
generation:object
AI image generation options
generation.countToGenerate
countToGenerate:
number
The number of images to generate in one request
generation.fieldsForContext?
optional
fieldsForContext:string
[]
Fields of record to use for context. if supplied must be array of valid column names for resource where plugin is used.
generation.openAiOptions
openAiOptions:
object
Options for OpenAI
generation.openAiOptions.apiKey
apiKey:
string
The OpenAI API key
generation.openAiOptions.model
model:
string
The model to use, e.g. 'dall-e-3'
generation.openAiOptions.size
size:
string
The size of the image to generate, e.g. '1792x1024'
generation.provider
provider:
string
The provider to use for image generation for now only 'openai-dall-e' is supported
generation.rateLimit?
optional
rateLimit:object
Since AI generation can be expensive, we can limit the number of requests per IP.
generation.rateLimit.errorMessage
errorMessage:
string
!Not used now Message shown to user when rate limit is reached
generation.rateLimit.limit
limit:
string
E.g. 5/1d - 5 requests per day 3/1h - 3 requests per hour
maxFileSize?
optional
maxFileSize:number
the maximum file size in bytes
pathColumnName
pathColumnName:
string
The name of the column where the path to the uploaded file is stored. On place of this column, a file upload field will be shown.
preview
preview:
object
preview.previewUrl()?
optional
previewUrl: ({s3Path}
) =>string
Used to display preview (if it is image) in list and show views. Defaulted to the AWS S3 presigned URL if resource is private or public URL if resource is public. Can be used to generate custom e.g. CDN(e.g. Cloudflare) URL to worm up cache and deliver preview faster.
Example:
previewUrl: ({record, path}) => `https://my-bucket.s3.amazonaws.com/${path}`,
Parameters
Parameter | Type |
---|---|
{s3Path} | any |
Returns
string
preview.showInList?
optional
showInList:boolean
Whether to show preview of image instead of path in list field By default true
preview.showInShow?
optional
showInShow:boolean
Whether to show preview of image instead of path in list field By default true
s3ACL?
optional
s3ACL:string
ACL which will be set to uploaded file, e.g. 'public-read'. If you want to use 'public-read', it is your responsibility to set the "ACL Enabled" to true in the S3 bucket policy and Uncheck "Block all public access" in the bucket settings.
s3AccessKeyId
s3AccessKeyId:
string
S3 access key id
s3Bucket
s3Bucket:
string
S3 bucket name where we will upload the files, e.g. 'my-bucket'
s3Path()
s3Path: (
{originalFilename, originalExtension, contentType}
) =>string
The path where the file will be uploaded to the S3 bucket, same path will be stored in the database in the column specified in pathColumnName
example:
s3Path: ({record, originalFilename}) => `/aparts/${record.id}/${originalFilename}`
Parameters
Parameter | Type |
---|---|
{originalFilename, originalExtension, contentType} | any |
Returns
string
s3Region
s3Region:
string
S3 region, e.g. 'us-east-1'
s3SecretAccessKey
s3SecretAccessKey:
string
S3 secret access key