@opentelemetry/api
Advanced tools
Comparing version 0.18.0 to 0.18.1
@@ -50,4 +50,4 @@ "use strict"; | ||
var _a, _b; | ||
var version = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version; | ||
if (!version || !semver_1.isCompatible(version)) { | ||
var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version; | ||
if (!globalVersion || !semver_1.isCompatible(globalVersion)) { | ||
return; | ||
@@ -54,0 +54,0 @@ } |
@@ -6,4 +6,9 @@ /** | ||
* - Exact match is always compatible | ||
* - Major versions must always match | ||
* - The minor version of the API module requesting access to the global API must be greater or equal to the minor version of this API | ||
* - Major versions must match exactly | ||
* - 1.x package cannot use global 2.x package | ||
* - 2.x package cannot use global 1.x package | ||
* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API | ||
* - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects | ||
* - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3 | ||
* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor | ||
* - Patch and build tag differences are not considered at this time | ||
@@ -13,3 +18,3 @@ * | ||
*/ | ||
export declare function _makeCompatibilityCheck(ownVersion: string): (version: string) => boolean; | ||
export declare function _makeCompatibilityCheck(ownVersion: string): (globalVersion: string) => boolean; | ||
/** | ||
@@ -19,4 +24,9 @@ * Test an API version to see if it is compatible with this API. | ||
* - Exact match is always compatible | ||
* - Major versions must always match | ||
* - The minor version of the API module requesting access to the global API must be greater or equal to the minor version of this API | ||
* - Major versions must match exactly | ||
* - 1.x package cannot use global 2.x package | ||
* - 2.x package cannot use global 1.x package | ||
* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API | ||
* - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects | ||
* - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3 | ||
* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor | ||
* - Patch and build tag differences are not considered at this time | ||
@@ -26,3 +36,3 @@ * | ||
*/ | ||
export declare const isCompatible: (version: string) => boolean; | ||
export declare const isCompatible: (globalVersion: string) => boolean; | ||
//# sourceMappingURL=semver.d.ts.map |
@@ -26,4 +26,9 @@ "use strict"; | ||
* - Exact match is always compatible | ||
* - Major versions must always match | ||
* - The minor version of the API module requesting access to the global API must be greater or equal to the minor version of this API | ||
* - Major versions must match exactly | ||
* - 1.x package cannot use global 2.x package | ||
* - 2.x package cannot use global 1.x package | ||
* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API | ||
* - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects | ||
* - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3 | ||
* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor | ||
* - Patch and build tag differences are not considered at this time | ||
@@ -38,3 +43,4 @@ * | ||
if (!myVersionMatch) { | ||
throw new Error('Cannot parse own version'); | ||
// we cannot guarantee compatibility so we always return noop | ||
return function () { return false; }; | ||
} | ||
@@ -46,44 +52,43 @@ var ownVersionParsed = { | ||
}; | ||
return function isCompatible(version) { | ||
if (acceptedVersions.has(version)) { | ||
function _reject(v) { | ||
rejectedVersions.add(v); | ||
return false; | ||
} | ||
function _accept(v) { | ||
acceptedVersions.add(v); | ||
return true; | ||
} | ||
return function isCompatible(globalVersion) { | ||
if (acceptedVersions.has(globalVersion)) { | ||
return true; | ||
} | ||
if (rejectedVersions.has(version)) { | ||
if (rejectedVersions.has(globalVersion)) { | ||
return false; | ||
} | ||
var m = version.match(re); | ||
if (!m) { | ||
var globalVersionMatch = globalVersion.match(re); | ||
if (!globalVersionMatch) { | ||
// cannot parse other version | ||
rejectedVersions.add(version); | ||
return false; | ||
// we cannot guarantee compatibility so we always noop | ||
return _reject(globalVersion); | ||
} | ||
var otherVersionParsed = { | ||
major: +m[1], | ||
minor: +m[2], | ||
patch: +m[3], | ||
var globalVersionParsed = { | ||
major: +globalVersionMatch[1], | ||
minor: +globalVersionMatch[2], | ||
patch: +globalVersionMatch[3], | ||
}; | ||
// major versions must match | ||
if (ownVersionParsed.major !== otherVersionParsed.major) { | ||
rejectedVersions.add(version); | ||
return false; | ||
if (ownVersionParsed.major !== globalVersionParsed.major) { | ||
return _reject(globalVersion); | ||
} | ||
// if major version is 0, minor is treated like major and patch is treated like minor | ||
if (ownVersionParsed.major === 0) { | ||
if (ownVersionParsed.minor !== otherVersionParsed.minor) { | ||
rejectedVersions.add(version); | ||
return false; | ||
if (ownVersionParsed.minor === globalVersionParsed.minor && | ||
ownVersionParsed.patch <= globalVersionParsed.patch) { | ||
return _accept(globalVersion); | ||
} | ||
if (ownVersionParsed.patch < otherVersionParsed.patch) { | ||
rejectedVersions.add(version); | ||
return false; | ||
} | ||
acceptedVersions.add(version); | ||
return true; | ||
return _reject(globalVersion); | ||
} | ||
if (ownVersionParsed.minor < otherVersionParsed.minor) { | ||
rejectedVersions.add(version); | ||
return false; | ||
if (ownVersionParsed.minor <= globalVersionParsed.minor) { | ||
return _accept(globalVersion); | ||
} | ||
acceptedVersions.add(version); | ||
return true; | ||
return _reject(globalVersion); | ||
}; | ||
@@ -96,4 +101,9 @@ } | ||
* - Exact match is always compatible | ||
* - Major versions must always match | ||
* - The minor version of the API module requesting access to the global API must be greater or equal to the minor version of this API | ||
* - Major versions must match exactly | ||
* - 1.x package cannot use global 2.x package | ||
* - 2.x package cannot use global 1.x package | ||
* - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API | ||
* - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects | ||
* - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3 | ||
* - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor | ||
* - Patch and build tag differences are not considered at this time | ||
@@ -100,0 +110,0 @@ * |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.18.0"; | ||
export declare const VERSION = "0.18.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.18.0'; | ||
exports.VERSION = '0.18.1'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,2 +5,12 @@ # CHANGELOG | ||
## 0.18.1 | ||
### :bug: Bug Fix | ||
* [#16](https://github.com/open-telemetry/opentelemetry-js-api/pull/16) fix: Reverse the direction of the semver check ([@dyladan](https://github.com/dyladan)) | ||
### Committers: 1 | ||
* Daniel Dyla ([@dyladan](https://github.com/dyladan)) | ||
## v0.18.0 | ||
@@ -7,0 +17,0 @@ |
{ | ||
"name": "@opentelemetry/api", | ||
"version": "0.18.0", | ||
"version": "0.18.1", | ||
"description": "Public API for OpenTelemetry", | ||
@@ -5,0 +5,0 @@ "main": "build/src/index.js", |
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
186205
3283