Skip to content

Commit

Permalink
Merge branch develop into renovate/typescript-5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jamil314 committed Nov 19, 2024
2 parents 3ada53d + 5334759 commit 0fb9024
Show file tree
Hide file tree
Showing 26 changed files with 1,097 additions and 28 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

6 changes: 2 additions & 4 deletions development-environment/setup-countryconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ echo

cd ../

BRANCH=master
if [[ $CI == "true" ]]; then
BRANCH=develop
fi
BRANCH=develop


git clone --branch $BRANCH --depth 1 https://github.com/opencrvs/opencrvs-countryconfig.git

Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ import { ReviewCorrection } from './views/ReviewCorrection/ReviewCorrection'
import { ReviewCertificate } from './views/PrintCertificate/ReviewCertificateAction'
import AllUserEmail from './views/SysAdmin/Communications/AllUserEmail/AllUserEmail'
import { ReloadModal } from './views/Modals/ReloadModal'
import { Workqueues } from './v2-events/workqueues'
import { V2_ROOT_ROUTE } from './v2-events/routes'

interface IAppProps {
client?: ApolloClient<NormalizedCacheObject>
Expand Down Expand Up @@ -537,6 +539,11 @@ export function App(props: IAppProps) {
path={routes.PRINT_RECORD}
component={PrintRecord}
/>
<ProtectedRoute
exact
path={V2_ROOT_ROUTE}
component={Workqueues}
/>
</Switch>
</TransitionWrapper>
</>
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/components/form/FormFieldGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ class FormSectionComponent extends React.Component<Props> {
}

const nestedFieldName = `${field.name}.nestedFields.${nestedField.name}`

const nestedFieldTouched =
touched[field.name] &&
(touched[field.name] as unknown as ITouchedNestedFields)
Expand Down
20 changes: 20 additions & 0 deletions packages/client/src/v2-events/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/
module.exports = {
rules: {
'no-restricted-imports': [
'error',
{
patterns: ['@client/*', '!@client/v2-events', '!@client/components']
}
]
}
}
12 changes: 12 additions & 0 deletions packages/client/src/v2-events/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

export function noop() {}
11 changes: 11 additions & 0 deletions packages/client/src/v2-events/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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.
*/
export const V2_ROOT_ROUTE = '/v2'
12 changes: 12 additions & 0 deletions packages/client/src/v2-events/useEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

export function noop() {}
16 changes: 16 additions & 0 deletions packages/client/src/v2-events/workqueues/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 React from 'react'

export function Workqueues() {
return <div>This is where it starts from</div>
}
24 changes: 24 additions & 0 deletions packages/events/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.
*/
module.exports = {
extends: '../../.eslintrc.js',
env: {
es6: true
},
overrides: [
{
files: ['*.ts'],
parserOptions: {
project: ['./tsconfig.json']
}
}
]
}
21 changes: 21 additions & 0 deletions packages/events/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
12 changes: 12 additions & 0 deletions packages/events/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG BRANCH=develop
FROM opencrvs/ocrvs-base:${BRANCH}

USER node

WORKDIR /app/packages/events
COPY --chown=node:node packages/events/*.json /app/packages/events/
RUN yarn install --frozen-lockfile
COPY --chown=node:node packages/events /app/packages/events
RUN yarn build

CMD [ "yarn", "start:prod" ]
21 changes: 21 additions & 0 deletions packages/events/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*.md
*.yml
*.yaml
.vscode
**/.git
**/test

# From root
**/node_modules
**/coverage
**/.DS_Store
**/.env
**/*.log
.secrets/*
data
grafana

# Exclude unused packages
packages/*
!packages/commons
!packages/events
51 changes: 51 additions & 0 deletions packages/events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@opencrvs/events",
"version": "1.5.0",
"description": "OpenCRVS Events service",
"license": "MPL-2.0",
"private": true,
"scripts": {
"start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts",
"start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js",
"test": "yarn test:compilation && vitest run",
"lint": "eslint -c .eslintrc.js --fix ./src --max-warnings=0",
"precommit": "lint-staged",
"test:compilation": "tsc --noEmit",
"build": "tsc",
"build:clean": "rm -rf build"
},
"dependencies": {
"@opencrvs/commons": "^1.3.0",
"@trpc/server": "^11.0.0-rc.532",
"app-module-path": "^2.2.0",
"envalid": "^8.0.0",
"mongodb": "6.9.0",
"superjson": "1.9.0-0",
"tsconfig-paths": "^3.13.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"cross-env": "^7.0.0",
"eslint": "^7.11.0",
"vite-tsconfig-paths": "^3.5.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-prettier": "^4.0.0",
"lint-staged": "^15.0.0",
"mongodb-memory-server": "^10.1.2",
"nodemon": "^3.0.0",
"prettier": "2.8.8",
"ts-jest": "27.1.4",
"ts-node": "^6.1.1",
"typescript": "4.9.5",
"vitest": "^2.1.5"
},
"lint-staged": {
"src/**/*.{ts,graphql}": [
"prettier --write",
"eslint -c .eslintrc.js --fix"
]
}
}
16 changes: 16 additions & 0 deletions packages/events/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { cleanEnv, url } from 'envalid'

export const env = cleanEnv(process.env, {
MONGO_URL: url({ devDefault: 'mongodb://localhost/events' })
})
48 changes: 48 additions & 0 deletions packages/events/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 { vi } from 'vitest'
import { appRouter, t } from './router'
import {
setupServer,
getClient,
resetServer
} from './storage/__mocks__/mongodb'

const { createCallerFactory } = t

vi.mock('@events/storage/mongodb')

beforeAll(async () => {
await setupServer()
})

afterEach(async () => {
resetServer()
})

test('creating a declaration is an idempotent operation', async () => {
const createCaller = createCallerFactory(appRouter)

const caller = createCaller({})
const db = await getClient()

await caller.event.create({
transactionId: '1',
record: { type: 'birth', fields: [] }
})

await caller.event.create({
transactionId: '1',
record: { type: 'birth', fields: [] }
})

expect(await db.collection('events').find().toArray()).toHaveLength(1)
})
25 changes: 25 additions & 0 deletions packages/events/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.
*/

// eslint-disable-next-line import/no-unassigned-import
import '@opencrvs/commons/monitoring'

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('app-module-path').addPath(require('path').join(__dirname, '../'))

import { appRouter } from './router'
import { createHTTPServer } from '@trpc/server/adapters/standalone'

const server = createHTTPServer({
router: appRouter
})

server.listen(5555)
45 changes: 45 additions & 0 deletions packages/events/src/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 { initTRPC } from '@trpc/server'
import superjson from 'superjson'
import { z } from 'zod'
import { createEvent, EventInput, getEventById } from './service/events'

export const t = initTRPC.create({
transformer: superjson
})

const router = t.router
const publicProcedure = t.procedure

/**
* @public
*/
export type AppRouter = typeof appRouter

export const appRouter = router({
event: router({
create: publicProcedure
.input(
z.object({
transactionId: z.string(),
record: EventInput
})
)
.mutation(async (options) => {
return createEvent(options.input.record, options.input.transactionId)
}),
get: publicProcedure.input(z.string()).query(async ({ input }) => {
return getEventById(input)
})
})
})
Loading

0 comments on commit 0fb9024

Please sign in to comment.