adminforth 2.4.0-next.3 → 2.4.0-next.300

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 (206) hide show
  1. package/commands/callTsProxy.js +14 -4
  2. package/commands/cli.js +12 -4
  3. package/commands/createApp/templates/api.ts.hbs +10 -0
  4. package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
  5. package/commands/createApp/templates/index.ts.hbs +13 -5
  6. package/commands/createApp/templates/package.json.hbs +1 -1
  7. package/commands/createApp/utils.js +45 -7
  8. package/commands/createCustomComponent/configLoader.js +17 -4
  9. package/commands/createCustomComponent/configUpdater.js +25 -21
  10. package/commands/createCustomComponent/fileGenerator.js +1 -1
  11. package/commands/createCustomComponent/main.js +15 -8
  12. package/commands/createCustomComponent/templates/customCrud/beforeActionButtons.vue.hbs +38 -0
  13. package/commands/createCustomComponent/templates/customCrud/saveButton.vue.hbs +28 -0
  14. package/commands/createCustomComponent/templates/login/beforeLogin.vue.hbs +18 -0
  15. package/commands/createPlugin/templates/custom/tsconfig.json.hbs +2 -5
  16. package/commands/createPlugin/templates/package.json.hbs +1 -1
  17. package/commands/generateModels.js +30 -22
  18. package/dist/auth.d.ts +9 -1
  19. package/dist/auth.d.ts.map +1 -1
  20. package/dist/auth.js +21 -2
  21. package/dist/auth.js.map +1 -1
  22. package/dist/dataConnectors/baseConnector.d.ts +1 -1
  23. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  24. package/dist/dataConnectors/baseConnector.js +69 -17
  25. package/dist/dataConnectors/baseConnector.js.map +1 -1
  26. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  27. package/dist/dataConnectors/clickhouse.js +15 -0
  28. package/dist/dataConnectors/clickhouse.js.map +1 -1
  29. package/dist/dataConnectors/mongo.d.ts.map +1 -1
  30. package/dist/dataConnectors/mongo.js +50 -15
  31. package/dist/dataConnectors/mongo.js.map +1 -1
  32. package/dist/dataConnectors/mysql.d.ts.map +1 -1
  33. package/dist/dataConnectors/mysql.js +11 -0
  34. package/dist/dataConnectors/mysql.js.map +1 -1
  35. package/dist/dataConnectors/postgres.d.ts.map +1 -1
  36. package/dist/dataConnectors/postgres.js +43 -14
  37. package/dist/dataConnectors/postgres.js.map +1 -1
  38. package/dist/dataConnectors/sqlite.d.ts.map +1 -1
  39. package/dist/dataConnectors/sqlite.js +11 -0
  40. package/dist/dataConnectors/sqlite.js.map +1 -1
  41. package/dist/index.d.ts +12 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +42 -21
  44. package/dist/index.js.map +1 -1
  45. package/dist/modules/codeInjector.d.ts +2 -0
  46. package/dist/modules/codeInjector.d.ts.map +1 -1
  47. package/dist/modules/codeInjector.js +67 -12
  48. package/dist/modules/codeInjector.js.map +1 -1
  49. package/dist/modules/configValidator.d.ts +6 -0
  50. package/dist/modules/configValidator.d.ts.map +1 -1
  51. package/dist/modules/configValidator.js +203 -25
  52. package/dist/modules/configValidator.js.map +1 -1
  53. package/dist/modules/restApi.d.ts +1 -1
  54. package/dist/modules/restApi.d.ts.map +1 -1
  55. package/dist/modules/restApi.js +172 -31
  56. package/dist/modules/restApi.js.map +1 -1
  57. package/dist/modules/styles.d.ts +499 -13
  58. package/dist/modules/styles.d.ts.map +1 -1
  59. package/dist/modules/styles.js +555 -31
  60. package/dist/modules/styles.js.map +1 -1
  61. package/dist/modules/utils.d.ts +7 -15
  62. package/dist/modules/utils.d.ts.map +1 -1
  63. package/dist/modules/utils.js +45 -68
  64. package/dist/modules/utils.js.map +1 -1
  65. package/dist/servers/express.d.ts +5 -0
  66. package/dist/servers/express.d.ts.map +1 -1
  67. package/dist/servers/express.js +40 -1
  68. package/dist/servers/express.js.map +1 -1
  69. package/dist/spa/index.html +1 -1
  70. package/dist/spa/package-lock.json +1208 -708
  71. package/dist/spa/package.json +34 -34
  72. package/dist/spa/src/App.vue +58 -173
  73. package/dist/spa/src/adminforth.ts +42 -18
  74. package/dist/spa/src/afcl/AreaChart.vue +0 -1
  75. package/dist/spa/src/afcl/BarChart.vue +2 -2
  76. package/dist/spa/src/afcl/Button.vue +6 -6
  77. package/dist/spa/src/afcl/ButtonGroup.vue +91 -0
  78. package/dist/spa/src/afcl/Card.vue +25 -0
  79. package/dist/spa/src/afcl/Checkbox.vue +21 -13
  80. package/dist/spa/src/afcl/CountryFlag.vue +4 -1
  81. package/dist/spa/src/{components/CustomDatePicker.vue → afcl/DatePicker.vue} +95 -9
  82. package/dist/spa/src/afcl/Dialog.vue +47 -27
  83. package/dist/spa/src/afcl/Dropzone.vue +103 -44
  84. package/dist/spa/src/afcl/Input.vue +18 -8
  85. package/dist/spa/src/afcl/JsonViewer.vue +25 -0
  86. package/dist/spa/src/afcl/Link.vue +1 -1
  87. package/dist/spa/src/afcl/LinkButton.vue +3 -3
  88. package/dist/spa/src/afcl/PieChart.vue +5 -5
  89. package/dist/spa/src/afcl/ProgressBar.vue +7 -7
  90. package/dist/spa/src/afcl/Select.vue +82 -34
  91. package/dist/spa/src/afcl/Skeleton.vue +6 -6
  92. package/dist/spa/src/afcl/Table.vue +309 -73
  93. package/dist/spa/src/afcl/Textarea.vue +31 -0
  94. package/dist/spa/src/afcl/Toggle.vue +32 -0
  95. package/dist/spa/src/afcl/Tooltip.vue +28 -18
  96. package/dist/spa/src/afcl/VerticalTabs.vue +16 -7
  97. package/dist/spa/src/afcl/index.ts +6 -3
  98. package/dist/spa/src/components/AcceptModal.vue +48 -14
  99. package/dist/spa/src/components/Breadcrumbs.vue +5 -5
  100. package/dist/spa/src/components/CallActionWrapper.vue +15 -0
  101. package/dist/spa/src/components/ColumnValueInput.vue +38 -18
  102. package/dist/spa/src/components/ColumnValueInputWrapper.vue +4 -3
  103. package/dist/spa/src/components/CustomDateRangePicker.vue +9 -8
  104. package/dist/spa/src/components/CustomRangePicker.vue +37 -21
  105. package/dist/spa/src/components/ErrorMessage.vue +21 -0
  106. package/dist/spa/src/components/Filters.vue +194 -131
  107. package/dist/spa/src/components/GroupsTable.vue +9 -8
  108. package/dist/spa/src/components/MenuLink.vue +90 -23
  109. package/dist/spa/src/components/ResourceForm.vue +94 -51
  110. package/dist/spa/src/components/ResourceListTable.vue +120 -90
  111. package/dist/spa/src/components/ResourceListTableVirtual.vue +118 -84
  112. package/dist/spa/src/components/ShowTable.vue +21 -15
  113. package/dist/spa/src/components/Sidebar.vue +470 -0
  114. package/dist/spa/src/components/SingleSkeletLoader.vue +6 -6
  115. package/dist/spa/src/components/SkeleteLoader.vue +3 -3
  116. package/dist/spa/src/components/ThreeDotsMenu.vue +84 -15
  117. package/dist/spa/src/components/Toast.vue +40 -29
  118. package/dist/spa/src/components/UserMenuSettingsButton.vue +69 -0
  119. package/dist/spa/src/components/ValueRenderer.vue +44 -17
  120. package/dist/spa/src/controls/BoolToggle.vue +34 -0
  121. package/dist/spa/src/i18n.ts +5 -3
  122. package/dist/spa/src/main.ts +1 -1
  123. package/dist/spa/src/renderers/CompactField.vue +1 -1
  124. package/dist/spa/src/renderers/CompactUUID.vue +1 -1
  125. package/dist/spa/src/router/index.ts +8 -0
  126. package/dist/spa/src/shims-vue.d.ts +5 -0
  127. package/dist/spa/src/spa_types/core.ts +13 -1
  128. package/dist/spa/src/stores/core.ts +13 -1
  129. package/dist/spa/src/stores/filters.ts +33 -2
  130. package/dist/spa/src/stores/modal.ts +6 -1
  131. package/dist/spa/src/stores/toast.ts +22 -3
  132. package/dist/spa/src/types/Back.ts +164 -23
  133. package/dist/spa/src/types/Common.ts +92 -32
  134. package/dist/spa/src/types/FrontendAPI.ts +31 -5
  135. package/dist/spa/src/types/adapters/CaptchaAdapter.ts +34 -0
  136. package/dist/spa/src/types/adapters/CompletionAdapter.ts +25 -0
  137. package/dist/spa/src/types/adapters/EmailAdapter.ts +27 -0
  138. package/dist/spa/src/types/adapters/ImageGenerationAdapter.ts +50 -0
  139. package/dist/spa/src/types/adapters/ImageVisionAdapter.ts +30 -0
  140. package/dist/spa/src/types/adapters/KeyValueAdapter.ts +16 -0
  141. package/dist/spa/src/types/adapters/OAuth2Adapter.ts +34 -0
  142. package/dist/spa/src/types/adapters/StorageAdapter.ts +73 -0
  143. package/dist/spa/src/types/adapters/index.ts +8 -0
  144. package/dist/spa/src/utils.ts +291 -11
  145. package/dist/spa/src/views/CreateView.vue +63 -21
  146. package/dist/spa/src/views/EditView.vue +55 -22
  147. package/dist/spa/src/views/ListView.vue +144 -87
  148. package/dist/spa/src/views/LoginView.vue +60 -55
  149. package/dist/spa/src/views/ResourceParent.vue +2 -2
  150. package/dist/spa/src/views/SettingsView.vue +121 -0
  151. package/dist/spa/src/views/ShowView.vue +83 -53
  152. package/dist/spa/src/websocket.ts +6 -1
  153. package/dist/spa/tsconfig.app.json +1 -1
  154. package/dist/spa/vite.config.ts +45 -2
  155. package/dist/types/Back.d.ts +147 -14
  156. package/dist/types/Back.d.ts.map +1 -1
  157. package/dist/types/Back.js +15 -0
  158. package/dist/types/Back.js.map +1 -1
  159. package/dist/types/Common.d.ts +107 -29
  160. package/dist/types/Common.d.ts.map +1 -1
  161. package/dist/types/Common.js.map +1 -1
  162. package/dist/types/FrontendAPI.d.ts +31 -3
  163. package/dist/types/FrontendAPI.d.ts.map +1 -1
  164. package/dist/types/FrontendAPI.js.map +1 -1
  165. package/dist/types/adapters/CaptchaAdapter.d.ts +30 -0
  166. package/dist/types/adapters/CaptchaAdapter.d.ts.map +1 -0
  167. package/dist/types/adapters/CaptchaAdapter.js +5 -0
  168. package/dist/types/adapters/CaptchaAdapter.js.map +1 -0
  169. package/dist/types/adapters/CompletionAdapter.d.ts +20 -0
  170. package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -0
  171. package/dist/types/adapters/CompletionAdapter.js +2 -0
  172. package/dist/types/adapters/CompletionAdapter.js.map +1 -0
  173. package/dist/types/adapters/EmailAdapter.d.ts +20 -0
  174. package/dist/types/adapters/EmailAdapter.d.ts.map +1 -0
  175. package/dist/types/adapters/EmailAdapter.js +2 -0
  176. package/dist/types/adapters/EmailAdapter.js.map +1 -0
  177. package/dist/types/adapters/ImageGenerationAdapter.d.ts +37 -0
  178. package/dist/types/adapters/ImageGenerationAdapter.d.ts.map +1 -0
  179. package/dist/types/adapters/ImageGenerationAdapter.js +2 -0
  180. package/dist/types/adapters/ImageGenerationAdapter.js.map +1 -0
  181. package/dist/types/adapters/ImageVisionAdapter.d.ts +25 -0
  182. package/dist/types/adapters/ImageVisionAdapter.d.ts.map +1 -0
  183. package/dist/types/adapters/ImageVisionAdapter.js +2 -0
  184. package/dist/types/adapters/ImageVisionAdapter.js.map +1 -0
  185. package/dist/types/adapters/KeyValueAdapter.d.ts +10 -0
  186. package/dist/types/adapters/KeyValueAdapter.d.ts.map +1 -0
  187. package/dist/types/adapters/KeyValueAdapter.js +2 -0
  188. package/dist/types/adapters/KeyValueAdapter.js.map +1 -0
  189. package/dist/types/adapters/OAuth2Adapter.d.ts +32 -0
  190. package/dist/types/adapters/OAuth2Adapter.d.ts.map +1 -0
  191. package/dist/types/adapters/OAuth2Adapter.js +2 -0
  192. package/dist/types/adapters/OAuth2Adapter.js.map +1 -0
  193. package/dist/types/adapters/StorageAdapter.d.ts +63 -0
  194. package/dist/types/adapters/StorageAdapter.d.ts.map +1 -0
  195. package/dist/types/adapters/StorageAdapter.js +2 -0
  196. package/dist/types/adapters/StorageAdapter.js.map +1 -0
  197. package/dist/types/adapters/index.d.ts +9 -0
  198. package/dist/types/adapters/index.d.ts.map +1 -0
  199. package/dist/types/adapters/index.js +2 -0
  200. package/dist/types/adapters/index.js.map +1 -0
  201. package/package.json +4 -2
  202. package/dist/spa/src/types/Adapters.ts +0 -213
  203. package/dist/types/Adapters.d.ts +0 -168
  204. package/dist/types/Adapters.d.ts.map +0 -1
  205. package/dist/types/Adapters.js +0 -2
  206. package/dist/types/Adapters.js.map +0 -1
