-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
162 lines (134 loc) · 3.47 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
export type PluginOptions = {
/**
* 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.
*/
pathColumnName: string;
/**
* the list of allowed file extensions
*/
allowedFileExtensions?: string[]; // allowed file extensions
/**
* the maximum file size in bytes
*/
maxFileSize?: number;
/**
* S3 bucket name where we will upload the files, e.g. 'my-bucket'
*/
s3Bucket: string,
/**
* S3 region, e.g. 'us-east-1'
*/
s3Region: string,
/**
* S3 access key id
*/
s3AccessKeyId: string,
/**
* S3 secret access key
*/
s3SecretAccessKey: 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.
*/
s3ACL?: 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 {@link pathColumnName}
*
* example:
*
* ```typescript
* s3Path: ({originalFilename}) => `/aparts/${originalFilename}`
* ```
*
*/
s3Path: ({originalFilename, originalExtension, contentType, record }: {
originalFilename: string,
originalExtension: string,
contentType: string,
record?: any,
}) => string,
preview: {
/**
* Whether to show preview of image instead of path in list field
* By default true
*/
showInList?: boolean,
/**
* Whether to show preview of image instead of path in list field
* By default true
*/
showInShow?: boolean,
/**
* Maximum width of the preview image
*/
maxWidth?: 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:
*
* ```typescript
* previewUrl: ({record, path}) => `https://my-bucket.s3.amazonaws.com/${path}`,
* ```
*
*/
previewUrl?: ({s3Path}) => string,
}
/**
* AI image generation options
*/
generation?: {
/**
* The provider to use for image generation
* for now only 'openai-dall-e' is supported
*/
provider: string,
/**
* The number of images to generate
* in one request
*/
countToGenerate: number,
/**
* Options for OpenAI
*/
openAiOptions: {
/**
* The model to use, e.g. 'dall-e-3'
*/
model: string,
/**
* The size of the image to generate, e.g. '1792x1024'
*/
size: string,
/**
* The OpenAI API key
*/
apiKey: string,
},
/**
* Fields of record to use for context. if supplied must be array of valid column names for resource
* where plugin is used.
*/
fieldsForContext? : string[],
/**
* Since AI generation can be expensive, we can limit the number of requests per IP.
*/
rateLimit?: {
/**
* E.g. 5/1d - 5 requests per day
* 3/1h - 3 requests per hour
*/
limit: string,
/**
* !Not used now
* Message shown to user when rate limit is reached
*/
errorMessage: string,
},
}
}