-
Notifications
You must be signed in to change notification settings - Fork 11
[Persistence]: Backend implementation #1211
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
Merged
rubenthoms
merged 42 commits into
equinor:persistence/main
from
rubenthoms:persistence/backend-database-access
Oct 28, 2025
Merged
Changes from 22 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
42efb93
wip
rubenthoms b13ae37
Backend implementations for persistence
rubenthoms deaa37c
Updated lock file
rubenthoms e5c52a9
fix: linting
rubenthoms 348a5d7
Adding nosec comments to local dev code
rubenthoms 9ade9ff
fix: mypy
rubenthoms 3cc435a
fix: linting etc.
rubenthoms 5e1877e
fix: regenerated frontend api files
rubenthoms 126fca0
Adjusted generated api files
rubenthoms 0000411
Removed snapshot previews
rubenthoms bcb6c6c
Removed SPA adjustments in nginx config
rubenthoms 8be97b4
Merge branch 'persistence/main' into persistence/backend-database-access
rubenthoms 2af12fa
Adjusted after review comments
rubenthoms bc856f7
First adjustments after review discussion
rubenthoms 2009a18
wip
rubenthoms e56e498
Refactoring
rubenthoms 90daf5b
Multiple bug fixes
rubenthoms 00f2148
Removed unused imports
rubenthoms ebc509c
Final fixes
rubenthoms fed88fa
Re-generated api files, adjusted comments
rubenthoms 2d79071
Further simplifications
rubenthoms 23c985f
Documentation for endpoints
rubenthoms e15e22a
`FilterFactory` to ensure filter fields exist
rubenthoms dce4044
Re-generated api files
rubenthoms c021409
Removal of `limit` and `offset` from stores' `get_many_async`
rubenthoms 169c8ba
Adjustments to comments
rubenthoms 52c715d
Missing @no-cache decorator and removal of summary fields
rubenthoms 1bfaad8
Multiple adjustments after review
rubenthoms 64f0c05
Update backend_py/primary/primary/routers/persistence/router.py
rubenthoms 742cbfd
Update backend_py/primary/primary/routers/persistence/router.py
rubenthoms b73484d
Update frontend/src/api/autogen/sdk.gen.ts
rubenthoms 7cea0de
Update frontend/src/api/autogen/sdk.gen.ts
rubenthoms 2955bab
Adjustments according to review comments
rubenthoms 96d7ae1
Merge branch 'persistence/main' into persistence/backend-database-access
rubenthoms babcb4e
Marked util function as private
rubenthoms 2770917
Re-generated api files
rubenthoms 65dec0e
Comments for database document models
rubenthoms a07a523
formatting
rubenthoms dac5fff
Linting
rubenthoms fe366dc
Giving fake connection string for prod DB to skip local setup
rubenthoms 2f886c3
formatting
rubenthoms 608a875
Unused import
rubenthoms 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 hidden or 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 hidden or 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 hidden or 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,18 +1,38 @@ | ||
| import hashlib | ||
| from typing import Any, cast | ||
| from typing import Any, TypeVar, cast | ||
|
|
||
| from azure.core.async_paging import AsyncPageIterator, AsyncItemPaged | ||
|
|
||
|
|
||
| T = TypeVar("T") | ||
|
|
||
|
|
||
| # Utility function to hash a JSON string using SHA-256 | ||
| # This function mimics the behavior of TextEncoder in JavaScript, which encodes strings to | ||
| # UTF-8 before hashing. The output is a hexadecimal string representation of the hash. | ||
| # | ||
| # It is important that this function returns the same hash as the JavaScript version | ||
| def hash_sha256(json_string: str) -> str: | ||
| data = json_string.encode("utf-8") # Matches TextEncoder behavior | ||
| def hash_session_content_string(string: str) -> str: | ||
| data = string.encode("utf-8") # Matches TextEncoder behavior | ||
| hash_bytes = hashlib.sha256(data).digest() | ||
| hash_hex = "".join(f"{b:02x}" for b in hash_bytes) | ||
| return hash_hex | ||
|
|
||
|
|
||
| def cast_query_params(params: list[dict[str, Any]]) -> list[dict[str, object]]: | ||
| return cast(list[dict[str, object]], params) | ||
|
|
||
|
|
||
| def query_by_page(query_iterable: AsyncItemPaged[T], page_token: str | None) -> AsyncPageIterator[T]: | ||
| """ | ||
| Cosmosdb's `by_page` returns a more narrow subtype than anticipated. This makes | ||
| extra's like `.continuation_token` not show up in returned value's type. | ||
|
|
||
| This util function correctly casts the return value to the expected type | ||
| """ | ||
| pager = query_iterable.by_page(page_token) | ||
|
|
||
| if not isinstance(pager, AsyncPageIterator): | ||
| raise TypeError("Expected AsyncPageIterator from query_items_by_page_token_async") | ||
|
|
||
| return cast(AsyncPageIterator[T], pager) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.