{"id":17115740,"url":"https://github.com/pathikrit/node-visionect","last_synced_at":"2025-03-24T00:49:32.214Z","repository":{"id":103335346,"uuid":"609204045","full_name":"pathikrit/node-visionect","owner":"pathikrit","description":"Thin nodejs client around the Visionect Server Management API","archived":false,"fork":false,"pushed_at":"2023-03-20T05:13:27.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-03T03:34:33.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pathikrit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-03T15:40:24.000Z","updated_at":"2023-03-03T17:19:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a60cc14-b00f-46af-ba95-2689c367b0d9","html_url":"https://github.com/pathikrit/node-visionect","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"c3330d17739e414b289b24faa5828d4818a5783a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fnode-visionect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fnode-visionect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fnode-visionect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fnode-visionect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pathikrit","download_url":"https://codeload.github.com/pathikrit/node-visionect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245191612,"owners_count":20575248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T17:46:20.737Z","updated_at":"2025-03-24T00:49:32.181Z","avatar_url":"https://github.com/pathikrit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-visionect [![CI](https://github.com/pathikrit/node-visionect/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/pathikrit/node-visionect/actions/workflows/ci.yml)\n\nA thin node.js [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) based wrapper around the [Visionect Server Management API](http://api.visionect.com/)\n\n## Installation [![NPM Package Version](https://img.shields.io/npm/v/node-visionect.svg?)](https://www.npmjs.com/package/node-visionect)\n```sh\nnpm add node-visionect\n```\n## Example\n```js\nconst VisionectApiClient = require('node-joan')\n\nconst vss = new VisionectApiClient({\n  apiServer: 'https://localhost:8081',\n  apiKey: '\u003capiKey\u003e',\n  apiSecret: '\u003capiSecret\u003e'\n})\n\nvss.devices.get()\n  .then(res =\u003e console.log(res.status, res.headers, res.data))\n  .catch(err =\u003e console.error(err))\n\n// Update URL\nvss.sessions.patch(uuid, {Backend: {Fields: {url: 'https://example.com'}}})\n```\nThis library is used in production by the [Newswall project](https://github.com/pathikrit/newswall) - feel free to refer to it for further usage examples.\n\n## APIs\n\n### Devices APIs\n```js\nvss.devices.get() // get all devices\nvss.devices.get(uuid) // get a particular device\nvss.devices.get(uuid, from, to = now, group = false) // Get an array of historical statuses; See http://api.vss.com/#device-status-device-status\n\nvss.devices.update(uuid, data) // update a particular device\nvss.devices.update(data) // update all devices\nvss.devices.patch(uuid, data) // Partial update a device\n\nvss.devices.delete(uuid) // delete a devices\n\nvss.devices.reboot(uuid1, uuid2, /*...*/) // reboot devices\n```\n### Device Config APIs\n```js\nvss.devices.config.get(uuid) // Get all config for device\nvss.devices.config.get(uuid, [typeId1, typeId2]/*, ...*/) // Get particular configs e.g. vss.devices.config.get(uuid, [65, 67]) to get WiFi info\n\nvss.devices.config.set(uuid, {Type: id1, value: v1}, {Type: id1, value: v2}, /*...*/) // Set configs\n\n// Full list of type ids: https://docs.visionect.com/AppDevelopment/generalJsExtensions.html#tclv-list\n// e.g. to disable system screens (the ones that show when charging or no WiFi)\nvss.devices.config.set(uuid, {Type: 49, Value: '0'})\n```\n\n### Live View APIs\n```js\nvss.view.device(uuid) // return current image that is displayed on the device\nvss.view.server(uuid) // return the server side image for the device\nvss.view.set(uuid, img) // Set the image on device; see http://api.vss.com/#backends\n\n//Example: Save the live view image locally\nconst fs = require('fs')\nconst fileType = '.png'\nvss.view.device(uuid, fileType).then(res =\u003e fs.writeFileSync(uuid + fileType, res.data))\n```\n\n### Session APIs\n```js\nvss.sessions.get() // get all sessions\nvss.sessions.get(uuid) // get a particular session\n\nvss.sessions.update(uuid, data) // update a particular session\nvss.sessions.update(data) // update all sessions\nvss.sessions.patch(uuid, data) // Partial update a session\n\nvss.sessions.create(data) // create a session\n\nvss.sessions.restart(uuid1, uuid2, /*...*/) // restart sessions\nvss.sessions.clearCache(uuid1, uuid2, /*...*/) // clear session caches\n```\n\n### User APIs\n```js\nvss.users.get() // get all users\nvss.users.get(username) // get a particular user\n\nvss.users.update(username, data) // update a particular user\nvss.users.update(data) // update all users\nvss.users.patch(uuid, data) // Partial update a user\n\nvss.users.create(data) // create a user\n```\n\n### Server APIs\n```js\nvss.server.status() // Get server status\nvss.server.config() // Get server config\nvss.server.config(data) // Set server config\nvss.server.config(data, patch = true) // Partial update server config\nvss.server.orphans(all = true) // See http://api.vss.com/#health\n```\n\n### Primitive APIs\nDirectly call any HTTP endpoints using the following low level utils:\n```js\nvss.http.get(path)\nvss.http.post(path, data)\nvss.http.put(path, data)\nvss.http.patch(path, data)\nvss.http.delete(path, data)\nvss.http.options(path)\n```\n\n### Plugins\nYou can access the underlying [axios](https://axios-http.com/) HTTP caller via `vss.http`.\nThis makes it possible to use any [axios plugins](https://www.npmjs.com/search?ranking=popularity\u0026q=axios) e.g.\n```js\n// This will print all API calls as curl commands to console\nconst curlirize = require('axios-curlirize')\ncurlirize(vss.http)\n```\n\n### Intercept Requests / Responses\nUse [axios interceptors](https://axios-http.com/docs/interceptors) to intercept requests/response:\n```js\n// Intercept requests e.g. to block certain calls\nvss.http.interceptors.request.use(req =\u003e {\n  return (process.env.NODE_ENV === 'test' \u0026\u0026 req.method.toUpperCase() !== 'GET') ?\n    Promise.reject(`Cannot make ${req.method} API calls from tests`) : req\n})\n\n// Intercept responses e.g. to log the response / request\nvss.http.interceptors.response.use(\n  res =\u003e {\n    console.log(res.request.method, res.request.path, res.status, res.headers)\n    return res\n  },\n  err =\u003e {\n    console.error('Received non-2xx response', err)\n    return Promise.reject(err)\n  }\n)\n\n// 3rd party logger: https://github.com/hg-pyun/axios-logger\nvss.http.interceptors.request.use(AxiosLogger.requestLogger)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Fnode-visionect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpathikrit%2Fnode-visionect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Fnode-visionect/lists"}