@adminforth/upload 1.5.0 → 2.0.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.
package/build.log CHANGED
@@ -11,5 +11,5 @@ custom/preview.vue
11
11
  custom/tsconfig.json
12
12
  custom/uploader.vue
13
13
 
14
- sent 43,165 bytes received 134 bytes 86,598.00 bytes/sec
14
+ sent 43,158 bytes received 134 bytes 86,584.00 bytes/sec
15
15
  total size is 42,676 speedup is 0.99
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ export default class UploadPlugin extends AdminForthPlugin {
24
24
  }
25
25
  setupLifecycleRule() {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- this.options.storage.adapter.setupLifecycle();
27
+ this.options.storageAdapter.setupLifecycle();
28
28
  });
29
29
  }
30
30
  genPreviewUrl(record) {
@@ -34,7 +34,7 @@ export default class UploadPlugin extends AdminForthPlugin {
34
34
  record[`previewUrl_${this.pluginInstanceId}`] = this.options.preview.previewUrl({ filePath: record[this.options.pathColumnName] });
35
35
  return;
36
36
  }
37
- const previewUrl = yield this.options.storage.adapter.getDownloadUrl(record[this.options.pathColumnName], 1800);
37
+ const previewUrl = yield this.options.storageAdapter.getDownloadUrl(record[this.options.pathColumnName], 1800);
38
38
  record[`previewUrl_${this.pluginInstanceId}`] = previewUrl;
39
39
  });
40
40
  }
@@ -148,7 +148,7 @@ export default class UploadPlugin extends AdminForthPlugin {
148
148
  if (record[pathColumnName]) {
149
149
  process.env.HEAVY_DEBUG && console.log('🪥🪥 remove ObjectTagging', record[pathColumnName]);
150
150
  // let it crash if it fails: this is a new file which just was uploaded.
151
- yield this.options.storage.adapter.markKeyForNotDeletation(record[pathColumnName]);
151
+ yield this.options.storageAdapter.markKeyForNotDeletation(record[pathColumnName]);
152
152
  }
153
153
  return { ok: true };
154
154
  }));
