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

@feature-hub/core

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feature-hub/core - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.5.0](https://github.com/sinnerschrader/feature-hub/compare/v0.4.0...v0.5.0) (2018-12-11)
### Features
* **core:** separate configs for feature apps and services ([#165](https://github.com/sinnerschrader/feature-hub/issues/165)) ([bcff8fe](https://github.com/sinnerschrader/feature-hub/commit/bcff8fe)), closes [#133](https://github.com/sinnerschrader/feature-hub/issues/133)
# [0.4.0](https://github.com/sinnerschrader/feature-hub/compare/v0.3.0...v0.4.0) (2018-12-03)

@@ -8,0 +19,0 @@

34

lib/feature-app-manager.d.ts
import { AsyncValue } from './async-value';
import { FeatureServiceConsumerDefinition, FeatureServiceConsumerEnvironment, FeatureServiceProviderDefinition, FeatureServiceRegistryLike } from './feature-service-registry';
export interface FeatureAppDefinition<TFeatureApp> extends FeatureServiceConsumerDefinition {
import { FeatureServiceConsumerDefinition, FeatureServiceProviderDefinition, FeatureServiceRegistryLike, FeatureServices } from './feature-service-registry';
export interface FeatureAppEnvironment<TConfig, TFeatureServices extends FeatureServices> {
/**
* A Feature App config object that is provided by the integrator.
*/
readonly config: TConfig;
/**
* An object of required Feature Services that are semver-compatible with the
* declared dependencies in the Feature App definition.
*/
readonly featureServices: TFeatureServices;
}
export interface FeatureAppDefinition<TFeatureApp, TConfig = unknown, TFeatureServices extends FeatureServices = FeatureServices> extends FeatureServiceConsumerDefinition {
readonly ownFeatureServiceDefinitions?: FeatureServiceProviderDefinition[];
create(env: FeatureServiceConsumerEnvironment): TFeatureApp;
create(env: FeatureAppEnvironment<TConfig, TFeatureServices>): TFeatureApp;
}
export interface FeatureAppModule<TFeatureApp> {
readonly default: FeatureAppDefinition<TFeatureApp>;
}
export declare type ModuleLoader = (url: string) => Promise<unknown>;
export interface FeatureAppScope<TFeatureApp> {
readonly featureApp: TFeatureApp;
export interface FeatureAppScope {
readonly featureApp: unknown;
destroy(): void;
}
export interface FeatureAppConfigs {
readonly [featureAppId: string]: unknown;
}
export interface FeatureAppManagerLike {
getAsyncFeatureAppDefinition(url: string): AsyncValue<FeatureAppDefinition<unknown>>;
getFeatureAppScope(featureAppDefinition: FeatureAppDefinition<unknown>, idSpecifier?: string): FeatureAppScope<unknown>;
getFeatureAppScope(featureAppDefinition: FeatureAppDefinition<unknown>, idSpecifier?: string): FeatureAppScope;
preloadFeatureApp(url: string): Promise<void>;

@@ -24,8 +35,9 @@ destroy(): void;

private readonly loadModule;
private readonly configs;
private readonly asyncFeatureAppDefinitions;
private readonly featureAppDefinitionsWithRegisteredOwnFeatureServices;
private readonly featureAppScopes;
constructor(featureServiceRegistry: FeatureServiceRegistryLike, loadModule: ModuleLoader);
constructor(featureServiceRegistry: FeatureServiceRegistryLike, loadModule: ModuleLoader, configs?: FeatureAppConfigs);
getAsyncFeatureAppDefinition(url: string): AsyncValue<FeatureAppDefinition<unknown>>;
getFeatureAppScope(featureAppDefinition: FeatureAppDefinition<unknown>, idSpecifier?: string): FeatureAppScope<unknown>;
getFeatureAppScope(featureAppDefinition: FeatureAppDefinition<unknown>, idSpecifier?: string): FeatureAppScope;
preloadFeatureApp(url: string): Promise<void>;

@@ -32,0 +44,0 @@ destroy(): void;

@@ -6,5 +6,6 @@ "use strict";

class FeatureAppManager {
constructor(featureServiceRegistry, loadModule) {
constructor(featureServiceRegistry, loadModule, configs = Object.create(null)) {
this.featureServiceRegistry = featureServiceRegistry;
this.loadModule = loadModule;
this.configs = configs;
this.asyncFeatureAppDefinitions = new Map();

@@ -61,4 +62,8 @@ this.featureAppDefinitionsWithRegisteredOwnFeatureServices = new WeakSet();

createFeatureAppScope(featureAppDefinition, idSpecifier, deleteFeatureAppScope) {
const featureServiceBindings = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, idSpecifier);
const featureApp = featureAppDefinition.create(featureServiceBindings.consumerEnvironment);
const config = this.configs[featureAppDefinition.id];
const binding = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, idSpecifier);
const featureApp = featureAppDefinition.create({
config,
featureServices: binding.featureServices
});
console.info(`The feature app scope for the ID ${JSON.stringify(featureAppDefinition.id)} and its specifier ${JSON.stringify(idSpecifier)} has been successfully created.`);

@@ -71,3 +76,3 @@ let destroyed = false;

deleteFeatureAppScope();
featureServiceBindings.unbind();
binding.unbind();
destroyed = true;

@@ -74,0 +79,0 @@ };

@@ -11,2 +11,16 @@ export interface FeatureServiceConsumerDependencies {

}
export interface FeatureServiceEnvironment<TConfig, TFeatureServices extends FeatureServices> {
/**
* A Feature Service config object that is provided by the integrator.
*/
readonly config: TConfig;
/**
* An object of required Feature Services that are semver-compatible with the
* declared dependencies in the Feature App definition.
*/
readonly featureServices: TFeatureServices;
}
export interface FeatureServiceProviderDefinition<TConfig = unknown, TFeatureServices extends FeatureServices = FeatureServices> extends FeatureServiceConsumerDefinition {
create(env: FeatureServiceEnvironment<TConfig, TFeatureServices>): SharedFeatureService;
}
export interface FeatureServiceBinding<TFeatureService> {

@@ -16,10 +30,2 @@ readonly featureService: TFeatureService;

}
export interface FeatureServiceConsumerEnvironment {
readonly featureServices: FeatureServices;
readonly config: unknown;
}
export interface FeatureServiceBindings {
readonly consumerEnvironment: FeatureServiceConsumerEnvironment;
unbind(): void;
}
export declare type FeatureServiceBinder<TFeatureService> = (uniqueConsumerId: string) => FeatureServiceBinding<TFeatureService>;

@@ -29,20 +35,21 @@ export interface SharedFeatureService {

}
export interface FeatureServiceProviderDefinition extends FeatureServiceConsumerDefinition {
create(env: FeatureServiceConsumerEnvironment): SharedFeatureService;
export interface FeatureServicesBinding {
readonly featureServices: FeatureServices;
unbind(): void;
}
export interface FeatureServiceConsumerConfigs {
readonly [consumerId: string]: unknown;
export interface FeatureServiceConfigs {
readonly [featureServiceId: string]: unknown;
}
export interface FeatureServiceRegistryLike {
registerProviders(providerDefinitions: FeatureServiceProviderDefinition[], consumerId: string): void;
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerIdSpecifier?: string): FeatureServiceBindings;
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerIdSpecifier?: string): FeatureServicesBinding;
}
export declare class FeatureServiceRegistry implements FeatureServiceRegistryLike {
private readonly consumerConfigs;
private readonly configs;
private readonly sharedFeatureServices;
private readonly uniqueConsumerIds;
constructor(consumerConfigs: FeatureServiceConsumerConfigs);
constructor(configs?: FeatureServiceConfigs);
registerProviders(providerDefinitions: FeatureServiceProviderDefinition[], consumerId: string): void;
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerIdSpecifier?: string): FeatureServiceBindings;
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerIdSpecifier?: string): FeatureServicesBinding;
private bindFeatureService;
}

@@ -6,4 +6,4 @@ "use strict";

class FeatureServiceRegistry {
constructor(consumerConfigs) {
this.consumerConfigs = consumerConfigs;
constructor(configs = Object.create(null)) {
this.configs = configs;
this.sharedFeatureServices = new Map();

@@ -25,3 +25,5 @@ this.uniqueConsumerIds = new Set();

else if (providerDefinition) {
this.sharedFeatureServices.set(providerId, providerDefinition.create(this.bindFeatureServices(providerDefinition).consumerEnvironment));
const config = this.configs[providerId];
const { featureServices } = this.bindFeatureServices(providerDefinition);
this.sharedFeatureServices.set(providerId, providerDefinition.create({ config, featureServices }));
console.info(`The feature service provider ${JSON.stringify(providerId)} has been successfully registered by the consumer ${JSON.stringify(consumerId)}.`);

@@ -49,6 +51,2 @@ }

this.uniqueConsumerIds.add(uniqueConsumerId);
const consumerEnvironment = {
featureServices,
config: this.consumerConfigs[consumerId]
};
let unbound = false;

@@ -74,3 +72,3 @@ const unbind = () => {

console.info(`All required feature services have been successfully bound to the consumer ${JSON.stringify(uniqueConsumerId)}.`);
return { consumerEnvironment, unbind };
return { featureServices, unbind };
}

@@ -77,0 +75,0 @@ bindFeatureService(providerId, uniqueConsumerId, requiredVersion) {

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

import { FeatureAppModule } from '../feature-app-manager';
export declare function isFeatureAppModule(maybeFeatureAppModule: any): maybeFeatureAppModule is FeatureAppModule<unknown>;
import { FeatureAppDefinition } from '../feature-app-manager';
export interface FeatureAppModule {
readonly default: FeatureAppDefinition<unknown>;
}
export declare function isFeatureAppModule(maybeFeatureAppModule: any): maybeFeatureAppModule is FeatureAppModule;

@@ -10,3 +10,3 @@ "use strict";

}
function createDependencyEdges(dependentName, dependencies = {}) {
function createDependencyEdges(dependentName, dependencies = Object.create(null)) {
return Object.keys(dependencies).map(createTuple(dependentName));

@@ -13,0 +13,0 @@ }

{
"name": "@feature-hub/core",
"version": "0.4.0",
"version": "0.5.0",
"description": "The core functionality of the Feature Hub.",

@@ -31,3 +31,3 @@ "bugs": {

},
"gitHead": "2e3fd698f3e1fa0ed3c916372e977332398a3a53"
"gitHead": "abe94b93ae86f63a607dbf5c9b7601a0b7ca0139"
}

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