-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
184 lines (149 loc) · 4.32 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import { AdminUser, ImageGenerationAdapter } from "adminforth";
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 use preview components provided by the plugin. BY default true
*/
usePreviewComponents?: boolean,
/**
* Maximum width of the preview image
*/
maxWidth?: string,
/**
* Maximum width of the preview image in list view
*/
maxListWidth?: string,
/**
* Maximum width of the preview image in show view
*/
maxShowWidth?: string,
/**
* Minimum width of the preview image
*/
minWidth?: string,
/**
* Minimum width of the preview image in list view
*/
minListWidth?: string,
/**
* Minimum width of the preview image in show view
*/
minShowWidth?: 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?: {
adapter: ImageGenerationAdapter,
/**
* The size of the generated image.
*/
outputSize?: string,
/**
* Fields for conetext which will be used to generate the image.
* If specified, the plugin will use fields from the record to provide additional context to the AI model.
*/
fieldsForContext?: string[],
/**
* The number of images to generate
* in one request
*/
countToGenerate: number,
/**
* Prompt which will be suggested to user during image generation. You can use record fields with mustache brackets:
* E.g. 'Generate a photo of car {{ model }} from {{ brand }} in {{ color }} color of {{ year }} year'. For now plugin get's these fields from open create/edit form
* so they should be present in the form.
*
* Reserved variables:
* - {{field}} - label of resource
* - {{resource}} - label of resource
*/
generationPrompt?: string,
/**
* If you want to use some image as reference for generation, you can use this function to get the path to the image.
*/
attachFiles?: ({ record, adminUser }: {
record: any,
adminUser: AdminUser,
}) => 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,
},
}
}