Comparing version 0.44.7 to 0.45.0
@@ -14,6 +14,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -65,6 +66,6 @@ }); | ||
}; | ||
var __values = (this && this.__values) || function (o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
@@ -75,2 +76,3 @@ if (o && i >= o.length) o = void 0; | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
@@ -96,3 +98,3 @@ var __spread = (this && this.__spread) || function () { | ||
if (config === void 0) { config = {}; } | ||
var options = __assign({}, defaults, config); | ||
var options = __assign(__assign({}, defaults), config); | ||
var instance = axios_1.default.create({ | ||
@@ -113,3 +115,3 @@ baseURL: options.apiURL, | ||
var getToken = newGetToken; | ||
var r3 = __assign({}, options, { | ||
var r3 = __assign(__assign({}, options), { | ||
// Store the axios instance so we can re-use it and also add | ||
@@ -793,3 +795,3 @@ // interceptors on it. | ||
}) | ||
.then(function () { return (__assign({}, contact, { accountCreated: true })); })]; | ||
.then(function () { return (__assign(__assign({}, contact), { accountCreated: true })); })]; | ||
}); | ||
@@ -962,3 +964,5 @@ }); | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, r3.get('/bulk/registration/uploads/list/').then(function (_a) { | ||
return [2 /*return*/, r3 | ||
.get('/bulk/registration/uploads/list/') | ||
.then(function (_a) { | ||
var uploads = _a.uploads; | ||
@@ -1093,3 +1097,3 @@ return uploads.map(function (reg) { return ({ | ||
data: data, | ||
headers: __assign({}, extraHeaders, utils_1.pickBy({ | ||
headers: __assign(__assign({}, extraHeaders), utils_1.pickBy({ | ||
Authorization: token, | ||
@@ -1110,3 +1114,3 @@ developerKey: r3.developerKey, | ||
data: data, | ||
headers: __assign({}, extraHeaders, utils_1.pickBy({ | ||
headers: __assign(__assign({}, extraHeaders), utils_1.pickBy({ | ||
accessKey: r3.accessKey, | ||
@@ -1113,0 +1117,0 @@ apiKey: r3.apiKey, |
export declare function parseLegacyDate(date: string, format: string): Date | ||
export declare function toNumber(num: any, radix?: number): number | ||
export declare function groupBy(arr: any[], key: string): any | ||
export declare function pickBy(object: { | ||
[key: string]: any | ||
}): { | ||
[key: string]: any | ||
} | ||
export declare function pickBy(object: { [key: string]: any }): any | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
function parseLegacyDate(date, format) { | ||
return luxon_1.DateTime.fromFormat(date, format).toJSDate(); | ||
return luxon_1.DateTime.fromFormat(date, format.replace('T', "'T'")).toJSDate(); | ||
} | ||
@@ -8,0 +8,0 @@ exports.parseLegacyDate = parseLegacyDate; |
{ | ||
"name": "remote.it", | ||
"version": "0.44.7", | ||
"version": "0.45.0", | ||
"description": "remote.it JavaScript/node client library", | ||
@@ -10,4 +10,3 @@ "main": "lib/remote.it.js", | ||
"clean": "rimraf lib/*", | ||
"lint": "tslint --fix --project .", | ||
"postcompile": "npm-run-all -p prettier lint size", | ||
"postcompile": "npm-run-all -p prettier size", | ||
"postpublish": "#git push origin --all; git push origin --tags", | ||
@@ -50,3 +49,3 @@ "postversion": "#npm publish", | ||
"js-base64": "^2.5.1", | ||
"luxon": "^1.22.0" | ||
"luxon": "^1.22.2" | ||
}, | ||
@@ -61,3 +60,6 @@ "bugs": { | ||
"homepage": "https://github.com/remoteit/remote.it.js#readme", | ||
"gitHead": "a9c4906f943f60be0ced0f497604b9e149084b37" | ||
"gitHead": "1ed80042bb9ba50fe8742e0033c9740ca939ecfd", | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^4.4.2" | ||
} | ||
} |
@@ -281,3 +281,3 @@ import axios, { AxiosError, AxiosResponse, Method } from 'axios' | ||
service: IService, | ||
hostip: string = '255.255.255.255' | ||
hostip = '255.255.255.255' | ||
): Promise<IConnection> { | ||
@@ -446,56 +446,56 @@ return r3 | ||
// Construct a nested tree of device+services | ||
const grouped = Object.keys(groupedByHardwareID).map( | ||
(hwid: string): IDevice | undefined => { | ||
// services: IRawService[], hwid: string | ||
let services = groupedByHardwareID[hwid] | ||
let device: IRawDevice | undefined | ||
const grouped = Object.keys(groupedByHardwareID).map((hwid: string): | ||
| IDevice | ||
| undefined => { | ||
// services: IRawService[], hwid: string | ||
let services = groupedByHardwareID[hwid] | ||
let device: IRawDevice | undefined | ||
for (const service of services) { | ||
if (service.servicetitle === 'Bulk Service') { | ||
const removed = services.splice(services.indexOf(service), 1) | ||
device = removed[0] | ||
} | ||
for (const service of services) { | ||
if (service.servicetitle === 'Bulk Service') { | ||
const removed = services.splice(services.indexOf(service), 1) | ||
device = removed[0] | ||
} | ||
if (!device) return | ||
} | ||
if (!device) return | ||
services = services.filter(Boolean) | ||
services = services.filter(Boolean) | ||
return { | ||
id: device.deviceaddress, | ||
name: device.devicealias, | ||
owner: device.ownerusername, | ||
state: device.devicestate as DeviceState, | ||
hardwareID: hwid, | ||
createdAt: new Date(device.createdate), | ||
shared: device.shared, | ||
region: device.georegion, | ||
contactedAt: new Date(device.lastcontacted), | ||
lastExternalIP: device.devicelastip, | ||
lastInternalIP: device.lastinternalip, | ||
return { | ||
id: device.deviceaddress, | ||
name: device.devicealias, | ||
owner: device.ownerusername, | ||
state: device.devicestate as DeviceState, | ||
hardwareID: hwid, | ||
createdAt: new Date(device.createdate), | ||
shared: device.shared, | ||
region: device.georegion, | ||
contactedAt: new Date(device.lastcontacted), | ||
lastExternalIP: device.devicelastip, | ||
lastInternalIP: device.lastinternalip, | ||
services: [ | ||
...new Set( | ||
services.map( | ||
(s: IRawService): IService => ({ | ||
id: s.deviceaddress, | ||
name: s.devicealias, | ||
port: r3.devices.parseDeviceType(s.devicetype).port, | ||
state: s.devicestate as ServiceState, | ||
protocol: s.servicetitle, | ||
lastExternalIP: s.devicelastip, | ||
createdAt: new Date(s.createdate), | ||
contactedAt: new Date(s.lastcontacted), | ||
region: s.georegion, | ||
type: r3.devices.parseDeviceType(s.devicetype).name, | ||
typeID: r3.devices.parseDeviceType(s.devicetype).id, | ||
deviceID: device | ||
? device.deviceaddress | ||
: 'unknown-device-id', | ||
}) | ||
) | ||
), | ||
] as IService[], | ||
} | ||
services: [ | ||
...new Set( | ||
services.map( | ||
(s: IRawService): IService => ({ | ||
id: s.deviceaddress, | ||
name: s.devicealias, | ||
port: r3.devices.parseDeviceType(s.devicetype).port, | ||
state: s.devicestate as ServiceState, | ||
protocol: s.servicetitle, | ||
lastExternalIP: s.devicelastip, | ||
createdAt: new Date(s.createdate), | ||
contactedAt: new Date(s.lastcontacted), | ||
region: s.georegion, | ||
type: r3.devices.parseDeviceType(s.devicetype).name, | ||
typeID: r3.devices.parseDeviceType(s.devicetype).id, | ||
deviceID: device | ||
? device.deviceaddress | ||
: 'unknown-device-id', | ||
}) | ||
) | ||
), | ||
] as IService[], | ||
} | ||
) | ||
}) | ||
@@ -512,3 +512,3 @@ return grouped.filter(Boolean) as IDevice[] | ||
): Promise<any> { | ||
let body = { | ||
const body = { | ||
categoryA: catA, | ||
@@ -530,3 +530,3 @@ categoryB: catB, | ||
): Promise<any> { | ||
let body = { | ||
const body = { | ||
statusA: statusA, | ||
@@ -759,19 +759,21 @@ statusB: statusB, | ||
async list(): Promise<IRegistration[]> { | ||
return r3.get('/bulk/registration/uploads/list/').then( | ||
({ uploads }: { uploads: IRawRegistration[] }): IRegistration[] => | ||
uploads.map(reg => ({ | ||
id: reg.id, | ||
state: reg.state, | ||
uploaded: toNumber(reg.uploaded), | ||
name: reg.name, | ||
type: reg.type, | ||
productID: reg.productid, | ||
productName: reg.productname, | ||
registered: reg.registered, | ||
preRegistered: toNumber(reg.preregistered), | ||
failures: toNumber(reg.service_failures), | ||
createdAt: new Date(reg.created), | ||
updatedAt: new Date(reg.updated), | ||
})) | ||
) | ||
return r3 | ||
.get('/bulk/registration/uploads/list/') | ||
.then( | ||
({ uploads }: { uploads: IRawRegistration[] }): IRegistration[] => | ||
uploads.map(reg => ({ | ||
id: reg.id, | ||
state: reg.state, | ||
uploaded: toNumber(reg.uploaded), | ||
name: reg.name, | ||
type: reg.type, | ||
productID: reg.productid, | ||
productName: reg.productname, | ||
registered: reg.registered, | ||
preRegistered: toNumber(reg.preregistered), | ||
failures: toNumber(reg.service_failures), | ||
createdAt: new Date(reg.created), | ||
updatedAt: new Date(reg.updated), | ||
})) | ||
) | ||
}, | ||
@@ -854,3 +856,3 @@ // TODO: Define return type | ||
// let token = 'Bearer ' + r3.getToken().getJwtToken() | ||
let token = await getToken!() | ||
const token = await getToken!() | ||
@@ -857,0 +859,0 @@ return r3.axios |
import { DateTime } from 'luxon' | ||
export function parseLegacyDate(date: string, format: string) { | ||
return DateTime.fromFormat(date, format).toJSDate() | ||
export function parseLegacyDate(date: string, format: string): Date { | ||
return DateTime.fromFormat(date, format.replace('T', "'T'")).toJSDate() | ||
} | ||
export function toNumber(num: any, radix = 10) { | ||
export function toNumber(num: any, radix = 10): number { | ||
return parseInt(num, radix) | ||
} | ||
export function groupBy(arr: any[], key: string) { | ||
export function groupBy(arr: any[], key: string): any { | ||
return arr.reduce( | ||
@@ -18,3 +18,3 @@ (r, v, i, a, k = v[key]) => ((r[k] || (r[k] = [])).push(v), r), | ||
export function pickBy(object: { [key: string]: any }) { | ||
export function pickBy(object: { [key: string]: any }): any { | ||
const obj: { [key: string]: any } = {} | ||
@@ -21,0 +21,0 @@ for (const key in object) { |
@@ -608,6 +608,3 @@ import setup, { | ||
const hostip = '0.0.0.0' | ||
const conn = await r3.devices.connect( | ||
service, | ||
hostip | ||
) | ||
const conn = await r3.devices.connect(service, hostip) | ||
@@ -614,0 +611,0 @@ expect(r3.post).toBeCalledWith('/device/connect', { |
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
236501
1
4653
Updatedluxon@^1.22.2