@adminforth/upload 1.0.19 → 1.0.21

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.
@@ -103,7 +103,7 @@
103
103
 
104
104
  <script setup lang="ts">
105
105
 
106
- import { ref, onMounted } from 'vue'
106
+ import { ref, onMounted, nextTick } from 'vue'
107
107
  import { Carousel } from 'flowbite';
108
108
  import { callAdminForthApi } from '@/utils';
109
109
 
@@ -197,7 +197,7 @@ async function generateImages() {
197
197
  // 'https://via.placeholder.com/600x400?text=Image+1',
198
198
  // 'https://via.placeholder.com/600x400?text=Image+2',
199
199
  // ];
200
- await new Promise(resolve => setTimeout(resolve, 0));
200
+ await nextTick();
201
201
 
202
202
  caurosel.value = new Carousel(
203
203
  document.getElementById('gallery'),
@@ -213,7 +213,7 @@ async function generateImages() {
213
213
  override: true,
214
214
  }
215
215
  );
216
- await new Promise(resolve => setTimeout(resolve, 0));
216
+ await nextTick();
217
217
  loading.value = false;
218
218
  }
219
219
 
@@ -103,7 +103,7 @@
103
103
 
104
104
  <script setup lang="ts">
105
105
 
106
- import { ref, onMounted } from 'vue'
106
+ import { ref, onMounted, nextTick } from 'vue'
107
107
  import { Carousel } from 'flowbite';
108
108
  import { callAdminForthApi } from '@/utils';
109
109
 
@@ -197,7 +197,7 @@ async function generateImages() {
197
197
  // 'https://via.placeholder.com/600x400?text=Image+1',
198
198
  // 'https://via.placeholder.com/600x400?text=Image+2',
199
199
  // ];
200
- await new Promise(resolve => setTimeout(resolve, 0));
200
+ await nextTick();
201
201
 
202
202
  caurosel.value = new Carousel(
203
203
  document.getElementById('gallery'),
@@ -213,7 +213,7 @@ async function generateImages() {
213
213
  override: true,
214
214
  }
215
215
  );
216
- await new Promise(resolve => setTimeout(resolve, 0));
216
+ await nextTick();
217
217
  loading.value = false;
218
218
  }
219
219
 
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
11
11
  import { ExpirationStatus, GetObjectCommand, PutObjectCommand, S3 } from '@aws-sdk/client-s3';
12
12
  import { AdminForthPlugin, suggestIfTypo } from "adminforth";
13
13
  import { Readable } from "stream";
14
- import { RateLimiter, getClinetIp } from "adminforth";
14
+ import { RateLimiter } from "adminforth";
15
15
  const ADMINFORTH_NOT_YET_USED_TAG = 'adminforth-candidate-for-cleanup';
16
16
  export default class UploadPlugin extends AdminForthPlugin {
17
17
  constructor(options) {
@@ -329,6 +329,7 @@ export default class UploadPlugin extends AdminForthPlugin {
329
329
  });
330
330
  }
331
331
  validateConfigAfterDiscover(adminforth, resourceConfig) {
332
+ this.adminforth = adminforth;
332
333
  // called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
333
334
  this.setupLifecycleRule();
334
335
  }
@@ -418,7 +419,7 @@ export default class UploadPlugin extends AdminForthPlugin {
418
419
  }
419
420
  if ((_d = this.options.generation.rateLimit) === null || _d === void 0 ? void 0 : _d.limit) {
420
421
  // rate limit
421
- const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_e = this.options.generation.rateLimit) === null || _e === void 0 ? void 0 : _e.limit, getClinetIp(headers));
422
+ const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_e = this.options.generation.rateLimit) === null || _e === void 0 ? void 0 : _e.limit, this.adminforth.auth.getClientIp(headers));
422
423
  if (error) {
423
424
  return { error: this.options.generation.rateLimit.errorMessage };
424
425
  }
package/index.ts CHANGED
@@ -4,13 +4,15 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
4
4
  import { ExpirationStatus, GetObjectCommand, ObjectCannedACL, PutObjectCommand, S3 } from '@aws-sdk/client-s3';
5
5
  import { AdminForthPlugin, AdminForthResourceColumn, AdminForthResourcePages, IAdminForth, IHttpServer, suggestIfTypo } from "adminforth";
6
6
  import { Readable } from "stream";
7
- import { RateLimiter, getClinetIp } from "adminforth";
7
+ import { RateLimiter } from "adminforth";
8
8
 
9
9
  const ADMINFORTH_NOT_YET_USED_TAG = 'adminforth-candidate-for-cleanup';
10
10
 
11
11
  export default class UploadPlugin extends AdminForthPlugin {
12
12
  options: PluginOptions;
13
13
 
14
+ adminforth!: IAdminForth;
15
+
14
16
  constructor(options: PluginOptions) {
15
17
  super(options, import.meta.url);
16
18
  this.options = options;
@@ -363,6 +365,7 @@ export default class UploadPlugin extends AdminForthPlugin {
363
365
  }
364
366
 
365
367
  validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: any) {
368
+ this.adminforth = adminforth;
366
369
  // called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
367
370
  this.setupLifecycleRule();
368
371
  }
@@ -464,7 +467,7 @@ export default class UploadPlugin extends AdminForthPlugin {
464
467
  const { error } = RateLimiter.checkRateLimit(
465
468
  this.pluginInstanceId,
466
469
  this.options.generation.rateLimit?.limit,
467
- getClinetIp(headers),
470
+ this.adminforth.auth.getClientIp(headers),
468
471
  );
469
472
  if (error) {
470
473
  return { error: this.options.generation.rateLimit.errorMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -142,6 +142,7 @@ export type PluginOptions = {
142
142
  limit: string,
143
143
 
144
144
  /**
145
+ * !Not used now
145
146
  * Message shown to user when rate limit is reached
146
147
  */
147
148
  errorMessage: string,