Skip to content

Commit

Permalink
chore: remove options type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 21, 2019
1 parent 7ad2e9f commit 571032b
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 85 deletions.
3 changes: 1 addition & 2 deletions src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export interface BotData extends BaseServiceData {
}

export type BotDefinition = ServiceDefinition<BotData>;
export type BotOptions = BaseServiceOptions<BotData>;

@Inject(INJECT_LOGGER, INJECT_METRICS, INJECT_SERVICES)
export class Bot extends BaseService<BotData> implements Service {
Expand All @@ -67,7 +66,7 @@ export class Bot extends BaseService<BotData> implements Service {
protected incoming: Subject<Message>;
protected outgoing: Subject<Message>;

constructor(options: BotOptions) {
constructor(options: BaseServiceOptions<BotData>) {
super(options, 'isolex#/definitions/service-bot');

this.logger.info(options, 'creating bot');
Expand Down
4 changes: 1 addition & 3 deletions src/controller/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export interface AccountControllerData extends ControllerData {
};
}

export type AccountControllerOptions = BaseControllerOptions<AccountControllerData>;

@Inject(INJECT_CLOCK, INJECT_STORAGE)
export class AccountController extends BaseController<AccountControllerData> implements Controller {
protected clock: Clock;
Expand All @@ -50,7 +48,7 @@ export class AccountController extends BaseController<AccountControllerData> imp
protected tokenRepository: Repository<Token>;
protected userRepository: UserRepository;

constructor(options: AccountControllerOptions) {
constructor(options: BaseControllerOptions<AccountControllerData>) {
super(options, 'isolex#/definitions/service-controller-account', [NOUN_GRANT, NOUN_ACCOUNT, NOUN_SESSION]);

this.clock = mustExist(options[INJECT_CLOCK]);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/CompletionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export interface CompletionControllerData extends ControllerData {
defaultTarget: ServiceMetadata;
}

export type CompletionControllerOptions = BaseControllerOptions<CompletionControllerData>;

@Inject(INJECT_STORAGE)
export class CompletionController extends BaseController<CompletionControllerData> implements Controller {
protected readonly fragmentRepository: Repository<Fragment>;
protected target?: Listener;

constructor(options: CompletionControllerOptions) {
constructor(options: BaseControllerOptions<CompletionControllerData>) {
super(options, 'isolex#/definitions/service-controller-completion', [NOUN_FRAGMENT]);

this.fragmentRepository = mustExist(options[INJECT_STORAGE]).getRepository(Fragment);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/CountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ export interface CountControllerData extends ControllerData {
};
}

export type CountControllerOptions = BaseControllerOptions<CountControllerData>;

@Inject(INJECT_STORAGE)
export class CountController extends BaseController<CountControllerData> implements Controller {
protected readonly counterRepository: Repository<Counter>;

constructor(options: CountControllerOptions) {
constructor(options: BaseControllerOptions<CountControllerData>) {
super(options, 'isolex#/definitions/service-controller-count', [NOUN_COUNTER]);

this.counterRepository = mustExist(options[INJECT_STORAGE]).getRepository(Counter);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/DiceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ export const NOUN_ROLL = 'roll';

export type DiceControllerData = ControllerData;

export type DiceControllerOptions = BaseControllerOptions<DiceControllerData>;

@Inject(INJECT_MATH)
export class DiceController extends BaseController<DiceControllerData> implements Controller {
protected math: MathJsStatic;

constructor(options: DiceControllerOptions) {
constructor(options: BaseControllerOptions<DiceControllerData>) {
super(options, 'isolex#/definitions/service-controller-dice', [NOUN_ROLL]);

this.math = mustExist(options[INJECT_MATH]).create({});
Expand Down
3 changes: 1 addition & 2 deletions src/controller/EchoController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { Context } from 'src/entity/Context';
export const NOUN_ECHO = 'echo';

export type EchoControllerData = ControllerData;
export type EchoControllerOptions = BaseControllerOptions<EchoControllerData>;

@Inject()
export class EchoController extends BaseController<EchoControllerData> implements Controller {
constructor(options: EchoControllerOptions) {
constructor(options: BaseControllerOptions<EchoControllerData>) {
super(options, 'isolex#/definitions/service-controller-echo', [NOUN_ECHO]);
}

Expand Down
4 changes: 1 addition & 3 deletions src/controller/LearnController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ export interface LearnControllerData extends ControllerData {
nouns: ChecklistOptions<string>;
}

export type LearnControllerOptions = BaseControllerOptions<LearnControllerData>;

@Inject(INJECT_STORAGE)
export class LearnController extends BaseController<LearnControllerData> implements Controller {
protected readonly checkNoun: Checklist<string>;
protected readonly keywordRepository: Repository<Keyword>;

constructor(options: LearnControllerOptions) {
constructor(options: BaseControllerOptions<LearnControllerData>) {
super(options, 'isolex#/definitions/service-controller-learn', [NOUN_KEYWORD]);

this.checkNoun = new Checklist(options.data.nouns);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/MathController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ export interface MathControllerData extends ControllerData {
};
}

export type MathControllerOptions = BaseControllerOptions<MathControllerData>;

@Inject(INJECT_MATH)
export class MathController extends BaseController<MathControllerData> implements Controller {
protected math: MathJsStatic;

constructor(options: MathControllerOptions) {
constructor(options: BaseControllerOptions<MathControllerData>) {
super(options, 'isolex#/definitions/service-controller-math', [NOUN_MATH]);

this.math = mustExist(options[INJECT_MATH]).create(options.data.math);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/PickController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export interface PickControllerData extends ControllerData {

export const NOUN_PICK = 'pick';

export type PickControllerOptions = BaseControllerOptions<PickControllerData>;

@Inject()
export class PickController extends BaseController<PickControllerData> implements Controller {
protected list: Checklist<string>;

constructor(options: PickControllerOptions) {
constructor(options: BaseControllerOptions<PickControllerData>) {
super(options, 'isolex#/definitions/service-controller-pick', [NOUN_PICK]);

this.list = new Checklist(options.data.check);
Expand Down
3 changes: 1 addition & 2 deletions src/controller/RandomController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { Context } from 'src/entity/Context';
import { countList } from 'src/utils';

export type RandomControllerData = ControllerData;
export type RandomControllerOptions = BaseControllerOptions<RandomControllerData>;

export const NOUN_RANDOM = 'random';

@Inject()
export class RandomController extends BaseController<RandomControllerData> implements Controller {
constructor(options: RandomControllerOptions) {
constructor(options: BaseControllerOptions<RandomControllerData>) {
super(options, 'isolex#/definitions/service-controller-random', [NOUN_RANDOM]);
}

Expand Down
4 changes: 1 addition & 3 deletions src/controller/ReactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ export interface CompiledReaction {
match: Match;
}

export type ReactionControllerOptions = BaseControllerOptions<ReactionControllerData>;

export const NOUN_REACTION = 'reaction';

@Inject()
export class ReactionController extends BaseController<ReactionControllerData> implements Controller {
protected reactions: Array<CompiledReaction>;

constructor(options: ReactionControllerOptions) {
constructor(options: BaseControllerOptions<ReactionControllerData>) {
super(options, 'isolex#/definitions/service-controller-reaction', [NOUN_REACTION]);

this.reactions = options.data.reactions.map((r) => {
Expand Down
4 changes: 1 addition & 3 deletions src/controller/SearchController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ export interface SearchControllerData extends ControllerData {
};
}

export type SearchControllerOptions = BaseControllerOptions<SearchControllerData>;

export const NOUN_SEARCH = 'search';

@Inject(INJECT_TEMPLATE, INJECT_REQUEST)
export class SearchController extends BaseController<SearchControllerData> implements Controller {
protected readonly request: RequestFactory;
protected readonly url: Template;

constructor(options: SearchControllerOptions) {
constructor(options: BaseControllerOptions<SearchControllerData>) {
super(options, 'isolex#/definitions/service-controller-search', [NOUN_SEARCH]);

this.request = mustExist(options[INJECT_REQUEST]);
Expand Down
3 changes: 1 addition & 2 deletions src/controller/SedController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { Message } from 'src/entity/Message';
import { doesExist, mustExist } from 'src/utils';

export type SedControllerData = ControllerData;
export type SedControllerOptions = BaseControllerOptions<SedControllerData>;

export const NOUN_SED = 'sed';

@Inject()
export class SedController extends BaseController<SedControllerData> implements Controller {
constructor(options: SedControllerOptions) {
constructor(options: BaseControllerOptions<SedControllerData>) {
super(options, 'isolex#/definitions/service-controller-sed', [NOUN_SED]);
}

Expand Down
4 changes: 1 addition & 3 deletions src/controller/TimeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ export interface TimeControllerData extends ControllerData {
zone: string;
}

export type TimeControllerOptions = BaseControllerOptions<TimeControllerData>;

@Inject(INJECT_CLOCK)
export class TimeController extends BaseController<TimeControllerData> implements Controller {
protected readonly clock: Clock;

constructor(options: TimeControllerOptions) {
constructor(options: BaseControllerOptions<TimeControllerData>) {
super(options, 'isolex#/definitions/service-controller-time', [NOUN_TIME]);

this.clock = mustExist(options[INJECT_CLOCK]);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/TokenController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ export interface TokenControllerData extends ControllerData {
};
}

export type TokenControllerOptions = BaseControllerOptions<TokenControllerData>;

@Inject(INJECT_CLOCK, INJECT_STORAGE)
export class TokenController extends BaseController<TokenControllerData> implements Controller {
protected readonly clock: Clock;
protected readonly storage: Storage;
protected readonly tokenRepository: Repository<Token>;

constructor(options: TokenControllerOptions) {
constructor(options: BaseControllerOptions<TokenControllerData>) {
super(options, 'isolex#/definitions/service-controller-token', [NOUN_TOKEN]);

this.clock = mustExist(options[INJECT_CLOCK]);
Expand Down
3 changes: 1 addition & 2 deletions src/controller/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ export const NOUN_ROLE = 'role';
export const NOUN_USER = 'user';

export type UserControllerData = ControllerData;
export type UserControllerOptions = BaseControllerOptions<UserControllerData>;

@Inject(INJECT_STORAGE)
export class UserController extends BaseController<UserControllerData> implements Controller {
protected readonly roleRepository: Repository<Role>;
protected readonly userRepository: UserRepository;

constructor(options: UserControllerOptions) {
constructor(options: BaseControllerOptions<UserControllerData>) {
super(options, 'isolex#/definitions/service-controller-user', [NOUN_ROLE, NOUN_USER]);

const storage = mustExist(options[INJECT_STORAGE]);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/WeatherController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ export interface WeatherControllerData extends ControllerData {
};
}

export type WeatherControllerOptions = BaseControllerOptions<WeatherControllerData>;

export const NOUN_WEATHER = 'weather';

@Inject(INJECT_REQUEST)
export class WeatherController extends BaseController<WeatherControllerData> implements Controller {
protected readonly request: RequestFactory;

constructor(options: WeatherControllerOptions) {
constructor(options: BaseControllerOptions<WeatherControllerData>) {
super(options, 'isolex#/definitions/service-controller-weather', [NOUN_WEATHER]);

this.request = mustExist(options[INJECT_REQUEST]);
Expand Down
4 changes: 1 addition & 3 deletions src/controller/github/PRController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ export interface GithubPRControllerData extends ControllerData {
};
}

export type GithubPRControllerOptions = BaseControllerOptions<GithubPRControllerData>;

@Inject()
export class GithubPRController extends BaseController<GithubPRControllerData> implements Controller {
protected client: Octokit;

constructor(options: GithubPRControllerOptions) {
constructor(options: BaseControllerOptions<GithubPRControllerData>) {
super(options, 'isolex#/definitions/service-controller-github-pr', [NOUN_PULL_REQUEST]);

this.client = new Octokit({
Expand Down
6 changes: 2 additions & 4 deletions src/controller/gitlab/CIController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ export interface GitlabCIControllerData extends ControllerData {
client: GitlabClientData;
}

export type GitlabCIControllerOptions = BaseControllerOptions<GitlabCIControllerData>;

export const NOUN_GITLAB_JOB = 'gitlab-ci-job';
export const NOUN_GITLAB_PIPELINE = 'gitlab-ci-pipeline';

@Inject()
export class GitlabCIController extends BaseController<GitlabCIControllerData> implements Controller {
protected readonly container: Container;
protected client?: GitlabClient;
protected container: Container;

constructor(options: GitlabCIControllerOptions) {
constructor(options: BaseControllerOptions<GitlabCIControllerData>) {
super(options, 'isolex#/definitions/service-controller-gitlab-ci', [NOUN_GITLAB_JOB, NOUN_GITLAB_PIPELINE]);
this.container = options.container;
}
Expand Down
4 changes: 1 addition & 3 deletions src/controller/kubernetes/AppsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ export interface AppsControllerData extends KubernetesBaseControllerData {
};
}

export type AppsControllerOptions = BaseControllerOptions<AppsControllerData>;

@Inject()
export class KubernetesAppsController extends KubernetesBaseController<AppsControllerData> implements Controller {
protected client?: AppsClient;

constructor(options: AppsControllerOptions) {
constructor(options: BaseControllerOptions<AppsControllerData>) {
super(options, 'isolex#/definitions/service-controller-kubernetes-apps', [
NOUN_DAEMONSET,
NOUN_DEPLOYMENT,
Expand Down
4 changes: 1 addition & 3 deletions src/controller/kubernetes/CoreController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ export interface CoreControllerData extends KubernetesBaseControllerData {
};
}

export type CoreControllerOptions = BaseControllerOptions<CoreControllerData>;

@Inject()
export class KubernetesCoreController extends KubernetesBaseController<CoreControllerData> implements Controller {
protected client?: k8s.Core_v1Api;

constructor(options: CoreControllerOptions) {
constructor(options: BaseControllerOptions<CoreControllerData>) {
super(options, 'isolex#/definitions/service-controller-kubernetes-core', [NOUN_POD, NOUN_SERVICE]);
}

Expand Down
4 changes: 1 addition & 3 deletions src/filter/UserFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ export interface UserFilterData extends FilterData {
users: ChecklistOptions<string>;
}

export type UserFilterOptions = BaseFilterOptions<UserFilterData>;

export class UserFilter extends BaseFilter<UserFilterData> implements Filter {
protected list: Checklist<string>;

constructor(options: UserFilterOptions) {
constructor(options: BaseFilterOptions<UserFilterData>) {
super(options, 'isolex#/definitions/service-filter-user');

this.list = new Checklist(options.data.users);
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Container, Logger, Module } from 'noicejs';
import * as sourceMapSupport from 'source-map-support';
import * as yargs from 'yargs-parser';

import { Bot, BotOptions } from 'src/Bot';
import { Bot, BotData } from 'src/Bot';
import { loadConfig } from 'src/config';
import { BotModule } from 'src/module/BotModule';
import { ControllerModule } from 'src/module/ControllerModule';
Expand All @@ -15,7 +15,7 @@ import { ParserModule } from 'src/module/ParserModule';
import { ServiceModule } from 'src/module/ServiceModule';
import { TransformModule } from 'src/module/TransformModule';
import { Schema } from 'src/schema';
import { ServiceEvent } from 'src/Service';
import { ServiceEvent, ServiceDefinition } from 'src/Service';
import { BunyanLogger } from 'src/utils/BunyanLogger';
import { signal, SIGNAL_RELOAD, SIGNAL_RESET, SIGNAL_STOP } from 'src/utils/Signal';
import { VERSION_INFO } from 'src/version';
Expand Down Expand Up @@ -117,7 +117,7 @@ async function main(argv: Array<string>): Promise<number> {
logger.info('configuring container');
await ctr.configure({ logger });

const bot = await ctr.create<Bot, BotOptions>(Bot, config);
const bot = await ctr.create<Bot, ServiceDefinition<BotData>>(Bot, config);
botModule.setBot(bot);

logger.info('starting bot');
Expand Down
4 changes: 1 addition & 3 deletions src/interval/CommandInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ export interface CommandIntervalData extends IntervalData {
defaultCommand: CommandOptions;
}

export type CommandIntervalOptions = BaseIntervalOptions<CommandIntervalData>;

export class CommandInterval extends BaseInterval<CommandIntervalData> {
constructor(options: CommandIntervalOptions) {
constructor(options: BaseIntervalOptions<CommandIntervalData>) {
super(options, 'isolex#/definitions/service-interval-command');
}

Expand Down
4 changes: 1 addition & 3 deletions src/interval/EventInterval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ export interface EventIntervalData extends IntervalData {
services: Array<ServiceMetadata>;
}

export type EventIntervalOptions = BaseIntervalOptions<EventIntervalData>;

export class EventInterval extends BaseInterval<EventIntervalData> {
constructor(options: EventIntervalOptions) {
constructor(options: BaseIntervalOptions<EventIntervalData>) {
super(options, 'isolex#/definitions/service-interval-event');
}

Expand Down
Loading

0 comments on commit 571032b

Please sign in to comment.