@geekmidas/storage 0.0.5 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{AmazonStorageClient-tyGekctm.cjs → AmazonStorageClient-BKzXhCX0.cjs} +28 -5
  3. package/dist/AmazonStorageClient-BKzXhCX0.cjs.map +1 -0
  4. package/dist/{AmazonStorageClient-DaktozmE.d.mts → AmazonStorageClient-Bc_LP3K6.d.mts} +6 -5
  5. package/dist/AmazonStorageClient-Bc_LP3K6.d.mts.map +1 -0
  6. package/dist/{AmazonStorageClient-Bkw-x2o2.mjs → AmazonStorageClient-CwUey48q.mjs} +3 -2
  7. package/dist/AmazonStorageClient-CwUey48q.mjs.map +1 -0
  8. package/dist/{AmazonStorageClient-aduVU3_p.d.cts → AmazonStorageClient-DxT8_gTZ.d.cts} +6 -5
  9. package/dist/AmazonStorageClient-DxT8_gTZ.d.cts.map +1 -0
  10. package/dist/AmazonStorageClient.cjs +1 -1
  11. package/dist/AmazonStorageClient.d.cts +2 -2
  12. package/dist/AmazonStorageClient.d.mts +2 -2
  13. package/dist/AmazonStorageClient.mjs +2 -2
  14. package/dist/{StorageClient-CZGIC_fz.mjs → StorageClient-4ADnTPnJ.mjs} +2 -1
  15. package/dist/StorageClient-4ADnTPnJ.mjs.map +1 -0
  16. package/dist/StorageClient-BDRVrMJj.cjs +2 -1
  17. package/dist/StorageClient-BDRVrMJj.cjs.map +1 -0
  18. package/dist/{StorageClient-CveQoxJa.d.mts → StorageClient-BWS26EEf.d.cts} +4 -2
  19. package/dist/StorageClient-BWS26EEf.d.cts.map +1 -0
  20. package/dist/{StorageClient-CcOAW3YV.d.cts → StorageClient-VG7Thpke.d.mts} +4 -2
  21. package/dist/StorageClient-VG7Thpke.d.mts.map +1 -0
  22. package/dist/StorageClient.d.cts +1 -1
  23. package/dist/StorageClient.d.mts +1 -1
  24. package/dist/StorageClient.mjs +1 -1
  25. package/dist/aws.cjs +1 -1
  26. package/dist/aws.d.cts +2 -2
  27. package/dist/aws.d.mts +2 -2
  28. package/dist/aws.mjs +2 -2
  29. package/dist/index.d.cts +1 -1
  30. package/dist/index.d.mts +1 -1
  31. package/package.json +29 -6
  32. package/src/AmazonStorageClient.ts +178 -178
  33. package/src/StorageClient.ts +68 -68
  34. package/src/__tests__/AmazonStorageClient.spec.ts +501 -501
  35. package/src/__tests__/StorageClient.spec.ts +71 -71
  36. package/src/aws.ts +7 -7
  37. package/tsconfig.json +9 -0
  38. package/tsdown.config.ts +5 -5
  39. package/dist/__tests__/AmazonStorageClient.spec.cjs +0 -348
  40. package/dist/__tests__/AmazonStorageClient.spec.d.cts +0 -1
  41. package/dist/__tests__/AmazonStorageClient.spec.d.mts +0 -1
  42. package/dist/__tests__/AmazonStorageClient.spec.mjs +0 -347
  43. package/dist/__tests__/StorageClient.spec.cjs +0 -81
  44. package/dist/__tests__/StorageClient.spec.d.cts +0 -1
  45. package/dist/__tests__/StorageClient.spec.d.mts +0 -1
  46. package/dist/__tests__/StorageClient.spec.mjs +0 -81
  47. package/dist/chunk-DWy1uDak.cjs +0 -39
  48. package/dist/magic-string.es-BvJNBYzY.mjs +0 -1014
  49. package/dist/magic-string.es-CKiDiYoS.cjs +0 -1015
  50. package/dist/vi.bdSIJ99Y-CucmVasy.mjs +0 -14928
  51. package/dist/vi.bdSIJ99Y-D0m6qImj.cjs +0 -14926
