Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nrfcloud/models

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrfcloud/models - npm Package Compare versions

Comparing version 1.5.0 to 2.0.0

dist/schema/ApiIndex.d.ts

32

dist/error/AccessDeniedError.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var AccessDeniedError = /** @class */ (function (_super) {
__extends(AccessDeniedError, _super);
function AccessDeniedError() {
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
var _this = _super.apply(this, params) || this;
_this.name = AccessDeniedError.name;
Error.captureStackTrace(_this, AccessDeniedError);
Object.setPrototypeOf(_this, AccessDeniedError.prototype);
return _this;
class AccessDeniedError extends Error {
constructor(...params) {
super(...params);
this.name = AccessDeniedError.name;
Error.captureStackTrace(this, AccessDeniedError);
Object.setPrototypeOf(this, AccessDeniedError.prototype);
}
return AccessDeniedError;
}(Error));
}
exports.AccessDeniedError = AccessDeniedError;
//# sourceMappingURL=AccessDeniedError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var ApplicationError = /** @class */ (function (_super) {
__extends(ApplicationError, _super);
function ApplicationError() {
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
var _this = _super.apply(this, params) || this;
_this.name = ApplicationError.name;
Error.captureStackTrace(_this, ApplicationError);
Object.setPrototypeOf(_this, ApplicationError.prototype);
return _this;
class ApplicationError extends Error {
constructor(...params) {
super(...params);
this.name = ApplicationError.name;
Error.captureStackTrace(this, ApplicationError);
Object.setPrototypeOf(this, ApplicationError.prototype);
}
return ApplicationError;
}(Error));
}
exports.ApplicationError = ApplicationError;
//# sourceMappingURL=ApplicationError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BadRequestError = /** @class */ (function (_super) {
__extends(BadRequestError, _super);
function BadRequestError() {
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
var _this = _super.apply(this, params) || this;
_this.name = BadRequestError.name;
Error.captureStackTrace(_this, BadRequestError);
Object.setPrototypeOf(_this, BadRequestError.prototype);
return _this;
class BadRequestError extends Error {
constructor(...params) {
super(...params);
this.name = BadRequestError.name;
Error.captureStackTrace(this, BadRequestError);
Object.setPrototypeOf(this, BadRequestError.prototype);
}
return BadRequestError;
}(Error));
}
exports.BadRequestError = BadRequestError;
//# sourceMappingURL=BadRequestError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var EntityNotFoundError = /** @class */ (function (_super) {
__extends(EntityNotFoundError, _super);
function EntityNotFoundError() {
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
var _this = _super.apply(this, params) || this;
_this.name = EntityNotFoundError.name;
Error.captureStackTrace(_this, EntityNotFoundError);
Object.setPrototypeOf(_this, EntityNotFoundError.prototype);
return _this;
class EntityNotFoundError extends Error {
constructor(...params) {
super(...params);
this.name = EntityNotFoundError.name;
Error.captureStackTrace(this, EntityNotFoundError);
Object.setPrototypeOf(this, EntityNotFoundError.prototype);
}
return EntityNotFoundError;
}(Error));
}
exports.EntityNotFoundError = EntityNotFoundError;
//# sourceMappingURL=EntityNotFoundError.js.map

@@ -18,2 +18,1 @@ "use strict";

