Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-7584
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Dec 4, 2024
2 parents 8ea38fa + 6bfc039 commit 63d5b0b
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: euanmillar,rikukissa
approvers: euanmillar,rikukissa,alsmk
minimum-approvals: 1
issue-title: 'Deploy (${{ github.event.inputs.environment }}): core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }}'
issue-body: 'Please approve or deny the deployment of core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }} to ${{ github.event.inputs.environment }}'
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ services:
- jwt-public-key.{{ts}}
environment:
- NODE_ENV=production
- MONGO_URL=mongodb://${STACK}__events:${METRICS_MONGODB_PASSWORD}@mongo1/${STACK}__events?replicaSet=rs0
- MONGO_URL=mongodb://events:${METRICS_MONGODB_PASSWORD}@mongo1/events?replicaSet=rs0
deploy:
labels:
- 'traefik.enable=false'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@hapi/h2o2": "^9.1.0",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "^0.0.5",
"@types/chalk": "^2.2.0",
"@types/code": "^4.0.3",
"@types/csv2json": "^1.4.0",
Expand Down
19 changes: 19 additions & 0 deletions src/api/custom-event/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import * as Hapi from '@hapi/hapi'
import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership'

export const customEventHandler = (
request: Hapi.Request,
h: Hapi.ResponseToolkit
) => {
return h.response([tennisClubMembershipEvent]).code(200)
}
8 changes: 8 additions & 0 deletions src/api/event-registration/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
confirmRegistration
// rejectRegistration
} from '@countryconfig/utils/gateway-api'
import { tennisClubMembershipEvent } from '@countryconfig/form/tennis-club-membership'

export async function eventRegistrationHandler(
request: Hapi.Request,
Expand Down Expand Up @@ -67,3 +68,10 @@ export async function eventRegistrationHandler(

return h.response().code(202)
}

export const tennisClubMembershipEventHandler = (
request: Hapi.Request,
h: Hapi.ResponseToolkit
) => {
return h.response(tennisClubMembershipEvent).code(200)
}
132 changes: 132 additions & 0 deletions src/form/tennis-club-membership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { defineConfig } from '@opencrvs/toolkit/events'

export const tennisClubMembershipEvent = defineConfig({
id: 'TENNIS_CLUB_MEMBERSHIP',
label: {
defaultMessage: 'Tennis club membership application',
description: 'This is what this event is referred as in the system',
id: 'event.tennis-club-membership.label'
},
actions: [
{
type: 'DECLARE',
label: {
defaultMessage: 'Send an application',
description:
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.tennis-club-membership.action.declare.label'
},
forms: [
{
label: {
id: 'event.tennis-club-membership.action.declare.form.label',
defaultMessage: 'Tennis club membership application',
description: 'This is what this form is referred as in the system'
},
active: true,
version: {
id: '1.0.0',
label: {
id: 'event.tennis-club-membership.action.declare.form.version.1',
defaultMessage: 'Version 1',
description: 'This is the first version of the form'
}
},
pages: [
{
id: 'applicant',
title: {
id: 'event.tennis-club-membership.action.declare.form.section.who.title',
defaultMessage: 'Who is applying for the membership?',
description: 'This is the title of the section'
},
fields: [
{
id: 'applicant.firstname',
type: 'TEXT',
required: true,
label: {
defaultMessage: "Applicant's first name",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.who.field.firstname.label'
}
},
{
id: 'applicant.surname',
type: 'TEXT',
required: true,
label: {
defaultMessage: "Applicant's surname",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.who.field.surname.label'
}
},
{
id: 'applicant.dob',
type: 'DATE',
required: true,
label: {
defaultMessage: "Applicant's date of birth",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.who.field.dob.label'
}
}
]
},
{
id: 'recommender',
title: {
id: 'event.tennis-club-membership.action.declare.form.section.recommender.title',
defaultMessage: 'Who is recommending the applicant?',
description: 'This is the title of the section'
},
fields: [
{
id: 'recommender.firstname',
type: 'TEXT',
required: true,
label: {
defaultMessage: "Recommender's first name",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.firstname.label'
}
},
{
id: 'recommender.surname',
type: 'TEXT',
required: true,
label: {
defaultMessage: "Recommender's surname",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.surname.label'
}
},
{
id: 'recommender.id',
type: 'TEXT',
required: true,
label: {
defaultMessage: "Recommender's membership ID",
description: 'This is the label for the field',
id: 'event.tennis-club-membership.action.declare.form.section.recommender.field.id.label'
}
}
]
}
]
}
]
}
]
})
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { trackingIDHandler } from './api/tracking-id/handler'
import { dashboardQueriesHandler } from './api/dashboards/handler'
import { fontsHandler } from './api/fonts/handler'
import { recordNotificationHandler } from './api/record-notification/handler'
import { customEventHandler } from '@countryconfig/api/custom-event/handler'

export interface ITokenPayload {
sub: string
Expand Down Expand Up @@ -589,6 +590,16 @@ export async function createServer() {
}
})

