-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: persons endpoint #18
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
113f5d6
feat: persons endpoint
joscha 7b3f48b
Merge branch 'main' into joscha/persons-endpoint
joscha 45556ec
feat: persons endpoint; search iterator
joscha e9b0b59
style: clean types
joscha dd60999
style: clean types
joscha 7ee3be9
style: clean types; II
joscha 9ab4d71
test: add test for persons endpoint
joscha 668e280
refactor: search iterator HOC
joscha 180eb4f
test: persons iterator test
joscha bfe25e1
refactor: move fn
joscha a2f6d24
feat: persons endpoint; single get
joscha e468838
ci: add coderabbit config
joscha ce34b20
feat: persons endpoint; delete, create, update, fields
joscha 00475a5
fix: persons ednpoint; dates search
joscha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
reviews: | ||
auto_review: | ||
drafts: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
gitignore_excludes: true | ||
eof_newline: true | ||
exclude: | ||
- .yamllint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { PagedResponse } from './paged_response.ts' | ||
import type { PagedRequest } from './paged_request.ts' | ||
|
||
export const createSearchIteratorFn = < | ||
FN extends (r: PAGED_REQUEST) => Promise<PAGED_RESPONSE>, | ||
PAGED_REQUEST extends PagedRequest, | ||
PAGED_RESPONSE extends | ||
& PagedResponse | ||
& Record<PAYLOAD_KEY, SINGLE_RESPONSE[]>, | ||
PAYLOAD_KEY extends string = | ||
& keyof Omit<PAGED_RESPONSE, keyof PagedResponse> | ||
& string, | ||
SINGLE_RESPONSE = object, | ||
>(searchFn: FN, key: PAYLOAD_KEY) => { | ||
async function* searchIterator( | ||
params: Omit<PAGED_REQUEST, 'page_token'>, | ||
): AsyncGenerator<PAGED_RESPONSE[]> { | ||
let page_token: string | undefined = undefined | ||
while (true) { | ||
const response: PAGED_RESPONSE = await searchFn( | ||
// TODO(@joscha): remove cast | ||
(page_token | ||
? { ...params, page_token } | ||
: params) as PAGED_REQUEST, | ||
) | ||
|
||
// TODO(@joscha): remove cast | ||
yield response[key] as unknown as PAGED_RESPONSE[] | ||
|
||
if (response.next_page_token === null) { | ||
// no more pages to fetch | ||
return | ||
} else { | ||
page_token = response.next_page_token | ||
} | ||
} | ||
} | ||
return searchIterator | ||
} | ||
Comment on lines
+4
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider removing TODO comments or addressing them. There are TODO comments indicating casts that need to be removed. Ensure these are addressed before finalizing the code. - // TODO(@joscha): remove cast
- (page_token
- ? { ...params, page_token }
- : params) as PAGED_REQUEST,
+ const requestParams: PAGED_REQUEST = page_token
+ ? { ...params, page_token }
+ : params;
+ const response: PAGED_RESPONSE = await searchFn(requestParams); - // TODO(@joscha): remove cast
- yield response[key] as unknown as PAGED_RESPONSE[]
+ const responsePayload: PAGED_RESPONSE[] = response[key];
+ yield responsePayload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Ensure proper error handling for the asynchronous generator.
The function does not handle potential errors from the
searchFn
call. Consider adding try-catch blocks to handle errors gracefully.Committable suggestion