Update dependencies & fix misc formatting errors
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {Directive, OptionDefinition} from '../Directive'
|
||||
import * as colors from 'colors/safe'
|
||||
import * as repl from 'repl'
|
||||
import * as tsNode from 'ts-node'
|
||||
// import * as tsNode from 'ts-node'
|
||||
import {globalRegistry} from '../../util'
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ export class Container {
|
||||
* Collection of callbacks waiting for a dependency key to be resolved.
|
||||
* @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.
|
||||
|
||||
@@ -41,7 +41,7 @@ export interface ModuleRegistrationFluency {
|
||||
@Singleton()
|
||||
export class HTTPKernel extends AppClass {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging;
|
||||
protected readonly logging!: Logging
|
||||
|
||||
/**
|
||||
* Collection of preflight modules to apply.
|
||||
|
||||
@@ -12,7 +12,7 @@ export class PoweredByHeaderInjectionHTTPModule extends HTTPKernelModule {
|
||||
public readonly executeWithBlockingWriteback = true
|
||||
|
||||
@Inject()
|
||||
protected readonly config!: Config;
|
||||
protected readonly config!: Config
|
||||
|
||||
public static register(kernel: HTTPKernel): void {
|
||||
kernel.register(this).after()
|
||||
|
||||
@@ -13,7 +13,7 @@ import {ActivatedRoute} from '../routing/ActivatedRoute'
|
||||
* Enumeration of different HTTP verbs.
|
||||
* @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.
|
||||
@@ -36,9 +36,9 @@ export interface HTTPProtocol {
|
||||
* Interface that describes the origin IP address of a request.
|
||||
*/
|
||||
export interface HTTPSourceAddress {
|
||||
address: string;
|
||||
family: 'IPv4' | 'IPv6';
|
||||
port: number;
|
||||
address: string
|
||||
family: 'IPv4' | 'IPv6'
|
||||
port: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,43 +55,43 @@ export interface DataContainer {
|
||||
export class Request extends ScopedContainer implements DataContainer {
|
||||
|
||||
/** The cookie manager for the request. */
|
||||
public readonly cookies: HTTPCookieJar;
|
||||
public readonly cookies: HTTPCookieJar
|
||||
|
||||
/** The URL suffix of the request. */
|
||||
public readonly url: string;
|
||||
public readonly url: string
|
||||
|
||||
/** The fully-qualified URL of the request. */
|
||||
public readonly fullUrl: string;
|
||||
public readonly fullUrl: string
|
||||
|
||||
/** The HTTP verb of the request. */
|
||||
public readonly method: HTTPMethod;
|
||||
public readonly method: HTTPMethod
|
||||
|
||||
/** True if the request was made via TLS. */
|
||||
public readonly secure: boolean;
|
||||
public readonly secure: boolean
|
||||
|
||||
/** The request HTTP protocol version. */
|
||||
public readonly protocol: HTTPProtocol;
|
||||
public readonly protocol: HTTPProtocol
|
||||
|
||||
/** The URL path, stripped of query params. */
|
||||
public readonly path: string;
|
||||
public readonly path: string
|
||||
|
||||
/** 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. */
|
||||
public readonly query: {[key: string]: any};
|
||||
public readonly query: {[key: string]: any}
|
||||
|
||||
/** True if the request was made via XMLHttpRequest. */
|
||||
public readonly isXHR: boolean;
|
||||
public readonly isXHR: boolean
|
||||
|
||||
/** The origin IP address of the request. */
|
||||
public readonly address: HTTPSourceAddress;
|
||||
public readonly address: HTTPSourceAddress
|
||||
|
||||
/** The associated response. */
|
||||
public readonly response: Response;
|
||||
public readonly response: Response
|
||||
|
||||
/** The media types accepted by the client. */
|
||||
public readonly mediaTypes: string[];
|
||||
public readonly mediaTypes: string[]
|
||||
|
||||
/** Input parsed from the request */
|
||||
public readonly parsedInput: {[key: string]: any} = {}
|
||||
|
||||
@@ -45,7 +45,7 @@ export class SocketRouteBuilder {
|
||||
* @param key
|
||||
* @param selector
|
||||
*/
|
||||
connected<TKey extends any>(
|
||||
connected<TKey>(
|
||||
key: TypedDependencyKey<TKey>,
|
||||
selector: (x: TKey) => (ws: WebSocketBus) => Awaitable<void>,
|
||||
): this {
|
||||
@@ -68,7 +68,7 @@ export class SocketRouteBuilder {
|
||||
* @param key
|
||||
* @param selector
|
||||
*/
|
||||
event<TState extends JSONState, TKey extends any>(
|
||||
event<TState extends JSONState, TKey>(
|
||||
eventClass: Instantiable<StateEvent<TState>>,
|
||||
key: TypedDependencyKey<TKey>,
|
||||
selector: (x: TKey) => (state: TState) => Awaitable<void>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Container, Inject, Injectable} from '../../di'
|
||||
import {Inject, Injectable} from '../../di'
|
||||
import {Migrator} from './Migrator'
|
||||
import {DatabaseService} from '../DatabaseService'
|
||||
import {FieldType} from '../types'
|
||||
@@ -14,9 +14,6 @@ export class DatabaseMigrator extends Migrator {
|
||||
@Inject()
|
||||
protected readonly db!: DatabaseService
|
||||
|
||||
@Inject('injector')
|
||||
protected readonly injector!: Container
|
||||
|
||||
/** True if we've initialized the migrator. */
|
||||
protected initialized = false
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import {ModelKey, QueryRow, QuerySource} from '../types'
|
||||
import {Container, Inject, Instantiable, isInstantiable} from '../../di'
|
||||
import {Container, Instantiable, isInstantiable} from '../../di'
|
||||
import {DatabaseService} from '../DatabaseService'
|
||||
import {ModelBuilder} from './ModelBuilder'
|
||||
import {getFieldsMeta, ModelField} from './Field'
|
||||
import {deepCopy, Collection, uuid4, isKeyof, Pipeline, hasOwnProperty} from '../../util'
|
||||
import {EscapeValueObject, QuerySafeValue} from '../dialect/SQLDialect'
|
||||
import {Logging} from '../../service/Logging'
|
||||
import {Connection} from '../connection/Connection'
|
||||
import {ModelRetrievedEvent} from './events/ModelRetrievedEvent'
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
* @type string
|
||||
|
||||
@@ -8,18 +8,18 @@ import {ModelBuilder} from '../model/ModelBuilder'
|
||||
* A model instance which stores records from the ORMCache driver.
|
||||
*/
|
||||
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')
|
||||
public cacheKey!: string;
|
||||
public cacheKey!: string
|
||||
|
||||
@Field(FieldType.text, 'cache_value')
|
||||
public cacheValue!: string;
|
||||
public cacheValue!: string
|
||||
|
||||
@Field(FieldType.timestamp, 'cache_expires')
|
||||
public cacheExpires?: Date;
|
||||
public cacheExpires?: Date
|
||||
|
||||
public static withCacheKey(key: string): ModelBuilder<CacheModel> {
|
||||
return this.query<CacheModel>()
|
||||
|
||||
@@ -35,7 +35,7 @@ export class ORMSession extends Session {
|
||||
this.data = this.session.json
|
||||
} else {
|
||||
this.session = <SessionModel> Container.getContainer().make(SessionModel)
|
||||
this.session.uuid = this.key
|
||||
this.session.sessionUuid = this.key
|
||||
this.data = {} as SessionData
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export class ORMSession extends Session {
|
||||
throw new SessionNotLoadedError()
|
||||
}
|
||||
|
||||
this.session.uuid = this.key
|
||||
this.session.sessionUuid = this.key
|
||||
this.session.json = JSON.stringify(this.data)
|
||||
await this.session.save()
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ export class SessionModel extends Model<SessionModel> {
|
||||
protected static populateKeyOnInsert = true
|
||||
|
||||
@Field(FieldType.varchar, 'session_uuid')
|
||||
public uuid!: string;
|
||||
public sessionUuid!: string
|
||||
|
||||
@Field(FieldType.json, 'session_data')
|
||||
public json!: any;
|
||||
public json!: any
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import {Singleton, Inject} from '../di'
|
||||
import {Singleton} from '../di'
|
||||
import {CanonicalRecursive} from './CanonicalRecursive'
|
||||
import {Logging} from './Logging'
|
||||
|
||||
/**
|
||||
* Canonical unit that loads configuration files from `app/configs`.
|
||||
*/
|
||||
@Singleton()
|
||||
export class Config extends CanonicalRecursive {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
protected appPath: string[] = ['configs']
|
||||
|
||||
protected suffix = '.config'
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface BusInternalSubscription {
|
||||
*/
|
||||
@Singleton()
|
||||
export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<TEvent>, AwareOfContainerLifecycle {
|
||||
awareOfContainerLifecycle: true = true
|
||||
awareOfContainerLifecycle = true as const
|
||||
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
@@ -11,7 +11,7 @@ import {CanonicalItemClass} from '../CanonicalReceiver'
|
||||
*/
|
||||
@Injectable()
|
||||
export class LocalBus<TEvent extends Event = Event> extends CanonicalItemClass implements EventBus<TEvent>, AwareOfContainerLifecycle {
|
||||
awareOfContainerLifecycle: true = true
|
||||
awareOfContainerLifecycle = true as const
|
||||
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
@@ -12,7 +12,7 @@ import {getEventName} from './getEventName'
|
||||
*/
|
||||
@Injectable()
|
||||
export class RedisBus implements EventBus, AwareOfContainerLifecycle {
|
||||
awareOfContainerLifecycle: true = true
|
||||
awareOfContainerLifecycle = true as const
|
||||
|
||||
@Inject()
|
||||
protected readonly redis!: Redis
|
||||
|
||||
@@ -100,7 +100,7 @@ export class StateEventSerializer extends BaseSerializer<StateEvent<JSONState>,
|
||||
protected readonly injector!: Container
|
||||
|
||||
/** The StateEvent implementation. */
|
||||
public readonly eventClass: Instantiable<StateEvent<JSONState>>;
|
||||
public readonly eventClass: Instantiable<StateEvent<JSONState>>
|
||||
|
||||
constructor(
|
||||
eventClass: Instantiable<StateEvent<JSONState>>,
|
||||
|
||||
@@ -23,7 +23,7 @@ import {Request} from '../../http/lifecycle/Request'
|
||||
|
||||
@Injectable()
|
||||
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
|
||||
|
||||
@@ -45,7 +45,7 @@ export function deepCopy<T>(target: T): T {
|
||||
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 }
|
||||
Object.keys(copy).forEach(key => {
|
||||
copy[key] = deepCopy<any>(copy[key])
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as fs from 'fs'
|
||||
import {Readable, Writable} from 'stream'
|
||||
import {Collection} from '../../collection/Collection'
|
||||
import {UniversalPath} from '../path'
|
||||
import {Maybe} from '../types'
|
||||
|
||||
/**
|
||||
* 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 metaPath = this.metadataPath(storePath)
|
||||
await new Promise<void>((res, rej) => {
|
||||
sftp.writeFile(metaPath, JSON.stringify(meta), err => {
|
||||
sftp.writeFile(metaPath, JSON.stringify(meta), (err: Maybe<Error>) => {
|
||||
if ( err ) {
|
||||
rej(err)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user