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

@loopback/context

Package Overview
Dependencies
Maintainers
10
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loopback/context - npm Package Compare versions

Comparing version 5.0.5 to 5.0.6

2

dist/binding-filter.d.ts

@@ -42,3 +42,3 @@ import { Binding, BindingTag } from './binding';

*/
export declare type BindingSelector<ValueType = unknown> = BindingAddress<ValueType> | BindingFilter;
export type BindingSelector<ValueType = unknown> = BindingAddress<ValueType> | BindingFilter;
/**

@@ -45,0 +45,0 @@ * Type guard for binding address

@@ -11,3 +11,3 @@ import { MetadataAccessor } from '@loopback/metadata';

*/
export declare type BindingMetadata<T = unknown> = {
export type BindingMetadata<T = unknown> = {
/**

@@ -29,3 +29,3 @@ * An array of template functions to configure a binding

*/
export declare type BindingScopeAndTags = {
export type BindingScopeAndTags = {
scope?: BindingScope;

@@ -37,3 +37,3 @@ tags?: BindingTag | BindingTag[];

*/
export declare type BindingSpec<T = unknown> = BindingTemplate<T> | BindingScopeAndTags;
export type BindingSpec<T = unknown> = BindingTemplate<T> | BindingScopeAndTags;
/**

@@ -99,3 +99,3 @@ * Check if a class implements `Provider` interface

*/
export declare type TypeNamespaceMapping = {
export type TypeNamespaceMapping = {
[name: string]: string;

@@ -107,3 +107,3 @@ };

*/
export declare type BindingFromClassOptions = {
export type BindingFromClassOptions = {
/**

@@ -110,0 +110,0 @@ * Binding key

@@ -1,2 +0,2 @@

export declare type BindingAddress<T = unknown> = string | BindingKey<T>;
export type BindingAddress<T = unknown> = string | BindingKey<T>;
export declare class BindingKey<ValueType> {

@@ -3,0 +3,0 @@ readonly key: string;

@@ -11,6 +11,2 @@ "use strict";

class BindingKey {
constructor(key, propertyPath) {
this.key = key;
this.propertyPath = propertyPath;
}
/**

@@ -41,2 +37,6 @@ * Create a new key for a binding bound to a value of type `ValueType`.

}
constructor(key, propertyPath) {
this.key = key;
this.propertyPath = propertyPath;
}
toString() {

@@ -43,0 +43,0 @@ return this.propertyPath

@@ -158,3 +158,3 @@ /// <reference types="node" />

*/
export declare type ConstantBindingSource<T> = {
export type ConstantBindingSource<T> = {
type: BindingType.CONSTANT;

@@ -166,3 +166,3 @@ value: T;

*/
export declare type DynamicValueBindingSource<T> = {
export type DynamicValueBindingSource<T> = {
type: BindingType.DYNAMIC_VALUE;

@@ -174,3 +174,3 @@ value: ValueFactory<T> | DynamicValueProviderClass<T>;

*/
export declare type ClassBindingSource<T> = {
export type ClassBindingSource<T> = {
type: BindingType.CLASS;

@@ -182,3 +182,3 @@ value: Constructor<T>;

*/
export declare type ProviderBindingSource<T> = {
export type ProviderBindingSource<T> = {
type: BindingType.PROVIDER;

@@ -190,3 +190,3 @@ value: Constructor<Provider<T>>;

*/
export declare type AliasBindingSource<T> = {
export type AliasBindingSource<T> = {
type: BindingType.ALIAS;

@@ -198,16 +198,16 @@ value: BindingAddress<T>;

*/
export declare type BindingSource<T> = ConstantBindingSource<T> | DynamicValueBindingSource<T> | ClassBindingSource<T> | ProviderBindingSource<T> | AliasBindingSource<T>;
export declare type TagMap = MapObject<any>;
export type BindingSource<T> = ConstantBindingSource<T> | DynamicValueBindingSource<T> | ClassBindingSource<T> | ProviderBindingSource<T> | AliasBindingSource<T>;
export type TagMap = MapObject<any>;
/**
* Binding tag can be a simple name or name/value pairs
*/
export declare type BindingTag = TagMap | string;
export type BindingTag = TagMap | string;
/**
* A function as the template to configure bindings
*/
export declare type BindingTemplate<T = unknown> = (binding: Binding<T>) => void;
export type BindingTemplate<T = unknown> = (binding: Binding<T>) => void;
/**
* Information for a binding event
*/
export declare type BindingEvent = {
export type BindingEvent = {
/**

@@ -229,3 +229,3 @@ * Event type

*/
export declare type BindingEventListener = (
export type BindingEventListener = (
/**

@@ -238,3 +238,3 @@ * Binding event

*/
export declare type ValueFactory<T = unknown> = (resolutionCtx: ResolutionContext) => ValueOrPromise<T | undefined>;
export type ValueFactory<T = unknown> = (resolutionCtx: ResolutionContext) => ValueOrPromise<T | undefined>;
/**

@@ -241,0 +241,0 @@ * A class with a static `value` method as the factory function for

@@ -203,12 +203,2 @@ "use strict";

class Binding extends events_1.EventEmitter {
constructor(key, isLocked = false) {
super();
this.isLocked = isLocked;
/**
* Map for tag name/value pairs
*/
this.tagMap = {};
binding_key_1.BindingKey.validate(key);
this.key = key.toString();
}
/**

@@ -252,2 +242,12 @@ * Scope of the binding to control how the value is cached/shared

}
constructor(key, isLocked = false) {
super();
this.isLocked = isLocked;
/**
* Map for tag name/value pairs
*/
this.tagMap = {};
binding_key_1.BindingKey.validate(key);
this.key = key.toString();
}
/**

@@ -254,0 +254,0 @@ * Cache the resolved value by the binding scope

@@ -6,3 +6,3 @@ import { Binding } from './binding';

*/
export declare type ContextEvent = {
export type ContextEvent = {
/**

@@ -24,2 +24,2 @@ * Source context that emits the event

*/
export declare type ContextEventListener = (event: ContextEvent) => void;
export type ContextEventListener = (event: ContextEvent) => void;

@@ -9,3 +9,3 @@ import { Binding } from './binding';

*/
export declare type ContextEventType = 'bind' | 'unbind' | string;
export type ContextEventType = 'bind' | 'unbind' | string;
/**

@@ -17,3 +17,3 @@ * Listen on `bind`, `unbind`, or other events

*/
export declare type ContextObserverFn = (eventType: ContextEventType, binding: Readonly<Binding<unknown>>, context: Context) => ValueOrPromise<void>;
export type ContextObserverFn = (eventType: ContextEventType, binding: Readonly<Binding<unknown>>, context: Context) => ValueOrPromise<void>;
/**

@@ -38,2 +38,2 @@ * Observers of context bind/unbind events

*/
export declare type ContextEventObserver = ContextObserver | ContextObserverFn;
export type ContextEventObserver = ContextObserver | ContextObserverFn;

@@ -159,3 +159,6 @@ "use strict";

};
options.session = resolution_session_1.ResolutionSession.fork(options.session);
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `view` resolution to avoid
// possible circular dependencies
options.session = undefined;
return b.getValue(this.context, options);

@@ -162,0 +165,0 @@ });

@@ -11,3 +11,2 @@ "use strict";

const inject_1 = require("./inject");
const resolution_session_1 = require("./resolution-session");
const value_promise_1 = require("./value-promise");

@@ -132,4 +131,2 @@ /**

const bindingKey = getTargetBindingKey(injection, session);
// We need to clone the session for the getter as it will be resolved later
const forkedSession = resolution_session_1.ResolutionSession.fork(session);
const meta = injection.metadata;

@@ -141,3 +138,6 @@ return async function getter() {

return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, {
session: forkedSession,
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `getter` resolution to avoid
// possible circular dependencies
session: undefined,
optional: meta.optional,

@@ -144,0 +144,0 @@ });

@@ -85,3 +85,3 @@ import { MetadataMap } from '@loopback/metadata';

*/
export declare type Getter<T> = () => Promise<T>;
export type Getter<T> = () => Promise<T>;
export declare namespace Getter {

@@ -105,3 +105,3 @@ /**

*/
export declare type Setter<T> = (value: T) => void;
export type Setter<T> = (value: T) => void;
/**

@@ -108,0 +108,0 @@ * Metadata for `@inject.binding`

@@ -258,6 +258,7 @@ "use strict";

const bindingSelector = injection.bindingSelector;
// We need to clone the session for the getter as it will be resolved later
const forkedSession = resolution_session_1.ResolutionSession.fork(session);
const options = {
session: forkedSession,
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `getter` resolution to avoid
// possible circular dependencies
session: undefined,
...injection.metadata,

@@ -264,0 +265,0 @@ };

@@ -9,3 +9,3 @@ import { Context } from './context';

*/
export declare type AsValueOrPromise<T> = T extends Promise<unknown> ? T : ValueOrPromise<T>;
export type AsValueOrPromise<T> = T extends Promise<unknown> ? T : ValueOrPromise<T>;
/**

@@ -15,3 +15,3 @@ * The intercepted variant of a function to return `ValueOrPromise<T>`.

*/
export declare type AsInterceptedFunction<T> = T extends (...args: InvocationArgs) => infer R ? (...args: Parameters<T>) => AsValueOrPromise<R> : T;
export type AsInterceptedFunction<T> = T extends (...args: InvocationArgs) => infer R ? (...args: Parameters<T>) => AsValueOrPromise<R> : T;
/**

@@ -46,3 +46,3 @@ * The proxy type for `T`. The return type for any method of `T` with original

*/
export declare type AsyncProxy<T> = {
export type AsyncProxy<T> = {
[P in keyof T]: AsInterceptedFunction<T[P]>;

@@ -49,0 +49,0 @@ };

@@ -11,3 +11,3 @@ import { BindingFilter } from './binding-filter';

*/
export declare type NonVoid = string | number | boolean | null | undefined | object;
export type NonVoid = string | number | boolean | null | undefined | object;
/**

@@ -17,3 +17,3 @@ * The `next` function that can be used to invoke next generic interceptor in

*/
export declare type Next = () => ValueOrPromise<NonVoid>;
export type Next = () => ValueOrPromise<NonVoid>;
/**

@@ -53,3 +53,3 @@ * An interceptor function to be invoked in a chain for the given context.

*/
export declare type GenericInterceptor<C extends Context = Context> = (context: C, next: Next) => ValueOrPromise<NonVoid>;
export type GenericInterceptor<C extends Context = Context> = (context: C, next: Next) => ValueOrPromise<NonVoid>;
/**

@@ -61,3 +61,3 @@ * Interceptor function or a binding key that resolves a generic interceptor

*/
export declare type GenericInterceptorOrKey<C extends Context = Context> = BindingAddress<GenericInterceptor<C>> | GenericInterceptor<C>;
export type GenericInterceptorOrKey<C extends Context = Context> = BindingAddress<GenericInterceptor<C>> | GenericInterceptor<C>;
/**

@@ -64,0 +64,0 @@ * A chain of generic interceptors to be invoked for the given context

@@ -59,3 +59,3 @@ import { MetadataAccessor } from '@loopback/metadata';

*/
export declare type InterceptorOrKey = GenericInterceptorOrKey<InvocationContext>;
export type InterceptorOrKey = GenericInterceptorOrKey<InvocationContext>;
/**

@@ -62,0 +62,0 @@ * Metadata key for method-level interceptors

@@ -7,7 +7,7 @@ import { Context } from './context';

*/
export declare type InvocationResult = any;
export type InvocationResult = any;
/**
* Array of arguments for a method invocation
*/
export declare type InvocationArgs = any[];
export type InvocationArgs = any[];
/**

@@ -73,3 +73,3 @@ * An interface to represent the caller of the invocation

*/
export declare type InvocationOptions = {
export type InvocationOptions = {
/**

@@ -76,0 +76,0 @@ * Skip dependency injection on method parameters

@@ -11,3 +11,3 @@ /**

*/
export declare type JSONPrimitive = string | number | boolean | null;
export type JSONPrimitive = string | number | boolean | null;
/**

@@ -19,3 +19,3 @@ * JSON values

*/
export declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
/**

@@ -22,0 +22,0 @@ * JSON object

@@ -9,3 +9,3 @@ import { Binding } from './binding';

*/
export declare type ResolutionAction = (session: ResolutionSession) => ValueOrPromise<BoundValue>;
export type ResolutionAction = (session: ResolutionSession) => ValueOrPromise<BoundValue>;
/**

@@ -33,3 +33,3 @@ * Wrapper for bindings tracked by resolution sessions

*/
export declare type ResolutionElement = BindingElement | InjectionElement;
export type ResolutionElement = BindingElement | InjectionElement;
/**

@@ -145,3 +145,3 @@ * Object to keep states for a session to resolve bindings and their

*/
export declare type ResolutionOptionsOrSession = ResolutionOptions | ResolutionSession;
export type ResolutionOptionsOrSession = ResolutionOptions | ResolutionSession;
/**

@@ -148,0 +148,0 @@ * Normalize ResolutionOptionsOrSession to ResolutionOptions

/**
* A class constructor accepting arbitrary arguments.
*/
export declare type Constructor<T> = new (...args: any[]) => T;
export declare type BoundValue = any;
export type Constructor<T> = new (...args: any[]) => T;
export type BoundValue = any;
/**

@@ -15,4 +15,4 @@ * Representing a value or promise. This type is used to represent results of

*/
export declare type ValueOrPromise<T> = T | PromiseLike<T>;
export declare type MapObject<T> = Record<string, T>;
export type ValueOrPromise<T> = T | PromiseLike<T>;
export type MapObject<T> = Record<string, T>;
/**

@@ -19,0 +19,0 @@ * Check whether a value is a Promise-like instance.

{
"name": "@loopback/context",
"description": "Facilities to manage artifacts and their dependencies in your Node.js applications. The module exposes TypeScript/JavaScript APIs and decorators to register artifacts, declare dependencies, and resolve artifacts by keys. It also serves as an IoC container to support dependency injection",
"version": "5.0.5",
"version": "5.0.6",
"keywords": [

@@ -46,3 +46,3 @@ "LoopBack",

"dependencies": {
"@loopback/metadata": "^5.0.5",
"@loopback/metadata": "^5.0.6",
"@types/debug": "^4.1.7",

@@ -56,11 +56,11 @@ "debug": "^4.3.4",

"devDependencies": {
"@loopback/build": "^9.0.5",
"@loopback/eslint-config": "^13.0.5",
"@loopback/testlab": "^5.0.5",
"@types/bluebird": "^3.5.37",
"@types/node": "^14.18.33",
"@types/uuid": "^8.3.4",
"@loopback/build": "^9.0.6",
"@loopback/eslint-config": "^13.0.6",
"@loopback/testlab": "^5.0.6",
"@types/bluebird": "^3.5.38",
"@types/node": "^14.18.34",
"@types/uuid": "^9.0.0",
"bluebird": "^3.7.2"
},
"gitHead": "2d762e2a1bcc73263dd7776e072b3ec3a9279472"
"gitHead": "709a5ecd1ffddeb02262cecabf7b663c7b4d7e47"
}

@@ -208,3 +208,6 @@ // Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.

};
options.session = ResolutionSession.fork(options.session);
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `view` resolution to avoid
// possible circular dependencies
options.session = undefined;
return b.getValue(this.context, options);

@@ -211,0 +214,0 @@ });

@@ -178,4 +178,2 @@ // Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved.

const bindingKey = getTargetBindingKey(injection, session);
// We need to clone the session for the getter as it will be resolved later
const forkedSession = ResolutionSession.fork(session);
const meta = injection.metadata;

@@ -186,3 +184,6 @@ return async function getter() {

return ctx.getConfigAsValueOrPromise(bindingKey, meta.propertyPath, {
session: forkedSession,
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `getter` resolution to avoid
// possible circular dependencies
session: undefined,
optional: meta.optional,

@@ -189,0 +190,0 @@ });

@@ -437,6 +437,7 @@ // Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.

const bindingSelector = injection.bindingSelector as BindingAddress;
// We need to clone the session for the getter as it will be resolved later
const forkedSession = ResolutionSession.fork(session);
const options: ResolutionOptions = {
session: forkedSession,
// https://github.com/loopbackio/loopback-next/issues/9041
// We should start with a new session for `getter` resolution to avoid
// possible circular dependencies
session: undefined,
...injection.metadata,

@@ -443,0 +444,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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