@bluecopa/core 0.1.25 → 0.1.27
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export interface FileDownloadRequest {
|
|
2
2
|
fileId: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
method?: 'GET' | 'PUT';
|
|
3
5
|
}
|
|
4
6
|
/**
|
|
5
7
|
* Downloads a file from S3 using presigned URL
|
|
@@ -8,4 +10,4 @@ export interface FileDownloadRequest {
|
|
|
8
10
|
* @returns Promise<any> The file data
|
|
9
11
|
* @throws Error if the request fails
|
|
10
12
|
*/
|
|
11
|
-
export declare function fileDownload({ fileId, }: FileDownloadRequest): Promise<any>;
|
|
13
|
+
export declare function fileDownload({ fileId, contentType, method, }: FileDownloadRequest): Promise<any>;
|
|
@@ -3,7 +3,6 @@ export interface FileUploadRequest {
|
|
|
3
3
|
contentType?: string;
|
|
4
4
|
method?: string;
|
|
5
5
|
data: any;
|
|
6
|
-
uploadType?: string;
|
|
7
6
|
}
|
|
8
7
|
export interface FileUploadResponse {
|
|
9
8
|
fileId: string;
|
|
@@ -15,8 +14,7 @@ export interface FileUploadResponse {
|
|
|
15
14
|
* @param params.contentType - Optional: Content type (defaults to 'application/json')
|
|
16
15
|
* @param params.method - Optional: HTTP method (defaults to 'PUT')
|
|
17
16
|
* @param params.data - Required: The data to upload
|
|
18
|
-
* @param params.uploadType - Optional: Upload type for path generation (defaults to 'DEFINITION')
|
|
19
17
|
* @returns Promise<FileUploadResponse> The file ID/path
|
|
20
18
|
* @throws Error if the request fails
|
|
21
19
|
*/
|
|
22
|
-
export declare function fileUpload({ path, contentType, method, data,
|
|
20
|
+
export declare function fileUpload({ path, contentType, method, data, }: FileUploadRequest): Promise<FileUploadResponse>;
|
|
@@ -4,9 +4,6 @@ export interface CreateOrUpdateFormRequest {
|
|
|
4
4
|
}
|
|
5
5
|
export interface CreateOrUpdateFormResponse {
|
|
6
6
|
data: Form;
|
|
7
|
-
processSheetId: string;
|
|
8
|
-
isDummy: boolean;
|
|
9
|
-
formInstanceId: string;
|
|
10
7
|
}
|
|
11
8
|
/**
|
|
12
9
|
* Creates or updates a form
|
|
@@ -15,4 +12,4 @@ export interface CreateOrUpdateFormResponse {
|
|
|
15
12
|
* @returns Promise<Form> The created or updated form
|
|
16
13
|
* @throws Error if the request fails
|
|
17
14
|
*/
|
|
18
|
-
export declare function createOrUpdateForm(
|
|
15
|
+
export declare function createOrUpdateForm({ data, }: CreateOrUpdateFormRequest): Promise<Form>;
|
package/dist/index.es.js
CHANGED
|
@@ -218,25 +218,32 @@ async function fileUpload({
|
|
|
218
218
|
path,
|
|
219
219
|
contentType,
|
|
220
220
|
method,
|
|
221
|
-
data
|
|
222
|
-
uploadType
|
|
221
|
+
data
|
|
223
222
|
}) {
|
|
224
223
|
var _a, _b, _c;
|
|
225
224
|
try {
|
|
226
|
-
if (!data) {
|
|
225
|
+
if (!data || !path) {
|
|
227
226
|
throw { message: "Data is required", status: 400 };
|
|
228
227
|
}
|
|
229
|
-
const response = await apiClient.post("/file/
|
|
230
|
-
path,
|
|
228
|
+
const response = await apiClient.post("/file/url", {
|
|
229
|
+
key: path,
|
|
231
230
|
contentType,
|
|
232
|
-
method
|
|
233
|
-
data,
|
|
234
|
-
uploadType
|
|
231
|
+
method
|
|
235
232
|
});
|
|
236
|
-
if (!response.data || !response.data.
|
|
233
|
+
if (!response.data || !response.data.url) {
|
|
237
234
|
throw { message: "Failed to upload file", status: 500 };
|
|
238
235
|
}
|
|
239
|
-
|
|
236
|
+
const fileUploadUrl = response.data.url;
|
|
237
|
+
const config = {
|
|
238
|
+
method,
|
|
239
|
+
url: fileUploadUrl,
|
|
240
|
+
headers: {
|
|
241
|
+
"Content-Type": contentType
|
|
242
|
+
},
|
|
243
|
+
data
|
|
244
|
+
};
|
|
245
|
+
await axios(config);
|
|
246
|
+
return { fileId: path };
|
|
240
247
|
} catch (error) {
|
|
241
248
|
const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while uploading file";
|
|
242
249
|
const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
|
|
@@ -244,20 +251,24 @@ async function fileUpload({
|
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
async function fileDownload({
|
|
247
|
-
fileId
|
|
254
|
+
fileId,
|
|
255
|
+
contentType,
|
|
256
|
+
method
|
|
248
257
|
}) {
|
|
249
258
|
var _a, _b, _c;
|
|
250
259
|
try {
|
|
251
260
|
if (!fileId) {
|
|
252
261
|
throw { message: "File ID is required", status: 400 };
|
|
253
262
|
}
|
|
254
|
-
const response = await apiClient.
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
const response = await apiClient.post("/file/url", {
|
|
264
|
+
key: fileId,
|
|
265
|
+
contentType: contentType || "application/json",
|
|
266
|
+
method: method || "GET"
|
|
267
|
+
});
|
|
257
268
|
if (!response.data || !response.data.data) {
|
|
258
269
|
throw { message: "Failed to download file", status: 500 };
|
|
259
270
|
}
|
|
260
|
-
return response.data.
|
|
271
|
+
return response.data.url;
|
|
261
272
|
} catch (error) {
|
|
262
273
|
const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while downloading file";
|
|
263
274
|
const status = ((_c = error.response) == null ? void 0 : _c.status) || 500;
|
|
@@ -6863,13 +6874,17 @@ async function getFormById({
|
|
|
6863
6874
|
throw { message, status };
|
|
6864
6875
|
}
|
|
6865
6876
|
}
|
|
6866
|
-
async function createOrUpdateForm(
|
|
6877
|
+
async function createOrUpdateForm({
|
|
6878
|
+
data
|
|
6879
|
+
}) {
|
|
6867
6880
|
var _a, _b, _c;
|
|
6868
6881
|
try {
|
|
6869
|
-
if (!
|
|
6882
|
+
if (!data) {
|
|
6870
6883
|
throw { message: "Form data is required", status: 400 };
|
|
6871
6884
|
}
|
|
6872
|
-
const response = await apiClient.post("/form/create-or-update-form",
|
|
6885
|
+
const response = await apiClient.post("/form/create-or-update-form", {
|
|
6886
|
+
data
|
|
6887
|
+
});
|
|
6873
6888
|
if (!response.data || !response.data.data) {
|
|
6874
6889
|
throw { message: "Failed to create or update form", status: 500 };
|
|
6875
6890
|
}
|