@forge/bridge 5.7.0-next.8 → 5.7.0-next.9
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 +6 -0
- package/out/object-store/download.d.ts +4 -4
- package/out/object-store/download.d.ts.map +1 -1
- package/out/object-store/download.js +13 -13
- package/out/object-store/getMetadata.d.ts +6 -0
- package/out/object-store/getMetadata.d.ts.map +1 -0
- package/out/object-store/getMetadata.js +25 -0
- package/out/object-store/types.d.ts +10 -5
- package/out/object-store/types.d.ts.map +1 -1
- package/out/object-store/upload.d.ts +3 -3
- package/out/object-store/upload.d.ts.map +1 -1
- package/out/object-store/upload.js +8 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DownloadResult
|
|
2
|
-
export declare const download: ({
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { DownloadResult } from './types';
|
|
2
|
+
export declare const download: ({ functionKey, keys }: {
|
|
3
|
+
functionKey: string;
|
|
4
|
+
keys: string[];
|
|
5
5
|
}) => Promise<DownloadResult[]>;
|
|
6
6
|
//# sourceMappingURL=download.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/object-store/download.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAsB,
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/object-store/download.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAsB,MAAM,SAAS,CAAC;AAUlE,eAAO,MAAM,QAAQ;iBAIN,MAAM;UACb,MAAM,EAAE;MACZ,QAAQ,cAAc,EAAE,CAqD3B,CAAC"}
|
|
@@ -3,20 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.download = void 0;
|
|
4
4
|
const invoke_1 = require("../invoke");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
|
-
const download = async ({
|
|
7
|
-
if (!
|
|
8
|
-
throw new errors_1.BridgeAPIError('
|
|
6
|
+
const download = async ({ functionKey, keys }) => {
|
|
7
|
+
if (!functionKey || functionKey.length === 0) {
|
|
8
|
+
throw new errors_1.BridgeAPIError('functionKey is required to filter and generate download URLs');
|
|
9
9
|
}
|
|
10
|
-
if (!Array.isArray(
|
|
11
|
-
throw new errors_1.BridgeAPIError('
|
|
10
|
+
if (!Array.isArray(keys) || keys.length === 0) {
|
|
11
|
+
throw new errors_1.BridgeAPIError('keys array is required and must not be empty');
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const downloadUrlsTokeys = (await (0, invoke_1.invoke)(functionKey, {
|
|
14
|
+
keys
|
|
15
15
|
}));
|
|
16
|
-
if (!
|
|
17
|
-
throw new errors_1.BridgeAPIError('Invalid response from
|
|
16
|
+
if (!downloadUrlsTokeys || typeof downloadUrlsTokeys !== 'object') {
|
|
17
|
+
throw new errors_1.BridgeAPIError('Invalid response from functionKey');
|
|
18
18
|
}
|
|
19
|
-
const downloadPromises = Object.entries(
|
|
19
|
+
const downloadPromises = Object.entries(downloadUrlsTokeys).map(async ([downloadUrl, key]) => {
|
|
20
20
|
try {
|
|
21
21
|
const response = await fetch(downloadUrl, {
|
|
22
22
|
method: 'GET'
|
|
@@ -24,7 +24,7 @@ const download = async ({ filterAndGenerateDownloadUrls, objectKeys }) => {
|
|
|
24
24
|
if (!response.ok) {
|
|
25
25
|
return {
|
|
26
26
|
success: false,
|
|
27
|
-
|
|
27
|
+
key: key,
|
|
28
28
|
status: response.status,
|
|
29
29
|
error: `Download failed with status ${response.status}`
|
|
30
30
|
};
|
|
@@ -32,7 +32,7 @@ const download = async ({ filterAndGenerateDownloadUrls, objectKeys }) => {
|
|
|
32
32
|
const blob = await response.blob();
|
|
33
33
|
return {
|
|
34
34
|
success: true,
|
|
35
|
-
|
|
35
|
+
key: key,
|
|
36
36
|
blob,
|
|
37
37
|
status: response.status
|
|
38
38
|
};
|
|
@@ -40,7 +40,7 @@ const download = async ({ filterAndGenerateDownloadUrls, objectKeys }) => {
|
|
|
40
40
|
catch (error) {
|
|
41
41
|
return {
|
|
42
42
|
success: false,
|
|
43
|
-
|
|
43
|
+
key: key,
|
|
44
44
|
status: 503,
|
|
45
45
|
error: error instanceof Error ? error.message : 'Download failed'
|
|
46
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMetadata.d.ts","sourceRoot":"","sources":["../../src/object-store/getMetadata.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAUjD,eAAO,MAAM,WAAW;iBAIT,MAAM;UACb,MAAM,EAAE;MACZ,QAAQ,iBAAiB,EAAE,CAyB9B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadata = void 0;
|
|
4
|
+
const invoke_1 = require("../invoke");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const getMetadata = async ({ functionKey, keys }) => {
|
|
7
|
+
if (!functionKey || functionKey.length === 0) {
|
|
8
|
+
throw new errors_1.BridgeAPIError('functionKey is required to filter and generate object metadata');
|
|
9
|
+
}
|
|
10
|
+
if (!Array.isArray(keys) || keys.length === 0) {
|
|
11
|
+
throw new errors_1.BridgeAPIError('keys array is required and must not be empty');
|
|
12
|
+
}
|
|
13
|
+
const results = await Promise.all(keys.map(async (key) => {
|
|
14
|
+
const result = (await (0, invoke_1.invoke)(functionKey, { key }));
|
|
15
|
+
if (!result || typeof result !== 'object') {
|
|
16
|
+
return {
|
|
17
|
+
key: key,
|
|
18
|
+
error: 'Invalid response from functionKey'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}));
|
|
23
|
+
return results;
|
|
24
|
+
};
|
|
25
|
+
exports.getMetadata = getMetadata;
|
|
@@ -3,9 +3,6 @@ export declare type ObjectMetadata = {
|
|
|
3
3
|
checksum: string;
|
|
4
4
|
checksumType: string;
|
|
5
5
|
};
|
|
6
|
-
export declare type FilterAndGenerateUrls = {
|
|
7
|
-
function: string;
|
|
8
|
-
};
|
|
9
6
|
export declare type FileMetadata = ObjectMetadata & {
|
|
10
7
|
key: string;
|
|
11
8
|
ttlSeconds?: number;
|
|
@@ -13,13 +10,13 @@ export declare type FileMetadata = ObjectMetadata & {
|
|
|
13
10
|
};
|
|
14
11
|
export declare type UploadResult = {
|
|
15
12
|
success: boolean;
|
|
16
|
-
|
|
13
|
+
key: string;
|
|
17
14
|
status?: number;
|
|
18
15
|
error?: string;
|
|
19
16
|
};
|
|
20
17
|
export declare type DownloadResult = {
|
|
21
18
|
success: boolean;
|
|
22
|
-
|
|
19
|
+
key: string;
|
|
23
20
|
blob?: Blob;
|
|
24
21
|
status?: number;
|
|
25
22
|
error?: string;
|
|
@@ -30,4 +27,12 @@ export declare type PresignedURLMapping = {
|
|
|
30
27
|
export declare type DownloadURLMapping = {
|
|
31
28
|
[url: string]: string;
|
|
32
29
|
};
|
|
30
|
+
export declare type GetMetadataResult = {
|
|
31
|
+
key: string;
|
|
32
|
+
checksum?: string;
|
|
33
|
+
size?: number;
|
|
34
|
+
createdAt?: string;
|
|
35
|
+
currentVersion?: string;
|
|
36
|
+
error?: string;
|
|
37
|
+
};
|
|
33
38
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/object-store/types.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/object-store/types.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,YAAY,GAAG,cAAc,GAAG;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,cAAc,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,mBAAmB,GAAG;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC;CAC7B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE3D,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const upload: ({
|
|
3
|
-
|
|
1
|
+
import type { UploadResult } from './types';
|
|
2
|
+
export declare const upload: ({ functionKey, objects }: {
|
|
3
|
+
functionKey: string;
|
|
4
4
|
objects: Blob[];
|
|
5
5
|
}) => Promise<UploadResult[]>;
|
|
6
6
|
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/object-store/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuC,
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/object-store/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuC,YAAY,EAAE,MAAM,SAAS,CAAC;AA8BjF,eAAO,MAAM,MAAM;iBAIJ,MAAM;aACV,IAAI,EAAE;MACb,QAAQ,YAAY,EAAE,CAkEzB,CAAC"}
|
|
@@ -16,19 +16,19 @@ const getObjectMetadata = async (blob) => {
|
|
|
16
16
|
checksumType
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
const upload = async ({
|
|
20
|
-
if (!
|
|
21
|
-
throw new errors_1.BridgeAPIError('
|
|
19
|
+
const upload = async ({ functionKey, objects }) => {
|
|
20
|
+
if (!functionKey || functionKey.length === 0) {
|
|
21
|
+
throw new errors_1.BridgeAPIError('functionKey is required to filter and generate presigned URLs');
|
|
22
22
|
}
|
|
23
23
|
if (!Array.isArray(objects) || objects.length === 0) {
|
|
24
24
|
throw new errors_1.BridgeAPIError('objects array is required and must not be empty');
|
|
25
25
|
}
|
|
26
26
|
const allObjectMetadata = await Promise.all(objects.map((obj) => getObjectMetadata(obj)));
|
|
27
|
-
const presignedURLsToObjectMetadata = (await (0, invoke_1.invoke)(
|
|
27
|
+
const presignedURLsToObjectMetadata = (await (0, invoke_1.invoke)(functionKey, {
|
|
28
28
|
allObjectMetadata
|
|
29
29
|
}));
|
|
30
30
|
if (!presignedURLsToObjectMetadata || typeof presignedURLsToObjectMetadata !== 'object') {
|
|
31
|
-
throw new errors_1.BridgeAPIError('Invalid response from
|
|
31
|
+
throw new errors_1.BridgeAPIError('Invalid response from functionKey');
|
|
32
32
|
}
|
|
33
33
|
const checksumToBlobMap = new Map();
|
|
34
34
|
objects.forEach((blob, index) => {
|
|
@@ -41,7 +41,7 @@ const upload = async ({ filterAndGenerateUrls, objects }) => {
|
|
|
41
41
|
if (!object) {
|
|
42
42
|
return {
|
|
43
43
|
success: false,
|
|
44
|
-
|
|
44
|
+
key: key,
|
|
45
45
|
error: `Blob not found for checksum ${checksum}`
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -56,7 +56,7 @@ const upload = async ({ filterAndGenerateUrls, objects }) => {
|
|
|
56
56
|
});
|
|
57
57
|
return {
|
|
58
58
|
success: response.ok,
|
|
59
|
-
|
|
59
|
+
key: key,
|
|
60
60
|
status: response.status,
|
|
61
61
|
error: response.ok ? undefined : `Upload failed with status ${response.status}`
|
|
62
62
|
};
|
|
@@ -64,7 +64,7 @@ const upload = async ({ filterAndGenerateUrls, objects }) => {
|
|
|
64
64
|
catch (error) {
|
|
65
65
|
return {
|
|
66
66
|
success: false,
|
|
67
|
-
|
|
67
|
+
key: key,
|
|
68
68
|
status: 503,
|
|
69
69
|
error: error instanceof Error ? error.message : 'Upload failed'
|
|
70
70
|
};
|