elixFormsAPI - update syntax and add prepare global function

This commit is contained in:
2026-02-23 10:28:54 +01:00
parent fd3d0da848
commit 98a6019e32
51 changed files with 1716 additions and 3379 deletions
@@ -15,333 +15,172 @@ http:
value: "7792"
body:
type: json
data: "{\r
\ \"userDocument\": \"{{elixBase64EftlDocument}}\", // see the pre-request script\r
\ \"userContext\": {\r
\ \"lang\": \"IT\",\r
\ \"docs\": [\r
\ {\r
\ \"name\": \"doc1\",\r
\ \"quantity\": 3,\r
\ \"price\": 123.3\r
\ },\r
\ {\r
\ \"name\": \"doc2\",\r
\ \"quantity\": 5,\r
\ \"price\": 213.3\r
\ },\r
\ {\r
\ \"name\": \"doc3\",\r
\ \"quantity\": 10,\r
\ \"price\": 321.3\r
\ }\r
\ ],\r
\ \"docsAsEntities\": [\r
\ {\r
\ \"eftlEntityType\": \"com.anthesi.elixforms.api.eftl.model.mock.EftlDoc\",\r
\ \"eftlEntity\": {\r
\ \"name\": \"doc1\",\r
\ \"quantity\": 3,\r
\ \"price\": 123.3\r
\ }\r
\ },\r
\ {\r
\ \"eftlEntityType\": \"com.anthesi.elixforms.api.eftl.model.mock.EftlDoc\",\r
\ \"eftlEntity\": {\r
\ \"name\": \"doc2\",\r
\ \"quantity\": 5,\r
\ \"price\": 213.3\r
\ }\r
\ },\r
\ {\r
\ \"eftlEntityType\": \"com.anthesi.elixforms.api.eftl.model.mock.EftlDoc\",\r
\ \"eftlEntity\": {\r
\ \"name\": \"doc3\",\r
\ \"quantity\": 10,\r
\ \"price\": 321.3\r
\ }\r
\ }\r
\ ],\r
\ \"singleEntity\": {\r
\ \"eftlEntityType\": \"com.anthesi.elixforms.api.eftl.model.mock.EftlDoc\",\r
\ \"eftlEntity\": {\r
\ \"name\": \"doc1\",\r
\ \"quantity\": 3,\r
\ \"price\": 123.3\r
\ }\r
\ },\r
\ \"simpleList\": [\r
\ \"s1\",\r
\ \"s2\",\r
\ \"s3\"\r
\ ],\r
\ \"docsSize\": 3\r
\ }\r
}"
data: |-
{
"userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
"userContext": {
"lang": "IT",
"docs": [
{
"name": "doc1",
"quantity": 3,
"price": 123.3
},
{
"name": "doc2",
"quantity": 5,
"price": 213.3
},
{
"name": "doc3",
"quantity": 10,
"price": 321.3
}
],
"docsAsEntities": [
{
"eftlEntityType": "com.anthesi.elixforms.api.eftl.model.mock.EftlDoc",
"eftlEntity": {
"name": "doc1",
"quantity": 3,
"price": 123.3
}
},
{
"eftlEntityType": "com.anthesi.elixforms.api.eftl.model.mock.EftlDoc",
"eftlEntity": {
"name": "doc2",
"quantity": 5,
"price": 213.3
}
},
{
"eftlEntityType": "com.anthesi.elixforms.api.eftl.model.mock.EftlDoc",
"eftlEntity": {
"name": "doc3",
"quantity": 10,
"price": 321.3
}
}
],
"singleEntity": {
"eftlEntityType": "com.anthesi.elixforms.api.eftl.model.mock.EftlDoc",
"eftlEntity": {
"name": "doc1",
"quantity": 3,
"price": 123.3
}
},
"simpleList": [
"s1",
"s2",
"s3"
],
"docsSize": 3
}
}
auth: inherit
runtime:
scripts:
- type: before-request
code: "// Copy-pasta your EFTL document below inside the template literals (`)\r
var eftlDocumentToBeProcessed = `\r
<html>\r
<!-- codice NON processato da EFTL -->\r
<head>\r
</head>\r
<body style=\"font-family: Tahoma, Verdana, Segoe, sans-serif; font-size: 12px; fontstyle: normal; line-height: 19.6px;\">\r
<p style=\"text-align: center; font-size: 13pt; padding-top: 5pt;\">\r
<a href=\"#ITALIANO\">VERSIONE ITALIANA</a></p>\r
<p style=\"padding-bottom: 5pt;\"> </p>\r
<h2 align=\"center\"><strong>[TAG]SCHEMAID,341,COL0005,IUQOID, , [/TAG]</strong></h2>\r
<p style=\"text-align: center; font-size: 14pt; padding-top: 25pt;\">Tipologia: <strong>[TAG]SCHEMAID,341,COL0003,IUQOID, , [/TAG]</strong></p>\r
<p style=\"text-align: center; font-size: 14pt; padding-top: 25pt;\">Corrispettivo: <strong>[TAG]SCHEMAID,341,COL0009,IUQOID, , [/TAG]</strong></p>\r
<p style=\"text-align: center; font-size: 14pt; padding-top: 5pt;\">Decreto del Rettore</p>\r
<hr />\r
\r
<!-- Questo invece &egrave; processato -->\r
[EFTL]\r
<h2 align=\"center\"><strong>[TAG]SCHEMAID,341,COL0005,IUQOID, , [/TAG]</strong></h2>\r
<p style=\"text-align: center; font-size: 14pt; padding-top: 25pt;\">Tipologia: <strong>[TAG]SCHEMAID,341,COL0003,IUQOID, , [/TAG]</strong></p>\r
<p style=\"text-align: center; font-size: 14pt; padding-top: 25pt;\">Corrispettivo: <strong>[TAG]SCHEMAID,341,COL0009,IUQOID, , [/TAG]</strong></p>\r
[/EFTL]\r
\r
...\r
\r
[eftl] [!-- Inizio blocco EFTL --]\r
[!-- Blocco di codice riportato in output come scrittura non EFTL --]\r
<tag>testo tra tag html</tag> [!-- Blocco di codice riportato in output come scrittura non EFTL --]\r
testo senza tags\r
[VAR name=\"i\" type=\"number\"] [!-- Inizio blocco VAR per la definizione di una variabile --]\r
[% i = 0; %] [!-- Blocco di assegnazione valore ad una variabile --]\r
[/VAR]\r
<p>un po' di testo che verr&agrave; riportato</p> [!-- Blocco di codice riportato in output come scrittura non EFTL --]\r
[!-- Inizio blocco if/then/elese --]\r
[IF]\r
[CONDITION] [!-- Condizione del blocco IF da valutare: risultato aspettato di tipo booleano --]\r
[% lang == \"IT\" %]\r
[/CONDITION]\r
[THEN] [!-- Se blocco condizione true --]\r
\r
[FOR varName=\"doc\" iterable=\"docs\"]\r
doc: [%= doc %]\r
[/FOR]\r
\r
[!-- Condizione Blocco while --]\r
[WHILE]\r
[CONDITION] [% docs != null && i < docsSize %] [/CONDITION]\r
[DO] [!-- Blocco while da eseguire se condizione è \"true\" --]\r
<p> value of var \"i\" is: [%= i %]</p>\r
[FOR varName=\"doc\" iterable=\"docs\"] [!-- Blocco FOR di iterazione --]\r
doc corrente: [%= doc %] [!-- Blocco esposizione del valore della variabile --]\r
<strong> Sto ciclando sul documento con nome e prezzo </strong>\r
\r
[/FOR]\r
[% i = i + 1; %] [!-- Blocco di assegnazione valore ad una variabile --]\r
<p> value of var \"i\" after increment is: [%= i %]</p>\r
[/DO]\r
[/WHILE]\r
[/THEN]\r
[ELSE] [!-- Se blocco condizione false --]\r
<strong>fixed-time RESEARCH ASSISTANT CONTRACT/S for COLLABORATION at RESEARCH ACTIVITY</strong>\r
[/ELSE]\r
[/IF]\r
[!-- Fine blocco EFTL --]\r
[/EFTL]\r
<!-- codice NON processato da EFTL -->\r
\r
...\r
\r
<p>testo tra un documento blocco EFTL&copy; e l'altro</p>\r
\r
...\r
\r
[EFTL] [!-- Inizio 2° blocco EFTL --]\r
<ol>\r
<li>\r
Decreto del rettore del [TAG]SCHEMAID,202,COL0030,ID_OBJECT, , [/TAG] nr. [TAG]SCHEMAID,202,COL0022,ID_OBJECT, , [/TAG]\r
</li>\r
<li>\r
Decreto del rettore nr. [TAG]GETVALUEBYTAG,NUM_PROT,REQUEST,IUQOID[FILTER]ACTION_NAME=pers_a_inviaPerFirmaRemotaBando_facEcon[/FILTER][/TAG] del [TAG]GETVALUEBYTAG,PROVV_DATE,REQUEST,IUQOID[FILTER]ACTION_NAME=pers_a_inviaPerFirmaRemotaBando_facEcon[/FILTER],,,dd/MM/yyyy[/TAG]\r
</li>\r
</ol>\r
<tag>altro tag</tag>\r
[!-- Fine 2° blocco EFTL --]\r
[/EFTL]\r
<!-- codice NON processato da EFTL -->\r
<p align=\"center\">\r
<em>Resto del documento...</em>\r
</p>\r
<p> </p>\r
<p>The Rector</p>\r
<p>Digitally signed</p>\r
</body>\r
</html>\r
`;\r
\r
var base64EncodedDocument = btoa(eftlDocumentToBeProcessed);\r
\r
bru.setVar(\"elixBase64EftlDocument\", base64EncodedDocument);"
code: |-
const { prepareEftlDocument } = require("./elixFormsJs.js")
// Copy-pasta your EFTL document below inside the template literals (`)
prepareEftlDocument(String.raw`
<html>
<!-- codice NON processato da EFTL -->
<head>
</head>
<body style="font-family: Tahoma, Verdana, Segoe, sans-serif; font-size: 12px; fontstyle: normal; line-height: 19.6px;">
<p style="text-align: center; font-size: 13pt; padding-top: 5pt;">
<a href="#ITALIANO">VERSIONE ITALIANA</a></p>
<p style="padding-bottom: 5pt;"> </p>
<h2 align="center"><strong>[TAG]SCHEMAID,341,COL0005,IUQOID, , [/TAG]</strong></h2>
<p style="text-align: center; font-size: 14pt; padding-top: 25pt;">Tipologia: <strong>[TAG]SCHEMAID,341,COL0003,IUQOID, , [/TAG]</strong></p>
<p style="text-align: center; font-size: 14pt; padding-top: 25pt;">Corrispettivo: <strong>[TAG]SCHEMAID,341,COL0009,IUQOID, , [/TAG]</strong></p>
<p style="text-align: center; font-size: 14pt; padding-top: 5pt;">Decreto del Rettore</p>
<hr />
<!-- Questo invece &egrave; processato -->
[EFTL]
<h2 align="center"><strong>[TAG]SCHEMAID,341,COL0005,IUQOID, , [/TAG]</strong></h2>
<p style="text-align: center; font-size: 14pt; padding-top: 25pt;">Tipologia: <strong>[TAG]SCHEMAID,341,COL0003,IUQOID, , [/TAG]</strong></p>
<p style="text-align: center; font-size: 14pt; padding-top: 25pt;">Corrispettivo: <strong>[TAG]SCHEMAID,341,COL0009,IUQOID, , [/TAG]</strong></p>
[/EFTL]
...
[eftl] [!-- Inizio blocco EFTL --]
[!-- Blocco di codice riportato in output come scrittura non EFTL --]
<tag>testo tra tag html</tag> [!-- Blocco di codice riportato in output come scrittura non EFTL --]
testo senza tags
[VAR name="i" type="number"] [!-- Inizio blocco VAR per la definizione di una variabile --]
[% i = 0; %] [!-- Blocco di assegnazione valore ad una variabile --]
[/VAR]
<p>un po' di testo che verr&agrave; riportato</p> [!-- Blocco di codice riportato in output come scrittura non EFTL --]
[!-- Inizio blocco if/then/elese --]
[IF]
[CONDITION] [!-- Condizione del blocco IF da valutare: risultato aspettato di tipo booleano --]
[% lang == "IT" %]
[/CONDITION]
[THEN] [!-- Se blocco condizione true --]
[FOR varName="doc" iterable="docs"]
doc: [%= doc %]
[/FOR]
[!-- Condizione Blocco while --]
[WHILE]
[CONDITION] [% docs != null && i < docsSize %] [/CONDITION]
[DO] [!-- Blocco while da eseguire se condizione è "true" --]
<p> value of var "i" is: [%= i %]</p>
[FOR varName="doc" iterable="docs"] [!-- Blocco FOR di iterazione --]
doc corrente: [%= doc %] [!-- Blocco esposizione del valore della variabile --]
<strong> Sto ciclando sul documento con nome e prezzo </strong>
[/FOR]
[% i = i + 1; %] [!-- Blocco di assegnazione valore ad una variabile --]
<p> value of var "i" after increment is: [%= i %]</p>
[/DO]
[/WHILE]
[/THEN]
[ELSE] [!-- Se blocco condizione false --]
<strong>fixed-time RESEARCH ASSISTANT CONTRACT/S for COLLABORATION at RESEARCH ACTIVITY</strong>
[/ELSE]
[/IF]
[!-- Fine blocco EFTL --]
[/EFTL]
<!-- codice NON processato da EFTL -->
...
<p>testo tra un documento blocco EFTL&copy; e l'altro</p>
...
[EFTL] [!-- Inizio 2° blocco EFTL --]
<ol>
<li>
Decreto del rettore del [TAG]SCHEMAID,202,COL0030,ID_OBJECT, , [/TAG] nr. [TAG]SCHEMAID,202,COL0022,ID_OBJECT, , [/TAG]
</li>
<li>
Decreto del rettore nr. [TAG]GETVALUEBYTAG,NUM_PROT,REQUEST,IUQOID[FILTER]ACTION_NAME=pers_a_inviaPerFirmaRemotaBando_facEcon[/FILTER][/TAG] del [TAG]GETVALUEBYTAG,PROVV_DATE,REQUEST,IUQOID[FILTER]ACTION_NAME=pers_a_inviaPerFirmaRemotaBando_facEcon[/FILTER],,,dd/MM/yyyy[/TAG]
</li>
</ol>
<tag>altro tag</tag>
[!-- Fine 2° blocco EFTL --]
[/EFTL]
<!-- codice NON processato da EFTL -->
<p align="center">
<em>Resto del documento...</em>
</p>
<p> </p>
<p>The Rector</p>
<p>Digitally signed</p>
</body>
</html>
`);
settings:
encodeUrl: true