adminforth 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/commands/cli.js +12 -4
  2. package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
  3. package/commands/createApp/templates/index.ts.hbs +4 -1
  4. package/commands/createApp/templates/package.json.hbs +1 -1
  5. package/commands/createApp/utils.js +27 -2
  6. package/dist/dataConnectors/mongo.d.ts.map +1 -1
  7. package/dist/dataConnectors/mongo.js +1 -8
  8. package/dist/dataConnectors/mongo.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/modules/codeInjector.js +2 -2
  14. package/dist/modules/codeInjector.js.map +1 -1
  15. package/dist/spa/src/App.vue +1 -1
  16. package/dist/spa/src/afcl/Button.vue +3 -3
  17. package/dist/spa/src/afcl/Input.vue +2 -2
  18. package/dist/spa/src/afcl/JsonViewer.vue +25 -0
  19. package/dist/spa/src/afcl/Select.vue +1 -2
  20. package/dist/spa/src/afcl/Table.vue +8 -8
  21. package/dist/spa/src/afcl/index.ts +1 -1
  22. package/dist/spa/src/components/AcceptModal.vue +4 -4
  23. package/dist/spa/src/components/Filters.vue +1 -1
  24. package/dist/spa/src/components/ResourceListTable.vue +15 -16
  25. package/dist/spa/src/components/ResourceListTableVirtual.vue +6 -6
  26. package/dist/spa/src/components/ShowTable.vue +7 -4
  27. package/dist/spa/src/components/ValueRenderer.vue +1 -1
  28. package/dist/spa/src/types/Back.ts +6 -6
  29. package/dist/spa/src/types/adapters/CompletionAdapter.ts +25 -0
  30. package/dist/spa/src/types/adapters/EmailAdapter.ts +29 -0
  31. package/dist/spa/src/types/adapters/ImageGenerationAdapter.ts +50 -0
  32. package/dist/spa/src/types/adapters/OAuth2Adapter.ts +34 -0
  33. package/dist/spa/src/types/adapters/StorageAdapter.ts +73 -0
  34. package/dist/spa/src/types/adapters/index.ts +5 -0
  35. package/dist/spa/src/views/CreateView.vue +2 -2
  36. package/dist/spa/src/views/ListView.vue +2 -2
  37. package/dist/spa/src/views/ShowView.vue +3 -3
  38. package/dist/types/Back.d.ts +5 -5
  39. package/dist/types/adapters/CompletionAdapter.d.ts +20 -0
  40. package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -0
  41. package/dist/types/adapters/CompletionAdapter.js +2 -0
  42. package/dist/types/adapters/CompletionAdapter.js.map +1 -0
  43. package/dist/types/adapters/EmailAdapter.d.ts +21 -0
  44. package/dist/types/adapters/EmailAdapter.d.ts.map +1 -0
  45. package/dist/types/adapters/EmailAdapter.js +2 -0
  46. package/dist/types/adapters/EmailAdapter.js.map +1 -0
  47. package/dist/types/adapters/ImageGenerationAdapter.d.ts +37 -0
  48. package/dist/types/adapters/ImageGenerationAdapter.d.ts.map +1 -0
  49. package/dist/types/adapters/ImageGenerationAdapter.js +2 -0
  50. package/dist/types/adapters/ImageGenerationAdapter.js.map +1 -0
  51. package/dist/types/adapters/OAuth2Adapter.d.ts +32 -0
  52. package/dist/types/adapters/OAuth2Adapter.d.ts.map +1 -0
  53. package/dist/types/adapters/OAuth2Adapter.js +2 -0
  54. package/dist/types/adapters/OAuth2Adapter.js.map +1 -0
  55. package/dist/types/adapters/StorageAdapter.d.ts +63 -0
  56. package/dist/types/adapters/StorageAdapter.d.ts.map +1 -0
  57. package/dist/types/adapters/StorageAdapter.js +2 -0
  58. package/dist/types/adapters/StorageAdapter.js.map +1 -0
  59. package/dist/types/adapters/index.d.ts +6 -0
  60. package/dist/types/adapters/index.d.ts.map +1 -0
  61. package/dist/types/adapters/index.js +2 -0
  62. package/dist/types/adapters/index.js.map +1 -0
  63. package/package.json +2 -2
  64. package/dist/spa/src/types/Adapters.ts +0 -213
  65. package/dist/types/Adapters.d.ts +0 -168
  66. package/dist/types/Adapters.d.ts.map +0 -1
  67. package/dist/types/Adapters.js +0 -2
  68. package/dist/types/Adapters.js.map +0 -1
