@gov-cy/govcy-express-services 0.1.1 → 0.1.3
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 +33 -12
- package/package.json +1 -1
- package/src/middleware/govcyReviewPostHandler.mjs +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# govcy Express Services
|
|
2
|
-
](https://www.npmjs.com/package/@gov-cy/govcy-express-services)
|
|
3
|
+

|
|
3
4
|
[](https://github.com/gov-cy/govcy-express-services/actions/workflows/unit-test.yml)
|
|
5
|
+
[](https://github.com/gov-cy/govcy-express-services/actions/workflows/tag-and-publish-on-version-change.yml)
|
|
4
6
|
|
|
5
7
|
> ⚠️ **Warning:**
|
|
6
|
-
> This package is under active development and is not a finished product. It is intended for testing, acceptance, integration, and browser testing purposes only.
|
|
8
|
+
> This package is **under active development** and is not a finished product. It is intended for testing, acceptance, integration, and browser testing purposes only.
|
|
9
|
+
>
|
|
7
10
|
> **No guarantees are provided regarding stability, security, or compliance. Using this package does not imply your product or service will automatically pass any required assessments, audits, or certifications by the Cyprus government or any other authority.**
|
|
11
|
+
>
|
|
8
12
|
> You are responsible for ensuring your own compliance, security, and quality assurance processes.
|
|
9
13
|
|
|
10
14
|
## 📝 Description
|
|
@@ -248,6 +252,10 @@ Here's an example of a page defined in the JSON file:
|
|
|
248
252
|
}
|
|
249
253
|
```
|
|
250
254
|
|
|
255
|
+
The above `page` JSON generates a page that looks like the following screenshot:
|
|
256
|
+
|
|
257
|
+

|
|
258
|
+
|
|
251
259
|
The JSON structure is based on the [govcy-frontend-renderer's JSON template](https://github.com/gov-cy/govcy-frontend-renderer/blob/main/README.md#json-template-example).
|
|
252
260
|
|
|
253
261
|
Lets break down the JSON config for this page:
|
|
@@ -285,6 +293,10 @@ The `review` page is automatically generated by the project and includes the fol
|
|
|
285
293
|
- **Change links**: A list of links to each page in the service.
|
|
286
294
|
- **Submit button**: A button to submit the form.
|
|
287
295
|
|
|
296
|
+
Here's an example screenshot of review page
|
|
297
|
+
|
|
298
|
+

|
|
299
|
+
|
|
288
300
|
When the user clicks a change link, the user is redirected to the corresponding page in the service. After the user clicks on `continue` button the user is redirected back to the `review` page.
|
|
289
301
|
|
|
290
302
|
When the user clicks the `Submit` button, all the data gathered from the site's forms within this session are validated based on the validation definition in the JSON file, and if they pass they are submitted to the configured API endpoint.
|
|
@@ -297,6 +309,10 @@ The `success` page is automatically generated by the project, is accessible only
|
|
|
297
309
|
- **PDF Download link**: A link to download the PDF of the submission's data in a human-readable format.
|
|
298
310
|
- **Summary**: A summary of the data from all the pages in the service.
|
|
299
311
|
|
|
312
|
+
Here's an example screenshot of success page
|
|
313
|
+
|
|
314
|
+

|
|
315
|
+
|
|
300
316
|
### 🛡️ Site eligibility checks
|
|
301
317
|
|
|
302
318
|
The project uses an array of API endpoints to check the eligibility of a service/site. To use this feature, you need to configure the following in your JSON file under the `site` object:
|
|
@@ -383,7 +399,7 @@ For each eligibility API endpoint, the project sends a request to the API endpoi
|
|
|
383
399
|
|
|
384
400
|
**Example GET Request:**
|
|
385
401
|
|
|
386
|
-
```
|
|
402
|
+
```http
|
|
387
403
|
GET /check-eligibility?checkFor=isCitizen,isAdult HTTP/1.1
|
|
388
404
|
Host: localhost:3002
|
|
389
405
|
Authorization: Bearer eyJhbGciOi...
|
|
@@ -394,7 +410,7 @@ Accept: text/plain
|
|
|
394
410
|
|
|
395
411
|
**Example POST Request**:
|
|
396
412
|
|
|
397
|
-
```
|
|
413
|
+
```http
|
|
398
414
|
POST /check-eligibility HTTP/1.1
|
|
399
415
|
Host: localhost:3002
|
|
400
416
|
Authorization: Bearer eyJhbGciOi...
|
|
@@ -507,7 +523,7 @@ With the above config, when a user submits the `review` page, the service sends
|
|
|
507
523
|
|
|
508
524
|
**Example Request:**
|
|
509
525
|
|
|
510
|
-
```
|
|
526
|
+
```http
|
|
511
527
|
POST /submission-endpoint HTTP/1.1
|
|
512
528
|
Host: localhost:3002
|
|
513
529
|
Authorization: Bearer eyJhbGciOi...
|
|
@@ -517,12 +533,15 @@ Accept: text/plain
|
|
|
517
533
|
Content-Type: application/json
|
|
518
534
|
|
|
519
535
|
{
|
|
520
|
-
"
|
|
521
|
-
"
|
|
522
|
-
"
|
|
523
|
-
"
|
|
524
|
-
"
|
|
525
|
-
|
|
536
|
+
"submission_username": "username",
|
|
537
|
+
"submission_email": "email@example.com",
|
|
538
|
+
"submission_data": "{\"index\":{\"formData\":{\"certificate_select\":[\"birth\",\"permanent_residence\"]}}}",
|
|
539
|
+
"submission_data_version": "1",
|
|
540
|
+
"print_friendly_data": "[{\"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\":\"\"}]}]}]",
|
|
541
|
+
"renderer_data": "{\"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\"}}]}]}}]}]}}",
|
|
542
|
+
"renderer_version": "1.14.3",
|
|
543
|
+
"design_systems_version": "3.2.0",
|
|
544
|
+
"service": "{\"id\":\"test\",\"title\":{\"el\":\"Υπηρεσία τεστ\",\"en\":\"Test service\",\"tr\":\"\"}}"
|
|
526
545
|
}
|
|
527
546
|
```
|
|
528
547
|
|
|
@@ -537,7 +556,7 @@ The API is expected to return a JSON response with the following structure (see
|
|
|
537
556
|
"ErrorCode": 0,
|
|
538
557
|
"ErrorMessage": null,
|
|
539
558
|
"Data": {
|
|
540
|
-
"
|
|
559
|
+
"referenceValue": "12345678"
|
|
541
560
|
}
|
|
542
561
|
}
|
|
543
562
|
```
|
|
@@ -586,7 +605,9 @@ The data is collected from the form elements and the data layer and are sent via
|
|
|
586
605
|
<summary>Here's a sample submission data JSON (as an object, before stringification)</summary>
|
|
587
606
|
|
|
588
607
|
> ℹ️ **Note:**
|
|
608
|
+
>
|
|
589
609
|
> When sent to the API, the fields `submission_data`, `renderer_data`, `print_friendly_data`, and `service` are stringified using `JSON.stringify()`.
|
|
610
|
+
>
|
|
590
611
|
> The sample below shows the structure **before** stringification for clarity.
|
|
591
612
|
|
|
592
613
|
```json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gov-cy/govcy-express-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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",
|
|
@@ -90,7 +90,7 @@ export function govcyReviewPostHandler() {
|
|
|
90
90
|
|
|
91
91
|
// Check if the response is successful
|
|
92
92
|
if (response.Succeeded) {
|
|
93
|
-
let referenceNo = response?.Data?.
|
|
93
|
+
let referenceNo = response?.Data?.referenceValue || "";
|
|
94
94
|
// Add the reference number to the submission data
|
|
95
95
|
submissionData.referenceNumber = referenceNo;
|
|
96
96
|
logger.info("✅ Data submitted", siteId, referenceNo);
|