-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
lang
option to DataType read operations (#473)
* feat: Add `lang` option to DataType read operations * update typescript defs * add getMany support * initial implementation of `TranslationApi` * * add @types/json-stable-strinfify * start writing unit tests * error handling for missing translation * fix error in sql query * * remove `message` from object when hashing * fix logic error when `put` * handle unexisting key in the indexing (by creating a new Set) * make `fieldRef` and `regionCode` optional when `get` * improve `get()` by ignoring not translated languages, improve typing * * make `index` private, run it on `put` * expose cache map through symbol and getter * improve `get` signature (by making `fieldRef` and `regionCode` optional) * add more unit tests * revert `index` as private method, update tests * update magic-bytes manually * add e2e/translation-api.js and expose translation api in mapeo project * * add translationTable to index writer * add translationDoc to entries for batching indexer * move decoding of translationDoc into `.index` function in translationApi * rever changes to `.index` method (better to accept doc than block) * first e2e tests * revert regionCode fallback (since its handled in an upper layer) * use default config for translationApi e2e tests, test with a bunch of translations * add translation fixtures * add check of expected translation * improve test messages * add assertion of matching preset docId with translation docIdRef * add tests and fixture for fields * Integrate actual translation-api in DataType * add type to translation * Promise.all translation on getMany * datatype clean, type translationApi in tests * add fallback when not matching `regionCode`, test that * re-add misterious dissapearing //ts-expect error on datatype * Apply suggestions from code review * Have better typing on `getByDocId` result * Avoid extra translation lookup * remove ts-ignore Co-authored-by: Evan Hahn <me@evanhahn.com> * revert removal of translation object clone in datatype * check if `fieldRef` is string before setting the property * Fix "use before define" issue with DataType & TranslationApi (#604) `DataType` needs access to `TranslationApi.prototype.get`, but `TranslationApi` needs access to `DataType`. To avoid this circular reference, pass a `getTranslations` function into `DataType`. * add e2e tests * add e2e tests for presets * chore: fix type errors in translation api e2e test (#619) See [this comment](https://github.com/digidem/mapeo-core-next/pull/473/files/a51f709ca5edf7eec82c37ab922eab81433119c3#diff-8d53b37e24956c77fbf7b47691ded78c4b5c35010b94ad0b7e3d4dc49bcb6419). --------- Co-authored-by: Tomás Ciccola <tciccola@digital-democracy.com> Co-authored-by: tomasciccola <117094913+tomasciccola@users.noreply.github.com> Co-authored-by: Evan Hahn <me@evanhahn.com>
- Loading branch information
1 parent
a84e89a
commit 7f8fcdd
Showing
9 changed files
with
402 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.