From 3b786c0871a01228715ce5cdc9751578621cbc93 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 18 Oct 2023 11:36:48 +0530 Subject: [PATCH] refactor: cleanup types --- factories/redis_manager.ts | 2 +- index.ts | 10 +++++----- package.json | 4 ++-- providers/redis_provider.ts | 2 +- services/main.ts | 2 +- src/connections/abstract_connection.ts | 2 +- src/connections/redis_cluster_connection.ts | 2 +- src/connections/redis_connection.ts | 2 +- src/define_config.ts | 2 +- src/redis_manager.ts | 2 +- src/{types/main.ts => types.ts} | 8 ++++---- src/types/extended.ts | 16 ---------------- 12 files changed, 19 insertions(+), 35 deletions(-) rename src/{types/main.ts => types.ts} (92%) delete mode 100644 src/types/extended.ts diff --git a/factories/redis_manager.ts b/factories/redis_manager.ts index b5c2511..a7cfe51 100644 --- a/factories/redis_manager.ts +++ b/factories/redis_manager.ts @@ -9,7 +9,7 @@ import RedisManager from '../src/redis_manager.js' import { LoggerFactory } from '@adonisjs/core/factories/logger' -import type { RedisClusterConnectionConfig, RedisConnectionConfig } from '../src/types/main.js' +import type { RedisClusterConnectionConfig, RedisConnectionConfig } from '../src/types.js' /** * Redis manager factory is used to create an instance of the redis diff --git a/index.ts b/index.ts index c5e6356..680b6f3 100644 --- a/index.ts +++ b/index.ts @@ -7,10 +7,10 @@ * file that was distributed with this source code. */ -import './src/types/extended.js' - -export { defineConfig } from './src/define_config.js' -export { stubsRoot } from './stubs/index.js' -export { configure } from './configure.js' export * as errors from './src/errors.js' +export { configure } from './configure.js' +export { stubsRoot } from './stubs/index.js' +export { defineConfig } from './src/define_config.js' export { default as RedisManager } from './src/redis_manager.js' +export { RedisConnection } from './src/connections/redis_connection.js' +export { RedisClusterConnection } from './src/connections/redis_cluster_connection.js' diff --git a/package.json b/package.json index e0917d1..9a88429 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "./services/main": "./build/services/main.js", "./redis_provider": "./build/providers/redis_provider.js", "./factories": "./build/factories/main.js", - "./types": "./build/src/types/main.js" + "./types": "./build/src/types.js" }, "scripts": { "pretest": "npm run lint", @@ -117,7 +117,7 @@ "./services/main.ts", "./providers/redis_provider.ts", "./factories/main.ts", - "./src/types/main.ts" + "./src/types.ts" ], "outDir": "./build", "clean": true, diff --git a/providers/redis_provider.ts b/providers/redis_provider.ts index 4c978a5..b8cca18 100644 --- a/providers/redis_provider.ts +++ b/providers/redis_provider.ts @@ -8,7 +8,7 @@ */ import type { ApplicationService } from '@adonisjs/core/types' -import type { RedisService } from '../src/types/main.js' +import type { RedisService } from '../src/types.js' declare module '@adonisjs/core/types' { export interface ContainerBindings { diff --git a/services/main.ts b/services/main.ts index 47af1a1..91bf657 100644 --- a/services/main.ts +++ b/services/main.ts @@ -8,7 +8,7 @@ */ import app from '@adonisjs/core/services/app' -import { RedisService } from '../src/types/main.js' +import { RedisService } from '../src/types.js' let redis: RedisService diff --git a/src/connections/abstract_connection.ts b/src/connections/abstract_connection.ts index f3ab253..5681d65 100644 --- a/src/connections/abstract_connection.ts +++ b/src/connections/abstract_connection.ts @@ -18,7 +18,7 @@ import type { ConnectionEvents, PubSubChannelHandler, PubSubPatternHandler, -} from '../types/main.js' +} from '../types.js' /** * Abstract factory implements the shared functionality required by Redis cluster diff --git a/src/connections/redis_cluster_connection.ts b/src/connections/redis_cluster_connection.ts index 1673acd..ad3d00c 100644 --- a/src/connections/redis_cluster_connection.ts +++ b/src/connections/redis_cluster_connection.ts @@ -16,7 +16,7 @@ import type { ConnectionEvents, IORedisBaseCommands, RedisClusterConnectionConfig, -} from '../types/main.js' +} from '../types.js' /** * Redis cluster connection exposes the API to run Redis commands using `ioredis` as the diff --git a/src/connections/redis_connection.ts b/src/connections/redis_connection.ts index e64922f..1abe491 100644 --- a/src/connections/redis_connection.ts +++ b/src/connections/redis_connection.ts @@ -16,7 +16,7 @@ import type { ConnectionEvents, RedisConnectionConfig, IORedisConnectionCommands, -} from '../types/main.js' +} from '../types.js' /** * Redis connection exposes the API to run Redis commands using `ioredis` as the diff --git a/src/define_config.ts b/src/define_config.ts index 9588778..7cc56da 100644 --- a/src/define_config.ts +++ b/src/define_config.ts @@ -8,7 +8,7 @@ */ import { RuntimeException } from '@poppinss/utils' -import type { RedisConnectionsList } from './types/main.js' +import type { RedisConnectionsList } from './types.js' /** * Define config for redis diff --git a/src/redis_manager.ts b/src/redis_manager.ts index a6bcf5c..003159d 100644 --- a/src/redis_manager.ts +++ b/src/redis_manager.ts @@ -22,7 +22,7 @@ import type { PubSubChannelHandler, PubSubPatternHandler, RedisConnectionsList, -} from './types/main.js' +} from './types.js' /** * Redis Manager exposes the API to manage multiple redis connections diff --git a/src/types/main.ts b/src/types.ts similarity index 92% rename from src/types/main.ts rename to src/types.ts index 813b2ad..e283ba3 100644 --- a/src/types/main.ts +++ b/src/types.ts @@ -9,10 +9,10 @@ import type { Redis, Cluster, RedisOptions, ClusterOptions } from 'ioredis' -import type RedisManager from '../redis_manager.js' -import type { baseMethods, redisMethods } from '../connections/io_methods.js' -import type RedisConnection from '../connections/redis_connection.js' -import type RedisClusterConnection from '../connections/redis_cluster_connection.js' +import type RedisManager from './redis_manager.js' +import type RedisConnection from './connections/redis_connection.js' +import type { baseMethods, redisMethods } from './connections/io_methods.js' +import type RedisClusterConnection from './connections/redis_cluster_connection.js' /** * PubSub subscriber diff --git a/src/types/extended.ts b/src/types/extended.ts deleted file mode 100644 index e4aca4f..0000000 --- a/src/types/extended.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * @adonisjs/redis - * - * (c) AdonisJS - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import type { RedisService } from './main.js' - -declare module '@adonisjs/core/types' { - export interface ContainerBindings { - redis: RedisService - } -}