@@ -55,7 +55,7 @@ export interface FrontendAPIInterface {
55
55
  *
56
56
  * @param params - The parameters of the alert
57
57
  */
58
- alert(params:AlertParams): void;
58
+ alert(params:AlertParams): void | Promise<string> | string;
59
59
 
60
60
 
61
61
  list: {
@@ -82,27 +82,40 @@ export interface FrontendAPIInterface {
82
82
  */
83
83
  closeThreeDotsDropdown(): void;
84
84
 
85
-
86
85
  /**
87
- * Set a filter in the list
88
- * Works only when user located on the list page.
86
+ * Set a filter in the list.
87
+ * Works only when user located on the list page. If filter already exists, it will be replaced with the new one.
89
88
  * Can be used to set filter from charts or other components in pageInjections.
90
89
  *
90
+ * Filters are automatically marked as hidden (won't count in badge) if:
91
+ * - Column has showIn.filter: false
92
+ *
91
93
  * Example:
92
94
  *
93
95
  * ```ts
94
96
  * import adminforth from '@/adminforth'
95
97
  *
98
+ * // Regular filter (will show in badge if column.showIn.filter !== false)
96
99
  * adminforth.list.setFilter({field: 'name', operator: 'ilike', value: 'john'})
100
+ *
101
+ * // Hidden filter (won't show in badge if column.showIn.filter === false)
102
+ * adminforth.list.setFilter({field: 'internal_status', operator: 'eq', value: 'active'})
97
103
  * ```
98
104
  *
105
+ * Please note that you can set/update filter even for fields which have showIn.filter=false in resource configuration.
106
+ * Also you can set filter for virtual columns. For example Universal search plugin calls updateFilter for virtual column which has showIn.filter=false (because we dont want to show this column in filter dropdown, plugin renders its own filter UI)
107
+ *
99
108
  * @param filter - The filter to set
100
109
  */
101
110
  setFilter(filter: FilterParams): void;
102
111
 
103
112
  /**
113
+ * DEPRECATED: does the same as setFilter, kept for backward compatibility
104
114
  * Update a filter in the list
105
115
  *
116
+ * Filters visibility in badge is automatically determined by column configuration:
117
+ * - Hidden if column has showIn.filter: false
118
+ *
106
119
  * Example:
107
120
  *
108
121
  * ```ts
@@ -121,6 +134,14 @@ export interface FrontendAPIInterface {
121
134
  clearFilters(): void;
122
135
  }
123
136
 
137
+ show: {
138
+ /**
139
+ * Full refresh the current record on the show page. Loader may be shown during fetching.
140
+ * Fire-and-forget; you don't need to await it.
141
+ */
142
+ refresh(): void;
143
+ }
144
+
124
145
  menu: {
125
146
  /**
126
147
  * Refreshes the badges in the menu, by recalling the badge function for each menu item
@@ -171,7 +192,12 @@ export type AlertParams = {
171
192
  * Default is 10 seconds;
172
193
  */
173
194
  timeout?: number | 'unlimited';
174
-
195
+
196
+ /**
197
+ * Optional buttons to display in the alert
198
+ */
199
+ buttons?: {value: any, label: string}[];
200
+
175
201
  }
176
202
 
177
203
 
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Interface for Captcha adapters.
3
+ */
4
+
5
+ export interface CaptchaAdapter {
6
+ /**
7
+ * Returns the script source URL for the captcha widget.
8
+ */
9
+ getScriptSrc(): string;
10
+
11
+ /**
12
+ * Returns the site key for the captcha.
13
+ */
14
+ getSiteKey(): string;
15
+
16
+ /**
17
+ * Returns the widget ID for the captcha.
18
+ */
19
+ getWidgetId(): string;
20
+
21
+ /**
22
+ * Returns the script HTML for the captcha widget.
23
+ */
24
+ getRenderWidgetCode(): string;
25
+
26
+ /**
27
+ * Returns the function name to render the captcha widget.
28
+ */
29
+ getRenderWidgetFunctionName(): string;
30
+ /**
31
+ * Validates the captcha token.
32
+ */
33
+ validate(token: string, ip: string): Promise<Record<string, any>>;
34
+ }
@@ -0,0 +1,25 @@
1
+ export interface CompletionAdapter {
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(): void;
8
+
9
+ /**
10
+ * This method should return a text completion based on the provided content and stop sequence.
11
+ * @param content - The input text to complete
12
+ * @param stop - An array of stop sequences to indicate where to stop the completion
13
+ * @param maxTokens - The maximum number of tokens to generate
14
+ * @returns A promise that resolves to an object containing the completed text and other metadata
15
+ */
16
+ complete(
17
+ content: string,
18
+ stop: string[],
19
+ maxTokens: number,
20
+ ): Promise<{
21
+ content?: string;
22
+ finishReason?: string;
23
+ error?: string;
24
+ }>;
25
+ }
@@ -0,0 +1,27 @@
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-readable 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
+ }
@@ -0,0 +1,50 @@
1
+ export interface ImageGenerationAdapter {
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(): void;
8
+
9
+ /**
10
+ * Return max number of images which model can generate in one request
11
+ */
12
+ outputImagesMaxCountSupported(): number;
13
+
14
+ /**
15
+ * Return the list of supported dimensions in format ["100x500", "200x200"]
16
+ */
17
+ outputDimensionsSupported(): string[];
18
+
19
+ /**
20
+ * Input file extension supported
21
+ */
22
+ inputFileExtensionSupported(): string[];
23
+
24
+ /**
25
+ * This method should generate an image based on the provided prompt and input files.
26
+ * @param prompt - The prompt to generate the image
27
+ * @param inputFiles - An array of input file paths (optional)
28
+ * @param n - The number of images to generate (default is 1)
29
+ * @param size - The size of the generated image (default is the lowest dimension supported)
30
+ * @returns A promise that resolves to an object containing the generated image URLs and any error message
31
+ */
32
+ generate({
33
+ prompt,
34
+ inputFiles,
35
+ n,
36
+ size,
37
+ }: {
38
+ prompt: string,
39
+ inputFiles: string[],
40
+
41
+ // default = lowest dimension supported
42
+ size?: string,
43
+
44
+ // one by default
45
+ n?: number
46
+ }): Promise<{
47
+ imageURLs?: string[];
48
+ error?: string;
49
+ }>;
50
+ }
@@ -0,0 +1,30 @@
1
+ export interface ImageVisionAdapter {
2
+
3
+ /**
4
+ * This method is called to validate the configuration of the adapter
5
+ * and should throw a clear user-readable error if the configuration is invalid.
6
+ */
7
+ validate(): void;
8
+
9
+ /**
10
+ * Input file extension supported
11
+ */
12
+ inputFileExtensionSupported(): string[];
13
+
14
+ /**
15
+ * This method should generate an image based on the provided prompt and input files.
16
+ * @param prompt - The prompt to generate the image
17
+ * @param inputFileUrls - An array of input file paths (optional)
18
+ * @returns A promise that resolves to an object containing the generated image and any error message
19
+ */
20
+ generate({
21
+ prompt,
22
+ inputFileUrls,
23
+ }: {
24
+ prompt: string,
25
+ inputFileUrls: string[],
26
+ }): Promise<{
27
+ response: string;
28
+ error?: string;
29
+ }>;
30
+ }
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * Might have implementations like RAM, Redis, Memcached,
4
+ *
5
+ */
6
+ export interface KeyValueAdapter {
7
+
8
+ get(key: string): Promise<string | null>;
9
+
10
+ set(key: string, value: string, expiresInSeconds?: number): Promise<void>;
11
+
12
+ delete(key: string): Promise<void>;
13
+
14
+ }
15
+
16
+
@@ -0,0 +1,34 @@
1
+
2
+ /**
3
+ * This interface is used to implement OAuth2 authentication adapters.
4
+ */
5
+ export interface OAuth2Adapter {
6
+ /**
7
+ * This method should return navigatable URL to the OAuth2 provider authentication page.
8
+ */
9
+ getAuthUrl(): string;
10
+
11
+ /**
12
+ * This method should return the token from the OAuth2 provider using the provided code and redirect URI.
13
+ * @param code - The authorization code received from the OAuth2 provider
14
+ * @param redirect_uri - The redirect URI used in the authentication request
15
+ * @returns A promise that resolves to an object containing the email address of the authenticated user
16
+ */
17
+ getTokenFromCode(code: string, redirect_uri: string): Promise<{ email: string }>;
18
+
19
+ /**
20
+ * This method should return text (content) of SVG icon which will be used in the UI.
21
+ * Use official SVG icons with simplest possible conent, omit icons which have base64 encoded raster images inside.
22
+ */
23
+ getIcon(): string;
24
+
25
+ /**
26
+ * This method should return the text to be displayed on the button in the UI
27
+ */
28
+ getButtonText?(): string;
29
+
30
+ /**
31
+ * This method should return the name of the adapter
32
+ */
33
+ getName?(): string;
34
+ }
@@ -0,0 +1,73 @@
1
+
2
+ /**
3
+ * Each storage adapter should support two ways of storing files:
4
+ * - publically (public URL) - the file can be accessed by anyone by HTTP GET / HEAD request with plain URL
5
+ * - privately (presigned URL) - the file can be accessed by anyone by HTTP GET / HEAD request only with presigned URLs, limited by expiration time
6
+ *
7
+ */
8
+ export interface StorageAdapter {
9
+ /**
10
+ * 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).
11
+ * 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.
12
+ * The PUT method should fail if the file already exists.
13
+ *
14
+ * Adapter user will always pass next parameters to the method:
15
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
16
+ * @param expiresIn - The expiration time in seconds for the presigned URL
17
+ * @param contentType - The content type of the file to be uploaded, e.g. "image/png"
18
+ *
19
+ * @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
20
+ */
21
+ getUploadSignedUrl(key: string, contentType: string, expiresIn?: number): Promise<{
22
+ uploadUrl: string;
23
+ uploadExtraParams?: Record<string, string>;
24
+ }>;
25
+
26
+ /**
27
+ * 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).
28
+ * If adapter configured to store objects publically, this method should return the public URL of the file.
29
+ * If adapter configured to no allow public storing of images, this method should return the presigned URL for the file.
30
+ *
31
+ * @param key - The key of the file to be downloaded e.g. "uploads/file.txt"
32
+ * @param expiresIn - The expiration time in seconds for the presigned URL
33
+ */
34
+ getDownloadUrl(key: string, expiresIn?: number): Promise<string>;
35
+
36
+ /**
37
+ * This method should mark the file for deletion.
38
+ * If file is marked for delation and exists more then 24h (since creation date) it should be deleted.
39
+ * This method should work even if the file does not exist yet (e.g. only presigned URL was generated).
40
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
41
+ */
42
+ markKeyForDeletation(key: string): Promise<void>;
43
+
44
+
45
+ /**
46
+ * This method should mark the file to not be deleted.
47
+ * This method should be used to cancel the deletion of the file if it was marked for deletion.
48
+ * @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
49
+ */
50
+ markKeyForNotDeletation(key: string): Promise<void>;
51
+
52
+
53
+ /**
54
+ * This method can start needed schedullers, cron jobs, etc. to clean up the storage.
55
+ * @param adapterUserUniqueRepresentation - The unique representation of the plugin instance which
56
+ * wil use this adapter. Might be handy if you need to distinguish between different instances of the same adapter.
57
+ */
58
+ setupLifecycle(adapterUserUniqueRepresentation: string): Promise<void>;
59
+
60
+ /**
61
+ * If adapter is configured to publically, this method should return true.
62
+ */
63
+ objectCanBeAccesedPublicly(): Promise<boolean>;
64
+
65
+ /**
66
+ * This method should return the key as a data URL (base64 encoded string).
67
+ * @param key - The key of the file to be converted to a data URL
68
+ * @returns A promise that resolves to a string containing the data URL
69
+ */
70
+ getKeyAsDataURL(key: string): Promise<string>;
71
+ }
72
+
73
+
@@ -0,0 +1,8 @@
1
+ export type { EmailAdapter } from './EmailAdapter.js';
2
+ export type { CompletionAdapter } from './CompletionAdapter.js';
3
+ export type { ImageGenerationAdapter } from './ImageGenerationAdapter.js';
4
+ export type { KeyValueAdapter } from './KeyValueAdapter.js';
5
+ export type { ImageVisionAdapter } from './ImageVisionAdapter.js';
6
+ export type { OAuth2Adapter } from './OAuth2Adapter.js';
7
+ export type { StorageAdapter } from './StorageAdapter.js';
8
+ export type { CaptchaAdapter } from './CaptchaAdapter.js';