@aravinthan_p/appnest-app-sdk-utils 1.0.6 → 1.0.7
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.
|
@@ -91,7 +91,7 @@ const create = async ({ key }) => {
|
|
|
91
91
|
dataType: 'STRING',
|
|
92
92
|
operationType: 'create',
|
|
93
93
|
}
|
|
94
|
-
return await dbAPIWrapper({ apiPayload });
|
|
94
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
95
95
|
} catch (error) {
|
|
96
96
|
console.error("$Db - create - error:", error.message);
|
|
97
97
|
throw error;
|
|
@@ -107,7 +107,7 @@ const update = async ({ key, value }) => {
|
|
|
107
107
|
dataType: 'STRING',
|
|
108
108
|
operationType: 'update',
|
|
109
109
|
}
|
|
110
|
-
return await dbAPIWrapper({ apiPayload });
|
|
110
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
111
111
|
} catch (error) {
|
|
112
112
|
console.error("$Db - update - error:", error.message);
|
|
113
113
|
throw error;
|
|
@@ -122,7 +122,7 @@ const deleteOperation = async ({ key }) => {
|
|
|
122
122
|
dataType: 'STRING',
|
|
123
123
|
operationType: 'delete',
|
|
124
124
|
}
|
|
125
|
-
return await dbAPIWrapper({ apiPayload });
|
|
125
|
+
return await dbAPIWrapper({ apiMethod: DB_API.DELETE.method, apiUrl: DB_API.DELETE.endpoint, apiPayload });
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
128
|
console.error("$Db - deleteOperation - error:", error.message);
|
|
@@ -138,7 +138,7 @@ const stringGet = async ({ key }) => {
|
|
|
138
138
|
dataType: 'STRING',
|
|
139
139
|
operationType: 'get',
|
|
140
140
|
}
|
|
141
|
-
return await dbAPIWrapper({ apiPayload });
|
|
141
|
+
return await dbAPIWrapper({ apiMethod: DB_API.GET.method, apiUrl: DB_API.GET.endpoint, apiPayload });
|
|
142
142
|
} catch (error) {
|
|
143
143
|
console.error("$Db - stringGet - error:", error.message);
|
|
144
144
|
throw error;
|
|
@@ -157,7 +157,7 @@ const stringCreate = async ({ key, value }) => {
|
|
|
157
157
|
value,
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
return await dbAPIWrapper({ apiPayload });
|
|
160
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
161
161
|
} catch (error) {
|
|
162
162
|
console.error("$Db - stringSet - error:", error.message);
|
|
163
163
|
throw error;
|
|
@@ -173,7 +173,7 @@ const stringUpdate = async ({ key, value }) => {
|
|
|
173
173
|
dataType: 'STRING',
|
|
174
174
|
operationType: 'update',
|
|
175
175
|
}
|
|
176
|
-
return await dbAPIWrapper({ apiPayload });
|
|
176
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
177
177
|
} catch (error) {
|
|
178
178
|
console.error("$Db - stringUpdate - error:", error.message);
|
|
179
179
|
throw error;
|
|
@@ -188,7 +188,7 @@ const stringDelete = async ({ key }) => {
|
|
|
188
188
|
dataType: 'STRING',
|
|
189
189
|
operationType: 'delete',
|
|
190
190
|
}
|
|
191
|
-
return await dbAPIWrapper({ apiPayload });
|
|
191
|
+
return await dbAPIWrapper({ apiMethod: DB_API.DELETE.method, apiUrl: DB_API.DELETE.endpoint, apiPayload });
|
|
192
192
|
} catch (error) {
|
|
193
193
|
console.error("$Db - stringDelete - error:", error.message);
|
|
194
194
|
throw error;
|
|
@@ -210,7 +210,7 @@ const numberGet = async ({ key }) => {
|
|
|
210
210
|
dataType: 'NUMBER',
|
|
211
211
|
operationType: 'get',
|
|
212
212
|
}
|
|
213
|
-
return await dbAPIWrapper({ apiPayload });
|
|
213
|
+
return await dbAPIWrapper({ apiMethod: DB_API.GET.method, apiUrl: DB_API.GET.endpoint, apiPayload });
|
|
214
214
|
} catch (error) {
|
|
215
215
|
console.error("$Db - numberGet - error:", error.message);
|
|
216
216
|
throw error;
|
|
@@ -226,7 +226,7 @@ const numberCreate = async ({ key, value }) => {
|
|
|
226
226
|
dataType: 'NUMBER',
|
|
227
227
|
operationType: 'create',
|
|
228
228
|
}
|
|
229
|
-
return await dbAPIWrapper({ apiPayload });
|
|
229
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
230
230
|
}
|
|
231
231
|
catch (error) {
|
|
232
232
|
console.error("$Db - numberCreate - error:", error.message);
|
|
@@ -243,7 +243,7 @@ const numberUpdate = async ({ key, value }) => {
|
|
|
243
243
|
dataType: 'NUMBER',
|
|
244
244
|
operationType: 'update',
|
|
245
245
|
}
|
|
246
|
-
return await dbAPIWrapper({ apiPayload });
|
|
246
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
247
247
|
}
|
|
248
248
|
catch (error) {
|
|
249
249
|
console.error("$Db - numberUpdate - error:", error.message);
|
|
@@ -259,7 +259,7 @@ const numberDelete = async ({ key }) => {
|
|
|
259
259
|
dataType: 'NUMBER',
|
|
260
260
|
operationType: 'delete',
|
|
261
261
|
}
|
|
262
|
-
return await dbAPIWrapper({ apiPayload });
|
|
262
|
+
return await dbAPIWrapper({ apiMethod: DB_API.DELETE.method, apiUrl: DB_API.DELETE.endpoint, apiPayload });
|
|
263
263
|
}
|
|
264
264
|
catch (error) {
|
|
265
265
|
console.error("$Db - numberDelete - error:", error.message);
|
|
@@ -275,7 +275,7 @@ const numberIncrement = async ({ key }) => {
|
|
|
275
275
|
dataType: 'NUMBER',
|
|
276
276
|
operationType: 'increment',
|
|
277
277
|
}
|
|
278
|
-
return await dbAPIWrapper({ apiPayload });
|
|
278
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
279
279
|
}
|
|
280
280
|
catch (error) {
|
|
281
281
|
console.error("$Db - numberIncrement - error:", error.message);
|
|
@@ -291,7 +291,7 @@ const numberDecrement = async ({ key }) => {
|
|
|
291
291
|
dataType: 'NUMBER',
|
|
292
292
|
operationType: 'decrement',
|
|
293
293
|
}
|
|
294
|
-
return await dbAPIWrapper({ apiPayload });
|
|
294
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
295
295
|
}
|
|
296
296
|
catch (error) {
|
|
297
297
|
console.error("$Db - numberDecrement - error:", error.message);
|
|
@@ -316,7 +316,7 @@ const listGet = async ({ key }) => {
|
|
|
316
316
|
dataType: 'LIST',
|
|
317
317
|
operationType: 'get',
|
|
318
318
|
}
|
|
319
|
-
return await dbAPIWrapper({ apiPayload });
|
|
319
|
+
return await dbAPIWrapper({ apiMethod: DB_API.GET.method, apiUrl: DB_API.GET.endpoint, apiPayload });
|
|
320
320
|
} catch (error) {
|
|
321
321
|
console.error("$Db - listGet - error:", error.message);
|
|
322
322
|
throw error;
|
|
@@ -332,7 +332,7 @@ const listCreate = async ({ key, value }) => {
|
|
|
332
332
|
dataType: 'LIST',
|
|
333
333
|
operationType: 'create',
|
|
334
334
|
}
|
|
335
|
-
return await dbAPIWrapper({ apiPayload });
|
|
335
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
336
336
|
} catch (error) {
|
|
337
337
|
console.error("$Db - listCreate - error:", error.message);
|
|
338
338
|
throw error;
|
|
@@ -348,7 +348,7 @@ const listUpdate = async ({ key, value }) => {
|
|
|
348
348
|
dataType: 'LIST',
|
|
349
349
|
operationType: 'update',
|
|
350
350
|
}
|
|
351
|
-
return await dbAPIWrapper({ apiPayload });
|
|
351
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
352
352
|
} catch (error) {
|
|
353
353
|
console.error("$Db - listUpdate - error:", error.message);
|
|
354
354
|
throw error;
|
|
@@ -365,7 +365,7 @@ const listAppend = async ({ key, value }) => {
|
|
|
365
365
|
dataType: 'LIST',
|
|
366
366
|
operationType: 'append',
|
|
367
367
|
}
|
|
368
|
-
return await dbAPIWrapper({ apiPayload });
|
|
368
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
369
369
|
} catch (error) {
|
|
370
370
|
console.error("$Db - listAppend - error:", error.message);
|
|
371
371
|
throw error;
|
|
@@ -381,7 +381,7 @@ const listPrepend = async ({ key, value }) => {
|
|
|
381
381
|
dataType: 'LIST',
|
|
382
382
|
operationType: 'prepend',
|
|
383
383
|
}
|
|
384
|
-
return await dbAPIWrapper({ apiPayload });
|
|
384
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
385
385
|
} catch (error) {
|
|
386
386
|
console.error("$Db - listPrepend - error:", error.message);
|
|
387
387
|
throw error;
|
|
@@ -397,7 +397,7 @@ const listUpdateItemAtIndex = async ({ key, value, index }) => {
|
|
|
397
397
|
dataType: 'LIST',
|
|
398
398
|
operationType: 'updateItemAtIndex',
|
|
399
399
|
}
|
|
400
|
-
return await dbAPIWrapper({ apiPayload });
|
|
400
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
401
401
|
} catch (error) {
|
|
402
402
|
console.error("$Db - listUpdateItemAtIndex - error:", error.message);
|
|
403
403
|
throw error;
|
|
@@ -412,7 +412,7 @@ const listRemoveItemAtIndex = async ({ key, index }) => {
|
|
|
412
412
|
dataType: 'LIST',
|
|
413
413
|
operationType: 'removeItemAtIndex',
|
|
414
414
|
}
|
|
415
|
-
return await dbAPIWrapper({ apiPayload });
|
|
415
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
416
416
|
}
|
|
417
417
|
catch (error) {
|
|
418
418
|
console.error("$Db - listRemoveItemAtIndex - error:", error.message);
|
|
@@ -439,7 +439,7 @@ const mapGet = async ({ key }) => {
|
|
|
439
439
|
dataType: 'MAP',
|
|
440
440
|
operationType: 'get',
|
|
441
441
|
}
|
|
442
|
-
return await dbAPIWrapper({ apiPayload });
|
|
442
|
+
return await dbAPIWrapper({ apiMethod: DB_API.GET.method, apiUrl: DB_API.GET.endpoint, apiPayload });
|
|
443
443
|
} catch (error) {
|
|
444
444
|
console.error("$Db - mapGet - error:", error.message);
|
|
445
445
|
throw error;
|
|
@@ -462,7 +462,7 @@ const mapCreate = async ({ key, value }) => {
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
console.log("$Db - mapCreate - apiPayload:", apiPayload);
|
|
465
|
-
return await dbAPIWrapper({ apiPayload });
|
|
465
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
466
466
|
} catch (error) {
|
|
467
467
|
console.error("$Db - mapCreate - error:", error.message);
|
|
468
468
|
throw error;
|
|
@@ -478,7 +478,7 @@ const mapUpdate = async ({ key, value }) => {
|
|
|
478
478
|
dataType: 'MAP',
|
|
479
479
|
operationType: 'update',
|
|
480
480
|
}
|
|
481
|
-
return await dbAPIWrapper({ apiPayload });
|
|
481
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
482
482
|
} catch (error) {
|
|
483
483
|
console.error("$Db - mapUpdate - error:", error.message);
|
|
484
484
|
throw error;
|
|
@@ -493,6 +493,7 @@ const mapDelete = async ({ key }) => {
|
|
|
493
493
|
dataType: 'MAP',
|
|
494
494
|
operationType: 'delete',
|
|
495
495
|
}
|
|
496
|
+
return await dbAPIWrapper({ apiMethod: DB_API.DELETE.method, apiUrl: DB_API.DELETE.endpoint, apiPayload });
|
|
496
497
|
}
|
|
497
498
|
catch (error) {
|
|
498
499
|
console.error("$Db - mapDelete - error:", error.message);
|
|
@@ -517,7 +518,7 @@ const booleanGet = async ({ key }) => {
|
|
|
517
518
|
dataType: 'BOOLEAN',
|
|
518
519
|
operationType: 'get',
|
|
519
520
|
}
|
|
520
|
-
return await dbAPIWrapper({ apiPayload });
|
|
521
|
+
return await dbAPIWrapper({ apiMethod: DB_API.GET.method, apiUrl: DB_API.GET.endpoint, apiPayload });
|
|
521
522
|
} catch (error) {
|
|
522
523
|
console.error("$Db - booleanGet - error:", error.message);
|
|
523
524
|
throw error;
|
|
@@ -537,7 +538,7 @@ const booleanCreate = async ({ key, value }) => {
|
|
|
537
538
|
}
|
|
538
539
|
}
|
|
539
540
|
console.log("$Db - booleanCreate - apiPayload:", apiPayload);
|
|
540
|
-
return await dbAPIWrapper({ apiPayload });
|
|
541
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
541
542
|
} catch (error) {
|
|
542
543
|
console.error("$Db - booleanCreate - error:", error.message);
|
|
543
544
|
throw error;
|
|
@@ -553,7 +554,7 @@ const booleanUpdate = async ({ key, value }) => {
|
|
|
553
554
|
dataType: 'BOOLEAN',
|
|
554
555
|
operationType: 'update',
|
|
555
556
|
}
|
|
556
|
-
return await dbAPIWrapper({ apiPayload });
|
|
557
|
+
return await dbAPIWrapper({ apiMethod: DB_API.SET.method, apiUrl: DB_API.SET.endpoint, apiPayload });
|
|
557
558
|
} catch (error) {
|
|
558
559
|
console.error("$Db - booleanUpdate - error:", error.message);
|
|
559
560
|
throw error;
|
|
@@ -568,7 +569,7 @@ const booleanDelete = async ({ key }) => {
|
|
|
568
569
|
dataType: 'BOOLEAN',
|
|
569
570
|
operationType: 'delete',
|
|
570
571
|
}
|
|
571
|
-
return await dbAPIWrapper({ apiPayload });
|
|
572
|
+
return await dbAPIWrapper({ apiMethod: DB_API.DELETE.method, apiUrl: DB_API.DELETE.endpoint, apiPayload });
|
|
572
573
|
}
|
|
573
574
|
catch (error) {
|
|
574
575
|
console.error("$Db - booleanDelete - error:", error.message);
|
|
@@ -584,17 +585,18 @@ const boolean = {
|
|
|
584
585
|
}
|
|
585
586
|
|
|
586
587
|
|
|
587
|
-
const dbAPIWrapper = async ({ apiPayload }) => {
|
|
588
|
+
const dbAPIWrapper = async ({ apiMethod, apiUrl, apiPayload }) => {
|
|
588
589
|
try {
|
|
589
590
|
const parentLayerConfigObject = getParentLayerConfigObject();
|
|
590
591
|
const requestBody = {
|
|
591
592
|
userInstalledId: parentLayerConfigObject.userInstalledId,
|
|
593
|
+
appId: parentLayerConfigObject.appId,
|
|
592
594
|
...apiPayload
|
|
593
595
|
};
|
|
594
596
|
console.log("$Db - dbAPIWrapper - requestBody:", requestBody);
|
|
595
597
|
const response = await makeSparrowAppAPICall({
|
|
596
|
-
method:
|
|
597
|
-
endpoint:
|
|
598
|
+
method: apiMethod,
|
|
599
|
+
endpoint: apiUrl,
|
|
598
600
|
requestBody
|
|
599
601
|
});
|
|
600
602
|
console.log("$Db - dbAPIWrapper - response:", response);
|
|
@@ -46,9 +46,21 @@ const SCHEDULE_API = {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const DB_API = {
|
|
49
|
-
|
|
50
|
-
endpoint: '/api/
|
|
49
|
+
GET: {
|
|
50
|
+
endpoint: '/v2/api/typed-storage-v2/get-storage',
|
|
51
|
+
method: 'POST',
|
|
52
|
+
},
|
|
53
|
+
GET_PATTERN: {
|
|
54
|
+
endpoint: '/v2/api//typed-storage-v2/get-pattern-storage',
|
|
51
55
|
method: 'POST',
|
|
56
|
+
},
|
|
57
|
+
SET: {
|
|
58
|
+
endpoint: '/v2/api/typed-storage-v2/set-storage',
|
|
59
|
+
method: 'POST',
|
|
60
|
+
},
|
|
61
|
+
DELETE: {
|
|
62
|
+
endpoint: '/v2/api/typed-storage-v2/del-storage',
|
|
63
|
+
method: 'DELETE',
|
|
52
64
|
}
|
|
53
65
|
}
|
|
54
66
|
|