diff --git a/src/core/contracts/errorHandling.ts b/src/core/contracts/errorHandling.ts index 6fc053a..3237151 100644 --- a/src/core/contracts/errorHandling.ts +++ b/src/core/contracts/errorHandling.ts @@ -1,6 +1,6 @@ import type { Observable } from 'rxjs'; import type { Logging } from './logging'; -import util from 'util'; +import util from 'node:util'; /** * @since 2.0.0 */ diff --git a/src/core/contracts/index.ts b/src/core/contracts/index.ts index ad878b1..725919d 100644 --- a/src/core/contracts/index.ts +++ b/src/core/contracts/index.ts @@ -1,3 +1,3 @@ -export { ErrorHandling, DefaultErrorHandling } from './errorHandling'; -export { Logging, DefaultLogging } from './logging'; -export { ModuleManager, DefaultModuleManager } from './moduleManager'; +export { type ErrorHandling, DefaultErrorHandling } from './errorHandling'; +export { type Logging, DefaultLogging } from './logging'; +export { type ModuleManager, DefaultModuleManager } from './moduleManager'; diff --git a/src/core/contracts/logging.ts b/src/core/contracts/logging.ts index f431f43..43ca0b2 100644 --- a/src/core/contracts/logging.ts +++ b/src/core/contracts/logging.ts @@ -1,4 +1,4 @@ -import type { LogPayload } from '../../types/handler'; +import type { LogPayload } from '../../types/core'; /** * @since 2.0.0 */ diff --git a/src/core/contracts/moduleManager.ts b/src/core/contracts/moduleManager.ts index 4db9ce1..4e7f0a7 100644 --- a/src/core/contracts/moduleManager.ts +++ b/src/core/contracts/moduleManager.ts @@ -1,40 +1,22 @@ -import type { CommandModule, CommandModuleDefs } from '../../types/module'; -import type { CommandType, ModuleStore } from '../structures'; -import type { Processed } from '../../types/handler'; +import type { ModuleStore } from '../structures'; /** * @since 2.0.0 */ export interface ModuleManager { - get( - strat: (ms: ModuleStore) => Processed | undefined, - ): Processed | undefined; - set(strat: (ms: ModuleStore) => void): void; + get(id: string): string | undefined; + set(id: string, path: string): void; } /** * @since 2.0.0 */ export class DefaultModuleManager implements ModuleManager { constructor(private moduleStore: ModuleStore) {} - get( - strat: (ms: ModuleStore) => Processed | undefined, - ) { - return strat(this.moduleStore); + get(id: string) { + return this.moduleStore.Commands.get(id); + } + set(id: string, path: string): void { + this.moduleStore.Commands.set(id, path) } - set(strat: (ms: ModuleStore) => void): void { - strat(this.moduleStore); - } } -export type ModuleGetter = (accessStrat: (ms: ModuleStore) => Processed|undefined) => Processed|undefined -export function createModuleGetter(moduleManager: ModuleManager) { - return (accessStrat: (ms: ModuleStore) => Processed|undefined) => { - return moduleManager.get(accessStrat) - } -} - -export function createModuleInserter(moduleManager: ModuleManager) { - return (insertStrat: (ms: ModuleStore) => void) => { - return moduleManager.set(insertStrat) - } -} diff --git a/src/core/dependencies.ts b/src/core/dependencies.ts index d875d28..3511aaf 100644 --- a/src/core/dependencies.ts +++ b/src/core/dependencies.ts @@ -1,6 +1,6 @@ import type { Container } from 'iti'; -import type { AnyDependencies, DependencyConfiguration, MapDeps, ServerlessDependencies, WebsocketDependencies } from '../types/handler'; -import SernEmitter from './sernEmitter'; +import type { AnyDependencies, DependencyConfiguration, MapDeps, ServerlessDependencies, WebsocketDependencies } from '../types/core'; +import { SernEmitter } from './sernEmitter'; import { DefaultErrorHandling, DefaultLogging, DefaultModuleManager } from './contracts'; import { Result } from 'ts-results-es'; import { BehaviorSubject } from 'rxjs'; diff --git a/src/core/index.ts b/src/core/index.ts index 914217d..5f5a13e 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,5 +1,4 @@ -import SernEmitter from './sernEmitter'; -export { SernEmitter }; +export * from './sernEmitter'; export * from './contracts'; export * from './platform'; export * from './plugins'; diff --git a/src/core/module-loading.ts b/src/core/module-loading.ts index 89b9a30..1471073 100644 --- a/src/core/module-loading.ts +++ b/src/core/module-loading.ts @@ -1,10 +1,9 @@ -import { readdirSync, statSync } from 'fs'; import { readdir, stat } from 'fs/promises'; import { join, basename, resolve } from 'path'; import { type Observable, from, mergeMap } from 'rxjs'; import { SernError } from './structures/errors'; import { type Result, Err, Ok } from 'ts-results-es'; -import { Processed } from '../types/handler'; +import { Processed } from '../types/core'; import { Module } from '../types/module'; import * as assert from 'node:assert' import * as util from 'node:util' diff --git a/src/core/operators.ts b/src/core/operators.ts index 1e0c086..59da2f9 100644 --- a/src/core/operators.ts +++ b/src/core/operators.ts @@ -3,14 +3,13 @@ * Each function should be modular and testable, not bound to discord / sern * and independent of each other */ - import { concatMap, defaultIfEmpty, EMPTY, every, fromEvent, map, Observable, of, OperatorFunction, pipe, share, switchMap } from 'rxjs'; import type { AnyModule } from '../types/module'; import type { PluginResult, VoidResult } from '../types/plugin'; import { Result } from 'ts-results-es'; -import { Awaitable, ImportPayload, Processed } from '../types/handler'; +import { Awaitable } from '../types/handler'; +import { ImportPayload, Processed } from '../types/core'; import { EventEmitter } from 'node:events'; - /** * if {src} is true, mapTo V, else ignore * @param item @@ -88,3 +87,4 @@ export const sharedObservable = (e: EventEmitter, eventName: string) => { return (fromEvent(e, eventName) as Observable).pipe(share()) }; + diff --git a/src/core/platform.ts b/src/core/platform.ts index 1cedb65..150618b 100644 --- a/src/core/platform.ts +++ b/src/core/platform.ts @@ -15,7 +15,6 @@ export interface WebsocketStrategy { export interface ServerlessStrategy { type: DispatchType.Serverless; - endpoint: string; } export function makeWebsocketAdapter( diff --git a/src/core/plugins/args.ts b/src/core/plugins/args.ts index 46b9c67..21f9f8a 100644 --- a/src/core/plugins/args.ts +++ b/src/core/plugins/args.ts @@ -1,7 +1,7 @@ import type { CommandType } from '../structures/enums'; import type { PluginType } from '../structures/enums'; import type { Module } from '../../types/module'; -import type { Processed } from '../../types/handler'; +import type { Processed } from '../../types/core'; import { EventType } from '../structures/enums'; import { CommandArgsMatrix, EventArgsMatrix } from '../../types/module'; @@ -14,6 +14,7 @@ export type CommandArgs< I extends CommandType = CommandType, J extends PluginType = PluginType, > = CommandArgsMatrix[I][J]; + export type EventArgs< I extends EventType = EventType, J extends PluginType = PluginType, diff --git a/src/core/plugins/index.ts b/src/core/plugins/index.ts index 3f8a662..37c4f0a 100644 --- a/src/core/plugins/index.ts +++ b/src/core/plugins/index.ts @@ -1,2 +1,2 @@ -export { EventArgs, InitArgs, CommandArgs } from './args'; +export { type EventArgs, type InitArgs, type CommandArgs } from './args'; export * from './createPlugin'; diff --git a/src/core/sernEmitter.ts b/src/core/sernEmitter.ts index 42ea093..1b13c10 100644 --- a/src/core/sernEmitter.ts +++ b/src/core/sernEmitter.ts @@ -6,7 +6,7 @@ import type { Module } from '../types/module'; /** * @since 1.0.0 */ -class SernEmitter extends EventEmitter { +export class SernEmitter extends EventEmitter { /** * Listening to sern events with on. This event stays on until a crash or a normal exit * @param eventName @@ -85,4 +85,3 @@ class SernEmitter extends EventEmitter { } } -export default SernEmitter; diff --git a/src/core/structures/enums.ts b/src/core/structures/enums.ts index 9cc3fb1..3e8eabf 100644 --- a/src/core/structures/enums.ts +++ b/src/core/structures/enums.ts @@ -101,22 +101,3 @@ export enum PayloadType { */ Warning = 'warning', } - -export enum ApplicationCommandType { - ChatInput = 1, - User = 2, - Message = 3 -} - - -export const enum ComponentType { - ActionRow = 1, - Button = 2, - StringSelect = 3, - TextInput = 4, - UserSelect = 5, - RoleSelect = 6, - MentionableSelect = 7, - ChannelSelect = 8, -} - diff --git a/src/core/structures/wrapper.ts b/src/core/structures/wrapper.ts index ade68e6..3295a6f 100644 --- a/src/core/structures/wrapper.ts +++ b/src/core/structures/wrapper.ts @@ -1,4 +1,4 @@ -import type { ServerlessDependencies, WebsocketDependencies } from '../../types/handler'; +import type { ServerlessDependencies, WebsocketDependencies } from '../../types/core'; import { DispatchType, ServerlessStrategy, WebsocketStrategy } from '../platform'; export interface DefaultWrapper {