@feature-hub/core
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -75,3 +75,3 @@ "use strict"; | ||
const { featureAppManager } = (0, create_feature_hub_1.createFeatureHub)('test:integrator', featureHubOptions); | ||
expect(() => featureAppManager.createFeatureAppScope('test:feature-app', mockFeatureAppDefinition)).toThrowError(new Error('The external dependency "foo" is not provided.')); | ||
expect(() => featureAppManager.createFeatureAppScope('test:feature-app', mockFeatureAppDefinition)).toThrowError(new Error('The external dependency "foo" as required by "test:feature-app" is not provided.')); | ||
}); | ||
@@ -134,3 +134,3 @@ }); | ||
it('throws for a Feature Service with mismatching externals', () => { | ||
expect(() => (0, create_feature_hub_1.createFeatureHub)('test:integrator', featureHubOptions)).toThrowError(new Error('The external dependency "foo" is not provided.')); | ||
expect(() => (0, create_feature_hub_1.createFeatureHub)('test:integrator', featureHubOptions)).toThrowError(new Error('The external dependency "foo" as required by "test:feature-service" is not provided.')); | ||
}); | ||
@@ -137,0 +137,0 @@ }); |
@@ -25,2 +25,5 @@ "use strict"; | ||
}).toThrowError(new Error('The external dependency "react" in the required version range "^16.7.0" is not satisfied. The provided version is "16.6.0".')); | ||
expect(() => { | ||
validator.validate({ react: '^16.7.0' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" in the version range "^16.7.0" is not satisfied. The provided version is "16.6.0".')); | ||
}); | ||
@@ -32,2 +35,5 @@ it('throws an error for an unsatisfied required external (not provided)', () => { | ||
}).toThrowError(new Error('The external dependency "react" is not provided.')); | ||
expect(() => { | ||
validator.validate({ react: '^16.7.0' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" is not provided.')); | ||
}); | ||
@@ -39,2 +45,5 @@ it('throws an error for an invalid required external', () => { | ||
}).toThrowError(new Error('The external dependency "react" in the required version range "invalid" is not satisfied. The provided version is "16.6.0".')); | ||
expect(() => { | ||
validator.validate({ react: 'invalid' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" in the version range "invalid" is not satisfied. The provided version is "16.6.0".')); | ||
}); | ||
@@ -41,0 +50,0 @@ }); |
@@ -297,5 +297,3 @@ "use strict"; | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'testId'); | ||
}); | ||
@@ -318,5 +316,3 @@ it('throws the validation error', () => { | ||
featureAppManager.createFeatureAppScope('testId', mockFeatureAppDefinition); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'testId'); | ||
}); | ||
@@ -323,0 +319,0 @@ it("doesn't throw an error", () => { |
@@ -259,5 +259,3 @@ "use strict"; | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'a'); | ||
}); | ||
@@ -283,5 +281,3 @@ it('throws the validation error', () => { | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'a'); | ||
}); | ||
@@ -288,0 +284,0 @@ it("doesn't throw an error", () => { |
@@ -30,4 +30,4 @@ /** | ||
*/ | ||
validate(requiredExternals: RequiredExternals): void; | ||
validate(requiredExternals: RequiredExternals, consumerId?: string): void; | ||
} | ||
//# sourceMappingURL=externals-validator.d.ts.map |
@@ -31,10 +31,12 @@ "use strict"; | ||
*/ | ||
validate(requiredExternals) { | ||
validate(requiredExternals, consumerId) { | ||
for (const [externalName, versionRange] of Object.entries(requiredExternals)) { | ||
const providedVersion = this.providedExternals[externalName]; | ||
if (!providedVersion) { | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} is not provided.`); | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)}${consumerId ? ` as required by ${JSON.stringify(consumerId)}` : ``} is not provided.`); | ||
} | ||
if (!(0, satisfies_1.default)(providedVersion, versionRange)) { | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} in the required version range ${JSON.stringify(versionRange)} is not satisfied. The provided version is ${JSON.stringify(providedVersion)}.`); | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} ${consumerId | ||
? `as required by ${JSON.stringify(consumerId)} in the` | ||
: `in the required`} version range ${JSON.stringify(versionRange)} is not satisfied. The provided version is ${JSON.stringify(providedVersion)}.`); | ||
} | ||
@@ -41,0 +43,0 @@ } |
@@ -161,3 +161,3 @@ "use strict"; | ||
var _a, _b; | ||
this.validateExternals(featureAppDefinition); | ||
this.validateExternals(featureAppDefinition, featureAppId); | ||
const { featureAppName, baseUrl, beforeCreate, config, done, parentFeatureApp, } = options; | ||
@@ -210,3 +210,3 @@ const binding = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, featureAppId, featureAppName); | ||
} | ||
validateExternals(featureAppDefinition) { | ||
validateExternals(featureAppDefinition, featureAppId) { | ||
const { externalsValidator } = this.options; | ||
@@ -218,3 +218,3 @@ if (!externalsValidator) { | ||
if (dependencies && dependencies.externals) { | ||
externalsValidator.validate(dependencies.externals); | ||
externalsValidator.validate(dependencies.externals, featureAppId); | ||
} | ||
@@ -221,0 +221,0 @@ } |
@@ -155,3 +155,3 @@ "use strict"; | ||
} | ||
this.validateExternals(providerDefinition); | ||
this.validateExternals(providerDefinition, providerId); | ||
const { featureServices } = this.bindFeatureServices(providerDefinition, providerId); | ||
@@ -203,3 +203,3 @@ const sharedFeatureService = providerDefinition.create({ featureServices }); | ||
} | ||
validateExternals(featureAppDefinition) { | ||
validateExternals(consumerDefinition, consumerId) { | ||
const { externalsValidator } = this.options; | ||
@@ -209,5 +209,5 @@ if (!externalsValidator) { | ||
} | ||
const { dependencies } = featureAppDefinition; | ||
const { dependencies } = consumerDefinition; | ||
if (dependencies && dependencies.externals) { | ||
externalsValidator.validate(dependencies.externals); | ||
externalsValidator.validate(dependencies.externals, consumerId); | ||
} | ||
@@ -214,0 +214,0 @@ } |
@@ -73,3 +73,3 @@ // tslint:disable:no-implicit-dependencies | ||
const { featureAppManager } = createFeatureHub('test:integrator', featureHubOptions); | ||
expect(() => featureAppManager.createFeatureAppScope('test:feature-app', mockFeatureAppDefinition)).toThrowError(new Error('The external dependency "foo" is not provided.')); | ||
expect(() => featureAppManager.createFeatureAppScope('test:feature-app', mockFeatureAppDefinition)).toThrowError(new Error('The external dependency "foo" as required by "test:feature-app" is not provided.')); | ||
}); | ||
@@ -132,3 +132,3 @@ }); | ||
it('throws for a Feature Service with mismatching externals', () => { | ||
expect(() => createFeatureHub('test:integrator', featureHubOptions)).toThrowError(new Error('The external dependency "foo" is not provided.')); | ||
expect(() => createFeatureHub('test:integrator', featureHubOptions)).toThrowError(new Error('The external dependency "foo" as required by "test:feature-service" is not provided.')); | ||
}); | ||
@@ -135,0 +135,0 @@ }); |
@@ -23,2 +23,5 @@ import { ExternalsValidator } from '../externals-validator'; | ||
}).toThrowError(new Error('The external dependency "react" in the required version range "^16.7.0" is not satisfied. The provided version is "16.6.0".')); | ||
expect(() => { | ||
validator.validate({ react: '^16.7.0' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" in the version range "^16.7.0" is not satisfied. The provided version is "16.6.0".')); | ||
}); | ||
@@ -30,2 +33,5 @@ it('throws an error for an unsatisfied required external (not provided)', () => { | ||
}).toThrowError(new Error('The external dependency "react" is not provided.')); | ||
expect(() => { | ||
validator.validate({ react: '^16.7.0' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" is not provided.')); | ||
}); | ||
@@ -37,2 +43,5 @@ it('throws an error for an invalid required external', () => { | ||
}).toThrowError(new Error('The external dependency "react" in the required version range "invalid" is not satisfied. The provided version is "16.6.0".')); | ||
expect(() => { | ||
validator.validate({ react: 'invalid' }, 'test-consumer'); | ||
}).toThrowError(new Error('The external dependency "react" as required by "test-consumer" in the version range "invalid" is not satisfied. The provided version is "16.6.0".')); | ||
}); | ||
@@ -39,0 +48,0 @@ }); |
@@ -295,5 +295,3 @@ // tslint:disable:no-implicit-dependencies | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'testId'); | ||
}); | ||
@@ -316,5 +314,3 @@ it('throws the validation error', () => { | ||
featureAppManager.createFeatureAppScope('testId', mockFeatureAppDefinition); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'testId'); | ||
}); | ||
@@ -321,0 +317,0 @@ it("doesn't throw an error", () => { |
@@ -257,5 +257,3 @@ // tslint:disable:no-implicit-dependencies | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'a'); | ||
}); | ||
@@ -281,5 +279,3 @@ it('throws the validation error', () => { | ||
catch (_a) { } | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ | ||
react: '^16.0.0', | ||
}); | ||
expect(mockExternalsValidator.validate).toHaveBeenCalledWith({ react: '^16.0.0' }, 'a'); | ||
}); | ||
@@ -286,0 +282,0 @@ it("doesn't throw an error", () => { |
@@ -30,4 +30,4 @@ /** | ||
*/ | ||
validate(requiredExternals: RequiredExternals): void; | ||
validate(requiredExternals: RequiredExternals, consumerId?: string): void; | ||
} | ||
//# sourceMappingURL=externals-validator.d.ts.map |
@@ -25,10 +25,12 @@ import semverSatisfies from 'semver/functions/satisfies'; | ||
*/ | ||
validate(requiredExternals) { | ||
validate(requiredExternals, consumerId) { | ||
for (const [externalName, versionRange] of Object.entries(requiredExternals)) { | ||
const providedVersion = this.providedExternals[externalName]; | ||
if (!providedVersion) { | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} is not provided.`); | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)}${consumerId ? ` as required by ${JSON.stringify(consumerId)}` : ``} is not provided.`); | ||
} | ||
if (!semverSatisfies(providedVersion, versionRange)) { | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} in the required version range ${JSON.stringify(versionRange)} is not satisfied. The provided version is ${JSON.stringify(providedVersion)}.`); | ||
throw new Error(`The external dependency ${JSON.stringify(externalName)} ${consumerId | ||
? `as required by ${JSON.stringify(consumerId)} in the` | ||
: `in the required`} version range ${JSON.stringify(versionRange)} is not satisfied. The provided version is ${JSON.stringify(providedVersion)}.`); | ||
} | ||
@@ -35,0 +37,0 @@ } |
@@ -135,3 +135,3 @@ import { AsyncValue } from './async-value'; | ||
var _a, _b; | ||
this.validateExternals(featureAppDefinition); | ||
this.validateExternals(featureAppDefinition, featureAppId); | ||
const { featureAppName, baseUrl, beforeCreate, config, done, parentFeatureApp, } = options; | ||
@@ -184,3 +184,3 @@ const binding = this.featureServiceRegistry.bindFeatureServices(featureAppDefinition, featureAppId, featureAppName); | ||
} | ||
validateExternals(featureAppDefinition) { | ||
validateExternals(featureAppDefinition, featureAppId) { | ||
const { externalsValidator } = this.options; | ||
@@ -192,3 +192,3 @@ if (!externalsValidator) { | ||
if (dependencies && dependencies.externals) { | ||
externalsValidator.validate(dependencies.externals); | ||
externalsValidator.validate(dependencies.externals, featureAppId); | ||
} | ||
@@ -195,0 +195,0 @@ } |
@@ -126,3 +126,3 @@ import semverCoerce from 'semver/functions/coerce'; | ||
} | ||
this.validateExternals(providerDefinition); | ||
this.validateExternals(providerDefinition, providerId); | ||
const { featureServices } = this.bindFeatureServices(providerDefinition, providerId); | ||
@@ -174,3 +174,3 @@ const sharedFeatureService = providerDefinition.create({ featureServices }); | ||
} | ||
validateExternals(featureAppDefinition) { | ||
validateExternals(consumerDefinition, consumerId) { | ||
const { externalsValidator } = this.options; | ||
@@ -180,5 +180,5 @@ if (!externalsValidator) { | ||
} | ||
const { dependencies } = featureAppDefinition; | ||
const { dependencies } = consumerDefinition; | ||
if (dependencies && dependencies.externals) { | ||
externalsValidator.validate(dependencies.externals); | ||
externalsValidator.validate(dependencies.externals, consumerId); | ||
} | ||
@@ -185,0 +185,0 @@ } |
{ | ||
"name": "@feature-hub/core", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Create scalable web applications using micro frontends.", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "dcfce86481a857e78c2c565ae32f260a06cc66bf" | ||
"gitHead": "a9413fc8a42ef342723920d043af1571058f5d87" | ||
} |
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
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
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
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
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
731132
4823