Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d37967a
change validate and register translations
cibelius Oct 30, 2025
125e84d
fix form config and translations
cibelius Nov 3, 2025
b949671
remove field configs from validate and review for death and tennis club
cibelius Nov 4, 2025
1892e94
add missing translations
cibelius Nov 5, 2025
057a100
Merge pull request #1124 from opencrvs/ocrvs-10824
cibelius Nov 5, 2025
86d9493
update toolkit
cibelius Nov 5, 2025
0eaa729
Merge remote-tracking branch 'origin/develop' into v2.0-temp
cibelius Nov 6, 2025
8ef5329
remove unnecessary review parts, add wip flag config to birth
cibelius Nov 7, 2025
c455b10
upgrade toolkit
cibelius Nov 7, 2025
f45aa1f
test
cibelius Nov 7, 2025
aa1b0f2
upgrade zod
cibelius Nov 8, 2025
a5ced0c
upgrade toolkit
cibelius Nov 8, 2025
60f168e
Merge remote-tracking branch 'origin/develop' into v2.0-temp
cibelius Nov 8, 2025
d460351
Merge branch 'v2.0-temp' into custom-actions-config
cibelius Nov 8, 2025
0e530d7
Merge pull request #1139 from opencrvs/custom-actions-config
cibelius Nov 11, 2025
415a67b
test
cibelius Nov 11, 2025
9674775
improve local dev env logging, add custom action handler, add config …
cibelius Nov 14, 2025
40ef6b6
update toolkit
cibelius Nov 14, 2025
bdc13d6
Merge remote-tracking branch 'origin/develop' into v2.0-temp
cibelius Nov 14, 2025
4107151
rename custom action type
cibelius Nov 14, 2025
d1a3808
update toolkit
cibelius Nov 14, 2025
1b72bda
Merge remote-tracking branch 'origin/develop' into v2.0-temp
cibelius Nov 14, 2025
60340a9
update config
cibelius Nov 17, 2025
0abbeb3
Merge remote-tracking branch 'origin/develop' into v2.0-temp
cibelius Nov 17, 2025
2630210
upgrade toolkit
cibelius Nov 17, 2025
b9a36b1
Merge remote-tracking branch 'origin/v2.0-temp' into ocrvs-10720-init
cibelius Nov 18, 2025
09e0da2
dont use pino in tests
cibelius Nov 18, 2025
a3cef71
Merge pull request #1142 from opencrvs/ocrvs-10720-init
cibelius Nov 18, 2025
6a9eed4
upgrade toolkit
cibelius Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions infrastructure/postgres/setup-analytics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ CREATE TABLE IF NOT EXISTS analytics.event_actions (
UNIQUE (id, event_id)
);
ALTER TABLE analytics.event_actions ADD COLUMN IF NOT EXISTS custom_action_type TEXT;
CREATE TABLE IF NOT EXISTS analytics.location_levels (
id text PRIMARY KEY,
level int NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@hapi/boom": "^9.1.1",
"@hapi/hapi": "^20.0.1",
"@hapi/inert": "^6.0.3",
"@opencrvs/toolkit": "1.9.0-rc.79b0f42",
"@opencrvs/toolkit": "1.9.0-rc.8476ac9",
"@types/chalk": "^2.2.0",
"@types/csv2json": "^1.4.0",
"@types/fhir": "^0.0.30",
Expand Down Expand Up @@ -114,7 +114,7 @@
"tsconfig-paths": "^3.8.0",
"typescript": "^5.1.6",
"uuid": "^11.1.0",
"zod": "^3.24.1"
"zod": "^4.1.12"
},
"lint-staged": {
"src/**/*.{ts,graphql}": [
Expand Down
8 changes: 8 additions & 0 deletions src/api/custom-event/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export function getCustomEventsHandler(
.code(200)
}

export async function onCustomActionHandler(
request: ActionConfirmationRequest,
h: Hapi.ResponseToolkit
) {
return h.response().code(200)
}

export async function onAnyActionHandler(
request: ActionConfirmationRequest,
h: Hapi.ResponseToolkit
Expand All @@ -33,6 +40,7 @@ export async function onAnyActionHandler(
const token = request.auth.artifacts.token as string

const event = request.payload

await sendInformantNotification({ event, token })

return h.response().code(200)
Expand Down
14 changes: 0 additions & 14 deletions src/api/notification/informantNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { InformantType as BirthInformantType } from '@countryconfig/form/v2/birt
import { InformantTemplateType } from './sms-service'
import { generateFailureLog, NotificationParams, notify } from './handler'
import { InformantType as DeathInformantType } from '@countryconfig/form/v2/death/forms/pages/informant'
import { birthEvent } from '@countryconfig/form/v2/birth'
import { deathEvent } from '@countryconfig/form/v2/death'

const resolveName = (name: FieldUpdateValue) => {
const nameObj = {
Expand Down Expand Up @@ -77,18 +75,6 @@ function getInformant(eventType: string, declaration: Record<string, any>) {
throw new Error('Invalid event type')
}

function getEventConfig(eventType: string) {
if (eventType === Event.Birth) {
return birthEvent
}

if (eventType === Event.Death) {
return deathEvent
}

throw new Error('Invalid event type')
}

async function getNotificationParams(
event: EventDocument,
token: string,
Expand Down
3 changes: 2 additions & 1 deletion src/data-seeding/roles/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ export const roles: Role[] = [
'record.register[event=birth|death|tennis-club-membership]',
'record.registered.print-certified-copies[event=birth|death|tennis-club-membership]',
'record.registered.correct[event=birth|death|tennis-club-membership]',
'record.unassign-others[event=birth|death|tennis-club-membership]'
'record.unassign-others[event=birth|death|tennis-club-membership]',
'record.custom-action[event=birth,customActionType=Approve]'
]
},
{
Expand Down
6 changes: 2 additions & 4 deletions src/form/tennis-club-membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,7 @@ export const tennisClubMembershipEvent = defineConfig({
description:
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.tennis-club-membership.action.validate.label'
},
review: TENNIS_CLUB_DECLARATION_REVIEW
}
},
{
type: ActionType.REGISTER,
Expand All @@ -918,8 +917,7 @@ export const tennisClubMembershipEvent = defineConfig({
description:
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.tennis-club-membership.action.register.label'
},
review: TENNIS_CLUB_DECLARATION_REVIEW
}
},
{
type: ActionType.PRINT_CERTIFICATE,
Expand Down
59 changes: 56 additions & 3 deletions src/form/v2/birth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
*/
import {
ActionType,
and,
ConditionalType,
defineConfig,
field
field,
not
} from '@opencrvs/toolkit/events'
import {
BIRTH_DECLARATION_FORM,
Expand All @@ -24,6 +26,7 @@ import { BIRTH_CERTIFICATE_COLLECTOR_FORM } from './forms/printForm'
import { PlaceOfBirth } from './forms/pages/child'
import { CORRECTION_FORM } from './forms/correctionForm'
import { dedupConfig } from './dedupConfig'
import { applicationConfig } from '@countryconfig/api/application/application-config'

export const birthEvent = defineConfig({
id: Event.Birth,
Expand All @@ -45,6 +48,17 @@ export const birthEvent = defineConfig({
description:
'This is a fallback title if actual title resolves to empty string'
},
flags: [
{
id: 'approval-required-for-late-registration',
label: {
id: 'event.birth.flag.approval-required-for-late-registration',
defaultMessage: 'Approval required for late registration',
description: 'Flag label for approval required for late registration'
},
requiresAction: true
}
],
summary: {
fields: [
{
Expand Down Expand Up @@ -188,6 +202,47 @@ export const birthEvent = defineConfig({
id: 'event.birth.action.detect-duplicate.label'
},
query: dedupConfig
},
flags: [
{
id: 'approval-required-for-late-registration',
operation: 'add',
conditional: and(
not(
field('child.dob')
.isAfter()
.days(applicationConfig.BIRTH.LATE_REGISTRATION_TARGET)
.inPast()
),
field('child.dob').isBefore().now()
)
}
]
},
{
type: ActionType.CUSTOM,
customActionType: 'Approve',
label: {
defaultMessage: 'Approve',
description:
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.birth.action.approve.label'
},
supportingCopy: {
defaultMessage:
'This birth has been registered late. You are now approving it for further validation and registration.',
description: 'This is the confirmation text for the approve action',
id: 'event.birth.action.approve.confirmationText'
},
form: [],
flags: [
{ id: 'approval-required-for-late-registration', operation: 'remove' }
],
auditHistoryLabel: {
defaultMessage: 'Approved',
description:
'The label to show in audit history for the approve action',
id: 'event.birth.action.approve.audit-history-label'
}
},
{
Expand All @@ -198,7 +253,6 @@ export const birthEvent = defineConfig({
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.birth.action.validate.label'
},
review: BIRTH_DECLARATION_REVIEW,
deduplication: {
id: 'birth-deduplication',
label: {
Expand All @@ -218,7 +272,6 @@ export const birthEvent = defineConfig({
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.birth.action.register.label'
},
review: BIRTH_DECLARATION_REVIEW,
deduplication: {
id: 'birth-deduplication',
label: {
Expand Down
2 changes: 0 additions & 2 deletions src/form/v2/death/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export const deathEvent = defineConfig({
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.death.action.validate.label'
},
review: DEATH_DECLARATION_REVIEW,
deduplication: {
id: 'death-deduplication',
label: {
Expand All @@ -221,7 +220,6 @@ export const deathEvent = defineConfig({
'This is shown as the action name anywhere the user can trigger the action from',
id: 'event.death.action.register.label'
},
review: DEATH_DECLARATION_REVIEW,
deduplication: {
id: 'death-deduplication',
label: {
Expand Down
22 changes: 16 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ import { fontsHandler } from './api/fonts/handler'
import { recordNotificationHandler } from './api/record-notification/handler'
import {
getCustomEventsHandler,
onAnyActionHandler
onAnyActionHandler,
onCustomActionHandler
} from '@countryconfig/api/custom-event/handler'
import { readFileSync } from 'fs'
import {
ActionDocument,
ActionStatus,
Expand Down Expand Up @@ -92,7 +92,7 @@ export interface ITokenPayload {
export default function getPlugins() {
const plugins: any[] = [inert, JWT]

if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV !== 'test') {
plugins.push({
plugin: Pino,
options: {
Expand Down Expand Up @@ -641,6 +641,16 @@ export async function createServer() {
}
})

server.route({
method: 'POST',
path: `/trigger/events/{event}/actions/${ActionType.CUSTOM}`,
handler: onCustomActionHandler,
options: {
tags: ['api', 'events'],
description: 'Receives notifications on event custom action'
}
})

server.route({
method: 'POST',
path: '/trigger/events/{event}/actions/{action}',
Expand Down Expand Up @@ -748,9 +758,9 @@ export async function createServer() {
await syncLocationLevels()
await syncLocationStatistics()

const logMsg = `Server successfully started on ${COUNTRY_CONFIG_HOST}:${COUNTRY_CONFIG_PORT}`
logger.info(logMsg)
server.log('info', logMsg)
logger.info(
`Server successfully started on ${COUNTRY_CONFIG_HOST}:${COUNTRY_CONFIG_PORT}`
)
}

return { server, start, stop }
Expand Down
5 changes: 5 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export const logger =
]
})
: pino({
serializers: {
req: () => undefined,
res: () => undefined,
responseTime: () => undefined
},
transport: {
target: 'pino-pretty',
options: {
Expand Down
Loading
Loading