@gov-cy/govcy-express-services 1.0.0-alpha.16 → 1.0.0-alpha.17
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/README.md
CHANGED
|
@@ -1175,14 +1175,14 @@ Accept: text/plain
|
|
|
1175
1175
|
Content-Type: application/json
|
|
1176
1176
|
|
|
1177
1177
|
{
|
|
1178
|
-
"
|
|
1179
|
-
"
|
|
1180
|
-
"
|
|
1181
|
-
"
|
|
1182
|
-
"
|
|
1183
|
-
"
|
|
1184
|
-
"
|
|
1185
|
-
"
|
|
1178
|
+
"submissionUsername": "username",
|
|
1179
|
+
"submissionEmail": "email@example.com",
|
|
1180
|
+
"submissionData": "{\"index\":{\"certificate_select\":[\"birth\",\"permanent_residence\"]}}",
|
|
1181
|
+
"submissionDataVersion": "1",
|
|
1182
|
+
"printFriendlyData": "[{\"pageUrl\":\"index\",\"pageTitle\":{\"el\":\"Επιλογή Εγγάφου\",\"en\":\"Document selection\",\"tr\":\"\"},\"fields\":[{\"id\":\"certificate_select\",\"name\":\"certificate_select\",\"label\":{\"el\":\"Τι έγγραφα επιθυμείτε να εκδώσετε;\",\"en\":\"What documents do you wish to issue?\"},\"value\":[\"birth\",\"permanent_residence\"],\"valueLabel\":[{\"el\":\"Πιστοποιητικό γέννησης\",\"en\":\"Birth certificate\",\"tr\":\"\"},{\"el\":\"Βεβαίωση μόνιμης διαμονής\",\"en\":\"Certificate of permanent residence\",\"tr\":\"\"}]}]}]",
|
|
1183
|
+
"rendererData": "{\"element\":\"summaryList\",\"params\":{\"items\":[{\"key\":{\"el\":\"Επιλογή Εγγάφου\",\"en\":\"Document selection\",\"tr\":\"\"},\"value\":[{\"element\":\"summaryList\",\"params\":{\"items\":[{\"key\":{\"el\":\"Τι έγγραφα επιθυμείτε να εκδώσετε;\",\"en\":\"What documents do you wish to issue?\"},\"value\":[{\"element\":\"textElement\",\"params\":{\"text\":{\"en\":\"Birth certificate, Certificate of permanent residence\",\"el\":\"Birth certificate, Certificate of permanent residence\",\"tr\":\"Birth certificate, Certificate of permanent residence\"},\"type\":\"span\"}}]}]}}]}]}}",
|
|
1184
|
+
"rendererVersion": "1.14.3",
|
|
1185
|
+
"designSystemsVersion": "3.2.0",
|
|
1186
1186
|
"service": "{\"id\":\"test\",\"title\":{\"el\":\"Υπηρεσία τεστ\",\"en\":\"Test service\",\"tr\":\"\"}}"
|
|
1187
1187
|
}
|
|
1188
1188
|
```
|
|
@@ -1233,15 +1233,15 @@ HTTP/1.1 200 OK
|
|
|
1233
1233
|
The data is collected from the form elements and the data layer and are sent via the submission API in the following format:
|
|
1234
1234
|
|
|
1235
1235
|
```json
|
|
1236
|
-
|
|
1237
|
-
"
|
|
1238
|
-
"
|
|
1239
|
-
"
|
|
1240
|
-
"
|
|
1241
|
-
"
|
|
1242
|
-
"
|
|
1243
|
-
"
|
|
1244
|
-
"
|
|
1236
|
+
{
|
|
1237
|
+
"submissionUsername" : "", // User's username
|
|
1238
|
+
"submissionEmail" : "", // User's email
|
|
1239
|
+
"submissionData": "{}", // Raw data as submitted by the user in each page
|
|
1240
|
+
"submissionDataVersion": "",// The submission data version
|
|
1241
|
+
"printFriendlyData": "[]", // Print friendly data
|
|
1242
|
+
"rendererData" :"{}", // Renderer data of the summary list
|
|
1243
|
+
"rendererVersion": "", // The renderer version
|
|
1244
|
+
"designSystemsVersion": "", // The design systems version
|
|
1245
1245
|
"service": "{}" // Service info
|
|
1246
1246
|
}
|
|
1247
1247
|
```
|
|
@@ -1252,16 +1252,16 @@ The data is collected from the form elements and the data layer and are sent via
|
|
|
1252
1252
|
|
|
1253
1253
|
> ℹ️ **Note:**
|
|
1254
1254
|
>
|
|
1255
|
-
> When sent to the API, the fields `
|
|
1255
|
+
> When sent to the API, the fields `submissionData`, `rendererData`, `printFriendlyData`, and `service` are stringified using `JSON.stringify()`.
|
|
1256
1256
|
>
|
|
1257
1257
|
> The sample below shows the structure **before** stringification for clarity.
|
|
1258
1258
|
|
|
1259
1259
|
```json
|
|
1260
1260
|
{
|
|
1261
|
-
"
|
|
1262
|
-
"
|
|
1263
|
-
"
|
|
1264
|
-
"
|
|
1261
|
+
"submissionUsername": "username", // User's username
|
|
1262
|
+
"submissionEmail": "email@example.com", // User's email
|
|
1263
|
+
"submissionDataVersion": "0.1", // Submission data version
|
|
1264
|
+
"submissionData": { // Submission raw data. Object, will be stringified
|
|
1265
1265
|
"index": { // Page level
|
|
1266
1266
|
"id_select": ["id", "arc"], // field level. Could be string or array
|
|
1267
1267
|
"id_number": "654654",
|
|
@@ -1293,8 +1293,8 @@ The data is collected from the form elements and the data layer and are sent via
|
|
|
1293
1293
|
"reason": "24324dssf"
|
|
1294
1294
|
}
|
|
1295
1295
|
},
|
|
1296
|
-
"
|
|
1297
|
-
"
|
|
1296
|
+
"submissionDataVersion": "1", // Submission data version
|
|
1297
|
+
"rendererData": { // Summary list renderer data ready for rendering . Object, will be stringified
|
|
1298
1298
|
"element": "summaryList",
|
|
1299
1299
|
"params": {
|
|
1300
1300
|
"items": [
|
|
@@ -1501,7 +1501,7 @@ The data is collected from the form elements and the data layer and are sent via
|
|
|
1501
1501
|
]
|
|
1502
1502
|
}
|
|
1503
1503
|
},
|
|
1504
|
-
"
|
|
1504
|
+
"printFriendlyData": [ // Print friendly data. Object, will be stringified
|
|
1505
1505
|
{
|
|
1506
1506
|
"pageUrl": "index", // Page URL
|
|
1507
1507
|
"pageTitle": { // Page title
|
|
@@ -1664,8 +1664,8 @@ The data is collected from the form elements and the data layer and are sent via
|
|
|
1664
1664
|
]
|
|
1665
1665
|
}
|
|
1666
1666
|
],
|
|
1667
|
-
"
|
|
1668
|
-
"
|
|
1667
|
+
"rendererVersion": "1.14.1", // Renderer version
|
|
1668
|
+
"designSystemsVersion": "3.1.0", // Design systems version
|
|
1669
1669
|
"service": { // Service metadata. Object, will be stringified
|
|
1670
1670
|
"id": "takeover",
|
|
1671
1671
|
"title": {
|
|
@@ -2015,7 +2015,7 @@ TEST_SUBMISSION_API_SERVICE_ID=123
|
|
|
2015
2015
|
3. If not found, call the PUT endpoint to create a new temporary record.
|
|
2016
2016
|
- **On every form POST**, after successful validation:
|
|
2017
2017
|
- The `submissionPutAPIEndpoint` will fire-and-forget a `PUT` request to update the saved submission with the latest form data.
|
|
2018
|
-
- The payload includes all required submission fields with `
|
|
2018
|
+
- The payload includes all required submission fields with `submissionData` JSON-stringified.
|
|
2019
2019
|
|
|
2020
2020
|
#### `submissionGetAPIEndpoint` `GET` API Request and Response
|
|
2021
2021
|
This API is used to retrieve the saved submission data.
|
|
@@ -2116,7 +2116,7 @@ Accept: text/plain
|
|
|
2116
2116
|
Content-Type: application/json
|
|
2117
2117
|
|
|
2118
2118
|
{
|
|
2119
|
-
"
|
|
2119
|
+
"submissionData" : "{\"index\":{\"formData\":{\"certificate_select\":[\"birth\",\"permanent_residence\"]}},\"data-entry-radios\":{\"formData\":{\"mobile_select\":\"other\",\"mobileTxt\":\"+35799484967\"}}}"
|
|
2120
2120
|
}
|
|
2121
2121
|
```
|
|
2122
2122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gov-cy/govcy-express-services",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.17",
|
|
4
4
|
"description": "An Express-based system that dynamically renders services using @gov-cy/govcy-frontend-renderer and posts data to a submission API.",
|
|
5
5
|
"author": "DMRID - DSF Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@gov-cy/dsf-email-templates": "^2.1.0",
|
|
54
|
-
"@gov-cy/govcy-frontend-renderer": "^1.22.
|
|
54
|
+
"@gov-cy/govcy-frontend-renderer": "^1.22.1",
|
|
55
55
|
"axios": "^1.9.0",
|
|
56
56
|
"cookie-parser": "^1.4.7",
|
|
57
57
|
"dotenv": "^16.3.1",
|
|
@@ -118,7 +118,7 @@ export function govcyReviewPostHandler() {
|
|
|
118
118
|
|
|
119
119
|
//-- Send email to user
|
|
120
120
|
// Generate the email body
|
|
121
|
-
let emailBody = generateSubmitEmail(service, submissionData.
|
|
121
|
+
let emailBody = generateSubmitEmail(service, submissionData.printFriendlyData, referenceNo, req);
|
|
122
122
|
logger.debug("Email generated:", emailBody);
|
|
123
123
|
// Send the email
|
|
124
124
|
sendEmail(service.site.title[service.site.lang],emailBody,[dataLayer.getUser(req.session).email], "eMail").catch(err => {
|
|
@@ -135,9 +135,9 @@ function _uploadFileEventHandler(event) {
|
|
|
135
135
|
"tr": "The selected file must be a JPG, JPEG, PNG or PDF"
|
|
136
136
|
},
|
|
137
137
|
"uploadFailed409": {
|
|
138
|
-
"el": "Το επιλεγμένο αρχείο πρέπει να είναι μικρότερο από
|
|
139
|
-
"en": "The selected file must be smaller than
|
|
140
|
-
"tr": "The selected file must be smaller than
|
|
138
|
+
"el": "Το επιλεγμένο αρχείο πρέπει να είναι μικρότερο από 4MB",
|
|
139
|
+
"en": "The selected file must be smaller than 4MB",
|
|
140
|
+
"tr": "The selected file must be smaller than 4MB"
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
|
|
@@ -32,7 +32,7 @@ export function prepareSubmissionData(req, siteId, service) {
|
|
|
32
32
|
// }
|
|
33
33
|
// }
|
|
34
34
|
|
|
35
|
-
// ----- consistent data model for
|
|
35
|
+
// ----- consistent data model for submissionData (CONFIG-BASED)
|
|
36
36
|
const submissionData = {};
|
|
37
37
|
|
|
38
38
|
// Loop through every page in the service definition
|
|
@@ -110,7 +110,7 @@ export function prepareSubmissionData(req, siteId, service) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
logger.debug("Submission Data prepared:", submissionData);
|
|
113
|
-
// ----- END config-based stable
|
|
113
|
+
// ----- END config-based stable submissionData block
|
|
114
114
|
|
|
115
115
|
// Get the print-friendly data from the session store
|
|
116
116
|
const printFriendlyData = preparePrintFriendlyData(req, siteId, service);
|
|
@@ -119,14 +119,14 @@ export function prepareSubmissionData(req, siteId, service) {
|
|
|
119
119
|
const reviewSummaryList = generateReviewSummary(printFriendlyData, req, siteId, false);
|
|
120
120
|
// Prepare the submission data object
|
|
121
121
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
submissionUsername: dataLayer.getUser(req.session).name,
|
|
123
|
+
submissionEmail: dataLayer.getUser(req.session).email,
|
|
124
|
+
submissionData: submissionData, // Raw data as submitted by the user in each page
|
|
125
|
+
submissionDataVersion: service.site?.submission_data_version || "", // The submission data version
|
|
126
|
+
printFriendlyData: printFriendlyData, // Print-friendly data
|
|
127
|
+
rendererData: reviewSummaryList, // Renderer data of the summary list
|
|
128
|
+
rendererVersion: service.site?.renderer_version || "", // The renderer version
|
|
129
|
+
designSystemsVersion: service.site?.design_systems_version || "", // The design systems version
|
|
130
130
|
service: { // Service info
|
|
131
131
|
id: service.site.id, // Service ID
|
|
132
132
|
title: service.site.title // Service title multilingual object
|
|
@@ -145,14 +145,14 @@ export function prepareSubmissionData(req, siteId, service) {
|
|
|
145
145
|
export function prepareSubmissionDataAPI(data) {
|
|
146
146
|
|
|
147
147
|
return {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
submissionUsername: String(data.submissionUsername ?? ""),
|
|
149
|
+
submissionEmail: String(data.submissionEmail ?? ""),
|
|
150
|
+
submissionData: JSON.stringify(data.submissionData ?? {}),
|
|
151
|
+
submissionDataVersion: String(data.submissionDataVersion ?? ""),
|
|
152
|
+
printFriendlyData: JSON.stringify(data.printFriendlyData ?? []),
|
|
153
|
+
rendererData: JSON.stringify(data.rendererData ?? {}),
|
|
154
|
+
rendererVersion: String(data.rendererVersion ?? ""),
|
|
155
|
+
designSystemsVersion: String(data.designSystemsVersion ?? ""),
|
|
156
156
|
service: JSON.stringify(data.service ?? {})
|
|
157
157
|
};
|
|
158
158
|
}
|