@@ -0,0 +1,20 @@
1
+ export interface CompletionAdapter {
2
+ /**
3
+ * This method is called to validate the configuration of the adapter
4
+ * and should throw a clear user-readbale error if the configuration is invalid.
5
+ */
6
+ validate(): void;
7
+ /**
8
+ * This method should return a text completion based on the provided content and stop sequence.
9
+ * @param content - The input text to complete
10
+ * @param stop - An array of stop sequences to indicate where to stop the completion
11
+ * @param maxTokens - The maximum number of tokens to generate
12
+ * @returns A promise that resolves to an object containing the completed text and other metadata
13
+ */
14
+ complete(content: string, stop: string[], maxTokens: number): Promise<{
15
+ content?: string;
16
+ finishReason?: string;
17
+ error?: string;
18
+ }>;
19
+ }
20
+ //# sourceMappingURL=CompletionAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletionAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/CompletionAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAEhC;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CompletionAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompletionAdapter.js","sourceRoot":"","sources":["../../../types/adapters/CompletionAdapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ interface EmailAdapter {
2
+ /**
3
+ * This method is called to validate the configuration of the adapter
4
+ * and should throw a clear user-readbale error if the configuration is invalid.
5
+ */
6
+ validate(): Promise<void>;
7
+ /**
8
+ * This method should send an email using the adapter
9
+ * @param from - The sender's email address
10
+ * @param to - The recipient's email address
11
+ * @param text - The plain text version of the email
12
+ * @param html - The HTML version of the email
13
+ * @param subject - The subject of the email
14
+ */
15
+ sendEmail(from: string, to: string, text: string, html: string, subject: string): Promise<{
16
+ error?: string;
17
+ ok?: boolean;
18
+ }>;
19
+ }
20
+ export { EmailAdapter };
21
+ //# sourceMappingURL=EmailAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/EmailAdapter.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IAEpB;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;;;OAOG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,EAAE,CAAC,EAAE,OAAO,CAAC;KACd,CAAC,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EmailAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailAdapter.js","sourceRoot":"","sources":["../../../types/adapters/EmailAdapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ export interface ImageGenerationAdapter {
2
+ /**
3
+ * This method is called to validate the configuration of the adapter
4
+ * and should throw a clear user-readbale error if the configuration is invalid.
5
+ */
6
+ validate(): void;
7
+ /**
8
+ * Return max number of images which model can generate in one request
9
+ */
10
+ outputImagesMaxCountSupported(): number;
11
+ /**
12
+ * Return the list of supported dimensions in format ["100x500", "200x200"]
13
+ */
14
+ outputDimensionsSupported(): string[];
15
+ /**
16
+ * Input file extension supported
17
+ */
18
+ inputFileExtensionSupported(): string[];
19
+ /**
20
+ * This method should generate an image based on the provided prompt and input files.
21
+ * @param prompt - The prompt to generate the image
22
+ * @param inputFiles - An array of input file paths (optional)
23
+ * @param n - The number of images to generate (default is 1)
24
+ * @param size - The size of the generated image (default is the lowest dimension supported)
25
+ * @returns A promise that resolves to an object containing the generated image URLs and any error message
26
+ */
27
+ generate({ prompt, inputFiles, n, size, }: {
28
+ prompt: string;
29
+ inputFiles: string[];
30
+ size?: string;
31
+ n?: number;
32
+ }): Promise<{
33
+ imageURLs?: string[];
34
+ error?: string;
35
+ }>;
36
+ }
37
+ //# sourceMappingURL=ImageGenerationAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageGenerationAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/ImageGenerationAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IAErC;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;OAEG;IACH,6BAA6B,IAAI,MAAM,CAAC;IAExC;;OAEG;IACH,yBAAyB,IAAI,MAAM,EAAE,CAAC;IAEtC;;OAEG;IACH,2BAA2B,IAAI,MAAM,EAAE,CAAC;IAExC;;;;;;;OAOG;IACH,QAAQ,CAAC,EACP,MAAM,EACN,UAAU,EACV,CAAC,EACD,IAAI,GACL,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,EAAE,CAAC;QAGrB,IAAI,CAAC,EAAE,MAAM,CAAC;QAGd,CAAC,CAAC,EAAE,MAAM,CAAA;KACX,GAAG,OAAO,CAAC;QACV,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ImageGenerationAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageGenerationAdapter.js","sourceRoot":"","sources":["../../../types/adapters/ImageGenerationAdapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * This interface is used to implement OAuth2 authentication adapters.
3
+ */
4
+ export interface OAuth2Adapter {
5
+ /**
6
+ * This method should return navigatable URL to the OAuth2 provider authentication page.
7
+ */
8
+ getAuthUrl(): string;
9
+ /**
10
+ * This method should return the token from the OAuth2 provider using the provided code and redirect URI.
11
+ * @param code - The authorization code received from the OAuth2 provider
12
+ * @param redirect_uri - The redirect URI used in the authentication request
13
+ * @returns A promise that resolves to an object containing the email address of the authenticated user
14
+ */
15
+ getTokenFromCode(code: string, redirect_uri: string): Promise<{
16
+ email: string;
17
+ }>;
18
+ /**
19
+ * This method should return text (content) of SVG icon which will be used in the UI.
20
+ * Use official SVG icons with simplest possible conent, omit icons which have base64 encoded raster images inside.
21
+ */
22
+ getIcon(): string;
23
+ /**
24
+ * This method should return the text to be displayed on the button in the UI
25
+ */
26
+ getButtonText?(): string;
27
+ /**
28
+ * This method should return the name of the adapter
29
+ */
30
+ getName?(): string;
31
+ }
32
+ //# sourceMappingURL=OAuth2Adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuth2Adapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/OAuth2Adapter.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEjF;;;OAGG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,IAAI,MAAM,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,IAAI,MAAM,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OAuth2Adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuth2Adapter.js","sourceRoot":"","sources":["../../../types/adapters/OAuth2Adapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Each storage adapter should support two ways of storing files:
3
+ * - publically (public URL) - the file can be accessed by anyone by HTTP GET / HEAD request with plain URL
4
+ * - privately (presigned URL) - the file can be accessed by anyone by HTTP GET / HEAD request only with presigned URLs, limited by expiration time
5
+ *
6
+ */
7
+ export interface StorageAdapter {
8
+ /**
9
+ * This method should return the presigned URL for the given key capable of upload (adapter user will call PUT multipart form data to this URL within expiresIn seconds after link generation).
10
+ * By default file which will be uploaded on PUT should be marked for deletion. So if during 24h it is not marked for not deletion, it adapter should delete it forever.
11
+ * The PUT method should fail if the file already exists.
12
+ *
13
+ * Adapter user will always pass next parameters to the method:
14
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
15
+ * @param expiresIn - The expiration time in seconds for the presigned URL
16
+ * @param contentType - The content type of the file to be uploaded, e.g. "image/png"
17
+ *
18
+ * @returns A promise that resolves to an object containing the upload URL and any extra parameters which should be sent with PUT multipart form data
19
+ */
20
+ getUploadSignedUrl(key: string, contentType: string, expiresIn?: number): Promise<{
21
+ uploadUrl: string;
22
+ uploadExtraParams?: Record<string, string>;
23
+ }>;
24
+ /**
25
+ * This method should return the URL for the given key capable of download (200 GET request with response body or 200 HEAD request without response body).
26
+ * If adapter configured to store objects publically, this method should return the public URL of the file.
27
+ * If adapter configured to no allow public storing of images, this method should return the presigned URL for the file.
28
+ *
29
+ * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
30
+ * @param expiresIn - The expiration time in seconds for the presigned URL
31
+ */
32
+ getDownloadUrl(key: string, expiresIn?: number): Promise<string>;
33
+ /**
34
+ * This method should mark the file for deletion.
35
+ * If file is marked for delation and exists more then 24h (since creation date) it should be deleted.
36
+ * This method should work even if the file does not exist yet (e.g. only presigned URL was generated).
37
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
38
+ */
39
+ markKeyForDeletation(key: string): Promise<void>;
40
+ /**
41
+ * This method should mark the file to not be deleted.
42
+ * This method should be used to cancel the deletion of the file if it was marked for deletion.
43
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
44
+ */
45
+ markKeyForNotDeletation(key: string): Promise<void>;
46
+ /**
47
+ * This method can start needed schedullers, cron jobs, etc. to clean up the storage.
48
+ * @param adapterUserUniqueRepresentation - The unique representation of the plugin instance which
49
+ * wil use this adapter. Might be handy if you need to distinguish between different instances of the same adapter.
50
+ */
51
+ setupLifecycle(adapterUserUniqueRepresentation: string): Promise<void>;
52
+ /**
53
+ * If adapter is configured to publically, this method should return true.
54
+ */
55
+ objectCanBeAccesedPublicly(): Promise<boolean>;
56
+ /**
57
+ * This method should return the key as a data URL (base64 encoded string).
58
+ * @param key - The key of the file to be converted to a data URL
59
+ * @returns A promise that resolves to a string containing the data URL
60
+ */
61
+ getKeyAsDataURL(key: string): Promise<string>;
62
+ }
63
+ //# sourceMappingURL=StorageAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/StorageAdapter.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAChF,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAC,CAAC;IAEH;;;;;;;OAOG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGjD;;;;OAIG;IACH,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGpD;;;;OAIG;IACH,cAAc,CAAC,+BAA+B,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvE;;OAEG;IACH,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/C;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StorageAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageAdapter.js","sourceRoot":"","sources":["../../../types/adapters/StorageAdapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export type { EmailAdapter } from './EmailAdapter.js';
2
+ export type { CompletionAdapter } from './CompletionAdapter.js';
3
+ export type { ImageGenerationAdapter } from './ImageGenerationAdapter.js';
4
+ export type { OAuth2Adapter } from './OAuth2Adapter.js';
5
+ export type { StorageAdapter } from './StorageAdapter.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../types/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../types/adapters/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -79,7 +79,7 @@
79
79
  "jsonwebtoken": "^9.0.2",