@@ -182,7 +182,7 @@ export default class UploadPlugin extends AdminForthPlugin {
182
182
  resourceConfig.hooks.delete.afterSave.push((_a) => __awaiter(this, [_a], void 0, function* ({ record }) {
183
183
  if (record[pathColumnName]) {
184
184
  try {
185
- yield this.options.storage.adapter.markKeyForDeletation(record[pathColumnName]);
185
+ yield this.options.storageAdapter.markKeyForDeletation(record[pathColumnName]);
186
186
  }
187
187
  catch (e) {
188
188
  // file might be e.g. already deleted, so we catch error
@@ -206,7 +206,7 @@ export default class UploadPlugin extends AdminForthPlugin {
206
206
  if (oldRecord[pathColumnName]) {
207
207
  // put tag to delete old file
208
208
  try {
209
- yield this.options.storage.adapter.markKeyForDeletation(oldRecord[pathColumnName]);
209
+ yield this.options.storageAdapter.markKeyForDeletation(oldRecord[pathColumnName]);
210
210
  }
211
211
  catch (e) {
212
212
  // file might be e.g. already deleted, so we catch error
@@ -216,7 +216,7 @@ export default class UploadPlugin extends AdminForthPlugin {
216
216
  if (updates[virtualColumn.name] !== null) {
217
217
  // remove tag from new file
218
218
  // in this case we let it crash if it fails: this is a new file which just was uploaded.
219
- yield this.options.storage.adapter.markKeyForNotDeletation(updates[pathColumnName]);
219
+ yield this.options.storageAdapter.markKeyForNotDeletation(updates[pathColumnName]);
220
220
  }
221
221
  }
222
222
  return { ok: true };
@@ -261,13 +261,13 @@ export default class UploadPlugin extends AdminForthPlugin {
261
261
  if (filePath.startsWith('/')) {
262
262
  throw new Error('s3Path should not start with /, please adjust s3path function to not return / at the start of the path');
263
263
  }
264
- const { uploadUrl, uploadExtraParams } = yield this.options.storage.adapter.getUploadSignedUrl(filePath, contentType, 1800);
264
+ const { uploadUrl, uploadExtraParams } = yield this.options.storageAdapter.getUploadSignedUrl(filePath, contentType, 1800);
265
265
  let previewUrl;
266
266
  if ((_c = this.options.preview) === null || _c === void 0 ? void 0 : _c.previewUrl) {
267
267
  previewUrl = this.options.preview.previewUrl({ filePath });
268
268
  }
269
269
  else {
270
- previewUrl = yield this.options.storage.adapter.getDownloadUrl(filePath, 1800);
270
+ previewUrl = yield this.options.storageAdapter.getDownloadUrl(filePath, 1800);
271
271
  }
272
272
  return {
273
273
  uploadUrl,
package/index.ts CHANGED
@@ -28,7 +28,7 @@ export default class UploadPlugin extends AdminForthPlugin {
28
28
  }
29
29
 
30
30
  async setupLifecycleRule() {
31
- this.options.storage.adapter.setupLifecycle();
31
+ this.options.storageAdapter.setupLifecycle();
32
32
  }
33
33
 
34
34
  async genPreviewUrl(record: any) {
@@ -36,7 +36,7 @@ export default class UploadPlugin extends AdminForthPlugin {
36
36
  record[`previewUrl_${this.pluginInstanceId}`] = this.options.preview.previewUrl({ filePath: record[this.options.pathColumnName] });
37
37
  return;
38
38
  }
39
- const previewUrl = await this.options.storage.adapter.getDownloadUrl(record[this.options.pathColumnName], 1800);
39
+ const previewUrl = await this.options.storageAdapter.getDownloadUrl(record[this.options.pathColumnName], 1800);
40
40
 
41
41
  record[`previewUrl_${this.pluginInstanceId}`] = previewUrl;
42
42
  }
@@ -161,7 +161,7 @@ export default class UploadPlugin extends AdminForthPlugin {
161
161
  if (record[pathColumnName]) {
162
162
  process.env.HEAVY_DEBUG && console.log('🪥🪥 remove ObjectTagging', record[pathColumnName]);
163
163
  // let it crash if it fails: this is a new file which just was uploaded.
164
- await this.options.storage.adapter.markKeyForNotDeletation(record[pathColumnName]);
164
+ await this.options.storageAdapter.markKeyForNotDeletation(record[pathColumnName]);
165
165
  }
166
166
  return { ok: true };
167
167
  });
@@ -204,7 +204,7 @@ export default class UploadPlugin extends AdminForthPlugin {
204
204
  resourceConfig.hooks.delete.afterSave.push(async ({ record }: { record: any }) => {
205
205
  if (record[pathColumnName]) {
206
206
  try {
207
- await this.options.storage.adapter.markKeyForDeletation(record[pathColumnName]);
207
+ await this.options.storageAdapter.markKeyForDeletation(record[pathColumnName]);
208
208
  } catch (e) {
209
209
  // file might be e.g. already deleted, so we catch error
210
210
  console.error(`Error setting tag ${ADMINFORTH_NOT_YET_USED_TAG} to true for object ${record[pathColumnName]}. File will not be auto-cleaned up`, e);
@@ -233,7 +233,7 @@ export default class UploadPlugin extends AdminForthPlugin {
233
233
  if (oldRecord[pathColumnName]) {
234
234
  // put tag to delete old file
235
235
  try {
236
- await this.options.storage.adapter.markKeyForDeletation(oldRecord[pathColumnName]);
236
+ await this.options.storageAdapter.markKeyForDeletation(oldRecord[pathColumnName]);
237
237
  } catch (e) {
238
238
  // file might be e.g. already deleted, so we catch error
239
239
  console.error(`Error setting tag ${ADMINFORTH_NOT_YET_USED_TAG} to true for object ${oldRecord[pathColumnName]}. File will not be auto-cleaned up`, e);
@@ -242,7 +242,7 @@ export default class UploadPlugin extends AdminForthPlugin {
242
242
  if (updates[virtualColumn.name] !== null) {
243
243
  // remove tag from new file
244
244
  // in this case we let it crash if it fails: this is a new file which just was uploaded.
245
- await this.options.storage.adapter.markKeyForNotDeletation(updates[pathColumnName]);
245
+ await this.options.storageAdapter.markKeyForNotDeletation(updates[pathColumnName]);
246
246
  }
247
247
  }
248
248
  return { ok: true };
@@ -296,12 +296,12 @@ export default class UploadPlugin extends AdminForthPlugin {
296
296
  if (filePath.startsWith('/')) {
297
297
  throw new Error('s3Path should not start with /, please adjust s3path function to not return / at the start of the path');
298
298
  }
299
- const { uploadUrl, uploadExtraParams } = await this.options.storage.adapter.getUploadSignedUrl(filePath, contentType, 1800);
299
+ const { uploadUrl, uploadExtraParams } = await this.options.storageAdapter.getUploadSignedUrl(filePath, contentType, 1800);
300
300
  let previewUrl;
301
301
  if (this.options.preview?.previewUrl) {
302
302
  previewUrl = this.options.preview.previewUrl({ filePath });
303
303
  } else {
304
- previewUrl = await this.options.storage.adapter.getDownloadUrl(filePath, 1800);
304
+ previewUrl = await this.options.storageAdapter.getDownloadUrl(filePath, 1800);
305
305
  }
306
306
 
307
307
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -155,12 +155,9 @@ export type PluginOptions = {
155
155
 
156
156
  }
157
157
 
158
- storage?: {
159
- /**
160
- * The adapter used to store the files.
161
- * For now only S3 adapter is supported.
162
- */
163
- adapter: StorageAdapter,
164
- }
165
-
158
+ /**
159
+ * The adapter used to store the files.
160
+ * For now only S3 adapter is supported.
161
+ */
162
+ storageAdapter: StorageAdapter,
166
163
  }