Skip to content
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

Rewrite JSONImporter in TypeScript. Closes #30 #43

Merged
merged 23 commits into from
Oct 4, 2022
Merged

Conversation

umesh-timalsina
Copy link
Contributor

No description provided.

@umesh-timalsina umesh-timalsina changed the title One to one refactor with TypeScript Rewrite JSONImporter in TypeScript Sep 28, 2022
@umesh-timalsina umesh-timalsina changed the title Rewrite JSONImporter in TypeScript Rewrite JSONImporter in TypeScript. Closes #30 Sep 28, 2022
@umesh-timalsina umesh-timalsina marked this pull request as ready for review September 28, 2022 23:24
Copy link
Collaborator

@brollb brollb left a comment

Choose a reason for hiding this comment

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

Overall, it looks good! The concurrency issues should be addressed before merging since they introduce bugs but before you fix them, we should add tests reproducing the issue for regression testing at the very least.

lib/common/JSONImporter/Exporter.ts Outdated Show resolved Hide resolved
lib/common/JSONImporter/Exporter.ts Outdated Show resolved Hide resolved
lib/common/JSONImporter/Exporter.ts Outdated Show resolved Hide resolved
lib/common/JSONImporter/Importer.ts Outdated Show resolved Hide resolved
return [
new NodeChangeSet(
nodePath,
childState.id || '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably shouldn't use '' since that is actually used for the root node. undefined would probably be better.

resolvedSelectors.record(parentPath, alternateSelector, created);
}
const nodeState = await this.toJSON(created, new OmittedProperties(['children']));
const changes = gmeDiff(nodeState, state);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't like diffing in the patch fn if it can be avoided but this should be explored in a different PR

lib/common/JSONImporter/Models.ts Outdated Show resolved Hide resolved
Comment on lines 12 to 27
super(args);
const invalidProperties = INVALID_PROPS.filter(prop => this.has(prop));

if(invalidProperties.length) {
throw new Error(`Invalid properties to omit: ${invalidProperties.join(', ')}`);
}
}

withRelatedProperties(): OmittedProperties {
const relatedProps = Object.keys(RELATED_PROPERTIES)
.filter(key => this.has(key))
.flatMap(key => RELATED_PROPERTIES[key]);

relatedProps.forEach(dep => this.add(dep));
return this;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add a code formatter - like prettier - as a githook (not in this PR).

package.json Outdated Show resolved Hide resolved
@brollb
Copy link
Collaborator

brollb commented Oct 4, 2022

Nice work, @umesh-timalsina! There are a few things left for other PRs:

@brollb brollb merged commit 4659c8f into main Oct 4, 2022
@brollb brollb deleted the 30-ts-refactor branch October 4, 2022 15:34
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.

2 participants