server.route({
method: 'GET',
path: '/events',
handler: customEventHandler,
options: {
tags: ['api', 'custom-event'],
description: 'Serves custom events'
}
})

server.ext({
type: 'onRequest',
method(request: Hapi.Request & { sentryScope?: any }, h) {
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"@countryconfig/*": ["./*"]
},
"target": "es6",
"module": "commonjs",
"module": "Node16",
"outDir": "build/dist",
"sourceMap": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"rootDir": ".",
"lib": ["esnext.asynciterable", "es6", "es2017", "es2019", "es2022"],
"forceConsistentCasingInFileNames": true,
Expand Down
9 changes: 7 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
"@graphql-tools/utils" "^9.2.1"
tslib "^2.4.0"

"@graphql-tools/schema@^9.0.18", "@graphql-tools/schema@^9.0.19":
"@graphql-tools/schema@^9.0.0", "@graphql-tools/schema@^9.0.18", "@graphql-tools/schema@^9.0.19":
version "9.0.19"
resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-9.0.19.tgz#c4ad373b5e1b8a0cf365163435b7d236ebdd06e7"
integrity sha512-oBRPoNBtCkk0zbUsyP4GaIzCt8C0aCI4ycIRUL67KK5pOHljKLBBtGT+Jr6hkzA74C8Gco8bpZPe7aWFjiaK2w==
Expand Down Expand Up @@ -1194,7 +1194,7 @@
value-or-promise "^1.0.11"
ws "^8.12.0"

"@graphql-tools/utils@^9.0.0", "@graphql-tools/utils@^9.2.1":
"@graphql-tools/utils@^9.0.0", "@graphql-tools/utils@^9.1.1", "@graphql-tools/utils@^9.2.1":
version "9.2.1"
resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-9.2.1.tgz#1b3df0ef166cfa3eae706e3518b17d5922721c57"
integrity sha512-WUw506Ql6xzmOORlriNrD6Ugx+HjVgYxt9KCXD9mHAak+eaXSwuGGPyE60hy9xaDEoXKBsG7SkG69ybitaVl6A==
Expand Down Expand Up @@ -1712,6 +1712,11 @@
dependencies:
"@octokit/openapi-types" "^18.0.0"

"@opencrvs/toolkit@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@opencrvs/toolkit/-/toolkit-0.0.5.tgz#dbd3395b561c1eb3527b8cfc28b6e1dd301671f3"
integrity sha512-Ex45aFUJ1iQwpYGMHhxVbhpuQFqVlmdSkNXz1phkM7KAzNtngL2KGIJCc6TFv4GKOHU/lLEfmGyrhIDCKlA7fQ==

"@parcel/[email protected]":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.0.tgz#e32d3dda6647791ee930556aee206fcd5ea0fb7a"
Expand Down

0 comments on commit 63d5b0b

Please sign in to comment.