-
Notifications
You must be signed in to change notification settings - Fork 72
fix(core): moving some files to a shared location #4018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Part of ENG-433 Signed-off-by: Ramil Garipov <ramil@metriport.com>
WalkthroughThe changes update import paths for the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant PatientImportQueryLocal
participant SharedApi
Caller->>PatientImportQueryLocal: processPatientQuery()
PatientImportQueryLocal->>SharedApi: startPatientQuery({..., context: patientImportContext})
SharedApi-->>PatientImportQueryLocal: { requestId }
PatientImportQueryLocal->>SharedApi: startDocumentQuery({..., context: patientImportContext })
SharedApi-->>PatientImportQueryLocal: { requestId }
PatientImportQueryLocal-->>Caller: (processing/logging with patientImportContext)
sequenceDiagram
participant Caller
participant startPatientQuery
Caller->>startPatientQuery: startPatientQuery({ ..., context })
startPatientQuery->>startPatientQuery: Call API with context
startPatientQuery-->>Caller: { requestId }
sequenceDiagram
participant Caller
participant startDocumentQuery
Caller->>startDocumentQuery: startDocumentQuery({ ..., context })
startDocumentQuery->>startDocumentQuery: Call API with context
startDocumentQuery-->>Caller: { requestId }
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error code ERR_SSL_WRONG_VERSION_NUMBER 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Part of ENG-433 Signed-off-by: Ramil Garipov <ramil@metriport.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/api/src/routes/internal/medical/patient-job.ts
(1 hunks)packages/infra/lib/jobs/jobs-stack.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: - Use the Onion Pattern to organize a package's code in layers - Try to use immutable code and avoid sharing state across different functions, objects, and systems - Try...
**/*.ts
: - Use the Onion Pattern to organize a package's code in layers
- Try to use immutable code and avoid sharing state across different functions, objects, and systems
- Try to build code that's idempotent whenever possible
- Prefer functional programming style functions: small, deterministic, 1 input, 1 output
- Minimize coupling / dependencies
- Avoid modifying objects received as parameter
- Only add comments to code to explain why something was done, not how it works
- Naming
- classes, enums:
PascalCase
- constants, variables, functions:
camelCase
- file names:
kebab-case
- table and column names:
snake_case
- Use meaningful names, so whoever is reading the code understands what it means
- Don’t use negative names, like
notEnabled
, preferisDisabled
- For numeric values, if the type doesn’t convey the unit, add the unit to the name
- Typescript
- Use types
- Prefer
const
instead oflet
- Avoid
any
and casting fromany
to other types- Type predicates: only applicable to narrow down the type, not to force a complete type conversion
- Prefer deconstructing parameters for functions instead of multiple parameters that might be of
the same type- Don’t use
null
inside the app, only on code interacting with external interfaces/services,
like DB and HTTP; convert toundefined
before sending inwards into the code- Use
async/await
instead of.then()
- Use the strict equality operator
===
, don’t use abstract equality operator==
- When calling a Promise-returning function asynchronously (i.e., not awaiting), use
.catch()
to
handle errors (seeprocessAsyncError
andemptyFunction
depending on the case)- Date and Time
- Always use
buildDayjs()
to createdayjs
instances- Prefer
dayjs.duration(...)
to create duration consts and keep them asduration
- Prefer Nullish Coalesce (??) than the OR operator (||) to provide a default value
- Avoid creating arrow functions
- Use truthy syntax instead of
in
- i.e.,if (data.link)
notif ('link' in data)
- Error handling
- Pass the original error as the new one’s
cause
so the stack trace is persisted- Error messages should have a static message - add dynamic data to MetriportError's
additionalInfo
prop- Avoid sending multiple events to Sentry for a single error
- Global constants and variables
- Move literals to constants declared after imports when possible (avoid magic numbers)
- Avoid shared, global objects
- Avoid using
console.log
andconsole.error
in packages other than utils, infra and shared,
and try to useout().log
instead- Avoid multi-line logs
- don't send objects as a second parameter to
console.log()
orout().log()
- don't create multi-line strings when using
JSON.stringify()
- Use
eslint
to enforce code style- Use
prettier
to format code- max column length is 100 chars
- multi-line comments use
/** */
- scripts: top-level comments go after the import
packages/infra/lib/jobs/jobs-stack.ts
packages/api/src/routes/internal/medical/patient-job.ts
🧠 Learnings (1)
packages/api/src/routes/internal/medical/patient-job.ts (1)
Learnt from: RamilGaripov
PR: metriport/metriport#3976
File: packages/api/src/routes/medical/patient.ts:541-543
Timestamp: 2025-06-18T21:05:22.256Z
Learning: In packages/api/src/routes/medical/patient.ts, inline schema definitions like cohortIdSchema are acceptable and don't need to be moved to separate schema files when the user prefers to keep them inline.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/infra/lib/jobs/jobs-stack.ts (1)
28-28
: ```shell
#!/bin/bashDisplay the context around the 'entry' property in jobs-stack.ts to see how paths are resolved
rg -n "entry:" -A5 -B5 packages/infra/lib/jobs/jobs-stack.ts
</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
}); | ||
if (this.waitTimeAtTheEndInMillis > 0) await sleep(this.waitTimeAtTheEndInMillis); | ||
} catch (error) { | ||
const { log } = out(`PatientImport processPatientQuery.local - cx ${cxId}, job ${jobId}`); | ||
const { log } = out( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need these edits -- this is the patient import code so it doesn't need to send in its own context, can just be inline as it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just replacing the string with a const. What's the big deal? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just unnecessary complexity. If I change the global one, I'm going to have to consider what that might mean for this error message (the fact that they're equal now is arbitrary -- the local implementation error handling might want a different context than the shard code). Generally tying things together that don't need to be is better avoided unless there's a full push it to replace it everywhere and the decision to have shared context -- in which case we'd updated all the local implementations (not just this one).
But, it's low stakes so no worries -- not a blocker by any means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/infra/lib/jobs/jobs-scheduler.ts (1)
18-25
: Consider extracting the hardcoded function name to a constant.The function follows functional programming principles and immutability as required by the coding guidelines. However, the hardcoded
"StartPatientJobsScheduler"
could be extracted to a constant for better maintainability.+const JOBS_SCHEDULER_LAMBDA_NAME = "StartPatientJobsScheduler"; function getSettings(props: JobsSchedulerProps, config: NonNullable<EnvConfig["jobs"]>) { return { ...props, - name: "StartPatientJobsScheduler", + name: JOBS_SCHEDULER_LAMBDA_NAME, scheduleExpression: config.startPatientJobsSchedulerScheduleExpression, url: `http://${props.apiAddress}${config.startPatientJobsSchedulerUrl}`, }; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/infra/lib/api-stack.ts
(2 hunks)packages/infra/lib/jobs/jobs-scheduler.ts
(1 hunks)packages/infra/lib/jobs/jobs-stack.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/infra/lib/jobs/jobs-stack.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: - Use the Onion Pattern to organize a package's code in layers - Try to use immutable code and avoid sharing state across different functions, objects, and systems - Try...
**/*.ts
: - Use the Onion Pattern to organize a package's code in layers
- Try to use immutable code and avoid sharing state across different functions, objects, and systems
- Try to build code that's idempotent whenever possible
- Prefer functional programming style functions: small, deterministic, 1 input, 1 output
- Minimize coupling / dependencies
- Avoid modifying objects received as parameter
- Only add comments to code to explain why something was done, not how it works
- Naming
- classes, enums:
PascalCase
- constants, variables, functions:
camelCase
- file names:
kebab-case
- table and column names:
snake_case
- Use meaningful names, so whoever is reading the code understands what it means
- Don’t use negative names, like
notEnabled
, preferisDisabled
- For numeric values, if the type doesn’t convey the unit, add the unit to the name
- Typescript
- Use types
- Prefer
const
instead oflet
- Avoid
any
and casting fromany
to other types- Type predicates: only applicable to narrow down the type, not to force a complete type conversion
- Prefer deconstructing parameters for functions instead of multiple parameters that might be of
the same type- Don’t use
null
inside the app, only on code interacting with external interfaces/services,
like DB and HTTP; convert toundefined
before sending inwards into the code- Use
async/await
instead of.then()
- Use the strict equality operator
===
, don’t use abstract equality operator==
- When calling a Promise-returning function asynchronously (i.e., not awaiting), use
.catch()
to
handle errors (seeprocessAsyncError
andemptyFunction
depending on the case)- Date and Time
- Always use
buildDayjs()
to createdayjs
instances- Prefer
dayjs.duration(...)
to create duration consts and keep them asduration
- Prefer Nullish Coalesce (??) than the OR operator (||) to provide a default value
- Avoid creating arrow functions
- Use truthy syntax instead of
in
- i.e.,if (data.link)
notif ('link' in data)
- Error handling
- Pass the original error as the new one’s
cause
so the stack trace is persisted- Error messages should have a static message - add dynamic data to MetriportError's
additionalInfo
prop- Avoid sending multiple events to Sentry for a single error
- Global constants and variables
- Move literals to constants declared after imports when possible (avoid magic numbers)
- Avoid shared, global objects
- Avoid using
console.log
andconsole.error
in packages other than utils, infra and shared,
and try to useout().log
instead- Avoid multi-line logs
- don't send objects as a second parameter to
console.log()
orout().log()
- don't create multi-line strings when using
JSON.stringify()
- Use
eslint
to enforce code style- Use
prettier
to format code- max column length is 100 chars
- multi-line comments use
/** */
- scripts: top-level comments go after the import
packages/infra/lib/api-stack.ts
packages/infra/lib/jobs/jobs-scheduler.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
packages/infra/lib/api-stack.ts (2)
49-49
: LGTM: Import follows established patterns.The import is correctly placed alphabetically and follows the existing import structure in the file.
740-747
: LGTM: Function call follows established patterns and provides proper parameters.The
createJobsScheduler
call is consistent with other similar function calls in the file (likecreateDocQueryChecker
andcreateCqDirectoryRebuilder
) and correctly passes all required parameters according to theJobsSchedulerProps
type.packages/infra/lib/jobs/jobs-scheduler.ts (3)
1-9
: LGTM: Clean imports following TypeScript best practices.The imports are well-organized and include only necessary dependencies. The use of type-only imports where appropriate follows TypeScript conventions.
10-16
: LGTM: Well-defined type interface following naming conventions.The
JobsSchedulerProps
type is properly defined using PascalCase as specified in the coding guidelines, and includes all necessary properties with appropriate TypeScript types.
27-48
: LGTM: Function follows functional programming principles and handles edge cases properly.The function adheres to the coding guidelines by:
- Using functional programming style (small, deterministic, single responsibility)
- Properly handling the case where
config.jobs
is undefined by returningundefined
- Using meaningful parameter names and TypeScript types
- Avoiding mutation of input parameters
- Following camelCase naming convention
The early return pattern for missing configuration is appropriate and prevents errors downstream.
… eng-433-moving-files Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-433 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Part of ENG-433
Issues:
Dependencies
Description
Testing
Release Plan
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Refactor
Chores