@adminforth/upload 2.5.0 → 2.6.1
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 +2 -2
- package/custom/imageGenerator.vue +14 -12
- package/dist/custom/imageGenerator.vue +14 -12
- package/dist/index.js +6 -0
- package/index.ts +8 -0
- package/package.json +1 -1
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 49,
|
|
15
|
-
total size is 48,
|
|
14
|
+
sent 49,299 bytes received 134 bytes 98,866.00 bytes/sec
|
|
15
|
+
total size is 48,810 speedup is 0.99
|
|
@@ -376,20 +376,22 @@ async function generateImages() {
|
|
|
376
376
|
method: 'POST',
|
|
377
377
|
body: { jobId },
|
|
378
378
|
});
|
|
379
|
-
if (jobResponse
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
379
|
+
if (jobResponse !== null) {
|
|
380
|
+
if (jobResponse?.error) {
|
|
381
|
+
error = jobResponse.error;
|
|
382
|
+
break;
|
|
383
|
+
};
|
|
384
|
+
jobStatus = jobResponse?.job?.status;
|
|
385
|
+
if (jobStatus === 'failed') {
|
|
386
|
+
error = jobResponse?.job?.error || $t('Image generation job failed');
|
|
387
|
+
}
|
|
388
|
+
if (jobStatus === 'timeout') {
|
|
389
|
+
error = jobResponse?.job?.error || $t('Image generation job timeout');
|
|
390
|
+
}
|
|
389
391
|
}
|
|
390
392
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
391
|
-
} while (jobStatus === 'in_progress')
|
|
392
|
-
|
|
393
|
+
} while (jobStatus === 'in_progress' || jobStatus === null)
|
|
394
|
+
|
|
393
395
|
if (error) {
|
|
394
396
|
adminforth.alert({
|
|
395
397
|
message: error,
|
|
@@ -376,20 +376,22 @@ async function generateImages() {
|
|
|
376
376
|
method: 'POST',
|
|
377
377
|
body: { jobId },
|
|
378
378
|
});
|
|
379
|
-
if (jobResponse
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
379
|
+
if (jobResponse !== null) {
|
|
380
|
+
if (jobResponse?.error) {
|
|
381
|
+
error = jobResponse.error;
|
|
382
|
+
break;
|
|
383
|
+
};
|
|
384
|
+
jobStatus = jobResponse?.job?.status;
|
|
385
|
+
if (jobStatus === 'failed') {
|
|
386
|
+
error = jobResponse?.job?.error || $t('Image generation job failed');
|
|
387
|
+
}
|
|
388
|
+
if (jobStatus === 'timeout') {
|
|
389
|
+
error = jobResponse?.job?.error || $t('Image generation job timeout');
|
|
390
|
+
}
|
|
389
391
|
}
|
|
390
392
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
391
|
-
} while (jobStatus === 'in_progress')
|
|
392
|
-
|
|
393
|
+
} while (jobStatus === 'in_progress' || jobStatus === null)
|
|
394
|
+
|
|
393
395
|
if (error) {
|
|
394
396
|
adminforth.alert({
|
|
395
397
|
message: error,
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,12 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
23
23
|
// for calcualting average time
|
|
24
24
|
this.totalCalls = 0;
|
|
25
25
|
this.totalDuration = 0;
|
|
26
|
+
this.getFileDownloadUrl = (path_1, ...args_1) => __awaiter(this, [path_1, ...args_1], void 0, function* (path, expiresInSeconds = 1800) {
|
|
27
|
+
if (!path) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
return this.options.storageAdapter.getDownloadUrl(path, expiresInSeconds);
|
|
31
|
+
});
|
|
26
32
|
if ((_b = (_a = this.options.generation) === null || _a === void 0 ? void 0 : _a.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
|
|
27
33
|
this.rateLimiter = new RateLimiter((_c = this.options.generation.rateLimit) === null || _c === void 0 ? void 0 : _c.limit);
|
|
28
34
|
}
|
package/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
21
21
|
|
|
22
22
|
rateLimiter: RateLimiter;
|
|
23
23
|
|
|
24
|
+
getFileDownloadUrl: ((path: string) => Promise<string>);
|
|
25
|
+
|
|
24
26
|
constructor(options: PluginOptions) {
|
|
25
27
|
super(options, import.meta.url);
|
|
26
28
|
this.options = options;
|
|
@@ -28,6 +30,12 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
28
30
|
// for calcualting average time
|
|
29
31
|
this.totalCalls = 0;
|
|
30
32
|
this.totalDuration = 0;
|
|
33
|
+
this.getFileDownloadUrl = async (path: string, expiresInSeconds: number = 1800) : Promise<string> => {
|
|
34
|
+
if (!path) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
return this.options.storageAdapter.getDownloadUrl(path, expiresInSeconds);
|
|
38
|
+
}
|
|
31
39
|
if (this.options.generation?.rateLimit?.limit) {
|
|
32
40
|
this.rateLimiter = new RateLimiter(this.options.generation.rateLimit?.limit)
|
|
33
41
|
}
|