@geekmidas/storage 0.0.4 → 0.1.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/README.md +71 -1
- package/dist/{AmazonStorageClient-DT9DeKVz.cjs → AmazonStorageClient-BKzXhCX0.cjs} +40 -10
- package/dist/AmazonStorageClient-BKzXhCX0.cjs.map +1 -0
- package/dist/{AmazonStorageClient-DJMWn8vO.mjs → AmazonStorageClient-CwUey48q.mjs} +15 -7
- package/dist/AmazonStorageClient-CwUey48q.mjs.map +1 -0
- package/dist/{AmazonStorageClient-C16fG3G4.d.cts → AmazonStorageClient-Gz0Fh1sy.d.mts} +7 -3
- package/dist/{AmazonStorageClient-CP8Tx5oE.d.mts → AmazonStorageClient-aduVU3_p.d.cts} +7 -3
- package/dist/AmazonStorageClient.cjs +1 -1
- package/dist/AmazonStorageClient.d.cts +2 -2
- package/dist/AmazonStorageClient.d.mts +2 -2
- package/dist/AmazonStorageClient.mjs +2 -2
- package/dist/{StorageClient-CZGIC_fz.mjs → StorageClient-4ADnTPnJ.mjs} +2 -1
- package/dist/StorageClient-4ADnTPnJ.mjs.map +1 -0
- package/dist/StorageClient-BDRVrMJj.cjs +2 -1
- package/dist/StorageClient-BDRVrMJj.cjs.map +1 -0
- package/dist/{StorageClient-D-y4QLDq.d.cts → StorageClient-CcOAW3YV.d.cts} +5 -1
- package/dist/{StorageClient-CJbHRTVV.d.mts → StorageClient-XgMsiUrd.d.mts} +5 -1
- package/dist/StorageClient.d.cts +1 -1
- package/dist/StorageClient.d.mts +1 -1
- package/dist/StorageClient.mjs +1 -1
- package/dist/aws.cjs +1 -1
- package/dist/aws.d.cts +2 -2
- package/dist/aws.d.mts +2 -2
- package/dist/aws.mjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/package.json +28 -3
- package/src/AmazonStorageClient.ts +22 -3
- package/src/StorageClient.ts +2 -0
- package/src/__tests__/AmazonStorageClient.spec.ts +183 -0
- package/dist/__tests__/AmazonStorageClient.spec.cjs +0 -234
- package/dist/__tests__/AmazonStorageClient.spec.d.cts +0 -1
- package/dist/__tests__/AmazonStorageClient.spec.d.mts +0 -1
- package/dist/__tests__/AmazonStorageClient.spec.mjs +0 -233
- package/dist/__tests__/StorageClient.spec.cjs +0 -81
- package/dist/__tests__/StorageClient.spec.d.cts +0 -1
- package/dist/__tests__/StorageClient.spec.d.mts +0 -1
- package/dist/__tests__/StorageClient.spec.mjs +0 -81
- package/dist/chunk-DWy1uDak.cjs +0 -39
- package/dist/magic-string.es-BvJNBYzY.mjs +0 -1014
- package/dist/magic-string.es-CKiDiYoS.cjs +0 -1015
- package/dist/vi.bdSIJ99Y-CucmVasy.mjs +0 -14928
- package/dist/vi.bdSIJ99Y-D0m6qImj.cjs +0 -14926
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { beforeAll, describe, globalExpect, it } from "../vi.bdSIJ99Y-CucmVasy.mjs";
|
|
2
|
-
import { StorageProvider } from "../StorageClient-CZGIC_fz.mjs";
|
|
3
|
-
import { AmazonCannedAccessControlList, AmazonStorageClient } from "../AmazonStorageClient-DJMWn8vO.mjs";
|
|
4
|
-
import { S3Client } from "@aws-sdk/client-s3";
|
|
5
|
-
|
|
6
|
-
//#region src/__tests__/AmazonStorageClient.spec.ts
|
|
7
|
-
describe("AmazonStorageClient Integration Tests", () => {
|
|
8
|
-
let client;
|
|
9
|
-
const testBucket = "geekmidas";
|
|
10
|
-
const testKey = "test-files/test.txt";
|
|
11
|
-
const testContent = "Hello, World!";
|
|
12
|
-
const testContentType = "text/plain";
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
client = AmazonStorageClient.create({
|
|
15
|
-
bucket: testBucket,
|
|
16
|
-
region: "us-east-1",
|
|
17
|
-
accessKeyId: "geekmidas",
|
|
18
|
-
secretAccessKey: "geekmidas",
|
|
19
|
-
endpoint: "http://localhost:9000",
|
|
20
|
-
acl: AmazonCannedAccessControlList.PublicRead,
|
|
21
|
-
forcePathStyle: true
|
|
22
|
-
});
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
24
|
-
});
|
|
25
|
-
describe("provider property", () => {
|
|
26
|
-
it("should return AWS S3 provider", () => {
|
|
27
|
-
globalExpect(client.provider).toBe(StorageProvider.AWSS3);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe("upload and download workflow", () => {
|
|
31
|
-
it.skip("should upload a file directly and generate download URL", async () => {
|
|
32
|
-
await client.upload(testKey, testContent, testContentType);
|
|
33
|
-
const downloadUrl = await client.getDownloadURL({ path: testKey });
|
|
34
|
-
globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/test\.txt/);
|
|
35
|
-
globalExpect(downloadUrl).toContain("X-Amz-Algorithm=AWS4-HMAC-SHA256");
|
|
36
|
-
globalExpect(downloadUrl).toContain("X-Amz-Credential=");
|
|
37
|
-
globalExpect(downloadUrl).toContain("X-Amz-Date=");
|
|
38
|
-
globalExpect(downloadUrl).toContain("X-Amz-SignedHeaders=");
|
|
39
|
-
globalExpect(downloadUrl).toContain("X-Amz-Signature=");
|
|
40
|
-
const response = await fetch(downloadUrl);
|
|
41
|
-
globalExpect(response.ok).toBe(true);
|
|
42
|
-
const downloadedContent = await response.text();
|
|
43
|
-
globalExpect(downloadedContent).toBe(testContent);
|
|
44
|
-
});
|
|
45
|
-
it("should upload a file with filename and generate download URL with content disposition", async () => {
|
|
46
|
-
const keyWithName = "test-files/named-file.txt";
|
|
47
|
-
const fileName = "my-document.txt";
|
|
48
|
-
await client.upload(keyWithName, testContent, testContentType);
|
|
49
|
-
const downloadUrl = await client.getDownloadURL({
|
|
50
|
-
path: keyWithName,
|
|
51
|
-
name: fileName
|
|
52
|
-
});
|
|
53
|
-
globalExpect(downloadUrl).toContain("response-content-disposition=attachment%3B%20filename%3Dmy-document.txt");
|
|
54
|
-
});
|
|
55
|
-
it("should handle binary data upload", async () => {
|
|
56
|
-
const binaryKey = "test-files/binary.bin";
|
|
57
|
-
const binaryData = Buffer.from([
|
|
58
|
-
72,
|
|
59
|
-
101,
|
|
60
|
-
108,
|
|
61
|
-
108,
|
|
62
|
-
111
|
|
63
|
-
]);
|
|
64
|
-
await client.upload(binaryKey, binaryData, "application/octet-stream");
|
|
65
|
-
const downloadUrl = await client.getDownloadURL({ path: binaryKey });
|
|
66
|
-
const response = await fetch(downloadUrl);
|
|
67
|
-
const downloadedBuffer = await response.arrayBuffer();
|
|
68
|
-
globalExpect(new Uint8Array(downloadedBuffer)).toEqual(new Uint8Array(binaryData));
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("presigned upload URLs", () => {
|
|
72
|
-
it("should generate presigned PUT upload URL", async () => {
|
|
73
|
-
const uploadKey = "test-files/presigned-upload.txt";
|
|
74
|
-
const uploadUrl = await client.getUploadURL({
|
|
75
|
-
path: uploadKey,
|
|
76
|
-
contentType: testContentType,
|
|
77
|
-
contentLength: testContent.length
|
|
78
|
-
});
|
|
79
|
-
globalExpect(uploadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/test-files\/presigned-upload\.txt/);
|
|
80
|
-
globalExpect(uploadUrl).toContain("X-Amz-Algorithm=AWS4-HMAC-SHA256");
|
|
81
|
-
const uploadResponse = await fetch(uploadUrl, {
|
|
82
|
-
method: "PUT",
|
|
83
|
-
headers: {
|
|
84
|
-
"Content-Type": testContentType,
|
|
85
|
-
"Content-Length": testContent.length.toString()
|
|
86
|
-
},
|
|
87
|
-
body: testContent
|
|
88
|
-
});
|
|
89
|
-
globalExpect(uploadResponse.ok).toBe(true);
|
|
90
|
-
const downloadUrl = await client.getDownloadURL({ path: uploadKey });
|
|
91
|
-
const downloadResponse = await fetch(downloadUrl);
|
|
92
|
-
const downloadedContent = await downloadResponse.text();
|
|
93
|
-
globalExpect(downloadedContent).toBe(testContent);
|
|
94
|
-
});
|
|
95
|
-
it("should generate presigned POST upload with form fields", async () => {
|
|
96
|
-
const uploadKey = "test-files/presigned-post.txt";
|
|
97
|
-
const uploadData = await client.getUpload({
|
|
98
|
-
path: uploadKey,
|
|
99
|
-
contentType: testContentType,
|
|
100
|
-
contentLength: testContent.length
|
|
101
|
-
});
|
|
102
|
-
globalExpect(uploadData.url).toBe("http://localhost:9000/geekmidas");
|
|
103
|
-
globalExpect(uploadData.fields).toContainEqual({
|
|
104
|
-
key: "key",
|
|
105
|
-
value: uploadKey
|
|
106
|
-
});
|
|
107
|
-
globalExpect(uploadData.fields).toContainEqual({
|
|
108
|
-
key: "acl",
|
|
109
|
-
value: "public-read"
|
|
110
|
-
});
|
|
111
|
-
const formData = new FormData();
|
|
112
|
-
uploadData.fields.forEach(({ key, value }) => {
|
|
113
|
-
formData.append(key, value);
|
|
114
|
-
});
|
|
115
|
-
formData.append("file", new Blob([testContent], { type: testContentType }));
|
|
116
|
-
const uploadResponse = await fetch(uploadData.url, {
|
|
117
|
-
method: "POST",
|
|
118
|
-
body: formData
|
|
119
|
-
});
|
|
120
|
-
globalExpect(uploadResponse.ok).toBe(true);
|
|
121
|
-
const downloadUrl = await client.getDownloadURL({ path: uploadKey });
|
|
122
|
-
const downloadResponse = await fetch(downloadUrl);
|
|
123
|
-
const downloadedContent = await downloadResponse.blob();
|
|
124
|
-
globalExpect(downloadedContent).toEqual(new Blob([testContent], { type: testContentType }));
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe("versioning", () => {
|
|
128
|
-
it("should handle file versions", async () => {
|
|
129
|
-
const versionKey = "test-files/versioned.txt";
|
|
130
|
-
const content1 = "Version 1";
|
|
131
|
-
const content2 = "Version 2";
|
|
132
|
-
await client.upload(versionKey, content1, testContentType);
|
|
133
|
-
await client.upload(versionKey, content2, testContentType);
|
|
134
|
-
const versions = await client.getVersions(versionKey);
|
|
135
|
-
globalExpect(Array.isArray(versions)).toBe(true);
|
|
136
|
-
if (versions.length > 0) {
|
|
137
|
-
globalExpect(versions[0]).toHaveProperty("id");
|
|
138
|
-
globalExpect(versions[0]).toHaveProperty("createdAt");
|
|
139
|
-
globalExpect(versions[0].createdAt).toBeInstanceOf(Date);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
describe("error handling", () => {
|
|
144
|
-
it("should handle download URL generation for non-existent files", async () => {
|
|
145
|
-
const downloadUrl = await client.getDownloadURL({ path: "non-existent/file.txt" });
|
|
146
|
-
globalExpect(downloadUrl).toMatch(/^http:\/\/localhost:9000\/geekmidas\/non-existent\/file\.txt/);
|
|
147
|
-
const response = await fetch(downloadUrl);
|
|
148
|
-
globalExpect(response.status).toBe(404);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
describe("custom expiration times", () => {
|
|
152
|
-
it("should respect custom expiration for download URLs", async () => {
|
|
153
|
-
const key = "test-files/expiration-test.txt";
|
|
154
|
-
await client.upload(key, testContent, testContentType);
|
|
155
|
-
const shortExpirationUrl = await client.getDownloadURL({ path: key }, 1);
|
|
156
|
-
const longExpirationUrl = await client.getDownloadURL({ path: key }, 3600);
|
|
157
|
-
globalExpect(shortExpirationUrl).toContain("X-Amz-Expires=1");
|
|
158
|
-
globalExpect(longExpirationUrl).toContain("X-Amz-Expires=3600");
|
|
159
|
-
});
|
|
160
|
-
it("should respect custom expiration for upload URLs", async () => {
|
|
161
|
-
const key = "test-files/upload-expiration-test.txt";
|
|
162
|
-
const shortExpirationUrl = await client.getUploadURL({
|
|
163
|
-
path: key,
|
|
164
|
-
contentType: testContentType,
|
|
165
|
-
contentLength: testContent.length
|
|
166
|
-
}, 1);
|
|
167
|
-
const longExpirationUrl = await client.getUploadURL({
|
|
168
|
-
path: key,
|
|
169
|
-
contentType: testContentType,
|
|
170
|
-
contentLength: testContent.length
|
|
171
|
-
}, 3600);
|
|
172
|
-
globalExpect(shortExpirationUrl).toContain("X-Amz-Expires=1");
|
|
173
|
-
globalExpect(longExpirationUrl).toContain("X-Amz-Expires=3600");
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe("factory method", () => {
|
|
177
|
-
it("should create client with minimal configuration", () => {
|
|
178
|
-
const minimalClient = AmazonStorageClient.create({ bucket: "geekmidas" });
|
|
179
|
-
globalExpect(minimalClient).toBeInstanceOf(AmazonStorageClient);
|
|
180
|
-
globalExpect(minimalClient.provider).toBe(StorageProvider.AWSS3);
|
|
181
|
-
});
|
|
182
|
-
it("should create client with full configuration", () => {
|
|
183
|
-
const fullClient = AmazonStorageClient.create({
|
|
184
|
-
bucket: "geekmidas",
|
|
185
|
-
region: "us-west-2",
|
|
186
|
-
accessKeyId: "test-key",
|
|
187
|
-
secretAccessKey: "test-secret",
|
|
188
|
-
endpoint: "https://custom-s3.example.com",
|
|
189
|
-
acl: AmazonCannedAccessControlList.Private
|
|
190
|
-
});
|
|
191
|
-
globalExpect(fullClient).toBeInstanceOf(AmazonStorageClient);
|
|
192
|
-
globalExpect(fullClient.provider).toBe(StorageProvider.AWSS3);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe("different ACL configurations", () => {
|
|
196
|
-
it("should work with different ACL settings", async () => {
|
|
197
|
-
const privateClient = AmazonStorageClient.create({
|
|
198
|
-
bucket: testBucket,
|
|
199
|
-
region: "us-east-1",
|
|
200
|
-
accessKeyId: "minioadmin",
|
|
201
|
-
secretAccessKey: "minioadmin",
|
|
202
|
-
endpoint: "http://localhost:9000",
|
|
203
|
-
acl: AmazonCannedAccessControlList.Private
|
|
204
|
-
});
|
|
205
|
-
const uploadData = await privateClient.getUpload({
|
|
206
|
-
path: "test-files/private.txt",
|
|
207
|
-
contentType: testContentType,
|
|
208
|
-
contentLength: testContent.length
|
|
209
|
-
});
|
|
210
|
-
globalExpect(uploadData.fields).toContainEqual({
|
|
211
|
-
key: "acl",
|
|
212
|
-
value: "private"
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
describe("S3Client integration", () => {
|
|
217
|
-
it("should work with externally created S3Client", () => {
|
|
218
|
-
const s3Client = new S3Client({
|
|
219
|
-
region: "us-east-1",
|
|
220
|
-
credentials: {
|
|
221
|
-
accessKeyId: "minioadmin",
|
|
222
|
-
secretAccessKey: "minioadmin"
|
|
223
|
-
},
|
|
224
|
-
endpoint: "http://localhost:9000"
|
|
225
|
-
});
|
|
226
|
-
const storageClient = new AmazonStorageClient(s3Client, testBucket, AmazonCannedAccessControlList.PublicRead);
|
|
227
|
-
globalExpect(storageClient).toBeInstanceOf(AmazonStorageClient);
|
|
228
|
-
globalExpect(storageClient.provider).toBe(StorageProvider.AWSS3);
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
const require_StorageClient = require('../StorageClient-BDRVrMJj.cjs');
|
|
2
|
-
const require_vi_bdSIJ99Y = require('../vi.bdSIJ99Y-D0m6qImj.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/__tests__/StorageClient.spec.ts
|
|
5
|
-
require_vi_bdSIJ99Y.describe("StorageClient", () => {
|
|
6
|
-
require_vi_bdSIJ99Y.describe("StorageProvider enum", () => {
|
|
7
|
-
require_vi_bdSIJ99Y.it("should have correct provider values", () => {
|
|
8
|
-
require_vi_bdSIJ99Y.globalExpect(require_StorageClient.StorageProvider.AWSS3).toBe("geekimdas.toolbox.storage.aws.s3");
|
|
9
|
-
require_vi_bdSIJ99Y.globalExpect(require_StorageClient.StorageProvider.GCP).toBe("geekimdas.toolbox.storage.gcp");
|
|
10
|
-
require_vi_bdSIJ99Y.globalExpect(require_StorageClient.StorageProvider.AZURE).toBe("geekimdas.toolbox.storage.azure");
|
|
11
|
-
});
|
|
12
|
-
require_vi_bdSIJ99Y.it("should have unique provider values", () => {
|
|
13
|
-
const values = Object.values(require_StorageClient.StorageProvider);
|
|
14
|
-
const uniqueValues = new Set(values);
|
|
15
|
-
require_vi_bdSIJ99Y.globalExpect(uniqueValues.size).toBe(values.length);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
require_vi_bdSIJ99Y.describe("interfaces", () => {
|
|
19
|
-
require_vi_bdSIJ99Y.it("should define DocumentVersion interface correctly", () => {
|
|
20
|
-
const version = {
|
|
21
|
-
id: "test-id",
|
|
22
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
23
|
-
};
|
|
24
|
-
require_vi_bdSIJ99Y.globalExpect(version.id).toBe("test-id");
|
|
25
|
-
require_vi_bdSIJ99Y.globalExpect(version.createdAt).toBeInstanceOf(Date);
|
|
26
|
-
});
|
|
27
|
-
require_vi_bdSIJ99Y.it("should define File interface correctly", () => {
|
|
28
|
-
const file = { path: "test/path.txt" };
|
|
29
|
-
require_vi_bdSIJ99Y.globalExpect(file.path).toBe("test/path.txt");
|
|
30
|
-
require_vi_bdSIJ99Y.globalExpect(file.name).toBeUndefined();
|
|
31
|
-
const fileWithName = {
|
|
32
|
-
path: "test/path.txt",
|
|
33
|
-
name: "display-name.txt"
|
|
34
|
-
};
|
|
35
|
-
require_vi_bdSIJ99Y.globalExpect(fileWithName.path).toBe("test/path.txt");
|
|
36
|
-
require_vi_bdSIJ99Y.globalExpect(fileWithName.name).toBe("display-name.txt");
|
|
37
|
-
});
|
|
38
|
-
require_vi_bdSIJ99Y.it("should define GetUploadParams interface correctly", () => {
|
|
39
|
-
const params = {
|
|
40
|
-
path: "test/upload.txt",
|
|
41
|
-
contentType: "text/plain",
|
|
42
|
-
contentLength: 100
|
|
43
|
-
};
|
|
44
|
-
require_vi_bdSIJ99Y.globalExpect(params.path).toBe("test/upload.txt");
|
|
45
|
-
require_vi_bdSIJ99Y.globalExpect(params.contentType).toBe("text/plain");
|
|
46
|
-
require_vi_bdSIJ99Y.globalExpect(params.contentLength).toBe(100);
|
|
47
|
-
});
|
|
48
|
-
require_vi_bdSIJ99Y.it("should define GetUploadResponse interface correctly", () => {
|
|
49
|
-
const response = {
|
|
50
|
-
url: "https://example.com/upload",
|
|
51
|
-
fields: [{
|
|
52
|
-
key: "key",
|
|
53
|
-
value: "test/path.txt"
|
|
54
|
-
}, {
|
|
55
|
-
key: "acl",
|
|
56
|
-
value: "public-read"
|
|
57
|
-
}]
|
|
58
|
-
};
|
|
59
|
-
require_vi_bdSIJ99Y.globalExpect(response.url).toBe("https://example.com/upload");
|
|
60
|
-
require_vi_bdSIJ99Y.globalExpect(response.fields).toHaveLength(2);
|
|
61
|
-
require_vi_bdSIJ99Y.globalExpect(response.fields[0]).toEqual({
|
|
62
|
-
key: "key",
|
|
63
|
-
value: "test/path.txt"
|
|
64
|
-
});
|
|
65
|
-
require_vi_bdSIJ99Y.globalExpect(response.fields[1]).toEqual({
|
|
66
|
-
key: "acl",
|
|
67
|
-
value: "public-read"
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
require_vi_bdSIJ99Y.it("should define UploadField type correctly", () => {
|
|
71
|
-
const field = {
|
|
72
|
-
key: "test-key",
|
|
73
|
-
value: "test-value"
|
|
74
|
-
};
|
|
75
|
-
require_vi_bdSIJ99Y.globalExpect(field.key).toBe("test-key");
|
|
76
|
-
require_vi_bdSIJ99Y.globalExpect(field.value).toBe("test-value");
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { describe, globalExpect, it } from "../vi.bdSIJ99Y-CucmVasy.mjs";
|
|
2
|
-
import { StorageProvider } from "../StorageClient-CZGIC_fz.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/__tests__/StorageClient.spec.ts
|
|
5
|
-
describe("StorageClient", () => {
|
|
6
|
-
describe("StorageProvider enum", () => {
|
|
7
|
-
it("should have correct provider values", () => {
|
|
8
|
-
globalExpect(StorageProvider.AWSS3).toBe("geekimdas.toolbox.storage.aws.s3");
|
|
9
|
-
globalExpect(StorageProvider.GCP).toBe("geekimdas.toolbox.storage.gcp");
|
|
10
|
-
globalExpect(StorageProvider.AZURE).toBe("geekimdas.toolbox.storage.azure");
|
|
11
|
-
});
|
|
12
|
-
it("should have unique provider values", () => {
|
|
13
|
-
const values = Object.values(StorageProvider);
|
|
14
|
-
const uniqueValues = new Set(values);
|
|
15
|
-
globalExpect(uniqueValues.size).toBe(values.length);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe("interfaces", () => {
|
|
19
|
-
it("should define DocumentVersion interface correctly", () => {
|
|
20
|
-
const version = {
|
|
21
|
-
id: "test-id",
|
|
22
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
23
|
-
};
|
|
24
|
-
globalExpect(version.id).toBe("test-id");
|
|
25
|
-
globalExpect(version.createdAt).toBeInstanceOf(Date);
|
|
26
|
-
});
|
|
27
|
-
it("should define File interface correctly", () => {
|
|
28
|
-
const file = { path: "test/path.txt" };
|
|
29
|
-
globalExpect(file.path).toBe("test/path.txt");
|
|
30
|
-
globalExpect(file.name).toBeUndefined();
|
|
31
|
-
const fileWithName = {
|
|
32
|
-
path: "test/path.txt",
|
|
33
|
-
name: "display-name.txt"
|
|
34
|
-
};
|
|
35
|
-
globalExpect(fileWithName.path).toBe("test/path.txt");
|
|
36
|
-
globalExpect(fileWithName.name).toBe("display-name.txt");
|
|
37
|
-
});
|
|
38
|
-
it("should define GetUploadParams interface correctly", () => {
|
|
39
|
-
const params = {
|
|
40
|
-
path: "test/upload.txt",
|
|
41
|
-
contentType: "text/plain",
|
|
42
|
-
contentLength: 100
|
|
43
|
-
};
|
|
44
|
-
globalExpect(params.path).toBe("test/upload.txt");
|
|
45
|
-
globalExpect(params.contentType).toBe("text/plain");
|
|
46
|
-
globalExpect(params.contentLength).toBe(100);
|
|
47
|
-
});
|
|
48
|
-
it("should define GetUploadResponse interface correctly", () => {
|
|
49
|
-
const response = {
|
|
50
|
-
url: "https://example.com/upload",
|
|
51
|
-
fields: [{
|
|
52
|
-
key: "key",
|
|
53
|
-
value: "test/path.txt"
|
|
54
|
-
}, {
|
|
55
|
-
key: "acl",
|
|
56
|
-
value: "public-read"
|
|
57
|
-
}]
|
|
58
|
-
};
|
|
59
|
-
globalExpect(response.url).toBe("https://example.com/upload");
|
|
60
|
-
globalExpect(response.fields).toHaveLength(2);
|
|
61
|
-
globalExpect(response.fields[0]).toEqual({
|
|
62
|
-
key: "key",
|
|
63
|
-
value: "test/path.txt"
|
|
64
|
-
});
|
|
65
|
-
globalExpect(response.fields[1]).toEqual({
|
|
66
|
-
key: "acl",
|
|
67
|
-
value: "public-read"
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
it("should define UploadField type correctly", () => {
|
|
71
|
-
const field = {
|
|
72
|
-
key: "test-key",
|
|
73
|
-
value: "test-value"
|
|
74
|
-
};
|
|
75
|
-
globalExpect(field.key).toBe("test-key");
|
|
76
|
-
globalExpect(field.value).toBe("test-value");
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
//#endregion
|
package/dist/chunk-DWy1uDak.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(exports, '__commonJS', {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return __commonJS;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, '__toESM', {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return __toESM;
|
|
38
|
-
}
|
|
39
|
-
});
|