impaktapps-ui-builder 1.0.180 → 1.0.181-test
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/dist/impaktapps-ui-builder.es.js +70 -4
- package/dist/impaktapps-ui-builder.es.js.map +1 -1
- package/dist/impaktapps-ui-builder.umd.js +6 -6
- package/dist/impaktapps-ui-builder.umd.js.map +1 -1
- package/dist/src/impaktapps-ui-builder/runtime/services/downloadFile.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/runtime/services/interface.d.ts +1 -0
- package/dist/src/impaktapps-ui-builder/runtime/services/service.d.ts +2 -0
- package/package.json +1 -1
- package/src/impaktapps-ui-builder/builder/elements/UiSchema/event/schema.ts +1 -0
- package/src/impaktapps-ui-builder/runtime/services/downloadFile.ts +80 -0
- package/src/impaktapps-ui-builder/runtime/services/events.ts +6 -3
- package/src/impaktapps-ui-builder/runtime/services/interface.ts +1 -0
- package/src/impaktapps-ui-builder/runtime/services/service.ts +5 -3
|
@@ -9521,6 +9521,7 @@ const EventSchema = {
|
|
|
9521
9521
|
oneOf: [
|
|
9522
9522
|
{ title: "RankProvider", const: "RankProvider" },
|
|
9523
9523
|
{ title: "Download File", const: "downloadFile" },
|
|
9524
|
+
{ title: "Download File Stream", const: "downloadFileStream" },
|
|
9524
9525
|
{ title: "downloadFileFromUrl", const: "downloadFileFromUrl" }
|
|
9525
9526
|
]
|
|
9526
9527
|
},
|
|
@@ -10502,6 +10503,66 @@ const downloadFileFromUrl = (response, service2) => {
|
|
|
10502
10503
|
link.click();
|
|
10503
10504
|
link.parentNode.removeChild(link);
|
|
10504
10505
|
};
|
|
10506
|
+
const downloadFileStream = async (params2) => {
|
|
10507
|
+
try {
|
|
10508
|
+
let response;
|
|
10509
|
+
if (params2.method === "GET") {
|
|
10510
|
+
response = await params2.fetchservice.getStream(
|
|
10511
|
+
params2.url,
|
|
10512
|
+
params2.config
|
|
10513
|
+
);
|
|
10514
|
+
} else if (params2.method === "POST") {
|
|
10515
|
+
response = await params2.fetchservice.postStream(
|
|
10516
|
+
params2.url,
|
|
10517
|
+
params2.body,
|
|
10518
|
+
params2.config
|
|
10519
|
+
);
|
|
10520
|
+
} else {
|
|
10521
|
+
throw new Error(
|
|
10522
|
+
`Unsupported HTTP method: ${params2.method}. Only GET and POST are supported.`
|
|
10523
|
+
);
|
|
10524
|
+
}
|
|
10525
|
+
if (!response.ok) {
|
|
10526
|
+
throw new Error("Download failed");
|
|
10527
|
+
}
|
|
10528
|
+
params2.store.setNotify({
|
|
10529
|
+
SuccessMessage: "File Download Started Successfully",
|
|
10530
|
+
Success: true
|
|
10531
|
+
});
|
|
10532
|
+
const fileName = response.headers.get("filename") || "downloaded_file";
|
|
10533
|
+
const extension = fileName.includes(".") ? fileName.substring(fileName.lastIndexOf(".")) : "";
|
|
10534
|
+
const reader = response.body.getReader();
|
|
10535
|
+
const fileHandle = await window.showSaveFilePicker({
|
|
10536
|
+
suggestedName: fileName,
|
|
10537
|
+
types: extension ? [
|
|
10538
|
+
{
|
|
10539
|
+
description: "File",
|
|
10540
|
+
accept: {
|
|
10541
|
+
"application/octet-stream": [extension]
|
|
10542
|
+
}
|
|
10543
|
+
}
|
|
10544
|
+
] : void 0
|
|
10545
|
+
});
|
|
10546
|
+
const writable = await fileHandle.createWritable();
|
|
10547
|
+
while (true) {
|
|
10548
|
+
const { done, value } = await reader.read();
|
|
10549
|
+
if (done)
|
|
10550
|
+
break;
|
|
10551
|
+
await writable.write(value);
|
|
10552
|
+
}
|
|
10553
|
+
await writable.close();
|
|
10554
|
+
params2.store.setNotify({
|
|
10555
|
+
SuccessMessage: `File "${fileHandle.name}" downloaded successfully.`,
|
|
10556
|
+
Success: true
|
|
10557
|
+
});
|
|
10558
|
+
} catch (e) {
|
|
10559
|
+
params2.store.setNotify({
|
|
10560
|
+
FailMessage: "File Download Failed",
|
|
10561
|
+
Fail: true
|
|
10562
|
+
});
|
|
10563
|
+
console.error(e);
|
|
10564
|
+
}
|
|
10565
|
+
};
|
|
10505
10566
|
const executeEvents = (params2) => {
|
|
10506
10567
|
var _a, _b, _c;
|
|
10507
10568
|
let nextEvent = [];
|
|
@@ -10623,10 +10684,13 @@ function executeInBuiltFunctionHandler(params) {
|
|
|
10623
10684
|
let parameter = {};
|
|
10624
10685
|
if (params.config.funcParametersCode) {
|
|
10625
10686
|
const makeFunc = eval(params.config.funcParametersCode);
|
|
10626
|
-
parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
|
|
10627
|
-
params.serviceHolder[params.config.inBuiltFunctionType](
|
|
10687
|
+
parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.fetchservice);
|
|
10688
|
+
params.serviceHolder[params.config.inBuiltFunctionType](
|
|
10689
|
+
parameter,
|
|
10690
|
+
params.service
|
|
10691
|
+
);
|
|
10628
10692
|
} else {
|
|
10629
|
-
params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
|
|
10693
|
+
params.serviceHolder[params.config.inBuiltFunctionType](params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service, params.fetchservice);
|
|
10630
10694
|
}
|
|
10631
10695
|
}
|
|
10632
10696
|
function executeCustomHandler(params) {
|
|
@@ -10830,7 +10894,8 @@ var service = (funcParams) => {
|
|
|
10830
10894
|
dynamicData: funcParams.dynamicData,
|
|
10831
10895
|
userValue: funcParams.userValue,
|
|
10832
10896
|
service: funcParams.service,
|
|
10833
|
-
|
|
10897
|
+
fetchservice: funcParams.fetchservice,
|
|
10898
|
+
serviceHolder: { downloadFile: downloadFile$1, download: downloadFileFromUrl, downloadFileStream, ...funcParams.functionsProvider },
|
|
10834
10899
|
eventGroups,
|
|
10835
10900
|
functionsProvider: funcParams.functionsProvider,
|
|
10836
10901
|
formDataHolder
|
|
@@ -11092,6 +11157,7 @@ var service = (funcParams) => {
|
|
|
11092
11157
|
},
|
|
11093
11158
|
downloadFile: downloadFile$1,
|
|
11094
11159
|
downloadFileFromUrl,
|
|
11160
|
+
downloadFileStream,
|
|
11095
11161
|
...funcParams.functionsProvider
|
|
11096
11162
|
};
|
|
11097
11163
|
};
|