@@ -2,88 +2,88 @@ import { describe, expect, it } from 'vitest';
2
2
  import { StorageProvider } from '../StorageClient';
3
3
 
4
4
  describe('StorageClient', () => {
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
- });
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
- 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
- });
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
- 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
- };
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
- expect(version.id).toBe('test-id');
29
- expect(version.createdAt).toBeInstanceOf(Date);
30
- });
28
+ expect(version.id).toBe('test-id');
29
+ expect(version.createdAt).toBeInstanceOf(Date);
30
+ });
31
31
 
32
- it('should define File interface correctly', () => {
33
- const file: import('../StorageClient').File = {
34
- path: 'test/path.txt',
35
- };
32
+ it('should define File interface correctly', () => {
33
+ const file: import('../StorageClient').File = {
34
+ path: 'test/path.txt',
35
+ };
36
36
 
37
- expect(file.path).toBe('test/path.txt');
38
- expect(file.name).toBeUndefined();
37
+ expect(file.path).toBe('test/path.txt');
38
+ expect(file.name).toBeUndefined();
39
39
 
40
- const fileWithName: import('../StorageClient').File = {
41
- path: 'test/path.txt',
42
- name: 'display-name.txt',
43
- };
40
+ const fileWithName: import('../StorageClient').File = {
41
+ path: 'test/path.txt',
42
+ name: 'display-name.txt',
43
+ };
44
44
 
45
- expect(fileWithName.path).toBe('test/path.txt');
46
- expect(fileWithName.name).toBe('display-name.txt');
47
- });
45
+ expect(fileWithName.path).toBe('test/path.txt');
46
+ expect(fileWithName.name).toBe('display-name.txt');
47
+ });
48
48
 
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
- };
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
- expect(params.path).toBe('test/upload.txt');
57
- expect(params.contentType).toBe('text/plain');
58
- expect(params.contentLength).toBe(100);
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
- 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
- };
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
- 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
- });
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
- it('should define UploadField type correctly', () => {
80
- const field: import('../StorageClient').UploadField = {
81
- key: 'test-key',
82
- value: 'test-value',
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
- expect(field.key).toBe('test-key');
86
- expect(field.value).toBe('test-value');
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
- AmazonStorageClient,
3
- AmazonCannedAccessControlList,
2
+ AmazonCannedAccessControlList,
3
+ AmazonStorageClient,
4
4
  } from './AmazonStorageClient';
5
5
  export type {
6
- StorageClient,
7
- DocumentVersion,
8
- File,
9
- GetUploadParams,
10
- GetUploadResponse,
6
+ DocumentVersion,
7
+ File,
8
+ GetUploadParams,
9
+ GetUploadResponse,
10
+ StorageClient,
11
11
  } from './StorageClient';
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "composite": true
7
+ },
8
+ "include": ["src/**/*"]
9
+ }
package/tsdown.config.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { defineConfig } from 'tsdown';
2
2
 
3
3
  export default defineConfig({
4
- external: [
5
- '@aws-sdk/client-s3',
6
- '@aws-sdk/s3-presigned-post',
7
- '@aws-sdk/s3-request-presigner',
8
- ],
4
+ external: [
5
+ '@aws-sdk/client-s3',
6
+ '@aws-sdk/s3-presigned-post',
7
+ '@aws-sdk/s3-request-presigner',
8
+ ],
9
9
  });
