fix: update source api types to match S2 codebase #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I'm changing
Currently, some buckets/prefixes return parse errors while others do not:
The core issue regarding why the second API response failed to parse is that the
youssef-harbyaccount contains a populatedmetadata_public.domainsarray:Note that the account used in the successful API response lacks a populated
metadata_public.domainsarray:The proxy fails when it encounters a populated domain array due to the fact that the domain struct in the data proxy codebase does not match the API response. On the API, the
statusvalue is an enum1 added in S2:However, the data proxy is expecting the legacy schema where a domain would merely have a boolean
verifiedproperty:data.source.coop/src/apis/source.rs
Lines 100 to 104 in f497d48
How I did it
In this PR, we update the expected API schema to match the schema from within the source.coop codebase, namely within the following files:
I let Cursor AI take the wheel to update these types.
Also added tests with the real (but anonymized) data returned from https://source.coop/api/v1/products/youssef-harby/weather-station-realtime-parquet to ensure parsing would not throw an error.
Finally, improved the documentation of the file.
How to test it
PR Checklist
and I have opened issue/PR #XXX to track the change.
Related Issues
Footnotes
https://github.com/source-cooperative/source.coop/blob/c49aa11bb3f7a7bfd7caa40ff66193f9fe437b08/src/types/account.ts#L52 ↩