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

chore: separate schemas from conditions to allow better combinations/reuse of schemas #591

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

derekpierre
Copy link
Member

@derekpierre derekpierre commented Oct 4, 2024

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:
Currently, condition schemas and condition objects are mixed in the same module. This can generate a circular dependency when trying to reuse schemas for other condition schemas.

Instead, we should separate schemas from conditions so that the schemas can be obtained from a standalone module, increasing their use with other condition schemas.

This change allows us to have a anyConditionSchema that includes all condition schemas where any condition can be re-used eg. in CompoundCondition and SequentialCondition whose schemas can be recursive.

Overall, this PR is simply reshuffling code around and ensuring that the same exports from before are still available.

NOTE that the schemas folder is not publicly exported as part of @nucypher/taco library directly. Instead, schemas are still exported from their original condition module to maintain compatibility.

Issues fixed/closed:

  • Fixes #...

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@derekpierre derekpierre mentioned this pull request Oct 4, 2024
16 tasks
@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 97.00214% with 14 lines in your changes missing coverage. Please review.

Please upload report for BASE (epic-v0.6.x@2a51cac). Learn more about missing BASE report.

Files with missing lines Patch % Lines
packages/taco/src/conditions/schemas/common.ts 90.76% 6 Missing ⚠️
packages/taco/src/conditions/schemas/compound.ts 91.66% 4 Missing ⚠️
packages/taco/src/conditions/schemas/contract.ts 95.87% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             epic-v0.6.x     #591   +/-   ##
==============================================
  Coverage               ?   89.00%           
==============================================
  Files                  ?       71           
  Lines                  ?     6383           
  Branches               ?      165           
==============================================
  Hits                   ?     5681           
  Misses                 ?      702           
  Partials               ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@derekpierre derekpierre changed the title [WIP] Commonize Condition Schema [WIP] chore: separate and commonize condition schema Oct 7, 2024
@derekpierre derekpierre changed the title [WIP] chore: separate and commonize condition schema chore: separate and commonize condition schema Oct 7, 2024
@derekpierre derekpierre self-assigned this Oct 7, 2024
@derekpierre derekpierre marked this pull request as ready for review October 7, 2024 20:21
@derekpierre derekpierre changed the title chore: separate and commonize condition schema chore: separate and commonize condition schemas Oct 8, 2024
@derekpierre derekpierre changed the title chore: separate and commonize condition schemas chore: separate schemas from conditions to allow better reuse Oct 8, 2024
@derekpierre derekpierre changed the title chore: separate schemas from conditions to allow better reuse chore: separate schemas from conditions to allow better combinations/reuse of schemas Oct 8, 2024
@derekpierre derekpierre force-pushed the epic-v0.6.x branch 2 times, most recently from bfef228 to 2a51cac Compare October 10, 2024 17:41
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

LGTM!

Good TS work here, sir 🫡

Comment on lines +4 to +5
jsonApiConditionSchema,
JsonApiConditionType,
Copy link
Member

Choose a reason for hiding this comment

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

What's the criteria for capitalizing some elements and others not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure if there were criteria, but there was a pre-existing format for earlier conditions where the schema definition was not capitalized, but other types were.

@derekpierre derekpierre merged commit 5afedd8 into nucypher:epic-v0.6.x Oct 15, 2024
4 checks passed
derekpierre added a commit that referenced this pull request Oct 15, 2024
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