Update dependencies & fix misc formatting errors

This commit is contained in:
Garrett Mills 2022-09-30 12:02:39 -05:00
parent 52762bd4a1
commit 0484a586bd
23 changed files with 932 additions and 2797 deletions

1608
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.14.6", "version": "0.14.7",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -8,50 +8,50 @@
"lib": "lib" "lib": "lib"
}, },
"dependencies": { "dependencies": {
"@atao60/fse-cli": "^0.1.6", "@atao60/fse-cli": "^0.1.7",
"@extollo/ui": "^0.1.0", "@extollo/ui": "^0.1.0",
"@types/bcrypt": "^5.0.0", "@types/bcrypt": "^5.0.0",
"@types/busboy": "^0.2.3", "@types/busboy": "^0.2.3",
"@types/cli-table": "^0.3.0", "@types/cli-table": "^0.3.1",
"@types/ioredis": "^4.26.6", "@types/ioredis": "^4.26.6",
"@types/jsonwebtoken": "^8.5.8", "@types/jsonwebtoken": "^8.5.9",
"@types/mime-types": "^2.1.0", "@types/mime-types": "^2.1.1",
"@types/mkdirp": "^1.0.1", "@types/mkdirp": "^1.0.2",
"@types/negotiator": "^0.6.1", "@types/negotiator": "^0.6.1",
"@types/node": "^14.17.4", "@types/node": "^14.17.4",
"@types/pg": "^8.6.0", "@types/pg": "^8.6.5",
"@types/pluralize": "^0.0.29", "@types/pluralize": "^0.0.29",
"@types/pug": "^2.0.4", "@types/pug": "^2.0.6",
"@types/rimraf": "^3.0.0", "@types/rimraf": "^3.0.2",
"@types/ssh2": "^0.5.46", "@types/ssh2": "^0.5.46",
"@types/uuid": "^8.3.0", "@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
"bcrypt": "^5.0.1", "bcrypt": "^5.0.1",
"busboy": "^0.3.1", "busboy": "^0.3.1",
"cli-table": "^0.3.6", "cli-table": "^0.3.11",
"colors": "^1.4.0", "colors": "^1.4.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"ioredis": "^4.27.6", "ioredis": "^4.27.6",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"mime-types": "^2.1.31", "mime-types": "^2.1.35",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
"negotiator": "^0.6.2", "negotiator": "^0.6.3",
"node-fetch": "^3", "node-fetch": "^3.2.10",
"pg": "^8.6.0", "pg": "^8.8.0",
"pluralize": "^8.0.0", "pluralize": "^8.0.0",
"pug": "^3.0.2", "pug": "^3.0.2",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sqlite": "^4.1.2", "sqlite": "^4.1.2",
"sqlite3": "^5.1.1", "sqlite3": "^5.1.1",
"ssh2": "^1.1.0", "ssh2": "^1.11.0",
"ts-node": "^9.1.1", "ts-node": "^10.9.1",
"typedoc": "^0.20.36", "typedoc": "^0.23.15",
"typedoc-plugin-pages-fork": "^0.0.1", "typedoc-plugin-pages-fork": "^0.0.1",
"typedoc-plugin-sourcefile-url": "^1.0.6", "typedoc-plugin-sourcefile-url": "^1.0.6",
"typescript": "^4.7.4", "typescript": "^4.8.4",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"ws": "^8.8.0", "ws": "^8.9.0",
"zod": "^3.11.6" "zod": "^3.11.6"
}, },
"scripts": { "scripts": {
@ -76,14 +76,14 @@
"author": "garrettmills <shout@garrettmills.dev>", "author": "garrettmills <shout@garrettmills.dev>",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@types/chai": "^4.2.22", "@types/chai": "^4.3.3",
"@types/mocha": "^9.0.0", "@types/mocha": "^9.0.0",
"@types/sinon": "^10.0.6", "@types/sinon": "^10.0.13",
"@types/wtfnode": "^0.7.0", "@types/wtfnode": "^0.7.0",
"@typescript-eslint/eslint-plugin": "^4.26.0", "@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^4.26.0", "@typescript-eslint/parser": "^5.38.1",
"chai": "^4.3.4", "chai": "^4.3.6",
"eslint": "^7.27.0", "eslint": "^8.24.0",
"mocha": "^9.1.3", "mocha": "^9.1.3",
"sinon": "^12.0.1", "sinon": "^12.0.1",
"wtfnode": "^0.9.1" "wtfnode": "^0.9.1"

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
import {Directive, OptionDefinition} from '../Directive' import {Directive, OptionDefinition} from '../Directive'
import * as colors from 'colors/safe' import * as colors from 'colors/safe'
import * as repl from 'repl' import * as repl from 'repl'
import * as tsNode from 'ts-node' // import * as tsNode from 'ts-node'
import {globalRegistry} from '../../util' import {globalRegistry} from '../../util'
/** /**

View File

@ -147,7 +147,7 @@ export class Container {
* Collection of callbacks waiting for a dependency key to be resolved. * Collection of callbacks waiting for a dependency key to be resolved.
* @protected * @protected
*/ */
protected waitingResolveCallbacks: Collection<{ key: DependencyKey, callback: (t: unknown) => unknown }> = new Collection<{key: DependencyKey; callback:(t: unknown) => unknown}>(); protected waitingResolveCallbacks: Collection<{ key: DependencyKey, callback: (t: unknown) => unknown }> = new Collection<{key: DependencyKey; callback:(t: unknown) => unknown}>()
/** /**
* Collection of created objects that should have lifecycle events called on them, if they still exist. * Collection of created objects that should have lifecycle events called on them, if they still exist.

View File

@ -41,7 +41,7 @@ export interface ModuleRegistrationFluency {
@Singleton() @Singleton()
export class HTTPKernel extends AppClass { export class HTTPKernel extends AppClass {
@Inject() @Inject()
protected readonly logging!: Logging; protected readonly logging!: Logging
/** /**
* Collection of preflight modules to apply. * Collection of preflight modules to apply.

View File

@ -12,7 +12,7 @@ export class PoweredByHeaderInjectionHTTPModule extends HTTPKernelModule {
public readonly executeWithBlockingWriteback = true public readonly executeWithBlockingWriteback = true
@Inject() @Inject()
protected readonly config!: Config; protected readonly config!: Config
public static register(kernel: HTTPKernel): void { public static register(kernel: HTTPKernel): void {
kernel.register(this).after() kernel.register(this).after()

View File

@ -13,7 +13,7 @@ import {ActivatedRoute} from '../routing/ActivatedRoute'
* Enumeration of different HTTP verbs. * Enumeration of different HTTP verbs.
* @todo add others? * @todo add others?
*/ */
export type HTTPMethod = 'post' | 'get' | 'patch' | 'put' | 'delete' | 'unknown'; export type HTTPMethod = 'post' | 'get' | 'patch' | 'put' | 'delete' | 'unknown'
/** /**
* Returns true if the given item is a valid HTTP verb. * Returns true if the given item is a valid HTTP verb.
@ -36,9 +36,9 @@ export interface HTTPProtocol {
* Interface that describes the origin IP address of a request. * Interface that describes the origin IP address of a request.
*/ */
export interface HTTPSourceAddress { export interface HTTPSourceAddress {
address: string; address: string
family: 'IPv4' | 'IPv6'; family: 'IPv4' | 'IPv6'
port: number; port: number
} }
/** /**
@ -55,43 +55,43 @@ export interface DataContainer {
export class Request extends ScopedContainer implements DataContainer { export class Request extends ScopedContainer implements DataContainer {
/** The cookie manager for the request. */ /** The cookie manager for the request. */
public readonly cookies: HTTPCookieJar; public readonly cookies: HTTPCookieJar
/** The URL suffix of the request. */ /** The URL suffix of the request. */
public readonly url: string; public readonly url: string
/** The fully-qualified URL of the request. */ /** The fully-qualified URL of the request. */
public readonly fullUrl: string; public readonly fullUrl: string
/** The HTTP verb of the request. */ /** The HTTP verb of the request. */
public readonly method: HTTPMethod; public readonly method: HTTPMethod
/** True if the request was made via TLS. */ /** True if the request was made via TLS. */
public readonly secure: boolean; public readonly secure: boolean
/** The request HTTP protocol version. */ /** The request HTTP protocol version. */
public readonly protocol: HTTPProtocol; public readonly protocol: HTTPProtocol
/** The URL path, stripped of query params. */ /** The URL path, stripped of query params. */
public readonly path: string; public readonly path: string
/** The raw parsed query data from the request. */ /** The raw parsed query data from the request. */
public readonly rawQueryData: {[key: string]: string | string[] | undefined}; public readonly rawQueryData: {[key: string]: string | string[] | undefined}
/** The inferred query data. */ /** The inferred query data. */
public readonly query: {[key: string]: any}; public readonly query: {[key: string]: any}
/** True if the request was made via XMLHttpRequest. */ /** True if the request was made via XMLHttpRequest. */
public readonly isXHR: boolean; public readonly isXHR: boolean
/** The origin IP address of the request. */ /** The origin IP address of the request. */
public readonly address: HTTPSourceAddress; public readonly address: HTTPSourceAddress
/** The associated response. */ /** The associated response. */
public readonly response: Response; public readonly response: Response
/** The media types accepted by the client. */ /** The media types accepted by the client. */
public readonly mediaTypes: string[]; public readonly mediaTypes: string[]
/** Input parsed from the request */ /** Input parsed from the request */
public readonly parsedInput: {[key: string]: any} = {} public readonly parsedInput: {[key: string]: any} = {}

View File

@ -45,7 +45,7 @@ export class SocketRouteBuilder {
* @param key * @param key
* @param selector * @param selector
*/ */
connected<TKey extends any>( connected<TKey>(
key: TypedDependencyKey<TKey>, key: TypedDependencyKey<TKey>,
selector: (x: TKey) => (ws: WebSocketBus) => Awaitable<void>, selector: (x: TKey) => (ws: WebSocketBus) => Awaitable<void>,
): this { ): this {
@ -68,7 +68,7 @@ export class SocketRouteBuilder {
* @param key * @param key
* @param selector * @param selector
*/ */
event<TState extends JSONState, TKey extends any>( event<TState extends JSONState, TKey>(
eventClass: Instantiable<StateEvent<TState>>, eventClass: Instantiable<StateEvent<TState>>,
key: TypedDependencyKey<TKey>, key: TypedDependencyKey<TKey>,
selector: (x: TKey) => (state: TState) => Awaitable<void>, selector: (x: TKey) => (state: TState) => Awaitable<void>,

View File

@ -1,4 +1,4 @@
import {Container, Inject, Injectable} from '../../di' import {Inject, Injectable} from '../../di'
import {Migrator} from './Migrator' import {Migrator} from './Migrator'
import {DatabaseService} from '../DatabaseService' import {DatabaseService} from '../DatabaseService'
import {FieldType} from '../types' import {FieldType} from '../types'
@ -14,9 +14,6 @@ export class DatabaseMigrator extends Migrator {
@Inject() @Inject()
protected readonly db!: DatabaseService protected readonly db!: DatabaseService
@Inject('injector')
protected readonly injector!: Container
/** True if we've initialized the migrator. */ /** True if we've initialized the migrator. */
protected initialized = false protected initialized = false

View File

@ -1,11 +1,10 @@
import {ModelKey, QueryRow, QuerySource} from '../types' import {ModelKey, QueryRow, QuerySource} from '../types'
import {Container, Inject, Instantiable, isInstantiable} from '../../di' import {Container, Instantiable, isInstantiable} from '../../di'
import {DatabaseService} from '../DatabaseService' import {DatabaseService} from '../DatabaseService'
import {ModelBuilder} from './ModelBuilder' import {ModelBuilder} from './ModelBuilder'
import {getFieldsMeta, ModelField} from './Field' import {getFieldsMeta, ModelField} from './Field'
import {deepCopy, Collection, uuid4, isKeyof, Pipeline, hasOwnProperty} from '../../util' import {deepCopy, Collection, uuid4, isKeyof, Pipeline, hasOwnProperty} from '../../util'
import {EscapeValueObject, QuerySafeValue} from '../dialect/SQLDialect' import {EscapeValueObject, QuerySafeValue} from '../dialect/SQLDialect'
import {Logging} from '../../service/Logging'
import {Connection} from '../connection/Connection' import {Connection} from '../connection/Connection'
import {ModelRetrievedEvent} from './events/ModelRetrievedEvent' import {ModelRetrievedEvent} from './events/ModelRetrievedEvent'
import {ModelSavingEvent} from './events/ModelSavingEvent' import {ModelSavingEvent} from './events/ModelSavingEvent'
@ -26,9 +25,6 @@ import {ModelEvent} from './events/ModelEvent'
* Base for classes that are mapped to tables in a database. * Base for classes that are mapped to tables in a database.
*/ */
export abstract class Model<T extends Model<T>> extends LocalBus<ModelEvent<T>> { export abstract class Model<T extends Model<T>> extends LocalBus<ModelEvent<T>> {
@Inject()
protected readonly logging!: Logging
/** /**
* The name of the connection this model should run through. * The name of the connection this model should run through.
* @type string * @type string

View File

@ -8,18 +8,18 @@ import {ModelBuilder} from '../model/ModelBuilder'
* A model instance which stores records from the ORMCache driver. * A model instance which stores records from the ORMCache driver.
*/ */
export class CacheModel extends Model<CacheModel> { export class CacheModel extends Model<CacheModel> {
protected static table = 'caches'; // FIXME allow configuring protected static table = 'caches' // FIXME allow configuring
protected static key = 'cache_key'; protected static key = 'cache_key'
@Field(FieldType.varchar, 'cache_key') @Field(FieldType.varchar, 'cache_key')
public cacheKey!: string; public cacheKey!: string
@Field(FieldType.text, 'cache_value') @Field(FieldType.text, 'cache_value')
public cacheValue!: string; public cacheValue!: string
@Field(FieldType.timestamp, 'cache_expires') @Field(FieldType.timestamp, 'cache_expires')
public cacheExpires?: Date; public cacheExpires?: Date
public static withCacheKey(key: string): ModelBuilder<CacheModel> { public static withCacheKey(key: string): ModelBuilder<CacheModel> {
return this.query<CacheModel>() return this.query<CacheModel>()

View File

@ -35,7 +35,7 @@ export class ORMSession extends Session {
this.data = this.session.json this.data = this.session.json
} else { } else {
this.session = <SessionModel> Container.getContainer().make(SessionModel) this.session = <SessionModel> Container.getContainer().make(SessionModel)
this.session.uuid = this.key this.session.sessionUuid = this.key
this.data = {} as SessionData this.data = {} as SessionData
} }
} }
@ -48,7 +48,7 @@ export class ORMSession extends Session {
throw new SessionNotLoadedError() throw new SessionNotLoadedError()
} }
this.session.uuid = this.key this.session.sessionUuid = this.key
this.session.json = JSON.stringify(this.data) this.session.json = JSON.stringify(this.data)
await this.session.save() await this.session.save()
} }

View File

@ -13,8 +13,8 @@ export class SessionModel extends Model<SessionModel> {
protected static populateKeyOnInsert = true protected static populateKeyOnInsert = true
@Field(FieldType.varchar, 'session_uuid') @Field(FieldType.varchar, 'session_uuid')
public uuid!: string; public sessionUuid!: string
@Field(FieldType.json, 'session_data') @Field(FieldType.json, 'session_data')
public json!: any; public json!: any
} }

View File

@ -1,15 +1,11 @@
import {Singleton, Inject} from '../di' import {Singleton} from '../di'
import {CanonicalRecursive} from './CanonicalRecursive' import {CanonicalRecursive} from './CanonicalRecursive'
import {Logging} from './Logging'
/** /**
* Canonical unit that loads configuration files from `app/configs`. * Canonical unit that loads configuration files from `app/configs`.
*/ */
@Singleton() @Singleton()
export class Config extends CanonicalRecursive { export class Config extends CanonicalRecursive {
@Inject()
protected readonly logging!: Logging
protected appPath: string[] = ['configs'] protected appPath: string[] = ['configs']
protected suffix = '.config' protected suffix = '.config'

View File

@ -26,7 +26,7 @@ export interface BusInternalSubscription {
*/ */
@Singleton() @Singleton()
export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<TEvent>, AwareOfContainerLifecycle { export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<TEvent>, AwareOfContainerLifecycle {
awareOfContainerLifecycle: true = true awareOfContainerLifecycle = true as const
@Inject() @Inject()
protected readonly logging!: Logging protected readonly logging!: Logging

View File

@ -11,7 +11,7 @@ import {CanonicalItemClass} from '../CanonicalReceiver'
*/ */
@Injectable() @Injectable()
export class LocalBus<TEvent extends Event = Event> extends CanonicalItemClass implements EventBus<TEvent>, AwareOfContainerLifecycle { export class LocalBus<TEvent extends Event = Event> extends CanonicalItemClass implements EventBus<TEvent>, AwareOfContainerLifecycle {
awareOfContainerLifecycle: true = true awareOfContainerLifecycle = true as const
@Inject() @Inject()
protected readonly logging!: Logging protected readonly logging!: Logging

View File

@ -12,7 +12,7 @@ import {getEventName} from './getEventName'
*/ */
@Injectable() @Injectable()
export class RedisBus implements EventBus, AwareOfContainerLifecycle { export class RedisBus implements EventBus, AwareOfContainerLifecycle {
awareOfContainerLifecycle: true = true awareOfContainerLifecycle = true as const
@Inject() @Inject()
protected readonly redis!: Redis protected readonly redis!: Redis

View File

@ -100,7 +100,7 @@ export class StateEventSerializer extends BaseSerializer<StateEvent<JSONState>,
protected readonly injector!: Container protected readonly injector!: Container
/** The StateEvent implementation. */ /** The StateEvent implementation. */
public readonly eventClass: Instantiable<StateEvent<JSONState>>; public readonly eventClass: Instantiable<StateEvent<JSONState>>
constructor( constructor(
eventClass: Instantiable<StateEvent<JSONState>>, eventClass: Instantiable<StateEvent<JSONState>>,

View File

@ -23,7 +23,7 @@ import {Request} from '../../http/lifecycle/Request'
@Injectable() @Injectable()
export class WebSocketBus implements EventBus, AwareOfContainerLifecycle { export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
awareOfContainerLifecycle: true = true awareOfContainerLifecycle = true as const
/** /**
* If true, the session will be loaded when an event is received and * If true, the session will be loaded when an event is received and

View File

@ -45,7 +45,7 @@ export function deepCopy<T>(target: T): T {
return copy.map((item: any) => deepCopy<any>(item)) as any return copy.map((item: any) => deepCopy<any>(item)) as any
} }
if ( typeof target === 'object' && target !== {} ) { if ( typeof target === 'object' ) {
const copy = { ...(target as {[key: string]: any }) } as { [key: string]: any } const copy = { ...(target as {[key: string]: any }) } as { [key: string]: any }
Object.keys(copy).forEach(key => { Object.keys(copy).forEach(key => {
copy[key] = deepCopy<any>(copy[key]) copy[key] = deepCopy<any>(copy[key])

View File

@ -5,6 +5,7 @@ import * as fs from 'fs'
import {Readable, Writable} from 'stream' import {Readable, Writable} from 'stream'
import {Collection} from '../../collection/Collection' import {Collection} from '../../collection/Collection'
import {UniversalPath} from '../path' import {UniversalPath} from '../path'
import {Maybe} from '../types'
/** /**
* A Filesystem implementation that stores files on remote hosts via SFTP/SSH. * A Filesystem implementation that stores files on remote hosts via SFTP/SSH.
@ -190,7 +191,7 @@ export class SSHFilesystem extends Filesystem {
const sftp = await this.getSFTP() const sftp = await this.getSFTP()
const metaPath = this.metadataPath(storePath) const metaPath = this.metadataPath(storePath)
await new Promise<void>((res, rej) => { await new Promise<void>((res, rej) => {
sftp.writeFile(metaPath, JSON.stringify(meta), err => { sftp.writeFile(metaPath, JSON.stringify(meta), (err: Maybe<Error>) => {
if ( err ) { if ( err ) {
rej(err) rej(err)
} else { } else {

View File

@ -7,6 +7,7 @@
"strict": true, "strict": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"skipLibCheck": true,
"lib": ["ESNext"] "lib": ["ESNext"]
}, },
"include": ["src"], "include": ["src"],