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

cloudvision-connector

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudvision-connector - npm Package Compare versions

Comparing version 4.5.5 to 4.6.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [4.6.0](https://github.com/aristanetworks/cloudvision/compare/v4.5.5...v4.6.0) (2020-10-05)
### Features
* **cloudvision-connector:** add support for config dataset type ([#207](https://github.com/aristanetworks/cloudvision/issues/207)) ([5e9d570](https://github.com/aristanetworks/cloudvision/commit/5e9d57093c6f05b16fa7861470602dfd3ea73fee))
## [4.5.5](https://github.com/aristanetworks/cloudvision/compare/v4.5.4...v4.5.5) (2020-09-16)

@@ -8,0 +19,0 @@

34

dist/cloudvision-connector.js

@@ -399,3 +399,9 @@ (function (global, factory) {

const APP_DATASET_TYPE = 'app';
const CONFIG_DATASET_TYPE = 'config';
const DEVICE_DATASET_TYPE = 'device';
const ALL_DATASET_TYPES = [
APP_DATASET_TYPE,
CONFIG_DATASET_TYPE,
DEVICE_DATASET_TYPE,
];
const SEARCH_TYPE_ANY = 'ANY';

@@ -1219,8 +1225,14 @@ const SEARCH_TYPE_IP = 'IP';

/**
* Returns a list of datasets. This will return data sets of type 'device',
* as well as type 'app'.
* Returns a list of configs (datasets with type == 'config').
*/
getConfigs(callback) {
const configType = [CONFIG_DATASET_TYPE];
const params = { types: configType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}
/**
* Returns a list of datasets (datasets with type 'app', 'config' or 'device').
*/
getDatasets(callback) {
const allDatasetTypes = [APP_DATASET_TYPE, DEVICE_DATASET_TYPE];
const params = { types: allDatasetTypes };
const params = { types: ALL_DATASET_TYPES };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));

@@ -1233,3 +1245,4 @@ }

const deviceType = [DEVICE_DATASET_TYPE];
return this.get(GET_DATASETS, { types: deviceType }, makeNotifCallback(callback));
const params = { types: deviceType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}

@@ -1451,3 +1464,6 @@ /**

exports.ACTIVE_CODE = ACTIVE_CODE;
exports.ALL_DATASET_TYPES = ALL_DATASET_TYPES;
exports.APP_DATASET_TYPE = APP_DATASET_TYPE;
exports.CLOSE = CLOSE;
exports.CONFIG_DATASET_TYPE = CONFIG_DATASET_TYPE;
exports.CONNECTED = CONNECTED;

@@ -1458,4 +1474,12 @@ exports.DEVICE_DATASET_TYPE = DEVICE_DATASET_TYPE;

exports.EOF_CODE = EOF_CODE;
exports.GET = GET;
exports.GET_AND_SUBSCRIBE = GET_AND_SUBSCRIBE;
exports.GET_DATASETS = GET_DATASETS;
exports.GET_REQUEST_COMPLETED = GET_REQUEST_COMPLETED;
exports.PUBLISH = PUBLISH;
exports.Parser = Parser;
exports.SEARCH = SEARCH;
exports.SEARCH_SUBSCRIBE = SEARCH_SUBSCRIBE;
exports.SERVICE_REQUEST = SERVICE_REQUEST;
exports.SUBSCRIBE = SUBSCRIBE;
exports.default = Connector;

@@ -1462,0 +1486,0 @@ exports.fromBinaryKey = fromBinaryKey;

2

dist/cloudvision-connector.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("a-msgpack"),require("uuid"),require("base64-js")):"function"==typeof define&&define.amd?define(["exports","a-msgpack","uuid","base64-js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CloudvisionConnector={},e.msgpack,e.uuid,e["base64-js"])}(this,(function(e,t,n,s){"use strict";const r=e=>t.encode(e,{extensionCodec:t.Codec}),o=e=>t.decode(e,{extensionCodec:t.Codec,useJSBI:!0});function i(e){const t=[];for(let n=0;n<e.length;n+=1)t.push(s.fromByteArray(r(e[n])));return t}function a(e){const t={path_elements:[],timestamp:0};t.path_elements=function(e){const t=[];for(let n=0;n<e.length;n+=1)t.push(o(s.toByteArray(e[n])));return t}(e.path_elements||[]);let n="";return e.timestamp.nanos&&(n+=e.timestamp.nanos),n=n.padStart(9,"0"),t.timestamp=parseInt((""+e.timestamp.seconds+n).slice(0,13),10),e.updates&&(t.updates=function(e){const t={};for(let n=0;n<e.length;n+=1){const r=e[n].key,i=e[n].value,a=o(s.toByteArray(r)),c=o(s.toByteArray(i));t[r]={key:a,value:c}}return t}(e.updates)),e.deletes&&(t.deletes=function(e){const t={};for(let n=0;n<e.length;n+=1){const r=e[n];t[r]={key:o(s.toByteArray(r))}}return t}(e.deletes)),e.delete_all&&(t.deletes={}),t}function c(e,t){const n=a(t);e.notifications[JSON.stringify(n.path_elements)]?e.notifications[JSON.stringify(n.path_elements)].push(n):e.notifications[JSON.stringify(n.path_elements)]=[n]}function u(e,t){if(e.timestamp.seconds<t.timestamp.seconds)return-1;if(e.timestamp.seconds>t.timestamp.seconds)return 1;if(e.timestamp.nanos&&t.timestamp.nanos){if(e.timestamp.nanos<t.timestamp.nanos)return-1;if(e.timestamp.nanos>t.timestamp.nanos)return 1}return e.timestamp.nanos?t.timestamp.nanos?0:1:-1}function l(e){const t={timestamp:e.timestamp};return e.path_elements&&e.path_elements.length&&(t.path_elements=i(e.path_elements)),e.updates&&(t.updates=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o=e[n].key,i=e[n].value;t.push({key:s.fromByteArray(r(o)),value:s.fromByteArray(r(i))})}return t}(e.updates)),e.deletes&&(Object.keys(e.deletes).length?t.deletes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o=e[n];t.push(s.fromByteArray(r(o)))}return t}(e.deletes):t.delete_all=!0),t}class d{static parse(e,t){const n=JSON.parse(e),s=n.result;if(s&&!s.datasets&&s.notifications){const e=function(e,t){if(e.notifications.sort(u),t){const t={dataset:e.dataset,metadata:e.metadata||{},notifications:{}};for(let n=0;n<e.notifications.length;n+=1)c(t,e.notifications[n]);return t}const n={dataset:e.dataset,metadata:e.metadata||{},notifications:[]};for(let t=0;t<e.notifications.length;t+=1){const s=a(e.notifications[t]);n.notifications.push(s)}return n}(s,t);return{error:n.error,result:e,status:n.status,token:n.token}}return{error:n.error,result:n.result,status:n.status,token:n.token}}static stringify(e){const t=Object.assign({},e.params);return d.isQuery(t)&&(t.query=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o={dataset:e[n].dataset,paths:[]},a=e[n];for(let e=0;e<a.paths.length;e+=1){const t=a.paths[e],n={path_elements:[]},c=[];if(t.keys&&Array.isArray(t.keys)){for(let e=0;e<t.keys.length;e+=1)c.push(s.fromByteArray(r(t.keys[e])));n.keys=c}n.path_elements=i(t.path_elements),o.paths.push(n)}t.push(o)}return t}(t.query)),d.isPublish(t)&&(t.batch=function(e){const t=[],n={dataset:e.dataset,notifications:t};if(Array.isArray(e.notifications))for(let n=0;n<e.notifications.length;n+=1)t.push(l(e.notifications[n]));else{const n=Object.keys(e.notifications);for(let s=0;s<n.length;s+=1){const r=n[s];for(let n=0;n<e.notifications[r].length;n+=1)t.push(l(e.notifications[r][n]))}}return n}(t.batch)),JSON.stringify({token:e.token,command:e.command,params:t})}static isQuery(e){const t=e;return void 0!==t.query&&Array.isArray(t.query)}static isPublish(e){const t=e;return void 0!==t.sync&&void 0!==t.batch}}const h="ERROR",m=1001,f="GetRequest",p="close",y="DEVICES_DATASET_ID",g="getDatasets",b="getAndSubscribe",v="publish",E="subscribe",C="alpha/search",S="alpha/searchSubscribe",O="serviceRequest",k="app",A="device",T=new Set(["ANY","IP","MAC"]),N="connected",_="disconnected",P="cloudvision-connector",D={command:"NO_COMMAND",token:"NO_TOKEN",encodedParams:"NO_PARAMS"};class q{constructor(){this.events=new Map,this.requestContext=new Map}getEventsMap(){return this.events}getRequestContextMap(){return this.requestContext}has(e){return this.events.has(e)}bind(e,t,n){let s=this.events.get(e);return s?s.push(n):(s=[n],this.events.set(e,s),this.requestContext.set(e,t)),s.length}unbind(e,t){const n=this.events.get(e);if(!n)return null;const s=n.indexOf(t);-1!==s&&(n.splice(s,1),this.events.set(e,n));const r=n.length;return 0===r&&(this.events.delete(e),this.requestContext.delete(e)),r}unbindAll(e){this.events.delete(e),this.requestContext.delete(e)}emit(e,...t){const n=this.events.get(e);if(n)for(let s=n.length-1;s>=0;s-=1){const r=this.requestContext.get(e)||D;n[s](r,...t)}}close(){this.events.clear(),this.requestContext.clear()}}function I(){}class R{constructor(e){this.enableInstrumentation=!1,e&&(this.enableInstrumentation=!0),this.instrumentedCommands=e?e.commands:[],this.startFunction=e?e.start:I,this.infoFunction=e?e.info:I,this.endFunction=e?e.end:I}callStart(e,t){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.startFunction(t)}callInfo(e,t,n){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.infoFunction(t,n)}callEnd(e,t){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.endFunction(t)}}function B(e,t,n,s){const r=t?`${e}: ${t}`:e+": No message provided",o=n?`Status Code: ${n.code}, Status Message: ${n.message}`:void 0,i=s?"Request Token: "+s:void 0;switch(console.groupCollapsed("[[ CloudVision Connector ]]"),e){case h:i&&console.error(i),console.error(r),o&&console.error(o);break;case"WARN":i&&console.warn(i),console.warn(r),o&&console.warn(o);break;default:i&&console.log(i),console.log(r),o&&console.log(o)}console.groupEnd()}function w(e){return"number"==typeof e&&e>0}function M(e){return e/1e15>1}function j(e){const{start:t,end:n,versions:s}=e;let r,o,i;return w(t)&&(r=Math.floor(t)*(M(t)?1:1e6)),w(n)&&(o=Math.floor(n)*(M(n)?1:1e6)),w(s)&&(i=Math.floor(s)),{start:r,end:o,versions:i}}function x(e,t){const{start:n,end:s,versions:r}=e;return n&&s&&n>=s?(t(function(e,t,n){return`invalid params: start: ${e}, end: ${t}, versions: ${n||"undefined"}`}(n,s,r)),!1):!n||!r||(t("Defining start and versions is invalid"),!1)}function W(e,t,n=!1){return Array.isArray(e)?!!(n||e&&e.length)||(t("`query` param cannot be empty"),!1):(t("`query` param must be an array"),!1)}function F(e,t={}){return(n,s,r,o,i)=>{if(r&&r.code===m)return void e(null,void 0,r,o,i);if(n)return e(`Error: ${n}\nOptions: ${JSON.stringify(t)}`,void 0,r,o,i),void e(null,void 0,{code:m},o,i);const a=s;if(a&&a.datasets)return void e(null,a,r,o,i);const c=s;(c&&c.dataset||c)&&e(null,c,r,o,i)}}function U(e,t){const n={};if(Array.isArray(e)){const s=e.length;for(let r=0;r<s;r+=1){const{token:s,callback:o}=e[r];0===t.unbind(s,o)&&(n[s]=!0)}}else{const{token:s,callback:r}=e;0===t.unbind(s,r)&&(n[s]=!0)}return Object.keys(n).length?n:null}function J(e){const t=e.searchType;let n="ANY";return t&&T.has(t)&&(n=t),{search:e.search||"",searchType:n}}function $(e){return s.fromByteArray(t.encode(e,{extensionCodec:t.Codec}))}class G{constructor(e={batchResults:!0,debugMode:!1},t=WebSocket,n=d){this.connectorOptions=e,this.isRunning=!1,this.connectionEvents=new q,this.events=new q,this.WebSocket=t,this.Parser=n,this.instrumentation=new R(e.instrumentationConfig)}get websocket(){return this.ws}get connectionEmitter(){return this.connectionEvents}get eventsEmitter(){return this.events}callCommand(e,t,s){if(!this.isRunning)return s("Connection is down"),null;const r=n.v4(),o={command:e,encodedParams:$(t),token:r},i=this.makeCallbackWithUnbind(r,s);return this.events.bind(r,o,i),this.sendMessageOrError(r,e,t,o),r}cleanUpConnections(){this.events.close()}close(){this.closeWs(new CloseEvent("close")),this.connectionEvents.close(),this.ws.close()}closeWs(e){this.isRunning=!1,this.cleanUpConnections(),this.connectionEvents.emit("connection",G.DISCONNECTED,e)}closeCommand(e,t,s){const r=n.v4(),o={command:p,encodedParams:$(e),token:r},i=this.makeCallbackWithUnbind(r,s);this.events.bind(r,o,i);try{this.sendMessage(r,p,o,t)}catch(e){B(h,e),s(e,void 0,void 0,r)}return r}closeStreams(e,t){const n=U(e,this.events);return n?this.closeCommand(e,n,t):null}closeStream(e,t){const n=U(e,this.events);return n?this.closeCommand(e,n,t):null}connection(e){const t=(t,n,s)=>{e(n,s)};return this.connectionEvents.bind("connection",{command:"connection",encodedParams:"",token:""},t),()=>{this.connectionEvents.unbind("connection",t)}}get(e,t,n){return this.callCommand(e,t,n)}makeCallbackWithUnbind(e,t){const n=(s,r,o,i)=>{r&&(this.events.unbind(e,n),this.instrumentation.callInfo(s.command,s,{error:r})),this.instrumentation.callEnd(s.command,s),t(r,o,i,e,s)};return n}publish(e,t){return this.callCommand(v,e,t)}requestService(e,t){return this.callCommand(O,e,t)}run(e){this.runWithWs(new this.WebSocket(e))}runWithWs(e){this.ws=e,this.ws.onopen=e=>{this.isRunning||(this.isRunning=!0,this.connectionEvents.emit("connection",G.CONNECTED,e))},this.ws.onclose=e=>{this.closeWs(e)},this.ws.onmessage=e=>{var t;if("string"!=typeof e.data)return;let n;try{n=this.Parser.parse(e.data,this.connectorOptions.batchResults),this.connectorOptions.debugMode&&self.postMessage({response:n,source:P,timestamp:Date.now()},"*")}catch(e){return void B(h,e)}if(!n||!n.token)return void B(h,"No message body or message token");const{error:s,status:r,token:o}=n;s?this.events.emit(o,s,n.result,r):(!function(e,t,n,s){if(t&&Object.keys(t).length)return;const r=e;!r.dataset||r.dataset.name?!r.dataset||r.dataset.type?!r.dataset||r.notifications?s||!r.dataset||Array.isArray(r.notifications)||B(h,"Key 'notifications' is not an array",void 0,n):B(h,"No key 'notifications' found in response",void 0,n):B(h,"No key 'type' found in dataset",void 0,n):B(h,"No key 'name' found in dataset",void 0,n)}(n.result,r,o,this.connectorOptions.batchResults),this.events.emit(o,null,n.result,r),(null===(t=n.result)||void 0===t?void 0:t.metadata)&&"EOF"===n.result.metadata.GetRequest&&this.events.emit(o,null,null,{message:f,code:m}))}}search(e,t){return this.callCommand(C,e,t)}sendMessage(e,t,n,s){this.connectorOptions.debugMode&&self.postMessage({request:{token:e,command:t,params:s},source:P,timestamp:Date.now()},"*"),this.instrumentation.callStart(t,n),this.ws.send(this.Parser.stringify({token:e,command:t,params:s}))}sendMessageOrError(e,t,n,s){try{this.sendMessage(e,t,s,n)}catch(t){B(h,t),this.events.emit(e,t,void 0,void 0)}}stream(e,t,s){if(!this.isRunning)return s("Connection is down"),null;const r=n.v4(),o={command:e,encodedParams:$(t),token:r},i=(e,t,n,a)=>{t&&(this.events.unbind(r,i),this.instrumentation.callInfo(o.command,o,{error:t}),this.instrumentation.callEnd(e.command,e)),a&&3001===a.code&&this.instrumentation.callInfo(o.command,o,{message:"stream active"}),s(t,n,a,r,e)};return this.events.bind(r,o,i),this.sendMessageOrError(r,e,t,o),{token:r,callback:i}}}G.CONNECTED=N,G.DISCONNECTED=_;class V extends G{closeSubscriptions(e,t){return this.closeStreams(e,F(t))}getAndSubscribe(e,t,n){if(!W(e,t))return null;if(!x(n,t))return null;const s=j(n),r={query:e,start:s.start,end:s.end,versions:s.versions};return this.stream(b,r,F(t))}getApps(e){const t={types:[k]};return this.get(g,t,F(e))}getDatasets(e){const t={types:[k,A]};return this.get(g,t,F(e))}getDevices(e){const t=[A];return this.get(g,{types:t},F(e))}getWithOptions(e,t,n){if(e===y)return this.getDatasets(t),null;if(!W(e,t))return null;if(!x(n,t))return null;const{start:s,end:r,versions:o}=j(n),i={query:e,start:s,end:r,versions:o};return this.get("get",i,F(t,n))}runService(e,t){this.requestService(e,F(t))}runStreamingService(e,t){return e?this.stream(O,e,F(t)):(t("`request` param cannot be empty"),null)}searchWithOptions(e,t,n){if(!W(e,t,!0))return null;if(!x(n,t))return null;const{start:s,end:r}=j(n),o=J(n),i={query:e,start:s,end:r,search:o.search,searchType:o.searchType};return this.search(i,F(t,n))}searchSubscribe(e,t,n={search:""}){if(!W(e,t,!0))return null;const s=J(n);return this.stream(S,{query:e,search:s.search,searchType:s.searchType},F(t))}subscribe(e,t){return W(e,t)?this.stream(E,{query:e},F(t)):null}writeSync(e,t){this.publish({sync:!0,batch:{dataset:e.dataset,notifications:e.notifications}},function(e){return(t,n,s)=>{s&&s.code===m?e(!0):t&&e(!1,`Error: ${t}\n`)}}(t))}}V.CLOSE=p,V.DEVICES_DATASET_ID=y,V.GET_DATASETS=g,V.GET="get",V.GET_AND_SUBSCRIBE=b,V.ID=P,V.PUBLISH=v,V.SEARCH_SUBSCRIBE=S,V.SEARCH=C,V.SERVICE_REQUEST=O,V.SUBSCRIBE=E,Object.defineProperty(e,"Bool",{enumerable:!0,get:function(){return t.Bool}}),Object.defineProperty(e,"Float32",{enumerable:!0,get:function(){return t.Float32}}),Object.defineProperty(e,"Float64",{enumerable:!0,get:function(){return t.Float64}}),Object.defineProperty(e,"Int",{enumerable:!0,get:function(){return t.Int}}),Object.defineProperty(e,"NeatTypeSerializer",{enumerable:!0,get:function(){return t.NeatTypeSerializer}}),Object.defineProperty(e,"NeatTypes",{enumerable:!0,get:function(){return t.NeatTypes}}),Object.defineProperty(e,"Nil",{enumerable:!0,get:function(){return t.Nil}}),Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}}),Object.defineProperty(e,"Str",{enumerable:!0,get:function(){return t.Str}}),Object.defineProperty(e,"createBaseType",{enumerable:!0,get:function(){return t.createBaseType}}),Object.defineProperty(e,"isJsbi",{enumerable:!0,get:function(){return t.isJsbi}}),Object.defineProperty(e,"isNeatType",{enumerable:!0,get:function(){return t.isNeatType}}),e.ACTIVE_CODE=3001,e.APP_DATASET_TYPE=k,e.CONNECTED=N,e.DEVICE_DATASET_TYPE=A,e.DISCONNECTED=_,e.EOF="EOF",e.EOF_CODE=m,e.GET_REQUEST_COMPLETED=f,e.Parser=d,e.default=V,e.fromBinaryKey=function(e,n=!0){return t.decode(s.toByteArray(e),{extensionCodec:t.Codec,useJSBI:n})},e.sanitizeOptions=j,e.toBinaryKey=$,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("a-msgpack"),require("uuid"),require("base64-js")):"function"==typeof define&&define.amd?define(["exports","a-msgpack","uuid","base64-js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CloudvisionConnector={},e.msgpack,e.uuid,e["base64-js"])}(this,(function(e,t,n,s){"use strict";const r=e=>t.encode(e,{extensionCodec:t.Codec}),o=e=>t.decode(e,{extensionCodec:t.Codec,useJSBI:!0});function i(e){const t=[];for(let n=0;n<e.length;n+=1)t.push(s.fromByteArray(r(e[n])));return t}function a(e){const t={path_elements:[],timestamp:0};t.path_elements=function(e){const t=[];for(let n=0;n<e.length;n+=1)t.push(o(s.toByteArray(e[n])));return t}(e.path_elements||[]);let n="";return e.timestamp.nanos&&(n+=e.timestamp.nanos),n=n.padStart(9,"0"),t.timestamp=parseInt((""+e.timestamp.seconds+n).slice(0,13),10),e.updates&&(t.updates=function(e){const t={};for(let n=0;n<e.length;n+=1){const r=e[n].key,i=e[n].value,a=o(s.toByteArray(r)),c=o(s.toByteArray(i));t[r]={key:a,value:c}}return t}(e.updates)),e.deletes&&(t.deletes=function(e){const t={};for(let n=0;n<e.length;n+=1){const r=e[n];t[r]={key:o(s.toByteArray(r))}}return t}(e.deletes)),e.delete_all&&(t.deletes={}),t}function c(e,t){const n=a(t);e.notifications[JSON.stringify(n.path_elements)]?e.notifications[JSON.stringify(n.path_elements)].push(n):e.notifications[JSON.stringify(n.path_elements)]=[n]}function u(e,t){if(e.timestamp.seconds<t.timestamp.seconds)return-1;if(e.timestamp.seconds>t.timestamp.seconds)return 1;if(e.timestamp.nanos&&t.timestamp.nanos){if(e.timestamp.nanos<t.timestamp.nanos)return-1;if(e.timestamp.nanos>t.timestamp.nanos)return 1}return e.timestamp.nanos?t.timestamp.nanos?0:1:-1}function l(e){const t={timestamp:e.timestamp};return e.path_elements&&e.path_elements.length&&(t.path_elements=i(e.path_elements)),e.updates&&(t.updates=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o=e[n].key,i=e[n].value;t.push({key:s.fromByteArray(r(o)),value:s.fromByteArray(r(i))})}return t}(e.updates)),e.deletes&&(Object.keys(e.deletes).length?t.deletes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o=e[n];t.push(s.fromByteArray(r(o)))}return t}(e.deletes):t.delete_all=!0),t}class d{static parse(e,t){const n=JSON.parse(e),s=n.result;if(s&&!s.datasets&&s.notifications){const e=function(e,t){if(e.notifications.sort(u),t){const t={dataset:e.dataset,metadata:e.metadata||{},notifications:{}};for(let n=0;n<e.notifications.length;n+=1)c(t,e.notifications[n]);return t}const n={dataset:e.dataset,metadata:e.metadata||{},notifications:[]};for(let t=0;t<e.notifications.length;t+=1){const s=a(e.notifications[t]);n.notifications.push(s)}return n}(s,t);return{error:n.error,result:e,status:n.status,token:n.token}}return{error:n.error,result:n.result,status:n.status,token:n.token}}static stringify(e){const t=Object.assign({},e.params);return d.isQuery(t)&&(t.query=function(e){const t=[];for(let n=0;n<e.length;n+=1){const o={dataset:e[n].dataset,paths:[]},a=e[n];for(let e=0;e<a.paths.length;e+=1){const t=a.paths[e],n={path_elements:[]},c=[];if(t.keys&&Array.isArray(t.keys)){for(let e=0;e<t.keys.length;e+=1)c.push(s.fromByteArray(r(t.keys[e])));n.keys=c}n.path_elements=i(t.path_elements),o.paths.push(n)}t.push(o)}return t}(t.query)),d.isPublish(t)&&(t.batch=function(e){const t=[],n={dataset:e.dataset,notifications:t};if(Array.isArray(e.notifications))for(let n=0;n<e.notifications.length;n+=1)t.push(l(e.notifications[n]));else{const n=Object.keys(e.notifications);for(let s=0;s<n.length;s+=1){const r=n[s];for(let n=0;n<e.notifications[r].length;n+=1)t.push(l(e.notifications[r][n]))}}return n}(t.batch)),JSON.stringify({token:e.token,command:e.command,params:t})}static isQuery(e){const t=e;return void 0!==t.query&&Array.isArray(t.query)}static isPublish(e){const t=e;return void 0!==t.sync&&void 0!==t.batch}}const h="ERROR",m=1001,f="GetRequest",p="close",y="DEVICES_DATASET_ID",g="get",b="getDatasets",E="getAndSubscribe",v="publish",C="subscribe",S="alpha/search",A="alpha/searchSubscribe",O="serviceRequest",T="app",k="config",_="device",N=[T,k,_],P=new Set(["ANY","IP","MAC"]),D="connected",I="disconnected",R="cloudvision-connector",B={command:"NO_COMMAND",token:"NO_TOKEN",encodedParams:"NO_PARAMS"};class q{constructor(){this.events=new Map,this.requestContext=new Map}getEventsMap(){return this.events}getRequestContextMap(){return this.requestContext}has(e){return this.events.has(e)}bind(e,t,n){let s=this.events.get(e);return s?s.push(n):(s=[n],this.events.set(e,s),this.requestContext.set(e,t)),s.length}unbind(e,t){const n=this.events.get(e);if(!n)return null;const s=n.indexOf(t);-1!==s&&(n.splice(s,1),this.events.set(e,n));const r=n.length;return 0===r&&(this.events.delete(e),this.requestContext.delete(e)),r}unbindAll(e){this.events.delete(e),this.requestContext.delete(e)}emit(e,...t){const n=this.events.get(e);if(n)for(let s=n.length-1;s>=0;s-=1){const r=this.requestContext.get(e)||B;n[s](r,...t)}}close(){this.events.clear(),this.requestContext.clear()}}function w(){}class M{constructor(e){this.enableInstrumentation=!1,e&&(this.enableInstrumentation=!0),this.instrumentedCommands=e?e.commands:[],this.startFunction=e?e.start:w,this.infoFunction=e?e.info:w,this.endFunction=e?e.end:w}callStart(e,t){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.startFunction(t)}callInfo(e,t,n){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.infoFunction(t,n)}callEnd(e,t){this.enableInstrumentation&&this.instrumentedCommands.includes(e)&&this.endFunction(t)}}function j(e,t,n,s){const r=t?`${e}: ${t}`:e+": No message provided",o=n?`Status Code: ${n.code}, Status Message: ${n.message}`:void 0,i=s?"Request Token: "+s:void 0;switch(console.groupCollapsed("[[ CloudVision Connector ]]"),e){case h:i&&console.error(i),console.error(r),o&&console.error(o);break;case"WARN":i&&console.warn(i),console.warn(r),o&&console.warn(o);break;default:i&&console.log(i),console.log(r),o&&console.log(o)}console.groupEnd()}function x(e){return"number"==typeof e&&e>0}function U(e){return e/1e15>1}function W(e){const{start:t,end:n,versions:s}=e;let r,o,i;return x(t)&&(r=Math.floor(t)*(U(t)?1:1e6)),x(n)&&(o=Math.floor(n)*(U(n)?1:1e6)),x(s)&&(i=Math.floor(s)),{start:r,end:o,versions:i}}function F(e,t){const{start:n,end:s,versions:r}=e;return n&&s&&n>=s?(t(function(e,t,n){return`invalid params: start: ${e}, end: ${t}, versions: ${n||"undefined"}`}(n,s,r)),!1):!n||!r||(t("Defining start and versions is invalid"),!1)}function G(e,t,n=!1){return Array.isArray(e)?!!(n||e&&e.length)||(t("`query` param cannot be empty"),!1):(t("`query` param must be an array"),!1)}function J(e,t={}){return(n,s,r,o,i)=>{if(r&&r.code===m)return void e(null,void 0,r,o,i);if(n)return e(`Error: ${n}\nOptions: ${JSON.stringify(t)}`,void 0,r,o,i),void e(null,void 0,{code:m},o,i);const a=s;if(a&&a.datasets)return void e(null,a,r,o,i);const c=s;(c&&c.dataset||c)&&e(null,c,r,o,i)}}function $(e,t){const n={};if(Array.isArray(e)){const s=e.length;for(let r=0;r<s;r+=1){const{token:s,callback:o}=e[r];0===t.unbind(s,o)&&(n[s]=!0)}}else{const{token:s,callback:r}=e;0===t.unbind(s,r)&&(n[s]=!0)}return Object.keys(n).length?n:null}function L(e){const t=e.searchType;let n="ANY";return t&&P.has(t)&&(n=t),{search:e.search||"",searchType:n}}function V(e){return s.fromByteArray(t.encode(e,{extensionCodec:t.Codec}))}class H{constructor(e={batchResults:!0,debugMode:!1},t=WebSocket,n=d){this.connectorOptions=e,this.isRunning=!1,this.connectionEvents=new q,this.events=new q,this.WebSocket=t,this.Parser=n,this.instrumentation=new M(e.instrumentationConfig)}get websocket(){return this.ws}get connectionEmitter(){return this.connectionEvents}get eventsEmitter(){return this.events}callCommand(e,t,s){if(!this.isRunning)return s("Connection is down"),null;const r=n.v4(),o={command:e,encodedParams:V(t),token:r},i=this.makeCallbackWithUnbind(r,s);return this.events.bind(r,o,i),this.sendMessageOrError(r,e,t,o),r}cleanUpConnections(){this.events.close()}close(){this.closeWs(new CloseEvent("close")),this.connectionEvents.close(),this.ws.close()}closeWs(e){this.isRunning=!1,this.cleanUpConnections(),this.connectionEvents.emit("connection",H.DISCONNECTED,e)}closeCommand(e,t,s){const r=n.v4(),o={command:p,encodedParams:V(e),token:r},i=this.makeCallbackWithUnbind(r,s);this.events.bind(r,o,i);try{this.sendMessage(r,p,o,t)}catch(e){j(h,e),s(e,void 0,void 0,r)}return r}closeStreams(e,t){const n=$(e,this.events);return n?this.closeCommand(e,n,t):null}closeStream(e,t){const n=$(e,this.events);return n?this.closeCommand(e,n,t):null}connection(e){const t=(t,n,s)=>{e(n,s)};return this.connectionEvents.bind("connection",{command:"connection",encodedParams:"",token:""},t),()=>{this.connectionEvents.unbind("connection",t)}}get(e,t,n){return this.callCommand(e,t,n)}makeCallbackWithUnbind(e,t){const n=(s,r,o,i)=>{r&&(this.events.unbind(e,n),this.instrumentation.callInfo(s.command,s,{error:r})),this.instrumentation.callEnd(s.command,s),t(r,o,i,e,s)};return n}publish(e,t){return this.callCommand(v,e,t)}requestService(e,t){return this.callCommand(O,e,t)}run(e){this.runWithWs(new this.WebSocket(e))}runWithWs(e){this.ws=e,this.ws.onopen=e=>{this.isRunning||(this.isRunning=!0,this.connectionEvents.emit("connection",H.CONNECTED,e))},this.ws.onclose=e=>{this.closeWs(e)},this.ws.onmessage=e=>{var t;if("string"!=typeof e.data)return;let n;try{n=this.Parser.parse(e.data,this.connectorOptions.batchResults),this.connectorOptions.debugMode&&self.postMessage({response:n,source:R,timestamp:Date.now()},"*")}catch(e){return void j(h,e)}if(!n||!n.token)return void j(h,"No message body or message token");const{error:s,status:r,token:o}=n;s?this.events.emit(o,s,n.result,r):(!function(e,t,n,s){if(t&&Object.keys(t).length)return;const r=e;!r.dataset||r.dataset.name?!r.dataset||r.dataset.type?!r.dataset||r.notifications?s||!r.dataset||Array.isArray(r.notifications)||j(h,"Key 'notifications' is not an array",void 0,n):j(h,"No key 'notifications' found in response",void 0,n):j(h,"No key 'type' found in dataset",void 0,n):j(h,"No key 'name' found in dataset",void 0,n)}(n.result,r,o,this.connectorOptions.batchResults),this.events.emit(o,null,n.result,r),(null===(t=n.result)||void 0===t?void 0:t.metadata)&&"EOF"===n.result.metadata.GetRequest&&this.events.emit(o,null,null,{message:f,code:m}))}}search(e,t){return this.callCommand(S,e,t)}sendMessage(e,t,n,s){this.connectorOptions.debugMode&&self.postMessage({request:{token:e,command:t,params:s},source:R,timestamp:Date.now()},"*"),this.instrumentation.callStart(t,n),this.ws.send(this.Parser.stringify({token:e,command:t,params:s}))}sendMessageOrError(e,t,n,s){try{this.sendMessage(e,t,s,n)}catch(t){j(h,t),this.events.emit(e,t,void 0,void 0)}}stream(e,t,s){if(!this.isRunning)return s("Connection is down"),null;const r=n.v4(),o={command:e,encodedParams:V(t),token:r},i=(e,t,n,a)=>{t&&(this.events.unbind(r,i),this.instrumentation.callInfo(o.command,o,{error:t}),this.instrumentation.callEnd(e.command,e)),a&&3001===a.code&&this.instrumentation.callInfo(o.command,o,{message:"stream active"}),s(t,n,a,r,e)};return this.events.bind(r,o,i),this.sendMessageOrError(r,e,t,o),{token:r,callback:i}}}H.CONNECTED=D,H.DISCONNECTED=I;class Y extends H{closeSubscriptions(e,t){return this.closeStreams(e,J(t))}getAndSubscribe(e,t,n){if(!G(e,t))return null;if(!F(n,t))return null;const s=W(n),r={query:e,start:s.start,end:s.end,versions:s.versions};return this.stream(E,r,J(t))}getApps(e){const t={types:[T]};return this.get(b,t,J(e))}getConfigs(e){const t={types:[k]};return this.get(b,t,J(e))}getDatasets(e){const t={types:N};return this.get(b,t,J(e))}getDevices(e){const t={types:[_]};return this.get(b,t,J(e))}getWithOptions(e,t,n){if(e===y)return this.getDatasets(t),null;if(!G(e,t))return null;if(!F(n,t))return null;const{start:s,end:r,versions:o}=W(n),i={query:e,start:s,end:r,versions:o};return this.get(g,i,J(t,n))}runService(e,t){this.requestService(e,J(t))}runStreamingService(e,t){return e?this.stream(O,e,J(t)):(t("`request` param cannot be empty"),null)}searchWithOptions(e,t,n){if(!G(e,t,!0))return null;if(!F(n,t))return null;const{start:s,end:r}=W(n),o=L(n),i={query:e,start:s,end:r,search:o.search,searchType:o.searchType};return this.search(i,J(t,n))}searchSubscribe(e,t,n={search:""}){if(!G(e,t,!0))return null;const s=L(n);return this.stream(A,{query:e,search:s.search,searchType:s.searchType},J(t))}subscribe(e,t){return G(e,t)?this.stream(C,{query:e},J(t)):null}writeSync(e,t){this.publish({sync:!0,batch:{dataset:e.dataset,notifications:e.notifications}},function(e){return(t,n,s)=>{s&&s.code===m?e(!0):t&&e(!1,`Error: ${t}\n`)}}(t))}}Y.CLOSE=p,Y.DEVICES_DATASET_ID=y,Y.GET_DATASETS=b,Y.GET=g,Y.GET_AND_SUBSCRIBE=E,Y.ID=R,Y.PUBLISH=v,Y.SEARCH_SUBSCRIBE=A,Y.SEARCH=S,Y.SERVICE_REQUEST=O,Y.SUBSCRIBE=C,Object.defineProperty(e,"Bool",{enumerable:!0,get:function(){return t.Bool}}),Object.defineProperty(e,"Float32",{enumerable:!0,get:function(){return t.Float32}}),Object.defineProperty(e,"Float64",{enumerable:!0,get:function(){return t.Float64}}),Object.defineProperty(e,"Int",{enumerable:!0,get:function(){return t.Int}}),Object.defineProperty(e,"NeatTypeSerializer",{enumerable:!0,get:function(){return t.NeatTypeSerializer}}),Object.defineProperty(e,"NeatTypes",{enumerable:!0,get:function(){return t.NeatTypes}}),Object.defineProperty(e,"Nil",{enumerable:!0,get:function(){return t.Nil}}),Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}}),Object.defineProperty(e,"Str",{enumerable:!0,get:function(){return t.Str}}),Object.defineProperty(e,"createBaseType",{enumerable:!0,get:function(){return t.createBaseType}}),Object.defineProperty(e,"isJsbi",{enumerable:!0,get:function(){return t.isJsbi}}),Object.defineProperty(e,"isNeatType",{enumerable:!0,get:function(){return t.isNeatType}}),e.ACTIVE_CODE=3001,e.ALL_DATASET_TYPES=N,e.APP_DATASET_TYPE=T,e.CLOSE=p,e.CONFIG_DATASET_TYPE=k,e.CONNECTED=D,e.DEVICE_DATASET_TYPE=_,e.DISCONNECTED=I,e.EOF="EOF",e.EOF_CODE=m,e.GET=g,e.GET_AND_SUBSCRIBE=E,e.GET_DATASETS=b,e.GET_REQUEST_COMPLETED=f,e.PUBLISH=v,e.Parser=d,e.SEARCH=S,e.SEARCH_SUBSCRIBE=A,e.SERVICE_REQUEST=O,e.SUBSCRIBE=C,e.default=Y,e.fromBinaryKey=function(e,n=!0){return t.decode(s.toByteArray(e),{extensionCodec:t.Codec,useJSBI:n})},e.sanitizeOptions=W,e.toBinaryKey=V,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -398,3 +398,9 @@ import { encode, Codec, decode } from 'a-msgpack';

const APP_DATASET_TYPE = 'app';
const CONFIG_DATASET_TYPE = 'config';
const DEVICE_DATASET_TYPE = 'device';
const ALL_DATASET_TYPES = [
APP_DATASET_TYPE,
CONFIG_DATASET_TYPE,
DEVICE_DATASET_TYPE,
];
const SEARCH_TYPE_ANY = 'ANY';

@@ -1218,8 +1224,14 @@ const SEARCH_TYPE_IP = 'IP';

/**
* Returns a list of datasets. This will return data sets of type 'device',
* as well as type 'app'.
* Returns a list of configs (datasets with type == 'config').
*/
getConfigs(callback) {
const configType = [CONFIG_DATASET_TYPE];
const params = { types: configType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}
/**
* Returns a list of datasets (datasets with type 'app', 'config' or 'device').
*/
getDatasets(callback) {
const allDatasetTypes = [APP_DATASET_TYPE, DEVICE_DATASET_TYPE];
const params = { types: allDatasetTypes };
const params = { types: ALL_DATASET_TYPES };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));

@@ -1232,3 +1244,4 @@ }

const deviceType = [DEVICE_DATASET_TYPE];
return this.get(GET_DATASETS, { types: deviceType }, makeNotifCallback(callback));
const params = { types: deviceType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}

@@ -1378,2 +1391,2 @@ /**

export default Connector;
export { ACTIVE_CODE, APP_DATASET_TYPE, CONNECTED, DEVICE_DATASET_TYPE, DISCONNECTED, EOF, EOF_CODE, GET_REQUEST_COMPLETED, Parser, fromBinaryKey, sanitizeOptions, toBinaryKey };
export { ACTIVE_CODE, ALL_DATASET_TYPES, APP_DATASET_TYPE, CLOSE, CONFIG_DATASET_TYPE, CONNECTED, DEVICE_DATASET_TYPE, DISCONNECTED, EOF, EOF_CODE, GET, GET_AND_SUBSCRIBE, GET_DATASETS, GET_REQUEST_COMPLETED, PUBLISH, Parser, SEARCH, SEARCH_SUBSCRIBE, SERVICE_REQUEST, SUBSCRIBE, fromBinaryKey, sanitizeOptions, toBinaryKey };

@@ -401,3 +401,9 @@ 'use strict';

const APP_DATASET_TYPE = 'app';
const CONFIG_DATASET_TYPE = 'config';
const DEVICE_DATASET_TYPE = 'device';
const ALL_DATASET_TYPES = [
APP_DATASET_TYPE,
CONFIG_DATASET_TYPE,
DEVICE_DATASET_TYPE,
];
const SEARCH_TYPE_ANY = 'ANY';

@@ -1221,8 +1227,14 @@ const SEARCH_TYPE_IP = 'IP';

/**
* Returns a list of datasets. This will return data sets of type 'device',
* as well as type 'app'.
* Returns a list of configs (datasets with type == 'config').
*/
getConfigs(callback) {
const configType = [CONFIG_DATASET_TYPE];
const params = { types: configType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}
/**
* Returns a list of datasets (datasets with type 'app', 'config' or 'device').
*/
getDatasets(callback) {
const allDatasetTypes = [APP_DATASET_TYPE, DEVICE_DATASET_TYPE];
const params = { types: allDatasetTypes };
const params = { types: ALL_DATASET_TYPES };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));

@@ -1235,3 +1247,4 @@ }

const deviceType = [DEVICE_DATASET_TYPE];
return this.get(GET_DATASETS, { types: deviceType }, makeNotifCallback(callback));
const params = { types: deviceType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}

@@ -1453,3 +1466,6 @@ /**

exports.ACTIVE_CODE = ACTIVE_CODE;
exports.ALL_DATASET_TYPES = ALL_DATASET_TYPES;
exports.APP_DATASET_TYPE = APP_DATASET_TYPE;
exports.CLOSE = CLOSE;
exports.CONFIG_DATASET_TYPE = CONFIG_DATASET_TYPE;
exports.CONNECTED = CONNECTED;

@@ -1460,4 +1476,12 @@ exports.DEVICE_DATASET_TYPE = DEVICE_DATASET_TYPE;

exports.EOF_CODE = EOF_CODE;
exports.GET = GET;
exports.GET_AND_SUBSCRIBE = GET_AND_SUBSCRIBE;
exports.GET_DATASETS = GET_DATASETS;
exports.GET_REQUEST_COMPLETED = GET_REQUEST_COMPLETED;
exports.PUBLISH = PUBLISH;
exports.Parser = Parser;
exports.SEARCH = SEARCH;
exports.SEARCH_SUBSCRIBE = SEARCH_SUBSCRIBE;
exports.SERVICE_REQUEST = SERVICE_REQUEST;
exports.SUBSCRIBE = SUBSCRIBE;
exports.default = Connector;

@@ -1464,0 +1488,0 @@ exports.fromBinaryKey = fromBinaryKey;

{
"name": "cloudvision-connector",
"version": "4.5.5",
"version": "4.6.0",
"description": "A module to communicate with the CloudVision API server",

@@ -53,10 +53,10 @@ "author": "extensions@arista.com",

"dependencies": {
"a-msgpack": "4.5.5",
"a-msgpack": "4.6.0",
"base64-js": "1.3.1",
"jsbi": "3.1.4",
"uuid": "8.3.0"
"uuid": "8.3.1"
},
"devDependencies": {
"@arista/prettier-config": "1.1.3",
"@rollup/plugin-commonjs": "15.0.0",
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-node-resolve": "9.0.0",

@@ -73,6 +73,6 @@ "@rollup/plugin-replace": "2.3.2",

"eslint-config-airbnb-base": "14.1.0",
"eslint-config-arista-js": "1.1.28",
"eslint-config-arista-ts": "1.1.23",
"eslint-plugin-arista": "0.1.37",
"eslint-plugin-import": "2.22.0",
"eslint-config-arista-js": "1.1.29",
"eslint-config-arista-ts": "1.2.0",
"eslint-plugin-arista": "0.1.38",
"eslint-plugin-import": "2.22.1",
"jest": "26.4.2",

@@ -83,12 +83,12 @@ "js-yaml": "3.14.0",

"rimraf": "3.0.2",
"rollup": "2.26.11",
"rollup": "2.28.2",
"rollup-plugin-terser": "7.0.2",
"ts-jest": "26.3.0",
"ts-jest": "26.4.1",
"tslib": "2.0.1",
"typedoc": "0.19.1",
"typedoc": "0.19.2",
"typedoc-neo-theme": "1.0.10",
"typedoc-plugin-markdown": "2.4.2",
"typescript": "4.0.2"
"typedoc-plugin-markdown": "3.0.7",
"typescript": "4.0.3"
},
"gitHead": "6fe11c395fa562d8e1a2e2aaccbde7162114aba8"
"gitHead": "cb5af5031bbeb7a9a889be9a94b4d23e47b8f840"
}
import {
AppParams,
DatasetType,
DatasetParams,
NotifCallback,

@@ -18,4 +17,6 @@ Options,

import {
ALL_DATASET_TYPES,
APP_DATASET_TYPE,
CLOSE,
CONFIG_DATASET_TYPE,
DEVICES_DATASET_ID,

@@ -169,3 +170,3 @@ DEVICE_DATASET_TYPE,

const appType: typeof APP_DATASET_TYPE[] = [APP_DATASET_TYPE];
const params: AppParams = { types: appType };
const params: DatasetParams = { types: appType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));

@@ -175,8 +176,15 @@ }

/**
* Returns a list of datasets. This will return data sets of type 'device',
* as well as type 'app'.
* Returns a list of configs (datasets with type == 'config').
*/
public getConfigs(callback: NotifCallback): string | null {
const configType: typeof CONFIG_DATASET_TYPE[] = [CONFIG_DATASET_TYPE];
const params: DatasetParams = { types: configType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}
/**
* Returns a list of datasets (datasets with type 'app', 'config' or 'device').
*/
public getDatasets(callback: NotifCallback): string | null {
const allDatasetTypes: DatasetType[] = [APP_DATASET_TYPE, DEVICE_DATASET_TYPE];
const params: AppParams = { types: allDatasetTypes };
const params: DatasetParams = { types: ALL_DATASET_TYPES };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));

@@ -190,3 +198,4 @@ }

const deviceType: typeof DEVICE_DATASET_TYPE[] = [DEVICE_DATASET_TYPE];
return this.get(GET_DATASETS, { types: deviceType }, makeNotifCallback(callback));
const params: DatasetParams = { types: deviceType };
return this.get(GET_DATASETS, params, makeNotifCallback(callback));
}

@@ -193,0 +202,0 @@

@@ -18,3 +18,3 @@ // Copyright (c) 2018, Arista Networks, Inc.

import { RequestContext, SearchType } from '../types';
import { DatasetType, RequestContext, SearchType } from '../types';

@@ -56,3 +56,9 @@ export const ERROR = 'ERROR';

export const APP_DATASET_TYPE = 'app';
export const CONFIG_DATASET_TYPE = 'config';
export const DEVICE_DATASET_TYPE = 'device';
export const ALL_DATASET_TYPES: DatasetType[] = [
APP_DATASET_TYPE,
CONFIG_DATASET_TYPE,
DEVICE_DATASET_TYPE,
];

@@ -59,0 +65,0 @@ export const SEARCH_TYPE_ANY = 'ANY';

@@ -37,3 +37,6 @@ // Copyright (c) 2018, Arista Networks, Inc.

ACTIVE_CODE,
ALL_DATASET_TYPES,
APP_DATASET_TYPE,
CLOSE,
CONFIG_DATASET_TYPE,
CONNECTED,

@@ -44,4 +47,12 @@ DEVICE_DATASET_TYPE,

EOF_CODE,
GET,
GET_AND_SUBSCRIBE,
GET_DATASETS,
GET_REQUEST_COMPLETED,
PUBLISH,
SEARCH,
SEARCH_SUBSCRIBE,
SERVICE_REQUEST,
SUBSCRIBE,
} from './constants';
export { fromBinaryKey, toBinaryKey, sanitizeOptions } from './utils';

@@ -30,3 +30,3 @@ import { ContextCommand, RequestContext, WsCommand } from '../types';

constructor(config?: InstrumentationConfig) {
public constructor(config?: InstrumentationConfig) {
if (config) {

@@ -33,0 +33,0 @@ this.enableInstrumentation = true;

@@ -90,5 +90,8 @@ import { NotifCallback, Options, PublishCallback, PublishRequest, Query, SearchOptions, ServiceRequest, SubscriptionIdentifier } from '../types';

/**
* Returns a list of datasets. This will return data sets of type 'device',
* as well as type 'app'.
* Returns a list of configs (datasets with type == 'config').
*/
getConfigs(callback: NotifCallback): string | null;
/**
* Returns a list of datasets (datasets with type 'app', 'config' or 'device').
*/
getDatasets(callback: NotifCallback): string | null;

@@ -95,0 +98,0 @@ /**

@@ -1,2 +0,2 @@

import { RequestContext, SearchType } from '../types';
import { DatasetType, RequestContext, SearchType } from '../types';
export declare const ERROR = "ERROR";

@@ -30,3 +30,5 @@ export declare const INFO = "INFO";

export declare const APP_DATASET_TYPE = "app";
export declare const CONFIG_DATASET_TYPE = "config";
export declare const DEVICE_DATASET_TYPE = "device";
export declare const ALL_DATASET_TYPES: DatasetType[];
export declare const SEARCH_TYPE_ANY = "ANY";

@@ -33,0 +35,0 @@ export declare const SEARCH_TYPE_IP = "IP";

export { createBaseType, isJsbi, isNeatType, Bool, Float32, Float64, Int, NeatTypes, NeatTypeSerializer, Nil, Pointer, Str, } from 'a-msgpack';
export { default } from './Connector';
export { default as Parser } from './Parser';
export { ACTIVE_CODE, APP_DATASET_TYPE, CONNECTED, DEVICE_DATASET_TYPE, DISCONNECTED, EOF, EOF_CODE, GET_REQUEST_COMPLETED, } from './constants';
export { ACTIVE_CODE, ALL_DATASET_TYPES, APP_DATASET_TYPE, CLOSE, CONFIG_DATASET_TYPE, CONNECTED, DEVICE_DATASET_TYPE, DISCONNECTED, EOF, EOF_CODE, GET, GET_AND_SUBSCRIBE, GET_DATASETS, GET_REQUEST_COMPLETED, PUBLISH, SEARCH, SEARCH_SUBSCRIBE, SERVICE_REQUEST, SUBSCRIBE, } from './constants';
export { fromBinaryKey, toBinaryKey, sanitizeOptions } from './utils';
import { NeatType, PathElements } from 'a-msgpack';
import { APP_DATASET_TYPE, CLOSE, DEVICE_DATASET_TYPE, GET, GET_AND_SUBSCRIBE, GET_DATASETS, PUBLISH, SEARCH, SEARCH_SUBSCRIBE, SEARCH_TYPE_ANY, SEARCH_TYPE_IP, SEARCH_TYPE_MAC, SERVICE_REQUEST, SUBSCRIBE } from '../src/constants';
import { APP_DATASET_TYPE, CLOSE, CONFIG_DATASET_TYPE, DEVICE_DATASET_TYPE, GET, GET_AND_SUBSCRIBE, GET_DATASETS, PUBLISH, SEARCH, SEARCH_SUBSCRIBE, SEARCH_TYPE_ANY, SEARCH_TYPE_IP, SEARCH_TYPE_MAC, SERVICE_REQUEST, SUBSCRIBE } from '../src/constants';
export declare type GetCommand = typeof GET | typeof GET_DATASETS | typeof SEARCH;

@@ -10,3 +10,3 @@ /** @deprecated: Use `GetCommand`. */

export declare type WsCommand = GetCommand | StreamCommand | typeof CLOSE | typeof PUBLISH;
export declare type DatasetType = typeof APP_DATASET_TYPE | typeof DEVICE_DATASET_TYPE;
export declare type DatasetType = typeof APP_DATASET_TYPE | typeof CONFIG_DATASET_TYPE | typeof DEVICE_DATASET_TYPE;
/** @deprecated: Use `DatasetType`. */

@@ -81,3 +81,3 @@ export declare type DatasetTypes = DatasetType;

}
export interface AppParams {
export interface DatasetParams {
types?: DatasetType[];

@@ -98,2 +98,2 @@ }

}
export declare type CloudVisionParams = AppParams | CloseParams | QueryParams | SearchParams;
export declare type CloudVisionParams = CloseParams | DatasetParams | QueryParams | SearchParams;
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