@forge/kvs 1.2.7-next.0-experimental-d997307 → 1.2.7-next.0-experimental-3fd1b86
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/out/__test__/index.test.js +18 -432
- package/out/entity-query.d.ts +2 -3
- package/out/entity-query.d.ts.map +1 -1
- package/out/entity-query.js +3 -10
- package/out/entity.d.ts +4 -6
- package/out/entity.d.ts.map +1 -1
- package/out/entity.js +4 -5
- package/out/interfaces/entity-query.d.ts +1 -2
- package/out/interfaces/entity-query.d.ts.map +1 -1
- package/out/interfaces/kvs-api.d.ts +10 -19
- package/out/interfaces/kvs-api.d.ts.map +1 -1
- package/out/interfaces/kvs.d.ts +6 -13
- package/out/interfaces/kvs.d.ts.map +1 -1
- package/out/interfaces/query.d.ts +1 -2
- package/out/interfaces/query.d.ts.map +1 -1
- package/out/interfaces/transaction.d.ts +1 -3
- package/out/interfaces/transaction.d.ts.map +1 -1
- package/out/interfaces/types.d.ts +1 -32
- package/out/interfaces/types.d.ts.map +1 -1
- package/out/interfaces/types.js +1 -6
- package/out/kvs.d.ts +5 -10
- package/out/kvs.d.ts.map +1 -1
- package/out/kvs.js +6 -6
- package/out/query.d.ts.map +1 -1
- package/out/query.js +1 -5
- package/out/storage-api.d.ts +4 -5
- package/out/storage-api.d.ts.map +1 -1
- package/out/storage-api.js +24 -52
- package/out/transaction-api.d.ts +1 -2
- package/out/transaction-api.d.ts.map +1 -1
- package/out/transaction-api.js +2 -3
- package/out/utils/transaction-request-builder.d.ts.map +1 -1
- package/out/utils/transaction-request-builder.js +2 -3
- package/package.json +2 -2
package/out/storage-api.js
CHANGED
|
@@ -4,12 +4,6 @@ exports.StorageApi = void 0;
|
|
|
4
4
|
const types_1 = require("./interfaces/types");
|
|
5
5
|
const error_handling_1 = require("./utils/error-handling");
|
|
6
6
|
const errors_1 = require("./errors");
|
|
7
|
-
var ResponseType;
|
|
8
|
-
(function (ResponseType) {
|
|
9
|
-
ResponseType[ResponseType["NONE"] = 0] = "NONE";
|
|
10
|
-
ResponseType[ResponseType["EXPECTED"] = 1] = "EXPECTED";
|
|
11
|
-
ResponseType[ResponseType["OPTIONAL"] = 2] = "OPTIONAL";
|
|
12
|
-
})(ResponseType || (ResponseType = {}));
|
|
13
7
|
class StorageApi {
|
|
14
8
|
apiClient;
|
|
15
9
|
constructor(apiClient) {
|
|
@@ -17,72 +11,69 @@ class StorageApi {
|
|
|
17
11
|
}
|
|
18
12
|
async get(body) {
|
|
19
13
|
const rs = await this.handleKeyNotFound(async () => {
|
|
20
|
-
return this.request('/api/v1/get', body,
|
|
14
|
+
return this.request('/api/v1/get', body, true);
|
|
21
15
|
});
|
|
22
|
-
return this.processGetResponse(rs, body.options);
|
|
16
|
+
return this.processGetResponse(rs, body.options?.metadataFields);
|
|
23
17
|
}
|
|
24
18
|
async getSecret(body) {
|
|
25
19
|
const rs = await this.handleKeyNotFound(async () => {
|
|
26
|
-
return this.request('/api/v1/secret/get', body,
|
|
20
|
+
return this.request('/api/v1/secret/get', body, true);
|
|
27
21
|
});
|
|
28
|
-
return this.processGetResponse(rs, body.options);
|
|
22
|
+
return this.processGetResponse(rs, body.options?.metadataFields);
|
|
29
23
|
}
|
|
30
24
|
async getEntity(body) {
|
|
31
25
|
const rs = await this.handleKeyNotFound(async () => {
|
|
32
|
-
return this.request('/api/v1/entity/get', body,
|
|
26
|
+
return this.request('/api/v1/entity/get', body, true);
|
|
33
27
|
});
|
|
34
|
-
return this.processGetResponse(rs, body.options);
|
|
28
|
+
return this.processGetResponse(rs, body.options?.metadataFields);
|
|
35
29
|
}
|
|
36
30
|
async set(body) {
|
|
37
|
-
|
|
38
|
-
return rs && (0, types_1.isOverrideAndReturnOptions)(body.options) ? this.processSetResponse(rs, body.options) : undefined;
|
|
31
|
+
await this.request('/api/v1/set', body, false);
|
|
39
32
|
}
|
|
40
33
|
async setSecret(body) {
|
|
41
|
-
|
|
42
|
-
return rs && (0, types_1.isOverrideAndReturnOptions)(body.options) ? this.processSetResponse(rs, body.options) : undefined;
|
|
34
|
+
await this.request('/api/v1/secret/set', body, false);
|
|
43
35
|
}
|
|
44
36
|
async setEntity(body) {
|
|
45
|
-
|
|
46
|
-
return rs && (0, types_1.isOverrideAndReturnOptions)(body.options) ? this.processSetResponse(rs, body.options) : undefined;
|
|
37
|
+
await this.request('/api/v1/entity/set', body, false);
|
|
47
38
|
}
|
|
48
39
|
async delete(body) {
|
|
49
40
|
await this.handleKeyNotFound(async () => {
|
|
50
|
-
return this.request('/api/v1/delete', body,
|
|
41
|
+
return this.request('/api/v1/delete', body, false);
|
|
51
42
|
});
|
|
52
43
|
}
|
|
53
44
|
async deleteSecret(body) {
|
|
54
45
|
await this.handleKeyNotFound(async () => {
|
|
55
|
-
return this.request('/api/v1/secret/delete', body,
|
|
46
|
+
return this.request('/api/v1/secret/delete', body, false);
|
|
56
47
|
});
|
|
57
48
|
}
|
|
58
49
|
async deleteEntity(body) {
|
|
59
50
|
await this.handleKeyNotFound(async () => {
|
|
60
|
-
return this.request('/api/v1/entity/delete', body,
|
|
51
|
+
return this.request('/api/v1/entity/delete', body, false);
|
|
61
52
|
});
|
|
62
53
|
}
|
|
63
54
|
async query(body) {
|
|
64
|
-
const rs = await this.request('/api/v1/query', body,
|
|
55
|
+
const rs = await this.request('/api/v1/query', body, true);
|
|
65
56
|
return {
|
|
66
57
|
results: rs.data,
|
|
67
58
|
nextCursor: rs.cursor
|
|
68
59
|
};
|
|
69
60
|
}
|
|
70
61
|
async queryEntity(body) {
|
|
71
|
-
const rs = await this.request('/api/v1/entity/query', body,
|
|
62
|
+
const rs = await this.request('/api/v1/entity/query', body, true);
|
|
72
63
|
return {
|
|
73
64
|
results: rs.data,
|
|
74
65
|
nextCursor: rs.cursor
|
|
75
66
|
};
|
|
76
67
|
}
|
|
77
68
|
async batchSet(body) {
|
|
78
|
-
const rs = await this.request('/api/v1/batch/set', body,
|
|
69
|
+
const rs = await this.request('/api/v1/batch/set', body, true);
|
|
79
70
|
return {
|
|
80
71
|
successfulKeys: rs.successfulKeys,
|
|
81
72
|
failedKeys: rs.failedKeys
|
|
82
73
|
};
|
|
83
74
|
}
|
|
84
75
|
async transact(transactionRequest) {
|
|
85
|
-
await this.request('/api/v1/transaction', transactionRequest,
|
|
76
|
+
await this.request('/api/v1/transaction', transactionRequest, false);
|
|
86
77
|
}
|
|
87
78
|
async handleKeyNotFound(fn) {
|
|
88
79
|
try {
|
|
@@ -95,7 +86,7 @@ class StorageApi {
|
|
|
95
86
|
throw e;
|
|
96
87
|
}
|
|
97
88
|
}
|
|
98
|
-
async request(path, body,
|
|
89
|
+
async request(path, body, isResponseExpected) {
|
|
99
90
|
const requestBody = {
|
|
100
91
|
method: 'POST',
|
|
101
92
|
body: JSON.stringify(body),
|
|
@@ -105,13 +96,10 @@ class StorageApi {
|
|
|
105
96
|
};
|
|
106
97
|
const response = await this.apiClient(path, requestBody);
|
|
107
98
|
await (0, error_handling_1.checkResponseError)(response);
|
|
108
|
-
if (
|
|
109
|
-
return;
|
|
99
|
+
if (!isResponseExpected) {
|
|
100
|
+
return {};
|
|
110
101
|
}
|
|
111
102
|
const responseText = await response.text();
|
|
112
|
-
if (responseType === ResponseType.OPTIONAL && !responseText) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
103
|
try {
|
|
116
104
|
return JSON.parse(responseText);
|
|
117
105
|
}
|
|
@@ -119,38 +107,22 @@ class StorageApi {
|
|
|
119
107
|
throw new errors_1.ForgeKvsError(`Unexpected error. Response was not valid JSON: ${responseText}`);
|
|
120
108
|
}
|
|
121
109
|
}
|
|
122
|
-
processGetResponse(response,
|
|
123
|
-
if (response &&
|
|
124
|
-
const maybeCreatedAt =
|
|
110
|
+
processGetResponse(response, requestedMetadataFields) {
|
|
111
|
+
if (response && requestedMetadataFields?.length) {
|
|
112
|
+
const maybeCreatedAt = requestedMetadataFields.includes(types_1.MetadataField.CREATED_AT)
|
|
125
113
|
? { createdAt: response.createdAt }
|
|
126
114
|
: {};
|
|
127
|
-
const maybeUpdatedAt =
|
|
115
|
+
const maybeUpdatedAt = requestedMetadataFields.includes(types_1.MetadataField.UPDATED_AT)
|
|
128
116
|
? { updatedAt: response.updatedAt }
|
|
129
117
|
: {};
|
|
130
|
-
const maybeExpireTime = options.metadataFields?.includes(types_1.MetadataField.EXPIRE_TIME)
|
|
131
|
-
? { expireTime: response.expireTime }
|
|
132
|
-
: {};
|
|
133
118
|
return {
|
|
134
119
|
key: response.key,
|
|
135
120
|
value: response.value,
|
|
136
121
|
...maybeCreatedAt,
|
|
137
|
-
...maybeUpdatedAt
|
|
138
|
-
...maybeExpireTime
|
|
122
|
+
...maybeUpdatedAt
|
|
139
123
|
};
|
|
140
124
|
}
|
|
141
125
|
return response?.value;
|
|
142
126
|
}
|
|
143
|
-
processSetResponse(response, options) {
|
|
144
|
-
if (!response) {
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
key: response.key,
|
|
149
|
-
value: response.value,
|
|
150
|
-
...(options.returnMetadataFields?.includes(types_1.MetadataField.CREATED_AT) && { createdAt: response.createdAt }),
|
|
151
|
-
...(options.returnMetadataFields?.includes(types_1.MetadataField.UPDATED_AT) && { updatedAt: response.updatedAt }),
|
|
152
|
-
...(options.returnMetadataFields?.includes(types_1.MetadataField.EXPIRE_TIME) && { expireTime: response.expireTime })
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
127
|
}
|
|
156
128
|
exports.StorageApi = StorageApi;
|
package/out/transaction-api.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { StorageApi } from './storage-api';
|
|
2
2
|
import { EntityConditions, EntityRequiredConditions, TransactCheck, TransactDelete, TransactionBuilder, TransactSet } from './interfaces/transaction';
|
|
3
|
-
import { SetOptions } from './interfaces/types';
|
|
4
3
|
export declare class TransactionBuilderImpl implements TransactionBuilder {
|
|
5
4
|
private readonly storageApi;
|
|
6
5
|
protected sets: TransactSet<unknown>[];
|
|
7
6
|
protected deletes: TransactDelete<unknown>[];
|
|
8
7
|
protected checks: TransactCheck<unknown>[];
|
|
9
8
|
constructor(storageApi: StorageApi, sets?: TransactSet<unknown>[], deletes?: TransactDelete<unknown>[], checks?: TransactCheck<unknown>[]);
|
|
10
|
-
set<T>(key: string, value: T, entity?: EntityConditions<T
|
|
9
|
+
set<T>(key: string, value: T, entity?: EntityConditions<T>): this;
|
|
11
10
|
delete<T>(key: string, entity?: EntityConditions<T>): this;
|
|
12
11
|
check<T>(key: string, { entityName, conditions }: EntityRequiredConditions<T>): this;
|
|
13
12
|
execute(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-api.d.ts","sourceRoot":"","sources":["../src/transaction-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACZ,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction-api.d.ts","sourceRoot":"","sources":["../src/transaction-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAIlC,qBAAa,sBAAuB,YAAW,kBAAkB;IAE7D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE;IACtC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE;IAC5C,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE;gBAHzB,UAAU,EAAE,UAAU,EAC7B,IAAI,GAAE,WAAW,CAAC,OAAO,CAAC,EAAO,EACjC,OAAO,GAAE,cAAc,CAAC,OAAO,CAAC,EAAO,EACvC,MAAM,GAAE,aAAa,CAAC,OAAO,CAAC,EAAO;IAGjD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI;IAkBjE,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI;IAiB1D,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,IAAI;IAa9E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAY/B"}
|
package/out/transaction-api.js
CHANGED
|
@@ -13,11 +13,10 @@ class TransactionBuilderImpl {
|
|
|
13
13
|
this.deletes = deletes;
|
|
14
14
|
this.checks = checks;
|
|
15
15
|
}
|
|
16
|
-
set(key, value, entity
|
|
16
|
+
set(key, value, entity) {
|
|
17
17
|
const transactSet = {
|
|
18
18
|
key,
|
|
19
|
-
value
|
|
20
|
-
options
|
|
19
|
+
value
|
|
21
20
|
};
|
|
22
21
|
if (entity) {
|
|
23
22
|
transactSet.entity = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-request-builder.d.ts","sourceRoot":"","sources":["../../src/utils/transaction-request-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAoBvF,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"transaction-request-builder.d.ts","sourceRoot":"","sources":["../../src/utils/transaction-request-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAoBvF,eAAO,MAAM,eAAe,oDAW3B,CAAC;AAEF,eAAO,MAAM,mBAAmB,6CAA4C,aAU3E,CAAC;AAEF,eAAO,MAAM,kBAAkB,2CAA0C,YAUxE,CAAC"}
|
|
@@ -14,15 +14,14 @@ function buildConditionsRequest(filter) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
const buildRequestSet = (setOperation) => {
|
|
17
|
-
const { key, value, entity
|
|
17
|
+
const { key, value, entity } = setOperation;
|
|
18
18
|
const entityName = entity?.entityName;
|
|
19
19
|
const conditions = buildConditionsRequest(entity?.conditions);
|
|
20
20
|
return {
|
|
21
21
|
key,
|
|
22
22
|
value,
|
|
23
23
|
entityName,
|
|
24
|
-
conditions
|
|
25
|
-
options
|
|
24
|
+
conditions
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
27
|
exports.buildRequestSet = buildRequestSet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/kvs",
|
|
3
|
-
"version": "1.2.7-next.0-experimental-
|
|
3
|
+
"version": "1.2.7-next.0-experimental-3fd1b86",
|
|
4
4
|
"description": "Forge Key Value Store SDK",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@types/node": "20.19.1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@forge/api": "^7.0.1-next.0-experimental-
|
|
22
|
+
"@forge/api": "^7.0.1-next.0-experimental-3fd1b86"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|