From 5c7ca2cbaf43bbbdd4387ecf1ad8b8474af9042d Mon Sep 17 00:00:00 2001 From: Vladimir Upirov <4648606+Valodya@users.noreply.github.com> Date: Thu, 3 Nov 2022 22:26:45 +0200 Subject: [PATCH] - rename "exists" method to "exist" for Hive(str).Store --- backendless.d.ts | 4 ++-- src/hive/stores/base-store.js | 10 +++++----- test/tsd.ts | 20 +++++++++---------- test/unit/specs/hive/key-value.js | 32 +++++++++++++++--------------- test/unit/specs/hive/list.js | 32 +++++++++++++++--------------- test/unit/specs/hive/map.js | 32 +++++++++++++++--------------- test/unit/specs/hive/set.js | 32 +++++++++++++++--------------- test/unit/specs/hive/sorted-set.js | 32 +++++++++++++++--------------- 8 files changed, 97 insertions(+), 97 deletions(-) diff --git a/backendless.d.ts b/backendless.d.ts index 4400e247..6a3ec72d 100644 --- a/backendless.d.ts +++ b/backendless.d.ts @@ -336,7 +336,7 @@ declare module Backendless { delete(keys: Array): Promise; - exists(keys: Array): Promise; + exist(keys: Array): Promise; touch(keys: Array): Promise; } @@ -350,7 +350,7 @@ declare module Backendless { rename(newKeyName: string, overwrite?: boolean): Promise; - exists(): Promise; + exist(): Promise; getExpiration(): Promise; diff --git a/src/hive/stores/base-store.js b/src/hive/stores/base-store.js index 277e9886..5f04d2ba 100644 --- a/src/hive/stores/base-store.js +++ b/src/hive/stores/base-store.js @@ -2,7 +2,7 @@ import Utils from '../../utils' export class HiveStore { - static STATIC_METHODS = ['keys', 'delete', 'exists', 'touch'] + static STATIC_METHODS = ['keys', 'delete', 'exist', 'touch'] static registerType(hive) { const context = { ...this, app: hive.app, hiveName: hive.hiveName } @@ -68,14 +68,14 @@ export class HiveStore { }) } - static exists(keys) { + static exist(keys) { if (!Array.isArray(keys)) { throw new Error('Keys must be provided and must be a list of strings.') } return this.app.request .post({ - url : `${this.app.urls.hiveStore(this.hiveName, this.TYPE)}/action/exists`, + url : `${this.app.urls.hiveStore(this.hiveName, this.TYPE)}/action/exist`, data: keys }) } @@ -100,8 +100,8 @@ export class HiveStore { return this.constructor.delete.call({ ...this, ...this.constructor }, [this.storeKey]) } - async exists() { - const result = await this.constructor.exists.call({ ...this, ...this.constructor }, [this.storeKey]) + async exist() { + const result = await this.constructor.exist.call({ ...this, ...this.constructor }, [this.storeKey]) return !!result } diff --git a/test/tsd.ts b/test/tsd.ts index c90278ac..2a71c5c3 100644 --- a/test/tsd.ts +++ b/test/tsd.ts @@ -744,14 +744,14 @@ function testHiveStores() { promiseStoreKeysResult = Backendless.Hive(str).KeyValueStore.keys(storeKeysOptions); promiseVoid = Backendless.Hive(str).KeyValueStore.delete(strArr); - promiseNumber = Backendless.Hive(str).KeyValueStore.exists(strArr); + promiseNumber = Backendless.Hive(str).KeyValueStore.exist(strArr); promiseVoid = Backendless.Hive(str).KeyValueStore.touch(strArr); } function testGeneralInstance() { promiseNumber = Backendless.Hive(str).KeyValueStore(str).delete(); - promiseBoolean = Backendless.Hive(str).KeyValueStore(str).exists(); + promiseBoolean = Backendless.Hive(str).KeyValueStore(str).exist(); promiseVoid = Backendless.Hive(str).KeyValueStore(str).rename(str); promiseVoid = Backendless.Hive(str).KeyValueStore(str).rename(str, bool); @@ -808,14 +808,14 @@ function testHiveStores() { promiseStoreKeysResult = Backendless.Hive(str).ListStore.keys(storeKeysOptions); promiseVoid = Backendless.Hive(str).ListStore.delete(strArr); - promiseNumber = Backendless.Hive(str).ListStore.exists(strArr); + promiseNumber = Backendless.Hive(str).ListStore.exist(strArr); promiseVoid = Backendless.Hive(str).ListStore.touch(strArr); } function testGeneralInstance() { promiseNumber = Backendless.Hive(str).ListStore(str).delete(); - promiseBoolean = Backendless.Hive(str).ListStore(str).exists(); + promiseBoolean = Backendless.Hive(str).ListStore(str).exist(); promiseVoid = Backendless.Hive(str).ListStore(str).rename(str); promiseVoid = Backendless.Hive(str).ListStore(str).rename(str, bool); @@ -903,14 +903,14 @@ function testHiveStores() { promiseStoreKeysResult = Backendless.Hive(str).MapStore.keys(storeKeysOptions); promiseVoid = Backendless.Hive(str).MapStore.delete(strArr); - promiseNumber = Backendless.Hive(str).MapStore.exists(strArr); + promiseNumber = Backendless.Hive(str).MapStore.exist(strArr); promiseVoid = Backendless.Hive(str).MapStore.touch(strArr); } function testGeneralInstance() { promiseNumber = Backendless.Hive(str).MapStore(str).delete(); - promiseBoolean = Backendless.Hive(str).MapStore(str).exists(); + promiseBoolean = Backendless.Hive(str).MapStore(str).exist(); promiseVoid = Backendless.Hive(str).MapStore(str).rename(str); promiseVoid = Backendless.Hive(str).MapStore(str).rename(str, bool); @@ -975,14 +975,14 @@ function testHiveStores() { promiseStoreKeysResult = Backendless.Hive(str).SetStore.keys(storeKeysOptions); promiseVoid = Backendless.Hive(str).SetStore.delete(strArr); - promiseNumber = Backendless.Hive(str).SetStore.exists(strArr); + promiseNumber = Backendless.Hive(str).SetStore.exist(strArr); promiseVoid = Backendless.Hive(str).SetStore.touch(strArr); } function testGeneralInstance() { promiseNumber = Backendless.Hive(str).SetStore(str).delete(); - promiseBoolean = Backendless.Hive(str).SetStore(str).exists(); + promiseBoolean = Backendless.Hive(str).SetStore(str).exist(); promiseVoid = Backendless.Hive(str).SetStore(str).rename(str); promiseVoid = Backendless.Hive(str).SetStore(str).rename(str, bool); @@ -1065,14 +1065,14 @@ function testHiveStores() { promiseStoreKeysResult = Backendless.Hive(str).SortedSetStore.keys(storeKeysOptions); promiseVoid = Backendless.Hive(str).SortedSetStore.delete(strArr); - promiseNumber = Backendless.Hive(str).SortedSetStore.exists(strArr); + promiseNumber = Backendless.Hive(str).SortedSetStore.exist(strArr); promiseVoid = Backendless.Hive(str).SortedSetStore.touch(strArr); } function testGeneralInstance() { promiseNumber = Backendless.Hive(str).SortedSetStore(str).delete(); - promiseBoolean = Backendless.Hive(str).SortedSetStore(str).exists(); + promiseBoolean = Backendless.Hive(str).SortedSetStore(str).exist(); promiseVoid = Backendless.Hive(str).SortedSetStore(str).rename(str); promiseVoid = Backendless.Hive(str).SortedSetStore(str).rename(str, bool); diff --git a/test/unit/specs/hive/key-value.js b/test/unit/specs/hive/key-value.js index d13cb311..bd40c308 100644 --- a/test/unit/specs/hive/key-value.js +++ b/test/unit/specs/hive/key-value.js @@ -140,11 +140,11 @@ describe('Hive - Key Value Store', function() { it('success with multi keys', async () => { const request = prepareMockRequest(fakeResult) - const result = await Store.exists(['testKey1', 'testKey1']) + const result = await Store.exist(['testKey1', 'testKey1']) expect(request).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`, headers: { 'Content-Type': 'application/json' }, body : ['testKey1', 'testKey1'] }) @@ -155,16 +155,16 @@ describe('Hive - Key Value Store', function() { it('fails when key(s) is invalid', async () => { const errorMsg = 'Keys must be provided and must be a list of strings.' - await expect(() => Store.exists(undefined)).to.throw(errorMsg) - await expect(() => Store.exists(null)).to.throw(errorMsg) - await expect(() => Store.exists(false)).to.throw(errorMsg) - await expect(() => Store.exists(true)).to.throw(errorMsg) - await expect(() => Store.exists('')).to.throw(errorMsg) - await expect(() => Store.exists('key')).to.throw(errorMsg) - await expect(() => Store.exists(0)).to.throw(errorMsg) - await expect(() => Store.exists(123)).to.throw(errorMsg) - await expect(() => Store.exists(() => undefined)).to.throw(errorMsg) - await expect(() => Store.exists({})).to.throw(errorMsg) + await expect(() => Store.exist(undefined)).to.throw(errorMsg) + await expect(() => Store.exist(null)).to.throw(errorMsg) + await expect(() => Store.exist(false)).to.throw(errorMsg) + await expect(() => Store.exist(true)).to.throw(errorMsg) + await expect(() => Store.exist('')).to.throw(errorMsg) + await expect(() => Store.exist('key')).to.throw(errorMsg) + await expect(() => Store.exist(0)).to.throw(errorMsg) + await expect(() => Store.exist(123)).to.throw(errorMsg) + await expect(() => Store.exist(() => undefined)).to.throw(errorMsg) + await expect(() => Store.exist({})).to.throw(errorMsg) }) }) @@ -241,19 +241,19 @@ describe('Hive - Key Value Store', function() { const req1 = prepareMockRequest(1) const req2 = prepareMockRequest(0) - const result1 = await store.exists(storeKey) - const result2 = await store.exists(storeKey) + const result1 = await store.exist(storeKey) + const result2 = await store.exist(storeKey) expect(req1).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) expect(req2).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/key-value/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/key-value/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) diff --git a/test/unit/specs/hive/list.js b/test/unit/specs/hive/list.js index c3cda379..2d644ad5 100644 --- a/test/unit/specs/hive/list.js +++ b/test/unit/specs/hive/list.js @@ -141,11 +141,11 @@ describe('Hive - List Store', function() { it('success with multi keys', async () => { const request = prepareMockRequest(fakeResult) - const result = await Store.exists(['testKey1', 'testKey1']) + const result = await Store.exist(['testKey1', 'testKey1']) expect(request).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/list/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/list/action/exist`, headers: { 'Content-Type': 'application/json' }, body : ['testKey1', 'testKey1'] }) @@ -156,16 +156,16 @@ describe('Hive - List Store', function() { it('fails when key(s) is invalid', async () => { const errorMsg = 'Keys must be provided and must be a list of strings.' - await expect(() => Store.exists(undefined)).to.throw(errorMsg) - await expect(() => Store.exists(null)).to.throw(errorMsg) - await expect(() => Store.exists(false)).to.throw(errorMsg) - await expect(() => Store.exists(true)).to.throw(errorMsg) - await expect(() => Store.exists('')).to.throw(errorMsg) - await expect(() => Store.exists('key')).to.throw(errorMsg) - await expect(() => Store.exists(0)).to.throw(errorMsg) - await expect(() => Store.exists(123)).to.throw(errorMsg) - await expect(() => Store.exists(() => undefined)).to.throw(errorMsg) - await expect(() => Store.exists({})).to.throw(errorMsg) + await expect(() => Store.exist(undefined)).to.throw(errorMsg) + await expect(() => Store.exist(null)).to.throw(errorMsg) + await expect(() => Store.exist(false)).to.throw(errorMsg) + await expect(() => Store.exist(true)).to.throw(errorMsg) + await expect(() => Store.exist('')).to.throw(errorMsg) + await expect(() => Store.exist('key')).to.throw(errorMsg) + await expect(() => Store.exist(0)).to.throw(errorMsg) + await expect(() => Store.exist(123)).to.throw(errorMsg) + await expect(() => Store.exist(() => undefined)).to.throw(errorMsg) + await expect(() => Store.exist({})).to.throw(errorMsg) }) }) @@ -243,19 +243,19 @@ describe('Hive - List Store', function() { const req1 = prepareMockRequest(1) const req2 = prepareMockRequest(0) - const result1 = await store.exists(storeKey) - const result2 = await store.exists(storeKey) + const result1 = await store.exist(storeKey) + const result2 = await store.exist(storeKey) expect(req1).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/list/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/list/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) expect(req2).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/list/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/list/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) diff --git a/test/unit/specs/hive/map.js b/test/unit/specs/hive/map.js index 1d07ec1d..10b7e88f 100644 --- a/test/unit/specs/hive/map.js +++ b/test/unit/specs/hive/map.js @@ -140,11 +140,11 @@ describe('Hive - Map Store', function() { it('success with multi keys', async () => { const request = prepareMockRequest(fakeResult) - const result = await Store.exists(['testKey1', 'testKey1']) + const result = await Store.exist(['testKey1', 'testKey1']) expect(request).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/map/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/map/action/exist`, headers: { 'Content-Type': 'application/json' }, body : ['testKey1', 'testKey1'] }) @@ -155,16 +155,16 @@ describe('Hive - Map Store', function() { it('fails when key(s) is invalid', async () => { const errorMsg = 'Keys must be provided and must be a list of strings.' - await expect(() => Store.exists(undefined)).to.throw(errorMsg) - await expect(() => Store.exists(null)).to.throw(errorMsg) - await expect(() => Store.exists(false)).to.throw(errorMsg) - await expect(() => Store.exists(true)).to.throw(errorMsg) - await expect(() => Store.exists('')).to.throw(errorMsg) - await expect(() => Store.exists('key')).to.throw(errorMsg) - await expect(() => Store.exists(0)).to.throw(errorMsg) - await expect(() => Store.exists(123)).to.throw(errorMsg) - await expect(() => Store.exists(() => undefined)).to.throw(errorMsg) - await expect(() => Store.exists({})).to.throw(errorMsg) + await expect(() => Store.exist(undefined)).to.throw(errorMsg) + await expect(() => Store.exist(null)).to.throw(errorMsg) + await expect(() => Store.exist(false)).to.throw(errorMsg) + await expect(() => Store.exist(true)).to.throw(errorMsg) + await expect(() => Store.exist('')).to.throw(errorMsg) + await expect(() => Store.exist('key')).to.throw(errorMsg) + await expect(() => Store.exist(0)).to.throw(errorMsg) + await expect(() => Store.exist(123)).to.throw(errorMsg) + await expect(() => Store.exist(() => undefined)).to.throw(errorMsg) + await expect(() => Store.exist({})).to.throw(errorMsg) }) }) @@ -242,19 +242,19 @@ describe('Hive - Map Store', function() { const req1 = prepareMockRequest(1) const req2 = prepareMockRequest(0) - const result1 = await store.exists(storeKey) - const result2 = await store.exists(storeKey) + const result1 = await store.exist(storeKey) + const result2 = await store.exist(storeKey) expect(req1).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/map/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/map/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) expect(req2).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/map/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/map/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) diff --git a/test/unit/specs/hive/set.js b/test/unit/specs/hive/set.js index 2ccb47ba..9d528837 100644 --- a/test/unit/specs/hive/set.js +++ b/test/unit/specs/hive/set.js @@ -140,11 +140,11 @@ describe('Hive - Set Store', function() { it('success with multi keys', async () => { const request = prepareMockRequest(fakeResult) - const result = await Store.exists(['testKey1', 'testKey1']) + const result = await Store.exist(['testKey1', 'testKey1']) expect(request).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : ['testKey1', 'testKey1'] }) @@ -155,16 +155,16 @@ describe('Hive - Set Store', function() { it('fails when key(s) is invalid', async () => { const errorMsg = 'Keys must be provided and must be a list of strings.' - await expect(() => Store.exists(undefined)).to.throw(errorMsg) - await expect(() => Store.exists(null)).to.throw(errorMsg) - await expect(() => Store.exists(false)).to.throw(errorMsg) - await expect(() => Store.exists(true)).to.throw(errorMsg) - await expect(() => Store.exists('')).to.throw(errorMsg) - await expect(() => Store.exists('key')).to.throw(errorMsg) - await expect(() => Store.exists(0)).to.throw(errorMsg) - await expect(() => Store.exists(123)).to.throw(errorMsg) - await expect(() => Store.exists(() => undefined)).to.throw(errorMsg) - await expect(() => Store.exists({})).to.throw(errorMsg) + await expect(() => Store.exist(undefined)).to.throw(errorMsg) + await expect(() => Store.exist(null)).to.throw(errorMsg) + await expect(() => Store.exist(false)).to.throw(errorMsg) + await expect(() => Store.exist(true)).to.throw(errorMsg) + await expect(() => Store.exist('')).to.throw(errorMsg) + await expect(() => Store.exist('key')).to.throw(errorMsg) + await expect(() => Store.exist(0)).to.throw(errorMsg) + await expect(() => Store.exist(123)).to.throw(errorMsg) + await expect(() => Store.exist(() => undefined)).to.throw(errorMsg) + await expect(() => Store.exist({})).to.throw(errorMsg) }) }) @@ -242,19 +242,19 @@ describe('Hive - Set Store', function() { const req1 = prepareMockRequest(1) const req2 = prepareMockRequest(0) - const result1 = await store.exists(storeKey) - const result2 = await store.exists(storeKey) + const result1 = await store.exist(storeKey) + const result2 = await store.exist(storeKey) expect(req1).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) expect(req2).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) diff --git a/test/unit/specs/hive/sorted-set.js b/test/unit/specs/hive/sorted-set.js index 02299c49..fa7d3931 100644 --- a/test/unit/specs/hive/sorted-set.js +++ b/test/unit/specs/hive/sorted-set.js @@ -140,11 +140,11 @@ describe('Hive - Sorted Set Store', function() { it('success with multi keys', async () => { const request = prepareMockRequest(fakeResult) - const result = await Store.exists(['testKey1', 'testKey1']) + const result = await Store.exist(['testKey1', 'testKey1']) expect(request).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : ['testKey1', 'testKey1'] }) @@ -155,16 +155,16 @@ describe('Hive - Sorted Set Store', function() { it('fails when key(s) is invalid', async () => { const errorMsg = 'Keys must be provided and must be a list of strings.' - await expect(() => Store.exists(undefined)).to.throw(errorMsg) - await expect(() => Store.exists(null)).to.throw(errorMsg) - await expect(() => Store.exists(false)).to.throw(errorMsg) - await expect(() => Store.exists(true)).to.throw(errorMsg) - await expect(() => Store.exists('')).to.throw(errorMsg) - await expect(() => Store.exists('key')).to.throw(errorMsg) - await expect(() => Store.exists(0)).to.throw(errorMsg) - await expect(() => Store.exists(123)).to.throw(errorMsg) - await expect(() => Store.exists(() => undefined)).to.throw(errorMsg) - await expect(() => Store.exists({})).to.throw(errorMsg) + await expect(() => Store.exist(undefined)).to.throw(errorMsg) + await expect(() => Store.exist(null)).to.throw(errorMsg) + await expect(() => Store.exist(false)).to.throw(errorMsg) + await expect(() => Store.exist(true)).to.throw(errorMsg) + await expect(() => Store.exist('')).to.throw(errorMsg) + await expect(() => Store.exist('key')).to.throw(errorMsg) + await expect(() => Store.exist(0)).to.throw(errorMsg) + await expect(() => Store.exist(123)).to.throw(errorMsg) + await expect(() => Store.exist(() => undefined)).to.throw(errorMsg) + await expect(() => Store.exist({})).to.throw(errorMsg) }) }) @@ -242,19 +242,19 @@ describe('Hive - Sorted Set Store', function() { const req1 = prepareMockRequest(1) const req2 = prepareMockRequest(0) - const result1 = await store.exists(storeKey) - const result2 = await store.exists(storeKey) + const result1 = await store.exist(storeKey) + const result2 = await store.exist(storeKey) expect(req1).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] }) expect(req2).to.deep.include({ method : 'POST', - path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exists`, + path : `${APP_PATH}/hive/${hiveName}/sorted-set/action/exist`, headers: { 'Content-Type': 'application/json' }, body : [storeKey] })