Compare commits

...

21 Commits

Author SHA1 Message Date
Jacob Nguyen
4f12868141 Merge branch 'main' into renovate/all-minor-patch 2024-03-21 10:39:08 -05:00
renovate[bot]
d6f49d1d97 chore(deps): update actions/setup-node digest to 1a4442c (#354)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
2024-03-21 10:35:43 -05:00
renovate[bot]
cd85bf9755 chore(deps): update all non-major dependencies 2024-03-20 20:57:46 +00:00
renovate[bot]
8ecd30cf18 chore(deps): update actions/checkout digest to f43a0e5 (#353)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
2024-03-19 10:22:39 -05:00
github-actions[bot]
a19edaf883 chore(main): release 3.3.4 (#359)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-18 01:57:13 -05:00
Jacob Nguyen
90e55dfa14 fix: sern emitter err (#358)
* prep for fix

* fix ? (not tested

* fix error event not emitting payload
2024-03-18 01:47:14 -05:00
github-actions[bot]
2106522812 chore(main): release 3.3.3 (#357)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-02-24 18:35:24 -06:00
Jacob Nguyen
ce8c4bf649 fix: typings and cleanup (#356)
* fix typings and cleanup

* import type

* rm unused import
2024-02-18 09:34:53 -06:00
jacob
e89b918390 dfs 2024-02-17 11:40:19 -06:00
jacob
f8b69ae542 stuff 2024-02-17 11:38:37 -06:00
Jacob Nguyen
48f9f6ec16 fix: rm deprecated class modules, clean up, rm indirection (#355)
* refactor: rm deprecations, clean up, rm indirection

* fix: singleton init not being fired when inserting function

* refactor and generic internal add

* deprecate a few things that i impusively added lol
2024-02-17 11:35:53 -06:00
jacob
86ebb221ed deprecate a few things that i impusively added lol 2024-02-15 12:36:00 -06:00
jacob
4efdbb21fb refactor and generic internal add 2024-02-15 12:26:34 -06:00
jacob
07b11b357b fix: singleton init not being fired when inserting function 2024-02-14 15:58:50 -06:00
jacob
ac7f47c590 refactor: rm deprecations, clean up, rm indirection 2024-02-12 21:47:35 -06:00
45cbda7b42 refactor: cleanup (#348)
* some wip code

Co-authored-by: Jacob Nguyen <jacoobes@users.noreply.github.com>

* general idea

* style

* making shrimple truly optional

* got optional localizer working

* proposing api notation?

* prepare for localization map

* add localsFor

* merge some internals

* boss call

* add test for init functionality

* add documentation

* inline and cleanup

* feat: logging for experimental json loading

* loosen typings

* dev workflow and cleaning up comments

* cleaning up a bit more

* rename Localizer -> Localization

* more documentation, change dir for default localizer

* some tests

* "

* move stuff, refactor, deprecate

* yarnb

* Update index.ts

---------

Co-authored-by: Jacob Nguyen <jacoobes@users.noreply.github.com>
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
Co-authored-by: jacob <jacoobes@sern.dev>
2024-02-09 17:46:16 -06:00
Jacob Nguyen
5cad432589 Update README.md 2024-01-08 14:31:49 -06:00
Jacob Nguyen
044a10dace Update README.md 2024-01-08 14:29:49 -06:00
github-actions[bot]
9d5c6c714f chore(main): release 3.3.2 (#352)
* chore(main): release 3.3.2

* Update CHANGELOG.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
2024-01-08 12:16:52 -06:00
Jacob Nguyen
4f2387119a fix: presence feature not workign on cjs applications (#351)
* start fix

* fix on unix

* better solution
2024-01-08 12:11:27 -06:00
Jacob Nguyen
a6fa4e3dcb fix docs build 2024-01-07 15:38:22 -06:00
50 changed files with 1514 additions and 1543 deletions

34
.github/workflows/npm-publish-dev.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Continuous Delivery
on:
push:
branches:
- main
paths:
- 'src/**'
- 'package.json'
jobs:
Publish:
name: Publishing Dev
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Set up Node.js
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Install Node.js dependencies
run: npm i && npm run build:dev
- name: Publish to npm
run: |
npm version premajor --preid "dev.$(git rev-parse --verify --short HEAD)" --git-tag-version=false
npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

File diff suppressed because one or more lines are too long

875
.yarn/releases/yarn-3.8.1.cjs vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -2,4 +2,4 @@ enableGlobalCache: true
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.5.1.cjs
yarnPath: .yarn/releases/yarn-3.8.1.cjs

View File

@@ -1,5 +1,28 @@
# Changelog
## [3.3.4](https://github.com/sern-handler/handler/compare/v3.3.3...v3.3.4) (2024-03-18)
### Bug Fixes
* sern emitter err ([#358](https://github.com/sern-handler/handler/issues/358)) ([90e55df](https://github.com/sern-handler/handler/commit/90e55dfa1466c91e5da48922251309331921b1ef))
## [3.3.3](https://github.com/sern-handler/handler/compare/v3.3.2...v3.3.3) (2024-02-25)
### Bug Fixes
* rm deprecated class modules, clean up, rm indirection ([#355](https://github.com/sern-handler/handler/issues/355)) ([48f9f6e](https://github.com/sern-handler/handler/commit/48f9f6ec16e650d574bd24dcbb0ed176933bfe17))
* singleton init not being fired when inserting function ([07b11b3](https://github.com/sern-handler/handler/commit/07b11b357baac0c3c7055c022bc353995c80f766))
* typings and cleanup ([#356](https://github.com/sern-handler/handler/issues/356)) ([ce8c4bf](https://github.com/sern-handler/handler/commit/ce8c4bf6492b9680fb1c1a530d3e0028f214ad2f))
## [3.3.2](https://github.com/sern-handler/handler/compare/v3.3.1...v3.3.2) (2024-01-08)
### Bug Fixes
* presence feature not working on cjs applications ([#351](https://github.com/sern-handler/handler/issues/351)) ([4f23871](https://github.com/sern-handler/handler/commit/4f2387119acfde036d0d1626553e9050f55627d1))
## [3.3.1](https://github.com/sern-handler/handler/compare/v3.3.0...v3.3.1) (2024-01-07)

View File

@@ -42,26 +42,6 @@ export default commandModule({
});
```
</details>
<details><summary>modal.ts</summary>
```ts
export default commandModule({
type: CommandType.Modal,
//Installed a plugin to make sure modal fields pass a validation.
plugins : [
assertFields({
fields: {
name: /^([^0-9]*)$/
},
failure: (errors, modal) => modal.reply('your submission did not pass the validations')
})
],
execute : (modal) => {
modal.reply('thanks for the submission!');
}
})
```
</details>
## 🤖 Bots Using sern
@@ -72,7 +52,8 @@ export default commandModule({
- [Murayama](https://github.com/murayamabot/murayama), :pepega:
- [Protector (WIP)](https://github.com/needhamgary/Protector), Just a simple bot to help enhance a private minecraft server.
- [SmokinWeed 💨](https://github.com/Peter-MJ-Parker/sern-bud), A fun bot for a small - but growing - server.
- [Man Nomic](https://github.com/jacoobes/man-nomic), A simple information bot to provide information to the nomic-ai discord community.
- [Linear-Discord](https://github.com/sern-handler/linear-discord) Display and manage a linear dashboard.
## 💻 CLI
It is **highly encouraged** to use the [command line interface](https://github.com/sern-handler/cli) for your project. Don't forget to view it.

View File

@@ -1,7 +1,7 @@
{
"name": "@sern/handler",
"packageManager": "yarn@3.5.0",
"version": "3.3.1",
"packageManager": "yarn@3.8.1",
"version": "3.3.4",
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -45,14 +45,13 @@
"devDependencies": {
"@faker-js/faker": "^8.0.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.59.1",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"discord.js": "^14.11.0",
"esbuild": "^0.17.0",
"eslint": "8.39.0",
"eslint": "8.57.0",
"prettier": "2.8.8",
"tsup": "^6.7.0",
"typescript": "5.0.2",
"typescript": "5.4.3",
"vitest": "latest"
},
"prettier": {
@@ -95,5 +94,8 @@
"type": "git",
"url": "git+https://github.com/sern-handler/handler.git"
},
"engines": {
"node": ">= 18.16.x"
},
"homepage": "https://sern.dev"
}

View File

@@ -1,10 +1,10 @@
export * as Id from './id';
export * from './operators';
export * from './predicates';
export * as Files from './module-loading';
export * from './functions';
export type { VoidResult } from '../types/core-plugin';
export { SernError } from './structures/enums';
export { ModuleStore } from './structures/module-store';
export * as DefaultServices from './structures/services';
export { useContainerRaw } from './ioc/base'
export * as __Services from './structures/services';
export { useContainerRaw } from './ioc/base';

View File

@@ -1,9 +0,0 @@
import type { Awaitable } from '../../types/utility';
/**
* Represents a Disposable contract.
* Let dependencies implement this to dispose and cleanup.
*/
export interface Disposable {
dispose(): Awaitable<unknown>;
}

View File

@@ -1,3 +1,5 @@
//i deleted it, hmm so how should we allow users to enable localization?
// a
import type { AnyFunction } from '../../types/utility';
export interface Emitter {

View File

@@ -1,5 +1,3 @@
import type { CommandModule,Processed, EventModule } from "../../types/core-modules";
/**
* @since 2.0.0
*/

View File

@@ -0,0 +1,16 @@
/**
* Represents an initialization contract.
* Let dependencies implement this to initiate some logic.
*/
export interface Init {
init(): unknown;
}
/**
* Represents a Disposable contract.
* Let dependencies implement this to dispose and cleanup.
*/
export interface Disposable {
dispose(): unknown;
}

View File

@@ -2,6 +2,5 @@ export * from './error-handling';
export * from './logging';
export * from './module-manager';
export * from './module-store';
export * from './init';
export * from './hooks';
export * from './emitter';
export * from './disposable'

View File

@@ -1,9 +0,0 @@
import type { Awaitable } from '../../types/utility';
/**
* Represents an initialization contract.
* Let dependencies implement this to initiate some logic.
*/
export interface Init {
init(): Awaitable<unknown>;
}

View File

@@ -16,12 +16,19 @@ interface MetadataAccess {
* @internal - direct access to the module manager will be removed in version 4
*/
export interface ModuleManager extends MetadataAccess {
get(id: string): string | undefined;
get(id: string): Module | undefined;
set(id: string, path: string): void;
getPublishableCommands(): Promise<CommandModule[]>;
set(id: string, path: Module): void;
/**
* @deprecated
*/
getPublishableCommands(): CommandModule[];
/*
* @deprecated
*/
getByNameCommandType<T extends CommandType>(
name: string,
commandType: T,
): Promise<CommandModuleDefs[T]> | undefined;
): CommandModuleDefs[T] | undefined;
}

View File

@@ -4,6 +4,6 @@ import type { CommandMeta, Module } from '../../types/core-modules';
* Represents a core module store that stores IDs mapped to file paths.
*/
export interface CoreModuleStore {
commands: Map<string, string>;
commands: Map<string, Module>;
metadata: WeakMap<Module, CommandMeta>;
}

View File

@@ -1,9 +1,19 @@
import { Err, Ok } from 'ts-results-es';
import { ApplicationCommandOptionType, AutocompleteInteraction } from 'discord.js';
import type { SernAutocompleteData, SernOptionsData } from '../types/core-modules';
import type { Module, SernAutocompleteData, SernOptionsData } from '../types/core-modules';
import type { AnyCommandPlugin, AnyEventPlugin, Plugin } from '../types/core-plugin';
import { PluginType } from './structures';
import type {
AnySelectMenuInteraction,
ButtonInteraction,
ChatInputCommandInteraction,
MessageContextMenuCommandInteraction,
ModalSubmitInteraction,
UserContextMenuCommandInteraction,
AutocompleteInteraction
} from 'discord.js';
import { ApplicationCommandOptionType, InteractionType } from 'discord.js';
import { PayloadType, PluginType } from './structures';
import assert from 'assert';
import type { Payload } from '../types/utility';
//function wrappers for empty ok / err
export const ok = /* @__PURE__*/ () => Ok.EMPTY;
@@ -40,7 +50,7 @@ export function treeSearch(
if (options === undefined) return undefined;
//clone to prevent mutation of original command module
const _options = options.map(a => ({ ...a }));
let subcommands = new Set();
const subcommands = new Set();
while (_options.length > 0) {
const cur = _options.pop()!;
switch (cur.type) {
@@ -81,3 +91,33 @@ export function treeSearch(
}
}
}
interface InteractionTypable {
type: InteractionType;
}
//discord.js pls fix ur typings or i will >:(
type AnyMessageComponentInteraction = AnySelectMenuInteraction | ButtonInteraction;
type AnyCommandInteraction =
| ChatInputCommandInteraction
| MessageContextMenuCommandInteraction
| UserContextMenuCommandInteraction;
export function isMessageComponent(i: InteractionTypable): i is AnyMessageComponentInteraction {
return i.type === InteractionType.MessageComponent;
}
export function isCommand(i: InteractionTypable): i is AnyCommandInteraction {
return i.type === InteractionType.ApplicationCommand;
}
export function isAutocomplete(i: InteractionTypable): i is AutocompleteInteraction {
return i.type === InteractionType.ApplicationCommandAutocomplete;
}
export function isModal(i: InteractionTypable): i is ModalSubmitInteraction {
return i.type === InteractionType.ModalSubmit;
}
export function resultPayload<T extends PayloadType>
(type: T, module?: Module, reason?: unknown) {
return { type, module, reason } as Payload & { type : T };
}

View File

@@ -42,19 +42,10 @@ const TypeMap = new Map<number, number>([
[CommandType.RoleSelect, ComponentType.RoleSelect],
[CommandType.ChannelSelect, ComponentType.ChannelSelect]]);
/*
* Generates a number based on CommandType.
* This corresponds to an ApplicationCommandType or ComponentType
* TextCommands are 0 as they aren't either or.
*/
function apiType(t: CommandType | EventType) {
return TypeMap.get(t)!;
}
/*
* Generates an id based on name and CommandType.
* A is for any ApplicationCommand. C is for any ComponentCommand
* Then, another number generated by apiType function is appended
* Then, another number fetched from TypeMap
*/
export function create(name: string, type: CommandType | EventType) {
if(type == CommandType.Text) {
@@ -67,7 +58,7 @@ export function create(name: string, type: CommandType | EventType) {
return `${name}_M`;
}
const am = (appBitField & type) !== 0 ? 'A' : 'C';
return `${name}_${am}${apiType(type)}`
return `${name}_${am}${TypeMap.get(type)!}`
}

View File

@@ -1,19 +1,40 @@
import * as assert from 'assert';
import { composeRoot, useContainer } from './dependency-injection';
import type { DependencyConfiguration } from '../../types/ioc';
import { useContainer } from './dependency-injection';
import type { CoreDependencies, DependencyConfiguration } from '../../types/ioc';
import { CoreContainer } from './container';
import { Result } from 'ts-results-es'
import { DefaultServices } from '../_internal';
import { Result } from 'ts-results-es';
import { __Services } from '../_internal';
import { AnyFunction } from '../../types/utility';
import type { Logging } from '../contracts/logging';
import type { UnpackFunction } from 'iti';
//SIDE EFFECT: GLOBAL DI
let containerSubject: CoreContainer<Partial<Dependencies>>;
/**
* @deprecated
* @internal
* Don't use this unless you know what you're doing. Destroys old containerSubject if it exists and disposes everything
* then it will swap
*/
export async function __swap_container(c: CoreContainer<Partial<Dependencies>>) {
if(containerSubject) {
await containerSubject.disposeAll()
}
containerSubject = c;
}
/**
* @internal
* Don't use this unless you know what you're doing. Destroys old containerSubject if it exists and disposes everything
* then it will swap
*/
export function __add_container(key: string,v : Insertable) {
containerSubject.add({ [key]: v });
}
/**
* Returns the underlying data structure holding all dependencies.
* Exposes methods from iti
* Use the Service API. The container should be readonly
* Use the Service API. The container should be readonly from the consumer side
*/
export function useContainerRaw() {
assert.ok(
@@ -28,20 +49,27 @@ export function disposeAll(logger: Logging|undefined) {
?.disposeAll()
.then(() => logger?.info({ message: 'Cleaning container and crashing' }));
}
const dependencyBuilder = (container: any, excluded: string[]) => {
type Insertable =
| ((container: CoreContainer<Dependencies>) => unknown )
| Record<PropertyKey, unknown>
type UnpackedDependencies = {
[K in keyof Dependencies]: UnpackFunction<Dependencies[K]>
}
type Insertable =
| ((container: UnpackedDependencies) => unknown)
| object
const dependencyBuilder = (container: any, excluded: string[] ) => {
return {
/**
* Insert a dependency into your container.
* Supply the correct key and dependency
*/
add(key: keyof Dependencies, v: Insertable) {
Result
.wrap(() => container.add({ [key]: v}))
.expect("Failed to add " + key);
if(typeof v !== 'function') {
Result.wrap(() => container.add({ [key]: v}))
.expect("Failed to add " + key);
} else {
Result.wrap(() =>
container.add((cntr: UnpackedDependencies) => ({ [key]: v(cntr)} )))
.expect("Failed to add " + key);
}
},
/**
* Exclude any dependencies from being added.
@@ -50,15 +78,21 @@ const dependencyBuilder = (container: any, excluded: string[]) => {
exclude(...keys: (keyof Dependencies)[]) {
keys.forEach(key => excluded.push(key));
},
/**
* @param key the key of the dependency
* @param v The dependency to swap out.
* Swap out a preexisting dependency.
*/
swap(key: keyof Dependencies, v: Insertable) {
Result
.wrap(() => container.upsert({ [key]: v }))
.expect("Failed to update " + key);
if(typeof v !== 'function') {
Result.wrap(() => container.upsert({ [key]: v}))
.expect("Failed to update " + key);
} else {
Result.wrap(() =>
container.upsert((cntr: UnpackedDependencies) => ({ [key]: v(cntr)})))
.expect("Failed to update " + key);
}
},
/**
* @param key the key of the dependency
@@ -70,33 +104,56 @@ const dependencyBuilder = (container: any, excluded: string[]) => {
* Swap out a preexisting dependency.
*/
addDisposer(key: keyof Dependencies, cleanup: AnyFunction) {
Result
.wrap(() => container.addDisposer({ [key] : cleanup }))
.expect("Failed to addDisposer for" + key);
Result.wrap(() => container.addDisposer({ [key] : cleanup }))
.expect("Failed to addDisposer for" + key);
}
};
};
type CallbackBuilder = (c: ReturnType<typeof dependencyBuilder>) => any
type ValidDependencyConfig =
| CallbackBuilder
| ((c: ReturnType<typeof dependencyBuilder>) => any)
| DependencyConfiguration;
export const insertLogger = (containerSubject: CoreContainer<any>) => {
containerSubject
.upsert({'@sern/logger': () => new DefaultServices.DefaultLogging});
/**
* Given the user's conf, check for any excluded/included dependency keys.
* Then, call conf.build to get the rest of the users' dependencies.
* Finally, update the containerSubject with the new container state
* @param conf
*/
function composeRoot(
container: CoreContainer<Partial<Dependencies>>,
conf: DependencyConfiguration,
) {
//container should have no client or logger yet.
const hasLogger = conf.exclude?.has('@sern/logger');
if (!hasLogger) {
__add_container('@sern/logger', new __Services.DefaultLogging);
}
//Build the container based on the callback provided by the user
conf.build(container as CoreContainer<Omit<CoreDependencies, '@sern/client'>>);
if (!hasLogger) {
container.get('@sern/logger')?.info({ message: 'All dependencies loaded successfully.' });
}
container.ready();
}
export async function makeDependencies<const T extends Dependencies>
(conf: ValidDependencyConfig) {
containerSubject = new CoreContainer();
if(typeof conf === 'function') {
const excluded: string[] = [];
conf(dependencyBuilder(containerSubject, excluded));
//We only include logger if it does not exist
const includeLogger =
!excluded.includes('@sern/logger')
&& !containerSubject.hasKey('@sern/logger');
if(!excluded.includes('@sern/logger')
&& !containerSubject.getTokens()['@sern/logger']) {
insertLogger(containerSubject);
if(includeLogger) {
__add_container('@sern/logger', new __Services.DefaultLogging);
}
containerSubject.ready();
@@ -107,5 +164,3 @@ export async function makeDependencies<const T extends Dependencies>
return useContainer<T>();
}

View File

@@ -1,9 +1,10 @@
import { Container } from 'iti';
import { Disposable, SernEmitter } from '../';
import { Disposable } from '../';
import * as assert from 'node:assert';
import { Subject } from 'rxjs';
import { DefaultServices, ModuleStore } from '../_internal';
import * as Hooks from './hooks'
import { __Services, ModuleStore } from '../_internal';
import * as Hooks from './hooks';
import { EventEmitter } from 'node:events';
/**
@@ -17,35 +18,39 @@ export class CoreContainer<T extends Partial<Dependencies>> extends Container<T,
assert.ok(!this.isReady(), 'Listening for dispose & init should occur prior to sern being ready.');
const { unsubscribe } = Hooks.createInitListener(this);
this.ready$
.subscribe({ complete: unsubscribe });
(this as Container<{}, {}>)
.add({ '@sern/errors': () => new DefaultServices.DefaultErrorHandling(),
'@sern/emitter': () => new SernEmitter,
.add({ '@sern/errors': () => new __Services.DefaultErrorHandling,
'@sern/emitter': () => new EventEmitter({ captureRejections: true }),
'@sern/store': () => new ModuleStore })
.add(ctx => {
return { '@sern/modules': () =>
new DefaultServices.DefaultModuleManager(ctx['@sern/store']) };
return { '@sern/modules': new __Services.DefaultModuleManager(ctx['@sern/store'])};
});
}
isReady() {
return this.ready$.closed;
}
hasKey(key: string): boolean {
return Boolean((this as Container<any,any>)._context[key]);
}
override async disposeAll() {
const otherDisposables = Object
.entries(this._context)
.flatMap(([key, value]) =>
'dispose' in value ? [key] : []);
for(const key of otherDisposables) {
otherDisposables.forEach(key => {
//possible source of bug: dispose is a property.
this.addDisposer({ [key]: (dep: Disposable) => dep.dispose() } as never);
}
await super.disposeAll()
})
await super.disposeAll();
}
ready() {
this.ready$.complete();
this.ready$.unsubscribe();

View File

@@ -1,6 +1,6 @@
import type { CoreDependencies, DependencyConfiguration, IntoDependencies } from '../../types/ioc';
import { insertLogger, useContainerRaw } from './base';
import { CoreContainer } from './container';
import assert from 'node:assert';
import type { IntoDependencies } from '../../types/ioc';
import { useContainerRaw } from './base';
/**
* @__PURE__
@@ -25,6 +25,7 @@ export function transient<T>(cb: () => () => T) {
* The new Service api, a cleaner alternative to useContainer
* To obtain intellisense, ensure a .d.ts file exists in the root of compilation.
* Usually our scaffolding tool takes care of this.
* Note: this method only works AFTER your container has been initiated
* @since 3.0.0
* @example
* ```ts
@@ -34,7 +35,9 @@ export function transient<T>(cb: () => () => T) {
*
*/
export function Service<const T extends keyof Dependencies>(key: T) {
return useContainerRaw().get(key)!;
const dep = useContainerRaw().get(key)!;
assert(dep, "Requested key " + key + " returned undefined");
return dep;
}
/**
* @since 3.0.0
@@ -46,32 +49,9 @@ export function Services<const T extends (keyof Dependencies)[]>(...keys: [...T]
return keys.map(k => container.get(k)!) as IntoDependencies<T>;
}
/**
* Given the user's conf, check for any excluded dependency keys.
* Then, call conf.build to get the rest of the users' dependencies.
* Finally, update the containerSubject with the new container state
* @param conf
*/
export function composeRoot(
container: CoreContainer<Partial<Dependencies>>,
conf: DependencyConfiguration,
) {
//container should have no client or logger yet.
const hasLogger = conf.exclude?.has('@sern/logger');
if (!hasLogger) {
insertLogger(container);
}
//Build the container based on the callback provided by the user
conf.build(container as CoreContainer<Omit<CoreDependencies, '@sern/client'>>);
if (!hasLogger) {
container.get('@sern/logger')?.info({ message: 'All dependencies loaded successfully.' });
}
container.ready();
}
export function useContainer<const T extends Dependencies>() {
return <V extends (keyof T)[]>(...keys: [...V]) =>
keys.map(key => useContainerRaw().get(key as keyof Dependencies)) as IntoDependencies<V>;
}

View File

@@ -9,7 +9,7 @@ type HookName = 'init';
export const createInitListener = (coreContainer : CoreContainer<any>) => {
const initCalled = new Set<PropertyKey>();
const hasCallableMethod = createPredicate(initCalled);
const unsubscribe = coreContainer.on('containerUpserted', async (event) => {
const unsubscribe = coreContainer.on('containerUpserted', async event => {
if(isNotHookable(event)) {
return;
@@ -21,6 +21,7 @@ export const createInitListener = (coreContainer : CoreContainer<any>) => {
}
});
return { unsubscribe };
}

View File

@@ -1,24 +1,24 @@
import { Result } from 'ts-results-es';
import { type Observable, from, mergeMap, ObservableInput } from 'rxjs';
import { readdir, stat } from 'fs/promises';
import { basename, extname, join, resolve, parse } from 'path';
import { basename, extname, join, resolve, parse, dirname } from 'path';
import assert from 'assert';
import { createRequire } from 'node:module';
import type { ImportPayload, Wrapper } from '../types/core';
import type { Module } from '../types/core-modules';
import { existsSync } from 'fs';
import { fileURLToPath } from 'node:url';
import type { Logging } from './contracts/logging';
export const shouldHandle = (path: string, fpath: string) => {
const newPath = new URL(fpath+extname(path), path).href;
return {
exists: existsSync(fileURLToPath(newPath)),
path: newPath
}
const file_name = fpath+extname(path);
let newPath = join(dirname(path), file_name)
.replace(/file:\\?/, "");
return { exists: existsSync(newPath),
path: 'file:///'+newPath };
}
export type ModuleResult<T> = Promise<ImportPayload<T>>;
/**
* Import any module based on the absolute path.
* This can accept four types of exported modules
@@ -41,9 +41,7 @@ export async function importModule<T>(absPath: string) {
if ('default' in commandModule ) {
commandModule = commandModule.default;
}
return Result
.wrap(() => ({ module: commandModule.getInstance() }))
.unwrapOr({ module: commandModule }) as T;
return { module: commandModule } as T;
}
export async function defaultModuleLoader<T extends Module>(absPath: string): ModuleResult<T> {
@@ -79,11 +77,9 @@ const isSkippable = (filename: string) => {
async function deriveFileInfo(dir: string, file: string) {
const fullPath = join(dir, file);
return {
fullPath,
fileStats: await stat(fullPath),
base: basename(file),
};
return { fullPath,
fileStats: await stat(fullPath),
base: basename(file) };
}
async function* readPaths(dir: string): AsyncGenerator<string> {
@@ -109,11 +105,11 @@ async function* readPaths(dir: string): AsyncGenerator<string> {
const requir = createRequire(import.meta.url);
export function loadConfig(wrapper: Wrapper | 'file'): Wrapper {
export function loadConfig(wrapper: Wrapper | 'file', log: Logging | undefined): Wrapper {
if (wrapper !== 'file') {
return wrapper;
}
console.log('Experimental loading of sern.config.json');
log?.info({ message: 'Experimental loading of sern.config.json'});
const config = requir(resolve('sern.config.json'));
const makePath = (dir: PropertyKey) =>
@@ -121,20 +117,18 @@ export function loadConfig(wrapper: Wrapper | 'file'): Wrapper {
? join('dist', config.paths[dir]!)
: join(config.paths[dir]!);
console.log('Loading config: ', config);
log?.info({ message: 'Loading config: ' + JSON.stringify(config, null, 4) });
const commandsPath = makePath('commands');
console.log('Commands path is set to', commandsPath);
log?.info({ message: `Commands path is set to ${commandsPath}` });
let eventsPath: string | undefined;
if (config.paths.events) {
eventsPath = makePath('events');
console.log('Events path is set to', eventsPath);
log?.info({ message: `Events path is set to ${eventsPath} `});
}
return {
defaultPrefix: config.defaultPrefix,
commands: commandsPath,
events: eventsPath,
};
return { defaultPrefix: config.defaultPrefix,
commands: commandsPath,
events: eventsPath };
}

View File

@@ -1,19 +1,13 @@
import { ClientEvents } from 'discord.js';
import { CommandType, EventType, PluginType } from '../core/structures';
import { EventType } from '../core/structures';
import type {
AnyCommandPlugin,
AnyEventPlugin,
CommandArgs,
ControlPlugin,
EventArgs,
InitPlugin,
} from '../types/core-plugin';
import type {
CommandModule,
EventModule,
InputCommand,
InputEvent,
Module,
} from '../types/core-modules';
import { partitionPlugins } from './_internal';
import type { Awaitable } from '../types/utility';
@@ -61,53 +55,3 @@ export function discordEvent<T extends keyof ClientEvents>(mod: {
});
}
/**
* @deprecated
*/
function prepareClassPlugins(c: Module) {
const [onEvent, initPlugins] = partitionPlugins(c.plugins);
c.plugins = initPlugins as InitPlugin[];
c.onEvent = onEvent as ControlPlugin[];
}
/**
* @deprecated
* Will be removed in future
*/
export abstract class CommandExecutable<const Type extends CommandType = CommandType> {
abstract type: Type;
plugins: AnyCommandPlugin[] = [];
private static _instance: CommandModule;
static getInstance() {
if (!CommandExecutable._instance) {
//@ts-ignore
CommandExecutable._instance = new this();
prepareClassPlugins(CommandExecutable._instance);
}
return CommandExecutable._instance;
}
abstract execute(...args: CommandArgs<Type, PluginType.Control>): Awaitable<unknown>;
}
/**
* @deprecated
* Will be removed in future
*/
export abstract class EventExecutable<Type extends EventType> {
abstract type: Type;
plugins: AnyEventPlugin[] = [];
private static _instance: EventModule;
static getInstance() {
if (!EventExecutable._instance) {
//@ts-ignore
EventExecutable._instance = new this();
prepareClassPlugins(EventExecutable._instance);
}
return EventExecutable._instance;
}
abstract execute(...args: EventArgs<Type, PluginType.Control>): Awaitable<unknown>;
}

View File

@@ -59,20 +59,20 @@ export const sharedEventStream = <T>(e: Emitter, eventName: string) => {
return (fromEvent(e, eventName) as Observable<T>).pipe(share());
};
export function handleError<C>(crashHandler: ErrorHandling, logging?: Logging) {
export function handleError<C>(crashHandler: ErrorHandling, emitter: Emitter, logging?: Logging) {
return (pload: unknown, caught: Observable<C>) => {
// This is done to fit the ErrorHandling contract
const err = pload instanceof Error ? pload : Error(util.inspect(pload, { colors: true }));
//formatted payload
logging?.error({ message: util.inspect(pload) });
crashHandler.updateAlive(err);
if(!emitter.emit('error', pload)) {
const err = pload instanceof Error ? pload : Error(util.inspect(pload, { colors: true }));
logging?.error({ message: util.inspect(pload) });
crashHandler.updateAlive(err);
}
return caught;
};
}
// Temporary until i get rxjs operators working on ts-results-es
export const filterTap = <K, R>(onErr: (e: R) => void): OperatorFunction<Result<K, R>, K> =>
pipe(
concatMap(result => {
pipe(concatMap(result => {
if(result.isOk()) {
return of(result.value)
}

View File

@@ -1,34 +0,0 @@
import type {
AnySelectMenuInteraction,
AutocompleteInteraction,
ButtonInteraction,
ChatInputCommandInteraction,
MessageContextMenuCommandInteraction,
ModalSubmitInteraction,
UserContextMenuCommandInteraction,
} from 'discord.js';
import { InteractionType } from 'discord.js';
interface InteractionTypable {
type: InteractionType;
}
//discord.js pls fix ur typings or i will >:(
type AnyMessageComponentInteraction = AnySelectMenuInteraction | ButtonInteraction;
type AnyCommandInteraction =
| ChatInputCommandInteraction
| MessageContextMenuCommandInteraction
| UserContextMenuCommandInteraction;
export function isMessageComponent(i: InteractionTypable): i is AnyMessageComponentInteraction {
return i.type === InteractionType.MessageComponent;
}
export function isCommand(i: InteractionTypable): i is AnyCommandInteraction {
return i.type === InteractionType.ApplicationCommand;
}
export function isAutocomplete(i: InteractionTypable): i is AutocompleteInteraction {
return i.type === InteractionType.ApplicationCommandAutocomplete;
}
export function isModal(i: InteractionTypable): i is ModalSubmitInteraction {
return i.type === InteractionType.ModalSubmit;
}

View File

@@ -22,13 +22,11 @@ export type Config <T extends (keyof Dependencies)[]> =
/**
* A small wrapper to provide type inference.
* Create a Presence module which **MUST** be put in a file called presence.<language-extension>
* Create a Presence module which **MUST** be put in a file called presence.(language-extension)
* adjacent to the file where **Sern.init** is CALLED.
*/
export function module<T extends (keyof Dependencies)[]>
(conf: Config<T>) {
return conf;
}
export function module<T extends (keyof Dependencies)[]>(conf: Config<T>)
{ return conf; }
/**

View File

@@ -1,4 +1,4 @@
import {
import type {
BaseInteraction,
ChatInputCommandInteraction,
Client,

View File

@@ -1,5 +1,5 @@
export { CommandType, PluginType, PayloadType, EventType } from './enums';
export * from './context';
export * from './sern-emitter';
export * from './services';
export * from './module-store';

View File

@@ -1,12 +1,11 @@
import { CommandMeta, Module } from '../../types/core-modules';
import { CoreModuleStore } from '../contracts';
/*
* @internal
* @deprecated
* Version 4.0.0 will internalize this api. Please refrain from using ModuleStore!
* For interacting with modules, use the ModuleManager instead.
*/
export class ModuleStore implements CoreModuleStore {
export class ModuleStore {
metadata = new WeakMap<Module, CommandMeta>();
commands = new Map<string, string>();
commands = new Map<string, Module>();
}

View File

@@ -1,89 +0,0 @@
import { EventEmitter } from 'node:events';
import { PayloadType } from '../../core/structures';
import { Module } from '../../types/core-modules';
import { SernEventsMapping, Payload } from '../../types/utility';
/**
* @since 1.0.0
*/
export class SernEmitter extends EventEmitter {
constructor() {
super({ captureRejections: true });
}
/**
* Listening to sern events with on. This event stays on until a crash or a normal exit
* @param eventName
* @param listener what to do with the data
*/
public override on<T extends keyof SernEventsMapping>(
eventName: T,
listener: (...args: SernEventsMapping[T][]) => void,
): this {
return super.on(eventName, listener);
}
/**
* Listening to sern events with on. This event stays on until a crash or a normal exit
* @param eventName
* @param listener what to do with the data
*/
public override once<T extends keyof SernEventsMapping>(
eventName: T,
listener: (...args: SernEventsMapping[T][]) => void,
): this {
return super.once(eventName, listener);
}
/**
* Listening to sern events with on. This event stays on until a crash or a normal exit
* @param eventName
* @param args the arguments for emitting the eventName
*/
public override emit<T extends keyof SernEventsMapping>(
eventName: T,
...args: SernEventsMapping[T]
): boolean {
return super.emit(eventName, ...args);
}
private static payload<T extends Payload>(
type: PayloadType,
module?: Module,
reason?: unknown,
) {
return { type, module, reason } as T;
}
/**
* Creates a compliant SernEmitter failure payload
* @param module
* @param reason
*/
static failure(module?: Module, reason?: unknown) {
//The generic cast Payload & { type : PayloadType.* } coerces the type to be a failure payload
// same goes to the other methods below
return SernEmitter.payload<Payload & { type: PayloadType.Failure }>(
PayloadType.Failure,
module,
reason,
);
}
/**
* Creates a compliant SernEmitter module success payload
* @param module
*/
static success(module: Module) {
return SernEmitter.payload<Payload & { type: PayloadType.Success }>(
PayloadType.Success,
module,
);
}
/**
* Creates a compliant SernEmitter module warning payload
* @param reason
*/
static warning(reason: unknown) {
return SernEmitter.payload<Payload & { type: PayloadType.Warning }>(
PayloadType.Warning,
undefined,
reason,
);
}
}

View File

@@ -10,7 +10,7 @@ export class DefaultErrorHandling implements ErrorHandling {
throw err;
}
#keepAlive = 5;
#keepAlive = 1;
updateAlive(err: Error) {
this.#keepAlive--;

View File

@@ -1,6 +1,5 @@
import * as Id from '../../../core/id';
import { CoreModuleStore, ModuleManager } from '../../contracts';
import { Files } from '../../_internal';
import { CommandMeta, CommandModule, CommandModuleDefs, Module } from '../../../types/core-modules';
import { CommandType } from '../enums';
/**
@@ -13,11 +12,11 @@ export class DefaultModuleManager implements ModuleManager {
getByNameCommandType<T extends CommandType>(name: string, commandType: T) {
const id = this.get(Id.create(name, commandType));
if (!id) {
const module = this.get(Id.create(name, commandType));
if (!module) {
return undefined;
}
return Files.importModule<CommandModuleDefs[T]>(id);
return module as CommandModuleDefs[T];
}
setMetadata(m: Module, c: CommandMeta): void {
@@ -35,20 +34,18 @@ export class DefaultModuleManager implements ModuleManager {
get(id: string) {
return this.moduleStore.commands.get(id);
}
set(id: string, path: string): void {
set(id: string, path: CommandModule): void {
this.moduleStore.commands.set(id, path);
}
//not tested
getPublishableCommands(): Promise<CommandModule[]> {
getPublishableCommands(): CommandModule[] {
const entries = this.moduleStore.commands.entries();
const publishable = 0b000000110;
return Promise.all(
Array.from(entries)
return Array.from(entries)
.filter(([id]) => {
const last_entry = id.at(-1);
return last_entry == 'B' || !(publishable & Number.parseInt(last_entry!));
})
.map(([, path]) => Files.importModule<CommandModule>(path)),
);
.map(([, path]) => path as CommandModule);
}
}

View File

@@ -17,10 +17,7 @@ import type { CommandModule, Module, Processed } from '../types/core-modules';
//TODO: refactor dispatchers so that it implements a strategy for each different type of payload?
export function dispatchMessage(module: Processed<CommandModule>, args: [Context, Args]) {
return {
module,
args,
};
return { module, args };
}
export function contextArgs(wrappable: Message | BaseInteraction, messageArgs?: string[]) {
@@ -85,14 +82,8 @@ export function createDispatcher(payload: {
args: [payload.event],
};
}
return {
module: payload.module,
args: contextArgs(payload.event),
};
return { module: payload.module, args: contextArgs(payload.event) };
}
default: return {
module: payload.module,
args: [payload.event],
};
default: return { module: payload.module, args: [payload.event] };
}
}

View File

@@ -8,9 +8,9 @@ import {
of,
throwError,
tap,
MonoTypeOperatorFunction,
catchError,
finalize,
map,
} from 'rxjs';
import {
Files,
@@ -21,16 +21,15 @@ import {
handleError,
SernError,
VoidResult,
resultPayload,
} from '../core/_internal';
import { Emitter, ErrorHandling, Logging, ModuleManager } from '../core';
import { Emitter, ErrorHandling, Logging, ModuleManager, PayloadType } from '../core';
import { contextArgs, createDispatcher } from './dispatchers';
import { ObservableInput, pipe } from 'rxjs';
import { SernEmitter } from '../core';
import { Err, Ok, Result } from 'ts-results-es';
import type { Awaitable } from '../types/utility';
import type { ControlPlugin } from '../types/core-plugin';
import type { AnyModule, CommandModule, Module, Processed } from '../types/core-modules';
import type { ImportPayload } from '../types/core';
import type { AnyModule, CommandMeta, CommandModule, Module, Processed } from '../types/core-modules';
import { disposeAll } from '../core/ioc/base';
function createGenericHandler<Source, Narrowed extends Source, Output>(
@@ -74,20 +73,14 @@ export function createInteractionHandler<T extends Interaction>(
const possibleIds = Id.reconstruct(event);
let fullPaths= possibleIds
.map(id => mg.get(id))
.filter((id): id is string => id !== undefined);
.filter((id): id is Module => id !== undefined);
if(fullPaths.length == 0) {
return Err.EMPTY;
}
const [ path ] = fullPaths;
return Files
.defaultModuleLoader<Processed<CommandModule>>(path)
.then(payload => Ok(createDispatcher({
module: payload.module,
event,
})));
},
);
return Ok(createDispatcher({ module: path as Processed<CommandModule>, event }));
});
}
export function createMessageHandler(
@@ -104,39 +97,37 @@ export function createMessageHandler(
return Err('Possibly undefined behavior: could not find a static id to resolve');
}
}
return Files
.defaultModuleLoader<Processed<CommandModule>>(fullPath)
.then(payload => {
const args = contextArgs(event, rest);
return Ok({ args, ...payload });
});
return Ok({ args: contextArgs(event, rest), module: fullPath as Processed<CommandModule> })
});
}
/**
* IMPURE SIDE EFFECT
* This function assigns remaining, incomplete data to each imported module.
*/
function assignDefaults<T extends Module>(
moduleManager: ModuleManager,
): MonoTypeOperatorFunction<ImportPayload<T>> {
return tap(({ module, absPath }) => {
module.name ??= Files.filename(absPath);
module.description ??= '...';
moduleManager.setMetadata(module, {
isClass: module.constructor.name === 'Function',
fullPath: absPath,
id: Id.create(module.name, module.type),
});
function assignDefaults() {
return map(({ module, absPath }) => {
const processed = {
name: module.name ?? Files.filename(absPath),
description: module.description ?? '...',
...module
}
return {
module: processed,
absPath,
metadata: {
isClass: module.constructor.name === 'Function',
fullPath: absPath,
id: Id.create(processed.name, module.type),
}
}
});
}
export function buildModules<T extends AnyModule>(
input: ObservableInput<string>,
moduleManager: ModuleManager,
) {
return Files
.buildModuleStream<Processed<T>>(input)
.pipe(assignDefaults(moduleManager));
.pipe(assignDefaults());
}
@@ -168,10 +159,10 @@ export function executeModule(
concatMap(() => Result.wrapAsync(async () => task())),
concatMap(result => {
if (result.isOk()) {
emitter.emit('module.activate', SernEmitter.success(module));
emitter.emit('module.activate', resultPayload(PayloadType.Success, module));
return EMPTY;
}
return throwError(() => SernEmitter.failure(module, result.error));
return throwError(() => resultPayload(PayloadType.Failure, module, result.error));
}),
);
@@ -218,14 +209,11 @@ export function callInitPlugins<T extends Processed<AnyModule>>(sernEmitter: Emi
createResultResolver({
createStream: args => from(args.module.plugins).pipe(callPlugin(args)),
onStop: (module: T) => {
sernEmitter.emit(
'module.register',
SernEmitter.failure(module, SernError.PluginFailure),
);
sernEmitter.emit('module.register', resultPayload(PayloadType.Failure, module, SernError.PluginFailure));
},
onNext: ({ module }) => {
sernEmitter.emit('module.register', SernEmitter.success(module));
return { module };
onNext: (payload) => {
sernEmitter.emit('module.register', resultPayload(PayloadType.Success, payload.module));
return payload as { module: T; metadata: CommandMeta };
},
}),
);
@@ -258,9 +246,9 @@ export function makeModuleExecutor<
);
}
export const handleCrash = (err: ErrorHandling, log?: Logging) =>
export const handleCrash = (err: ErrorHandling,sernemitter: Emitter, log?: Logging) =>
pipe(
catchError(handleError(err, log)),
catchError(handleError(err, sernemitter, log)),
finalize(() => {
log?.info({
message: 'A stream closed or reached end of lifetime',

View File

@@ -1,6 +1,6 @@
import { Interaction } from 'discord.js';
import { mergeMap, merge } from 'rxjs';
import { SernEmitter } from '../core';
import { PayloadType } from '../core';
import {
isAutocomplete,
isCommand,
@@ -9,6 +9,7 @@ import {
sharedEventStream,
SernError,
filterTap,
resultPayload,
} from '../core/_internal';
import { createInteractionHandler, executeModule, makeModuleExecutor } from './_internal';
import type { DependencyList } from '../types/ioc';
@@ -25,8 +26,8 @@ export function interactionHandler([emitter, err, log, modules, client]: Depende
);
return interactionHandler$
.pipe(
filterTap(e => emitter.emit('warning', SernEmitter.warning(e))),
filterTap(e => emitter.emit('warning', resultPayload(PayloadType.Warning, undefined, e))),
makeModuleExecutor(module =>
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))),
emitter.emit('module.activate', resultPayload(PayloadType.Failure, module, SernError.PluginFailure))),
mergeMap(payload => executeModule(emitter, log, err, payload)));
}

View File

@@ -1,7 +1,7 @@
import { mergeMap, EMPTY } from 'rxjs';
import type { Message } from 'discord.js';
import { SernEmitter } from '../core';
import { sharedEventStream, SernError, filterTap } from '../core/_internal';
import { PayloadType } from '../core';
import { sharedEventStream, SernError, filterTap, resultPayload } from '../core/_internal';
import { createMessageHandler, executeModule, makeModuleExecutor } from './_internal';
import type { DependencyList } from '../types/ioc';
@@ -38,9 +38,10 @@ export function messageHandler(
const msgCommands$ = handle(isNonBot(defaultPrefix));
return msgCommands$.pipe(
filterTap((e) => emitter.emit('warning', SernEmitter.warning(e))),
filterTap((e) => emitter.emit('warning', resultPayload(PayloadType.Warning, undefined, e))),
makeModuleExecutor(module => {
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure));
const result = resultPayload(PayloadType.Failure, module, SernError.PluginFailure);
emitter.emit('module.activate', result);
}),
mergeMap(payload => executeModule(emitter, log, err, payload)));
}

View File

@@ -19,7 +19,6 @@ const parseConfig = async (conf: Promise<Presence.Result>) => {
.pipe(scan(onRepeat, s),
startWith(s));
}
//take 1?
return of(s).pipe(take(1));
})
};
@@ -37,7 +36,7 @@ export const presenceHandler = (path: string, setPresence: SetPresence) => {
})
const module$ = from(presence);
return module$.pipe(
//compose:.
//compose:
//call the execute function, passing that result into parseConfig.
//concatMap resolves the promise, and passes it to the next concatMap.
concatMap(fn => parseConfig(fn())),

View File

@@ -1,29 +1,31 @@
import { ObservableInput, concat, first, fromEvent, ignoreElements, pipe } from 'rxjs';
import { ObservableInput, concat, first, fromEvent, ignoreElements, pipe, tap } from 'rxjs';
import { CommandType } from '../core/structures';
import { SernError } from '../core/_internal';
import { Result } from 'ts-results-es';
import { ModuleManager } from '../core/contracts';
import { Logging, ModuleManager } from '../core/contracts';
import { buildModules, callInitPlugins } from './_internal';
import * as assert from 'node:assert';
import * as util from 'node:util';
import type { DependencyList } from '../types/ioc';
import type { AnyModule, Processed } from '../types/core-modules';
import type { AnyModule, CommandMeta, Processed } from '../types/core-modules';
export function startReadyEvent(
[sEmitter, , , moduleManager, client]: DependencyList,
export function readyHandler(
[sEmitter, , log , moduleManager, client]: DependencyList,
allPaths: ObservableInput<string>,
) {
const ready$ = fromEvent(client!, 'ready').pipe(once());
return concat(ready$, buildModules<AnyModule>(allPaths, moduleManager))
//Todo: add module manager on on ready
const ready$ = fromEvent(client!, 'ready').pipe(once(log));
return concat(ready$, buildModules<AnyModule>(allPaths))
.pipe(callInitPlugins(sEmitter))
.subscribe(({ module }) => {
register(moduleManager, module)
.subscribe(({ module, metadata }) => {
register(moduleManager, module, metadata)
.expect(SernError.InvalidModuleType + ' ' + util.inspect(module));
});
}
const once = () => pipe(
const once = (log: Logging | undefined) => pipe(
tap(() => { log?.info({ message: "Waiting on discord client to be ready..." }) }),
first(),
ignoreElements())
@@ -31,20 +33,22 @@ const once = () => pipe(
function register<T extends Processed<AnyModule>>(
manager: ModuleManager,
module: T,
metadata:CommandMeta
): Result<void, void> {
const { id, fullPath } = manager.getMetadata(module)!;
manager.setMetadata(module, metadata)!;
const validModuleType = module.type >= 0 && module.type <= 1 << 10;
assert.ok(
validModuleType,
`Found ${module.name} at ${fullPath}, which does not have a valid type`,
//@ts-ignore
`Found ${module.name} at ${metadata.fullPath}, which does not have a valid type`,
);
if (module.type === CommandType.Both) {
module.alias?.forEach(a => manager.set(`${a}_B`, fullPath));
module.alias?.forEach(a => manager.set(`${a}_B`, module));
} else {
if(module.type === CommandType.Text){
module.alias?.forEach(a => manager.set(`${a}_T`, fullPath));
module.alias?.forEach(a => manager.set(`${a}_T`, module));
}
}
return Result.wrap(() => manager.set(id, fullPath));
return Result.wrap(() => manager.set(metadata.id, module));
}

View File

@@ -23,7 +23,7 @@ export function eventsHandler(
throw Error(SernError.InvalidModuleType + ' while creating event handler');
}
};
buildModules<EventModule>(allPaths, moduleManager)
buildModules<EventModule>(allPaths)
.pipe(
callInitPlugins(emitter),
map(intoDispatcher),
@@ -31,6 +31,6 @@ export function eventsHandler(
* Where all events are turned on
*/
mergeAll(),
handleCrash(err, log))
handleCrash(err, emitter, log))
.subscribe();
}

View File

@@ -46,12 +46,8 @@ export {
commandModule,
eventModule,
discordEvent,
EventExecutable,
CommandExecutable,
} from './core/modules';
export * as Presence from './core/presences'
export {
useContainerRaw
} from './core/_internal'

View File

@@ -1,11 +1,11 @@
import { handleCrash } from './handlers/_internal';
import callsites from 'callsites';
import { err, ok, Files } from './core/_internal';
import { Files } from './core/_internal';
import { merge } from 'rxjs';
import { Services } from './core/ioc';
import { Wrapper } from './types/core';
import { eventsHandler } from './handlers/user-defined-events';
import { startReadyEvent } from './handlers/ready-event';
import { readyHandler } from './handlers/ready-event';
import { messageHandler } from './handlers/message-event';
import { interactionHandler } from './handlers/interaction-event';
import { presenceHandler } from './handlers/presence';
@@ -23,25 +23,30 @@ import { Client } from 'discord.js';
* })
* ```
*/
export function init(maybeWrapper: Wrapper | 'file') {
const startTime = performance.now();
const wrapper = Files.loadConfig(maybeWrapper);
const dependencies = useDependencies();
const dependencies = Services('@sern/emitter',
'@sern/errors',
'@sern/logger',
'@sern/modules',
'@sern/client');
const logger = dependencies[2],
errorHandler = dependencies[1];
const wrapper = Files.loadConfig(maybeWrapper, logger);
if (wrapper.events !== undefined) {
eventsHandler(dependencies, Files.getFullPathTree(wrapper.events));
}
const initCallsite = callsites()[1].getFileName();
const presencePath = Files.shouldHandle(initCallsite!, "presence");
//Ready event: load all modules and when finished, time should be taken and logged
startReadyEvent(dependencies, Files.getFullPathTree(wrapper.commands))
readyHandler(dependencies, Files.getFullPathTree(wrapper.commands))
.add(() => {
logger?.info({ message: "Client signaled ready, registering modules" });
const time = ((performance.now() - startTime) / 1000).toFixed(2);
dependencies[0].emit('modulesLoaded');
logger?.info({ message: `sern: registered all modules in ${time} s`, });
logger?.info({ message: `sern: registered in ${time} s`, });
if(presencePath.exists) {
const setPresence = async (p: any) => {
return (dependencies[4] as Client).user?.setPresence(p);
@@ -53,17 +58,5 @@ export function init(maybeWrapper: Wrapper | 'file') {
const messages$ = messageHandler(dependencies, wrapper.defaultPrefix);
const interactions$ = interactionHandler(dependencies);
// listening to the message stream and interaction stream
merge(messages$, interactions$).pipe(handleCrash(errorHandler, logger)).subscribe();
merge(messages$, interactions$).pipe(handleCrash(errorHandler, dependencies[0], logger)).subscribe();
}
function useDependencies() {
return Services(
'@sern/emitter',
'@sern/errors',
'@sern/logger',
'@sern/modules',
'@sern/client',
);
}

View File

@@ -20,7 +20,6 @@ import { AnyCommandPlugin, AnyEventPlugin, ControlPlugin, InitPlugin } from './c
import { Awaitable, Args, SlashOptions, SernEventsMapping } from './utility';
export interface CommandMeta {
fullPath: string;
id: string;

View File

@@ -33,9 +33,9 @@ import type {
TextCommand,
UserSelectCommand,
} from './core-modules';
import { Args, Awaitable, Payload, SlashOptions } from './utility';
import { CommandType, Context, EventType, PluginType } from '../core';
import {
import type { Args, Awaitable, Payload, SlashOptions } from './utility';
import type { CommandType, Context, EventType, PluginType } from '../core';
import type {
ButtonInteraction,
ChannelSelectMenuInteraction,
ClientEvents,

View File

@@ -26,11 +26,15 @@ export type DependencyList = [
export interface CoreDependencies {
'@sern/client': () => Contracts.Emitter;
'@sern/logger'?: () => Contracts.Logging;
'@sern/emitter': () => Contracts.Emitter;
/**
* @deprecated
* Will be removed and turned internal
*/
'@sern/store': () => Contracts.CoreModuleStore;
'@sern/modules': () => Contracts.ModuleManager;
'@sern/errors': () => Contracts.ErrorHandling;
'@sern/logger'?: () => Contracts.Logging;
}
export type DependencyFromKey<T extends keyof Dependencies> = Dependencies[T];
@@ -39,8 +43,13 @@ export type IntoDependencies<Tuple extends [...any[]]> = {
[Index in keyof Tuple]: UnpackFunction<NonNullable<DependencyFromKey<Tuple[Index]>>>; //Unpack and make NonNullable
} & { length: Tuple['length'] };
/**
* @deprecated This old signature will be incompatible with future versions of sern.
*/
export interface DependencyConfiguration {
//@deprecated. Loggers will always be included in the future
/*
* @deprecated. Loggers will be opt-in the future
*/
exclude?: Set<'@sern/logger'>;
build: (
root: Container<Omit<CoreDependencies, '@sern/client'>, {}>,

View File

@@ -18,7 +18,7 @@ export type Args = ParseType<{ text: string[]; slash: SlashOptions }>;
export interface SernEventsMapping {
'module.register': [Payload];
'module.activate': [Payload];
error: [Payload];
error: [{ type: PayloadType.Failure; module?: AnyModule; reason: string | Error }];
warning: [Payload];
modulesLoaded: [never?];
}
@@ -26,8 +26,7 @@ export interface SernEventsMapping {
export type Payload =
| { type: PayloadType.Success; module: AnyModule }
| { type: PayloadType.Failure; module?: AnyModule; reason: string | Error }
| { type: PayloadType.Warning; reason: string };
| { type: PayloadType.Warning; module: undefined; reason: string };
export type ReplyOptions = string | Omit<InteractionReplyOptions, 'fetchReply'> | MessageReplyOptions;

64
test/core/id.test.ts Normal file
View File

@@ -0,0 +1,64 @@
import { CommandType } from '../../src/core';
import * as Id from '../../src/core/id'
import { expect, test } from 'vitest'
test('id -> Text', () => {
const bothCmdId = Id.create("ping", CommandType.Text)
expect(bothCmdId).toBe("ping_T")
})
test('id -> Both', () => {
const bothCmdId = Id.create("ping", CommandType.Both)
expect(bothCmdId).toBe("ping_B")
})
test('id -> CtxMsg', () => {
const bothCmdId = Id.create("ping", CommandType.CtxMsg)
expect(bothCmdId).toBe("ping_A3")
})
test('id -> CtxUsr', () => {
const bothCmdId = Id.create("ping", CommandType.CtxUser)
expect(bothCmdId).toBe("ping_A2")
})
test('id -> Modal', () => {
const modal = Id.create("my-modal", CommandType.Modal)
expect(modal).toBe("my-modal_M");
})
test('id -> Button', () => {
const modal = Id.create("my-button", CommandType.Button)
expect(modal).toBe("my-button_C2");
})
test('id -> Slash', () => {
const modal = Id.create("myslash", CommandType.Slash)
expect(modal).toBe("myslash_A1");
})
test('id -> StringSelect', () => {
const modal = Id.create("mystringselect", CommandType.StringSelect)
expect(modal).toBe("mystringselect_C3");
})
test('id -> UserSelect', () => {
const modal = Id.create("myuserselect", CommandType.UserSelect)
expect(modal).toBe("myuserselect_C5");
})
test('id -> RoleSelect', () => {
const modal = Id.create("myroleselect", CommandType.RoleSelect)
expect(modal).toBe("myroleselect_C6");
})
test('id -> MentionSelect', () => {
const modal = Id.create("mymentionselect", CommandType.MentionableSelect)
expect(modal).toBe("mymentionselect_C7");
})
test('id -> ChannelSelect', () => {
const modal = Id.create("mychannelselect", CommandType.ChannelSelect)
expect(modal).toBe("mychannelselect_C8");
})

View File

@@ -1,12 +1,13 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { CoreContainer } from '../../src/core/ioc/container';
import { EventEmitter } from 'events';
import { DefaultLogging, Disposable, Init, Logging } from '../../src/core';
import { DefaultLogging, Disposable, Emitter, Init, Logging } from '../../src/core';
import { CoreDependencies } from '../../src/types/ioc';
describe('ioc container', () => {
let container: CoreContainer<{}> = new CoreContainer();
let dependency: Logging & Init & Disposable;
let dependency2: Emitter
beforeEach(() => {
dependency = {
init: vi.fn(),
@@ -16,6 +17,11 @@ describe('ioc container', () => {
debug(): void {},
dispose: vi.fn()
};
dependency2 = {
addListener: vi.fn(),
removeListener: vi.fn(),
emit: vi.fn()
};
container = new CoreContainer();
});
const wait = (seconds: number) => new Promise((resolve) => setTimeout(resolve, seconds));
@@ -83,4 +89,25 @@ describe('ioc container', () => {
container.ready();
expect(dependency.init).toHaveBeenCalledTimes(0);
});
it('should init dependency depending on something else', () => {
container.add({ '@sern/client': dependency2 });
container.upsert((cntr) => ({
'@sern/logger': dependency
}));
container.ready();
expect(dependency.init).toHaveBeenCalledTimes(1);
})
it('should detect a key already exists', () => {
container.add({ '@sern/client': dependency2 });
expect(container.hasKey('@sern/client')).toBeTruthy()
})
it('should detect a key already exists', () => {
container.add({ '@sern/client': () => dependency2 });
expect(container.hasKey('@sern/client')).toBeTruthy()
})
});

View File

@@ -74,4 +74,7 @@ describe('services', () => {
expect(consoleMock).toHaveBeenCalledOnce();
expect(consoleMock).toHaveBeenLastCalledWith({ message: 'error' });
});
});

312
yarn.lock
View File

@@ -417,9 +417,16 @@ __metadata:
languageName: node
linkType: hard
"@eslint/eslintrc@npm:^2.0.2":
version: 2.1.2
resolution: "@eslint/eslintrc@npm:2.1.2"
"@eslint-community/regexpp@npm:^4.6.1":
version: 4.10.0
resolution: "@eslint-community/regexpp@npm:4.10.0"
checksum: 2a6e345429ea8382aaaf3a61f865cae16ed44d31ca917910033c02dc00d505d939f10b81e079fa14d43b51499c640138e153b7e40743c4c094d9df97d4e56f7b
languageName: node
linkType: hard
"@eslint/eslintrc@npm:^2.1.4":
version: 2.1.4
resolution: "@eslint/eslintrc@npm:2.1.4"
dependencies:
ajv: ^6.12.4
debug: ^4.3.2
@@ -430,21 +437,21 @@ __metadata:
js-yaml: ^4.1.0
minimatch: ^3.1.2
strip-json-comments: ^3.1.1
checksum: bc742a1e3b361f06fedb4afb6bf32cbd27171292ef7924f61c62f2aed73048367bcc7ac68f98c06d4245cd3fabc43270f844e3c1699936d4734b3ac5398814a7
checksum: 10957c7592b20ca0089262d8c2a8accbad14b4f6507e35416c32ee6b4dbf9cad67dfb77096bbd405405e9ada2b107f3797fe94362e1c55e0b09d6e90dd149127
languageName: node
linkType: hard
"@eslint/js@npm:8.39.0":
version: 8.39.0
resolution: "@eslint/js@npm:8.39.0"
checksum: 63fe36e2bfb5ff5705d1c1a8ccecd8eb2f81d9af239713489e767b0e398759c0177fcc75ad62581d02942f2776903a8496d5fae48dc2d883dff1b96fcb19e9e2
"@eslint/js@npm:8.57.0":
version: 8.57.0
resolution: "@eslint/js@npm:8.57.0"
checksum: 315dc65b0e9893e2bff139bddace7ea601ad77ed47b4550e73da8c9c2d2766c7a575c3cddf17ef85b8fd6a36ff34f91729d0dcca56e73ca887c10df91a41b0bb
languageName: node
linkType: hard
"@faker-js/faker@npm:^8.0.1":
version: 8.0.2
resolution: "@faker-js/faker@npm:8.0.2"
checksum: cf73daf9a50397eb0b3f04a7ef3fbb6f54acc026b167707136a7e58a517fd805a46c9e8c5f017f3022f104a4ff984765daaeee2cb98b3c34646db05c2acad441
version: 8.4.1
resolution: "@faker-js/faker@npm:8.4.1"
checksum: d802d531f8929562715adc279cfec763c9a4bc596ec67b0ce43fd0ae61b285d2b0eec6f1f4aa852452a63721a842fe7e81926dce7bd92acca94b01e2a1f55f5a
languageName: node
linkType: hard
@@ -455,14 +462,14 @@ __metadata:
languageName: node
linkType: hard
"@humanwhocodes/config-array@npm:^0.11.8":
version: 0.11.11
resolution: "@humanwhocodes/config-array@npm:0.11.11"
"@humanwhocodes/config-array@npm:^0.11.14":
version: 0.11.14
resolution: "@humanwhocodes/config-array@npm:0.11.14"
dependencies:
"@humanwhocodes/object-schema": ^1.2.1
debug: ^4.1.1
"@humanwhocodes/object-schema": ^2.0.2
debug: ^4.3.1
minimatch: ^3.0.5
checksum: db84507375ab77b8ffdd24f498a5b49ad6b64391d30dd2ac56885501d03964d29637e05b1ed5aefa09d57ac667e28028bc22d2da872bfcd619652fbdb5f4ca19
checksum: 861ccce9eaea5de19546653bccf75bf09fe878bc39c3aab00aeee2d2a0e654516adad38dd1098aab5e3af0145bbcbf3f309bdf4d964f8dab9dcd5834ae4c02f2
languageName: node
linkType: hard
@@ -473,10 +480,10 @@ __metadata:
languageName: node
linkType: hard
"@humanwhocodes/object-schema@npm:^1.2.1":
version: 1.2.1
resolution: "@humanwhocodes/object-schema@npm:1.2.1"
checksum: a824a1ec31591231e4bad5787641f59e9633827d0a2eaae131a288d33c9ef0290bd16fda8da6f7c0fcb014147865d12118df10db57f27f41e20da92369fcb3f1
"@humanwhocodes/object-schema@npm:^2.0.2":
version: 2.0.2
resolution: "@humanwhocodes/object-schema@npm:2.0.2"
checksum: 2fc11503361b5fb4f14714c700c02a3f4c7c93e9acd6b87a29f62c522d90470f364d6161b03d1cc618b979f2ae02aed1106fd29d302695d8927e2fc8165ba8ee
languageName: node
linkType: hard
@@ -625,18 +632,17 @@ __metadata:
dependencies:
"@faker-js/faker": ^8.0.1
"@types/node": ^18.15.11
"@typescript-eslint/eslint-plugin": 5.58.0
"@typescript-eslint/parser": 5.59.1
"@typescript-eslint/eslint-plugin": 5.62.0
"@typescript-eslint/parser": 5.62.0
callsites: ^3.1.0
discord.js: ^14.11.0
esbuild: ^0.17.0
eslint: 8.39.0
eslint: 8.57.0
iti: ^0.6.0
prettier: 2.8.8
rxjs: ^7.8.0
ts-results-es: ^4.0.0
tsup: ^6.7.0
typescript: 5.0.2
typescript: 5.4.3
vitest: latest
languageName: unknown
linkType: soft
@@ -679,16 +685,20 @@ __metadata:
linkType: hard
"@types/node@npm:*":
version: 20.5.9
resolution: "@types/node@npm:20.5.9"
checksum: 717490e94131722144878b4ca1a963ede1673bb8f2ef78c2f5b50b918df6dc9b35e7f8283e5c2a7a9f137730f7c08dc6228e53d4494a94c9ee16881e6ce6caed
version: 20.11.30
resolution: "@types/node@npm:20.11.30"
dependencies:
undici-types: ~5.26.4
checksum: 7597767aa3e44b0f1bf62efa522dd17741135f283c11de6a20ead8bb7016fb4999cc30adcd8f2bb29ebb216906c92894346ccd187de170927dc1e212d2c07c81
languageName: node
linkType: hard
"@types/node@npm:^18.15.11":
version: 18.17.14
resolution: "@types/node@npm:18.17.14"
checksum: f96ce1e588426a26cf82440193084f8bbab47bfb3c2e668cf174095f99ce808a20654b2137448c7e88cfd7b6c2b8521ffb6f714f521b3502ac595a0df0bff679
version: 18.19.26
resolution: "@types/node@npm:18.19.26"
dependencies:
undici-types: ~5.26.4
checksum: d72d4e7e520206a2a05cb3e03a73696fc3bdcdc6ba5330a75cfef4818cb137b260c32dfe85e8b4ea28e8fe92f1d1497e26336c607254c5eaf47032a1b1c8bb6e
languageName: node
linkType: hard
@@ -717,16 +727,16 @@ __metadata:
languageName: node
linkType: hard
"@typescript-eslint/eslint-plugin@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.58.0"
"@typescript-eslint/eslint-plugin@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/eslint-plugin@npm:5.62.0"
dependencies:
"@eslint-community/regexpp": ^4.4.0
"@typescript-eslint/scope-manager": 5.58.0
"@typescript-eslint/type-utils": 5.58.0
"@typescript-eslint/utils": 5.58.0
"@typescript-eslint/scope-manager": 5.62.0
"@typescript-eslint/type-utils": 5.62.0
"@typescript-eslint/utils": 5.62.0
debug: ^4.3.4
grapheme-splitter: ^1.0.4
graphemer: ^1.4.0
ignore: ^5.2.0
natural-compare-lite: ^1.4.0
semver: ^7.3.7
@@ -737,53 +747,43 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: e5d76d43c466ebd4b552e3307eff72ab5ae8a0c09a1d35fa13b62769ac3336df94d9281728ab5aafd2c14a0a644133583edcd708fce60a9a82df1db3ca3b8e14
checksum: fc104b389c768f9fa7d45a48c86d5c1ad522c1d0512943e782a56b1e3096b2cbcc1eea3fcc590647bf0658eef61aac35120a9c6daf979bf629ad2956deb516a1
languageName: node
linkType: hard
"@typescript-eslint/parser@npm:5.59.1":
version: 5.59.1
resolution: "@typescript-eslint/parser@npm:5.59.1"
"@typescript-eslint/parser@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/parser@npm:5.62.0"
dependencies:
"@typescript-eslint/scope-manager": 5.59.1
"@typescript-eslint/types": 5.59.1
"@typescript-eslint/typescript-estree": 5.59.1
"@typescript-eslint/scope-manager": 5.62.0
"@typescript-eslint/types": 5.62.0
"@typescript-eslint/typescript-estree": 5.62.0
debug: ^4.3.4
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
peerDependenciesMeta:
typescript:
optional: true
checksum: d324d32a69e06ab12aacb72cd3e2a8eb8ade6c2a4d4e6bb013941588a675e818a8ebd973bef1cd818da6a76eb00908bf66d84ef214c3f015dfcb40f8067a335e
checksum: d168f4c7f21a7a63f47002e2d319bcbb6173597af5c60c1cf2de046b46c76b4930a093619e69faf2d30214c29ab27b54dcf1efc7046a6a6bd6f37f59a990e752
languageName: node
linkType: hard
"@typescript-eslint/scope-manager@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/scope-manager@npm:5.58.0"
"@typescript-eslint/scope-manager@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/scope-manager@npm:5.62.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/visitor-keys": 5.58.0
checksum: f0d3df5cc3c461fe63ef89ad886b53c239cc7c1d9061d83d8a9d9c8e087e5501eac84bebff8a954728c17ccea191f235686373d54d2b8b6370af2bcf2b18e062
"@typescript-eslint/types": 5.62.0
"@typescript-eslint/visitor-keys": 5.62.0
checksum: 6062d6b797fe1ce4d275bb0d17204c827494af59b5eaf09d8a78cdd39dadddb31074dded4297aaf5d0f839016d601032857698b0e4516c86a41207de606e9573
languageName: node
linkType: hard
"@typescript-eslint/scope-manager@npm:5.59.1":
version: 5.59.1
resolution: "@typescript-eslint/scope-manager@npm:5.59.1"
"@typescript-eslint/type-utils@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/type-utils@npm:5.62.0"
dependencies:
"@typescript-eslint/types": 5.59.1
"@typescript-eslint/visitor-keys": 5.59.1
checksum: ae7758181d0f18d1ad20abf95164553fa98c20410968d538ac7abd430ec59f69e30d4da16ad968d029feced1ed49abc65daf6685c996eb4529d798e8320204ff
languageName: node
linkType: hard
"@typescript-eslint/type-utils@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/type-utils@npm:5.58.0"
dependencies:
"@typescript-eslint/typescript-estree": 5.58.0
"@typescript-eslint/utils": 5.58.0
"@typescript-eslint/typescript-estree": 5.62.0
"@typescript-eslint/utils": 5.62.0
debug: ^4.3.4
tsutils: ^3.21.0
peerDependencies:
@@ -791,30 +791,23 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 803f24daed185152bf86952d4acebb5ea18ff03db5f28750368edf76fdea46b4b0f8803ae0b61c0282b47181c9977113457b16e33d5d2cb33b13855f55c5e5b2
checksum: fc41eece5f315dfda14320be0da78d3a971d650ea41300be7196934b9715f3fe1120a80207551eb71d39568275dbbcf359bde540d1ca1439d8be15e9885d2739
languageName: node
linkType: hard
"@typescript-eslint/types@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/types@npm:5.58.0"
checksum: 8622a73d73220c4a7111537825f488c0271272032a1d4e129dc722bc6e8b3ec84f64469b2ca3b8dae7da3a9c18953ce1449af51f5f757dad60835eb579ad1d2c
"@typescript-eslint/types@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/types@npm:5.62.0"
checksum: 48c87117383d1864766486f24de34086155532b070f6264e09d0e6139449270f8a9559cfef3c56d16e3bcfb52d83d42105d61b36743626399c7c2b5e0ac3b670
languageName: node
linkType: hard
"@typescript-eslint/types@npm:5.59.1":
version: 5.59.1
resolution: "@typescript-eslint/types@npm:5.59.1"
checksum: 40ea7ccf59c4951797d3761e53c866a5979e07fbdabef9dc07d3a3f625a99d4318d5329ae8e628cdfdc0bb9bb6e6d8dfb740f33c7bf318e63fa0a863b9ae85c7
languageName: node
linkType: hard
"@typescript-eslint/typescript-estree@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/typescript-estree@npm:5.58.0"
"@typescript-eslint/typescript-estree@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/typescript-estree@npm:5.62.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/visitor-keys": 5.58.0
"@typescript-eslint/types": 5.62.0
"@typescript-eslint/visitor-keys": 5.62.0
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
@@ -823,63 +816,42 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 51b668ec858db0c040a71dff526273945cee4ba5a9b240528d503d02526685882d900cf071c6636a4d9061ed3fd4a7274f7f1a23fba55c4b48b143344b4009c7
checksum: 3624520abb5807ed8f57b1197e61c7b1ed770c56dfcaca66372d584ff50175225798bccb701f7ef129d62c5989070e1ee3a0aa2d84e56d9524dcf011a2bb1a52
languageName: node
linkType: hard
"@typescript-eslint/typescript-estree@npm:5.59.1":
version: 5.59.1
resolution: "@typescript-eslint/typescript-estree@npm:5.59.1"
dependencies:
"@typescript-eslint/types": 5.59.1
"@typescript-eslint/visitor-keys": 5.59.1
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
semver: ^7.3.7
tsutils: ^3.21.0
peerDependenciesMeta:
typescript:
optional: true
checksum: e33081937225f38e717ac2f9e90c4a8c6b71b701923eea3e03be76d8c466f0d3c6a4ec1d65c9fc1da4f1989416d386305353c5b53aa736d3af9503061001e3eb
languageName: node
linkType: hard
"@typescript-eslint/utils@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/utils@npm:5.58.0"
"@typescript-eslint/utils@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/utils@npm:5.62.0"
dependencies:
"@eslint-community/eslint-utils": ^4.2.0
"@types/json-schema": ^7.0.9
"@types/semver": ^7.3.12
"@typescript-eslint/scope-manager": 5.58.0
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/typescript-estree": 5.58.0
"@typescript-eslint/scope-manager": 5.62.0
"@typescript-eslint/types": 5.62.0
"@typescript-eslint/typescript-estree": 5.62.0
eslint-scope: ^5.1.1
semver: ^7.3.7
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
checksum: c618ae67963ecf96b1492c09afaeb363f542f0d6780bcac4af3c26034e3b20034666b2d523aa94821df813aafb57a0b150a7d5c2224fe8257452ad1de2237a58
checksum: ee9398c8c5db6d1da09463ca7bf36ed134361e20131ea354b2da16a5fdb6df9ba70c62a388d19f6eebb421af1786dbbd79ba95ddd6ab287324fc171c3e28d931
languageName: node
linkType: hard
"@typescript-eslint/visitor-keys@npm:5.58.0":
version: 5.58.0
resolution: "@typescript-eslint/visitor-keys@npm:5.58.0"
"@typescript-eslint/visitor-keys@npm:5.62.0":
version: 5.62.0
resolution: "@typescript-eslint/visitor-keys@npm:5.62.0"
dependencies:
"@typescript-eslint/types": 5.58.0
"@typescript-eslint/types": 5.62.0
eslint-visitor-keys: ^3.3.0
checksum: ab2d1f37660559954c840429ef78bbf71834063557e3e68e435005b4987970b9356fdf217ead53f7a57f66f5488dc478062c5c44bf17053a8bf041733539b98f
checksum: 976b05d103fe8335bef5c93ad3f76d781e3ce50329c0243ee0f00c0fcfb186c81df50e64bfdd34970148113f8ade90887f53e3c4938183afba830b4ba8e30a35
languageName: node
linkType: hard
"@typescript-eslint/visitor-keys@npm:5.59.1":
version: 5.59.1
resolution: "@typescript-eslint/visitor-keys@npm:5.59.1"
dependencies:
"@typescript-eslint/types": 5.59.1
eslint-visitor-keys: ^3.3.0
checksum: f98e399147310cad67de718a8a6336f053d46753bade380c89ddac3dd49512555c3f613636b255ce0b5e2b004654d1c167eb5e53fc8085148b637a5afc20cdd8
"@ungap/structured-clone@npm:^1.2.0":
version: 1.2.0
resolution: "@ungap/structured-clone@npm:1.2.0"
checksum: 4f656b7b4672f2ce6e272f2427d8b0824ed11546a601d8d5412b9d7704e83db38a8d9f402ecdf2b9063fc164af842ad0ec4a55819f621ed7e7ea4d1efcc74524
languageName: node
linkType: hard
@@ -1003,7 +975,7 @@ __metadata:
languageName: node
linkType: hard
"ajv@npm:^6.10.0, ajv@npm:^6.12.4":
"ajv@npm:^6.12.4":
version: 6.12.6
resolution: "ajv@npm:6.12.6"
dependencies:
@@ -1316,7 +1288,7 @@ __metadata:
languageName: node
linkType: hard
"debug@npm:4, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4":
"debug@npm:4, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4":
version: 4.3.4
resolution: "debug@npm:4.3.4"
dependencies:
@@ -1449,7 +1421,7 @@ __metadata:
languageName: node
linkType: hard
"esbuild@npm:^0.17.0, esbuild@npm:^0.17.6":
"esbuild@npm:^0.17.6":
version: 0.17.19
resolution: "esbuild@npm:0.17.19"
dependencies:
@@ -1620,7 +1592,7 @@ __metadata:
languageName: node
linkType: hard
"eslint-scope@npm:^7.2.0":
"eslint-scope@npm:^7.2.2":
version: 7.2.2
resolution: "eslint-scope@npm:7.2.2"
dependencies:
@@ -1630,33 +1602,34 @@ __metadata:
languageName: node
linkType: hard
"eslint-visitor-keys@npm:^3.3.0, eslint-visitor-keys@npm:^3.4.0, eslint-visitor-keys@npm:^3.4.1":
"eslint-visitor-keys@npm:^3.3.0, eslint-visitor-keys@npm:^3.4.1, eslint-visitor-keys@npm:^3.4.3":
version: 3.4.3
resolution: "eslint-visitor-keys@npm:3.4.3"
checksum: 36e9ef87fca698b6fd7ca5ca35d7b2b6eeaaf106572e2f7fd31c12d3bfdaccdb587bba6d3621067e5aece31c8c3a348b93922ab8f7b2cbc6aaab5e1d89040c60
languageName: node
linkType: hard
"eslint@npm:8.39.0":
version: 8.39.0
resolution: "eslint@npm:8.39.0"
"eslint@npm:8.57.0":
version: 8.57.0
resolution: "eslint@npm:8.57.0"
dependencies:
"@eslint-community/eslint-utils": ^4.2.0
"@eslint-community/regexpp": ^4.4.0
"@eslint/eslintrc": ^2.0.2
"@eslint/js": 8.39.0
"@humanwhocodes/config-array": ^0.11.8
"@eslint-community/regexpp": ^4.6.1
"@eslint/eslintrc": ^2.1.4
"@eslint/js": 8.57.0
"@humanwhocodes/config-array": ^0.11.14
"@humanwhocodes/module-importer": ^1.0.1
"@nodelib/fs.walk": ^1.2.8
ajv: ^6.10.0
"@ungap/structured-clone": ^1.2.0
ajv: ^6.12.4
chalk: ^4.0.0
cross-spawn: ^7.0.2
debug: ^4.3.2
doctrine: ^3.0.0
escape-string-regexp: ^4.0.0
eslint-scope: ^7.2.0
eslint-visitor-keys: ^3.4.0
espree: ^9.5.1
eslint-scope: ^7.2.2
eslint-visitor-keys: ^3.4.3
espree: ^9.6.1
esquery: ^1.4.2
esutils: ^2.0.2
fast-deep-equal: ^3.1.3
@@ -1664,30 +1637,27 @@ __metadata:
find-up: ^5.0.0
glob-parent: ^6.0.2
globals: ^13.19.0
grapheme-splitter: ^1.0.4
graphemer: ^1.4.0
ignore: ^5.2.0
import-fresh: ^3.0.0
imurmurhash: ^0.1.4
is-glob: ^4.0.0
is-path-inside: ^3.0.3
js-sdsl: ^4.1.4
js-yaml: ^4.1.0
json-stable-stringify-without-jsonify: ^1.0.1
levn: ^0.4.1
lodash.merge: ^4.6.2
minimatch: ^3.1.2
natural-compare: ^1.4.0
optionator: ^0.9.1
optionator: ^0.9.3
strip-ansi: ^6.0.1
strip-json-comments: ^3.1.0
text-table: ^0.2.0
bin:
eslint: bin/eslint.js
checksum: d7a074ff326e7ea482500dc0427a7d4b0260460f0f812d19b46b1cca681806b67309f23da9d17cd3de8eb74dd3c14cb549c4d58b05b140564d14cc1a391122a0
checksum: 3a48d7ff85ab420a8447e9810d8087aea5b1df9ef68c9151732b478de698389ee656fd895635b5f2871c89ee5a2652b3f343d11e9db6f8486880374ebc74a2d9
languageName: node
linkType: hard
"espree@npm:^9.5.1, espree@npm:^9.6.0":
"espree@npm:^9.6.0, espree@npm:^9.6.1":
version: 9.6.1
resolution: "espree@npm:9.6.1"
dependencies:
@@ -2025,10 +1995,10 @@ __metadata:
languageName: node
linkType: hard
"grapheme-splitter@npm:^1.0.4":
version: 1.0.4
resolution: "grapheme-splitter@npm:1.0.4"
checksum: 0c22ec54dee1b05cd480f78cf14f732cb5b108edc073572c4ec205df4cd63f30f8db8025afc5debc8835a8ddeacf648a1c7992fe3dcd6ad38f9a476d84906620
"graphemer@npm:^1.4.0":
version: 1.4.0
resolution: "graphemer@npm:1.4.0"
checksum: bab8f0be9b568857c7bec9fda95a89f87b783546d02951c40c33f84d05bb7da3fd10f863a9beb901463669b6583173a8c8cc6d6b306ea2b9b9d5d3d943c3a673
languageName: node
linkType: hard
@@ -2106,7 +2076,7 @@ __metadata:
languageName: node
linkType: hard
"import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1":
"import-fresh@npm:^3.2.1":
version: 3.3.0
resolution: "import-fresh@npm:3.3.0"
dependencies:
@@ -2250,13 +2220,6 @@ __metadata:
languageName: node
linkType: hard
"js-sdsl@npm:^4.1.4":
version: 4.4.2
resolution: "js-sdsl@npm:4.4.2"
checksum: ba705adc1788bf3c6f6c8e5077824f2bb4f0acab5a984420ce5cc492c7fff3daddc26335ad2c9a67d4f5e3241ec790f9e5b72a625adcf20cf321d2fd85e62b8b
languageName: node
linkType: hard
"js-yaml@npm:^4.1.0":
version: 4.1.0
resolution: "js-yaml@npm:4.1.0"
@@ -2745,7 +2708,7 @@ __metadata:
languageName: node
linkType: hard
"optionator@npm:^0.9.1":
"optionator@npm:^0.9.3":
version: 0.9.3
resolution: "optionator@npm:0.9.3"
dependencies:
@@ -3265,7 +3228,7 @@ __metadata:
languageName: node
linkType: hard
"strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1":
"strip-json-comments@npm:^3.1.1":
version: 3.1.1
resolution: "strip-json-comments@npm:3.1.1"
checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443
@@ -3410,9 +3373,9 @@ __metadata:
linkType: hard
"ts-results-es@npm:^4.0.0":
version: 4.0.0
resolution: "ts-results-es@npm:4.0.0"
checksum: 32a7059491e36d06c5a1084fe9be8021a0beb2d94a94b0c3fa85dc3e96561bf34fb8fd60ebe661064c9fc2bafcf437b6b65f119e8d7497af7f76cda9d9a2a945
version: 4.1.0
resolution: "ts-results-es@npm:4.1.0"
checksum: c04fd553a37930d234b7d7d31a4c3ea4396e47986a34e528f572af93d070db5cc64f6fcf0587f3c2f9b7061132427e89033572706bfdda112a29929439c5ec46
languageName: node
linkType: hard
@@ -3500,23 +3463,23 @@ __metadata:
languageName: node
linkType: hard
"typescript@npm:5.0.2":
version: 5.0.2
resolution: "typescript@npm:5.0.2"
"typescript@npm:5.4.3":
version: 5.4.3
resolution: "typescript@npm:5.4.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: bef1dcd166acfc6934b2ec4d72f93edb8961a5fab36b8dd2aaf6f4f4cd5c0210f2e0850aef4724f3b4913d5aef203a94a28ded731b370880c8bcff7e4ff91fc1
checksum: d74d731527e35e64d8d2dcf2f897cf8cfbc3428be0ad7c48434218ba4ae41239f53be7c90714089db1068c05cae22436af2ecba71fd36ecc5e7a9118af060198
languageName: node
linkType: hard
"typescript@patch:typescript@5.0.2#~builtin<compat/typescript>":
version: 5.0.2
resolution: "typescript@patch:typescript@npm%3A5.0.2#~builtin<compat/typescript>::version=5.0.2&hash=b5f058"
"typescript@patch:typescript@5.4.3#~builtin<compat/typescript>":
version: 5.4.3
resolution: "typescript@patch:typescript@npm%3A5.4.3#~builtin<compat/typescript>::version=5.4.3&hash=5adc0c"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 0411be9e19bf6a547d574b3261fa8598f55a5243123f2a50a79b0dc15a017abbf541f15b8b43331294e409cc978e548ac5ae4e0c5b98ba5ae98029304de047be
checksum: 523ec29bc308b4ca0cec9a139ac08a27939891d8ad620d249cf5e1a35454e37cd7bb52613a1884f1206aa11d2fb1c4c83fb9e939bde542aaa8527ba818cb8177
languageName: node
linkType: hard
@@ -3527,6 +3490,13 @@ __metadata:
languageName: node
linkType: hard
"undici-types@npm:~5.26.4":
version: 5.26.5
resolution: "undici-types@npm:5.26.5"
checksum: 3192ef6f3fd5df652f2dc1cd782b49d6ff14dc98e5dced492aa8a8c65425227da5da6aafe22523c67f035a272c599bb89cfe803c1db6311e44bed3042fc25487
languageName: node
linkType: hard
"undici@npm:5.27.2":
version: 5.27.2
resolution: "undici@npm:5.27.2"