Closed noctera closed 2 years ago
can you please fix the ci errors.
LGTM. But I think we should add a unique key (maybe the version of the server and unique identifier for vocascan) in the export json to be able to check later when importing if this is really a vocab file.
This is a good idea. When we add the server version as a validation for imports, we can also check if some exportes json files are out of date when some structure will be changing in the future
The version key and the type are now built in.
Description
Serverside implementation of the import/export function, which allows to add and store vocabs from a package or group from/in a JSON file.
To do:
`GET /api/languagePackage/:languagePackageIdexport?queryStatus=false`
Response ```json { "name": "Englisch - German", "foreignWordLanguage": "en", "translatedWordLanguage": "de", "vocabsPerDay": 5, "rightWords": 2, "Groups": [ { "name": "unit 1", "description": "", "VocabularyCards": [ { "name": "test vocab", "description": "This is a test description", "drawerId": "21e8e24d-5879-432f-b8bb-0db6cf38bb17", "Translations": [ { "name": "test translation" } ] }, { "name": "test vocab", "description": "This is a test description", "drawerId": "21e8e24d-5879-432f-b8bb-0db6cf38bb17", "Translations": [ { "name": "test translation" } ] }, { "name": "test vocab", "description": "This is a test description", "drawerId": "4f318312-84d6-4091-bcb1-cff4766266c9", "Translations": [ { "name": "test translation" } ] } ] } ], "Drawers": [ { "id": "14f4c057-79da-4863-aa02-3bc918c0af45", "stage": 2, "queryInterval": 2 }, { "id": "ca7aadc8-9518-46ed-8652-aa57f315859e", "stage": 4, "queryInterval": 5 }, { "id": "ae1a7a74-15d6-45be-b66d-63907c4c1662", "stage": 7, "queryInterval": 60 }, { "id": "7bb1b5f2-1e55-457c-8a46-2b0a72a92c4a", "stage": 0, "queryInterval": 0 }, { "id": "4f318312-84d6-4091-bcb1-cff4766266c9", "stage": 1, "queryInterval": 1 }, { "id": "e31ee57c-27b2-4bb3-ba6c-46a7aab1cadf", "stage": 3, "queryInterval": 3 }, { "id": "cb03d329-08ae-4982-b30f-40d8f1b3fd71", "stage": 5, "queryInterval": 10 }, { "id": "d4f21553-3beb-48d9-b2c6-7a3cbd5b2274", "stage": 6, "queryInterval": 30 }, { "id": "21e8e24d-5879-432f-b8bb-0db6cf38bb17", "stage": 8, "queryInterval": 90 } ] } ```
`GET /api/group/:groupId/export`
Response ```json { "name": "unit 1", "description": "", "VocabularyCards": [ { "name": "test vocab", "description": "test description", "Translations": [ { "name": "test translation" } ] } ] } ```
`POST /api/import?active=true&activate=false&queryStatus=false (PACKAGE)`
Body (without imported query status) ```json { "version": "v1.0.1", "type": "vocascan/package", "name": "English - German", "foreignWordLanguage": "en", "translatedWordLanguage": "de", "vocabsPerDay": 100, "rightWords": 2, "Groups": [ { "name": "unit 1", "description": "", "VocabularyCards": [ { "name": "test vocab", "description": "test description", "Translations": [ { "name": "test translation" } ] } ] } ] } ``` Body (with imported query status) when drawerId is not specified the "activate" property will be used to store the vocab card ```json { "version": "v1.0.1", "type": "vocascan/package", "name": "Englisch - Deutsch", "foreignWordLanguage": "en", "translatedWordLanguage": "de", "vocabsPerDay": 5, "rightWords": 2, "Groups": [ { "name": "unit 1", "description": "asfsfsf", "VocabularyCards": [ { "name": "test vocab", "description": "This is a test description", "drawerId": "cff3a3e2-3084-4950-a572-502e846a38b8" "Translations": [ { "name": "test translation" } ] }, { "name": "test vocab", "description": "This is a test description", "drawerId": "cff3a3e2-3084-4950-a572-502e846a38b8" "Translations": [ { "name": "test translation" } ] }, { "name": "test vocab", "description": "This is a test description", "drawerId": "36ec80d1-35d9-4404-8523-705b4919e91f", "Translations": [ { "name": "test translation" } ] } ] } ], "Drawers": [ { "id": "0b846944-5892-4205-b35e-da46264ac5ed", "stage": 0, "queryInterval": 0 }, { "id": "36ec80d1-35d9-4404-8523-705b4919e91f", "stage": 1, "queryInterval": 1 }, { "id": "be4c9336-faa3-47b5-bc33-cff177695d95", "stage": 2, "queryInterval": 2 }, { "id": "dccd2ff5-6810-4391-b17e-b2fd7976054c", "stage": 3, "queryInterval": 3 }, { "id": "2cde6dd1-62fd-4e0a-8b98-bcc99caa2c93", "stage": 4, "queryInterval": 5 }, { "id": "af37655d-f8c7-4d90-8d5f-5a69d79389ff", "stage": 5, "queryInterval": 10 }, { "id": "d831529a-4cf5-4953-a678-1bd87038bbc2", "stage": 6, "queryInterval": 30 }, { "id": "10bee574-feb4-4b5a-9cd5-2d32d18c2450", "stage": 7, "queryInterval": 60 }, { "id": "cff3a3e2-3084-4950-a572-502e846a38b8", "stage": 8, "queryInterval": 90 } ] } ```
`POST /api/import?languagePackageId&active&activate (GROUP)`
Body ```json { "name": "unit 1", "description": "", "VocabularyCards": [ { "name": "test vocab", "description": "test description", "Translations": [ { "name": "test translation" } ] }, ] } ```
Motivation and Context
We wanted to have import and export functions to share vocabs among each other, or simply transfer them to another server, by exporting them with their current query status
Screenshots / GIFs (if appropriate):
Checklist
Resolves