@forge/storage
Advanced tools
Comparing version 1.5.15-experimental-03ab603 to 1.5.15-experimental-2b4814c
@@ -266,3 +266,3 @@ "use strict"; | ||
const globalStorage = getStorage(apiClientMock); | ||
await globalStorage.bulkSet([ | ||
const response = await globalStorage.bulkSet([ | ||
{ | ||
@@ -285,2 +285,4 @@ key: 'testKey', | ||
}); | ||
expect(response).toHaveProperty('savedKeys', ['testKey']); | ||
expect(response).toHaveProperty('failedKeys', []); | ||
}); | ||
@@ -287,0 +289,0 @@ it('should throw an error if the storage API returns successful = false', async () => { |
@@ -79,6 +79,5 @@ "use strict"; | ||
const requestBody = gql_queries_1.UntypedQueries.bulkSet(this.doGetAppContextAri(), items, false); | ||
const response = await this.mutation(requestBody, 'appStorage', 'setAppStoredEntities'); | ||
const parsedResponse = await getResponseBody(response); | ||
const failedKeys = parsedResponse.appStorage.setAppStoredEntities.failedKeys; | ||
const savedKeys = parsedResponse.appStorage.setAppStoredEntities.savedKeys; | ||
const response = await this.mutation(requestBody, 'appStorage', 'setAppStoredEntities', true); | ||
const failedKeys = response.failedKeys; | ||
const savedKeys = response.savedKeys; | ||
return { | ||
@@ -131,9 +130,12 @@ savedKeys, | ||
} | ||
async mutation(body, namespace, mutationMethod) { | ||
async mutation(body, namespace, mutationMethod, returnResponseBody) { | ||
const response = await this.apiClient(this.endpoint, this.buildRequest(body)); | ||
const { [namespace]: { [mutationMethod]: { success, errors } } } = await getResponseBody(response); | ||
assertNoErrors(errors); | ||
if (!success) { | ||
const { [namespace]: { [mutationMethod]: mutationResponse } } = await getResponseBody(response); | ||
assertNoErrors(mutationResponse.errors); | ||
if (!mutationResponse.success) { | ||
throw errors_1.APIError.forStatus(500); | ||
} | ||
if (returnResponseBody) { | ||
return mutationResponse; | ||
} | ||
return response; | ||
@@ -140,0 +142,0 @@ } |
{ | ||
"name": "@forge/storage", | ||
"version": "1.5.15-experimental-03ab603", | ||
"version": "1.5.15-experimental-2b4814c", | ||
"description": "Forge Storage methods", | ||
@@ -5,0 +5,0 @@ "author": "Atlassian", |
Sorry, the diff of this file is not supported yet
130581
2740