|
2 | 2 | import { PluginOptions } from './types.js'; |
3 | 3 | import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; |
4 | 4 | import { ExpirationStatus, GetObjectCommand, ObjectCannedACL, PutObjectCommand, S3 } from '@aws-sdk/client-s3'; |
5 | | -import { AdminForthPlugin, AdminForthResourceColumn, AdminForthResourcePages, Filters, IAdminForth, IHttpServer, suggestIfTypo } from "adminforth"; |
| 5 | +import { AdminForthPlugin, AdminForthResourceColumn, AdminForthResource, Filters, IAdminForth, IHttpServer, suggestIfTypo } from "adminforth"; |
6 | 6 | import { Readable } from "stream"; |
7 | 7 | import { RateLimiter } from "adminforth"; |
8 | 8 |
|
@@ -94,15 +94,15 @@ export default class UploadPlugin extends AdminForthPlugin { |
94 | 94 | record[`previewUrl_${this.pluginInstanceId}`] = previewUrl; |
95 | 95 | } |
96 | 96 |
|
97 | | - async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: any) { |
| 97 | + async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) { |
98 | 98 | super.modifyResourceConfig(adminforth, resourceConfig); |
99 | 99 | // after column to store the path of the uploaded file, add new VirtualColumn, |
100 | 100 | // show only in edit and create views |
101 | 101 | // use component uploader.vue |
102 | 102 | const { pathColumnName } = this.options; |
103 | 103 | const pathColumnIndex = resourceConfig.columns.findIndex((column: any) => column.name === pathColumnName); |
104 | 104 | if (pathColumnIndex === -1) { |
105 | | - throw new Error(`Column with name "${pathColumnName}" not found in resource "${resourceConfig.name}"`); |
| 105 | + throw new Error(`Column with name "${pathColumnName}" not found in resource "${resourceConfig.label}"`); |
106 | 106 | } |
107 | 107 |
|
108 | 108 | if (this.options.generation?.fieldsForContext) { |
@@ -315,7 +315,7 @@ export default class UploadPlugin extends AdminForthPlugin { |
315 | 315 |
|
316 | 316 |
|
317 | 317 | // add edit postSave hook to delete old file and remove tag from new file |
318 | | - resourceConfig.hooks.edit.afterSave.push(async ({ updates, oldRecord }: { record: any, oldRecord: any }) => { |
| 318 | + resourceConfig.hooks.edit.afterSave.push(async ({ updates, oldRecord }: { updates: any, oldRecord: any }) => { |
319 | 319 |
|
320 | 320 | if (updates[virtualColumn.name] || updates[virtualColumn.name] === null) { |
321 | 321 | const s3 = new S3({ |
|
0 commit comments