@geekmidas/storage 0.1.0 → 1.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/CHANGELOG.md +12 -0
- package/dist/AmazonStorageClient-BKzXhCX0.cjs.map +1 -1
- package/dist/{AmazonStorageClient-Gz0Fh1sy.d.mts → AmazonStorageClient-Bc_LP3K6.d.mts} +5 -5
- package/dist/AmazonStorageClient-Bc_LP3K6.d.mts.map +1 -0
- package/dist/AmazonStorageClient-CwUey48q.mjs.map +1 -1
- package/dist/{AmazonStorageClient-aduVU3_p.d.cts → AmazonStorageClient-DxT8_gTZ.d.cts} +5 -5
- package/dist/AmazonStorageClient-DxT8_gTZ.d.cts.map +1 -0
- package/dist/AmazonStorageClient.d.cts +2 -2
- package/dist/AmazonStorageClient.d.mts +2 -2
- package/dist/StorageClient-4ADnTPnJ.mjs.map +1 -1
- package/dist/StorageClient-BDRVrMJj.cjs.map +1 -1
- package/dist/{StorageClient-CcOAW3YV.d.cts → StorageClient-BWS26EEf.d.cts} +3 -2
- package/dist/StorageClient-BWS26EEf.d.cts.map +1 -0
- package/dist/{StorageClient-XgMsiUrd.d.mts → StorageClient-VG7Thpke.d.mts} +3 -2
- package/dist/StorageClient-VG7Thpke.d.mts.map +1 -0
- package/dist/StorageClient.d.cts +1 -1
- package/dist/StorageClient.d.mts +1 -1
- package/dist/aws.d.cts +2 -2
- package/dist/aws.d.mts +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/package.json +3 -3
- package/src/AmazonStorageClient.ts +178 -178
- package/src/StorageClient.ts +68 -68
- package/src/__tests__/AmazonStorageClient.spec.ts +501 -501
- package/src/__tests__/StorageClient.spec.ts +71 -71
- package/src/aws.ts +7 -7
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +5 -5
|
@@ -2,88 +2,88 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
import { StorageProvider } from '../StorageClient';
|
|
3
3
|
|
|
4
4
|
describe('StorageClient', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
describe('StorageProvider enum', () => {
|
|
6
|
+
it('should have correct provider values', () => {
|
|
7
|
+
expect(StorageProvider.AWSS3).toBe('geekimdas.toolbox.storage.aws.s3');
|
|
8
|
+
expect(StorageProvider.GCP).toBe('geekimdas.toolbox.storage.gcp');
|
|
9
|
+
expect(StorageProvider.AZURE).toBe('geekimdas.toolbox.storage.azure');
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
it('should have unique provider values', () => {
|
|
13
|
+
const values = Object.values(StorageProvider);
|
|
14
|
+
const uniqueValues = new Set(values);
|
|
15
|
+
expect(uniqueValues.size).toBe(values.length);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
describe('interfaces', () => {
|
|
20
|
+
it('should define DocumentVersion interface correctly', () => {
|
|
21
|
+
// This is a compile-time test to ensure the interface exists
|
|
22
|
+
// and has the correct shape
|
|
23
|
+
const version: import('../StorageClient').DocumentVersion = {
|
|
24
|
+
id: 'test-id',
|
|
25
|
+
createdAt: new Date(),
|
|
26
|
+
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
expect(version.id).toBe('test-id');
|
|
29
|
+
expect(version.createdAt).toBeInstanceOf(Date);
|
|
30
|
+
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
it('should define File interface correctly', () => {
|
|
33
|
+
const file: import('../StorageClient').File = {
|
|
34
|
+
path: 'test/path.txt',
|
|
35
|
+
};
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
expect(file.path).toBe('test/path.txt');
|
|
38
|
+
expect(file.name).toBeUndefined();
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const fileWithName: import('../StorageClient').File = {
|
|
41
|
+
path: 'test/path.txt',
|
|
42
|
+
name: 'display-name.txt',
|
|
43
|
+
};
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
expect(fileWithName.path).toBe('test/path.txt');
|
|
46
|
+
expect(fileWithName.name).toBe('display-name.txt');
|
|
47
|
+
});
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
it('should define GetUploadParams interface correctly', () => {
|
|
50
|
+
const params: import('../StorageClient').GetUploadParams = {
|
|
51
|
+
path: 'test/upload.txt',
|
|
52
|
+
contentType: 'text/plain',
|
|
53
|
+
contentLength: 100,
|
|
54
|
+
};
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
expect(params.path).toBe('test/upload.txt');
|
|
57
|
+
expect(params.contentType).toBe('text/plain');
|
|
58
|
+
expect(params.contentLength).toBe(100);
|
|
59
|
+
});
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
it('should define GetUploadResponse interface correctly', () => {
|
|
62
|
+
const response: import('../StorageClient').GetUploadResponse = {
|
|
63
|
+
url: 'https://example.com/upload',
|
|
64
|
+
fields: [
|
|
65
|
+
{ key: 'key', value: 'test/path.txt' },
|
|
66
|
+
{ key: 'acl', value: 'public-read' },
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
expect(response.url).toBe('https://example.com/upload');
|
|
71
|
+
expect(response.fields).toHaveLength(2);
|
|
72
|
+
expect(response.fields[0]).toEqual({
|
|
73
|
+
key: 'key',
|
|
74
|
+
value: 'test/path.txt',
|
|
75
|
+
});
|
|
76
|
+
expect(response.fields[1]).toEqual({ key: 'acl', value: 'public-read' });
|
|
77
|
+
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
it('should define UploadField type correctly', () => {
|
|
80
|
+
const field: import('../StorageClient').UploadField = {
|
|
81
|
+
key: 'test-key',
|
|
82
|
+
value: 'test-value',
|
|
83
|
+
};
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
expect(field.key).toBe('test-key');
|
|
86
|
+
expect(field.value).toBe('test-value');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
89
|
});
|
package/src/aws.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
AmazonCannedAccessControlList,
|
|
3
|
+
AmazonStorageClient,
|
|
4
4
|
} from './AmazonStorageClient';
|
|
5
5
|
export type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
DocumentVersion,
|
|
7
|
+
File,
|
|
8
|
+
GetUploadParams,
|
|
9
|
+
GetUploadResponse,
|
|
10
|
+
StorageClient,
|
|
11
11
|
} from './StorageClient';
|
package/tsconfig.json
ADDED
package/tsdown.config.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineConfig } from 'tsdown';
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
external: [
|
|
5
|
+
'@aws-sdk/client-s3',
|
|
6
|
+
'@aws-sdk/s3-presigned-post',
|
|
7
|
+
'@aws-sdk/s3-request-presigner',
|
|
8
|
+
],
|
|
9
9
|
});
|