Skip to content

Commit

Permalink
refactor: drop Contract keyword from everything except implmentable i…
Browse files Browse the repository at this point in the history
…nterfaces
  • Loading branch information
thetutlage committed Apr 6, 2020
1 parent 5c150b8 commit b5302d5
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 68 deletions.
84 changes: 42 additions & 42 deletions adonis-typings/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Migrations config
*/
export type MigratorConfigContract = {
export type MigratorConfig = {
disableTransactions?: boolean,
paths?: string[],
tableName?: string,
Expand All @@ -261,7 +261,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
asyncStackTraces?: boolean,
revision?: number,
healthCheck?: boolean,
migrations?: MigratorConfigContract,
migrations?: MigratorConfig,
pool?: {
afterCreate?: (conn: any, done: any) => void,
min?: number,
Expand All @@ -284,7 +284,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Knex forwards all config options to the driver directly. So feel
* free to define them (let us know, in case any options are missing)
*/
export type SqliteConfigContract = SharedConfigNode & {
export type SqliteConfig = SharedConfigNode & {
client: 'sqlite' | 'sqlite3',
connection: {
filename: string,
Expand Down Expand Up @@ -314,18 +314,18 @@ declare module '@ioc:Adonis/Lucid/Database' {
flags?: string,
ssl?: any,
}
export type MysqlConfigContract = SharedConfigNode & {
export type MysqlConfig = SharedConfigNode & {
client: 'mysql',
version?: string,
connection?: SharedConnectionNode & MysqlConnectionNode,
replicas?: {
write: {
connection: MysqlConfigContract['connection'],
pool?: MysqlConfigContract['pool'],
connection: MysqlConfig['connection'],
pool?: MysqlConfig['pool'],
}
read: {
connection: MysqlConfigContract['connection'][],
pool?: MysqlConfigContract['pool'],
connection: MysqlConfig['connection'][],
pool?: MysqlConfig['pool'],
},
},
}
Expand All @@ -337,7 +337,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Knex forwards all config options to the driver directly. So feel
* free to define them (let us know, in case any options are missing)
*/
export type Mysql2ConfigContract = MysqlConfigContract & {
export type Mysql2Config = MysqlConfig & {
client: 'mysql2',
}

Expand All @@ -351,19 +351,19 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Knex forwards all config options to the driver directly. So feel
* free to define them (let us know, in case any options are missing)
*/
export type PostgreConfigContract = SharedConfigNode & {
export type PostgreConfig = SharedConfigNode & {
client: 'pg' | 'postgres' | 'postgresql',
version?: string,
returning?: string,
connection?: string | SharedConnectionNode,
replicas?: {
write: {
connection: PostgreConfigContract['connection'],
pool?: PostgreConfigContract['pool'],
connection: PostgreConfig['connection'],
pool?: PostgreConfig['pool'],
}
read: {
connection: PostgreConfigContract['connection'][],
pool?: PostgreConfigContract['pool'],
connection: PostgreConfig['connection'][],
pool?: PostgreConfig['pool'],
},
},
searchPath?: string[],
Expand All @@ -376,7 +376,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Knex forwards all config options to the driver directly. So feel
* free to define them (let us know, in case any options are missing)
*/
export type RedshiftConfigContract = PostgreConfigContract & {
export type RedshiftConfig = PostgreConfig & {
client: 'redshift',
}

Expand All @@ -399,17 +399,17 @@ declare module '@ioc:Adonis/Lucid/Database' {
maxRows?: number,
oracleClientVersion?: number,
}
export type OracleConfigContract = SharedConfigNode & {
export type OracleConfig = SharedConfigNode & {
client: 'oracledb',
connection?: SharedConnectionNode & OracleConnectionNode,
replicas?: {
write: {
connection: OracleConfigContract['connection'],
pool?: OracleConfigContract['pool'],
connection: OracleConfig['connection'],
pool?: OracleConfig['pool'],
}
read: {
connection: OracleConfigContract['connection'][],
pool?: OracleConfigContract['pool'],
connection: OracleConfig['connection'][],
pool?: OracleConfig['pool'],
},
},
fetchAsString?: any[],
Expand All @@ -429,18 +429,18 @@ declare module '@ioc:Adonis/Lucid/Database' {
requestTimeout?: number,
parseJSON?: boolean,
}
export type MssqlConfigContract = SharedConfigNode & {
export type MssqlConfig = SharedConfigNode & {
client: 'mssql',
version?: string,
connection?: SharedConnectionNode & MssqlConnectionNode,
replicas?: {
write: {
connection: MssqlConfigContract['connection'],
pool?: MssqlConfigContract['pool'],
connection: MssqlConfig['connection'],
pool?: MssqlConfig['pool'],
}
read: {
connection: MssqlConfigContract['connection'][],
pool?: MssqlConfigContract['pool'],
connection: MssqlConfig['connection'][],
pool?: MssqlConfig['pool'],
},
},
}
Expand All @@ -449,29 +449,29 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Connection config must be the config from one of the
* available dialects
*/
export type ConnectionConfigContract =
SqliteConfigContract |
MysqlConfigContract |
PostgreConfigContract |
OracleConfigContract |
RedshiftConfigContract |
Mysql2ConfigContract |
MssqlConfigContract
export type ConnectionConfig =
SqliteConfig |
MysqlConfig |
PostgreConfig |
OracleConfig |
RedshiftConfig |
Mysql2Config |
MssqlConfig

/**
* Shape of config inside the database config file
*/
export type DatabaseConfigContract = {
export type DatabaseConfig = {
connection: string,
connections: { [key: string]: ConnectionConfigContract },
connections: { [key: string]: ConnectionConfig },
}

/**
* The shape of a connection within the connection manager
*/
export type ConnectionManagerConnectionNode = {
export type ConnectionNode = {
name: string,
config: ConnectionConfigContract,
config: ConnectionConfig,
connection?: ConnectionContract,
state: 'registered' | 'migrating' | 'open' | 'closed',
}
Expand All @@ -485,7 +485,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* List of registered connection. You must check the connection state
* to understand, if it is connected or not
*/
connections: Map<string, ConnectionManagerConnectionNode>
connections: Map<string, ConnectionNode>

/**
* Everytime a connection is created
Expand All @@ -506,7 +506,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Add a new connection to the list of managed connection. You must call
* connect seperately to instantiate a connection instance
*/
add (connectionName: string, config: ConnectionConfigContract): void
add (connectionName: string, config: ConnectionConfig): void

/**
* Instantiate a connection. It is a noop, when connection for the given
Expand All @@ -517,7 +517,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Get connection node
*/
get (connectionName: string): ConnectionManagerConnectionNode | undefined
get (connectionName: string): ConnectionNode | undefined

/**
* Find if a connection name is managed by the manager or not
Expand All @@ -528,7 +528,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Patch the existing connection config. This triggers the disconnect on the
* old connection
*/
patch (connectionName: string, config: ConnectionConfigContract): void
patch (connectionName: string, config: ConnectionConfig): void

/**
* Find if a managed connection is instantiated or not
Expand Down Expand Up @@ -585,7 +585,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Untouched config
*/
config: ConnectionConfigContract,
config: ConnectionConfig,

/**
* List of emitted events
Expand Down
4 changes: 2 additions & 2 deletions adonis-typings/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ declare module '@ioc:Adonis/Lucid/Model' {
/**
* Used to construct defaults for the model
*/
$configurator: OrmConfigContract,
$configurator: OrmConfig,

/**
* A copy of internal keys mapping. One should be able to resolve between
Expand Down Expand Up @@ -867,7 +867,7 @@ declare module '@ioc:Adonis/Lucid/Model' {
* Shape of ORM config to have a standard place for computing
* defaults
*/
export type OrmConfigContract = {
export type OrmConfig = {
/**
* Return the default table name for a given model
*/
Expand Down
2 changes: 1 addition & 1 deletion adonis-typings/orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare module '@ioc:Adonis/Lucid/Orm' {
HasManyThrough,
} from '@ioc:Adonis/Lucid/Relations'

export { OrmConfigContract, ModelQueryBuilderContract } from '@ioc:Adonis/Lucid/Model'
export { OrmConfig, ModelQueryBuilderContract } from '@ioc:Adonis/Lucid/Model'

export const scope: ScopeFn
export const BaseModel: LucidModel
Expand Down
10 changes: 5 additions & 5 deletions src/Connection/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { HealthReportEntry } from '@ioc:Adonis/Core/HealthCheck'

import {
ReportNode,
ConnectionNode,
ConnectionConfig,
ConnectionContract,
ConnectionConfigContract,
ConnectionManagerContract,
ConnectionManagerConnectionNode,
} from '@ioc:Adonis/Lucid/Database'

import { Connection } from './index'
Expand Down Expand Up @@ -105,7 +105,7 @@ export class ConnectionManager extends EventEmitter implements ConnectionManager
* Add a named connection with it's configuration. Make sure to call `connect`
* before using the connection to make database queries.
*/
public add (connectionName: string, config: ConnectionConfigContract): void {
public add (connectionName: string, config: ConnectionConfig): void {
/**
* Noop when connection already exists. If one wants to change the config, they
* must release the old connection and add a new one
Expand Down Expand Up @@ -153,7 +153,7 @@ export class ConnectionManager extends EventEmitter implements ConnectionManager
/**
* Patching the config
*/
public patch (connectionName: string, config: ConnectionConfigContract): void {
public patch (connectionName: string, config: ConnectionConfig): void {
const connection = this.get(connectionName)

/**
Expand Down Expand Up @@ -190,7 +190,7 @@ export class ConnectionManager extends EventEmitter implements ConnectionManager
/**
* Returns the connection node for a given named connection
*/
public get (connectionName: string): ConnectionManagerConnectionNode | undefined {
public get (connectionName: string): ConnectionNode | undefined {
return this.connections.get(connectionName)
}

Expand Down
8 changes: 4 additions & 4 deletions src/Connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EventEmitter } from 'events'
import { Exception } from '@poppinss/utils'
import { patchKnex } from 'knex-dynamic-connection'
import { LoggerContract } from '@ioc:Adonis/Core/Logger'
import { ConnectionConfigContract, ConnectionContract, ReportNode } from '@ioc:Adonis/Lucid/Database'
import { ConnectionConfig, ConnectionContract, ReportNode } from '@ioc:Adonis/Lucid/Database'

import { Logger } from './Logger'

Expand Down Expand Up @@ -60,7 +60,7 @@ export class Connection extends EventEmitter implements ConnectionContract {

constructor (
public readonly name: string,
public config: ConnectionConfigContract,
public config: ConnectionConfig,
private logger: LoggerContract,
) {
super()
Expand Down Expand Up @@ -204,14 +204,14 @@ export class Connection extends EventEmitter implements ConnectionContract {
/**
* Resolves connection config for the writer connection
*/
private writeConfigResolver (originalConfig: ConnectionConfigContract) {
private writeConfigResolver (originalConfig: ConnectionConfig) {
return originalConfig.connection
}

/**
* Resolves connection config for the reader connection
*/
private readConfigResolver (originalConfig: ConnectionConfigContract) {
private readConfigResolver (originalConfig: ConnectionConfig) {
if (!this.readReplicas.length) {
return originalConfig.connection
}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { LoggerContract } from '@ioc:Adonis/Core/Logger'
import { ProfilerContract } from '@ioc:Adonis/Core/Profiler'

import {
DatabaseConfig,
DatabaseContract,
DatabaseClientOptions,
DatabaseConfigContract,
TransactionClientContract,
ConnectionManagerContract,
} from '@ioc:Adonis/Lucid/Database'
Expand Down Expand Up @@ -58,7 +58,7 @@ export class Database implements DatabaseContract {
public connectionGlobalTransactions: Map<string, TransactionClientContract> = new Map()

constructor (
private config: DatabaseConfigContract,
private config: DatabaseConfig,
private logger: LoggerContract,
private profiler: ProfilerContract,
) {
Expand Down
6 changes: 3 additions & 3 deletions src/Migrator/MigrationSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

/// <reference path="../../adonis-typings/index.ts" />

import { esmRequire, fsReadAll } from '@poppinss/utils'
import { join, isAbsolute, extname } from 'path'
import { esmRequire, fsReadAll } from '@poppinss/utils'
import { MigrationNode } from '@ioc:Adonis/Lucid/Migrator'
import { ConnectionConfig } from '@ioc:Adonis/Lucid/Database'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { ConnectionConfigContract } from '@ioc:Adonis/Lucid/Database'

/**
* Migration source exposes the API to read the migration files
* from disk for a given connection.
*/
export class MigrationSource {
constructor (
private config: ConnectionConfigContract,
private config: ConnectionConfig,
private app: ApplicationContract,
) {}

Expand Down
Loading

0 comments on commit b5302d5

Please sign in to comment.