UNPKG

mnubo-sdk

Version:
229 lines 9.97 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var decorators_1 = require("../decorators"); var basePath = '/api/v3/model'; var EntityOpsImpl = /** @class */ (function () { function EntityOpsImpl(client, path) { this.client = client; this.path = path; } EntityOpsImpl.prototype.create = function (value) { var valueArray = Array.isArray(value) ? value : [value]; return this.client.post("" + basePath + this.path, valueArray); }; EntityOpsImpl.prototype.update = function (key, update) { return this.client.put("" + basePath + this.path + "/" + key, update); }; EntityOpsImpl.prototype.generateDeployCode = function (key) { return this.client .post("" + basePath + this.path + "/" + key + "/deploy", null) .then(function (response) { return response.code; }); }; EntityOpsImpl.prototype.applyDeployCode = function (key, code) { return this.client.post("" + basePath + this.path + "/" + key + "/deploy/" + code, null); }; EntityOpsImpl.prototype.deploy = function (key) { var _this = this; return this.generateDeployCode(key).then(function (code) { return _this.applyDeployCode(key, code); }); }; __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise) ], EntityOpsImpl.prototype, "create", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise) ], EntityOpsImpl.prototype, "update", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], EntityOpsImpl.prototype, "generateDeployCode", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise) ], EntityOpsImpl.prototype, "applyDeployCode", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], EntityOpsImpl.prototype, "deploy", null); return EntityOpsImpl; }()); var TypeOpsImpl = /** @class */ (function () { function TypeOpsImpl(client, path, entityPath) { this.client = client; this.path = path; this.entityPath = entityPath; } TypeOpsImpl.prototype.create = function (value) { var valueArray = Array.isArray(value) ? value : [value]; return this.client.post("" + basePath + this.path, valueArray); }; TypeOpsImpl.prototype.update = function (key, update) { return this.client.put("" + basePath + this.path + "/" + key, update); }; TypeOpsImpl.prototype.delete = function (key) { return this.client.delete("" + basePath + this.path + "/" + key); }; TypeOpsImpl.prototype.addRelation = function (key, entityKey) { return this.client.post("" + basePath + this.path + "/" + key + this.entityPath + "/" + entityKey, null); }; TypeOpsImpl.prototype.removeRelation = function (key, entityKey) { return this.client.delete("" + basePath + this.path + "/" + key + this.entityPath + "/" + entityKey); }; __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", Promise) ], TypeOpsImpl.prototype, "create", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise) ], TypeOpsImpl.prototype, "update", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], TypeOpsImpl.prototype, "delete", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise) ], TypeOpsImpl.prototype, "addRelation", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise) ], TypeOpsImpl.prototype, "removeRelation", null); return TypeOpsImpl; }()); var ResetOpsImpl = /** @class */ (function () { function ResetOpsImpl(client) { this.client = client; } ResetOpsImpl.prototype.generateResetCode = function () { return this.client.post(basePath + "/reset", null).then(function (response) { return response.code; }); }; ResetOpsImpl.prototype.applyResetCode = function (code) { return this.client.post(basePath + "/reset/" + code, null); }; ResetOpsImpl.prototype.reset = function () { var _this = this; return this.generateResetCode().then(function (code) { return _this.applyResetCode(code); }); }; __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], ResetOpsImpl.prototype, "generateResetCode", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], ResetOpsImpl.prototype, "applyResetCode", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], ResetOpsImpl.prototype, "reset", null); return ResetOpsImpl; }()); var Model = /** @class */ (function () { function Model(client) { this.client = client; var timeseriesPath = '/timeseries'; var objectAttributesPath = '/objectAttributes'; this.sandboxOps = { timeseriesOps: new EntityOpsImpl(client, timeseriesPath), ownerAttributesOps: new EntityOpsImpl(client, '/ownerAttributes'), objectAttributesOps: new EntityOpsImpl(client, objectAttributesPath), objectTypesOps: new TypeOpsImpl(client, '/objectTypes', objectAttributesPath), eventTypesOps: new TypeOpsImpl(client, '/eventTypes', timeseriesPath), resetOps: new ResetOpsImpl(client), }; } Model.prototype.export = function () { return this.client.get(basePath + '/export'); }; Model.prototype.getTimeseries = function () { return this.client.get(basePath + '/timeseries'); }; Model.prototype.getOwnerAttributes = function () { return this.client.get(basePath + '/ownerAttributes'); }; Model.prototype.getObjectAttributes = function () { return this.client.get(basePath + '/objectAttributes'); }; Model.prototype.getObjectTypes = function () { return this.client.get(basePath + '/objectTypes'); }; Model.prototype.getEventTypes = function () { return this.client.get(basePath + '/eventTypes'); }; __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "export", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "getTimeseries", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "getOwnerAttributes", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "getObjectAttributes", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "getObjectTypes", null); __decorate([ decorators_1.authenticate, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], Model.prototype, "getEventTypes", null); return Model; }()); exports.Model = Model; //# sourceMappingURL=model.js.map