balena-sdk 16.9.2 → 16.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/es2015/balena-browser.js +16 -33
- package/es2015/balena-browser.min.js +1 -1
- package/es2015/index.d.ts +1 -1
- package/es2015/models/index.d.ts +1 -1
- package/es2015/models/os.d.ts +1 -1
- package/es2015/models/os.js +15 -32
- package/es2015/util/sdk-version.js +1 -1
- package/es2018/balena-browser.js +16 -33
- package/es2018/balena-browser.min.js +1 -1
- package/es2018/index.d.ts +1 -1
- package/es2018/models/index.d.ts +1 -1
- package/es2018/models/os.d.ts +1 -1
- package/es2018/models/os.js +15 -32
- package/es2018/util/sdk-version.js +1 -1
- package/package.json +2 -2
package/es2015/index.d.ts
CHANGED
|
@@ -349,7 +349,7 @@ declare const sdkTemplate: {
|
|
|
349
349
|
_getDeviceTypes: (() => Promise<import("./types/device-type-json").DeviceType[]>) & import("memoizee").Memoized<() => Promise<import("./types/device-type-json").DeviceType[]>>;
|
|
350
350
|
_getDownloadSize: ((deviceType: string, version: string) => Promise<any>) & import("memoizee").Memoized<(deviceType: string, version: string) => Promise<any>>;
|
|
351
351
|
_clearDeviceTypesAndOsVersionCaches: () => void;
|
|
352
|
-
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Pick<import("./models/os").OsVersion, "rawVersion" | "isRecommended">[]) => string | undefined;
|
|
352
|
+
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Pick<import("./models/os").OsVersion, "rawVersion" | "isRecommended">[]) => string | null | undefined;
|
|
353
353
|
OsTypes: typeof import("./models/os").OsTypes;
|
|
354
354
|
getAllOsVersions: {
|
|
355
355
|
(deviceType: string, options?: import("../typings/pinejs-client-core").ODataOptions<import("./types/models").Release> | undefined): Promise<import("./models/os").OsVersion[]>;
|
package/es2015/models/index.d.ts
CHANGED
|
@@ -269,7 +269,7 @@ declare const _default: (deps: InjectedDependenciesParam, opts: InjectedOptionsP
|
|
|
269
269
|
_getDeviceTypes: (() => Promise<import("../types/device-type-json").DeviceType[]>) & import("memoizee").Memoized<() => Promise<import("../types/device-type-json").DeviceType[]>>;
|
|
270
270
|
_getDownloadSize: ((deviceType: string, version: string) => Promise<any>) & import("memoizee").Memoized<(deviceType: string, version: string) => Promise<any>>;
|
|
271
271
|
_clearDeviceTypesAndOsVersionCaches: () => void;
|
|
272
|
-
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Pick<import("./os").OsVersion, "rawVersion" | "isRecommended">[]) => string | undefined;
|
|
272
|
+
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Pick<import("./os").OsVersion, "rawVersion" | "isRecommended">[]) => string | null | undefined;
|
|
273
273
|
OsTypes: typeof import("./os").OsTypes;
|
|
274
274
|
getAllOsVersions: {
|
|
275
275
|
(deviceType: string, options?: import("..").PineOptions<import("..").Release> | undefined): Promise<import("./os").OsVersion[]>;
|
package/es2015/models/os.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ declare const getOsModel: (deps: InjectedDependenciesParam, opts: InjectedOption
|
|
|
51
51
|
_getDeviceTypes: (() => Promise<DeviceTypeJson.DeviceType[]>) & import("memoizee").Memoized<() => Promise<DeviceTypeJson.DeviceType[]>>;
|
|
52
52
|
_getDownloadSize: ((deviceType: string, version: string) => Promise<any>) & import("memoizee").Memoized<(deviceType: string, version: string) => Promise<any>>;
|
|
53
53
|
_clearDeviceTypesAndOsVersionCaches: () => void;
|
|
54
|
-
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Array<Pick<OsVersion, 'rawVersion' | 'isRecommended'>>) => string | undefined;
|
|
54
|
+
_getMaxSatisfyingVersion: (versionOrRange: string, osVersions: Array<Pick<OsVersion, 'rawVersion' | 'isRecommended'>>) => string | null | undefined;
|
|
55
55
|
OsTypes: typeof OsTypes;
|
|
56
56
|
getAllOsVersions: {
|
|
57
57
|
(deviceType: string, options?: PineOptions<Release> | undefined): Promise<OsVersion[]>;
|
package/es2015/models/os.js
CHANGED
|
@@ -46,7 +46,9 @@ const releaseSelectedFields = (0, types_1.toWritable)([
|
|
|
46
46
|
'known_issue_list',
|
|
47
47
|
'raw_version',
|
|
48
48
|
]);
|
|
49
|
-
const
|
|
49
|
+
const sortVersions = (a, b) => {
|
|
50
|
+
return bSemver.rcompare(a.rawVersion, b.rawVersion);
|
|
51
|
+
};
|
|
50
52
|
const getOsModel = function (deps, opts) {
|
|
51
53
|
const { pine, request, pubsub } = deps;
|
|
52
54
|
const { apiUrl, isBrowser } = opts;
|
|
@@ -58,9 +60,6 @@ const getOsModel = function (deps, opts) {
|
|
|
58
60
|
() => require('../util/device-types'));
|
|
59
61
|
const hupActionHelper = once(() => require('../util/device-actions/os-update/utils').hupActionHelper);
|
|
60
62
|
const authDependentMemoizer = (0, cache_1.getAuthDependentMemoize)(pubsub);
|
|
61
|
-
const sortVersions = (a, b) => {
|
|
62
|
-
return bSemver.rcompare(a.rawVersion, b.rawVersion);
|
|
63
|
-
};
|
|
64
63
|
const tagsToDictionary = (tags) => {
|
|
65
64
|
const result = {};
|
|
66
65
|
for (const { tag_key, value } of tags) {
|
|
@@ -187,14 +186,12 @@ const getOsModel = function (deps, opts) {
|
|
|
187
186
|
const appTags = getOsAppTags((_c = hostApp.application_tag) !== null && _c !== void 0 ? _c : []);
|
|
188
187
|
osVersionsByDeviceType[hostAppDeviceType].push(..._getOsVersionsFromReleases((_d = hostApp.owns__release) !== null && _d !== void 0 ? _d : [], appTags));
|
|
189
188
|
});
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
// This mutates the passed object.
|
|
193
|
-
const _transformVersionSets = (osVersionsByDeviceType) => {
|
|
189
|
+
// transform version sets
|
|
194
190
|
Object.keys(osVersionsByDeviceType).forEach((deviceType) => {
|
|
195
191
|
osVersionsByDeviceType[deviceType].sort(sortVersions);
|
|
196
|
-
|
|
192
|
+
// TODO: Drop in next major
|
|
197
193
|
// Note: the recommended version settings might come from the server in the future, for now we just set it to the latest version for each os type.
|
|
194
|
+
const recommendedPerOsType = {};
|
|
198
195
|
osVersionsByDeviceType[deviceType].forEach((version) => {
|
|
199
196
|
if (!recommendedPerOsType[version.osType]) {
|
|
200
197
|
if (version.variant !== 'dev' &&
|
|
@@ -214,7 +211,7 @@ const getOsModel = function (deps, opts) {
|
|
|
214
211
|
};
|
|
215
212
|
const _getAllOsVersions = (deviceTypes, options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
216
213
|
const hostapps = yield _getOsVersions(deviceTypes, options);
|
|
217
|
-
return yield
|
|
214
|
+
return yield _transformHostApps(hostapps);
|
|
218
215
|
});
|
|
219
216
|
const _memoizedGetAllOsVersions = authDependentMemoizer((deviceTypes, listedByDefault) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
220
217
|
return yield _getAllOsVersions(deviceTypes, listedByDefault
|
|
@@ -250,7 +247,7 @@ const getOsModel = function (deps, opts) {
|
|
|
250
247
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
251
248
|
const singleDeviceTypeArg = typeof deviceTypes === 'string' ? deviceTypes : false;
|
|
252
249
|
deviceTypes = Array.isArray(deviceTypes) ? deviceTypes : [deviceTypes];
|
|
253
|
-
const versionsByDt = yield _memoizedGetAllOsVersions(deviceTypes.sort(), true);
|
|
250
|
+
const versionsByDt = yield _memoizedGetAllOsVersions(deviceTypes.slice().sort(), true);
|
|
254
251
|
return singleDeviceTypeArg
|
|
255
252
|
? (_a = versionsByDt[singleDeviceTypeArg]) !== null && _a !== void 0 ? _a : []
|
|
256
253
|
: versionsByDt;
|
|
@@ -284,7 +281,7 @@ const getOsModel = function (deps, opts) {
|
|
|
284
281
|
const singleDeviceTypeArg = typeof deviceTypes === 'string' ? deviceTypes : false;
|
|
285
282
|
deviceTypes = Array.isArray(deviceTypes) ? deviceTypes : [deviceTypes];
|
|
286
283
|
const versionsByDt = options == null
|
|
287
|
-
? yield _memoizedGetAllOsVersions(deviceTypes.sort(), null)
|
|
284
|
+
? yield _memoizedGetAllOsVersions(deviceTypes.slice().sort(), null)
|
|
288
285
|
: yield _getAllOsVersions(deviceTypes, options);
|
|
289
286
|
return singleDeviceTypeArg
|
|
290
287
|
? (_a = versionsByDt[singleDeviceTypeArg]) !== null && _a !== void 0 ? _a : []
|
|
@@ -341,23 +338,12 @@ const getOsModel = function (deps, opts) {
|
|
|
341
338
|
return v;
|
|
342
339
|
}
|
|
343
340
|
const vNormalized = v[0] === 'v' ? v.substring(1) : v;
|
|
344
|
-
|
|
341
|
+
// We still don't want to allow `balenaOS` prefixes, which balena-semver allows.
|
|
342
|
+
if (!bSemver.valid(vNormalized) || !/^\d/.test(vNormalized)) {
|
|
345
343
|
throw new Error(`Invalid semver version: ${v}`);
|
|
346
344
|
}
|
|
347
345
|
return vNormalized;
|
|
348
346
|
};
|
|
349
|
-
const fixNonSemver = (version) => {
|
|
350
|
-
if (version == null) {
|
|
351
|
-
return version;
|
|
352
|
-
}
|
|
353
|
-
return version.replace(/\.rev(\d+)/, '+FIXED-rev$1');
|
|
354
|
-
};
|
|
355
|
-
const unfixNonSemver = (version) => {
|
|
356
|
-
if (version == null) {
|
|
357
|
-
return version;
|
|
358
|
-
}
|
|
359
|
-
return version.replace(/\+FIXED-rev(\d+)/, '.rev$1');
|
|
360
|
-
};
|
|
361
347
|
/**
|
|
362
348
|
* @summary Get the max OS version satisfying the given range.
|
|
363
349
|
* @description Utility method exported for testability.
|
|
@@ -378,16 +364,13 @@ const getOsModel = function (deps, opts) {
|
|
|
378
364
|
return (_d = ((_c = osVersions.find((v) => v.isRecommended)) !== null && _c !== void 0 ? _c : osVersions[0])) === null || _d === void 0 ? void 0 : _d.rawVersion;
|
|
379
365
|
}
|
|
380
366
|
const versions = osVersions.map((v) => v.rawVersion);
|
|
381
|
-
|
|
382
|
-
// TODO: Once we integrate balena-semver, balena-semver should learn to handle this itself
|
|
383
|
-
const semverVersionOrRange = fixNonSemver(versionOrRange);
|
|
384
|
-
if (semverVersions.includes(semverVersionOrRange)) {
|
|
367
|
+
if (versions.includes(versionOrRange)) {
|
|
385
368
|
// If the _exact_ version you're looking for exists, it's not a range, and
|
|
386
369
|
// we should return it exactly, not any old equivalent version.
|
|
387
|
-
return
|
|
370
|
+
return versionOrRange;
|
|
388
371
|
}
|
|
389
|
-
const maxVersion = bSemver.maxSatisfying(
|
|
390
|
-
return
|
|
372
|
+
const maxVersion = bSemver.maxSatisfying(versions, versionOrRange);
|
|
373
|
+
return maxVersion;
|
|
391
374
|
};
|
|
392
375
|
/**
|
|
393
376
|
* @summary Get OS download size estimate
|
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// being embedded in the dist of the consumer project
|
|
7
7
|
// which we want to avoid, both b/c of the dist size increase &
|
|
8
8
|
// the security concerns of including the versions of the dependencies
|
|
9
|
-
const sdkVersion = '16.9.
|
|
9
|
+
const sdkVersion = '16.9.4';
|
|
10
10
|
exports.default = sdkVersion;
|
package/es2018/balena-browser.js
CHANGED
|
@@ -9382,7 +9382,9 @@ const releaseSelectedFields = (0, types_1.toWritable)([
|
|
|
9382
9382
|
'known_issue_list',
|
|
9383
9383
|
'raw_version',
|
|
9384
9384
|
]);
|
|
9385
|
-
const
|
|
9385
|
+
const sortVersions = (a, b) => {
|
|
9386
|
+
return bSemver.rcompare(a.rawVersion, b.rawVersion);
|
|
9387
|
+
};
|
|
9386
9388
|
const getOsModel = function (deps, opts) {
|
|
9387
9389
|
const { pine, request, pubsub } = deps;
|
|
9388
9390
|
const { apiUrl, isBrowser } = opts;
|
|
@@ -9394,9 +9396,6 @@ const getOsModel = function (deps, opts) {
|
|
|
9394
9396
|
() => require('../util/device-types'));
|
|
9395
9397
|
const hupActionHelper = once(() => require('../util/device-actions/os-update/utils').hupActionHelper);
|
|
9396
9398
|
const authDependentMemoizer = (0, cache_1.getAuthDependentMemoize)(pubsub);
|
|
9397
|
-
const sortVersions = (a, b) => {
|
|
9398
|
-
return bSemver.rcompare(a.rawVersion, b.rawVersion);
|
|
9399
|
-
};
|
|
9400
9399
|
const tagsToDictionary = (tags) => {
|
|
9401
9400
|
const result = {};
|
|
9402
9401
|
for (const { tag_key, value } of tags) {
|
|
@@ -9531,14 +9530,12 @@ const getOsModel = function (deps, opts) {
|
|
|
9531
9530
|
const appTags = getOsAppTags((_c = hostApp.application_tag) !== null && _c !== void 0 ? _c : []);
|
|
9532
9531
|
osVersionsByDeviceType[hostAppDeviceType].push(..._getOsVersionsFromReleases((_d = hostApp.owns__release) !== null && _d !== void 0 ? _d : [], appTags));
|
|
9533
9532
|
});
|
|
9534
|
-
|
|
9535
|
-
};
|
|
9536
|
-
// This mutates the passed object.
|
|
9537
|
-
const _transformVersionSets = (osVersionsByDeviceType) => {
|
|
9533
|
+
// transform version sets
|
|
9538
9534
|
Object.keys(osVersionsByDeviceType).forEach((deviceType) => {
|
|
9539
9535
|
osVersionsByDeviceType[deviceType].sort(sortVersions);
|
|
9540
|
-
|
|
9536
|
+
// TODO: Drop in next major
|
|
9541
9537
|
// Note: the recommended version settings might come from the server in the future, for now we just set it to the latest version for each os type.
|
|
9538
|
+
const recommendedPerOsType = {};
|
|
9542
9539
|
osVersionsByDeviceType[deviceType].forEach((version) => {
|
|
9543
9540
|
if (!recommendedPerOsType[version.osType]) {
|
|
9544
9541
|
if (version.variant !== 'dev' &&
|
|
@@ -9558,7 +9555,7 @@ const getOsModel = function (deps, opts) {
|
|
|
9558
9555
|
};
|
|
9559
9556
|
const _getAllOsVersions = async (deviceTypes, options) => {
|
|
9560
9557
|
const hostapps = await _getOsVersions(deviceTypes, options);
|
|
9561
|
-
return await
|
|
9558
|
+
return await _transformHostApps(hostapps);
|
|
9562
9559
|
};
|
|
9563
9560
|
const _memoizedGetAllOsVersions = authDependentMemoizer(async (deviceTypes, listedByDefault) => {
|
|
9564
9561
|
return await _getAllOsVersions(deviceTypes, listedByDefault
|
|
@@ -9593,7 +9590,7 @@ const getOsModel = function (deps, opts) {
|
|
|
9593
9590
|
var _a;
|
|
9594
9591
|
const singleDeviceTypeArg = typeof deviceTypes === 'string' ? deviceTypes : false;
|
|
9595
9592
|
deviceTypes = Array.isArray(deviceTypes) ? deviceTypes : [deviceTypes];
|
|
9596
|
-
const versionsByDt = await _memoizedGetAllOsVersions(deviceTypes.sort(), true);
|
|
9593
|
+
const versionsByDt = await _memoizedGetAllOsVersions(deviceTypes.slice().sort(), true);
|
|
9597
9594
|
return singleDeviceTypeArg
|
|
9598
9595
|
? (_a = versionsByDt[singleDeviceTypeArg]) !== null && _a !== void 0 ? _a : []
|
|
9599
9596
|
: versionsByDt;
|
|
@@ -9625,7 +9622,7 @@ const getOsModel = function (deps, opts) {
|
|
|
9625
9622
|
const singleDeviceTypeArg = typeof deviceTypes === 'string' ? deviceTypes : false;
|
|
9626
9623
|
deviceTypes = Array.isArray(deviceTypes) ? deviceTypes : [deviceTypes];
|
|
9627
9624
|
const versionsByDt = options == null
|
|
9628
|
-
? await _memoizedGetAllOsVersions(deviceTypes.sort(), null)
|
|
9625
|
+
? await _memoizedGetAllOsVersions(deviceTypes.slice().sort(), null)
|
|
9629
9626
|
: await _getAllOsVersions(deviceTypes, options);
|
|
9630
9627
|
return singleDeviceTypeArg
|
|
9631
9628
|
? (_a = versionsByDt[singleDeviceTypeArg]) !== null && _a !== void 0 ? _a : []
|
|
@@ -9681,23 +9678,12 @@ const getOsModel = function (deps, opts) {
|
|
|
9681
9678
|
return v;
|
|
9682
9679
|
}
|
|
9683
9680
|
const vNormalized = v[0] === 'v' ? v.substring(1) : v;
|
|
9684
|
-
|
|
9681
|
+
// We still don't want to allow `balenaOS` prefixes, which balena-semver allows.
|
|
9682
|
+
if (!bSemver.valid(vNormalized) || !/^\d/.test(vNormalized)) {
|
|
9685
9683
|
throw new Error(`Invalid semver version: ${v}`);
|
|
9686
9684
|
}
|
|
9687
9685
|
return vNormalized;
|
|
9688
9686
|
};
|
|
9689
|
-
const fixNonSemver = (version) => {
|
|
9690
|
-
if (version == null) {
|
|
9691
|
-
return version;
|
|
9692
|
-
}
|
|
9693
|
-
return version.replace(/\.rev(\d+)/, '+FIXED-rev$1');
|
|
9694
|
-
};
|
|
9695
|
-
const unfixNonSemver = (version) => {
|
|
9696
|
-
if (version == null) {
|
|
9697
|
-
return version;
|
|
9698
|
-
}
|
|
9699
|
-
return version.replace(/\+FIXED-rev(\d+)/, '.rev$1');
|
|
9700
|
-
};
|
|
9701
9687
|
/**
|
|
9702
9688
|
* @summary Get the max OS version satisfying the given range.
|
|
9703
9689
|
* @description Utility method exported for testability.
|
|
@@ -9718,16 +9704,13 @@ const getOsModel = function (deps, opts) {
|
|
|
9718
9704
|
return (_d = ((_c = osVersions.find((v) => v.isRecommended)) !== null && _c !== void 0 ? _c : osVersions[0])) === null || _d === void 0 ? void 0 : _d.rawVersion;
|
|
9719
9705
|
}
|
|
9720
9706
|
const versions = osVersions.map((v) => v.rawVersion);
|
|
9721
|
-
|
|
9722
|
-
// TODO: Once we integrate balena-semver, balena-semver should learn to handle this itself
|
|
9723
|
-
const semverVersionOrRange = fixNonSemver(versionOrRange);
|
|
9724
|
-
if (semverVersions.includes(semverVersionOrRange)) {
|
|
9707
|
+
if (versions.includes(versionOrRange)) {
|
|
9725
9708
|
// If the _exact_ version you're looking for exists, it's not a range, and
|
|
9726
9709
|
// we should return it exactly, not any old equivalent version.
|
|
9727
|
-
return
|
|
9710
|
+
return versionOrRange;
|
|
9728
9711
|
}
|
|
9729
|
-
const maxVersion = bSemver.maxSatisfying(
|
|
9730
|
-
return
|
|
9712
|
+
const maxVersion = bSemver.maxSatisfying(versions, versionOrRange);
|
|
9713
|
+
return maxVersion;
|
|
9731
9714
|
};
|
|
9732
9715
|
/**
|
|
9733
9716
|
* @summary Get OS download size estimate
|
|
@@ -11916,7 +11899,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11916
11899
|
// being embedded in the dist of the consumer project
|
|
11917
11900
|
// which we want to avoid, both b/c of the dist size increase &
|
|
11918
11901
|
// the security concerns of including the versions of the dependencies
|
|
11919
|
-
const sdkVersion = '16.9.
|
|
11902
|
+
const sdkVersion = '16.9.4';
|
|
11920
11903
|
exports.default = sdkVersion;
|
|
11921
11904
|
|
|
11922
11905
|
},{}],47:[function(require,module,exports){
|