@sprucelabs/spruce-file-utils 15.1.5 → 15.1.7
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.
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const error_1 = __importDefault(require("@sprucelabs/error"));
|
7
|
+
class SpruceError extends error_1.default {
|
8
|
+
friendlyMessage() {
|
9
|
+
const { options } = this;
|
10
|
+
let message;
|
11
|
+
switch (options?.code) {
|
12
|
+
case 'UNAUTHORIZED':
|
13
|
+
message = 'You are not authorized to perform this action.';
|
14
|
+
break;
|
15
|
+
case 'BAD_REQUEST':
|
16
|
+
message = 'A Bad request just happened!';
|
17
|
+
break;
|
18
|
+
default:
|
19
|
+
message = super.friendlyMessage();
|
20
|
+
}
|
21
|
+
const fullMessage = options.friendlyMessage
|
22
|
+
? options.friendlyMessage
|
23
|
+
: message;
|
24
|
+
return fullMessage;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
exports.default = SpruceError;
|
@@ -2,10 +2,11 @@ import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
2
2
|
import { UploadedFile } from '../files.types';
|
3
3
|
import { ChunkingUploader, ChunkingUploaderEventContract, UploadOptions } from './ChunkingUploader';
|
4
4
|
export default class MockChunkingUploader extends AbstractEventEmitter<ChunkingUploaderEventContract> implements ChunkingUploader {
|
5
|
-
static instance
|
5
|
+
static instance?: MockChunkingUploader;
|
6
6
|
private lastUploadOptions?;
|
7
7
|
private lastUploadResponse?;
|
8
8
|
constructor();
|
9
|
+
static assertWasCreated(): void;
|
9
10
|
assertFileEqualsLastReturnedFromUpload(file: UploadedFile): void;
|
10
11
|
assertUploadOptionsEqual(options: UploadOptions): void;
|
11
12
|
upload(options: UploadOptions): Promise<{
|
@@ -9,6 +9,9 @@ class MockChunkingUploader extends mercury_event_emitter_1.AbstractEventEmitter
|
|
9
9
|
super(ChunkingUploader_1.chunkingUploaderEventContract);
|
10
10
|
MockChunkingUploader.instance = this;
|
11
11
|
}
|
12
|
+
static assertWasCreated() {
|
13
|
+
test_utils_1.assert.isTruthy(MockChunkingUploader.instance, 'You need to intantiate ChunkingUploaderImpl.Uploader(this.connectApi).');
|
14
|
+
}
|
12
15
|
assertFileEqualsLastReturnedFromUpload(file) {
|
13
16
|
(0, schema_1.assertOptions)({ file }, ['file']);
|
14
17
|
test_utils_1.assert.isEqualDeep(file, this.lastUploadResponse, 'Files do not match');
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sprucelabs/spruce-file-utils",
|
3
3
|
"description": "Utils for working with files and Sprucebot.",
|
4
|
-
"version": "15.1.
|
4
|
+
"version": "15.1.7",
|
5
5
|
"skill": {
|
6
6
|
"namespace": "files"
|
7
7
|
},
|
@@ -31,6 +31,8 @@
|
|
31
31
|
"build/uploading/ChunkingUploader.js",
|
32
32
|
"build/uploading/MockChunkingUploader.d.ts",
|
33
33
|
"build/uploading/MockChunkingUploader.js",
|
34
|
+
"build/errors/SpruceError.d.ts",
|
35
|
+
"build/errors/SpruceError.js",
|
34
36
|
|
35
37
|
"build/esm/uploading/LocalUploadStrategy.d.ts",
|
36
38
|
"build/esm/uploading/LocalUploadStrategy.js",
|
@@ -41,6 +43,7 @@
|
|
41
43
|
"build/esm/uploading/S3UploadStrategy.js",
|
42
44
|
"build/uploading/S3UploadStrategy.d.ts",
|
43
45
|
"build/uploading/S3UploadStrategy.js"
|
46
|
+
|
44
47
|
|
45
48
|
],
|
46
49
|
"keywords": [],
|