refactor: use resource identifiers
Some checks failed
Build Test / test (pull_request) Successful in 26s
JS Unit Tests / test (pull_request) Failing after 29s
PHP Unit Tests / test (pull_request) Successful in 56s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-14 22:34:18 -04:00
parent 69d4b2f42c
commit c7ef2c5495
13 changed files with 425 additions and 621 deletions

View File

@@ -72,9 +72,16 @@ export const collectionService = {
*
* @returns Promise with collection object
*/
async fetch(request: CollectionFetchRequest): Promise<CollectionObject> {
async fetch(request: CollectionFetchRequest): Promise<Record<string, CollectionObject>> {
const response = await transceivePost<CollectionFetchRequest, CollectionFetchResponse>('collection.fetch', request);
return createCollectionObject(response);
// Convert response to CollectionObject instances
const list: Record<string, CollectionObject> = {};
Object.entries(response).forEach(([identifier, entity]) => {
list[entity.identifier] = createCollectionObject(entity);
});
return list;
},
/**
@@ -128,8 +135,8 @@ export const collectionService = {
async delete(request: CollectionDeleteRequest): Promise<boolean | CollectionObject> {
const response = await transceivePost<CollectionDeleteRequest, CollectionDeleteResponse>('collection.delete', request);
if (response.outcome === 'moved' && response.data) {
return createCollectionObject(response.data);
if (response.disposition === 'moved' && response.mutation) {
return createCollectionObject(response.mutation);
}
return true;