@forge/bridge 5.8.0-next.12 → 5.8.0-next.13
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/out/object-store/index.d.ts +1 -0
- package/out/object-store/index.d.ts.map +1 -1
- package/out/object-store/index.js +1 -0
- package/out/object-store/objectStore.d.ts +2 -0
- package/out/object-store/objectStore.d.ts.map +1 -1
- package/out/object-store/objectStore.js +2 -1
- package/out/object-store/types.d.ts +7 -0
- package/out/object-store/types.d.ts.map +1 -1
- package/out/object-store/upload.d.ts +5 -1
- package/out/object-store/upload.d.ts.map +1 -1
- package/out/object-store/upload.js +54 -30
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @forge/bridge
|
|
2
2
|
|
|
3
|
+
## 5.8.0-next.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f23a84e: Add useObjectStore hook
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [24bd686]
|
|
12
|
+
- Updated dependencies [2011ffe]
|
|
13
|
+
- @forge/manifest@11.0.0-next.8
|
|
14
|
+
|
|
3
15
|
## 5.8.0-next.12
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object-store/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object-store/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createUploadPromises } from './upload';
|
|
1
2
|
export declare const objectStore: {
|
|
2
3
|
upload: ({ functionKey, objects }: {
|
|
3
4
|
functionKey: string;
|
|
@@ -16,4 +17,5 @@ export declare const objectStore: {
|
|
|
16
17
|
keys: string[];
|
|
17
18
|
}) => Promise<void>;
|
|
18
19
|
};
|
|
20
|
+
export { createUploadPromises };
|
|
19
21
|
//# sourceMappingURL=objectStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectStore.d.ts","sourceRoot":"","sources":["../../src/object-store/objectStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"objectStore.d.ts","sourceRoot":"","sources":["../../src/object-store/objectStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKxD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;CAKvB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectStore = void 0;
|
|
3
|
+
exports.createUploadPromises = exports.objectStore = void 0;
|
|
4
4
|
const upload_1 = require("./upload");
|
|
5
|
+
Object.defineProperty(exports, "createUploadPromises", { enumerable: true, get: function () { return upload_1.createUploadPromises; } });
|
|
5
6
|
const deleteObjects_1 = require("./deleteObjects");
|
|
6
7
|
const download_1 = require("./download");
|
|
7
8
|
const getMetadata_1 = require("./getMetadata");
|
|
@@ -6,6 +6,7 @@ export declare type ObjectMetadata = {
|
|
|
6
6
|
export declare type Base64Object = {
|
|
7
7
|
data: string;
|
|
8
8
|
mimeType?: string;
|
|
9
|
+
fileSize?: number;
|
|
9
10
|
};
|
|
10
11
|
export declare type UploadObject = Blob | Base64Object;
|
|
11
12
|
export declare type FileMetadata = ObjectMetadata & {
|
|
@@ -19,6 +20,12 @@ export declare type UploadResult = {
|
|
|
19
20
|
status?: number;
|
|
20
21
|
error?: string;
|
|
21
22
|
};
|
|
23
|
+
export declare type UploadPromiseItem = {
|
|
24
|
+
promise: Promise<UploadResult>;
|
|
25
|
+
index: number;
|
|
26
|
+
objectType?: string;
|
|
27
|
+
objectSize?: number;
|
|
28
|
+
};
|
|
22
29
|
export declare type DownloadResult = {
|
|
23
30
|
success: boolean;
|
|
24
31
|
key: string;
|
|
@@ -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,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,YAAY,GAAG,IAAI,GAAG,YAAY,CAAC;AAE/C,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,M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E,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,4 +1,8 @@
|
|
|
1
|
-
import type { UploadResult, UploadObject } from './types';
|
|
1
|
+
import type { UploadResult, UploadObject, UploadPromiseItem } from './types';
|
|
2
|
+
export declare const createUploadPromises: ({ functionKey, objects }: {
|
|
3
|
+
functionKey: string;
|
|
4
|
+
objects: UploadObject[];
|
|
5
|
+
}) => Promise<UploadPromiseItem[]>;
|
|
2
6
|
export declare const upload: ({ functionKey, objects }: {
|
|
3
7
|
functionKey: string;
|
|
4
8
|
objects: UploadObject[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/object-store/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuC,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/object-store/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuC,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA6ClH,eAAO,MAAM,oBAAoB;iBAIlB,MAAM;aACV,YAAY,EAAE;MACrB,QAAQ,iBAAiB,EAAE,CA0G9B,CAAC;AAUF,eAAO,MAAM,MAAM;iBAIJ,MAAM;aACV,YAAY,EAAE;MACrB,QAAQ,YAAY,EAAE,CAIzB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upload = void 0;
|
|
3
|
+
exports.upload = exports.createUploadPromises = void 0;
|
|
4
4
|
const invoke_1 = require("../invoke");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
6
|
const base64ToBlob = (base64, mimeType) => {
|
|
@@ -25,7 +25,7 @@ const getObjectMetadata = async (blob) => {
|
|
|
25
25
|
checksumType
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
const
|
|
28
|
+
const createUploadPromises = async ({ functionKey, objects }) => {
|
|
29
29
|
if (!functionKey || functionKey.length === 0) {
|
|
30
30
|
throw new errors_1.BridgeAPIError('functionKey is required to filter and generate presigned URLs');
|
|
31
31
|
}
|
|
@@ -55,46 +55,70 @@ const upload = async ({ functionKey, objects }) => {
|
|
|
55
55
|
throw new errors_1.BridgeAPIError('Invalid response from functionKey');
|
|
56
56
|
}
|
|
57
57
|
const checksumToBlobMap = new Map();
|
|
58
|
+
const checksumToIndexMap = new Map();
|
|
58
59
|
blobs.forEach((blob, index) => {
|
|
59
60
|
const metadata = allObjectMetadata[index];
|
|
60
61
|
checksumToBlobMap.set(metadata.checksum, blob);
|
|
62
|
+
checksumToIndexMap.set(metadata.checksum, index);
|
|
61
63
|
});
|
|
62
|
-
const uploadPromises = Object.entries(presignedURLsToObjectMetadata).map(
|
|
63
|
-
const { key,
|
|
64
|
+
const uploadPromises = Object.entries(presignedURLsToObjectMetadata).map(([presignedUrl, metadata]) => {
|
|
65
|
+
const { key, checksum } = metadata;
|
|
64
66
|
const object = checksumToBlobMap.get(checksum);
|
|
65
|
-
|
|
67
|
+
const index = checksumToIndexMap.get(checksum);
|
|
68
|
+
if (index === undefined) {
|
|
66
69
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
promise: Promise.resolve({
|
|
71
|
+
success: false,
|
|
72
|
+
key: key,
|
|
73
|
+
error: `Index not found for checksum ${checksum}`
|
|
74
|
+
}),
|
|
75
|
+
index: -1
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
|
-
|
|
73
|
-
const response = await fetch(presignedUrl, {
|
|
74
|
-
method: 'PUT',
|
|
75
|
-
body: object,
|
|
76
|
-
headers: {
|
|
77
|
-
'Content-Type': object.type || 'application/octet-stream',
|
|
78
|
-
'Content-Length': length.toString()
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
success: response.ok,
|
|
83
|
-
key: key,
|
|
84
|
-
status: response.status,
|
|
85
|
-
error: response.ok ? undefined : `Upload failed with status ${response.status}`
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
78
|
+
if (!object) {
|
|
89
79
|
return {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
promise: Promise.resolve({
|
|
81
|
+
success: false,
|
|
82
|
+
key: key,
|
|
83
|
+
error: `Blob not found for checksum ${checksum}`
|
|
84
|
+
}),
|
|
85
|
+
index
|
|
94
86
|
};
|
|
95
87
|
}
|
|
88
|
+
const uploadPromise = (async () => {
|
|
89
|
+
try {
|
|
90
|
+
const response = await fetch(presignedUrl, {
|
|
91
|
+
method: 'PUT',
|
|
92
|
+
body: object,
|
|
93
|
+
headers: {
|
|
94
|
+
'Content-Type': object.type || 'application/octet-stream',
|
|
95
|
+
'Content-Length': object.size.toString()
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
success: response.ok,
|
|
100
|
+
key: key,
|
|
101
|
+
status: response.status,
|
|
102
|
+
error: response.ok ? undefined : `Upload failed with status ${response.status}`
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return {
|
|
107
|
+
success: false,
|
|
108
|
+
key: key,
|
|
109
|
+
status: 503,
|
|
110
|
+
error: error instanceof Error ? error.message : 'Upload failed'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
return { promise: uploadPromise, index, objectType: object.type, objectSize: object.size };
|
|
96
115
|
});
|
|
97
|
-
|
|
116
|
+
return uploadPromises;
|
|
117
|
+
};
|
|
118
|
+
exports.createUploadPromises = createUploadPromises;
|
|
119
|
+
const upload = async ({ functionKey, objects }) => {
|
|
120
|
+
const uploadPromises = await (0, exports.createUploadPromises)({ functionKey, objects });
|
|
121
|
+
const results = await Promise.all(uploadPromises.map((item) => item.promise));
|
|
98
122
|
return results;
|
|
99
123
|
};
|
|
100
124
|
exports.upload = upload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/bridge",
|
|
3
|
-
"version": "5.8.0-next.
|
|
3
|
+
"version": "5.8.0-next.13",
|
|
4
4
|
"description": "Forge bridge API for custom UI apps",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@forge/resolver": "1.7.1",
|
|
19
19
|
"@statsig/js-client": "3.18.2",
|
|
20
20
|
"@types/history": "^4.7.11",
|
|
21
|
-
"@forge/manifest": "11.0.0-next.
|
|
21
|
+
"@forge/manifest": "11.0.0-next.8"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"history": "5.3.0",
|