__export(require("./error/ApplicationError"));
//# sourceMappingURL=index.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var VersionedContext_1 = require("./VersionedContext");
var URLValue_1 = require("../value/URLValue");
var Link_1 = require("./Link");
const VersionedContext_1 = require("./VersionedContext");
const URLValue_1 = require("../value/URLValue");
const Link_1 = require("./Link");
/**
* Describes entry points of an API
*/
var ApiIndex = /** @class */ (function (_super) {
__extends(ApiIndex, _super);
class ApiIndex extends VersionedContext_1.VersionedContext {
/**

@@ -33,24 +14,20 @@ * @param {Array} links Links in the index

*/
function ApiIndex(links) {
var _this = _super.call(this, ApiIndex.$context, ApiIndex.$contextVersion) || this;
_this.links = links.map(function (l) { return Link_1.LinkType(l, ['ApiIndex()', 'links:Link[]']); });
return _this;
constructor(links) {
super(ApiIndex.$context, ApiIndex.$contextVersion);
this.links = links.map(l => Link_1.LinkType(l, ['ApiIndex()', 'links:Link[]']));
}
ApiIndex.fromJSON = function (_a) {
var __context = _a.__context, __contextVersion = _a.__contextVersion, links = _a.links;
static fromJSON({ $context, $contextVersion, links }) {
VersionedContext_1.VersionedContext.checkContextVersion(ApiIndex, {
$context: URLValue_1.URLValue.fromString(__context, ['List.fromJSON()', '$context:URLValue']),
$contextVersion: __contextVersion
$context: URLValue_1.URLValue.fromString($context, ['List.fromJSON()', '$context:URLValue']),
$contextVersion: $contextVersion
});
return new ApiIndex(links.map(function (l) { return Link_1.Link.fromJSON(l); }));
};
ApiIndex.prototype.toJSON = function () {
var links = this.links;
return __assign({}, _super.prototype.toJSON.call(this), { links: links.map(function (l) { return l.toJSON(); }) });
};
ApiIndex.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#ApiIndex');
ApiIndex.$contextVersion = 1;
return ApiIndex;
}(VersionedContext_1.VersionedContext));
return new ApiIndex(links.map(l => Link_1.Link.fromJSON(l)));
}
toJSON() {
const { links } = this;
return Object.assign({}, super.toJSON(), { links: links.map(l => l.toJSON()) });
}
}
ApiIndex.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#ApiIndex');
ApiIndex.$contextVersion = 1;
exports.ApiIndex = ApiIndex;
//# sourceMappingURL=ApiIndex.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var VersionedContext_1 = require("../model/VersionedContext");
var URLValue_1 = require("../value/URLValue");
var t = require('tcomb');
var NonEmpytyStringType = t.refinement(t.String, function (s) { return s && s.length > 0; }, 'MaybeNonEmpytyStringType');
var MaybeNonEmpytyStringType = t.maybe(NonEmpytyStringType);
var HttpStatusCodeType = t.refinement(t.Integer, function (n) { return n >= 100 && n < 600; }, 'HttpStatusCodeType');
const VersionedContext_1 = require("../model/VersionedContext");
const URLValue_1 = require("../value/URLValue");
const t = require('tcomb');
const NonEmpytyStringType = t.refinement(t.String, (s) => s && s.length > 0, 'MaybeNonEmpytyStringType');
const MaybeNonEmpytyStringType = t.maybe(NonEmpytyStringType);
const HttpStatusCodeType = t.refinement(t.Integer, (n) => n >= 100 && n < 600, 'HttpStatusCodeType');
/**
* See https://datatracker.ietf.org/doc/draft-ietf-appsawg-http-problem/
*/
var HttpProblem = /** @class */ (function (_super) {
__extends(HttpProblem, _super);
class HttpProblem extends Error {
/**

@@ -36,38 +25,34 @@ * @param {String} type A URI reference [RFC3986] that identifies the problem type.

*/
function HttpProblem(type, title, status, detail) {
var _this = _super.call(this, title) || this;
Object.setPrototypeOf(_this, HttpProblem.prototype);
_this.$context = HttpProblem.$context;
_this.$contextVersion = HttpProblem.$contextVersion;
_this.name = HttpProblem.name;
_this.type = type;
_this.title = NonEmpytyStringType(title, ['HttpProblem', 'title:String']);
_this.status = HttpStatusCodeType(status, ['HttpProblem', 'status:HttpStatusCode']);
_this.detail = MaybeNonEmpytyStringType(detail, ['HttpProblem', 'detail:?String']);
return _this;
constructor(type, title, status, detail) {
super(title);
Object.setPrototypeOf(this, HttpProblem.prototype);
this.$context = HttpProblem.$context;
this.$contextVersion = HttpProblem.$contextVersion;
this.name = HttpProblem.name;
this.type = type;
this.title = NonEmpytyStringType(title, ['HttpProblem', 'title:String']);
this.status = HttpStatusCodeType(status, ['HttpProblem', 'status:HttpStatusCode']);
this.detail = MaybeNonEmpytyStringType(detail, ['HttpProblem', 'detail:?String']);
}
HttpProblem.fromJSON = function (_a) {
var __context = _a.__context, __contextVersion = _a.__contextVersion, type = _a.type, title = _a.title, status = _a.status, detail = _a.detail;
static fromJSON({ $context, $contextVersion, type, title, status, detail }) {
VersionedContext_1.VersionedContext.checkContextVersion(HttpProblem, {
$context: URLValue_1.URLValue.fromString(__context, ['HttpProblem.fromJSON()', '$context:URLValue']),
$contextVersion: __contextVersion
$context: URLValue_1.URLValue.fromString($context, ['HttpProblem.fromJSON()', '$context:URLValue']),
$contextVersion: $contextVersion
});
return new HttpProblem(new URLValue_1.URLValue(type), title, status, detail);
};
HttpProblem.prototype.toJSON = function () {
var _a = this, $context = _a.$context, $contextVersion = _a.$contextVersion, type = _a.type, title = _a.title, status = _a.status, detail = _a.detail;
}
toJSON() {
const { $context, $contextVersion, type, title, status, detail } = this;
return {
__context: $context.toString(),
__contextVersion: $contextVersion,
$context: $context.toString(),
$contextVersion: $contextVersion,
type: type.toString(),
title: title,
status: status,
detail: detail
title,
status,
detail
};
};
HttpProblem.$context = new URLValue_1.URLValue('https://www.ietf.org/id/draft-ietf-appsawg-http-problem-01.txt');
HttpProblem.$contextVersion = 1;
return HttpProblem;
}(Error));
}
}
HttpProblem.$context = new URLValue_1.URLValue('https://www.ietf.org/id/draft-ietf-appsawg-http-problem-01.txt');
HttpProblem.$contextVersion = 1;
exports.HttpProblem = HttpProblem;
//# sourceMappingURL=HttpProblem.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=JSONSerializeable.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var URLValue_1 = require("../value/URLValue");
var VersionedContext_1 = require("./VersionedContext");
var t = require('tcomb');
const URLValue_1 = require("../value/URLValue");
const VersionedContext_1 = require("./VersionedContext");
const t = require('tcomb');
/**
* Describes a link.
*/
var Link = /** @class */ (function (_super) {
__extends(Link, _super);
class Link extends VersionedContext_1.VersionedContext {
/**

@@ -35,25 +16,21 @@ * @param {URLValue} href URL to retrieve the link

*/
function Link(href, subject, rel) {
var _this = _super.call(this, Link.$context, Link.$contextVersion) || this;
_this.href = URLValue_1.URLValueType(href, ['Link()', 'href:URLValue']);
_this.subject = URLValue_1.URLValueType(subject, ['Link()', 'subject:URLValue']);
_this.rel = rel;
return _this;
constructor(href, subject, rel) {
super(Link.$context, Link.$contextVersion);
this.href = URLValue_1.URLValueType(href, ['Link()', 'href:URLValue']);
this.subject = URLValue_1.URLValueType(subject, ['Link()', 'subject:URLValue']);
this.rel = rel;
}
Link.fromJSON = function (_a) {
var __context = _a.__context, __contextVersion = _a.__contextVersion, href = _a.href, subject = _a.subject, rel = _a.rel;
VersionedContext_1.VersionedContext.checkContextVersion(Link, { $context: URLValue_1.URLValue.fromString(__context, ['Link.fromJSON()', '$context:URLValue']), $contextVersion: __contextVersion });
static fromJSON({ $context, $contextVersion, href, subject, rel }) {
VersionedContext_1.VersionedContext.checkContextVersion(Link, { $context: URLValue_1.URLValue.fromString($context, ['Link.fromJSON()', '$context:URLValue']), $contextVersion: $contextVersion });
return new Link(URLValue_1.URLValue.fromString(href, ['Link.fromJSON()', 'href:URLValue']), URLValue_1.URLValue.fromString(subject, ['Link.fromJSON()', 'subject:URLValue']), rel);
};
Link.prototype.toJSON = function () {
var _a = this, href = _a.href, subject = _a.subject, rel = _a.rel;
return __assign({}, _super.prototype.toJSON.call(this), { href: href.toString(), subject: subject.toString(), rel: rel });
};
Link.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#Link');
Link.$contextVersion = 1;
return Link;
}(VersionedContext_1.VersionedContext));
}
toJSON() {
const { href, subject, rel } = this;
return Object.assign({}, super.toJSON(), { href: href.toString(), subject: subject.toString(), rel });
}
}
Link.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#Link');
Link.$contextVersion = 1;
exports.Link = Link;
exports.LinkType = t.irreducible('LinkType', function (x) { return x && x instanceof Link; });
exports.LinkType = t.irreducible('LinkType', (x) => x && x instanceof Link);
exports.MaybeLinkType = t.maybe(exports.LinkType);
//# sourceMappingURL=Link.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var VersionedContext_1 = require("./VersionedContext");
var Link_1 = require("./Link");
const VersionedContext_1 = require("./VersionedContext");
const Link_1 = require("./Link");
/**

@@ -28,4 +10,3 @@ * Describes JSON data and provides $links between "entities".

*/
var LinkedEntity = /** @class */ (function (_super) {
__extends(LinkedEntity, _super);
class LinkedEntity extends VersionedContext_1.VersionedContext {
/**

@@ -36,14 +17,10 @@ * @param {URLValue} $context context for this model

*/
function LinkedEntity($context, $contextVersion, $links) {
if ($links === void 0) { $links = []; }
var _this = _super.call(this, $context, $contextVersion) || this;
_this.$links = $links.map(function (l) { return Link_1.LinkType(l, ['LinkedEntity()', '$links:Link[]']); });
return _this;
constructor($context, $contextVersion, $links = []) {
super($context, $contextVersion);
this.$links = $links.map(l => Link_1.LinkType(l, ['LinkedEntity()', '$links:Link[]']));
}
LinkedEntity.prototype.toJSON = function () {
return __assign({}, _super.prototype.toJSON.call(this), { __links: this.$links.length ? this.$links.map(function (l) { return l.toJSON(); }) : undefined });
};
return LinkedEntity;
}(VersionedContext_1.VersionedContext));
toJSON() {
return Object.assign({}, super.toJSON(), { $links: this.$links.length ? this.$links.map(l => l.toJSON()) : [] });
}
}
exports.LinkedEntity = LinkedEntity;
//# sourceMappingURL=LinkedEntity.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var LinkedEntity_1 = require("./LinkedEntity");
var URLValue_1 = require("../value/URLValue");
var Link_1 = require("./Link");
var t = require('tcomb');
var ZeroOrPositiveInteger = t.refinement(t.Integer, function (n) { return n >= 0; }, 'ZeroOrPositiveInteger');
const LinkedEntity_1 = require("./LinkedEntity");
const URLValue_1 = require("../value/URLValue");
const Link_1 = require("./Link");
const t = require('tcomb');
const ZeroOrPositiveInteger = t.refinement(t.Integer, (n) => n >= 0, 'ZeroOrPositiveInteger');
/**
* Describes a list if items. Can contain links to e.g. fetch the next page in a resultset.
*/
var List = /** @class */ (function (_super) {
__extends(List, _super);
class List extends LinkedEntity_1.LinkedEntity {
/**

@@ -37,32 +18,27 @@ * @param {Array} items Items in the list

*/
function List(items, total, $links) {
if ($links === void 0) { $links = []; }
var _this = _super.call(this, List.$context, List.$contextVersion, $links) || this;
_this.items = t.list(t.Any)(items, ['List()', 'items:any[]']);
_this.total = ZeroOrPositiveInteger(total, ['List()', 'total:int>=0']);
_this.hasNext = _this.$links.filter(function (link) { return link.rel === 'next'; }).length > 0;
_this.hasPrev = _this.$links.filter(function (link) { return link.rel === 'prev'; }).length > 0;
return _this;
constructor(items, total, $links = []) {
super(List.$context, List.$contextVersion, $links);
this.items = t.list(t.Any)(items, ['List()', 'items:any[]']);
this.total = ZeroOrPositiveInteger(total, ['List()', 'total:int>=0']);
this.hasNext = this.$links.filter(link => link.rel === 'next').length > 0;
this.hasPrev = this.$links.filter(link => link.rel === 'prev').length > 0;
}
List.fromJSON = function (_a, itemTransformer) {
var __context = _a.__context, __contextVersion = _a.__contextVersion, items = _a.items, total = _a.total, __links = _a.__links;
static fromJSON({ $context, $contextVersion, items, total, $links }, itemTransformer) {
LinkedEntity_1.LinkedEntity.checkContextVersion(List, {
$context: URLValue_1.URLValue.fromString(__context, ['List.fromJSON()', '$context:URLValue']),
$contextVersion: __contextVersion
$context: URLValue_1.URLValue.fromString($context, ['List.fromJSON()', '$context:URLValue']),
$contextVersion: $contextVersion
});
return new List(items.map(function (i) { return itemTransformer(i); }), total, __links ? __links.map(function (l) { return Link_1.Link.fromJSON(l); }) : undefined);
};
List.prototype.toJSON = function () {
var _a = this, items = _a.items, total = _a.total;
var s = _super.prototype.toJSON.call(this);
return __assign({}, s, { __links: s.__links || [] }, {
items: items.map(function (i) { return i.toJSON(); }),
total: total
return new List(items.map(i => itemTransformer(i)), total, $links ? $links.map(l => Link_1.Link.fromJSON(l)) : undefined);
}
toJSON() {
const { items, total } = this;
const s = super.toJSON();
return Object.assign({}, s, { $links: s.$links || [] }, {
items: items.map(i => i.toJSON()),
total
});
};
List.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#List');
List.$contextVersion = 1;
return List;
}(LinkedEntity_1.LinkedEntity));
}
}
List.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#List');
List.$contextVersion = 1;
exports.List = List;
//# sourceMappingURL=List.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var VersionedContext_1 = require("./VersionedContext");
var URLValue_1 = require("../value/URLValue");
const VersionedContext_1 = require("./VersionedContext");
const URLValue_1 = require("../value/URLValue");
/**
* Describes the status of the system.
*/
var Status = /** @class */ (function (_super) {
__extends(Status, _super);
class Status extends VersionedContext_1.VersionedContext {
/**
* @throws TypeError if invalid values are passed
*/
function Status(maintenance, version, time) {
if (time === void 0) { time = new Date(); }
var _this = _super.call(this, Status.$context, Status.$contextVersion) || this;
_this.maintenance = maintenance;
_this.version = version;
_this.time = time;
return _this;
constructor(maintenance, version, time = new Date()) {
super(Status.$context, Status.$contextVersion);
this.maintenance = maintenance;
this.version = version;
this.time = time;
}
Status.fromJSON = function (_a) {
var __context = _a.__context, __contextVersion = _a.__contextVersion, maintenance = _a.maintenance, version = _a.version, time = _a.time;
static fromJSON({ $context, $contextVersion, maintenance, version, time }) {
VersionedContext_1.VersionedContext.checkContextVersion(Status, {
$context: URLValue_1.URLValue.fromString(__context, ['Status.fromJSON()', '$context:URLValue']),
$contextVersion: __contextVersion
$context: URLValue_1.URLValue.fromString($context, ['Status.fromJSON()', '$context:URLValue']),
$contextVersion: $contextVersion
});
return new Status(maintenance, version, new Date(time));
};
Status.prototype.toJSON = function () {
var _a = this, maintenance = _a.maintenance, version = _a.version, time = _a.time;
return __assign({}, _super.prototype.toJSON.call(this), { maintenance: maintenance, version: version, time: time.toISOString() });
};
Status.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#Status');
Status.$contextVersion = 1;
return Status;
}(VersionedContext_1.VersionedContext));
}
toJSON() {
const { maintenance, version, time } = this;
return Object.assign({}, super.toJSON(), { maintenance, version, time: time.toISOString() });
}
}
Status.$context = new URLValue_1.URLValue('https://github.com/nRFCloud/models#Status');
Status.$contextVersion = 1;
exports.Status = Status;
//# sourceMappingURL=Status.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var URLValue_1 = require("../value/URLValue");
var t = require('tcomb');
var PositiveIntegerType = t.refinement(t.Integer, function (n) { return n >= 1; }, 'PositiveIntegerType');
const URLValue_1 = require("../value/URLValue");
const t = require('tcomb');
const PositiveIntegerType = t.refinement(t.Integer, (n) => n >= 1, 'PositiveIntegerType');
/**

@@ -11,3 +11,3 @@ * Describes JSON data

*/
var VersionedContext = /** @class */ (function () {
class VersionedContext {
/**

@@ -17,23 +17,21 @@ * @param {URLValue} $context context for this model

*/
function VersionedContext($context, $contextVersion) {
constructor($context, $contextVersion) {
this.$context = URLValue_1.URLValueType($context, ['VersionedContext()', '$context:URLValue']);
this.$contextVersion = PositiveIntegerType($contextVersion, ['VersionedContext()', '$contextVersion:int>=1']);
}
VersionedContext.prototype.toJSON = function () {
toJSON() {
return {
__context: this.$context.toString(),
__contextVersion: this.$contextVersion,
$context: this.$context.toString(),
$contextVersion: this.$contextVersion,
};
};
VersionedContext.checkContextVersion = function (expected, actual) {
}
static checkContextVersion(expected, actual) {
if (!expected.$context.equals(actual.$context)) {
throw new TypeError("Expected \"" + expected.$context + "\" but got \"" + actual.$context);
throw new TypeError(`Expected "${expected.$context}" but got "${actual.$context}`);
}
if (expected.$contextVersion !== actual.$contextVersion) {
throw new TypeError("Expected \"" + expected.$contextVersion + "\" but got \"" + actual.$contextVersion);
throw new TypeError(`Expected "${expected.$contextVersion}" but got "${actual.$contextVersion}`);
}
};
return VersionedContext;
}());
}
}
exports.VersionedContext = VersionedContext;
//# sourceMappingURL=VersionedContext.js.map
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var t = require('tcomb');
var uriRegex = /^https?:\/\/(((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9])|((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))(:(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0))?(\/[-a-zA-Z0-9@:%_+.,~?&/=()]*)*(#(?:[^#^[\]{}\\"<>%\s]|%[0-9a-f]{2})*)*$/i;
var URLValueString = t.refinement(t.String, function (s) { return uriRegex.test(s); }, 'URLValueString');
const t = require('tcomb');
const uriRegex = /^https?:\/\/(((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9])|((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))(:(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0))?(\/[-a-zA-Z0-9@:%_+.,~?&/=()]*)*(#(?:[^#^[\]{}\\"<>%\s]|%[0-9a-f]{2})*)*$/i;
const URLValueString = t.refinement(t.String, (s) => uriRegex.test(s), 'URLValueString');
/**
* A second level URI
*/
var URLValue = /** @class */ (function () {
class URLValue {
/**
* @throws TypeError if the provided URI fromString invalid
*/
function URLValue(url) {
constructor(url) {
if (url instanceof URLValue) {

@@ -26,13 +18,12 @@ url = url.toString();

if (!uriRegex.test(url)) {
throw new TypeError("URLValue: Not an URI: \"" + url + "!");
throw new TypeError(`URLValue: Not an URI: "${url}!`);
}
this.uri = url;
this.protocol = url.match(/^(https?:\/\/)/)[1];
this.hostname = url.match(/^https?:\/\/([^\/]+)/)[1];
this.query = /^[^#]+\?/.test(url) ? url.split('?', 2)[1].split('&').reduce(function (query, param) {
var _a = param.split('=', 2), k = _a[0], v = _a[1];
return __assign({}, query, (_b = {}, _b[decodeURIComponent(k)] = v ? decodeURIComponent(v) : '', _b));
var _b;
this.protocol = (url.match(/^(https?:\/\/)/) || [])[1];
this.hostname = (url.match(/^https?:\/\/([^\/]+)/) || [])[1];
this.query = /^[^#]+\?/.test(url) ? url.split('?', 2)[1].split('&').reduce((query, param) => {
const [k, v] = param.split('=', 2);
return Object.assign({}, query, { [decodeURIComponent(k)]: v ? decodeURIComponent(v) : '' });
}, {}) : {};
this.path = (url.replace(/^https?:\/\/([^\/]+)/, '') || '/').match(/^([^\?#]+)/)[1];
this.path = ((url.replace(/^https?:\/\/([^\/]+)/, '') || '/').match(/^([^\?#]+)/) || [])[1];
}

@@ -42,5 +33,5 @@ /**

*/
URLValue.prototype.toString = function () {
toString() {
return this.uri;
};
}
/**

@@ -50,5 +41,5 @@ * @param {URLValue} uri

*/
URLValue.prototype.equals = function (uri) {
equals(uri) {
return this.uri === uri.toString();
};
}
/**

@@ -58,5 +49,5 @@ * Returns a copy of the instance that has no trailing slash

*/
URLValue.prototype.slashless = function () {
slashless() {
return new URLValue(this.uri.replace(/\/+$/, ''));
};
}
/**

@@ -66,11 +57,9 @@ * Returns a copy of the instance with the given string appended

*/
URLValue.prototype.append = function (str) {
return new URLValue("" + this + str);
};
URLValue.fromString = function (str, path) { return new URLValue(URLValueString(str, path)); };
return URLValue;
}());
append(str) {
return new URLValue(`${this}${str}`);
}
}
URLValue.fromString = (str, path) => new URLValue(URLValueString(str, path));
exports.URLValue = URLValue;
exports.URLValueType = t.irreducible('URLValueType', function (x) { return x && x instanceof URLValue; });
exports.URLValueType = t.irreducible('URLValueType', (x) => x && x instanceof URLValue);
exports.MaybeURLValueType = t.maybe(exports.URLValueType);
//# sourceMappingURL=URLValue.js.map

@@ -1,1 +0,73 @@

{"name":"@nrfcloud/models","version":"1.5.0","description":"Contains model definitions for the REST API","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"test":"make test-prepare && jest","test:coverage":"make test-prepare && jest --coverage","lint":"tslint --project ./tsconfig.json","precommit":"npm run lint && npm test","commitmsg":"commitlint -e","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"repository":{"type":"git","url":"https://github.com/nRFCloud/models.git"},"keywords":["nRFCloud","IoT","NordicSemiconductor"],"author":"Nordic Semiconductor ASA | nordicsemi.no","license":"BSD-3-Clause","bugs":{"url":"https://github.com/nRFCloud/models/issues"},"homepage":"https://github.com/NordicSemiconductor/nrfcloud-models#readme","dependencies":{"tcomb":"^3.2.24"},"devDependencies":{"@commitlint/cli":"^4.2.2","@commitlint/config-angular":"^4.2.1","@types/jest":"^21.1.5","@types/node":"^8.0.47","husky":"^0.14.3","jest":"^21.2.1","json-schema-to-typescript":"^5.0.0","semantic-release":"^8.2.0","ts-jest":"^21.1.4","tslint":"^5.8.0","typescript":"^2.6.1"},"jest":{"moduleFileExtensions":["ts","tsx","js","json"],"transform":{"^.+\\.tsx?$":"<rootDir>/node_modules/ts-jest/preprocessor.js"},"testRegex":"(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$","coverageReporters":["html"],"mapCoverage":true},"files":["dist","scripts","README.md"],"publishConfig":{"access":"public"}}
{
"name": "@nrfcloud/models",
"version": "2.0.0",
"description": "Contains model definitions for the REST API",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"pretest": "make test-prepare",
"test": "jest",
"test:coverage": "npm run test -- --coverage",
"lint": "tslint --project ./tsconfig.json",
"precommit": "npm run lint && npm test",
"commitmsg": "commitlint -e",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
"url": "https://github.com/nRFCloud/models.git"
},
"keywords": [
"nRFCloud",
"IoT",
"NordicSemiconductor"
],
"author": "Nordic Semiconductor ASA | nordicsemi.no",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/nRFCloud/models/issues"
},
"homepage": "https://github.com/NordicSemiconductor/nrfcloud-models#readme",
"dependencies": {
"tcomb": "^3.2.24"
},
"devDependencies": {
"@commitlint/cli": "^6.0.1",
"@commitlint/config-angular": "^5.1.1",
"@nrfcloud/tslint-config": "^1.2.0",
"@types/jest": "^22.0.1",
"@types/node": "^9.3.0",
"husky": "^0.14.3",
"jest": "^22.0.5",
"json-schema-to-typescript": "^5.2.2",
"semantic-release": "^11.0.2",
"ts-jest": "^22.0.1",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
},
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
],
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"coverageReporters": [
"html"
],
"mapCoverage": true
},
"files": [
"dist",
"scripts",
"README.md"
],
"publishConfig": {
"access": "public",
"tag": "next"
}
}
# Models
[![npm](https://img.shields.io/npm/v/@nrfcloud/models.svg)](https://www.npmjs.com/package/@nrfcloud/models)
[![npm latest version](https://img.shields.io/npm/v/@nrfcloud/models/latest.svg)](https://www.npmjs.com/package/@nrfcloud/models)
[![npm next version](https://img.shields.io/npm/v/@nrfcloud/models/next.svg)](https://www.npmjs.com/package/@nrfcloud/models)
[![Build Status](https://travis-ci.org/nRFCloud/models.svg?branch=master)](https://travis-ci.org/nRFCloud/models)

@@ -35,8 +36,8 @@ [![Greenkeeper badge](https://badges.greenkeeper.io/nRFCloud/models.svg)](https://greenkeeper.io/)

{
"__context": "https://github.com/nRFCloud/models#ApiIndex",
"__contextVersion": 1,
"$context": "https://github.com/nRFCloud/models#ApiIndex",
"$contextVersion": 1,
"links": [
{
"__context": "https://github.com/nRFCloud/models#Link",
"__contextVersion": 1,
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://foo.iot.us-east-1.amazonaws.com",

@@ -47,4 +48,4 @@ "subject": "https://aws.amazon.com/iot-platform/",

{
"__context": "https://github.com/nRFCloud/models#Link",
"__contextVersion": 1,
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://bar.execute-api.us-east-1.amazonaws.com/prod",

@@ -67,4 +68,4 @@ "subject": "https://nrfcloud.com/",

{
"__context": "https://github.com/nRFCloud/models#Link",
"__contextVersion": 1,
"$context": "https://github.com/nRFCloud/models#Link",
"$contextVersion": 1,
"href": "https://api.nrfcloud.com/stage/custom-cards/foo/some-id",

@@ -85,4 +86,4 @@ "subject": "https://github.com/nRFCloud/models#CustomCard",

{
"__context": "https://github.com/nRFCloud/models#Status",
"__contextVersion": 1,
"$context": "https://github.com/nRFCloud/models#Status",
"$contextVersion": 1,
"maintenance": false,

@@ -103,8 +104,8 @@ "version": "1.0.0-beta.1",

{
"__context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#List",
"__contextVersion": 1,
"$context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#List",
"$contextVersion": 1,
items: [
{
"__context": "...",
"__contextVersion": ...,
"$context": "...",
"$contextVersion": ...,
...

@@ -116,4 +117,4 @@ }

{
"__context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#Link",
"__contextVersion": 1,
"$context": "https://github.com/NordicPlayground/nrfcloud-custom-cards-client#Link",
"$contextVersion": 1,
"href": "...",

@@ -138,4 +139,4 @@ "subject": "...",

{
"__context" : "https://www.ietf.org/id/draft-ietf-appsawg-http-problem-01.txt",
"__contextVersion" : 1,
"$context" : "https://www.ietf.org/id/draft-ietf-appsawg-http-problem-01.txt",
"$contextVersion" : 1,
"type" : "https://github.com/nRFCloud/models#EntityNotFoundError",

@@ -142,0 +143,0 @@ "title" : "Entity not found",

@@ -10,6 +10,6 @@ /**

const srcDir = process.argv[process.argv.length - 2];
const generatedDir = process.argv[process.argv.length - 1];
const targetDir = process.argv[process.argv.length - 1];
fs.readdir(srcDir, (err, files) => {
files.filter(f => /\.schema\.json$/.test(f)).forEach(file => {
files.filter(f => /[^.]+\.json$/.test(f)).forEach(file => {
fs.readFile(path.join(srcDir, file), 'utf-8', (err, data) => {

@@ -20,3 +20,3 @@ const d = JSON.parse(data);

.then(ts => {
fs.writeFile(path.join(generatedDir, `${title}.d.ts`), ts, (err) => {
fs.writeFile(path.join(targetDir, `${title}.d.ts`), ts, (err) => {
if (err) {

@@ -23,0 +23,0 @@ console.error(err);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc