@poppinss/manager
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,6 +0,6 @@ | ||
export interface ManagerContract<DriverContract extends any, MappingsList extends { | ||
[key: string]: DriverContract; | ||
export interface ManagerContract<DriverContract extends any, ReturnValueContract extends any = DriverContract, MappingsList extends { | ||
[key: string]: ReturnValueContract; | ||
} = { | ||
[key: string]: DriverContract; | ||
}, DefaultItem extends DriverContract = DriverContract> { | ||
[key: string]: ReturnValueContract; | ||
}, DefaultItem extends ReturnValueContract = ReturnValueContract> { | ||
use<K extends keyof MappingsList>(name: K): MappingsList[K]; | ||
@@ -11,15 +11,7 @@ use(name: string): DefaultItem; | ||
} | ||
export declare type ExtractImplementations<List extends { | ||
[key: string]: { | ||
implementation: any; | ||
}; | ||
}> = { | ||
export declare type ExtractImplementations<List extends any> = { | ||
[P in keyof List]: List[P]['implementation']; | ||
}; | ||
export declare type ExtractConfig<List extends { | ||
[key: string]: { | ||
config: any; | ||
}; | ||
}> = { | ||
export declare type ExtractConfig<List extends any> = { | ||
[P in keyof List]: List[P]['config']; | ||
}; |
import { ManagerContract } from './contracts'; | ||
export declare abstract class Manager<DriverContract extends any, MappingsList extends { | ||
[key: string]: DriverContract; | ||
export declare abstract class Manager<DriverContract extends any, ReturnValueContract extends any = DriverContract, MappingsList extends { | ||
[key: string]: ReturnValueContract; | ||
} = { | ||
[key: string]: DriverContract; | ||
}, DefaultItem extends DriverContract = DriverContract> implements ManagerContract<DriverContract, MappingsList, DefaultItem> { | ||
[key: string]: ReturnValueContract; | ||
}, DefaultItem extends ReturnValueContract = ReturnValueContract> implements ManagerContract<DriverContract, ReturnValueContract, MappingsList, DefaultItem> { | ||
protected $container: any; | ||
@@ -14,2 +14,3 @@ private _mappingsCache; | ||
protected abstract getMappingDriver(mappingName: string): string | undefined; | ||
protected wrapDriverResponse(value: DriverContract): ReturnValueContract; | ||
constructor($container: any); | ||
@@ -21,5 +22,5 @@ private _getFromCache; | ||
use<K extends keyof MappingsList>(name: K): MappingsList[K]; | ||
use(name: string): DriverContract; | ||
use(name: string): ReturnValueContract; | ||
use(): DefaultItem; | ||
extend(name: string, callback: (container: any, mappingName: string, config: any) => DriverContract): void; | ||
} |
@@ -9,2 +9,5 @@ "use strict"; | ||
} | ||
wrapDriverResponse(value) { | ||
return value; | ||
} | ||
_getFromCache(name) { | ||
@@ -19,3 +22,3 @@ return this._mappingsCache.get(name) || null; | ||
_makeExtendedDriver(mappingName, driver, config) { | ||
const value = this._extendedDrivers[driver](this.$container, mappingName, config); | ||
const value = this.wrapDriverResponse(this._extendedDrivers[driver](this.$container, mappingName, config)); | ||
this._saveToCache(mappingName, value); | ||
@@ -29,3 +32,3 @@ return value; | ||
} | ||
const value = this[driverCreatorName](mappingName, config); | ||
const value = this.wrapDriverResponse(this[driverCreatorName](mappingName, config)); | ||
this._saveToCache(mappingName, value); | ||
@@ -32,0 +35,0 @@ return value; |
{ | ||
"name": "@poppinss/manager", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "The builder (Manager) pattern implementation", | ||
@@ -12,3 +12,3 @@ "scripts": { | ||
"compile": "npm run lint && npm run clean && tsc", | ||
"build": "npm run compile && typedoc --theme markdown --excludePrivate --mdHideSources && git add docs", | ||
"build": "npm run compile && typedoc --theme markdown --excludePrivate --HideSources && git add docs", | ||
"commit": "git-cz", | ||
@@ -26,18 +26,18 @@ "release": "np", | ||
"@adonisjs/mrm-preset": "^2.1.0", | ||
"@types/node": "^12.7.2", | ||
"@types/node": "^12.7.5", | ||
"commitizen": "^4.0.3", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"del-cli": "^2.0.0", | ||
"del-cli": "^3.0.0", | ||
"doctoc": "^1.4.0", | ||
"husky": "^3.0.4", | ||
"japa": "^3.0.0", | ||
"husky": "^3.0.5", | ||
"japa": "^3.0.1", | ||
"mrm": "^1.2.2", | ||
"np": "^5.0.3", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.19.0", | ||
"np": "^5.1.0", | ||
"ts-node": "^8.4.1", | ||
"tslint": "^5.20.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typedoc": "^0.15.0", | ||
"typedoc-plugin-external-module-name": "^2.1.0", | ||
"typedoc-plugin-markdown": "^2.1.4", | ||
"typescript": "^3.6.2" | ||
"typedoc-plugin-markdown": "^2.2.4", | ||
"typescript": "^3.6.3" | ||
}, | ||
@@ -44,0 +44,0 @@ "nyc": { |
@@ -208,2 +208,3 @@ <div align="center"> | ||
MailDriverContract, | ||
MailDriverContract, | ||
MappingsList | ||
@@ -280,2 +281,3 @@ > { | ||
MailDriverContract, | ||
MailDriverContract, | ||
ExtractImplementations<MappingsList> | ||
@@ -282,0 +284,0 @@ > { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15943
307
101