@forge/storage 1.6.0 → 1.7.0
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.
- package/README.md +0 -1
- package/out/__test__/global-storage.test.js +6 -36
- package/out/global-storage.d.ts +1 -3
- package/out/global-storage.d.ts.map +1 -1
- package/out/global-storage.js +12 -17
- package/out/gql-queries.d.ts +9 -18
- package/out/gql-queries.d.ts.map +1 -1
- package/out/gql-queries.js +19 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,7 +25,6 @@ async function apiClient(path: string, init: RequestInit): Promise<APIResponse>
|
|
|
25
25
|
const extraHeaders = {
|
|
26
26
|
// See add-forge-user-agent.ts
|
|
27
27
|
'User-Agent': `H11n/${version} ${appAri}`,
|
|
28
|
-
'X-Forge-Context': appContextAri,
|
|
29
28
|
|
|
30
29
|
Authorization: `Bearer ${token}`
|
|
31
30
|
|
|
@@ -4,8 +4,7 @@ const errors_1 = require("../errors");
|
|
|
4
4
|
const global_storage_1 = require("../global-storage");
|
|
5
5
|
const gql_queries_1 = require("../gql-queries");
|
|
6
6
|
const mocks_1 = require("@atlassian/metrics-interface/dist/mocks");
|
|
7
|
-
const
|
|
8
|
-
const getStorage = (apiClientMock, metrics) => new global_storage_1.GlobalStorage(() => contextAri, apiClientMock, () => metrics);
|
|
7
|
+
const getStorage = (apiClientMock, metrics) => new global_storage_1.GlobalStorage(apiClientMock, () => metrics);
|
|
9
8
|
const getApiClientMock = (response, statusCode = 200) => {
|
|
10
9
|
return jest.fn().mockReturnValue({
|
|
11
10
|
ok: statusCode === 200,
|
|
@@ -72,11 +71,6 @@ describe.each([
|
|
|
72
71
|
const expectedBody = query ? { query, variables } : { variables };
|
|
73
72
|
expect(JSON.parse(body)).toEqual(expect.objectContaining(expectedBody));
|
|
74
73
|
}
|
|
75
|
-
beforeEach(() => {
|
|
76
|
-
global.api = {
|
|
77
|
-
__getAppAri: jest.fn().mockReturnValue(contextAri)
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
74
|
describe('get', () => {
|
|
81
75
|
it('should call the storage API, passing the provided key and returning the stored value', async () => {
|
|
82
76
|
const apiClientMock = getApiClientMock({
|
|
@@ -90,7 +84,6 @@ describe.each([
|
|
|
90
84
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
91
85
|
const returnedValue = await globalStorage.get('testKey');
|
|
92
86
|
verifyApiClientCalledWith(apiClientMock, {
|
|
93
|
-
contextAri,
|
|
94
87
|
key: 'testKey',
|
|
95
88
|
encrypted: false
|
|
96
89
|
});
|
|
@@ -111,7 +104,6 @@ describe.each([
|
|
|
111
104
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
112
105
|
const returnedValue = await globalStorage.get('testKey');
|
|
113
106
|
verifyApiClientCalledWith(apiClientMock, {
|
|
114
|
-
contextAri,
|
|
115
107
|
key: 'testKey',
|
|
116
108
|
encrypted: false
|
|
117
109
|
});
|
|
@@ -132,7 +124,6 @@ describe.each([
|
|
|
132
124
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
133
125
|
const returnedValue = await globalStorage.get('testKey');
|
|
134
126
|
verifyApiClientCalledWith(apiClientMock, {
|
|
135
|
-
contextAri,
|
|
136
127
|
key: 'testKey',
|
|
137
128
|
encrypted: false
|
|
138
129
|
});
|
|
@@ -153,7 +144,6 @@ describe.each([
|
|
|
153
144
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
154
145
|
const returnedValue = await globalStorage.get('testKey');
|
|
155
146
|
verifyApiClientCalledWith(apiClientMock, {
|
|
156
|
-
contextAri,
|
|
157
147
|
key: 'testKey',
|
|
158
148
|
encrypted: false
|
|
159
149
|
});
|
|
@@ -211,7 +201,6 @@ describe.each([
|
|
|
211
201
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
212
202
|
const returnedValue = await globalStorage.getSecret('testKey');
|
|
213
203
|
verifyApiClientCalledWith(apiClientMock, {
|
|
214
|
-
contextAri,
|
|
215
204
|
key: 'testKey',
|
|
216
205
|
encrypted: true
|
|
217
206
|
});
|
|
@@ -237,7 +226,6 @@ describe.each([
|
|
|
237
226
|
await globalStorage.set('testKey', 'testValue');
|
|
238
227
|
verifyApiClientCalledWith(apiClientMock, {
|
|
239
228
|
input: {
|
|
240
|
-
contextAri,
|
|
241
229
|
key: 'testKey',
|
|
242
230
|
value: 'testValue',
|
|
243
231
|
encrypted: false
|
|
@@ -293,7 +281,6 @@ describe.each([
|
|
|
293
281
|
await expect(globalStorage.set('testKey', 'testValue')).rejects.toThrow(errors_1.APIError.forStatus(500));
|
|
294
282
|
verifyApiClientCalledWith(apiClientMock, {
|
|
295
283
|
input: {
|
|
296
|
-
contextAri,
|
|
297
284
|
key: 'testKey',
|
|
298
285
|
value: 'testValue',
|
|
299
286
|
encrypted: false
|
|
@@ -320,7 +307,6 @@ describe.each([
|
|
|
320
307
|
await globalStorage.setSecret('testKey', 'testValue');
|
|
321
308
|
verifyApiClientCalledWith(apiClientMock, {
|
|
322
309
|
input: {
|
|
323
|
-
contextAri,
|
|
324
310
|
key: 'testKey',
|
|
325
311
|
value: 'testValue',
|
|
326
312
|
encrypted: true
|
|
@@ -347,7 +333,6 @@ describe.each([
|
|
|
347
333
|
await globalStorage.delete('testKey');
|
|
348
334
|
verifyApiClientCalledWith(apiClientMock, {
|
|
349
335
|
input: {
|
|
350
|
-
contextAri,
|
|
351
336
|
key: 'testKey',
|
|
352
337
|
encrypted: false
|
|
353
338
|
}
|
|
@@ -404,7 +389,6 @@ describe.each([
|
|
|
404
389
|
await globalStorage.deleteSecret('testKey');
|
|
405
390
|
verifyApiClientCalledWith(apiClientMock, {
|
|
406
391
|
input: {
|
|
407
|
-
contextAri,
|
|
408
392
|
key: 'testKey',
|
|
409
393
|
encrypted: true
|
|
410
394
|
}
|
|
@@ -427,7 +411,6 @@ describe.each([
|
|
|
427
411
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
428
412
|
const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
|
|
429
413
|
verifyApiClientCalledWith(apiClientMock, {
|
|
430
|
-
contextAri,
|
|
431
414
|
entityName: 'testEntityName',
|
|
432
415
|
key: 'testEntityKey'
|
|
433
416
|
});
|
|
@@ -448,7 +431,6 @@ describe.each([
|
|
|
448
431
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
449
432
|
const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
|
|
450
433
|
verifyApiClientCalledWith(apiClientMock, {
|
|
451
|
-
contextAri,
|
|
452
434
|
entityName: 'testEntityName',
|
|
453
435
|
key: 'testEntityKey'
|
|
454
436
|
});
|
|
@@ -469,7 +451,6 @@ describe.each([
|
|
|
469
451
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
470
452
|
const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
|
|
471
453
|
verifyApiClientCalledWith(apiClientMock, {
|
|
472
|
-
contextAri,
|
|
473
454
|
entityName: 'testEntityName',
|
|
474
455
|
key: 'testEntityKey'
|
|
475
456
|
});
|
|
@@ -490,7 +471,6 @@ describe.each([
|
|
|
490
471
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
491
472
|
const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
|
|
492
473
|
verifyApiClientCalledWith(apiClientMock, {
|
|
493
|
-
contextAri,
|
|
494
474
|
entityName: 'testEntityName',
|
|
495
475
|
key: 'testEntityKey'
|
|
496
476
|
});
|
|
@@ -551,7 +531,6 @@ describe.each([
|
|
|
551
531
|
await globalStorage.setEntity('testEntityName', 'testEntityKey', 'testValue');
|
|
552
532
|
verifyApiClientCalledWith(apiClientMock, {
|
|
553
533
|
input: {
|
|
554
|
-
contextAri,
|
|
555
534
|
entityName: 'testEntityName',
|
|
556
535
|
key: 'testEntityKey',
|
|
557
536
|
value: 'testValue'
|
|
@@ -607,7 +586,6 @@ describe.each([
|
|
|
607
586
|
await expect(globalStorage.setEntity('testEntityName', 'testEntityKey', 'testValue')).rejects.toThrow(errors_1.APIError.forStatus(500));
|
|
608
587
|
verifyApiClientCalledWith(apiClientMock, {
|
|
609
588
|
input: {
|
|
610
|
-
contextAri,
|
|
611
589
|
entityName: 'testEntityName',
|
|
612
590
|
key: 'testEntityKey',
|
|
613
591
|
value: 'testValue'
|
|
@@ -634,7 +612,6 @@ describe.each([
|
|
|
634
612
|
await globalStorage.deleteEntity('testEntityName', 'testEntityKey');
|
|
635
613
|
verifyApiClientCalledWith(apiClientMock, {
|
|
636
614
|
input: {
|
|
637
|
-
contextAri,
|
|
638
615
|
entityName: 'testEntityName',
|
|
639
616
|
key: 'testEntityKey'
|
|
640
617
|
}
|
|
@@ -700,11 +677,10 @@ describe.each([
|
|
|
700
677
|
const limit = 10;
|
|
701
678
|
const response = await globalStorage.list({ where, cursor, limit });
|
|
702
679
|
verifyApiClientCalledWith(apiClientMock, {
|
|
703
|
-
contextAri,
|
|
704
680
|
where,
|
|
705
681
|
cursor,
|
|
706
682
|
limit
|
|
707
|
-
}, gql_queries_1.UntypedQueries.listQuery(
|
|
683
|
+
}, gql_queries_1.UntypedQueries.listQuery({}).query);
|
|
708
684
|
expect(response).toEqual(expect.objectContaining({
|
|
709
685
|
results: [
|
|
710
686
|
{ key: 'key1', value: 'testValue' },
|
|
@@ -741,11 +717,10 @@ describe.each([
|
|
|
741
717
|
const limit = 10;
|
|
742
718
|
const response = await globalStorage.list({ where, cursor, limit });
|
|
743
719
|
verifyApiClientCalledWith(apiClientMock, {
|
|
744
|
-
contextAri,
|
|
745
720
|
where,
|
|
746
721
|
cursor,
|
|
747
722
|
limit
|
|
748
|
-
}, gql_queries_1.UntypedQueries.listQueryForCleanup(
|
|
723
|
+
}, gql_queries_1.UntypedQueries.listQueryForCleanup({}).query);
|
|
749
724
|
expect(response).toEqual(expect.objectContaining({
|
|
750
725
|
results: [
|
|
751
726
|
{ key: 'key1', value: 'testValue' },
|
|
@@ -770,11 +745,10 @@ describe.each([
|
|
|
770
745
|
const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
|
|
771
746
|
await globalStorage.list({});
|
|
772
747
|
verifyApiClientCalledWith(apiClientMock, {
|
|
773
|
-
contextAri,
|
|
774
748
|
where: null,
|
|
775
749
|
cursor: null,
|
|
776
750
|
limit: null
|
|
777
|
-
}, gql_queries_1.UntypedQueries.listQuery(
|
|
751
|
+
}, gql_queries_1.UntypedQueries.listQuery({}).query);
|
|
778
752
|
passMetrics
|
|
779
753
|
? checkMetricsFired(metricMocks, { store: 'untyped', operation: 'query', encrypted: false }, true)
|
|
780
754
|
: expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
|
|
@@ -846,9 +820,7 @@ describe.each([
|
|
|
846
820
|
results: [],
|
|
847
821
|
nextCursor: null
|
|
848
822
|
});
|
|
849
|
-
verifyApiClientCalledWith(apiClientMock, {
|
|
850
|
-
contextAri
|
|
851
|
-
}, gql_queries_1.CustomEntityQueries.listQuery(contextAri, {}).query);
|
|
823
|
+
verifyApiClientCalledWith(apiClientMock, {}, gql_queries_1.CustomEntityQueries.listQuery({}).query);
|
|
852
824
|
passMetrics
|
|
853
825
|
? checkMetricsFired(metricMocks, { store: 'typed', operation: 'query', encrypted: false }, true)
|
|
854
826
|
: expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
|
|
@@ -869,9 +841,7 @@ describe.each([
|
|
|
869
841
|
results: [],
|
|
870
842
|
nextCursor: 'DUMMY_CURSOR'
|
|
871
843
|
});
|
|
872
|
-
verifyApiClientCalledWith(apiClientMock, {
|
|
873
|
-
contextAri
|
|
874
|
-
}, gql_queries_1.CustomEntityQueries.listQuery(contextAri, {}).query);
|
|
844
|
+
verifyApiClientCalledWith(apiClientMock, {}, gql_queries_1.CustomEntityQueries.listQuery({}).query);
|
|
875
845
|
passMetrics
|
|
876
846
|
? checkMetricsFired(metricMocks, { store: 'typed', operation: 'query', encrypted: false }, true)
|
|
877
847
|
: expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
|
package/out/global-storage.d.ts
CHANGED
|
@@ -12,12 +12,10 @@ interface ListResults {
|
|
|
12
12
|
export declare type StoreType = 'typed' | 'untyped';
|
|
13
13
|
export declare type OperationType = 'get' | 'set' | 'query' | 'delete';
|
|
14
14
|
export declare class GlobalStorage implements SharedStorageAdapter {
|
|
15
|
-
private getAppContextAri;
|
|
16
15
|
private apiClient;
|
|
17
16
|
private readonly getMetrics;
|
|
18
17
|
private readonly endpoint;
|
|
19
|
-
constructor(
|
|
20
|
-
private doGetAppContextAri;
|
|
18
|
+
constructor(apiClient: FetchMethod, getMetrics: () => Metrics | undefined);
|
|
21
19
|
get(key: string): Promise<any>;
|
|
22
20
|
getSecret(key: string): Promise<any>;
|
|
23
21
|
list(options: ListOptions): Promise<ListResults>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAInD,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEtE,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;AAcD,oBAAY,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAC5C,oBAAY,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AA+B/D,qBAAa,aAAc,YAAW,oBAAoB;IAGtD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"global-storage.d.ts","sourceRoot":"","sources":["../src/global-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAInD,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEtE,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;AAcD,oBAAY,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAC5C,oBAAY,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AA+B/D,qBAAa,aAAc,YAAW,oBAAoB;IAGtD,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAH7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAE5C,SAAS,EAAE,WAAW,EACb,UAAU,EAAE,MAAM,OAAO,GAAG,SAAS;IAGlD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIpC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAqBhD,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IAc1E,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOxC,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/D,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5E,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAU1D,WAAW;YAUX,iBAAiB;IAU/B,OAAO,CAAC,YAAY;YAUN,KAAK;YAML,QAAQ;YAsBR,YAAY;CAyC3B"}
|
package/out/global-storage.js
CHANGED
|
@@ -25,18 +25,13 @@ async function getResponseBody(response) {
|
|
|
25
25
|
return responseBody.data;
|
|
26
26
|
}
|
|
27
27
|
class GlobalStorage {
|
|
28
|
-
getAppContextAri;
|
|
29
28
|
apiClient;
|
|
30
29
|
getMetrics;
|
|
31
30
|
endpoint = '/forge/entities/graphql';
|
|
32
|
-
constructor(
|
|
33
|
-
this.getAppContextAri = getAppContextAri;
|
|
31
|
+
constructor(apiClient, getMetrics) {
|
|
34
32
|
this.apiClient = apiClient;
|
|
35
33
|
this.getMetrics = getMetrics;
|
|
36
34
|
}
|
|
37
|
-
doGetAppContextAri() {
|
|
38
|
-
return typeof this.getAppContextAri === 'function' ? this.getAppContextAri() : this.getAppContextAri;
|
|
39
|
-
}
|
|
40
35
|
async get(key) {
|
|
41
36
|
return this.getInternal(key, false);
|
|
42
37
|
}
|
|
@@ -45,8 +40,8 @@ class GlobalStorage {
|
|
|
45
40
|
}
|
|
46
41
|
async list(options) {
|
|
47
42
|
const requestBody = process.env.IS_CLEANUP_FUNCTION === 'true'
|
|
48
|
-
? gql_queries_1.UntypedQueries.listQueryForCleanup(
|
|
49
|
-
: gql_queries_1.UntypedQueries.listQuery(
|
|
43
|
+
? gql_queries_1.UntypedQueries.listQueryForCleanup(options)
|
|
44
|
+
: gql_queries_1.UntypedQueries.listQuery(options);
|
|
50
45
|
const response = await this.wrapInMetric('untyped', 'query', false, async () => await this.query(requestBody));
|
|
51
46
|
const edges = process.env.IS_CLEANUP_FUNCTION === 'true'
|
|
52
47
|
? response.appStoredEntitiesForCleanup.edges
|
|
@@ -59,7 +54,7 @@ class GlobalStorage {
|
|
|
59
54
|
};
|
|
60
55
|
}
|
|
61
56
|
async listCustomEntities(options) {
|
|
62
|
-
const requestBody = gql_queries_1.CustomEntityQueries.listQuery(
|
|
57
|
+
const requestBody = gql_queries_1.CustomEntityQueries.listQuery(options);
|
|
63
58
|
const response = await this.wrapInMetric('typed', 'query', false, async () => await this.query(requestBody));
|
|
64
59
|
const edges = response.appStoredCustomEntities.edges;
|
|
65
60
|
const results = edges.map(({ node }) => node);
|
|
@@ -69,39 +64,39 @@ class GlobalStorage {
|
|
|
69
64
|
};
|
|
70
65
|
}
|
|
71
66
|
async set(key, value) {
|
|
72
|
-
const requestBody = gql_queries_1.UntypedQueries.set(
|
|
67
|
+
const requestBody = gql_queries_1.UntypedQueries.set(key, value, false);
|
|
73
68
|
await this.wrapInMetric('untyped', 'set', false, async () => await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity'));
|
|
74
69
|
}
|
|
75
70
|
async setSecret(key, value) {
|
|
76
|
-
const requestBody = gql_queries_1.UntypedQueries.set(
|
|
71
|
+
const requestBody = gql_queries_1.UntypedQueries.set(key, value, true);
|
|
77
72
|
await this.wrapInMetric('untyped', 'set', true, async () => await this.mutation(requestBody, 'appStorage', 'setAppStoredEntity'));
|
|
78
73
|
}
|
|
79
74
|
async delete(key) {
|
|
80
|
-
const requestBody = gql_queries_1.UntypedQueries.delete(
|
|
75
|
+
const requestBody = gql_queries_1.UntypedQueries.delete(key, false);
|
|
81
76
|
await this.wrapInMetric('untyped', 'delete', false, async () => this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity'));
|
|
82
77
|
}
|
|
83
78
|
async deleteSecret(key) {
|
|
84
|
-
const requestBody = gql_queries_1.UntypedQueries.delete(
|
|
79
|
+
const requestBody = gql_queries_1.UntypedQueries.delete(key, true);
|
|
85
80
|
await this.wrapInMetric('untyped', 'delete', true, async () => this.mutation(requestBody, 'appStorage', 'deleteAppStoredEntity'));
|
|
86
81
|
}
|
|
87
82
|
async getEntity(entityName, entityKey) {
|
|
88
83
|
return this.getEntityInternal(entityName, entityKey);
|
|
89
84
|
}
|
|
90
85
|
async setEntity(entityName, entityKey, value) {
|
|
91
|
-
const requestBody = gql_queries_1.CustomEntityQueries.set(
|
|
86
|
+
const requestBody = gql_queries_1.CustomEntityQueries.set(entityName, entityKey, value);
|
|
92
87
|
await this.wrapInMetric('typed', 'set', false, async () => this.mutation(requestBody, 'appStorageCustomEntity', 'setAppStoredCustomEntity'));
|
|
93
88
|
}
|
|
94
89
|
async deleteEntity(entityName, entityKey) {
|
|
95
|
-
const requestBody = gql_queries_1.CustomEntityQueries.delete(
|
|
90
|
+
const requestBody = gql_queries_1.CustomEntityQueries.delete(entityName, entityKey);
|
|
96
91
|
await this.wrapInMetric('typed', 'delete', false, async () => await this.mutation(requestBody, 'appStorageCustomEntity', 'deleteAppStoredCustomEntity'));
|
|
97
92
|
}
|
|
98
93
|
async getInternal(key, encrypted) {
|
|
99
|
-
const requestBody = gql_queries_1.UntypedQueries.get(
|
|
94
|
+
const requestBody = gql_queries_1.UntypedQueries.get(key, encrypted);
|
|
100
95
|
const { appStoredEntity: { value } } = await this.wrapInMetric('untyped', 'get', encrypted, async () => await this.query(requestBody));
|
|
101
96
|
return value ?? undefined;
|
|
102
97
|
}
|
|
103
98
|
async getEntityInternal(entityName, entityKey) {
|
|
104
|
-
const requestBody = gql_queries_1.CustomEntityQueries.get(
|
|
99
|
+
const requestBody = gql_queries_1.CustomEntityQueries.get(entityName, entityKey);
|
|
105
100
|
const { appStoredCustomEntity: { value } } = await this.wrapInMetric('typed', 'get', false, async () => await this.query(requestBody));
|
|
106
101
|
return value ?? undefined;
|
|
107
102
|
}
|
package/out/gql-queries.d.ts
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import { CustomEntityListOptions, ListOptions } from './query-interfaces';
|
|
2
2
|
export declare class UntypedQueries {
|
|
3
|
-
static get: (
|
|
3
|
+
static get: (key: string, encrypted: boolean) => {
|
|
4
4
|
query: string;
|
|
5
5
|
variables: {
|
|
6
|
-
contextAri: string;
|
|
7
6
|
key: string;
|
|
8
7
|
encrypted: boolean;
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
|
-
static set: (
|
|
10
|
+
static set: (key: string, value: any, encrypted: boolean) => {
|
|
12
11
|
query: string;
|
|
13
12
|
variables: {
|
|
14
13
|
input: {
|
|
15
|
-
contextAri: string;
|
|
16
14
|
key: string;
|
|
17
15
|
value: any;
|
|
18
16
|
encrypted: boolean;
|
|
19
17
|
};
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
static delete: (
|
|
20
|
+
static delete: (key: string, encrypted: boolean) => {
|
|
23
21
|
query: string;
|
|
24
22
|
variables: {
|
|
25
23
|
input: {
|
|
26
|
-
contextAri: string;
|
|
27
24
|
key: string;
|
|
28
25
|
encrypted: boolean;
|
|
29
26
|
};
|
|
30
27
|
};
|
|
31
28
|
};
|
|
32
|
-
static listQuery: (
|
|
29
|
+
static listQuery: (options: ListOptions) => {
|
|
33
30
|
query: string;
|
|
34
31
|
variables: {
|
|
35
|
-
contextAri: string;
|
|
36
32
|
where: import("./query-interfaces").WhereClause[] | null;
|
|
37
33
|
cursor: string | null;
|
|
38
34
|
limit: number | null;
|
|
39
35
|
};
|
|
40
36
|
};
|
|
41
|
-
static listQueryForCleanup: (
|
|
37
|
+
static listQueryForCleanup: (options: ListOptions) => {
|
|
42
38
|
query: string;
|
|
43
39
|
variables: {
|
|
44
|
-
contextAri: string;
|
|
45
40
|
where: import("./query-interfaces").WhereClause[] | null;
|
|
46
41
|
cursor: string | null;
|
|
47
42
|
limit: number | null;
|
|
@@ -49,36 +44,33 @@ export declare class UntypedQueries {
|
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
46
|
export declare class CustomEntityQueries {
|
|
52
|
-
static get: (
|
|
47
|
+
static get: (entityName: string, key: string) => {
|
|
53
48
|
query: string;
|
|
54
49
|
variables: {
|
|
55
|
-
contextAri: string;
|
|
56
50
|
entityName: string;
|
|
57
51
|
key: string;
|
|
58
52
|
};
|
|
59
53
|
};
|
|
60
|
-
static set: (
|
|
54
|
+
static set: (entityName: string, key: string, value: any) => {
|
|
61
55
|
query: string;
|
|
62
56
|
variables: {
|
|
63
57
|
input: {
|
|
64
|
-
contextAri: string;
|
|
65
58
|
entityName: string;
|
|
66
59
|
key: string;
|
|
67
60
|
value: any;
|
|
68
61
|
};
|
|
69
62
|
};
|
|
70
63
|
};
|
|
71
|
-
static delete: (
|
|
64
|
+
static delete: (entityName: string, key: string) => {
|
|
72
65
|
query: string;
|
|
73
66
|
variables: {
|
|
74
67
|
input: {
|
|
75
|
-
contextAri: string;
|
|
76
68
|
entityName: string;
|
|
77
69
|
key: string;
|
|
78
70
|
};
|
|
79
71
|
};
|
|
80
72
|
};
|
|
81
|
-
static listQuery: (
|
|
73
|
+
static listQuery: (options: CustomEntityListOptions) => {
|
|
82
74
|
query: string;
|
|
83
75
|
variables: {
|
|
84
76
|
limit?: number | undefined;
|
|
@@ -88,7 +80,6 @@ export declare class CustomEntityQueries {
|
|
|
88
80
|
filters?: {
|
|
89
81
|
[x: string]: import("./query-interfaces").FilterClause[];
|
|
90
82
|
} | undefined;
|
|
91
|
-
contextAri: string;
|
|
92
83
|
entityName: string | undefined;
|
|
93
84
|
indexName: string | undefined;
|
|
94
85
|
range: import("./query-interfaces").RangeClause | undefined;
|
package/out/gql-queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql-queries.d.ts","sourceRoot":"","sources":["../src/gql-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1E,qBAAa,cAAc;IACzB,OAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"gql-queries.d.ts","sourceRoot":"","sources":["../src/gql-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1E,qBAAa,cAAc;IACzB,OAAc,GAAG,QAAS,MAAM,aAAa,OAAO;;;;;;MAajD;IAEH,OAAc,GAAG,QAAS,MAAM,SAAS,GAAG,aAAa,OAAO;;;;;;;;;MAyB7D;IAEH,OAAc,MAAM,QAAS,MAAM,aAAa,OAAO;;;;;;;;MAwBpD;IAEH,OAAc,SAAS,YAAa,WAAW;;;;;;;MAqB5C;IAEH,OAAc,mBAAmB,YAAa,WAAW;;;;;;;MAqBtD;CACJ;AAED,qBAAa,mBAAmB;IAC9B,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM;;;;;;MAcjD;IAEH,OAAc,GAAG,eAAgB,MAAM,OAAO,MAAM,SAAS,GAAG;;;;;;;;;MAyB7D;IAEH,OAAc,MAAM,eAAgB,MAAM,OAAO,MAAM;;;;;;;;MAwBpD;IAEH,OAAc,SAAS,YAAa,uBAAuB;;;;;;;;;;;;;;MAsCzD;CACH"}
|
package/out/gql-queries.js
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomEntityQueries = exports.UntypedQueries = void 0;
|
|
4
4
|
class UntypedQueries {
|
|
5
|
-
static get = (
|
|
5
|
+
static get = (key, encrypted) => ({
|
|
6
6
|
query: `
|
|
7
|
-
query forge_app_getApplicationStorageEntity($
|
|
8
|
-
appStoredEntity(
|
|
7
|
+
query forge_app_getApplicationStorageEntity($key: ID!, $encrypted: Boolean!) {
|
|
8
|
+
appStoredEntity(key: $key, encrypted: $encrypted) {
|
|
9
9
|
key
|
|
10
10
|
value
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
`,
|
|
14
14
|
variables: {
|
|
15
|
-
contextAri,
|
|
16
15
|
key,
|
|
17
16
|
encrypted
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
static set = (
|
|
19
|
+
static set = (key, value, encrypted) => ({
|
|
21
20
|
query: `
|
|
22
21
|
mutation forge_app_setApplicationStorageEntity($input: SetAppStoredEntityMutationInput!) {
|
|
23
22
|
appStorage{
|
|
@@ -37,14 +36,13 @@ class UntypedQueries {
|
|
|
37
36
|
`,
|
|
38
37
|
variables: {
|
|
39
38
|
input: {
|
|
40
|
-
contextAri,
|
|
41
39
|
key,
|
|
42
40
|
value,
|
|
43
41
|
encrypted
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
});
|
|
47
|
-
static delete = (
|
|
45
|
+
static delete = (key, encrypted) => ({
|
|
48
46
|
query: `
|
|
49
47
|
mutation forge_app_deleteApplicationStorageEntity($input: DeleteAppStoredEntityMutationInput!) {
|
|
50
48
|
appStorage {
|
|
@@ -64,16 +62,15 @@ class UntypedQueries {
|
|
|
64
62
|
`,
|
|
65
63
|
variables: {
|
|
66
64
|
input: {
|
|
67
|
-
contextAri,
|
|
68
65
|
key,
|
|
69
66
|
encrypted
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
});
|
|
73
|
-
static listQuery = (
|
|
70
|
+
static listQuery = (options) => ({
|
|
74
71
|
query: `
|
|
75
|
-
query forge_app_getApplicationStorageEntities($
|
|
76
|
-
appStoredEntities(
|
|
72
|
+
query forge_app_getApplicationStorageEntities($where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
|
|
73
|
+
appStoredEntities(where: $where, after: $cursor, first: $limit) {
|
|
77
74
|
edges {
|
|
78
75
|
node {
|
|
79
76
|
value
|
|
@@ -86,16 +83,15 @@ class UntypedQueries {
|
|
|
86
83
|
}
|
|
87
84
|
`,
|
|
88
85
|
variables: {
|
|
89
|
-
contextAri,
|
|
90
86
|
where: options.where ?? null,
|
|
91
87
|
cursor: options.cursor ?? null,
|
|
92
88
|
limit: options.limit ?? null
|
|
93
89
|
}
|
|
94
90
|
});
|
|
95
|
-
static listQueryForCleanup = (
|
|
91
|
+
static listQueryForCleanup = (options) => ({
|
|
96
92
|
query: `
|
|
97
|
-
query forge_app_getApplicationStorageEntitiesForCleanup($
|
|
98
|
-
appStoredEntitiesForCleanup(
|
|
93
|
+
query forge_app_getApplicationStorageEntitiesForCleanup($where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
|
|
94
|
+
appStoredEntitiesForCleanup(where: $where, after: $cursor, first: $limit) {
|
|
99
95
|
edges {
|
|
100
96
|
node {
|
|
101
97
|
value
|
|
@@ -108,7 +104,6 @@ class UntypedQueries {
|
|
|
108
104
|
}
|
|
109
105
|
`,
|
|
110
106
|
variables: {
|
|
111
|
-
contextAri,
|
|
112
107
|
where: options.where ?? null,
|
|
113
108
|
cursor: options.cursor ?? null,
|
|
114
109
|
limit: options.limit ?? null
|
|
@@ -117,10 +112,10 @@ class UntypedQueries {
|
|
|
117
112
|
}
|
|
118
113
|
exports.UntypedQueries = UntypedQueries;
|
|
119
114
|
class CustomEntityQueries {
|
|
120
|
-
static get = (
|
|
115
|
+
static get = (entityName, key) => ({
|
|
121
116
|
query: `
|
|
122
|
-
query forge_app_getApplicationStorageCustomEntity ($
|
|
123
|
-
appStoredCustomEntity(
|
|
117
|
+
query forge_app_getApplicationStorageCustomEntity ($key: ID!, $entityName: String!) {
|
|
118
|
+
appStoredCustomEntity(key: $key, entityName: $entityName) {
|
|
124
119
|
value
|
|
125
120
|
entityName
|
|
126
121
|
key
|
|
@@ -128,12 +123,11 @@ class CustomEntityQueries {
|
|
|
128
123
|
}
|
|
129
124
|
`,
|
|
130
125
|
variables: {
|
|
131
|
-
contextAri,
|
|
132
126
|
entityName,
|
|
133
127
|
key
|
|
134
128
|
}
|
|
135
129
|
});
|
|
136
|
-
static set = (
|
|
130
|
+
static set = (entityName, key, value) => ({
|
|
137
131
|
query: `
|
|
138
132
|
mutation forge_app_setApplicationStorageCustomEntity($input: SetAppStoredCustomEntityMutationInput!) {
|
|
139
133
|
appStorageCustomEntity{
|
|
@@ -153,14 +147,13 @@ class CustomEntityQueries {
|
|
|
153
147
|
`,
|
|
154
148
|
variables: {
|
|
155
149
|
input: {
|
|
156
|
-
contextAri,
|
|
157
150
|
entityName,
|
|
158
151
|
key,
|
|
159
152
|
value
|
|
160
153
|
}
|
|
161
154
|
}
|
|
162
155
|
});
|
|
163
|
-
static delete = (
|
|
156
|
+
static delete = (entityName, key) => ({
|
|
164
157
|
query: `
|
|
165
158
|
mutation forge_app_deleteApplicationStorageCustomEntity($input: DeleteAppStoredCustomEntityMutationInput!) {
|
|
166
159
|
appStorageCustomEntity {
|
|
@@ -180,17 +173,16 @@ class CustomEntityQueries {
|
|
|
180
173
|
`,
|
|
181
174
|
variables: {
|
|
182
175
|
input: {
|
|
183
|
-
contextAri,
|
|
184
176
|
entityName,
|
|
185
177
|
key
|
|
186
178
|
}
|
|
187
179
|
}
|
|
188
180
|
});
|
|
189
|
-
static listQuery = (
|
|
181
|
+
static listQuery = (options) => {
|
|
190
182
|
return {
|
|
191
183
|
query: `
|
|
192
|
-
query AppStorageCustomEntityQueries ($
|
|
193
|
-
appStoredCustomEntities(
|
|
184
|
+
query AppStorageCustomEntityQueries ($entityName: String!, $indexName: String!, $range: AppStoredCustomEntityRange, $filters: AppStoredCustomEntityFilters, $sort:SortOrder, $limit: Int, $cursor: String, $partition: [AppStoredCustomEntityFieldValue!]) {
|
|
185
|
+
appStoredCustomEntities(entityName: $entityName, indexName: $indexName, range: $range, filters: $filters, sort:$sort, limit: $limit, cursor: $cursor, partition: $partition) {
|
|
194
186
|
edges {
|
|
195
187
|
node {
|
|
196
188
|
key
|
|
@@ -208,7 +200,6 @@ class CustomEntityQueries {
|
|
|
208
200
|
}
|
|
209
201
|
`,
|
|
210
202
|
variables: {
|
|
211
|
-
contextAri,
|
|
212
203
|
entityName: options.entityName,
|
|
213
204
|
indexName: options.indexName,
|
|
214
205
|
range: options.range,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/storage",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Forge Storage methods",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/node": "14.18.63",
|
|
19
19
|
"@types/node-fetch": "^2.6.11",
|
|
20
20
|
"node-fetch": "2.7.0",
|
|
21
|
-
"@forge/util": "1.4.
|
|
21
|
+
"@forge/util": "1.4.6",
|
|
22
22
|
"@atlassian/metrics-interface": "4.0.0"
|
|
23
23
|
}
|
|
24
24
|
}
|