123456789101112131415161718192021222324252627282930313233343536373839 |
- "use strict";
- var semver = require('semver');
- function compatible(compatibleSDK) {
- return function (clientSDK) {
- if (typeof clientSDK === 'string') {
- clientSDK = fromString(clientSDK);
- }
- // REST API, or custom SDK
- if (!clientSDK) {
- return true;
- }
- const clientVersion = clientSDK.version;
- const compatiblityVersion = compatibleSDK[clientSDK.sdk];
- return semver.satisfies(clientVersion, compatiblityVersion);
- };
- }
- function supportsForwardDelete(clientSDK) {
- return compatible({
- js: '>=1.9.0'
- })(clientSDK);
- }
- function fromString(version) {
- const versionRE = /([-a-zA-Z]+)([0-9\.]+)/;
- const match = version.toLowerCase().match(versionRE);
- if (match && match.length === 3) {
- return {
- sdk: match[1],
- version: match[2]
- };
- }
- return undefined;
- }
- module.exports = {
- compatible,
- supportsForwardDelete,
- fromString
- };
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJzZW12ZXIiLCJyZXF1aXJlIiwiY29tcGF0aWJsZSIsImNvbXBhdGlibGVTREsiLCJjbGllbnRTREsiLCJmcm9tU3RyaW5nIiwiY2xpZW50VmVyc2lvbiIsInZlcnNpb24iLCJjb21wYXRpYmxpdHlWZXJzaW9uIiwic2RrIiwic2F0aXNmaWVzIiwic3VwcG9ydHNGb3J3YXJkRGVsZXRlIiwianMiLCJ2ZXJzaW9uUkUiLCJtYXRjaCIsInRvTG93ZXJDYXNlIiwibGVuZ3RoIiwidW5kZWZpbmVkIiwibW9kdWxlIiwiZXhwb3J0cyJdLCJzb3VyY2VzIjpbIi4uL3NyYy9DbGllbnRTREsuanMiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHNlbXZlciA9IHJlcXVpcmUoJ3NlbXZlcicpO1xuXG5mdW5jdGlvbiBjb21wYXRpYmxlKGNvbXBhdGlibGVTREspIHtcbiAgcmV0dXJuIGZ1bmN0aW9uIChjbGllbnRTREspIHtcbiAgICBpZiAodHlwZW9mIGNsaWVudFNESyA9PT0g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