80
80
  "listr2": "^8.2.5",
81
81
  "mongodb": "6.6",
82
- "mysql2": "^3.12.0",
82
+ "mysql2": "^3.14.2",
83
83
  "node-fetch": "^3.3.2",
84
84
  "pg": "^8.11.5",
85
85
  "recast": "^0.23.11",
@@ -1,213 +0,0 @@
1
- export 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
- */
7
- validate(): Promise<void>;
8
-
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
- */
17
- sendEmail(
18
- from: string,
19
- to: string,
20
- text: string,
21
- html: string,
22
- subject: string
23
- ): Promise<{
24
- error?: string;
25
- ok?: boolean;
26
- }>;
27
- }
28
-
29
- export interface CompletionAdapter {
30
-
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
- */
35
- validate(): void;
36
-
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
- */
44
- complete(
45
- content: string,
46
- stop: string[],
47
- maxTokens: number,
48
- ): Promise<{
49
- content?: string;
50
- finishReason?: string;
51
- error?: string;
52
- }>;
53
- }
54
-
55
- export interface ImageGenerationAdapter {
56
-
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
- */
61
- validate(): void;
62
-
63
- /**
64
- * Return max number of images which model can generate in one request
65
- */
66
- outputImagesMaxCountSupported(): number;
67
-
68
- /**
69
- * Return the list of supported dimensions in format ["100x500", "200x200"]
70
- */
71
- outputDimensionsSupported(): string[];
72
-
73
- /**
74
- * Input file extension supported
75
- */
76
- inputFileExtensionSupported(): string[];
77
-
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
- */
86
- generate({
87
- prompt,
88
- inputFiles,
89
- n,
90
- size,
91
- }: {
92
- prompt: string,
93
- inputFiles: string[],
94
-
95
- // default = lowest dimension supported
96
- size?: string,
97
-
98
- // one by default
99
- n?: number
100
- }): Promise<{
101
- imageURLs?: string[];
102
- error?: string;
103
- }>;
104
- }
105
-
106
-
107
- /**
108
- * This interface is used to implement OAuth2 authentication adapters.
109
- */
110
- export interface OAuth2Adapter {
111
- /**
112
- * This method should return navigatable URL to the OAuth2 provider authentication page.
113
- */
114
- 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
- */
122
- 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
- */
128
- getIcon(): string;
129
-
130
- /**
131
- * This method should return the text to be displayed on the button in the UI
132
- */
133
- getButtonText?(): string;
134
-
135
- /**
136
- * This method should return the name of the adapter
137
- */
138
- getName?(): string;
139
- }
140
-
141
-
142
- /**
143
- * Each storage adapter should support two ways of storing files:
144
- * - publically (public URL) - the file can be accessed by anyone by HTTP GET / HEAD request with plain URL
145
- * - privately (presigned URL) - the file can be accessed by anyone by HTTP GET / HEAD request only with presigned URLs, limited by expiration time
146
- *
147
- */
148
- export interface StorageAdapter {
149
- /**
150
- * This method should return the presigned URL for the given key capable of upload (adapter user will call PUT multipart form data to this URL within expiresIn seconds after link generation).
151
- * By default file which will be uploaded on PUT should be marked for deletion. So if during 24h it is not marked for not deletion, it adapter should delete it forever.
152
- * The PUT method should fail if the file already exists.
153
- *
154
- * Adapter user will always pass next parameters to the method:
155
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
156
- * @param expiresIn - The expiration time in seconds for the presigned URL
157
- * @param contentType - The content type of the file to be uploaded, e.g. "image/png"
158
- *
159
- * @returns A promise that resolves to an object containing the upload URL and any extra parameters which should be sent with PUT multipart form data
160
- */
161
- getUploadSignedUrl(key: string, contentType: string, expiresIn?: number): Promise<{
162
- uploadUrl: string;
163
- uploadExtraParams?: Record<string, string>;
164
- }>;
165
-
166
- /**
167
- * This method should return the URL for the given key capable of download (200 GET request with response body or 200 HEAD request without response body).
168
- * If adapter configured to store objects publically, this method should return the public URL of the file.
169
- * If adapter configured to no allow public storing of images, this method should return the presigned URL for the file.
170
- *
171
- * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
172
- * @param expiresIn - The expiration time in seconds for the presigned URL
173
- */
174
- getDownloadUrl(key: string, expiresIn?: number): Promise<string>;
175
-
176
- /**
177
- * This method should mark the file for deletion.
178
- * If file is marked for delation and exists more then 24h (since creation date) it should be deleted.
179
- * This method should work even if the file does not exist yet (e.g. only presigned URL was generated).
180
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
181
- */
182
- markKeyForDeletation(key: string): Promise<void>;
183
-
184
-
185
- /**
186
- * This method should mark the file to not be deleted.
187
- * This method should be used to cancel the deletion of the file if it was marked for deletion.
188
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
189
- */
190
- markKeyForNotDeletation(key: string): Promise<void>;
191
-
192
-
193
- /**
194
- * This method can start needed schedullers, cron jobs, etc. to clean up the storage.
195
- * @param adapterUserUniqueRepresentation - The unique representation of the plugin instance which
196
- * wil use this adapter. Might be handy if you need to distinguish between different instances of the same adapter.
197
- */
198
- setupLifecycle(adapterUserUniqueRepresentation: string): Promise<void>;
199
-
200
- /**
201
- * If adapter is configured to publically, this method should return true.
202
- */
203
- objectCanBeAccesedPublicly(): Promise<boolean>;
204
-
205
- /**
206
- * This method should return the key as a data URL (base64 encoded string).
207
- * @param key - The key of the file to be converted to a data URL
208
- * @returns A promise that resolves to a string containing the data URL
209
- */
210
- getKeyAsDataURL(key: string): Promise<string>;
211
- }
212
-
213
-
@@ -1,168 +0,0 @@
1
- export interface EmailAdapter {
2
- /**
3
- * This method is called to validate the configuration of the adapter
4
- * and should throw a clear user-readbale error if the configuration is invalid.
5
- */
6
- validate(): Promise<void>;
7
- /**
8
- * This method should send an email using the adapter
9
- * @param from - The sender's email address
10
- * @param to - The recipient's email address
11
- * @param text - The plain text version of the email
12
- * @param html - The HTML version of the email
13
- * @param subject - The subject of the email
14
- */
15
- sendEmail(from: string, to: string, text: string, html: string, subject: string): Promise<{
16
- error?: string;
17
- ok?: boolean;
18
- }>;
19
- }
20
- export interface CompletionAdapter {
21
- /**
22
- * This method is called to validate the configuration of the adapter
23
- * and should throw a clear user-readbale error if the configuration is invalid.
24
- */
25
- validate(): void;
26
- /**
27
- * This method should return a text completion based on the provided content and stop sequence.
28
- * @param content - The input text to complete
29
- * @param stop - An array of stop sequences to indicate where to stop the completion
30
- * @param maxTokens - The maximum number of tokens to generate
31
- * @returns A promise that resolves to an object containing the completed text and other metadata
32
- */
33
- complete(content: string, stop: string[], maxTokens: number): Promise<{
34
- content?: string;
35
- finishReason?: string;
36
- error?: string;
37
- }>;
38
- }
39
- export interface ImageGenerationAdapter {
40
- /**
41
- * This method is called to validate the configuration of the adapter
42
- * and should throw a clear user-readbale error if the configuration is invalid.
43
- */
44
- validate(): void;
45
- /**
46
- * Return max number of images which model can generate in one request
47
- */
48
- outputImagesMaxCountSupported(): number;
49
- /**
50
- * Return the list of supported dimensions in format ["100x500", "200x200"]
51
- */
52
- outputDimensionsSupported(): string[];
53
- /**
54
- * Input file extension supported
55
- */
56
- inputFileExtensionSupported(): string[];
57
- /**
58
- * This method should generate an image based on the provided prompt and input files.
59
- * @param prompt - The prompt to generate the image
60
- * @param inputFiles - An array of input file paths (optional)
61
- * @param n - The number of images to generate (default is 1)
62
- * @param size - The size of the generated image (default is the lowest dimension supported)
63
- * @returns A promise that resolves to an object containing the generated image URLs and any error message
64
- */
65
- generate({ prompt, inputFiles, n, size, }: {
66
- prompt: string;
67
- inputFiles: string[];
68
- size?: string;
69
- n?: number;
70
- }): Promise<{
71
- imageURLs?: string[];
72
- error?: string;
73
- }>;
74
- }
75
- /**
76
- * This interface is used to implement OAuth2 authentication adapters.
77
- */
78
- export interface OAuth2Adapter {
79
- /**
80
- * This method should return navigatable URL to the OAuth2 provider authentication page.
81
- */
82
- getAuthUrl(): string;
83
- /**
84
- * This method should return the token from the OAuth2 provider using the provided code and redirect URI.
85
- * @param code - The authorization code received from the OAuth2 provider
86
- * @param redirect_uri - The redirect URI used in the authentication request
87
- * @returns A promise that resolves to an object containing the email address of the authenticated user
88
- */
89
- getTokenFromCode(code: string, redirect_uri: string): Promise<{
90
- email: string;
91
- }>;
92
- /**
93
- * This method should return text (content) of SVG icon which will be used in the UI.
94
- * Use official SVG icons with simplest possible conent, omit icons which have base64 encoded raster images inside.
95
- */
96
- getIcon(): string;
97
- /**
98
- * This method should return the text to be displayed on the button in the UI
99
- */
100
- getButtonText?(): string;
101
- /**
102
- * This method should return the name of the adapter
103
- */
104
- getName?(): string;
105
- }
106
- /**
107
- * Each storage adapter should support two ways of storing files:
108
- * - publically (public URL) - the file can be accessed by anyone by HTTP GET / HEAD request with plain URL
109
- * - privately (presigned URL) - the file can be accessed by anyone by HTTP GET / HEAD request only with presigned URLs, limited by expiration time
110
- *
111
- */
112
- export interface StorageAdapter {
113
- /**
114
- * This method should return the presigned URL for the given key capable of upload (adapter user will call PUT multipart form data to this URL within expiresIn seconds after link generation).
115
- * By default file which will be uploaded on PUT should be marked for deletion. So if during 24h it is not marked for not deletion, it adapter should delete it forever.
116
- * The PUT method should fail if the file already exists.
117
- *
118
- * Adapter user will always pass next parameters to the method:
119
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
120
- * @param expiresIn - The expiration time in seconds for the presigned URL
121
- * @param contentType - The content type of the file to be uploaded, e.g. "image/png"
122
- *
123
- * @returns A promise that resolves to an object containing the upload URL and any extra parameters which should be sent with PUT multipart form data
124
- */
125
- getUploadSignedUrl(key: string, contentType: string, expiresIn?: number): Promise<{
126
- uploadUrl: string;
127
- uploadExtraParams?: Record<string, string>;
128
- }>;
129
- /**
130
- * This method should return the URL for the given key capable of download (200 GET request with response body or 200 HEAD request without response body).
131
- * If adapter configured to store objects publically, this method should return the public URL of the file.
132
- * If adapter configured to no allow public storing of images, this method should return the presigned URL for the file.
133
- *
134
- * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
135
- * @param expiresIn - The expiration time in seconds for the presigned URL
136
- */
137
- getDownloadUrl(key: string, expiresIn?: number): Promise<string>;
138
- /**
139
- * This method should mark the file for deletion.
140
- * If file is marked for delation and exists more then 24h (since creation date) it should be deleted.
141
- * This method should work even if the file does not exist yet (e.g. only presigned URL was generated).
142
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
143
- */
144
- markKeyForDeletation(key: string): Promise<void>;
145
- /**
146
- * This method should mark the file to not be deleted.
147
- * This method should be used to cancel the deletion of the file if it was marked for deletion.
148
- * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
149
- */
150
- markKeyForNotDeletation(key: string): Promise<void>;
151
- /**
152
- * This method can start needed schedullers, cron jobs, etc. to clean up the storage.
153
- * @param adapterUserUniqueRepresentation - The unique representation of the plugin instance which
154
- * wil use this adapter. Might be handy if you need to distinguish between different instances of the same adapter.
155
- */
156
- setupLifecycle(adapterUserUniqueRepresentation: string): Promise<void>;
157
- /**
158
- * If adapter is configured to publically, this method should return true.
159
- */
160
- objectCanBeAccesedPublicly(): Promise<boolean>;
161
- /**
162
- * This method should return the key as a data URL (base64 encoded string).
163
- * @param key - The key of the file to be converted to a data URL
164
- * @returns A promise that resolves to a string containing the data URL
165
- */
166
- getKeyAsDataURL(key: string): Promise<string>;
167
- }
168
- //# sourceMappingURL=Adapters.d.ts.map