-
Notifications
You must be signed in to change notification settings - Fork 3
Bugfix merge schemas #15
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
5daa672 to
126cbe6
Compare
|
@Ge11ert, check this out, please 🙏 |
Ge11ert
left a comment
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.
LGTM, but have a few questions
utils/merge/mergeSchemas.js
Outdated
| action(first, second) { | ||
| if (!schema1.properties || !schema2.properties) return first; | ||
|
|
||
| const firstProperties = Object.keys(schema1.properties); |
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.
To get values of required prop we use result (resulting schema after merge) and schema 2 (result[key], schema2[key]). Here we use original schema 1 and schema 2.
Is this intended?
And, btw, maybe it will be better to pass schema1 and schema 2 as action func args and not to rely on closure? Then we will be able to move propsToMerge and propsToOverride out of function and not to generate new consts on every function call. Up to you, as one says, but worth considering.
utils/merge/mergeSchemas.js
Outdated
|
|
||
| const optionalOverride = firstProperties | ||
| .filter(property => secondProperties.includes(property)) | ||
| .filter(property => first.includes(property) && (!second || !second.includes(property))); |
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.
Multiple filters look a bit excessive. Can we merge them into one?
utils/merge/mergeSchemas.js
Outdated
|
|
||
| const optionalOverride = firstProperties | ||
| .filter(property => secondProperties.includes(property)) | ||
| .filter(property => first.includes(property) && (!second || !second.includes(property))); |
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.
How do you think, should we perform all checks in filter when there is no second at all? I mean, maybe we can check for !second right after schema1/2.properties check and exit early
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.
if there is no second at all, it exactly means that we need to override (firstRequired -> ['someProp'], secondRequired -> undefined => it means that someProp has to be optional)
On other comments - up to codewriter if it affects nothing. I changed it
126cbe6 to
38d640a
Compare
38d640a to
95465d3
Compare
Ge11ert
left a comment
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.
@igoradamenko approved
|
Build is failing due to the Coveralls issues: lemurheavy/coveralls-public#1708. I'm ignoring them and gonna merge the PR because the previous builds were green. |
|
Landed in @funboxteam/[email protected]. @SonyaOrlova, @Ge11ert, thanks! |
suggest to move resolving merge schemas conflicts to merge schemas handler