@forge/storage 1.5.15-experimental-03ab603 → 1.5.15-experimental-2b4814c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -263,7 +263,7 @@ describe('GlobalStorage', () => {
263
263
  }
264
264
  });
265
265
  const globalStorage = getStorage(apiClientMock);
266
- await globalStorage.bulkSet([
266
+ const response = await globalStorage.bulkSet([
267
267
  {
268
268
  key: 'testKey',
269
269
  value: 'testValue'
@@ -281,6 +281,8 @@ describe('GlobalStorage', () => {
281
281
  encrypted: false
282
282
  }
283
283
  });
284
+ expect(response).toHaveProperty('savedKeys', ['testKey']);
285
+ expect(response).toHaveProperty('failedKeys', []);
284
286
  });
285
287
  it('should throw an error if the storage API returns successful = false', async () => {
286
288
  const apiClientMock = getApiClientMock({
@@ -1 +1 @@
1
- {"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIjE,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,UAAU,WAAW;IACnB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA2CD,qBAAa,aAAc,YAAW,oBAAoB;IAGtD,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IAHnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAE5C,gBAAgB,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EACzC,SAAS,EAAE,WAAW;IAGhC,OAAO,CAAC,kBAAkB;IAIpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAA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CAAC,CAAC;IAI/D,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5E,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAK1D,WAAW;YAUX,iBAAiB;IAU/B,OAAO,CAAC,YAAY;YAUN,KAAK;YAML,QAAQ;CA6BvB"}
@@ -76,10 +76,9 @@ class GlobalStorage {
76
76
  }
77
77
  async bulkSet(items) {
78
78
  const requestBody = gql_queries_1.UntypedQueries.bulkSet(this.doGetAppContextAri(), items, false);
79
- const response = await this.mutation(requestBody, 'appStorage', 'setAppStoredEntities');
80
- const parsedResponse = await getResponseBody(response);
81
- const failedKeys = parsedResponse.appStorage.setAppStoredEntities.failedKeys;
82
- const savedKeys = parsedResponse.appStorage.setAppStoredEntities.savedKeys;
79
+ const response = await this.mutation(requestBody, 'appStorage', 'setAppStoredEntities', true);
80
+ const failedKeys = response.failedKeys;
81
+ const savedKeys = response.savedKeys;
83
82
  return {
84
83
  savedKeys,
85
84
  failedKeys
@@ -127,13 +126,16 @@ class GlobalStorage {
127
126
  const response = await this.apiClient(this.endpoint, this.buildRequest(body));
128
127
  return await getResponseBody(response);
129
128
  }
130
- async mutation(body, namespace, mutationMethod) {
129
+ async mutation(body, namespace, mutationMethod, returnResponseBody) {
131
130
  const response = await this.apiClient(this.endpoint, this.buildRequest(body));
132
- const { [namespace]: { [mutationMethod]: { success, errors } } } = await getResponseBody(response);
133
- assertNoErrors(errors);
134
- if (!success) {
131
+ const { [namespace]: { [mutationMethod]: mutationResponse } } = await getResponseBody(response);
132
+ assertNoErrors(mutationResponse.errors);
133
+ if (!mutationResponse.success) {
135
134
  throw errors_1.APIError.forStatus(500);
136
135
  }
136
+ if (returnResponseBody) {
137
+ return mutationResponse;
138
+ }
137
139
  return response;
138
140
  }
139
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/storage",
3
- "version": "1.5.15-experimental-03ab603",
3
+ "version": "1.5.15-experimental-2b4814c",
4
4
  "description": "Forge Storage methods",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",