Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knifecycle

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knifecycle - npm Package Compare versions

Comparing version 7.0.3 to 8.0.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# [8.0.0](https://github.com/nfroidure/knifecycle/compare/v7.0.3...v8.0.0) (2019-12-07)
### Bug Fixes
* **types:** fix handler types ([4d975df](https://github.com/nfroidure/knifecycle/commit/4d975dfefa77127ca9d7056cccd56d129238e9fb))
## [7.0.3](https://github.com/nfroidure/knifecycle/compare/v7.0.2...v7.0.3) (2019-12-02)

@@ -2,0 +11,0 @@

2

package.json
{
"name": "knifecycle",
"version": "7.0.3",
"version": "8.0.0",
"description": "Manage your NodeJS processes's lifecycle automatically with an unobtrusive dependency injection implementation.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

export type DependencyName = string;
export type Dependencies = { [name: string]: any };
export type DependencyDeclaration = string;
export type DependenciesDeclarations = DependencyDeclaration[];
export type Service = any;
export type Provider<S = Service> = {
service: S;
dispose?: () => Promise<void>;
fatalErrorPromise?: Promise<void>;
};
export type Dependencies<S = Service> = { [name: string]: S };
export type Services<S = Service> = { [name: string]: S };
export type Parameters = { [name: string]: any };
export interface ProviderInitializer<D extends Dependencies, S> {
(services?: D): Promise<{
service: S;
dispose?: () => Promise<void>;
fatalErrorPromise?: Promise<void>;
}>;
export interface HandlerFunction<D, P extends Parameters, U extends any[], R> {
(dependencies: D, parameters?: P, ...args: U): Promise<R>;
}
export interface ServiceInitializer<D extends Dependencies, S> {
(services?: D): Promise<S>;
export interface Handler<P extends Parameters, U extends any[], R> {
(parameters?: P, ...args: U): Promise<R>;
}
export interface HandlerInitializer<D extends Dependencies, U extends any[], V> {
(services?: D, ...args: U): Promise<V>;
export interface ProviderInitializer<D extends Dependencies, S = Service> {
(dependencies?: D): Promise<Provider<S>>;
}
export interface Handler<U extends any[], V> {
(...args: U): Promise<V>;
export interface ServiceInitializer<D extends Dependencies, S = Service> {
(dependencies?: D): Promise<S>;
}
export interface HandlerInitializer<D extends Dependencies, U extends any[], R, P = Parameters, S = Handler<P, U, R>> {
(dependencies?: D): Promise<S>;
}
export type Initializer<D extends Dependencies, S> =
| ServiceInitializer<D, S>
| ProviderInitializer<D, S>;
| ProviderInitializer<D, S>
| HandlerInitializer<D, any[], any, any, S>;
export type InitializerType = 'service' | 'provider' | 'constant';
export type DependenciesDeclarations = Array<DependencyName>;
export interface InitializerOptions {

@@ -34,3 +44,3 @@ singleton: boolean;

export interface InitializerDeclaration {
name: string;
name: DependencyName;
type: InitializerType;

@@ -42,4 +52,4 @@ inject?: DependenciesDeclarations;

export interface Injector {
(dependencies: DependenciesDeclarations): Promise<Dependencies>;
export interface Injector<S extends Services> {
(dependencies: DependenciesDeclarations): Promise<S>;
}

@@ -49,4 +59,4 @@ export interface Disposer {

}
export interface Autoloader<D> {
(name: DependencyName): Promise<D>;
export interface Autoloader<S = Service> {
(name: DependencyDeclaration): Promise<S>;
}

@@ -56,13 +66,13 @@ export interface FatalErrorProvider {

}
export interface SiloContext<D> {
export interface SiloContext<S extends Service> {
name: string,
servicesDescriptors: Map<DependencyName, D>,
servicesSequence: DependencyName[],
servicesShutdownsPromises: Map<DependencyName, Promise<void>>,
servicesDescriptors: Map<DependencyDeclaration, S>,
servicesSequence: DependencyDeclaration[],
servicesShutdownsPromises: Map<DependencyDeclaration, Promise<void>>,
errorsPromises: Promise<void>[],
}
export class Knifecycle {
export class Knifecycle<S = Services> {
constructor();
run(dependencies: DependenciesDeclarations): Promise<Dependencies>;
run<RS = S>(dependencies: DependenciesDeclarations): Promise<RS>;
destroy(): Promise<void>;

@@ -72,11 +82,24 @@ register<D extends Dependencies, S, T extends Initializer<D, S>>(

): Knifecycle;
toMermaidGraph({ shapes, styles, classes } : {
shapes: ({
pattern: RegExp,
template: string,
})[],
styles: ({
pattern: RegExp,
className: string,
})[],
classes: {
[name : string]: string,
},
}): string
}
export function initializer<
D extends Dependencies,
S,
T extends Initializer<D, S>
>(declaration: InitializerDeclaration, initializer: T): T;
export function initializer<D extends Dependencies, S, T extends Initializer<D, S>>(
declaration: InitializerDeclaration,
initializer: T
): T;
export function name<D extends Dependencies, S, T extends Initializer<D, S>>(
name: DependencyName,
name: DependencyDeclaration,
initializer: T,

@@ -126,3 +149,5 @@ ): T;

>(wrapper: Function, baseInitializer: T): T;
export function constant<S>(name: string, value: S): ServiceInitializer<any, S>;
export function service<

@@ -134,3 +159,3 @@ D extends Dependencies,

serviceBuilder: T,
name?: DependencyName,
name?: DependencyDeclaration,
dependencies?: DependenciesDeclarations,

@@ -144,2 +169,3 @@ options?: InitializerOptions,

>(serviceBuilder: T): T;
export function provider<

@@ -151,3 +177,3 @@ D extends Dependencies,

providerBuilder: T,
name?: DependencyName,
name?: DependencyDeclaration,
dependencies?: DependenciesDeclarations,

@@ -161,11 +187,22 @@ options?: InitializerOptions,

>(providerBuilder: T): T;
export function handler<D extends Dependencies, U extends any[], V>(
handlerInitializer: HandlerInitializer<D, U, V>,
name?: DependencyName,
export function handler<
D extends Dependencies,
P extends Parameters,
U extends any[],
R
>(
handlerFunction: HandlerFunction<D, P, U, R>,
name?: DependencyDeclaration,
dependencies?: DependenciesDeclarations,
options?: InitializerOptions,
): ServiceInitializer<D, Handler<U, V>>;
export function autoHandler<D extends Dependencies, U extends any[], V>(
handlerInitializer: HandlerInitializer<D, U, V>,
): ServiceInitializer<D, Handler<U, V>>;
): HandlerInitializer<D, U, R, P>;
export function autoHandler<
D extends Dependencies,
P extends Parameters,
U extends any[],
R
>(
handlerFunction: HandlerFunction<D, P, U, R>,
): HandlerInitializer<D, U, R, P>;

@@ -172,0 +209,0 @@ export const SPECIAL_PROPS: {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc