Skip to content

Commit

Permalink
chore: bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
didinele committed Jun 20, 2024
1 parent 3cb7b3b commit 1370962
Show file tree
Hide file tree
Showing 20 changed files with 3,215 additions and 2,696 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc.json

This file was deleted.

62 changes: 62 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import common from 'eslint-config-neon/flat/common.js';
import node from 'eslint-config-neon/flat/node.js';
import prettier from 'eslint-config-neon/flat/prettier.js';
import typescript from 'eslint-config-neon/flat/typescript.js';
import merge from 'lodash.merge';
import tseslint from 'typescript-eslint';

const commonFiles = '{js,mjs,cjs,ts,mts,cts,jsx,tsx}';

const commonRuleset = merge(...common, {
files: [`**/*${commonFiles}`],
rules: {
'no-eq-null': ['off'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
},
});

const nodeRuleset = merge(...node, { files: [`**/*${commonFiles}`] });

const typeScriptRuleset = merge(...typescript, {
files: [`**/*${commonFiles}`],
languageOptions: {
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
allowAutomaticSingleRunInference: true,
project: ['tsconfig.eslint.json', 'services/*/tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
rules: {
'@typescript-eslint/consistent-type-definitions': [2, 'interface'],
'@typescript-eslint/naming-convention': [
2,
{
selector: 'typeParameter',
format: ['PascalCase'],
custom: {
regex: '^\\w{3,}',
match: true,
},
},
],
},
settings: {
'import/resolver': {
typescript: {
project: ['tsconfig.eslint.json', 'services/*/tsconfig.eslint.json', 'packages/*/tsconfig.eslint.json'],
},
},
},
});

const prettierRuleset = merge(...prettier, { files: [`**/*${commonFiles}`] });

export default tseslint.config(
{
ignores: ['**/node_modules/', '.git/', '**/dist/', '**/coverage/', 'packages/core/src/db.ts'],
},
commonRuleset,
nodeRuleset,
typeScriptRuleset,
prettierRuleset,
);
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"packageManager": "[email protected]",
"private": true,
"version": "0.0.0",
"type": "module",
"workspaces": [
"packages/*",
"services/*"
Expand All @@ -25,21 +26,23 @@
"update": "yarn upgrade-interactive"
},
"dependencies": {
"prisma": "^5.3.1"
"prisma": "^5.15.1"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-angular": "^17.7.0",
"dotenv-cli": "^7.3.0",
"eslint": "^8.49.0",
"eslint-config-neon": "^0.1.56",
"eslint-formatter-pretty": "^5.0.0",
"husky": "^8.0.3",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-angular": "^19.3.0",
"dotenv-cli": "^7.4.2",
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.62",
"eslint-formatter-pretty": "^6.0.1",
"husky": "^9.0.11",
"is-ci": "^3.0.1",
"prettier": "^3.0.3",
"prisma-kysely": "^1.7.0",
"rimraf": "^5.0.1",
"turbo": "^1.10.14",
"typescript": "^5.2.2"
"lodash.merge": "^4.6.2",
"prettier": "^3.3.2",
"prisma-kysely": "^1.8.0",
"rimraf": "^5.0.7",
"turbo": "^2.0.4",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.1"
}
}
1 change: 0 additions & 1 deletion packages/core/.eslintignore

This file was deleted.

32 changes: 16 additions & 16 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
"version": "0.1.0",
"type": "module",
"scripts": {
"lint": "eslint src --ext .ts",
"lint": "eslint src",
"build": "tsc"
},
"engines": {
"node": ">=16.9.0"
},
"devDependencies": {
"@types/node": "^20.6.3",
"@types/pg": "^8.10.2",
"typescript": "^5.2.2"
"@types/node": "^20.14.6",
"@types/pg": "^8.11.6",
"typescript": "^5.4.5"
},
"dependencies": {
"@chatsift/pino-rotate-file": "^0.2.0",
"@discordjs/builders": "^1.6.5",
"@discordjs/core": "^1.0.1",
"@discordjs/rest": "^2.0.1",
"@chatsift/pino-rotate-file": "^0.3.0",
"@discordjs/builders": "^1.8.2",
"@discordjs/core": "^1.2.0",
"@discordjs/rest": "^2.3.0",
"@msgpack/msgpack": "^3.0.0-beta2",
"@naval-base/ms": "^3.1.0",
"@sapphire/bitfield": "^1.2.0",
"inversify": "^6.0.1",
"ioredis": "^5.3.2",
"kysely": "^0.26.3",
"@sapphire/bitfield": "^1.2.2",
"inversify": "^6.0.2",
"ioredis": "5.3.2",
"kysely": "^0.27.3",
"murmurhash": "^2.0.1",
"pg": "^8.11.3",
"pino": "^8.15.1",
"pino-pretty": "^10.2.0",
"tslib": "^2.6.2"
"pg": "^8.12.0",
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"tslib": "^2.6.3"
}
}
11 changes: 7 additions & 4 deletions packages/core/src/binary-encoding/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export type SimpleDataTypes =
export type ComplexDataTypes = DataType.Array | DataType.Object;

export interface IReader {
array<T>(mapper: (buffer: this) => T): T[];
array<ValueType>(mapper: (buffer: this) => ValueType): ValueType[];
bool(): boolean | null;
date(): number | null;
i16(): number | null;
i32(): number | null;
i8(): number | null;
object<T extends Record<string, unknown>>(mapper: (buffer: this) => T): T | null;
object<ValueType extends Record<string, unknown>>(mapper: (buffer: this) => ValueType): ValueType | null;
string(): string | null;
u16(): number | null;
u32(): number | null;
Expand All @@ -46,15 +46,18 @@ export interface IReader {
}

export interface IWriter {
array<T>(values: readonly T[] | null, mapper: (buffer: this, value: T) => void): this;
array<ValueType>(values: readonly ValueType[] | null, mapper: (buffer: this, value: ValueType) => void): this;
bool(value?: boolean | null): this;
date(value?: number | string | null): this;
dump(): Buffer;
dumpTrimmed(): Buffer;
i16(value?: number | null): this;
i32(value?: number | null): this;
i8(value?: number | null): this;
object<T extends Record<string, unknown>>(value: T | null, mapper: (buffer: this, value: T) => void): this;
object<ValueType extends Record<string, unknown>>(
value: ValueType | null,
mapper: (buffer: this, value: ValueType) => void,
): this;
string(value?: string | null): this;
u16(value?: number | null): this;
u32(value?: number | null): this;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/binary-encoding/Reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,31 @@ export class Reader implements IReader {
return Number(value);
}

public array<T>(mapper: (buffer: this) => T): T[] {
public array<ValueType>(mapper: (buffer: this) => ValueType): ValueType[] {
if (this.readNull(DataType.Array)) {
return [];
}

const length = this.data.readUInt32LE(this.offset);
this.offset += 4;

const values: T[] = [];
const values: ValueType[] = [];
for (let index = 0; index < length; index++) {
values.push(mapper(this));
}

return values;
}

public object<T extends Record<string, unknown>>(mapper: (buffer: this) => T): T | null {
public object<ValueType extends Record<string, unknown>>(mapper: (buffer: this) => ValueType): ValueType | null {
if (this.readNull(DataType.Object)) {
return null;
}

return mapper(this);
}

private readNull<Type extends Exclude<DataType, DataType.Null>>(dataType: Type): boolean {
private readNull<ValueType extends Exclude<DataType, DataType.Null>>(dataType: ValueType): boolean {
const read = this.data.readUInt8(this.offset++) as DataType;
if (read === DataType.Null) {
return true;
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/binary-encoding/Writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Writer implements IWriter {
return this.u64(parsed, DataType.Date);
}

public array<T>(values: readonly T[] | null, mapper: (buffer: this, value: T) => void) {
public array<ValueType>(values: readonly ValueType[] | null, mapper: (buffer: this, value: ValueType) => void) {
if (!values?.length) {
return this.writeNull();
}
Expand All @@ -177,7 +177,10 @@ export class Writer implements IWriter {
return this;
}

public object<T extends Record<string, unknown>>(value: T | null, mapper: (buffer: this, value: T) => void) {
public object<ValueType extends Record<string, unknown>>(
value: ValueType | null,
mapper: (buffer: this, value: ValueType) => void,
) {
if (value == null) {
return this.writeNull();
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/cache/CacheFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export class CacheFactory {

public constructor(@inject(INJECTION_TOKENS.redis) private readonly redis: Redis) {}

public build<T>(entity: ICacheEntity<T>): ICache<T> {
public build<ValueType>(entity: ICacheEntity<ValueType>): ICache<ValueType> {
if (this.caches.has(entity)) {
return this.caches.get(entity)! as ICache<T>;
return this.caches.get(entity)! as ICache<ValueType>;
}

const cache = new RedisCache<T>(this.redis, entity);
const cache = new RedisCache<ValueType>(this.redis, entity);
this.caches.set(entity, cache);

return cache;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/cache/ICache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* Responsible for caching data in Redis.
*/
export interface ICache<T> {
export interface ICache<ValueType> {
delete(id: string): Promise<void>;
get(id: string): Promise<T | null>;
getOld(id: string): Promise<T | null>;
get(id: string): Promise<ValueType | null>;
getOld(id: string): Promise<ValueType | null>;
has(id: string): Promise<boolean>;
set(id: string, value: T): Promise<void>;
set(id: string, value: ValueType): Promise<void>;
}
10 changes: 5 additions & 5 deletions packages/core/src/cache/RedisCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import type { ICacheEntity } from './entities/ICacheEntity.js';
* This class is deliberately not an `@injectable()`, refer to the README for more information on the pattern
* being used.
*/
export class RedisCache<T> implements ICache<T> {
export class RedisCache<ValueType> implements ICache<ValueType> {
public constructor(
private readonly redis: Redis,
private readonly entity: ICacheEntity<T>,
private readonly entity: ICacheEntity<ValueType>,
) {}

public async has(id: string): Promise<boolean> {
return Boolean(await this.redis.exists(this.entity.makeKey(id)));
}

public async get(id: string): Promise<T | null> {
public async get(id: string): Promise<ValueType | null> {
const key = this.entity.makeKey(id);
const raw = await this.redis.getBuffer(key);

Expand All @@ -29,7 +29,7 @@ export class RedisCache<T> implements ICache<T> {
return this.entity.toJSON(raw);
}

public async getOld(id: string): Promise<T | null> {
public async getOld(id: string): Promise<ValueType | null> {
const key = `old:${this.entity.makeKey(id)}`;
const raw = await this.redis.getBuffer(key);

Expand All @@ -41,7 +41,7 @@ export class RedisCache<T> implements ICache<T> {
return this.entity.toJSON(raw);
}

public async set(id: string, value: T): Promise<void> {
public async set(id: string, value: ValueType): Promise<void> {
const key = this.entity.makeKey(id);
if (await this.redis.exists(key)) {
await this.redis.rename(key, `old:${key}`);
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/experiments/ExperimentHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { setInterval } from 'node:timers';
import { inject, injectable } from 'inversify';
import murmurhash from 'murmurhash';
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
import type { Logger } from 'pino';
import { IDataManager, type ExperimentWithOverrides } from '../applicationData/IDataManager.js';
import { INJECTION_TOKENS } from '../container.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/experiments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ This directory contains handling of "experiments" across the entire stack. This
We generate a "hash" (value between 0 and 9999) from the experiment name and the guild ID. The database holds experiment
configuration data (ranges and overrides), which is how we determine if a guild is part of an experiment with minimal database hits.

Note: Naming convention for experiments is EXPERIMENT_NAME_[YYYY]_[MM]
Note: Naming convention for experiments is EXPERIMENT*NAME*[YYYY]\_[MM]

Note: Experiment data is re-polled ever 3 minutes.
4 changes: 2 additions & 2 deletions packages/core/src/util/parseRelativeTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* @remarks
* This is used for various ops, hence the <T>
*/
type TimeParserResult<T> =
type TimeParserResult<ValueType> =
| {
error: string;
ok: false;
}
| {
ok: true;
value: T;
value: ValueType;
};

const oneMs = 1;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/util/promiseAllObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*
* => Promise<{ a: X, b: Y }>
*/
export async function promiseAllObject<T extends Record<string, Promise<any>>>(
obj: T,
): Promise<{ [K in keyof T]: Awaited<T[K]> }> {
export async function promiseAllObject<TRecord extends Record<string, Promise<any>>>(
obj: TRecord,
): Promise<{ [K in keyof TRecord]: Awaited<TRecord[K]> }> {
return Object.fromEntries(await Promise.all(Object.entries(obj).map(async ([key, value]) => [key, await value])));
}
Loading

0 comments on commit 1370962

Please sign in to comment.