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

@feature-hub/core

Package Overview
Dependencies
Maintainers
4
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 1.7.0 to 2.0.0-alpha.0

13

lib/cjs/create-feature-hub.d.ts
import { ProvidedExternals } from './externals-validator';
import { FeatureAppConfigs, FeatureAppManager, ModuleLoader } from './feature-app-manager';
import { FeatureServiceConfigs, FeatureServiceConsumerDependencies, FeatureServiceProviderDefinition, FeatureServiceRegistry, FeatureServices, SharedFeatureService } from './feature-service-registry';
import { FeatureAppManager, ModuleLoader } from './feature-app-manager';
import { FeatureServiceConsumerDependencies, FeatureServiceProviderDefinition, FeatureServiceRegistry, FeatureServices, SharedFeatureService } from './feature-service-registry';
import { Logger } from './logger';

@@ -22,11 +22,2 @@ export interface FeatureHub {

/**
* Configurations for all Feature Apps that will potentially be created.
*/
readonly featureAppConfigs?: FeatureAppConfigs;
/**
* Configurations for all Feature Services that will potentially be
* registered.
*/
readonly featureServiceConfigs?: FeatureServiceConfigs;
/**
* Provided Feature Services. Sorting the provided definitions is not

@@ -33,0 +24,0 @@ * necessary, since the registry takes care of registering the given

9

lib/cjs/create-feature-hub.js

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

function createFeatureHub(integratorId, options = {}) {
const { featureAppConfigs, featureServiceConfigs, featureServiceDefinitions, featureServiceDependencies, providedExternals, moduleLoader, logger } = options;
const { featureServiceDefinitions, featureServiceDependencies, providedExternals, moduleLoader, logger } = options;
let externalsValidator;

@@ -23,3 +23,2 @@ if (providedExternals) {

const featureServiceRegistry = new feature_service_registry_1.FeatureServiceRegistry({
configs: featureServiceConfigs,
externalsValidator,

@@ -29,10 +28,8 @@ logger

const integratorDefinition = {
id: integratorId,
dependencies: { featureServices: featureServiceDependencies }
};
if (featureServiceDefinitions) {
featureServiceRegistry.registerFeatureServices(featureServiceDefinitions, integratorDefinition.id);
featureServiceRegistry.registerFeatureServices(featureServiceDefinitions, integratorId);
}
const featureAppManager = new feature_app_manager_1.FeatureAppManager(featureServiceRegistry, {
configs: featureAppConfigs,
externalsValidator,

@@ -42,3 +39,3 @@ moduleLoader,

});
const { featureServices } = featureServiceRegistry.bindFeatureServices(integratorDefinition);
const { featureServices } = featureServiceRegistry.bindFeatureServices(integratorDefinition, integratorId);
return { featureAppManager, featureServiceRegistry, featureServices };

@@ -45,0 +42,0 @@ }

@@ -15,6 +15,2 @@ /**

/**
* @deprecated Use [[ExternalsValidator]] instead.
*/
export declare type ExternalsValidatorLike = ExternalsValidator;
/**
* The `ExternalsValidator` validates required externals against the provided

@@ -21,0 +17,0 @@ * set of externals it is initilized with.

@@ -5,14 +5,4 @@ import { AsyncValue } from './async-value';

import { Logger } from './logger';
export interface FeatureAppEnvironment<TConfig, TInstanceConfig, TFeatureServices extends FeatureServices> {
export interface FeatureAppEnvironment<TFeatureServices extends FeatureServices, TConfig> {
/**
* A config object that is provided by the integrator. The same config object
* is used for all Feature App instances with the same ID, which is defined in
* their [[FeatureAppDefinition]].
*/
readonly config: TConfig;
/**
* A config object that is intended for a specific Feature App instance.
*/
readonly instanceConfig: TInstanceConfig;
/**
* An object of required Feature Services that are semver-compatible with the

@@ -23,7 +13,10 @@ * declared dependencies in the Feature App definition.

/**
* An optional ID specifier that distinguishes the Feature App instance from
* other Feature App instances with the same ID.
* A config object that is provided by the integrator.
*/
readonly idSpecifier: string | undefined;
readonly config: TConfig | undefined;
/**
* The ID that the integrator has assigned to the Feature App instance.
*/
readonly featureAppId: string;
/**
* The absolute or relative base URL of the Feature App's assets and/or BFF.

@@ -33,5 +26,5 @@ */

}
export interface FeatureAppDefinition<TFeatureApp, TConfig = unknown, TInstanceConfig = unknown, TFeatureServices extends FeatureServices = FeatureServices> extends FeatureServiceConsumerDefinition {
export interface FeatureAppDefinition<TFeatureApp, TFeatureServices extends FeatureServices = FeatureServices, TConfig = unknown> extends FeatureServiceConsumerDefinition {
readonly ownFeatureServiceDefinitions?: FeatureServiceProviderDefinition<SharedFeatureService>[];
create(env: FeatureAppEnvironment<TConfig, TInstanceConfig, TFeatureServices>): TFeatureApp;
create(env: FeatureAppEnvironment<TFeatureServices, TConfig>): TFeatureApp;
}

@@ -41,8 +34,10 @@ export declare type ModuleLoader = (url: string) => Promise<unknown>;

readonly featureApp: TFeatureApp;
destroy(): void;
/**
* When the `FeatureAppScope` is not needed anymore, e.g. the Feature App is
* unmounted, `release` must be called. When all scopes for a Feature App ID
* have been released, the Feature App instance is destroyed.
*/
release(): void;
}
export interface FeatureAppConfigs {
readonly [featureAppId: string]: unknown;
}
export interface FeatureAppScopeOptions {
export interface FeatureAppScopeOptions<TFeatureServices extends FeatureServices, TConfig> {
/**

@@ -53,25 +48,12 @@ * The absolute or relative base URL of the Feature App's assets and/or BFF.

/**
* A specifier to distinguish the Feature App instances from others created
* from the same definition.
*/
readonly idSpecifier?: string;
/**
* A config object that is intended for a specific Feature App instance.
*/
readonly instanceConfig?: unknown;
readonly config?: TConfig;
/**
* A callback that is called before the Feature App is created.
*/
readonly beforeCreate?: (consumerUid: string, featureServices: FeatureServices) => void;
readonly beforeCreate?: (env: FeatureAppEnvironment<TFeatureServices, TConfig>) => void;
}
/**
* @deprecated Use [[FeatureAppManager]] instead.
*/
export declare type FeatureAppManagerLike = FeatureAppManager;
export interface FeatureAppManagerOptions {
/**
* Configurations for all Feature Apps that will potentially be created.
*/
readonly configs?: FeatureAppConfigs;
/**
* For the `FeatureAppManager` to be able to load Feature Apps from a remote

@@ -105,3 +87,3 @@ * location, a module loader must be provided, (e.g. the

private readonly featureAppDefinitionsWithRegisteredOwnFeatureServices;
private readonly featureAppScopes;
private readonly featureAppRetainers;
private readonly logger;

@@ -126,5 +108,5 @@ constructor(featureServiceRegistry: FeatureServiceRegistry, options?: FeatureAppManagerOptions);

/**
* Create a [[FeatureAppScope]] which includes validating externals,
* binding all available Feature Service dependencies, and calling the
* `create` method of the [[FeatureAppDefinition]].
* Create a [[FeatureAppScope]] which includes validating externals, binding
* all available Feature Service dependencies, and calling the `create` method
* of the [[FeatureAppDefinition]].
*

@@ -140,11 +122,11 @@ * @throws Throws an error if Feature Services that the

*
* @param featureAppID The ID of the Feature App to create a scope for.
* @param featureAppDefinition The definition of the Feature App to create a
* scope for.
*
* @returns A [[FeatureAppScope]] for the provided [[FeatureAppDefinition]]
* and ID specifier. If `getFeatureAppScope` is called
* multiple times with the same [[FeatureAppDefinition]] and ID specifier,
* it returns the [[FeatureAppScope]] it created on the first call.
* @returns A [[FeatureAppScope]] for the provided Feature App ID and
* [[FeatureAppDefinition]]. A new scope is created for every call of
* `createFeatureAppScope`, even with the same ID and definiton.
*/
getFeatureAppScope<TFeatureApp>(featureAppDefinition: FeatureAppDefinition<TFeatureApp>, options?: FeatureAppScopeOptions): FeatureAppScope<TFeatureApp>;
createFeatureAppScope<TFeatureApp, TFeatureServices extends FeatureServices = FeatureServices, TConfig = unknown>(featureAppId: string, featureAppDefinition: FeatureAppDefinition<TFeatureApp, TFeatureServices, TConfig>, options?: FeatureAppScopeOptions<TFeatureServices, TConfig>): FeatureAppScope<TFeatureApp>;
/**

@@ -163,4 +145,5 @@ * Preload a [[FeatureAppDefinition]] using the module loader the

private registerOwnFeatureServices;
private createFeatureAppScope;
private getFeatureAppRetainer;
private createFeatureAppRetainer;
private validateExternals;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const async_value_1 = require("./async-value");
const create_uid_1 = require("./internal/create-uid");
const is_feature_app_module_1 = require("./internal/is-feature-app-module");

@@ -15,3 +14,3 @@ /**

this.featureAppDefinitionsWithRegisteredOwnFeatureServices = new WeakSet();
this.featureAppScopes = new Map();
this.featureAppRetainers = new Map();
this.logger = options.logger || console;

@@ -43,5 +42,5 @@ }

/**
* Create a [[FeatureAppScope]] which includes validating externals,
* binding all available Feature Service dependencies, and calling the
* `create` method of the [[FeatureAppDefinition]].
* Create a [[FeatureAppScope]] which includes validating externals, binding
* all available Feature Service dependencies, and calling the `create` method
* of the [[FeatureAppDefinition]].
*

@@ -57,20 +56,25 @@ * @throws Throws an error if Feature Services that the

*
* @param featureAppID The ID of the Feature App to create a scope for.
* @param featureAppDefinition The definition of the Feature App to create a
* scope for.
*
* @returns A [[FeatureAppScope]] for the provided [[FeatureAppDefinition]]
* and ID specifier. If `getFeatureAppScope` is called
* multiple times with the same [[FeatureAppDefinition]] and ID specifier,
* it returns the [[FeatureAppScope]] it created on the first call.
* @returns A [[FeatureAppScope]] for the provided Feature App ID and
* [[FeatureAppDefinition]]. A new scope is created for every call of
* `createFeatureAppScope`, even with the same ID and definiton.
*/
getFeatureAppScope(featureAppDefinition, options = {}) {
const { id: featureAppId } = featureAppDefinition;
const featureAppUid = create_uid_1.createUid(featureAppId, options.idSpecifier);
let featureAppScope = this.featureAppScopes.get(featureAppUid);
if (!featureAppScope) {
this.registerOwnFeatureServices(featureAppDefinition);
featureAppScope = this.createFeatureAppScope(featureAppDefinition, () => this.featureAppScopes.delete(featureAppUid), options);
this.featureAppScopes.set(featureAppUid, featureAppScope);
}
return featureAppScope;
createFeatureAppScope(featureAppId, featureAppDefinition, options = {}) {
const featureAppRetainer = this.getFeatureAppRetainer(featureAppId, featureAppDefinition, options);
let released = false;
return {
featureApp: featureAppRetainer.featureApp,
release: () => {
if (released) {
this.logger.warn(`The Feature App with the ID ${JSON.stringify(featureAppId)} has already been released for this scope.`);
}
else {
released = true;
featureAppRetainer.release();
}
}
};
}

@@ -97,3 +101,3 @@ /**

if (!is_feature_app_module_1.isFeatureAppModule(featureAppModule)) {
throw new Error(`The Feature App module at the url ${JSON.stringify(url)} is invalid. A Feature App module must have a Feature App definition as default export. A Feature App definition is an object with at least an \`id\` string and a \`create\` method.`);
throw new Error(`The Feature App module at the url ${JSON.stringify(url)} is invalid. A Feature App module must have a Feature App definition as default export. A Feature App definition is an object with at least a \`create\` method.`);
}

@@ -104,3 +108,3 @@ this.logger.info(`The Feature App module at the url ${JSON.stringify(url)} has been successfully loaded.`);

}
registerOwnFeatureServices(featureAppDefinition) {
registerOwnFeatureServices(featureAppId, featureAppDefinition) {
if (this.featureAppDefinitionsWithRegisteredOwnFeatureServices.has(featureAppDefinition)) {

@@ -110,34 +114,48 @@ return;

if (featureAppDefinition.ownFeatureServiceDefinitions) {
this.featureServiceRegistry.registerFeatureServices(featureAppDefinition.ownFeatureServiceDefinitions, featureAppDefinition.id);
this.featureServiceRegistry.registerFeatureServices(featureAppDefinition.ownFeatureServiceDefinitions, featureAppId);
}
this.featureAppDefinitionsWithRegisteredOwnFeatureServices.add(featureAppDefinition);
}
createFeatureAppScope(featureAppDefinition, deleteFeatureAppScope, options) {
getFeatureAppRetainer(featureAppId, featureAppDefinition, options) {
let featureAppRetainer = this.featureAppRetainers.get(featureAppId);
if (featureAppRetainer) {
featureAppRetainer.retain();
}
else {
this.registerOwnFeatureServices(featureAppId, featureAppDefinition);
featureAppRetainer = this.createFeatureAppRetainer(featureAppDefinition, featureAppId, options);
}
return featureAppRetainer;
}
createFeatureAppRetainer(featureAppDefinition, featureAppId, options) {
this.validateExternals(featureAppDefinition);
const { baseUrl, beforeCreate, idSpecifier, instanceConfig } = options;
const { configs } = this.options;
const config = configs && configs[featureAppDefinition.id];
const featureAppUid = create_uid_1.createUid(featureAppDefinition.id, idSpecifier);
const binding = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, idSpecifier);
const { baseUrl, beforeCreate, config } = options;
const binding = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, featureAppId);
const env = {
baseUrl,
config,
featureAppId,
featureServices: binding.featureServices
};
if (beforeCreate) {
beforeCreate(featureAppUid, binding.featureServices);
beforeCreate(env);
}
const featureApp = featureAppDefinition.create({
baseUrl,
config,
instanceConfig,
featureServices: binding.featureServices,
idSpecifier
});
this.logger.info(`The Feature App ${JSON.stringify(featureAppUid)} has been successfully created.`);
let destroyed = false;
const destroy = () => {
if (destroyed) {
throw new Error(`The Feature App ${JSON.stringify(featureAppUid)} could not be destroyed.`);
const featureApp = featureAppDefinition.create(env);
this.logger.info(`The Feature App with the ID ${JSON.stringify(featureAppId)} has been successfully created.`);
let retainCount = 1;
const featureAppRetainer = {
featureApp,
retain: () => {
retainCount += 1;
},
release: () => {
retainCount -= 1;
if (retainCount === 0) {
this.featureAppRetainers.delete(featureAppId);
binding.unbind();
}
}
deleteFeatureAppScope();
binding.unbind();
destroyed = true;
};
return { featureApp, destroy };
this.featureAppRetainers.set(featureAppId, featureAppRetainer);
return featureAppRetainer;
}

@@ -144,0 +162,0 @@ validateExternals(featureAppDefinition) {

@@ -11,3 +11,2 @@ import { ExternalsValidator, RequiredExternals } from './externals-validator';

export interface FeatureServiceConsumerDefinition {
readonly id: string;
readonly dependencies?: {

@@ -32,8 +31,4 @@ /**

}
export interface FeatureServiceEnvironment<TConfig, TFeatureServices extends FeatureServices> {
export interface FeatureServiceEnvironment<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

@@ -44,4 +39,5 @@ * declared dependencies in the Feature App definition.

}
export interface FeatureServiceProviderDefinition<TSharedFeatureService extends SharedFeatureService, TFeatureServices extends FeatureServices = FeatureServices, TConfig = unknown> extends FeatureServiceConsumerDefinition {
create(env: FeatureServiceEnvironment<TConfig, TFeatureServices>): TSharedFeatureService;
export interface FeatureServiceProviderDefinition<TSharedFeatureService extends SharedFeatureService, TFeatureServices extends FeatureServices = FeatureServices> extends FeatureServiceConsumerDefinition {
readonly id: string;
create(env: FeatureServiceEnvironment<TFeatureServices>): TSharedFeatureService;
}

@@ -52,24 +48,12 @@ export interface FeatureServiceBinding<TFeatureService> {

}
export declare type FeatureServiceBinder<TFeatureService> = (consumerUid: string) => FeatureServiceBinding<TFeatureService>;
export declare type FeatureServiceBinder<TFeatureService> = (consumerId: string) => FeatureServiceBinding<TFeatureService>;
export interface SharedFeatureService {
readonly [version: string]: FeatureServiceBinder<unknown> | undefined;
}
export interface FeatureServicesBinding {
readonly featureServices: FeatureServices;
export interface FeatureServicesBinding<TFeatureServices extends FeatureServices = FeatureServices> {
readonly featureServices: TFeatureServices;
unbind(): void;
}
export interface FeatureServiceConfigs {
readonly [featureServiceId: string]: unknown;
}
/**
* @deprecated Use [[FeatureServiceRegistry]] instead.
*/
export declare type FeatureServiceRegistryLike = FeatureServiceRegistry;
export interface FeatureServiceRegistryOptions {
/**
* Configurations for all Feature Services that will potentially be
* registered.
*/
readonly configs?: FeatureServiceConfigs;
/**
* If the [[FeatureAppManager]] is configured with a

@@ -99,3 +83,3 @@ * [[FeatureAppManagerOptions.moduleLoader]], to load Feature Apps from a

private readonly sharedFeatureServices;
private readonly consumerUids;
private readonly consumerIds;
private readonly logger;

@@ -113,11 +97,11 @@ constructor(options?: FeatureServiceRegistryOptions);

* @param providerDefinitions Feature Services that should be registered. A
* Feature Service and its dependencies must either be registered together,
* or the dependencies must have already been registered. It is not possible
* to provide dependencies later. Sorting the provided definitions is not
* Feature Service and its dependencies must either be registered together, or
* the dependencies must have already been registered. It is not possible to
* provide dependencies later. Sorting the provided definitions is not
* necessary, since the registry takes care of registering the given
* definitions in the correct order.
* @param consumerId The ID of the consumer that provides the provider
* @param registrantId The ID of the entity that registers the provider
* definitions.
*/
registerFeatureServices(providerDefinitions: FeatureServiceProviderDefinition<SharedFeatureService>[], consumerId: string): void;
registerFeatureServices(providerDefinitions: FeatureServiceProviderDefinition<SharedFeatureService>[], registrantId: string): void;
/**

@@ -132,6 +116,6 @@ * Bind all dependencies to a consumer.

* dependencies should be bound.
* @param consumerIdSpecifier A specifier that distinguishes the consumer
* from others with the same definition.
* @param consumerId The ID of the consumer to which dependencies should be
* bound.
*/
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerIdSpecifier?: string): FeatureServicesBinding;
bindFeatureServices(consumerDefinition: FeatureServiceConsumerDefinition, consumerId: string): FeatureServicesBinding;
private registerFeatureService;

@@ -138,0 +122,0 @@ private bindFeatureService;

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

const semver_1 = require("semver");
const create_uid_1 = require("./internal/create-uid");
const Messages = __importStar(require("./internal/feature-service-registry-messages"));

@@ -45,3 +44,3 @@ const toposort_dependencies_1 = require("./internal/toposort-dependencies");

this.sharedFeatureServices = new Map();
this.consumerUids = new Set();
this.consumerIds = new Set();
this.logger = options.logger || console;

@@ -59,15 +58,15 @@ }

* @param providerDefinitions Feature Services that should be registered. A
* Feature Service and its dependencies must either be registered together,
* or the dependencies must have already been registered. It is not possible
* to provide dependencies later. Sorting the provided definitions is not
* Feature Service and its dependencies must either be registered together, or
* the dependencies must have already been registered. It is not possible to
* provide dependencies later. Sorting the provided definitions is not
* necessary, since the registry takes care of registering the given
* definitions in the correct order.
* @param consumerId The ID of the consumer that provides the provider
* @param registrantId The ID of the entity that registers the provider
* definitions.
*/
registerFeatureServices(providerDefinitions, consumerId) {
registerFeatureServices(providerDefinitions, registrantId) {
const providerDefinitionsById = createProviderDefinitionsById(providerDefinitions);
const dependencyGraph = createDependencyGraph(providerDefinitions);
for (const providerId of toposort_dependencies_1.toposortDependencies(dependencyGraph)) {
this.registerFeatureService(providerDefinitionsById, providerId, consumerId);
this.registerFeatureService(providerDefinitionsById, providerId, registrantId);
}

@@ -84,10 +83,8 @@ }

* dependencies should be bound.
* @param consumerIdSpecifier A specifier that distinguishes the consumer
* from others with the same definition.
* @param consumerId The ID of the consumer to which dependencies should be
* bound.
*/
bindFeatureServices(consumerDefinition, consumerIdSpecifier) {
const { id: consumerId } = consumerDefinition;
const consumerUid = create_uid_1.createUid(consumerId, consumerIdSpecifier);
if (this.consumerUids.has(consumerUid)) {
throw new Error(Messages.featureServicesAlreadyBound(consumerUid));
bindFeatureServices(consumerDefinition, consumerId) {
if (this.consumerIds.has(consumerId)) {
throw new Error(Messages.featureServicesAlreadyBound(consumerId));
}

@@ -100,18 +97,18 @@ const bindings = new Map();

const versionRange = allDependencies[providerId];
const binding = this.bindFeatureService(providerId, consumerUid, versionRange, { optional });
const binding = this.bindFeatureService(providerId, consumerId, versionRange, { optional });
if (!binding) {
continue;
}
this.logger.info(Messages.featureServiceSuccessfullyBound(providerId, consumerUid));
this.logger.info(Messages.featureServiceSuccessfullyBound(providerId, consumerId));
bindings.set(providerId, binding);
featureServices[providerId] = binding.featureService;
}
this.consumerUids.add(consumerUid);
this.consumerIds.add(consumerId);
let unbound = false;
const unbind = () => {
if (unbound) {
throw new Error(Messages.featureServicesAlreadyUnbound(consumerUid));
throw new Error(Messages.featureServicesAlreadyUnbound(consumerId));
}
unbound = true;
this.consumerUids.delete(consumerUid);
this.consumerIds.delete(consumerId);
for (const [providerId, binding] of bindings.entries()) {

@@ -122,6 +119,6 @@ try {

}
this.logger.info(Messages.featureServiceSuccessfullyUnbound(providerId, consumerUid));
this.logger.info(Messages.featureServiceSuccessfullyUnbound(providerId, consumerId));
}
catch (error) {
this.logger.error(Messages.featureServiceCouldNotBeUnbound(providerId, consumerUid), error);
this.logger.error(Messages.featureServiceCouldNotBeUnbound(providerId, consumerId), error);
}

@@ -132,26 +129,19 @@ }

}
registerFeatureService(providerDefinitionsById, providerId, consumerId) {
registerFeatureService(providerDefinitionsById, providerId, registrantId) {
const providerDefinition = providerDefinitionsById.get(providerId);
if (this.sharedFeatureServices.has(providerId)) {
if (providerDefinitionsById.has(providerId)) {
this.logger.warn(Messages.featureServiceAlreadyRegistered(providerId, consumerId));
}
this.logger.warn(Messages.featureServiceAlreadyRegistered(providerId, registrantId));
}
else if (providerDefinition) {
this.validateExternals(providerDefinition);
const { configs } = this.options;
const config = configs && configs[providerId];
const { featureServices } = this.bindFeatureServices(providerDefinition);
const sharedFeatureService = providerDefinition.create({
config,
featureServices
});
this.validateFeatureServiceVersions(sharedFeatureService, providerId, consumerId);
const { featureServices } = this.bindFeatureServices(providerDefinition, providerId);
const sharedFeatureService = providerDefinition.create({ featureServices });
this.validateFeatureServiceVersions(sharedFeatureService, providerId, registrantId);
this.sharedFeatureServices.set(providerId, sharedFeatureService);
this.logger.info(Messages.featureServiceSuccessfullyRegistered(providerId, consumerId));
this.logger.info(Messages.featureServiceSuccessfullyRegistered(providerId, registrantId));
}
}
bindFeatureService(providerId, consumerUid, versionRange, { optional }) {
bindFeatureService(providerId, consumerId, versionRange, { optional }) {
if (!versionRange) {
const message = Messages.featureServiceDependencyVersionInvalid(optional, providerId, consumerUid);
const message = Messages.featureServiceDependencyVersionInvalid(optional, providerId, consumerId);
if (optional) {

@@ -165,3 +155,3 @@ this.logger.info(message);

if (!sharedFeatureService) {
const message = Messages.featureServiceNotRegistered(optional, providerId, consumerUid);
const message = Messages.featureServiceNotRegistered(optional, providerId, consumerId);
if (optional) {

@@ -177,3 +167,3 @@ this.logger.info(message);

if (!bindFeatureService) {
const message = Messages.featureServiceUnsupported(optional, providerId, consumerUid, versionRange, supportedVersions);
const message = Messages.featureServiceUnsupported(optional, providerId, consumerId, versionRange, supportedVersions);
if (optional) {

@@ -185,3 +175,3 @@ this.logger.info(message);

}
return bindFeatureService(consumerUid);
return bindFeatureService(consumerId);
}

@@ -198,6 +188,6 @@ validateExternals(featureAppDefinition) {

}
validateFeatureServiceVersions(sharedFeatureService, providerId, consumerId) {
validateFeatureServiceVersions(sharedFeatureService, providerId, registrantId) {
for (const version of Object.keys(sharedFeatureService)) {
if (!semver_1.valid(version)) {
throw new Error(Messages.featureServiceVersionInvalid(providerId, consumerId, version));
throw new Error(Messages.featureServiceVersionInvalid(providerId, registrantId, version));
}

@@ -204,0 +194,0 @@ }

@@ -1,11 +0,11 @@

export declare function featureServiceUnsupported(optional: boolean, providerId: string, consumerUid: string, versionRange: string, supportedVersions: string[]): string;
export declare function featureServiceVersionInvalid(providerId: string, consumerId: string, version: string): string | undefined;
export declare function featureServiceDependencyVersionInvalid(optional: boolean, providerId: string, consumerUid: string): string;
export declare function featureServiceNotRegistered(optional: boolean, providerId: string, consumerUid: string): string;
export declare function featureServiceSuccessfullyRegistered(providerId: string, consumerId: string): string;
export declare function featureServiceAlreadyRegistered(providerId: string, consumerId: string): string;
export declare function featureServiceSuccessfullyBound(providerId: string, consumerUid: string): string;
export declare function featureServicesAlreadyBound(consumerUid: string): string | undefined;
export declare function featureServiceCouldNotBeUnbound(providerId: string, consumerUid: string): string;
export declare function featureServiceSuccessfullyUnbound(providerId: string, consumerUid: string): string;
export declare function featureServicesAlreadyUnbound(consumerUid: string): string;
export declare function featureServiceUnsupported(optional: boolean, providerId: string, consumerId: string, versionRange: string, supportedVersions: string[]): string;
export declare function featureServiceVersionInvalid(providerId: string, registrantId: string, version: string): string | undefined;
export declare function featureServiceDependencyVersionInvalid(optional: boolean, providerId: string, consumerId: string): string;
export declare function featureServiceNotRegistered(optional: boolean, providerId: string, consumerId: string): string;
export declare function featureServiceSuccessfullyRegistered(providerId: string, registrantId: string): string;
export declare function featureServiceAlreadyRegistered(providerId: string, registrantId: string): string;
export declare function featureServiceSuccessfullyBound(providerId: string, consumerId: string): string;
export declare function featureServicesAlreadyBound(consumerId: string): string | undefined;
export declare function featureServiceCouldNotBeUnbound(providerId: string, consumerId: string): string;
export declare function featureServiceSuccessfullyUnbound(providerId: string, consumerId: string): string;
export declare function featureServicesAlreadyUnbound(consumerId: string): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function featureServiceUnsupported(optional, providerId, consumerUid, versionRange, supportedVersions) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} in the unsupported version range ${JSON.stringify(versionRange)} could not be bound to consumer ${JSON.stringify(consumerUid)}. The supported versions are ${JSON.stringify(supportedVersions)}.`;
function featureServiceUnsupported(optional, providerId, consumerId, versionRange, supportedVersions) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} in the unsupported version range ${JSON.stringify(versionRange)} could not be bound to consumer ${JSON.stringify(consumerId)}. The supported versions are ${JSON.stringify(supportedVersions)}.`;
}
exports.featureServiceUnsupported = featureServiceUnsupported;
function featureServiceVersionInvalid(providerId, consumerId, version) {
return `The Feature Service ${JSON.stringify(providerId)} could not be registered by consumer ${JSON.stringify(consumerId)} because it defines the invalid version ${JSON.stringify(version)}.`;
function featureServiceVersionInvalid(providerId, registrantId, version) {
return `The Feature Service ${JSON.stringify(providerId)} could not be registered by registrant ${JSON.stringify(registrantId)} because it defines the invalid version ${JSON.stringify(version)}.`;
}
exports.featureServiceVersionInvalid = featureServiceVersionInvalid;
function featureServiceDependencyVersionInvalid(optional, providerId, consumerUid) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} in an invalid version could not be bound to consumer ${JSON.stringify(consumerUid)}.`;
function featureServiceDependencyVersionInvalid(optional, providerId, consumerId) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} in an invalid version could not be bound to consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServiceDependencyVersionInvalid = featureServiceDependencyVersionInvalid;
function featureServiceNotRegistered(optional, providerId, consumerUid) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} is not registered and therefore could not be bound to consumer ${JSON.stringify(consumerUid)}.`;
function featureServiceNotRegistered(optional, providerId, consumerId) {
return `The ${optional ? 'optional' : 'required'} Feature Service ${JSON.stringify(providerId)} is not registered and therefore could not be bound to consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServiceNotRegistered = featureServiceNotRegistered;
function featureServiceSuccessfullyRegistered(providerId, consumerId) {
return `The Feature Service ${JSON.stringify(providerId)} has been successfully registered by consumer ${JSON.stringify(consumerId)}.`;
function featureServiceSuccessfullyRegistered(providerId, registrantId) {
return `The Feature Service ${JSON.stringify(providerId)} has been successfully registered by registrant ${JSON.stringify(registrantId)}.`;
}
exports.featureServiceSuccessfullyRegistered = featureServiceSuccessfullyRegistered;
function featureServiceAlreadyRegistered(providerId, consumerId) {
return `The already registered Feature Service ${JSON.stringify(providerId)} could not be re-registered by consumer ${JSON.stringify(consumerId)}.`;
function featureServiceAlreadyRegistered(providerId, registrantId) {
return `The already registered Feature Service ${JSON.stringify(providerId)} could not be re-registered by registrant ${JSON.stringify(registrantId)}.`;
}
exports.featureServiceAlreadyRegistered = featureServiceAlreadyRegistered;
function featureServiceSuccessfullyBound(providerId, consumerUid) {
return `The required Feature Service ${JSON.stringify(providerId)} has been successfully bound to consumer ${JSON.stringify(consumerUid)}.`;
function featureServiceSuccessfullyBound(providerId, consumerId) {
return `The required Feature Service ${JSON.stringify(providerId)} has been successfully bound to consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServiceSuccessfullyBound = featureServiceSuccessfullyBound;
function featureServicesAlreadyBound(consumerUid) {
return `All required Feature Services are already bound to consumer ${JSON.stringify(consumerUid)}.`;
function featureServicesAlreadyBound(consumerId) {
return `All required Feature Services are already bound to consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServicesAlreadyBound = featureServicesAlreadyBound;
function featureServiceCouldNotBeUnbound(providerId, consumerUid) {
return `The required Feature Service ${JSON.stringify(providerId)} could not be unbound from consumer ${JSON.stringify(consumerUid)}.`;
function featureServiceCouldNotBeUnbound(providerId, consumerId) {
return `The required Feature Service ${JSON.stringify(providerId)} could not be unbound from consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServiceCouldNotBeUnbound = featureServiceCouldNotBeUnbound;
function featureServiceSuccessfullyUnbound(providerId, consumerUid) {
return `The required Feature Service ${JSON.stringify(providerId)} has been successfully unbound from consumer ${JSON.stringify(consumerUid)}.`;
function featureServiceSuccessfullyUnbound(providerId, consumerId) {
return `The required Feature Service ${JSON.stringify(providerId)} has been successfully unbound from consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServiceSuccessfullyUnbound = featureServiceSuccessfullyUnbound;
function featureServicesAlreadyUnbound(consumerUid) {
return `All required Feature Services are already unbound from consumer ${JSON.stringify(consumerUid)}.`;
function featureServicesAlreadyUnbound(consumerId) {
return `All required Feature Services are already unbound from consumer ${JSON.stringify(consumerId)}.`;
}
exports.featureServicesAlreadyUnbound = featureServicesAlreadyUnbound;
//# sourceMappingURL=feature-service-registry-messages.js.map

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

const featureAppDefinition = maybeFeatureAppDefinition;
if (typeof featureAppDefinition.id !== 'string') {
return false;
}
return typeof featureAppDefinition.create === 'function';

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

{
"name": "@feature-hub/core",
"version": "1.7.0",
"version": "2.0.0-alpha.0",
"description": "Create scalable web applications using micro frontends.",

@@ -42,3 +42,3 @@ "keywords": [

},
"gitHead": "7bac04a0d5000d2b553be07286fcd0ef1a973f93"
"gitHead": "571af5d84b6093167dd58f82da08b597e55f8b62"
}

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

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