diff --git a/package-lock.json b/package-lock.json index 3c0d6c7..e1ce98f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -737,31 +737,31 @@ } }, "node_modules/@gomomento/sdk": { - "version": "1.80.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.80.0.tgz", - "integrity": "sha512-JQuRK/rp4Tt4Gr5hWnSPbyNWBf6ZJWcQokwRXKMLu0ld0U1C5JdvRtSu7uuWWXZhbfTMYhJIv/RsqQhF3DmMuA==", + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@gomomento/sdk/-/sdk-1.89.0.tgz", + "integrity": "sha512-tSbSPUgjs3mYZjTQ4yrb7/5PJRFLFrO72jIes2GLjNXkAFDCDBiTv7CRMlfqsBVNi2TQrK1+Ma+mjd9LgeHKiQ==", "dependencies": { "@gomomento/generated-types": "0.108.2", - "@gomomento/sdk-core": "1.80.0", + "@gomomento/sdk-core": "1.89.0", "@grpc/grpc-js": "1.10.5", "@types/google-protobuf": "3.15.10", "google-protobuf": "3.21.2", "jwt-decode": "3.1.2" }, "engines": { - "node": ">= 14" + "node": ">= 16" } }, "node_modules/@gomomento/sdk-core": { - "version": "1.80.0", - "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.80.0.tgz", - "integrity": "sha512-rXvuTjBVgZYUer8c0Gr2aRNxA7/U0+OknqXVCcy0mYzI08gy+McBCwJ3XmOOez9NQ6BsmIc1/fFjySlHIZi/Cw==", + "version": "1.89.0", + "resolved": "https://registry.npmjs.org/@gomomento/sdk-core/-/sdk-core-1.89.0.tgz", + "integrity": "sha512-1CSPHqb/wjzUkm05Dnxp1QIvIBVBmpNyDhGDMdoLPcCRmR9RUkNPRqneP1r4Kkcvp61wMxyC6UNLD+XZq/e1uQ==", "dependencies": { "buffer": "6.0.3", "jwt-decode": "3.1.2" }, "engines": { - "node": ">= 14" + "node": ">= 16" } }, "node_modules/@grpc/grpc-js": { @@ -2096,12 +2096,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -3368,9 +3368,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" diff --git a/src/momento-redis-adapter.ts b/src/momento-redis-adapter.ts index 4c12c16..53b0fb6 100644 --- a/src/momento-redis-adapter.ts +++ b/src/momento-redis-adapter.ts @@ -244,10 +244,8 @@ export class MomentoRedisAdapter } } else if (rsp instanceof CacheGet.Miss) { return null; - } else if (rsp instanceof CacheGet.Error) { - this.emitError('get', rsp.message(), rsp.errorCode()); } else { - this.emitError('get', `unexpected-response ${rsp.toString()}`); + this.emitError('get', rsp.message(), rsp.errorCode()); } return null; } @@ -255,15 +253,15 @@ export class MomentoRedisAdapter // eslint-disable-next-line require-await, @typescript-eslint/require-await async quit(): Promise<'OK'> { this.momentoClient.close(); - this.emit('end') + this.emit('end'); return 'OK'; } disconnect(reconnect?: boolean): void { // TODO handle reconnect event. re-make momento client? this.momentoClient.close(); - this.emit('end') - return + this.emit('end'); + return; } emitError(op: string, msg: string, code?: MomentoErrorCode) { @@ -396,13 +394,8 @@ export class MomentoRedisAdapter return 'OK'; } else if (rsp instanceof CacheSetIfAbsent.NotStored) { return null; - } else if (rsp instanceof CacheSetIfAbsent.Error) { - this.emitError('set-not-exists', rsp.message(), rsp.errorCode()); } else { - this.emitError( - 'set-not-exists', - `unexpected-response ${rsp.toString()}` - ); + this.emitError('set-not-exists', rsp.message(), rsp.errorCode()); } } else { let rsp: CacheSet.Response; @@ -425,10 +418,8 @@ export class MomentoRedisAdapter if (rsp instanceof CacheSet.Success) { return 'OK'; - } else if (rsp instanceof CacheSet.Error) { - this.emitError('set', rsp.message(), rsp.errorCode()); } else { - this.emitError('set', `unexpected-response ${rsp.toString()}`); + this.emitError('set', rsp.message(), rsp.errorCode()); } } @@ -455,10 +446,8 @@ export class MomentoRedisAdapter const rsp = await this.momentoClient.increment(this.cacheName, key); if (rsp instanceof CacheIncrement.Success) { return rsp.value(); - } else if (rsp instanceof CacheIncrement.Error) { - this.emitError('incr', rsp.message(), rsp.errorCode()); } else { - this.emitError('incr', `unexpected-response ${rsp.toString()}`); + this.emitError('incr', rsp.message(), rsp.errorCode()); } return null; } @@ -530,12 +519,11 @@ export class MomentoRedisAdapter if (rsp instanceof CacheDictionarySetFields.Success) { return fieldsToSet.size; - } else if (rsp instanceof CacheDictionarySetFields.Error) { - this.emitError('hset', rsp.message(), rsp.errorCode()); - return 0; } else { - this.emitError('hset', `unexpected-response ${rsp.toString()}`); - return 0; + { + this.emitError('hset', rsp.message(), rsp.errorCode()); + return 0; + } } } @@ -582,11 +570,8 @@ export class MomentoRedisAdapter } } else if (rsp instanceof CacheDictionaryGetFields.Miss) { return []; - } else if (rsp instanceof CacheDictionaryGetFields.Error) { - this.emitError('hmget', rsp.message(), rsp.errorCode()); - return []; } else { - this.emitError('hmget', `unexpected-response ${rsp.toString()}`); + this.emitError('hmget', rsp.message(), rsp.errorCode()); return []; } } @@ -605,11 +590,8 @@ export class MomentoRedisAdapter } } else if (rsp instanceof CacheDictionaryGetField.Miss) { return null; - } else if (rsp instanceof CacheDictionaryGetField.Error) { - this.emitError('hget', rsp.message(), rsp.errorCode()); - return null; } else { - this.emitError('hget', `unexpected-response ${rsp.toString()}`); + this.emitError('hget', rsp.message(), rsp.errorCode()); return null; } } @@ -631,11 +613,8 @@ export class MomentoRedisAdapter return record; } else if (rsp instanceof CacheDictionaryFetch.Miss) { return {}; - } else if (rsp instanceof CacheDictionaryFetch.Error) { - this.emitError('hgetall', rsp.message(), rsp.errorCode()); - return {}; } else { - this.emitError('hgetall', `unexpected-response ${rsp.toString()}`); + this.emitError('hgetall', rsp.message(), rsp.errorCode()); return {}; } } @@ -654,11 +633,8 @@ export class MomentoRedisAdapter ); if (rsp instanceof CacheDictionaryRemoveFields.Success) { return fields.length; - } else if (rsp instanceof CacheDictionaryRemoveFields.Error) { - this.emitError('hdel', rsp.message(), rsp.errorCode()); - return 0; } else { - this.emitError('hdel', `unexpected-response ${rsp.toString()}`); + this.emitError('hdel', rsp.message(), rsp.errorCode()); return 0; } } @@ -709,11 +685,8 @@ export class MomentoRedisAdapter const rsp = await this.momentoClient.setBatch(this.cacheName, items); if (rsp instanceof CacheSetBatch.Success) { return 'OK'; - } else if (rsp instanceof CacheSetBatch.Error) { - this.emitError('mset', rsp.message(), rsp.errorCode()); - return 'OK'; } else { - this.emitError('mset', `unexpected-response ${rsp.toString()}`); + this.emitError('mset', rsp.message(), rsp.errorCode()); return 'OK'; } } @@ -753,10 +726,8 @@ export class MomentoRedisAdapter value !== null ? new TextDecoder().decode(value) : null ); } - } else if (resp instanceof CacheGetBatch.Error) { - this.emitError('mget', resp.message(), resp.errorCode()); } else { - this.emitError('mget', `unexpected-response ${resp.toString()}`); + this.emitError('mget', resp.message(), resp.errorCode()); } return []; } @@ -767,10 +738,8 @@ export class MomentoRedisAdapter return rsp.remainingTtlMillis() / 1000; } else if (rsp instanceof CacheItemGetTtl.Miss) { return null; - } else if (rsp instanceof CacheItemGetTtl.Error) { - this.emitError('ttl', rsp.message(), rsp.errorCode()); } else { - this.emitError('ttl', `unexpected-response ${rsp.toString()}`); + this.emitError('ttl', rsp.message(), rsp.errorCode()); } return null; } @@ -781,10 +750,8 @@ export class MomentoRedisAdapter return rsp.remainingTtlMillis(); } else if (rsp instanceof CacheItemGetTtl.Miss) { return null; - } else if (rsp instanceof CacheItemGetTtl.Error) { - this.emitError('ttl', rsp.message(), rsp.errorCode()); } else { - this.emitError('ttl', `unexpected-response ${rsp.toString()}`); + this.emitError('ttl', rsp.message(), rsp.errorCode()); } return null; } @@ -829,10 +796,8 @@ export class MomentoRedisAdapter return 1; } else if (rsp instanceof CacheUpdateTtl.Miss) { return 0; - } else if (rsp instanceof CacheUpdateTtl.Error) { - this.emitError('pexpire', rsp.message(), rsp.errorCode()); } else { - this.emitError('pexpire', `unexpected-response ${rsp.toString()}`); + this.emitError('pexpire', rsp.message(), rsp.errorCode()); } } @@ -856,11 +821,8 @@ export class MomentoRedisAdapter const rsp = await this.momentoClient.flushCache(this.cacheName); if (rsp instanceof CacheFlush.Success) { return 'OK'; - } else if (rsp instanceof CacheFlush.Error) { - this.emitError('flushdb', rsp.message(), rsp.errorCode()); - return 'OK'; } else { - this.emitError('flushdb', `unexpected-response ${rsp.toString()}`); + this.emitError('flushdb', rsp.message(), rsp.errorCode()); return 'OK'; } }