chore: update Proccessed typing to ./core

This commit is contained in:
Jacob Nguyen
2023-05-05 10:12:16 -05:00
parent e644b184f2
commit 8e6061b4f2
14 changed files with 25 additions and 65 deletions

View File

@@ -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
*/

View File

@@ -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';

View File

@@ -1,4 +1,4 @@
import type { LogPayload } from '../../types/handler';
import type { LogPayload } from '../../types/core';
/**
* @since 2.0.0
*/

View File

@@ -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<T extends CommandType>(
strat: (ms: ModuleStore) => Processed<CommandModuleDefs[T]> | undefined,
): Processed<CommandModuleDefs[T]> | 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<T extends CommandType>(
strat: (ms: ModuleStore) => Processed<CommandModuleDefs[T]> | 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<CommandModule>|undefined) => Processed<CommandModule>|undefined
export function createModuleGetter(moduleManager: ModuleManager) {
return (accessStrat: (ms: ModuleStore) => Processed<CommandModule>|undefined) => {
return moduleManager.get(accessStrat)
}
}
export function createModuleInserter(moduleManager: ModuleManager) {
return (insertStrat: (ms: ModuleStore) => void) => {
return moduleManager.set(insertStrat)
}
}

View File

@@ -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';

View File

@@ -1,5 +1,4 @@
import SernEmitter from './sernEmitter';
export { SernEmitter };
export * from './sernEmitter';
export * from './contracts';
export * from './platform';
export * from './plugins';

View File

@@ -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'

View File

@@ -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 = <T>(e: EventEmitter, eventName: string) => {
return (fromEvent(e, eventName) as Observable<T>).pipe(share())
};

View File

@@ -15,7 +15,6 @@ export interface WebsocketStrategy {
export interface ServerlessStrategy {
type: DispatchType.Serverless;
endpoint: string;
}
export function makeWebsocketAdapter(

View File

@@ -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,

View File

@@ -1,2 +1,2 @@
export { EventArgs, InitArgs, CommandArgs } from './args';
export { type EventArgs, type InitArgs, type CommandArgs } from './args';
export * from './createPlugin';

View File

@@ -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;

View File

@@ -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,
}

View File

@@ -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 {