@bluecopa/core 0.1.27 → 0.1.29
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,9 +1,10 @@
|
|
|
1
1
|
import { Form } from './getFormById';
|
|
2
2
|
export interface CreateOrUpdateFormRequest {
|
|
3
3
|
data: Form;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
processSheetId: string;
|
|
5
|
+
formInstanceId: string;
|
|
6
|
+
isDummy: boolean;
|
|
7
|
+
status: "DRAFTED" | "PUBLISHED";
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Creates or updates a form
|
|
@@ -12,4 +13,4 @@ export interface CreateOrUpdateFormResponse {
|
|
|
12
13
|
* @returns Promise<Form> The created or updated form
|
|
13
14
|
* @throws Error if the request fails
|
|
14
15
|
*/
|
|
15
|
-
export declare function createOrUpdateForm({ data, }: CreateOrUpdateFormRequest): Promise<Form>;
|
|
16
|
+
export declare function createOrUpdateForm({ data, processSheetId, formInstanceId, isDummy, status, }: CreateOrUpdateFormRequest): Promise<Form>;
|
package/dist/index.es.js
CHANGED
|
@@ -230,10 +230,10 @@ async function fileUpload({
|
|
|
230
230
|
contentType,
|
|
231
231
|
method
|
|
232
232
|
});
|
|
233
|
-
if (!response.data
|
|
233
|
+
if (!response.data) {
|
|
234
234
|
throw { message: "Failed to upload file", status: 500 };
|
|
235
235
|
}
|
|
236
|
-
const fileUploadUrl = response.data
|
|
236
|
+
const fileUploadUrl = response.data;
|
|
237
237
|
const config = {
|
|
238
238
|
method,
|
|
239
239
|
url: fileUploadUrl,
|
|
@@ -255,7 +255,7 @@ async function fileDownload({
|
|
|
255
255
|
contentType,
|
|
256
256
|
method
|
|
257
257
|
}) {
|
|
258
|
-
var _a, _b, _c;
|
|
258
|
+
var _a, _b, _c, _d;
|
|
259
259
|
try {
|
|
260
260
|
if (!fileId) {
|
|
261
261
|
throw { message: "File ID is required", status: 400 };
|
|
@@ -265,13 +265,28 @@ async function fileDownload({
|
|
|
265
265
|
contentType: contentType || "application/json",
|
|
266
266
|
method: method || "GET"
|
|
267
267
|
});
|
|
268
|
-
if (!response.data
|
|
268
|
+
if (!response.data) {
|
|
269
269
|
throw { message: "Failed to download file", status: 500 };
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
const fileUrl = response.data;
|
|
272
|
+
let fileName = fileId;
|
|
273
|
+
try {
|
|
274
|
+
fileName = (_a = fileId.split("/").pop().split(".")) == null ? void 0 : _a[0];
|
|
275
|
+
} catch (error) {
|
|
276
|
+
}
|
|
277
|
+
if (fileUrl) {
|
|
278
|
+
const link = document.createElement("a");
|
|
279
|
+
link.href = fileUrl;
|
|
280
|
+
link.download = fileId;
|
|
281
|
+
link.target = "_blank";
|
|
282
|
+
document.body.appendChild(link);
|
|
283
|
+
link.click();
|
|
284
|
+
document.body.removeChild(link);
|
|
285
|
+
}
|
|
286
|
+
return fileUrl;
|
|
272
287
|
} catch (error) {
|
|
273
|
-
const message = ((
|
|
274
|
-
const status = ((
|
|
288
|
+
const message = ((_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || error.message || "An unexpected error occurred while downloading file";
|
|
289
|
+
const status = ((_d = error.response) == null ? void 0 : _d.status) || 500;
|
|
275
290
|
throw { message, status };
|
|
276
291
|
}
|
|
277
292
|
}
|
|
@@ -6875,7 +6890,11 @@ async function getFormById({
|
|
|
6875
6890
|
}
|
|
6876
6891
|
}
|
|
6877
6892
|
async function createOrUpdateForm({
|
|
6878
|
-
data
|
|
6893
|
+
data,
|
|
6894
|
+
processSheetId,
|
|
6895
|
+
formInstanceId,
|
|
6896
|
+
isDummy,
|
|
6897
|
+
status
|
|
6879
6898
|
}) {
|
|
6880
6899
|
var _a, _b, _c;
|
|
6881
6900
|
try {
|
|
@@ -6883,16 +6902,20 @@ async function createOrUpdateForm({
|
|
|
6883
6902
|
throw { message: "Form data is required", status: 400 };
|
|
6884
6903
|
}
|
|
6885
6904
|
const response = await apiClient.post("/form/create-or-update-form", {
|
|
6886
|
-
data
|
|
6905
|
+
data,
|
|
6906
|
+
processSheetId,
|
|
6907
|
+
formInstanceId,
|
|
6908
|
+
isDummy,
|
|
6909
|
+
status
|
|
6887
6910
|
});
|
|
6888
|
-
if (!response.data
|
|
6911
|
+
if (!response.data) {
|
|
6889
6912
|
throw { message: "Failed to create or update form", status: 500 };
|
|
6890
6913
|
}
|
|
6891
6914
|
return response.data.data;
|
|
6892
6915
|
} catch (error) {
|
|
6893
6916
|
const message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || error.message || "An unexpected error occurred while creating or updating form";
|
|
6894
|
-
const
|
|
6895
|
-
throw { message, status };
|
|
6917
|
+
const status2 = ((_c = error.response) == null ? void 0 : _c.status) || 500;
|
|
6918
|
+
throw { message, status: status2 };
|
|
6896
6919
|
}
|
|
6897
6920
|
}
|
|
6898
6921
|
const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|