@@ -1,348 +0,0 @@
1
- const require_chunk = require('../chunk-DWy1uDak.cjs');
2
- const require_StorageClient = require('../StorageClient-BDRVrMJj.cjs');
3
- const require_AmazonStorageClient = require('../AmazonStorageClient-tyGekctm.cjs');
4
- const require_vi_bdSIJ99Y = require('../vi.bdSIJ99Y-D0m6qImj.cjs');
5
- const __aws_sdk_client_s3 = require_chunk.__toESM(require("@aws-sdk/client-s3"));
6
- const __geekmidas_cache_memory = require_chunk.__toESM(require("@geekmidas/cache/memory"));
7
-
8
- //#region src/__tests__/AmazonStorageClient.spec.ts
9
- require_vi_bdSIJ99Y.describe("AmazonStorageClient Integration Tests", () => {
10
- let client;
11
- const testBucket = "geekmidas";
12
- const testKey = "test-files/test.txt";
13
- const testContent = "Hello, World!";
14
- const testContentType = "text/plain";
15
- require_vi_bdSIJ99Y.beforeAll(async () => {
16
- client = require_AmazonStorageClient.AmazonStorageClient.create({
17
- bucket: testBucket,
18
- region: "us-east-1",
19
- accessKeyId: "geekmidas",
20
- secretAccessKey: "geekmidas",
21
- endpoint: "http://localhost:9000",
22
- acl: require_AmazonStorageClient.AmazonCannedAccessControlList.PublicRead,
23
- forcePathStyle: true
24
- });
25
- await new Promise((resolve) => setTimeout(resolve, 2e3));
26
- });
27
- require_vi_bdSIJ99Y.describe("provider property", () => {
28
- require_vi_bdSIJ99Y.it("should return AWS S3 provider", () => {
29
- require_vi_bdSIJ99Y.globalExpect(client.provider).toBe(require_StorageClient.StorageProvider.AWSS3);
30
- });
31
- });
32
- require_vi_bdSIJ99Y.describe("upload and download workflow", () => {
33
- require_vi_bdSIJ99Y.it.skip("should upload a file directly and generate download URL", async () => {
34
- await client.upload(testKey, testContent, testContentType);
35
- const downloadUrl = await client.getDownloadURL({ path: testKey });
36
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/test\.txt/);
37
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-Algorithm=AWS4-HMAC-SHA256");
38
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-Credential=");
39
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-Date=");
40
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-SignedHeaders=");
41
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-Signature=");
42
- const response = await fetch(downloadUrl);
43
- require_vi_bdSIJ99Y.globalExpect(response.ok).toBe(true);
44
- const downloadedContent = await response.text();
45
- require_vi_bdSIJ99Y.globalExpect(downloadedContent).toBe(testContent);
46
- });
47
- require_vi_bdSIJ99Y.it("should upload a file with filename and generate download URL with content disposition", async () => {
48
- const keyWithName = "test-files/named-file.txt";
49
- const fileName = "my-document.txt";
50
- await client.upload(keyWithName, testContent, testContentType);
51
- const downloadUrl = await client.getDownloadURL({
52
- path: keyWithName,
53
- name: fileName
54
- });
55
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("response-content-disposition=attachment%3B%20filename%3Dmy-document.txt");
56
- });
57
- require_vi_bdSIJ99Y.it("should handle binary data upload", async () => {
58
- const binaryKey = "test-files/binary.bin";
59
- const binaryData = Buffer.from([
60
- 72,
61
- 101,
62
- 108,
63
- 108,
64
- 111
65
- ]);
66
- await client.upload(binaryKey, binaryData, "application/octet-stream");
67
- const downloadUrl = await client.getDownloadURL({ path: binaryKey });
68
- const response = await fetch(downloadUrl);
69
- const downloadedBuffer = await response.arrayBuffer();
70
- require_vi_bdSIJ99Y.globalExpect(new Uint8Array(downloadedBuffer)).toEqual(new Uint8Array(binaryData));
71
- });
72
- });
73
- require_vi_bdSIJ99Y.describe("presigned upload URLs", () => {
74
- require_vi_bdSIJ99Y.it("should generate presigned PUT upload URL", async () => {
75
- const uploadKey = "test-files/presigned-upload.txt";
76
- const uploadUrl = await client.getUploadURL({
77
- path: uploadKey,
78
- contentType: testContentType,
79
- contentLength: testContent.length
80
- });
81
- require_vi_bdSIJ99Y.globalExpect(uploadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/presigned-upload\.txt/);
82
- require_vi_bdSIJ99Y.globalExpect(uploadUrl).toContain("X-Amz-Algorithm=AWS4-HMAC-SHA256");
83
- const uploadResponse = await fetch(uploadUrl, {
84
- method: "PUT",
85
- headers: {
86
- "Content-Type": testContentType,
87
- "Content-Length": testContent.length.toString()
88
- },
89
- body: testContent
90
- });
91
- require_vi_bdSIJ99Y.globalExpect(uploadResponse.ok).toBe(true);
92
- const downloadUrl = await client.getDownloadURL({ path: uploadKey });
93
- const downloadResponse = await fetch(downloadUrl);
94
- const downloadedContent = await downloadResponse.text();
95
- require_vi_bdSIJ99Y.globalExpect(downloadedContent).toBe(testContent);
96
- });
97
- require_vi_bdSIJ99Y.it("should generate presigned POST upload with form fields", async () => {
98
- const uploadKey = "test-files/presigned-post.txt";
99
- const uploadData = await client.getUpload({
100
- path: uploadKey,
101
- contentType: testContentType,
102
- contentLength: testContent.length
103
- });
104
- require_vi_bdSIJ99Y.globalExpect(uploadData.url).toBe("http://localhost:9000/geekmidas");
105
- require_vi_bdSIJ99Y.globalExpect(uploadData.fields).toContainEqual({
106
- key: "key",
107
- value: uploadKey
108
- });
109
- require_vi_bdSIJ99Y.globalExpect(uploadData.fields).toContainEqual({
110
- key: "acl",
111
- value: "public-read"
112
- });
113
- const formData = new FormData();
114
- uploadData.fields.forEach(({ key, value }) => {
115
- formData.append(key, value);
116
- });
117
- formData.append("file", new Blob([testContent], { type: testContentType }));
118
- const uploadResponse = await fetch(uploadData.url, {
119
- method: "POST",
120
- body: formData
121
- });
122
- require_vi_bdSIJ99Y.globalExpect(uploadResponse.ok).toBe(true);
123
- const downloadUrl = await client.getDownloadURL({ path: uploadKey });
124
- const downloadResponse = await fetch(downloadUrl);
125
- const downloadedContent = await downloadResponse.blob();
126
- require_vi_bdSIJ99Y.globalExpect(downloadedContent).toEqual(new Blob([testContent], { type: testContentType }));
127
- });
128
- });
129
- require_vi_bdSIJ99Y.describe("versioning", () => {
130
- require_vi_bdSIJ99Y.it("should handle file versions", async () => {
131
- const versionKey = "test-files/versioned.txt";
132
- const content1 = "Version 1";
133
- const content2 = "Version 2";
134
- await client.upload(versionKey, content1, testContentType);
135
- await client.upload(versionKey, content2, testContentType);
136
- const versions = await client.getVersions(versionKey);
137
- require_vi_bdSIJ99Y.globalExpect(Array.isArray(versions)).toBe(true);
138
- if (versions.length > 0) {
139
- require_vi_bdSIJ99Y.globalExpect(versions[0]).toHaveProperty("id");
140
- require_vi_bdSIJ99Y.globalExpect(versions[0]).toHaveProperty("createdAt");
141
- require_vi_bdSIJ99Y.globalExpect(versions[0].createdAt).toBeInstanceOf(Date);
142
- }
143
- });
144
- });
145
- require_vi_bdSIJ99Y.describe("error handling", () => {
146
- require_vi_bdSIJ99Y.it("should handle download URL generation for non-existent files", async () => {
147
- const downloadUrl = await client.getDownloadURL({ path: "non-existent/file.txt" });
148
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/non-existent\/file\.txt/);
149
- const response = await fetch(downloadUrl);
150
- require_vi_bdSIJ99Y.globalExpect(response.status).toBe(404);
151
- });
152
- });
153
- require_vi_bdSIJ99Y.describe("custom expiration times", () => {
154
- require_vi_bdSIJ99Y.it("should respect custom expiration for download URLs", async () => {
155
- const key = "test-files/expiration-test.txt";
156
- await client.upload(key, testContent, testContentType);
157
- const shortExpirationUrl = await client.getDownloadURL({ path: key }, 1);
158
- const longExpirationUrl = await client.getDownloadURL({ path: key }, 3600);
159
- require_vi_bdSIJ99Y.globalExpect(shortExpirationUrl).toContain("X-Amz-Expires=1");
160
- require_vi_bdSIJ99Y.globalExpect(longExpirationUrl).toContain("X-Amz-Expires=3600");
161
- });
162
- require_vi_bdSIJ99Y.it("should respect custom expiration for upload URLs", async () => {
163
- const key = "test-files/upload-expiration-test.txt";
164
- const shortExpirationUrl = await client.getUploadURL({
165
- path: key,
166
- contentType: testContentType,
167
- contentLength: testContent.length
168
- }, 1);
169
- const longExpirationUrl = await client.getUploadURL({
170
- path: key,
171
- contentType: testContentType,
172
- contentLength: testContent.length
173
- }, 3600);
174
- require_vi_bdSIJ99Y.globalExpect(shortExpirationUrl).toContain("X-Amz-Expires=1");
175
- require_vi_bdSIJ99Y.globalExpect(longExpirationUrl).toContain("X-Amz-Expires=3600");
176
- });
177
- });
178
- require_vi_bdSIJ99Y.describe("factory method", () => {
179
- require_vi_bdSIJ99Y.it("should create client with minimal configuration", () => {
180
- const minimalClient = require_AmazonStorageClient.AmazonStorageClient.create({ bucket: "geekmidas" });
181
- require_vi_bdSIJ99Y.globalExpect(minimalClient).toBeInstanceOf(require_AmazonStorageClient.AmazonStorageClient);
182
- require_vi_bdSIJ99Y.globalExpect(minimalClient.provider).toBe(require_StorageClient.StorageProvider.AWSS3);
183
- });
184
- require_vi_bdSIJ99Y.it("should create client with full configuration", () => {
185
- const fullClient = require_AmazonStorageClient.AmazonStorageClient.create({
186
- bucket: "geekmidas",
187
- region: "us-west-2",
188
- accessKeyId: "test-key",
189
- secretAccessKey: "test-secret",
190
- endpoint: "https://custom-s3.example.com",
191
- acl: require_AmazonStorageClient.AmazonCannedAccessControlList.Private
192
- });
193
- require_vi_bdSIJ99Y.globalExpect(fullClient).toBeInstanceOf(require_AmazonStorageClient.AmazonStorageClient);
194
- require_vi_bdSIJ99Y.globalExpect(fullClient.provider).toBe(require_StorageClient.StorageProvider.AWSS3);
195
- });
196
- });
197
- require_vi_bdSIJ99Y.describe("different ACL configurations", () => {
198
- require_vi_bdSIJ99Y.it("should work with different ACL settings", async () => {
199
- const privateClient = require_AmazonStorageClient.AmazonStorageClient.create({
200
- bucket: testBucket,
201
- region: "us-east-1",
202
- accessKeyId: "minioadmin",
203
- secretAccessKey: "minioadmin",
204
- endpoint: "http://localhost:9000",
205
- acl: require_AmazonStorageClient.AmazonCannedAccessControlList.Private
206
- });
207
- const uploadData = await privateClient.getUpload({
208
- path: "test-files/private.txt",
209
- contentType: testContentType,
210
- contentLength: testContent.length
211
- });
212
- require_vi_bdSIJ99Y.globalExpect(uploadData.fields).toContainEqual({
213
- key: "acl",
214
- value: "private"
215
- });
216
- });
217
- });
218
- require_vi_bdSIJ99Y.describe("S3Client integration", () => {
219
- require_vi_bdSIJ99Y.it("should work with externally created S3Client", () => {
220
- const s3Client = new __aws_sdk_client_s3.S3Client({
221
- region: "us-east-1",
222
- credentials: {
223
- accessKeyId: "minioadmin",
224
- secretAccessKey: "minioadmin"
225
- },
226
- endpoint: "http://localhost:9000"
227
- });
228
- const storageClient = new require_AmazonStorageClient.AmazonStorageClient(s3Client, testBucket, require_AmazonStorageClient.AmazonCannedAccessControlList.PublicRead);
229
- require_vi_bdSIJ99Y.globalExpect(storageClient).toBeInstanceOf(require_AmazonStorageClient.AmazonStorageClient);
230
- require_vi_bdSIJ99Y.globalExpect(storageClient.provider).toBe(require_StorageClient.StorageProvider.AWSS3);
231
- });
232
- });
233
- require_vi_bdSIJ99Y.describe("cache functionality", () => {
234
- require_vi_bdSIJ99Y.it("should cache download URLs", async () => {
235
- const cache = new __geekmidas_cache_memory.InMemoryCache();
236
- const clientWithCache = require_AmazonStorageClient.AmazonStorageClient.create({
237
- bucket: testBucket,
238
- region: "us-east-1",
239
- accessKeyId: "geekmidas",
240
- secretAccessKey: "geekmidas",
241
- endpoint: "http://localhost:9000",
242
- forcePathStyle: true,
243
- cache
244
- });
245
- const key = "test-files/cache-test.txt";
246
- await clientWithCache.upload(key, testContent, testContentType);
247
- const url1 = await clientWithCache.getDownloadURL({ path: key });
248
- const url2 = await clientWithCache.getDownloadURL({ path: key });
249
- require_vi_bdSIJ99Y.globalExpect(url1).toBe(url2);
250
- const cacheKey = `download-url:${key}`;
251
- const cachedUrl = await cache.get(cacheKey);
252
- require_vi_bdSIJ99Y.globalExpect(cachedUrl).toBe(url1);
253
- });
254
- require_vi_bdSIJ99Y.it("should respect cache expiration based on URL expiry", async () => {
255
- const cache = new __geekmidas_cache_memory.InMemoryCache();
256
- const clientWithCache = require_AmazonStorageClient.AmazonStorageClient.create({
257
- bucket: testBucket,
258
- region: "us-east-1",
259
- accessKeyId: "geekmidas",
260
- secretAccessKey: "geekmidas",
261
- endpoint: "http://localhost:9000",
262
- forcePathStyle: true,
263
- cache
264
- });
265
- const key = "test-files/cache-expiry.txt";
266
- await clientWithCache.upload(key, testContent, testContentType);
267
- await clientWithCache.getDownloadURL({ path: key }, 30);
268
- const cacheKey = `download-url:${key}`;
269
- const cachedShortUrl = await cache.get(cacheKey);
270
- require_vi_bdSIJ99Y.globalExpect(cachedShortUrl).toBeUndefined();
271
- const longExpiryUrl = await clientWithCache.getDownloadURL({ path: key }, 3600);
272
- const cachedLongUrl = await cache.get(cacheKey);
273
- require_vi_bdSIJ99Y.globalExpect(cachedLongUrl).toBe(longExpiryUrl);
274
- });
275
- require_vi_bdSIJ99Y.it("should use cached URL when available", async () => {
276
- const cache = new __geekmidas_cache_memory.InMemoryCache();
277
- const clientWithCache = require_AmazonStorageClient.AmazonStorageClient.create({
278
- bucket: testBucket,
279
- region: "us-east-1",
280
- accessKeyId: "geekmidas",
281
- secretAccessKey: "geekmidas",
282
- endpoint: "http://localhost:9000",
283
- forcePathStyle: true,
284
- cache
285
- });
286
- const key = "test-files/pre-cached.txt";
287
- const cachedUrl = "https://pre-cached-url.example.com";
288
- const cacheKey = `download-url:${key}`;
289
- await cache.set(cacheKey, cachedUrl);
290
- const url = await clientWithCache.getDownloadURL({ path: key });
291
- require_vi_bdSIJ99Y.globalExpect(url).toBe(cachedUrl);
292
- });
293
- require_vi_bdSIJ99Y.it("should work without cache", async () => {
294
- const clientNoCache = require_AmazonStorageClient.AmazonStorageClient.create({
295
- bucket: testBucket,
296
- region: "us-east-1",
297
- accessKeyId: "geekmidas",
298
- secretAccessKey: "geekmidas",
299
- endpoint: "http://localhost:9000",
300
- forcePathStyle: true
301
- });
302
- const key = "test-files/no-cache.txt";
303
- await clientNoCache.upload(key, testContent, testContentType);
304
- const url1 = await clientNoCache.getDownloadURL({ path: key });
305
- const url2 = await clientNoCache.getDownloadURL({ path: key });
306
- require_vi_bdSIJ99Y.globalExpect(url1).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/no-cache\.txt/);
307
- require_vi_bdSIJ99Y.globalExpect(url2).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/no-cache\.txt/);
308
- });
309
- require_vi_bdSIJ99Y.it("should pass cache to constructor", () => {
310
- const cache = new __geekmidas_cache_memory.InMemoryCache();
311
- const s3Client = new __aws_sdk_client_s3.S3Client({
312
- region: "us-east-1",
313
- credentials: {
314
- accessKeyId: "geekmidas",
315
- secretAccessKey: "geekmidas"
316
- },
317
- endpoint: "http://localhost:9000",
318
- forcePathStyle: true
319
- });
320
- const clientWithCache = new require_AmazonStorageClient.AmazonStorageClient(s3Client, testBucket, require_AmazonStorageClient.AmazonCannedAccessControlList.PublicRead, cache);
321
- require_vi_bdSIJ99Y.globalExpect(clientWithCache.cache).toBe(cache);
322
- });
323
- });
324
- require_vi_bdSIJ99Y.describe("getVersionDownloadURL", () => {
325
- require_vi_bdSIJ99Y.it("should generate version-specific download URL", async () => {
326
- const versionKey = "test-files/version-download.txt";
327
- const versionId = "test-version-id";
328
- await client.upload(versionKey, testContent, testContentType);
329
- const downloadUrl = await client.getVersionDownloadURL({
330
- path: versionKey,
331
- name: "versioned-file.txt"
332
- }, versionId);
333
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/version-download\.txt/);
334
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("X-Amz-Algorithm=AWS4-HMAC-SHA256");
335
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toContain("response-content-disposition=attachment%3B%20filename%3Dversioned-file.txt");
336
- });
337
- require_vi_bdSIJ99Y.it("should generate version URL without filename", async () => {
338
- const versionKey = "test-files/version-no-name.txt";
339
- const versionId = "test-version-id";
340
- await client.upload(versionKey, testContent, testContentType);
341
- const downloadUrl = await client.getVersionDownloadURL({ path: versionKey }, versionId);
342
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/version-no-name\.txt/);
343
- require_vi_bdSIJ99Y.globalExpect(downloadUrl).not.toContain("response-content-disposition");
344
- });
345
- });
346
- });
347
-
348
- //#endregion
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };