@ti-engine/core 1.12.3 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ti-engine/core",
3
- "version": "1.12.3",
3
+ "version": "1.13.0",
4
4
  "description": "Microservice framework for Node.js: a Redis-backed message exchange with end-to-end call tracing, retries and tamper-evident message envelopes.",
5
5
  "keywords": [
6
6
  "microservices",
@@ -68,6 +68,14 @@
68
68
  "types": "./types/utils/cache.d.ts",
69
69
  "default": "./utils/cache.js"
70
70
  },
71
+ "#cache-capability": {
72
+ "types": "./types/components/cache/cache-capability.d.ts",
73
+ "default": "./components/cache/cache-capability.js"
74
+ },
75
+ "#cache-provider": {
76
+ "types": "./types/components/cache/cache-provider.d.ts",
77
+ "default": "./components/cache/cache-provider.js"
78
+ },
71
79
  "#config": {
72
80
  "types": "./types/utils/config.d.ts",
73
81
  "default": "./utils/config.js"
@@ -137,6 +145,10 @@
137
145
  "types": "./types/components/exchange/message-tracer.d.ts",
138
146
  "default": "./components/exchange/message-tracer.js"
139
147
  },
148
+ "#redis-cache-provider": {
149
+ "types": "./types/components/cache/redis-cache-provider.d.ts",
150
+ "default": "./components/cache/redis-cache-provider.js"
151
+ },
140
152
  "#redis-integration": {
141
153
  "types": "./types/integrations/redis-integration.d.ts",
142
154
  "default": "./integrations/redis-integration.js"
@@ -0,0 +1,23 @@
1
+ export { cacheCapabilityEnum as cacheCapability };
2
+ export type TiCacheCapability = string;
3
+ /**
4
+ * Enum for listing the optional behaviors a cache backend may or may not provide.
5
+ * <br/>
6
+ * NOTE: A backend declares what it supports through {@link CacheProvider#capabilities}; an application declares what it
7
+ * requires through the 'memoryCache.requiredCapabilities' setting. The two are reconciled once, during startup, so that
8
+ * a backend which cannot do what the application needs fails where somebody is watching rather than inside a request
9
+ * weeks later.
10
+ *
11
+ * @readonly
12
+ * @enum {string}
13
+ * @typedef {string} TiCacheCapability
14
+ */
15
+ declare const cacheCapabilityEnum: import("../definitions.types").TiEnumOf<{
16
+ KEY_EXPIRY: string[];
17
+ KEY_PATTERN_MATCH: string[];
18
+ LISTS: string[];
19
+ SETS: string[];
20
+ HASH_FIELDS: string[];
21
+ JSON_DOCUMENTS: string[];
22
+ ATOMIC_JSON_EDIT: string[];
23
+ }>;
@@ -0,0 +1,326 @@
1
+ export = CacheProvider;
2
+ import type ConnectionObserver from "#connection-observer";
3
+ /** @import ConnectionObserver from "#connection-observer" */
4
+ /**
5
+ * An abstract class that defines the storage behavior required by the {@link CommonMemoryCache}.
6
+ * <br/>
7
+ * NOTE: This sets the contract between the cache and whatever actually holds the values. It has to be inherited and
8
+ * implemented with the specifics of a given backend. For a working example please see the {@link RedisCacheProvider} class.
9
+ * <br/>
10
+ * NOTE: Implementations must NOT check whether the cache is operational. {@link CommonMemoryCache} performs that check
11
+ * once, before it delegates, so every backend inherits the same guard instead of restating it in each of its methods.
12
+ *
13
+ * @class CacheProvider
14
+ * @abstract
15
+ * @public
16
+ */
17
+ declare class CacheProvider {
18
+ /**
19
+ * @constructor
20
+ * @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
21
+ */
22
+ constructor();
23
+ /**
24
+ * Property returning the optional behaviors this backend provides.
25
+ * <br/>
26
+ * NOTE: Some capabilities can only be established once a connection exists — RedisJSON, for example, is a server-side
27
+ * module that has to be probed. Read this after {@link CacheProvider#initialize} has resolved, never before.
28
+ *
29
+ * @property
30
+ * @returns {string[]} Values drawn from {@link TiCacheCapability}.
31
+ * @abstract
32
+ * @public
33
+ */
34
+ get capabilities(): string[];
35
+ /**
36
+ * Used to verify whether this backend provides a given capability.
37
+ *
38
+ * @method
39
+ * @param {string} capability A value from {@link TiCacheCapability}.
40
+ * @returns {boolean}
41
+ * @public
42
+ */
43
+ hasCapability(capability: string): boolean;
44
+ /**
45
+ * Used to initialize the backend and establish whatever connection it requires.
46
+ *
47
+ * @method
48
+ * @returns {Promise}
49
+ * @abstract
50
+ * @public
51
+ */
52
+ initialize(): Promise<any>;
53
+ /**
54
+ * Used to gracefully shut the backend down.
55
+ *
56
+ * @method
57
+ * @returns {Promise}
58
+ * @abstract
59
+ * @public
60
+ */
61
+ shutDown(): Promise<any>;
62
+ /**
63
+ * Used to register a new {@link ConnectionObserver} for events related to the backend connection state.
64
+ *
65
+ * @method
66
+ * @param {ConnectionObserver} connectionObserver The {@link ConnectionObserver} that will be notified of any changes.
67
+ * @abstract
68
+ * @public
69
+ */
70
+ addConnectionObserver(connectionObserver: ConnectionObserver): void;
71
+ /**
72
+ * Used to search for keys by a given pattern.
73
+ *
74
+ * @method
75
+ * @param {string} pattern
76
+ * @returns {Promise<Array>}
77
+ * @requires {TiCacheCapability.KEY_PATTERN_MATCH}
78
+ * @abstract
79
+ * @public
80
+ */
81
+ matchKeys(pattern: string): Promise<any[]>;
82
+ /**
83
+ * Used to set a specific string value.
84
+ *
85
+ * @method
86
+ * @param {string} key
87
+ * @param {string} value
88
+ * @param {number} [expiration] Expiration value is in seconds.
89
+ * @returns {Promise<string>}
90
+ * @abstract
91
+ * @public
92
+ */
93
+ setValue(key: string, value: string, expiration?: number): Promise<string>;
94
+ /**
95
+ * Used to set multiple string values.
96
+ *
97
+ * @method
98
+ * @param {Object} keyValues
99
+ * @param {string} [prefix]
100
+ * @param {number} [expiration] Expiration value is in seconds.
101
+ * @returns {Promise}
102
+ * @abstract
103
+ * @public
104
+ */
105
+ setValues(keyValues: Object, prefix?: string, expiration?: number): Promise<any>;
106
+ /**
107
+ * Used to get a string value.
108
+ *
109
+ * @method
110
+ * @param {string} key
111
+ * @returns {Promise}
112
+ * @abstract
113
+ * @public
114
+ */
115
+ getValue(key: string): Promise<any>;
116
+ /**
117
+ * Used to get multiple string values.
118
+ *
119
+ * @method
120
+ * @param {string[]} keys
121
+ * @param {string} [prefix]
122
+ * @returns {Promise}
123
+ * @abstract
124
+ * @public
125
+ */
126
+ getValues(keys: string[], prefix?: string): Promise<any>;
127
+ /**
128
+ * Used to delete a value / item.
129
+ *
130
+ * @method
131
+ * @param {string} key
132
+ * @returns {Promise<boolean>}
133
+ * @abstract
134
+ * @public
135
+ */
136
+ deleteValue(key: string): Promise<boolean>;
137
+ /**
138
+ * Used to set expiration in seconds to an existing key.
139
+ *
140
+ * @method
141
+ * @param {string} key
142
+ * @param {number} seconds
143
+ * @param {string} [name] If a field in a hash set is to be expired instead, the name of that set.
144
+ * @returns {Promise<number>}
145
+ * @requires {TiCacheCapability.KEY_EXPIRY}
146
+ * @abstract
147
+ * @public
148
+ */
149
+ expireValue(key: string, seconds: number, name?: string): Promise<number>;
150
+ /**
151
+ * Used to add the specified values to a list.
152
+ *
153
+ * @method
154
+ * @param {string} listName
155
+ * @param {Object[]} values
156
+ * @returns {Promise<number>}
157
+ * @requires {TiCacheCapability.LISTS}
158
+ * @abstract
159
+ * @public
160
+ */
161
+ listPushValue(listName: string, values: Object[]): Promise<number>;
162
+ /**
163
+ * Used to add the specified value to a set.
164
+ *
165
+ * @method
166
+ * @param {string} key
167
+ * @param {string|Object} value
168
+ * @returns {Promise}
169
+ * @requires {TiCacheCapability.SETS}
170
+ * @abstract
171
+ * @public
172
+ */
173
+ addToSet(key: string, value: string | Object): Promise<any>;
174
+ /**
175
+ * Used to add multiple values to multiple sets in one transactional request.
176
+ *
177
+ * @method
178
+ * @param {string[]} keys
179
+ * @param {string[]} values
180
+ * @returns {Promise}
181
+ * @requires {TiCacheCapability.SETS}
182
+ * @abstract
183
+ * @public
184
+ */
185
+ addToSetMulti(keys: string[], values: string[]): Promise<any>;
186
+ /**
187
+ * Used to verify whether a value is a member of a set.
188
+ *
189
+ * @method
190
+ * @param {string} setName
191
+ * @param {string|Object} value
192
+ * @returns {Promise<boolean>}
193
+ * @requires {TiCacheCapability.SETS}
194
+ * @abstract
195
+ * @public
196
+ */
197
+ isSetMember(setName: string, value: string | Object): Promise<boolean>;
198
+ /**
199
+ * Used to fetch all members of a set.
200
+ *
201
+ * @method
202
+ * @param {string} key
203
+ * @returns {Promise<Array>}
204
+ * @requires {TiCacheCapability.SETS}
205
+ * @abstract
206
+ * @public
207
+ */
208
+ membersOfSet(key: string): Promise<any[]>;
209
+ /**
210
+ * Used to fetch the union of the provided sets.
211
+ *
212
+ * @method
213
+ * @param {string[]} keys
214
+ * @returns {Promise<Array>}
215
+ * @requires {TiCacheCapability.SETS}
216
+ * @abstract
217
+ * @public
218
+ */
219
+ unionOfSets(keys: string[]): Promise<any[]>;
220
+ /**
221
+ * Used to set a single field in a hash set.
222
+ *
223
+ * @method
224
+ * @param {string} key
225
+ * @param {string} name
226
+ * @param {string|Object} value
227
+ * @returns {Promise}
228
+ * @requires {TiCacheCapability.HASH_FIELDS}
229
+ * @abstract
230
+ * @public
231
+ */
232
+ hashSetField(key: string, name: string, value: string | Object): Promise<any>;
233
+ /**
234
+ * Used to set multiple fields in a hash set.
235
+ *
236
+ * @method
237
+ * @param {string} key
238
+ * @param {Object} fields
239
+ * @returns {Promise}
240
+ * @requires {TiCacheCapability.HASH_FIELDS}
241
+ * @abstract
242
+ * @public
243
+ */
244
+ hashSetFields(key: string, fields: Object): Promise<any>;
245
+ /**
246
+ * Used to fetch a single field from a hash set.
247
+ *
248
+ * @method
249
+ * @param {string} key
250
+ * @param {string} field
251
+ * @returns {Promise}
252
+ * @requires {TiCacheCapability.HASH_FIELDS}
253
+ * @abstract
254
+ * @public
255
+ */
256
+ hashGetField(key: string, field: string): Promise<any>;
257
+ /**
258
+ * Used to delete a single field from a hash set.
259
+ *
260
+ * @method
261
+ * @param {string} key
262
+ * @param {string} field
263
+ * @returns {Promise}
264
+ * @requires {TiCacheCapability.HASH_FIELDS}
265
+ * @abstract
266
+ * @public
267
+ */
268
+ hashDeleteField(key: string, field: string): Promise<any>;
269
+ /**
270
+ * Used to store a JSON document, or a branch of one.
271
+ *
272
+ * @method
273
+ * @param {string} key
274
+ * @param {Object} value
275
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments.
276
+ * @param {number} [overrideMode=0] 0 allows full override; 1 sets only if absent; 2 sets only if present.
277
+ * @returns {Promise}
278
+ * @requires {TiCacheCapability.JSON_DOCUMENTS}
279
+ * @abstract
280
+ * @public
281
+ */
282
+ setJSON(key: string, value: Object, path?: string | string[], overrideMode?: number): Promise<any>;
283
+ /**
284
+ * Used to fetch a JSON document, or a branch of one.
285
+ *
286
+ * @method
287
+ * @param {string} key
288
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments.
289
+ * @returns {Promise<Object>}
290
+ * @requires {TiCacheCapability.JSON_DOCUMENTS}
291
+ * @abstract
292
+ * @public
293
+ */
294
+ getJSON(key: string, path?: string | string[]): Promise<Object>;
295
+ /**
296
+ * Used to merge a value into an existing JSON document at the given path.
297
+ * <br/>
298
+ * NOTE: Callers rely on this being applied atomically by the backend when {@link TiCacheCapability.ATOMIC_JSON_EDIT}
299
+ * is declared — two concurrent edits to different paths of the same document must both survive. A backend that can
300
+ * only read-modify-write must NOT declare that capability, because the loss is silent: nothing throws, and one of
301
+ * the two writes is simply gone.
302
+ *
303
+ * @method
304
+ * @param {string} key
305
+ * @param {Object} value
306
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments.
307
+ * @returns {Promise}
308
+ * @requires {TiCacheCapability.JSON_DOCUMENTS}
309
+ * @abstract
310
+ * @public
311
+ */
312
+ editJSON(key: string, value: Object, path?: string | string[]): Promise<any>;
313
+ /**
314
+ * Used to append a value to an array inside a JSON document.
315
+ *
316
+ * @method
317
+ * @param {string} key
318
+ * @param {Object} value
319
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments.
320
+ * @returns {Promise}
321
+ * @requires {TiCacheCapability.JSON_DOCUMENTS}
322
+ * @abstract
323
+ * @public
324
+ */
325
+ arrayAppendJSON(key: string, value: Object, path?: string | string[]): Promise<any>;
326
+ }
@@ -0,0 +1,327 @@
1
+ export = RedisCacheProvider;
2
+ import CacheProvider = require("#cache-provider");
3
+ import type ConnectionObserver from "#connection-observer";
4
+ /**
5
+ * A {@link CacheProvider} backed by Redis, optionally with the RedisJSON module.
6
+ * <br/>
7
+ * NOTE: This holds every Redis-specific detail in the engine's cache path — the command names, the
8
+ * '[ error, value ]' result shape, and the JSONPath encoding. Nothing above it should know that Redis is what is
9
+ * storing the values.
10
+ *
11
+ * @class RedisCacheProvider
12
+ * @extends CacheProvider
13
+ * @public
14
+ */
15
+ declare class RedisCacheProvider extends CacheProvider {
16
+ #private;
17
+ /**
18
+ * @constructor
19
+ * @param {string} connectionIdentifier The identifier under which this backend's connection is observed.
20
+ */
21
+ constructor(connectionIdentifier: string);
22
+ /**
23
+ * Decodes one entry of a `multi(...).exec()` result into the value it carries.
24
+ * <br/>
25
+ * NOTE: Exposed for testing. The provider builds its own Redis client in its constructor, so `getValues` cannot be
26
+ * driven without a live server — this is one of the pure halves of it, and it is where the defect was.
27
+ *
28
+ * @method
29
+ * @param {Array} [result] One `[ error, value ]` entry.
30
+ * @returns {*} The parsed value, or `undefined` when there is none.
31
+ * @public
32
+ */
33
+ static decodeCommandValue(result?: any[]): any;
34
+ /**
35
+ * Maps a set of requested keys onto the values a `multi(...).exec()` returned for them, using `null` for a miss.
36
+ * <br/>
37
+ * NOTE: Exposed for testing, for the same reason as {@link RedisCacheProvider.decodeCommandValue}.
38
+ *
39
+ * @method
40
+ * @param {string[]} keys The keys that were requested, in command order.
41
+ * @param {Array} [rawResults] The `multi(...).exec()` result.
42
+ * @returns {Object} A null-prototype map of key to value, `null` where the key was absent.
43
+ * @public
44
+ */
45
+ static mapCommandValues(keys: string[], rawResults?: any[]): Object;
46
+ /**
47
+ * Property returning the connection identifier of this backend.
48
+ *
49
+ * @property
50
+ * @returns {string}
51
+ * @public
52
+ */
53
+ get connectionIdentifier(): string;
54
+ /**
55
+ * Property returning the optional behaviors this backend provides.
56
+ * <br/>
57
+ * NOTE: The JSON capabilities depend on the RedisJSON module being installed on the server, which is only known
58
+ * after the client has connected — so this is accurate from {@link RedisCacheProvider#initialize} onward and
59
+ * reports no JSON support before that.
60
+ *
61
+ * @property
62
+ * @returns {string[]}
63
+ * @override
64
+ * @public
65
+ */
66
+ get capabilities(): string[];
67
+ /**
68
+ * Used to initialize the backend and connect to the Redis server.
69
+ *
70
+ * @method
71
+ * @returns {Promise}
72
+ * @override
73
+ * @public
74
+ */
75
+ initialize(): Promise<any>;
76
+ /**
77
+ * Used to gracefully shut the Redis connection down.
78
+ *
79
+ * @method
80
+ * @returns {Promise}
81
+ * @override
82
+ * @public
83
+ */
84
+ shutDown(): Promise<any>;
85
+ /**
86
+ * Used to register a new {@link ConnectionObserver} for events related to the underlying Redis connection state.
87
+ *
88
+ * @method
89
+ * @param {ConnectionObserver} connectionObserver The {@link ConnectionObserver} that will be notified of any changes.
90
+ * @override
91
+ * @public
92
+ */
93
+ addConnectionObserver(connectionObserver: ConnectionObserver): void;
94
+ /**
95
+ * Used to search for keys by a given pattern.
96
+ *
97
+ * @method
98
+ * @param {string} pattern
99
+ * @returns {Promise<Array>}
100
+ * @public
101
+ */
102
+ matchKeys(pattern: string): Promise<any[]>;
103
+ /**
104
+ * Used to set a specific string value.
105
+ *
106
+ * @method
107
+ * @param {string} key
108
+ * @param {string} value
109
+ * @param {number} [expiration] Expiration value is in seconds.
110
+ * @return {Promise<string>}
111
+ * @public
112
+ */
113
+ setValue(key: string, value: string, expiration?: number): Promise<string>;
114
+ /**
115
+ * Used to set multiple string values.
116
+ *
117
+ * @method
118
+ * @param {Object} keyValues
119
+ * @param {string} [prefix]
120
+ * @param {number} [expiration]
121
+ * @return {Promise}
122
+ * @public
123
+ */
124
+ setValues(keyValues: Object, prefix?: string, expiration?: number): Promise<any>;
125
+ /**
126
+ * Used to get a string value.
127
+ *
128
+ * @method
129
+ * @param {string} key
130
+ * @return {Promise}
131
+ * @public
132
+ */
133
+ getValue(key: string): Promise<any>;
134
+ /**
135
+ * Used to get multiple string values.
136
+ *
137
+ * @method
138
+ * @param {string[]} keys
139
+ * @param {string} [prefix]
140
+ * @return {Promise}
141
+ * @public
142
+ */
143
+ getValues(keys: string[], prefix?: string): Promise<any>;
144
+ /**
145
+ * Used to delete a value / item.
146
+ *
147
+ * @method
148
+ * @param {string} key
149
+ * @returns {Promise<boolean>}
150
+ * @public
151
+ */
152
+ deleteValue(key: string): Promise<boolean>;
153
+ /**
154
+ * Used to set expiration in seconds to an existing key.
155
+ * <br/>
156
+ * NOTE: For performance optimization reasons, only use this only if the Redis command does not itself support the 'EX' argument.
157
+ *
158
+ * @method
159
+ * @param {string} key
160
+ * @param {number} seconds
161
+ * @param {string} [name] If you need to expire a field in a hash set instead, provide the name of the set here.
162
+ * @returns {Promise<number>} This will resolve with the seconds as provided initially by the caller.
163
+ * @public
164
+ */
165
+ expireValue(key: string, seconds: number, name?: string): Promise<number>;
166
+ /**
167
+ * Used to add the specified values to a list.
168
+ *
169
+ * @method
170
+ * @param {string} listName
171
+ * @param {Object[]} values
172
+ * @returns {Promise<number>}
173
+ * @public
174
+ */
175
+ listPushValue(listName: string, values: Object[]): Promise<number>;
176
+ /**
177
+ * Used to add the specified value to a set.
178
+ *
179
+ * @method
180
+ * @param {string} key
181
+ * @param {string|Object} value
182
+ * @returns {Promise}
183
+ * @public
184
+ */
185
+ addToSet(key: string, value: string | Object): Promise<any>;
186
+ /**
187
+ * Used to add multiple values to multiple sets in one transactional request.
188
+ * <br/>
189
+ * NOTE: The two arrays of keys and values must have correct index relations (i.e., first pair on keys[0] and values[0] and so on)!
190
+ *
191
+ * @method
192
+ * @param {string[]} keys
193
+ * @param {string[]} values
194
+ * @returns {Promise}
195
+ * @public
196
+ */
197
+ addToSetMulti(keys: string[], values: string[]): Promise<any>;
198
+ /**
199
+ * Used to check if the provided value is a member of the specified set.
200
+ *
201
+ * @method
202
+ * @param {string} setName
203
+ * @param {string} value
204
+ * @returns {Promise<boolean>}
205
+ * @public
206
+ */
207
+ isSetMember(setName: string, value: string): Promise<boolean>;
208
+ /**
209
+ * Used to get all elements of a set.
210
+ *
211
+ * @method
212
+ * @param {string} key
213
+ * @returns {Promise<Object[]>}
214
+ * @public
215
+ */
216
+ membersOfSet(key: string): Promise<Object[]>;
217
+ /**
218
+ * Used to get a union of all elements in the list of sets.
219
+ *
220
+ * @method
221
+ * @param {string[]} keys
222
+ * @returns {Promise<Object[]>}
223
+ * @public
224
+ */
225
+ unionOfSets(keys: string[]): Promise<Object[]>;
226
+ /**
227
+ * Used to set a single hash field.
228
+ *
229
+ * @method
230
+ * @deprecated
231
+ * @param {string} key
232
+ * @param {string} name
233
+ * @param {*} value
234
+ * @returns {Promise}
235
+ * @public
236
+ */
237
+ hashSetField(key: string, name: string, value: any): Promise<any>;
238
+ /**
239
+ * Used to set multiple hash fields.
240
+ *
241
+ * @method
242
+ * @deprecated
243
+ * @param {string} key
244
+ * @param {Object[]} fields
245
+ * @param {string} fields[].name
246
+ * @param {*} fields[].value
247
+ * @returns {Promise}
248
+ * @public
249
+ */
250
+ hashSetFields(key: string, fields: {
251
+ name: string;
252
+ value: any;
253
+ }[]): Promise<any>;
254
+ /**
255
+ * Used to get a single field from a hash.
256
+ *
257
+ * @method
258
+ * @param {string} key
259
+ * @param {string} field
260
+ * @return {Promise}
261
+ * @public
262
+ */
263
+ hashGetField(key: string, field: string): Promise<any>;
264
+ /**
265
+ * Used to remove a single field from a hash.
266
+ *
267
+ * @method
268
+ * @param {string} key
269
+ * @param {string} field
270
+ * @return {Promise<boolean>} Will return 'true' if the field was removed, 'false' otherwise.
271
+ * @public
272
+ */
273
+ hashDeleteField(key: string, field: string): Promise<boolean>;
274
+ /**
275
+ * Used to store a JSON variable.
276
+ * <br/>
277
+ * NOTE: Requires ReJSON module installed on server to work.
278
+ *
279
+ * @method
280
+ * @param {string} key
281
+ * @param {Object} value
282
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments (use the array form when key names may contain dots or other special characters).
283
+ * @param {number} [overrideMode=0] By default this allows full override for existing keys.
284
+ * Option 1 will set the key only if it doesn't already exist. Option 2 will set it only if it already exists.
285
+ * @returns {Promise}
286
+ * @public
287
+ */
288
+ setJSON(key: string, value: Object, path?: string | string[], overrideMode?: number): Promise<any>;
289
+ /**
290
+ * Used to fetch a JSON variable.
291
+ * <br/>
292
+ * NOTE: Requires ReJSON module installed on server to work.
293
+ *
294
+ * @method
295
+ * @param {string} key
296
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments (use the array form when key names may contain dots or other special characters).
297
+ * @returns {Promise<Object>}
298
+ * @public
299
+ */
300
+ getJSON(key: string, path?: string | string[]): Promise<Object>;
301
+ /**
302
+ * Used to update/edit an existing JSON variable.
303
+ * <br/>
304
+ * NOTE: Requires ReJSON module installed on server to work.
305
+ *
306
+ * @method
307
+ * @param {string} key
308
+ * @param {Object} value
309
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments (use the array form when key names may contain dots or other special characters).
310
+ * @returns {Promise}
311
+ * @public
312
+ */
313
+ editJSON(key: string, value: Object, path?: string | string[]): Promise<any>;
314
+ /**
315
+ * Used to add an item to a JSON array. That array needs to exist already.
316
+ * <br/>
317
+ * NOTE: Requires ReJSON module installed on server to work.
318
+ *
319
+ * @method
320
+ * @param {string} key
321
+ * @param {Object} value
322
+ * @param {string|string[]} [path="$"] A dot-separated JSONPath string, or an array of literal key segments (use the array form when key names may contain dots or other special characters).
323
+ * @returns {Promise}
324
+ * @public
325
+ */
326
+ arrayAppendJSON(key: string, value: Object, path?: string | string[]): Promise<any>;
327
+ }