rx-jupyter
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -20,4 +20,2 @@ "use strict"; | ||
var _path = require("path"); | ||
var _base = require("./base"); | ||
@@ -27,8 +25,10 @@ | ||
var urljoin = require("url-join"); | ||
function formURI(path) { | ||
return (0, _path.join)("/api/contents/", path); | ||
return urljoin("/api/contents/", path); | ||
} | ||
function formCheckpointURI(path, checkpointID) { | ||
return (0, _path.join)("/api/contents/", path, "checkpoints", checkpointID); | ||
return urljoin("/api/contents/", path, "checkpoints", checkpointID); | ||
} | ||
@@ -35,0 +35,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.terminals = exports.contents = exports.sessions = exports.kernelspecs = exports.kernels = exports.apiVersion = undefined; | ||
exports.terminals = exports.contents = exports.sessions = exports.kernelspecs = exports.kernels = exports.shutdown = exports.apiVersion = undefined; | ||
@@ -40,3 +40,17 @@ var _ajax = require("rxjs/observable/dom/ajax"); | ||
/** | ||
* Creates an AjaxObservable for shutting down a notebook server. | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* | ||
* @return {Object} An Observable with the request/response | ||
*/ | ||
function shutdown(serverConfig) { | ||
return (0, _ajax.ajax)((0, _base.createAJAXSettings)(serverConfig, "/api/shutdown", { method: "POST" })); | ||
} | ||
exports.apiVersion = apiVersion; | ||
exports.shutdown = shutdown; | ||
exports.kernels = kernels; | ||
@@ -43,0 +57,0 @@ exports.kernelspecs = kernelspecs; |
@@ -72,3 +72,3 @@ "use strict"; | ||
path: path, | ||
kernel_name: name | ||
name: name | ||
} | ||
@@ -129,4 +129,6 @@ }); | ||
var q = params.toString(); | ||
var suffix = q !== "" ? "?" + q : ""; | ||
var url = serverConfig.endpoint + "/api/kernels/" + kernelID + "/channels?" + q; | ||
var url = serverConfig.endpoint + "/api/kernels/" + kernelID + "/channels" + suffix; | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
@@ -140,25 +142,23 @@ } | ||
// and ensuring it's serialized | ||
return _Subject.Subject.create(_Subscriber.Subscriber.create({ | ||
next: function next(message) { | ||
if (typeof message === "string") { | ||
// Assume serialized | ||
wsSubject.next(message); | ||
} else if ((typeof message === "undefined" ? "undefined" : _typeof(message)) === "object") { | ||
var sessionizedMessage = Object.assign({}, message, { | ||
header: Object.assign({}, { | ||
session: sessionID | ||
}, message.header) | ||
}); | ||
return _Subject.Subject.create( | ||
// $FlowFixMe: figure out if this is a shortcoming in the flow def or our declaration | ||
_Subscriber.Subscriber.create(function (message) { | ||
if (typeof message === "string") { | ||
// Assume serialized | ||
wsSubject.next(message); | ||
} else if ((typeof message === "undefined" ? "undefined" : _typeof(message)) === "object") { | ||
var sessionizedMessage = Object.assign({}, message, { | ||
header: Object.assign({}, { | ||
session: sessionID | ||
}, message.header) | ||
}); | ||
wsSubject.next(JSON.stringify(sessionizedMessage)); | ||
} else { | ||
console.error("Message must be a string or object, app sent", message); | ||
} | ||
}, | ||
error: function error(e) { | ||
return wsSubject.error(e); | ||
}, | ||
complete: function complete() { | ||
return wsSubject.complete(); | ||
wsSubject.next(JSON.stringify(sessionizedMessage)); | ||
} else { | ||
console.error("Message must be a string or object, app sent", message); | ||
} | ||
}, function (e) { | ||
return wsSubject.error(e); | ||
}, function () { | ||
return wsSubject.complete(); | ||
}), // Subscriber | ||
@@ -168,4 +168,3 @@ // Subject.create takes a subscriber and an observable. We're only overriding | ||
// second argument to Subject.create (since it's _also_ an observable) | ||
// $FlowFixMe: update the flow definition to allow this | ||
wsSubject); | ||
} |
@@ -18,4 +18,2 @@ "use strict"; | ||
var _path = require("path"); | ||
var _base = require("./base"); | ||
@@ -25,4 +23,6 @@ | ||
var urljoin = require("url-join"); | ||
function formURI(path) { | ||
return (0, _path.join)("/api/terminals/", path); | ||
return urljoin("/api/terminals/", path); | ||
} | ||
@@ -29,0 +29,0 @@ |
{ | ||
"name": "rx-jupyter", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "RxJS 5 bindings for the Jupyter Notebook API", | ||
@@ -8,3 +8,4 @@ "main": "lib/index.js", | ||
"prepare": "npm run build", | ||
"build": "npm run build:clean && npm run build:lib && npm run build:flow", | ||
"prepublishOnly": "npm run build && npm run build:flow", | ||
"build": "npm run build:clean && npm run build:lib", | ||
"build:clean": "rimraf lib", | ||
@@ -14,8 +15,3 @@ "build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib", | ||
"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:flow": "flow", | ||
"precoverage": "nyc npm run test:unit", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" | ||
"build:watch": "npm run build:clean && npm run build:lib:watch && npm run build:flow" | ||
}, | ||
@@ -34,28 +30,7 @@ "repository": "https://github.com/nteract/nteract/tree/master/packages/rx-jupyter", | ||
}, | ||
"devDependencies": { | ||
"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" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-flow-strip-types" | ||
] | ||
}, | ||
"dependencies": { | ||
"rxjs": "^5.5.0", | ||
"url-join": "^2.0.2", | ||
"url-search-params": "^0.10.0" | ||
} | ||
} |
@@ -6,14 +6,13 @@ // @flow | ||
import { join as pathJoin } from "path"; | ||
import { createAJAXSettings } from "./base"; | ||
const querystring = require("querystring"); | ||
const urljoin = require("url-join"); | ||
function formURI(path: string): string { | ||
return pathJoin("/api/contents/", path); | ||
return urljoin("/api/contents/", path); | ||
} | ||
function formCheckpointURI(path: string, checkpointID: string): string { | ||
return pathJoin("/api/contents/", path, "checkpoints", checkpointID); | ||
return urljoin("/api/contents/", path, "checkpoints", checkpointID); | ||
} | ||
@@ -20,0 +19,0 @@ |
@@ -18,2 +18,23 @@ // @flow | ||
export { apiVersion, kernels, kernelspecs, sessions, contents, terminals }; | ||
/** | ||
* Creates an AjaxObservable for shutting down a notebook server. | ||
* | ||
* @param {Object} serverConfig - The server configuration | ||
* | ||
* @return {Object} An Observable with the request/response | ||
*/ | ||
function shutdown(serverConfig: Object): Observable<*> { | ||
return ajax( | ||
createAJAXSettings(serverConfig, "/api/shutdown", { method: "POST" }) | ||
); | ||
} | ||
export { | ||
apiVersion, | ||
shutdown, | ||
kernels, | ||
kernelspecs, | ||
sessions, | ||
contents, | ||
terminals | ||
}; |
@@ -58,3 +58,3 @@ // @flow | ||
path, | ||
kernel_name: name | ||
name | ||
} | ||
@@ -125,4 +125,8 @@ }); | ||
const q = params.toString(); | ||
const suffix = q !== "" ? `?${q}` : ""; | ||
const url = `${serverConfig.endpoint}/api/kernels/${kernelID}/channels?${q}`; | ||
const url = `${ | ||
serverConfig.endpoint | ||
}/api/kernels/${kernelID}/channels${suffix}`; | ||
return url.replace(/^http(s)?/, "ws$1"); | ||
@@ -143,4 +147,5 @@ } | ||
return Subject.create( | ||
Subscriber.create({ | ||
next: message => { | ||
// $FlowFixMe: figure out if this is a shortcoming in the flow def or our declaration | ||
Subscriber.create( | ||
message => { | ||
if (typeof message === "string") { | ||
@@ -168,11 +173,10 @@ // Assume serialized | ||
}, | ||
error: e => wsSubject.error(e), | ||
complete: () => wsSubject.complete() | ||
}), // Subscriber | ||
e => wsSubject.error(e), | ||
() => wsSubject.complete() | ||
), // Subscriber | ||
// Subject.create takes a subscriber and an observable. We're only overriding | ||
// the subscriber here so we pass the subject on as an observable as the | ||
// second argument to Subject.create (since it's _also_ an observable) | ||
// $FlowFixMe: update the flow definition to allow this | ||
wsSubject | ||
); | ||
} |
@@ -6,8 +6,8 @@ // @flow | ||
import { join as pathJoin } from "path"; | ||
import { createAJAXSettings, normalizeBaseURL } from "./base"; | ||
const urljoin = require("url-join"); | ||
function formURI(path: string) { | ||
return pathJoin("/api/terminals/", path); | ||
return urljoin("/api/terminals/", path); | ||
} | ||
@@ -14,0 +14,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
78859
0
29
1638
3
+ Addedurl-join@^2.0.2
+ Addedurl-join@2.0.5(transitive)