11export interface EmailAdapter {
2+
3+ /**
4+ * This method is called to validate the configuration of the adapter
5+ * and should throw a clear user-readbale error if the configuration is invalid.
6+ */
27 validate ( ) : Promise < void > ;
38
9+ /**
10+ * This method should send an email using the adapter
11+ * @param from - The sender's email address
12+ * @param to - The recipient's email address
13+ * @param text - The plain text version of the email
14+ * @param html - The HTML version of the email
15+ * @param subject - The subject of the email
16+ */
417 sendEmail (
518 from : string ,
619 to : string ,
@@ -15,8 +28,19 @@ export interface EmailAdapter {
1528
1629export interface CompletionAdapter {
1730
31+ /**
32+ * This method is called to validate the configuration of the adapter
33+ * and should throw a clear user-readbale error if the configuration is invalid.
34+ */
1835 validate ( ) : void ;
1936
37+ /**
38+ * This method should return a text completion based on the provided content and stop sequence.
39+ * @param content - The input text to complete
40+ * @param stop - An array of stop sequences to indicate where to stop the completion
41+ * @param maxTokens - The maximum number of tokens to generate
42+ * @returns A promise that resolves to an object containing the completed text and other metadata
43+ */
2044 complete (
2145 content : string ,
2246 stop : string [ ] ,
@@ -30,10 +54,14 @@ export interface CompletionAdapter {
3054
3155export interface ImageGenerationAdapter {
3256
57+ /**
58+ * This method is called to validate the configuration of the adapter
59+ * and should throw a clear user-readbale error if the configuration is invalid.
60+ */
3361 validate ( ) : void ;
3462
3563 /**
36- * Return 1 or 10, or Infinity if the adapter supports multiple images
64+ * Return max number of images which model can generate in one request
3765 */
3866 outputImagesMaxCountSupported ( ) : number ;
3967
@@ -47,6 +75,14 @@ export interface ImageGenerationAdapter {
4775 */
4876 inputFileExtensionSupported ( ) : string [ ] ;
4977
78+ /**
79+ * This method should generate an image based on the provided prompt and input files.
80+ * @param prompt - The prompt to generate the image
81+ * @param inputFiles - An array of input file paths (optional)
82+ * @param n - The number of images to generate (default is 1)
83+ * @param size - The size of the generated image (default is the lowest dimension supported)
84+ * @returns A promise that resolves to an object containing the generated image URLs and any error message
85+ */
5086 generate ( {
5187 prompt,
5288 inputFiles,
@@ -68,11 +104,76 @@ export interface ImageGenerationAdapter {
68104}
69105
70106
71-
107+ /**
108+ * This interface is used to implement OAuth2 authentication adapters.
109+ */
72110export interface OAuth2Adapter {
111+ /**
112+ * This method should return navigatable URL to the OAuth2 provider authentication page.
113+ */
73114 getAuthUrl ( ) : string ;
115+
116+ /**
117+ * This method should return the token from the OAuth2 provider using the provided code and redirect URI.
118+ * @param code - The authorization code received from the OAuth2 provider
119+ * @param redirect_uri - The redirect URI used in the authentication request
120+ * @returns A promise that resolves to an object containing the email address of the authenticated user
121+ */
74122 getTokenFromCode ( code : string , redirect_uri : string ) : Promise < { email : string } > ;
123+
124+ /**
125+ * This method should return text (content) of SVG icon which will be used in the UI.
126+ * Use official SVG icons with simplest possible conent, omit icons which have base64 encoded raster images inside.
127+ */
75128 getIcon ( ) : string ;
129+
130+ /**
131+ * This method should return the text to be displayed on the button in the UI
132+ */
76133 getButtonText ?( ) : string ;
134+
135+ /**
136+ * This method should return the name of the adapter
137+ */
77138 getName ?( ) : string ;
78139}
140+
141+
142+ export interface StorageAdapter {
143+ /**
144+ * This method should return the presigned URL for the given key capable of upload.
145+ * The PUT method should fail if the file already exists.
146+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
147+ * @param expiresIn - The expiration time in seconds for the presigned URL
148+ */
149+ getUploadSignedUrl ( key : string , contentType : string , expiresIn ?: number ) : Promise < string > ;
150+
151+ /**
152+ * This method should return the presigned URL for the given key capable of download
153+ * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
154+ * @param expiresIn - The expiration time in seconds for the presigned URL
155+ */
156+ getDownloadSignedUrl ( key : string , expiresIn ?: number ) : Promise < string > ;
157+
158+ /**
159+ * This method should mark the file for deletion.
160+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
161+ */
162+ markKeyForDeletation ( key : string ) : Promise < string > ;
163+
164+
165+ /**
166+ * This method should return the list of files in the storage.
167+ * @param key
168+ */
169+ markKeyForNotDeletation ( key : string ) : Promise < string > ;
170+
171+
172+ /**
173+ * THis method can start needed schedullers, cron jobs, etc. to clean up the storage.
174+ */
175+ setupLifecycle ( ) : Promise < void > ;
176+
177+ }
178+
179+
0 commit comments