Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
BREAKING CHANGES: Renaming types and exports (#218)
Browse files Browse the repository at this point in the history
* Renamed export `RedisModules as Redis` to RedisModules
* Renaming type `RISSet` to `RedisIntervalSet`
  • Loading branch information
danitseitlin authored Sep 30, 2022
1 parent 192ca9c commit 5a4b6ae
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
#RediSearch
redisearch-selected: ${{(github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.tests, 'redisearch') || github.event.inputs.tests == 'All'))}}
redisearch-code-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, '/redisearch/')}}
redisearch-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, 'redisearch.ts')}}
redisearch-test-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, 'redisearch.ts')}}
#RedisGraph
redisgraph-selected: ${{(github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.tests, 'redisgraph') || github.event.inputs.tests == 'All'))}}
redisgraph-code-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, '/redisgraph/')}}
Expand All @@ -41,7 +41,7 @@ jobs:
#RedisBloom Topk
rebloom-topk-selected: ${{(github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.tests, 'rebloom-topk') || github.event.inputs.tests == 'All'))}}
rebloom-topk-code-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, '/bloom-topk/')}}
rebloom-topk-test-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, 'redisblook-topk.ts')}}
rebloom-topk-test-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, 'redisbloom-topk.ts')}}
#RedisBloom CMK
rebloom-cmk-selected: ${{(github.event_name == 'workflow_dispatch' && (contains(github.event.inputs.tests, 'rebloom-cmk') || github.event.inputs.tests == 'All'))}}
rebloom-cmk-code-changes: ${{github.event_name == 'pull_request' && contains(steps.files.outputs.all, '/bloom-cmk/')}}
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { RedisModules as Redis } from './modules/redis-modules';
export { RedisModules } from './modules/redis-modules';
/* ** Redis JSON ***/
export { ReJSON } from './modules/rejson/rejson';
export { ReJSONGetParameters } from './modules/rejson/rejson.types'
Expand Down Expand Up @@ -41,4 +41,4 @@ export {
} from './modules/redis-ai/redis-ai.types';
/* ** RedisIntervalSets ***/
export { RedisIntervalSets } from './modules/ris/ris';
export { RISSet } from './modules/ris/ris.types';
export { RedisIntervalSet } from './modules/ris/ris.types';
2 changes: 0 additions & 2 deletions modules/bloom/redisbloom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class RedisBloom extends Module {
private bloomCommander = new BloomCommander();
/**
* Initializing the module object
* @param name The name of the module
* @param clusterNodes The nodes of the cluster
* @param moduleOptions The additional module options
* @param moduleOptions.isHandleError If to throw error on error
Expand All @@ -18,7 +17,6 @@ export class RedisBloom extends Module {
constructor(clusterNodes: Redis.ClusterNode[], moduleOptions?: RedisModuleOptions, clusterOptions?: Redis.ClusterOptions)
/**
* Initializing the module object
* @param name The name of the module
* @param redisOptions The options of the redis database
* @param moduleOptions The additional module options
* @param moduleOptions.isHandleError If to throw error on error
Expand Down
5 changes: 1 addition & 4 deletions modules/module.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export class Module {

/**
* Running a Redis command
* @param command The redis command
* @param args The args of the redis command
* @param data The command data of a command to send. Consists of command and args.
*/
async sendCommand(data: CommandData): Promise<any> {
try {
Expand All @@ -95,7 +94,6 @@ export class Module {

/**
* Handling a error
* @param module The name of the module
* @param error The message of the error
*/
handleError(error: string): any {
Expand All @@ -107,7 +105,6 @@ export class Module {
/**
* Simpilizing the response of the Module command
* @param response The array response from the module
* @param isSearchQuery If we should try to build search result object from result array (default: false)
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
handleResponse(response: any): any {
Expand Down
2 changes: 1 addition & 1 deletion modules/redis-ai/redis-ai.commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class RedisAICommander {
* @param key The tensor's key name
* @param type The tensor's data type can be one of: FLOAT , DOUBLE , INT8 , INT16 , INT32 , INT64 , UINT8 or UINT16
* @param data The tensor's data (binary/numberic)
* @param shape One or more dimensions, or the number of elements per axis, for the tensor
* @param shapes One or more dimensions, or the number of elements per axis, for the tensor
*/
tensorset(key: string, type: TensorType, shapes: number[], data?: number[] | Buffer[]): CommandData {
const args: (number | string | Buffer)[] = [key, type];
Expand Down
4 changes: 2 additions & 2 deletions modules/ris/ris.commander.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandData } from "../module.base";
import { RISSet } from "./ris.types";
import { RedisIntervalSet } from "./ris.types";

export class RedisIntervalSetsCommander {

Expand All @@ -8,7 +8,7 @@ export class RedisIntervalSetsCommander {
* @param key The name of the key
* @param sets A list of sets to create. At least 1 set is required.
*/
add(key: string, sets: RISSet[]): CommandData {
add(key: string, sets: RedisIntervalSet[]): CommandData {
let args: (number | string)[] = [key];
for(const set of sets){
args = args.concat([set.name, set.minimum, set.maximum])
Expand Down
6 changes: 3 additions & 3 deletions modules/ris/ris.helpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { RISSet } from "./ris.types";
import { RedisIntervalSet } from "./ris.types";

export class RedisIntervalSetsHelpers {
/**
* Parsing the iset.get command response
* @param sets The list of sets
*/
parseGet(sets: string[][]): RISSet[] {
const parsedSets: RISSet[] = [];
parseGet(sets: string[][]): RedisIntervalSet[] {
const parsedSets: RedisIntervalSet[] = [];
for(const set of sets) {
if(set.length > 2){
parsedSets.push({name: set[0], minimum: parseInt(set[1]), maximum: parseInt(set[2])})
Expand Down
6 changes: 3 additions & 3 deletions modules/ris/ris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Redis from 'ioredis';
import { Module, RedisModuleOptions } from '../module.base';
import { RedisIntervalSetsCommander } from './ris.commander';
import { RedisIntervalSetsHelpers } from './ris.helpers';
import { RISSet } from './ris.types';
import { RedisIntervalSet } from './ris.types';

export class RedisIntervalSets extends Module {
private risHelpers = new RedisIntervalSetsHelpers();
Expand Down Expand Up @@ -35,7 +35,7 @@ export class RedisIntervalSets extends Module {
* @param key The name of the key
* @param sets A list of sets to create. At least 1 set is required.
*/
async add(key: string, sets: RISSet[]): Promise<'OK'> {
async add(key: string, sets: RedisIntervalSet[]): Promise<'OK'> {
const command = this.risCommander.add(key, sets);
return await this.sendCommand(command);
}
Expand All @@ -45,7 +45,7 @@ export class RedisIntervalSets extends Module {
* @param key The name of the key
* @param setName Optional. The name of specific set. If not passed all interval sets under key will be retrieved.
*/
async get(key: string, setName?: string): Promise<RISSet[]> {
async get(key: string, setName?: string): Promise<RedisIntervalSet[]> {
const command = this.risCommander.get(key, setName);
const response = await this.sendCommand(command);
return this.risHelpers.parseGet(response);
Expand Down
2 changes: 1 addition & 1 deletion modules/ris/ris.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param minimum The minimum score of the interval set
* @param maximum The maximum score of the interval set
*/
export type RISSet = {
export type RedisIntervalSet = {
name?: string,
minimum: number,
maximum: number
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
"test": "mocha -r ts-node/register",
"run-redis": "docker run -p 6379:6379 -d --rm redis && docker ps -a",
"run-redis-with-rejson-module": "docker run -p 6379:6379 -d --rm redislabs/rejson:edge && docker ps -a",
"run-redis-with-rts-module":"docker run -p 6379:6379 -d --rm redislabs/redistimeseries:edge && docker ps -a",
"run-redis-with-rts-module": "docker run -p 6379:6379 -d --rm redislabs/redistimeseries:edge && docker ps -a",
"run-redis-with-redisearch-module": "docker run -p 6379:6379 -d --rm redislabs/redisearch:edge && docker ps -a",
"run-redis-with-redisgraph-module": "docker run -p 6379:6379 -d --rm redislabs/redisgraph:edge && docker ps -a",
"run-redis-with-redisgears-module": "docker run -p 6379:6379 -d --rm redislabs/redisgears:latest && docker ps -a",
"run-redis-with-bloom-module": "docker run -p 6379:6379 -d --rm redislabs/rebloom:latest && docker ps -a",
"run-redis-with-redisai-module": "docker run -p 6379:6379 -d --rm redislabs/redisai:edge-cpu-bionic && docker ps -a",
"run-redis-with-ris-module": "docker run -p 6379:6379 -d --rm danitseitlin/redis-interval-sets && docker ps -a",

"rejson-module-tests": "npm run test tests/rejson.ts -- -- --host=127.0.0.1 --port=6379",
"rts-module-tests": "npm run test tests/rts.ts -- -- --host=127.0.0.1 --port=6379",
"redisearch-module-tests": "npm run test tests/redisearch.ts -- -- --host=127.0.0.1 --port=6379",
Expand Down
2 changes: 1 addition & 1 deletion tests/redis-ai.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import * as fs from 'fs';
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
import { AIModel, AIScript, AIScriptInfo, AITensorInfo } from '../modules/redis-ai/redis-ai.types';
let redis: RedisModules;
describe('AI testing', async function() {
Expand Down
2 changes: 1 addition & 1 deletion tests/redisbloom-cmk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const key1 = 'key1cmk'
const key2 = 'key1cmk2';
Expand Down
2 changes: 1 addition & 1 deletion tests/redisbloom-cuckoo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
const key1 = 'key1cuckoo'
const key2 = '1'
const key3 = 'cuckoo'
Expand Down
2 changes: 1 addition & 1 deletion tests/redisbloom-tdigest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const key1 = 'mykey1'
const key2 = 'mykey2';
Expand Down
2 changes: 1 addition & 1 deletion tests/redisbloom-topk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const key1 = 'key1topk';

Expand Down
2 changes: 1 addition & 1 deletion tests/redisbloom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const key1 = 'key1bloom';
const key2 = '1';
Expand Down
2 changes: 1 addition & 1 deletion tests/redisearch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser'
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules'
import { RedisModules } from '../'
import { FTParsedSearchResponse, FTSearchArrayResponse } from '../modules/redisearch/redisearch.types'
import * as fs from 'fs';
let redis: RedisModules
Expand Down
2 changes: 1 addition & 1 deletion tests/redisgears.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
let executionId1: string;
let executionId2: string;
Expand Down
2 changes: 1 addition & 1 deletion tests/redisgraph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
import { GraphConfigInfo } from '../modules/redisgraph/redisgraph.types';
let redis: RedisModules;
const graphName = 'Test'
Expand Down
2 changes: 1 addition & 1 deletion tests/rejson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const key1 = 'key1';
const key2 = 'key2';
Expand Down
2 changes: 1 addition & 1 deletion tests/ris.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;

describe('RedisIntervalSets Module testing', async function() {
Expand Down
2 changes: 1 addition & 1 deletion tests/rts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cliArguments } from 'cli-argument-parser';
import { expect } from 'chai'
import { RedisModules } from '../modules/redis-modules';
import { RedisModules } from '../';
let redis: RedisModules;
const date = new Date(2019, 11, 24, 19).getTime();
const key1 = 'key:2:32';
Expand Down

0 comments on commit 5a4b6ae

Please # to comment.