Skip to content

Conversation

@rikukissa
Copy link
Member

@rikukissa rikukissa commented Nov 20, 2024

@github-actions
Copy link

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

"paths": {
"@gateway/*": ["./*"]
"@gateway/*": ["./*"],
"@events/*": ["../../events/src/*"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little nasty – it is because gateway imports the appRouter from events

import type { AppRouter } from '@opencrvs/events/src/router'

which again imports modules inside Events with the @events/... paths.

❯ yarn test:compilation
yarn run v1.22.4
$ tsc --noEmit
../events/src/service/events.ts:12:27 - error TS2307: Cannot find module '@events/storage/mongodb' or its corresponding type declarations.

12 import { getClient } from '@events/storage/mongodb'
                             ~~~~~~~~~~~~~~~~~~~~~~~~~

])
})
)
type: z.string()
Copy link
Member Author

@rikukissa rikukissa Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only field the user can really send at the point of Event creation is type if we take on the approach of only submitting actions like registerEvent(eventId, registrationData) from the client

url: env.EVENTS_URL,
transformer: superjson,
headers({ opList }) {
const headers = opList[0].context?.headers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all happy about this. opList is a non-empty list but still..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we parse it and throw to be sure, have a default or acknowledge the possibly undefined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit wonky that the opList cannot be strictly typed :/ but yeah works like this or ! with a comment or ^

@ocrvs-bot
Copy link
Contributor

Your environment is deployed to https://ocrvs-7824-b.opencrvs.dev

Copy link
Contributor

@makelicious makelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Non functional comments

if (obj.type === ActionType.REGISTER) {
return 'RegisterAction'
}
return 'CreateAction'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to be explicit here e.g. not defaulting to anything but exhausting the options

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we do type satisfies never to make sure all cases are handled at the end

url: env.EVENTS_URL,
transformer: superjson,
headers({ opList }) {
const headers = opList[0].context?.headers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we parse it and throw to be sure, have a default or acknowledge the possibly undefined?

APPLICATION_CONFIG_URL: url({ devDefault: 'http://localhost:2021/' }),
NOTIFICATION_URL: url({ devDefault: 'http://localhost:2020/' }),
WORKFLOW_URL: url({ devDefault: 'http://localhost:5050/' }),
EVENTS_URL: url({ devDefault: 'http://localhost:5555/' }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: Since we are using both conventions, with and without trailing slash, I would opt for without when introducing new ones. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; an extra trailing slash in our current setup might convey to a newcomer that it has a meaning that it doesn't

.mutation(async (options) => {
return addAction(options.input.eventId, {
...options.input.action,
type: 'NOTIFY',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using these through the ActionType.NOTIFY will make changing them much easier in the future.

registrationNumber: z.string()
})
export const CreateActionInput = ActionInputBase.extend({})
export const NotifyActionInput = ActionInputBase.extend({})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment for this pattern? Is it a matter of taking copy of the base an separating the type extension?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RegisterActionInput.extend({ type: z.enum([ActionType.REGISTER]) }) since one could argue that this is not RegisterActionInput until it has the type

DeclareActionInput.extend({ type: z.enum([ActionType.DECLARE]) }),
RegisterActionInput.extend({ type: z.enum([ActionType.REGISTER]) })
])
.and(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there semantic difference between extend and and?

Copy link
Member

@naftis naftis Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.and apparently creates { name: string } & { age: number } while .extend creates { name: string; age: number }

https://zod.dev/?id=merge (merge is equivalent to extend but has better example :D)
vs
https://zod.dev/?id=and

with:
node-version-file: .nvmrc

- name: Extract dependencies for ${{ matrix.package }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could benefit from adding description for this documenting the reason/aim

"xregexp": "^4.2.0"
},
"devDependencies": {
"@opencrvs/gateway": "^1.5.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the client need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does now as I added the logic to look at workflow dependencies to figure out which packages cannot be optimised away in build and test processes. Client did seem to have a dependency to gateway for whatever reason

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find the dependency but couldn't :O

@rikukissa rikukissa changed the base branch from feat/event-types to develop November 25, 2024 08:39
@rikukissa rikukissa merged commit 89ce49a into develop Nov 25, 2024
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants