rx-jupyter
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -9,11 +9,14 @@ Object.defineProperty(exports, "__esModule", { | ||
function normalizeBaseURL(url) { | ||
return url.replace(/\/+$/, ''); | ||
return url.replace(/\/+$/, ""); | ||
} | ||
function createAJAXSettings(serverConfig) { | ||
var uri = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/'; | ||
var uri = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "/"; | ||
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var baseURL = normalizeBaseURL(serverConfig.endpoint || serverConfig.url); | ||
var url = '' + baseURL + uri; | ||
var url = "" + baseURL + uri; | ||
var headers = { | ||
Authorization: "token " + (serverConfig.token ? serverConfig.token : "") | ||
}; | ||
// Merge in our typical settings for responseType, allow setting additional options | ||
@@ -23,3 +26,4 @@ // like the method | ||
url: url, | ||
responseType: 'json' | ||
responseType: "json", | ||
headers: headers | ||
}, serverConfig, opts); | ||
@@ -29,3 +33,2 @@ | ||
return settings; | ||
} | ||
//# sourceMappingURL=base.js.map | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -16,16 +16,18 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _path = require('path'); | ||
var _Observable = require("rxjs/Observable"); | ||
var _base = require('./base'); | ||
var _path = require("path"); | ||
var querystring = require('querystring'); | ||
var _base = require("./base"); | ||
var querystring = require("querystring"); | ||
function formURI(path) { | ||
return (0, _path.join)('/api/contents/', path); | ||
return (0, _path.join)("/api/contents/", path); | ||
} | ||
function formCheckpointURI(path, checkpointID) { | ||
return (0, _path.join)('/api/contents/', path, 'checkpoints', checkpointID); | ||
return (0, _path.join)("/api/contents/", path, "checkpoints", checkpointID); | ||
} | ||
@@ -51,13 +53,13 @@ | ||
/** | ||
* Creates an AjaxObservable for removing content | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* @param {string} path - The path to the content | ||
* | ||
* @return {AjaxObservable} An Observable with the request response | ||
*/ | ||
* Creates an AjaxObservable for removing content | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* @param {string} path - The path to the content | ||
* | ||
* @return {AjaxObservable} An Observable with the request response | ||
*/ | ||
function remove(serverConfig, path) { | ||
var uri = formURI(path); | ||
var opts = { | ||
method: 'DELETE' | ||
method: "DELETE" | ||
}; | ||
@@ -83,3 +85,3 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
if (query.length > 0) { | ||
uri = uri + '?' + query; | ||
uri = uri + "?" + query; | ||
} | ||
@@ -101,5 +103,5 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri)); | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'PATCH', | ||
method: "PATCH", | ||
body: model | ||
@@ -123,5 +125,5 @@ }; | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'POST', | ||
method: "POST", | ||
body: model | ||
@@ -144,5 +146,5 @@ }; | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'PUT', | ||
method: "PUT", | ||
body: model | ||
@@ -160,5 +162,5 @@ }; | ||
function listCheckpoints(serverConfig, path) { | ||
var uri = formCheckpointURI(path, ''); | ||
var uri = formCheckpointURI(path, ""); | ||
var opts = { | ||
method: 'GET' | ||
method: "GET" | ||
}; | ||
@@ -178,5 +180,5 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
function createCheckpoint(serverConfig, path) { | ||
var uri = formCheckpointURI(path, ''); | ||
var uri = formCheckpointURI(path, ""); | ||
var opts = { | ||
method: 'POST' | ||
method: "POST" | ||
}; | ||
@@ -196,3 +198,3 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
var opts = { | ||
method: 'DELETE' | ||
method: "DELETE" | ||
}; | ||
@@ -212,6 +214,5 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
var opts = { | ||
method: 'POST' | ||
method: "POST" | ||
}; | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
} | ||
//# sourceMappingURL=contents.js.map | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -8,25 +8,25 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _kernels = require('./kernels'); | ||
var _kernels = require("./kernels"); | ||
var kernels = _interopRequireWildcard(_kernels); | ||
var _kernelspecs = require('./kernelspecs'); | ||
var _kernelspecs = require("./kernelspecs"); | ||
var kernelspecs = _interopRequireWildcard(_kernelspecs); | ||
var _sessions = require('./sessions'); | ||
var _sessions = require("./sessions"); | ||
var sessions = _interopRequireWildcard(_sessions); | ||
var _contents = require('./contents'); | ||
var _contents = require("./contents"); | ||
var contents = _interopRequireWildcard(_contents); | ||
var _terminals = require('./terminals'); | ||
var _terminals = require("./terminals"); | ||
var terminals = _interopRequireWildcard(_terminals); | ||
var _base = require('./base'); | ||
var _base = require("./base"); | ||
@@ -36,3 +36,3 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function apiVersion(serverConfig) { | ||
var req = (0, _base.createAJAXSettings)(serverConfig, '/api'); | ||
var req = (0, _base.createAJAXSettings)(serverConfig, "/api"); | ||
return (0, _ajax.ajax)(req); | ||
@@ -46,3 +46,2 @@ } | ||
exports.contents = contents; | ||
exports.terminals = terminals; | ||
//# sourceMappingURL=index.js.map | ||
exports.terminals = terminals; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -15,8 +15,10 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _webSocket = require('rxjs/observable/dom/webSocket'); | ||
var _webSocket = require("rxjs/observable/dom/webSocket"); | ||
var _base = require('./base'); | ||
var _Observable = require("rxjs/Observable"); | ||
var _base = require("./base"); | ||
/** | ||
@@ -30,3 +32,3 @@ * Creates an AjaxObservable for listing running kernels. | ||
function list(serverConfig) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernels')); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernels")); | ||
} | ||
@@ -43,3 +45,3 @@ | ||
function get(serverConfig, id) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernels/' + id)); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernels/" + id)); | ||
} | ||
@@ -57,7 +59,7 @@ | ||
function start(serverConfig, name, path) { | ||
var startSettings = (0, _base.createAJAXSettings)(serverConfig, '/api/kernels', { | ||
var startSettings = (0, _base.createAJAXSettings)(serverConfig, "/api/kernels", { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'POST', | ||
method: "POST", | ||
body: { | ||
@@ -80,3 +82,3 @@ path: path, | ||
function kill(serverConfig, id) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernels/' + id, { method: 'DELETE' })); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernels/" + id, { method: "DELETE" })); | ||
} | ||
@@ -93,3 +95,5 @@ | ||
function interrupt(serverConfig, id) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernels/' + id + '/interrupt', { method: 'POST' })); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernels/" + id + "/interrupt", { | ||
method: "POST" | ||
})); | ||
} | ||
@@ -106,8 +110,10 @@ | ||
function restart(serverConfig, id) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernels/' + id + '/restart', { method: 'POST' })); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernels/" + id + "/restart", { | ||
method: "POST" | ||
})); | ||
} | ||
function formWebSocketURL(serverConfig, id) { | ||
var url = serverConfig.endpoint + '/api/kernels/' + id + '/channels'; | ||
return url.replace(/^http(s)?/, 'ws$1'); | ||
var url = serverConfig.endpoint + "/api/kernels/" + id + "/channels"; | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
} | ||
@@ -117,3 +123,2 @@ | ||
return (0, _webSocket.webSocket)(formWebSocketURL(serverConfig, id)); | ||
} | ||
//# sourceMappingURL=kernels.js.map | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _base = require('./base'); | ||
var _Observable = require("rxjs/Observable"); | ||
var _Observable2 = _interopRequireDefault(_Observable); | ||
var _base = require("./base"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -22,8 +28,7 @@ * Creates an AjaxObservable for listing avaialble kernelspecs. | ||
function list(serverConfig) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernelspecs')); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernelspecs")); | ||
} | ||
function get(serverConfig, name) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/kernelspecs/' + name)); | ||
} | ||
//# sourceMappingURL=kernelspecs.js.map | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/kernelspecs/" + name)); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -12,6 +12,12 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _base = require('./base'); | ||
var _Observable = require("rxjs/Observable"); | ||
var _Observable2 = _interopRequireDefault(_Observable); | ||
var _base = require("./base"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -27,3 +33,3 @@ * Creates an AjaxObservable for listing available sessions. | ||
function list(serverConfig) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/sessions')); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/sessions")); | ||
} | ||
@@ -40,4 +46,6 @@ | ||
*/ | ||
function get(serverConfig, sessionID) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/sessions/' + sessionID)); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/sessions/" + sessionID)); | ||
} | ||
@@ -55,3 +63,5 @@ | ||
function destroy(serverConfig, sessionID) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/sessions/' + sessionID, { method: 'DELETE' })); | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/sessions/" + sessionID, { | ||
method: "DELETE" | ||
})); | ||
} | ||
@@ -66,3 +76,3 @@ | ||
* | ||
* @param {String} body - Payload containing new kernel_name, new kernel_id, | ||
* @param {Object} body - Payload containing new kernel_name, new kernel_id, | ||
* name of the new session, and the new path. | ||
@@ -73,6 +83,6 @@ * | ||
function update(serverConfig, sessionID, body) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/sessions/' + sessionID, { | ||
method: 'PATCH', | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/sessions/" + sessionID, { | ||
method: "PATCH", | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
@@ -94,10 +104,9 @@ body: body | ||
function create(serverConfig, body) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, '/api/sessions', { | ||
method: 'POST', | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/sessions", { | ||
method: "POST", | ||
headers: { | ||
'Content-Type': 'application/json' | ||
"Content-Type": "application/json" | ||
}, | ||
body: body | ||
})); | ||
} | ||
//# sourceMappingURL=sessions.js.map | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -12,10 +12,16 @@ Object.defineProperty(exports, "__esModule", { | ||
var _ajax = require('rxjs/observable/dom/ajax'); | ||
var _ajax = require("rxjs/observable/dom/ajax"); | ||
var _path = require('path'); | ||
var _Observable = require("rxjs/Observable"); | ||
var _base = require('./base'); | ||
var _Observable2 = _interopRequireDefault(_Observable); | ||
var _path = require("path"); | ||
var _base = require("./base"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function formURI(path) { | ||
return (0, _path.join)('/api/terminals/', path); | ||
return (0, _path.join)("/api/terminals/", path); | ||
} | ||
@@ -29,5 +35,5 @@ | ||
function list(serverConfig) { | ||
var uri = '/api/terminals/'; | ||
var uri = "/api/terminals/"; | ||
var opts = { | ||
method: 'GET' | ||
method: "GET" | ||
}; | ||
@@ -43,5 +49,5 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
function create(serverConfig) { | ||
var uri = '/api/terminals/'; | ||
var uri = "/api/terminals/"; | ||
var opts = { | ||
method: 'POST' | ||
method: "POST" | ||
}; | ||
@@ -60,3 +66,3 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
var opts = { | ||
method: 'GET' | ||
method: "GET" | ||
}; | ||
@@ -75,3 +81,3 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
var opts = { | ||
method: 'DELETE' | ||
method: "DELETE" | ||
}; | ||
@@ -83,5 +89,4 @@ return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, uri, opts)); | ||
var baseURL = (0, _base.normalizeBaseURL)(serverConfig.endpoint || serverConfig.url); | ||
var url = baseURL + '/terminals/websocket/' + id; | ||
return url.replace(/^http(s)?/, 'ws$1'); | ||
} | ||
//# sourceMappingURL=terminals.js.map | ||
var url = baseURL + "/terminals/websocket/" + id; | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
} |
{ | ||
"name": "rx-jupyter", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "RxJS 5 bindings for the Jupyter Notebook API", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"prepublish": "npm run build", | ||
"build": "babel src --out-dir lib/ --source-maps", | ||
"build:docs": "jsdoc src --recurse -d docs", | ||
"prepare": "npm run build", | ||
"build": "npm run build:clean && npm run build:lib && npm run build:flow", | ||
"build:clean": "rimraf lib", | ||
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib", | ||
"build:lib": "babel -d lib src --ignore '**/__tests__/**'", | ||
"build:lib:watch": "npm run build:lib -- --watch", | ||
"pretest": "npm run build", | ||
"test": "npm run test:unit && npm run test:lint", | ||
"test:unit": "mocha --compilers js:babel-core/register --recursive", | ||
"test:lint": "eslint .", | ||
"test:flow": "flow", | ||
"precoverage": "nyc npm run test:unit", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/nteract/rx-jupyter.git" | ||
}, | ||
"repository": "https://github.com/nteract/nteract/tree/master/packages/rx-jupyter", | ||
"keywords": [ | ||
@@ -30,18 +30,17 @@ "jupyter", | ||
"bugs": { | ||
"url": "https://github.com/nteract/rx-jupyter/issues" | ||
"url": "https://github.com/nteract/nteract/issues" | ||
}, | ||
"homepage": "https://github.com/nteract/rx-jupyter#readme", | ||
"devDependencies": { | ||
"babel-cli": "^6.16.0", | ||
"babel-core": "^6.17.0", | ||
"babel-preset-es2015": "^6.16.0", | ||
"chai": "^3.5.0", | ||
"codecov": "^1.0.1", | ||
"eslint": "^3.8.0", | ||
"eslint-config-airbnb": "^12.0.0", | ||
"eslint-plugin-import": "^2.0.1", | ||
"jsdoc": "^3.4.2", | ||
"mocha": "^3.1.2", | ||
"nyc": "^8.3.1", | ||
"ws": "^1.1.1" | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"chai": "^4.1.2", | ||
"codecov": "^2.3.1", | ||
"flow-bin": "^0.54.0", | ||
"flow-copy-source": "^1.1.0", | ||
"flow-typed": "^2.2.0", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.2.1", | ||
"ws": "^3.2.0" | ||
}, | ||
@@ -51,7 +50,10 @@ "babel": { | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-flow-strip-types" | ||
] | ||
}, | ||
"dependencies": { | ||
"rxjs": "^5.0.0-rc.1" | ||
"rxjs": "^5.5.0" | ||
} | ||
} |
@@ -36,5 +36,6 @@ # rx-jupyter | ||
``` | ||
git clone https://github.com/nteract/rx-jupyter.git | ||
cd rx-jupyter | ||
npm install | ||
git clone https://github.com/nteract/nteract.git | ||
cd nteract | ||
npm i | ||
# Note that rx-jupyter is in packages/rx-jupyter | ||
``` | ||
@@ -41,0 +42,0 @@ ## Testing |
@@ -1,14 +0,28 @@ | ||
export function normalizeBaseURL(url) { | ||
return url.replace(/\/+$/, ''); | ||
// @flow | ||
export function normalizeBaseURL(url: string): string { | ||
return url.replace(/\/+$/, ""); | ||
} | ||
export function createAJAXSettings(serverConfig, uri = '/', opts = {}) { | ||
export function createAJAXSettings( | ||
serverConfig: Object, | ||
uri: string = "/", | ||
opts: Object = {} | ||
): Object { | ||
const baseURL = normalizeBaseURL(serverConfig.endpoint || serverConfig.url); | ||
const url = `${baseURL}${uri}`; | ||
const headers = { | ||
Authorization: `token ${serverConfig.token ? serverConfig.token : ""}` | ||
}; | ||
// Merge in our typical settings for responseType, allow setting additional options | ||
// like the method | ||
const settings = Object.assign({ | ||
url, | ||
responseType: 'json', | ||
}, serverConfig, opts); | ||
const settings = Object.assign( | ||
{ | ||
url, | ||
responseType: "json", | ||
headers | ||
}, | ||
serverConfig, | ||
opts | ||
); | ||
@@ -15,0 +29,0 @@ delete settings.endpoint; |
@@ -1,20 +0,20 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
// @flow | ||
import { join as pathJoin } from 'path'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import { Observable } from "rxjs/Observable"; | ||
import { | ||
createAJAXSettings, | ||
} from './base'; | ||
import { join as pathJoin } from "path"; | ||
const querystring = require('querystring'); | ||
import { createAJAXSettings } from "./base"; | ||
function formURI(path) { | ||
return pathJoin('/api/contents/', path); | ||
const querystring = require("querystring"); | ||
function formURI(path: string): string { | ||
return pathJoin("/api/contents/", path); | ||
} | ||
function formCheckpointURI(path, checkpointID) { | ||
return pathJoin('/api/contents/', path, 'checkpoints', checkpointID); | ||
function formCheckpointURI(path: string, checkpointID: string): string { | ||
return pathJoin("/api/contents/", path, "checkpoints", checkpointID); | ||
} | ||
/** | ||
@@ -38,13 +38,13 @@ * TODO: Explicit typing of the payloads for content | ||
/** | ||
* Creates an AjaxObservable for removing content | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* @param {string} path - The path to the content | ||
* | ||
* @return {AjaxObservable} An Observable with the request response | ||
*/ | ||
export function remove(serverConfig, path) { | ||
* Creates an AjaxObservable for removing content | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* @param {string} path - The path to the content | ||
* | ||
* @return {AjaxObservable} An Observable with the request response | ||
*/ | ||
export function remove(serverConfig: Object, path: string): Observable<*> { | ||
const uri = formURI(path); | ||
const opts = { | ||
method: 'DELETE', | ||
method: "DELETE" | ||
}; | ||
@@ -66,3 +66,7 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function get(serverConfig, path, params) { | ||
export function get( | ||
serverConfig: Object, | ||
path: string, | ||
params: Object | ||
): Observable<*> { | ||
let uri = formURI(path); | ||
@@ -84,10 +88,14 @@ const query = querystring.stringify(params); | ||
*/ | ||
export function update(serverConfig, path, model) { | ||
export function update( | ||
serverConfig: Object, | ||
path: string, | ||
model: Object | ||
): Observable<*> { | ||
const uri = formURI(path); | ||
const opts = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'PATCH', | ||
body: model, | ||
method: "PATCH", | ||
body: model | ||
}; | ||
@@ -106,10 +114,14 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function create(serverConfig, path, model) { | ||
export function create( | ||
serverConfig: Object, | ||
path: string, | ||
model: Object | ||
): Observable<*> { | ||
const uri = formURI(path); | ||
const opts = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'POST', | ||
body: model, | ||
method: "POST", | ||
body: model | ||
}; | ||
@@ -127,10 +139,14 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function save(serverConfig, path, model) { | ||
export function save( | ||
serverConfig: Object, | ||
path: string, | ||
model: Object | ||
): Observable<*> { | ||
const uri = formURI(path); | ||
const opts = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'PUT', | ||
body: model, | ||
method: "PUT", | ||
body: model | ||
}; | ||
@@ -146,6 +162,9 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function listCheckpoints(serverConfig, path) { | ||
const uri = formCheckpointURI(path, ''); | ||
export function listCheckpoints( | ||
serverConfig: Object, | ||
path: string | ||
): Observable<*> { | ||
const uri = formCheckpointURI(path, ""); | ||
const opts = { | ||
method: 'GET', | ||
method: "GET" | ||
}; | ||
@@ -164,6 +183,9 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function createCheckpoint(serverConfig, path) { | ||
const uri = formCheckpointURI(path, ''); | ||
export function createCheckpoint( | ||
serverConfig: Object, | ||
path: string | ||
): Observable<*> { | ||
const uri = formCheckpointURI(path, ""); | ||
const opts = { | ||
method: 'POST', | ||
method: "POST" | ||
}; | ||
@@ -180,6 +202,10 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function deleteCheckpoint(serverConfig, path, checkpointID) { | ||
export function deleteCheckpoint( | ||
serverConfig: Object, | ||
path: string, | ||
checkpointID: string | ||
): Observable<*> { | ||
const uri = formCheckpointURI(path, checkpointID); | ||
const opts = { | ||
method: 'DELETE', | ||
method: "DELETE" | ||
}; | ||
@@ -196,8 +222,12 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function restoreFromCheckpoint(serverConfig, path, checkpointID) { | ||
export function restoreFromCheckpoint( | ||
serverConfig: Object, | ||
path: string, | ||
checkpointID: string | ||
): Observable<*> { | ||
const uri = formCheckpointURI(path, checkpointID); | ||
const opts = { | ||
method: 'POST', | ||
method: "POST" | ||
}; | ||
return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
} |
@@ -1,15 +0,15 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
// @flow | ||
import * as kernels from './kernels'; | ||
import * as kernelspecs from './kernelspecs'; | ||
import * as sessions from './sessions'; | ||
import * as contents from './contents'; | ||
import * as terminals from './terminals'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import { | ||
createAJAXSettings, | ||
} from './base'; | ||
import * as kernels from "./kernels"; | ||
import * as kernelspecs from "./kernelspecs"; | ||
import * as sessions from "./sessions"; | ||
import * as contents from "./contents"; | ||
import * as terminals from "./terminals"; | ||
function apiVersion(serverConfig) { | ||
const req = createAJAXSettings(serverConfig, '/api'); | ||
import { createAJAXSettings } from "./base"; | ||
function apiVersion(serverConfig: Object) { | ||
const req = createAJAXSettings(serverConfig, "/api"); | ||
return ajax(req); | ||
@@ -16,0 +16,0 @@ } |
@@ -1,8 +0,8 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
// @flow | ||
import { webSocket } from 'rxjs/observable/dom/webSocket'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import { webSocket } from "rxjs/observable/dom/webSocket"; | ||
import { Observable } from "rxjs/Observable"; | ||
import { | ||
createAJAXSettings, | ||
} from './base'; | ||
import { createAJAXSettings } from "./base"; | ||
@@ -16,4 +16,4 @@ /** | ||
*/ | ||
export function list(serverConfig) { | ||
return ajax(createAJAXSettings(serverConfig, '/api/kernels')); | ||
export function list(serverConfig: Object): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, "/api/kernels")); | ||
} | ||
@@ -29,3 +29,3 @@ | ||
*/ | ||
export function get(serverConfig, id) { | ||
export function get(serverConfig: Object, id: string): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, `/api/kernels/${id}`)); | ||
@@ -43,12 +43,16 @@ } | ||
*/ | ||
export function start(serverConfig, name, path) { | ||
const startSettings = createAJAXSettings(serverConfig, '/api/kernels', { | ||
export function start( | ||
serverConfig: Object, | ||
name: string, | ||
path: string | ||
): Observable<*> { | ||
const startSettings = createAJAXSettings(serverConfig, "/api/kernels", { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
"Content-Type": "application/json" | ||
}, | ||
method: 'POST', | ||
method: "POST", | ||
body: { | ||
path, | ||
kernel_name: name, | ||
}, | ||
kernel_name: name | ||
} | ||
}); | ||
@@ -66,4 +70,6 @@ return ajax(startSettings); | ||
*/ | ||
export function kill(serverConfig, id) { | ||
return ajax(createAJAXSettings(serverConfig, `/api/kernels/${id}`, { method: 'DELETE' })); | ||
export function kill(serverConfig: Object, id: string): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, `/api/kernels/${id}`, { method: "DELETE" }) | ||
); | ||
} | ||
@@ -79,4 +85,8 @@ | ||
*/ | ||
export function interrupt(serverConfig, id) { | ||
return ajax(createAJAXSettings(serverConfig, `/api/kernels/${id}/interrupt`, { method: 'POST' })); | ||
export function interrupt(serverConfig: Object, id: string): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, `/api/kernels/${id}/interrupt`, { | ||
method: "POST" | ||
}) | ||
); | ||
} | ||
@@ -92,13 +102,17 @@ | ||
*/ | ||
export function restart(serverConfig, id) { | ||
return ajax(createAJAXSettings(serverConfig, `/api/kernels/${id}/restart`, { method: 'POST' })); | ||
export function restart(serverConfig: Object, id: string): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, `/api/kernels/${id}/restart`, { | ||
method: "POST" | ||
}) | ||
); | ||
} | ||
export function formWebSocketURL(serverConfig, id) { | ||
export function formWebSocketURL(serverConfig: Object, id: string): string { | ||
const url = `${serverConfig.endpoint}/api/kernels/${id}/channels`; | ||
return url.replace(/^http(s)?/, 'ws$1'); | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
} | ||
export function connect(serverConfig, id) { | ||
export function connect(serverConfig: Object, id: string): Observable<*> { | ||
return webSocket(formWebSocketURL(serverConfig, id)); | ||
} |
@@ -1,7 +0,8 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
// @flow | ||
import { | ||
createAJAXSettings, | ||
} from './base'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import Observable from "rxjs/Observable"; | ||
import { createAJAXSettings } from "./base"; | ||
/** | ||
@@ -14,8 +15,8 @@ * Creates an AjaxObservable for listing avaialble kernelspecs. | ||
*/ | ||
export function list(serverConfig) { | ||
return ajax(createAJAXSettings(serverConfig, '/api/kernelspecs')); | ||
export function list(serverConfig: Object): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, "/api/kernelspecs")); | ||
} | ||
export function get(serverConfig, name) { | ||
export function get(serverConfig: Object, name: string): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, `/api/kernelspecs/${name}`)); | ||
} |
@@ -1,7 +0,8 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
// @flow | ||
import { | ||
createAJAXSettings, | ||
} from './base'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import Observable from "rxjs/Observable"; | ||
import { createAJAXSettings } from "./base"; | ||
/** | ||
@@ -16,4 +17,4 @@ * Creates an AjaxObservable for listing available sessions. | ||
*/ | ||
export function list(serverConfig) { | ||
return ajax(createAJAXSettings(serverConfig, '/api/sessions')); | ||
export function list(serverConfig: Object): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, "/api/sessions")); | ||
} | ||
@@ -30,3 +31,3 @@ | ||
*/ | ||
export function get(serverConfig, sessionID) { | ||
export function get(serverConfig: Object, sessionID: string): Observable<*> { | ||
return ajax(createAJAXSettings(serverConfig, `/api/sessions/${sessionID}`)); | ||
@@ -44,4 +45,11 @@ } | ||
*/ | ||
export function destroy(serverConfig, sessionID) { | ||
return ajax(createAJAXSettings(serverConfig, `/api/sessions/${sessionID}`, { method: 'DELETE' })); | ||
export function destroy( | ||
serverConfig: Object, | ||
sessionID: string | ||
): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, `/api/sessions/${sessionID}`, { | ||
method: "DELETE" | ||
}) | ||
); | ||
} | ||
@@ -56,3 +64,3 @@ | ||
* | ||
* @param {String} body - Payload containing new kernel_name, new kernel_id, | ||
* @param {Object} body - Payload containing new kernel_name, new kernel_id, | ||
* name of the new session, and the new path. | ||
@@ -62,10 +70,16 @@ * | ||
*/ | ||
export function update(serverConfig, sessionID, body) { | ||
return ajax(createAJAXSettings(serverConfig, `/api/sessions/${sessionID}`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body, | ||
})); | ||
export function update( | ||
serverConfig: Object, | ||
sessionID: string, | ||
body: Object | ||
): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, `/api/sessions/${sessionID}`, { | ||
method: "PATCH", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body | ||
}) | ||
); | ||
} | ||
@@ -83,10 +97,12 @@ | ||
*/ | ||
export function create(serverConfig, body) { | ||
return ajax(createAJAXSettings(serverConfig, '/api/sessions', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body, | ||
})); | ||
export function create(serverConfig: Object, body: Object): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, "/api/sessions", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body | ||
}) | ||
); | ||
} |
@@ -1,11 +0,12 @@ | ||
import { ajax } from 'rxjs/observable/dom/ajax'; | ||
import { join as pathJoin } from 'path'; | ||
// @flow | ||
import { | ||
createAJAXSettings, | ||
normalizeBaseURL, | ||
} from './base'; | ||
import { ajax } from "rxjs/observable/dom/ajax"; | ||
import Observable from "rxjs/Observable"; | ||
function formURI(path) { | ||
return pathJoin('/api/terminals/', path); | ||
import { join as pathJoin } from "path"; | ||
import { createAJAXSettings, normalizeBaseURL } from "./base"; | ||
function formURI(path: string) { | ||
return pathJoin("/api/terminals/", path); | ||
} | ||
@@ -18,6 +19,6 @@ | ||
*/ | ||
export function list(serverConfig) { | ||
const uri = '/api/terminals/'; | ||
export function list(serverConfig: Object): Observable<*> { | ||
const uri = "/api/terminals/"; | ||
const opts = { | ||
method: 'GET', | ||
method: "GET" | ||
}; | ||
@@ -32,6 +33,6 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function create(serverConfig) { | ||
const uri = '/api/terminals/'; | ||
export function create(serverConfig: Object): Observable<*> { | ||
const uri = "/api/terminals/"; | ||
const opts = { | ||
method: 'POST', | ||
method: "POST" | ||
}; | ||
@@ -47,6 +48,6 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function get(serverConfig, id) { | ||
export function get(serverConfig: Object, id: string): Observable<*> { | ||
const uri = formURI(id); | ||
const opts = { | ||
method: 'GET', | ||
method: "GET" | ||
}; | ||
@@ -62,6 +63,6 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
*/ | ||
export function destroy(serverConfig, id) { | ||
export function destroy(serverConfig: Object, id: string): Observable<*> { | ||
const uri = formURI(id); | ||
const opts = { | ||
method: 'DELETE', | ||
method: "DELETE" | ||
}; | ||
@@ -71,7 +72,6 @@ return ajax(createAJAXSettings(serverConfig, uri, opts)); | ||
export function formWebSocketURL(serverConfig, id) { | ||
export function formWebSocketURL(serverConfig: Object, id: string): string { | ||
const baseURL = normalizeBaseURL(serverConfig.endpoint || serverConfig.url); | ||
const url = `${baseURL}/terminals/websocket/${id}`; | ||
return url.replace(/^http(s)?/, 'ws$1'); | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 12 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
48
1
56183
23
1056
1
1
Updatedrxjs@^5.5.0