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

jupyter-js-services

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupyter-js-services - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0-alpha

10

lib/config.d.ts

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

import { IAjaxOptions } from './utils';
import { IAjaxSettings } from './utils';
/**

@@ -21,3 +21,7 @@ * A Configurable data section.

*/
update(newdata: any, ajaxOptions?: IAjaxOptions): Promise<any>;
update(newdata: any): Promise<any>;
/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
}

@@ -29,3 +33,3 @@ /**

*/
export declare function getConfigSection(sectionName: string, baseUrl: string, ajaxOptions?: IAjaxOptions): Promise<IConfigSection>;
export declare function getConfigSection(sectionName: string, baseUrl: string, ajaxSettings?: IAjaxSettings): Promise<IConfigSection>;
/**

@@ -32,0 +36,0 @@ * Configurable object with defaults.

@@ -13,5 +13,6 @@ // Copyright (c) Jupyter Development Team.

*/
function getConfigSection(sectionName, baseUrl, ajaxOptions) {
var section = new ConfigSection(sectionName, baseUrl);
return section.load(ajaxOptions);
function getConfigSection(sectionName, baseUrl, ajaxSettings) {
baseUrl = baseUrl || utils.DEFAULT_BASE_URL;
var section = new ConfigSection(sectionName, baseUrl, ajaxSettings);
return section.load();
}

@@ -26,7 +27,27 @@ exports.getConfigSection = getConfigSection;

*/
function ConfigSection(sectionName, baseUrl) {
function ConfigSection(sectionName, baseUrl, ajaxSettings) {
this._url = "unknown";
this._data = {};
this._ajaxSettings = '{}';
baseUrl = baseUrl || utils.DEFAULT_BASE_URL;
if (ajaxSettings)
this.ajaxSettings = ajaxSettings;
this._url = utils.urlPathJoin(baseUrl, SERVICE_CONFIG_URL, utils.urlJoinEncode(sectionName));
}
Object.defineProperty(ConfigSection.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the section.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the section.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConfigSection.prototype, "data", {

@@ -53,8 +74,9 @@ /**

*/
ConfigSection.prototype.load = function (ajaxOptions) {
ConfigSection.prototype.load = function () {
var _this = this;
return utils.ajaxRequest(this._url, {
method: "GET",
dataType: "json",
}, ajaxOptions).then(function (success) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -76,14 +98,14 @@ throw Error('Invalid Status: ' + success.xhr.status);

* Updates the local data immediately, sends the change to the server,
* and updates the local data with the response, and fullfils the promise
* and updates the local data with the response, and fulfils the promise
* with that data.
*/
ConfigSection.prototype.update = function (newdata, ajaxOptions) {
ConfigSection.prototype.update = function (newdata) {
var _this = this;
this._data = utils.extend(this._data, newdata);
return utils.ajaxRequest(this._url, {
method: "PATCH",
data: JSON.stringify(newdata),
dataType: "json",
contentType: 'application/json',
}, ajaxOptions).then(function (success) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.data = JSON.stringify(newdata);
ajaxSettings.dataType = 'json';
ajaxSettings.contentType = 'application/json';
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -159,2 +181,1 @@ throw Error('Invalid Status: ' + success.xhr.status);

exports.ConfigWithDefaults = ConfigWithDefaults;
//# sourceMappingURL=config.js.map

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

import { IAjaxOptions } from './utils';
import { IAjaxSettings } from './utils';
/**

@@ -10,3 +10,3 @@ * Options for a contents object.

* #### Notes
* One of `{ "directory", "file", "notebook" }`
* One of `["directory", "file", "notebook"]`.
*/

@@ -18,5 +18,5 @@ type?: string;

* #### Notes
* One of `{ 'json', text', 'base64' }`
* One of `['json', text', 'base64']`.
*
* Only relevant for type: 'file'
* Only relevant for type: `'file'`.
*/

@@ -67,3 +67,3 @@ format?: string;

* #### Notes
* One of `{ "directory", "file", "notebook" }`
* One of `["directory", "file", "notebook"]`
*/

@@ -74,11 +74,11 @@ type: string;

*/
writable: boolean;
writable?: boolean;
/**
* File creation timestamp.
*/
created: string;
created?: string;
/**
* Last modified timestamp.
*/
last_modified: string;
last_modified?: string;
/**

@@ -119,5 +119,5 @@ * Specify the mime-type of file contents.

/**
* Interface that a content manager should implement.
* Interface that a contents manager should implement.
**/
export interface IContents {
export interface IContentsManager {
/**

@@ -127,10 +127,9 @@ * Get a file or directory.

* @param path: Path to the file or directory.
* @param options: Use `options.content = true` to return file contents.
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @param options: The options describing the file.
* Use `options.content = true` to return file contents.
*
* @returns A promise which resolves with the file content.
*/
get(path: string, options: IContentsOpts, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
get(path: string, options?: IContentsOpts): Promise<IContentsModel>;
/**

@@ -140,120 +139,136 @@ * Create a new untitled file or directory in the specified directory path.

* @param path: The directory in which to create the new file/directory.
* @param options: Use `ext` and `type` options to choose the type of file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param options: The options describing the new item.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with the created file content when the
* file is created.
*/
newUntitled(path: string, options: IContentsOpts, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
newUntitled(path: string, options: IContentsOpts): Promise<IContentsModel>;
/**
* Delete a file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
* @param path - The path to the file.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves when the file is deleted.
*/
delete(path: string, ajaxOptions?: IAjaxOptions): Promise<void>;
delete(path: string): Promise<void>;
/**
* Rename a file.
* Rename a file or directory.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param path - The original file path.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @param newPath - The new file path.
*
* @returns A promise which resolves with the new file content model when the
* file is renamed.
*/
rename(path: string, newPath: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
rename(path: string, newPath: string): Promise<IContentsModel>;
/**
* Save a file.
*
* #### Notes
* Ensure that `model.content` is populated for the file.
* @param path - The desired file path.
*
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param model - The file model to save.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with the file content model when the
* file is saved.
*/
save(path: string, model: any, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
save(path: string, model: any): Promise<IContentsModel>;
/**
* Copy a file into a given directory.
*
* #### Notes
* The server will select the name of the copied file.
* @param path - The original file path.
*
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param toDir - The destination directory path.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with the new content model when the
* file is copied.
*/
copy(path: string, toDir: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
copy(path: string, toDir: string): Promise<IContentsModel>;
/**
* List notebooks and directories at a given path.
*
* @param: path: The path to list notebooks in.
* @param: path - The path in which to list the contents.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with a model with the directory content.
*/
listContents(path: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
listContents(path: string): Promise<IContentsModel>;
/**
* Create a checkpoint for a file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param path - The path of the file.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with the new checkpoint model when the
* checkpoint is created.
*/
createCheckpoint(path: string, ajaxOptions?: IAjaxOptions): Promise<ICheckpointModel>;
createCheckpoint(path: string): Promise<ICheckpointModel>;
/**
* List available checkpoints for a file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
* @param path - The path of the file.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @returns A promise which resolves with a list of checkpoint models for
* the file.
*/
listCheckpoints(path: string, ajaxOptions?: IAjaxOptions): Promise<ICheckpointModel[]>;
listCheckpoints(path: string): Promise<ICheckpointModel[]>;
/**
* Restore a file to a known checkpoint state.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
* @param path - The path of the file.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @param checkpointID - The id of the checkpoint to restore.
*
* @returns A promise which resolves when the checkpoint is restored.
*/
restoreCheckpoint(path: string, checkpointID: string, ajaxOptions?: IAjaxOptions): Promise<void>;
restoreCheckpoint(path: string, checkpointID: string): Promise<void>;
/**
* Delete a checkpoint for a file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
* @param path - The path of the file.
*
* The promise is fulfilled on a valid response and rejected otherwise.
* @param checkpointID - The id of the checkpoint to delete.
*
* @returns A promise which resolves when the checkpoint is deleted.
*/
deleteCheckpoint(path: string, checkpointID: string, ajaxOptions?: IAjaxOptions): Promise<void>;
deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
}
/**
* A contents handle passing file operations to the back-end.
* A contents manager that passes file operations to the server.
*
* This includes checkpointing with the normal file operations.
*/
export declare class Contents implements IContents {
export declare class ContentsManager implements IContentsManager {
/**
* Create a new contents object.
* Construct a new contents manager object.
*
* @param baseUrl - The base URL for the server.
*
* @param ajaxSettings - Optional initial ajax settings.
*/
constructor(baseUrl: string);
constructor(baseUrl: string, ajaxSettings?: IAjaxSettings);
/**
* Get a copy of the default ajax settings for the contents manager.
*/
/**
* Set the default ajax settings for the contents manager.
*/
ajaxSettings: IAjaxSettings;
/**
* Get a file or directory.
*
* @param path: Path to the file or directory.
* @param options: Use `options.content = true` to return file contents.
*
* @param options: The options describing the file.
* Use `options.content = true` to return file contents.
*
* @returns A promise which resolves with the file content.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
get(path: string, options: IContentsOpts, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
get(path: string, options?: IContentsOpts): Promise<IContentsModel>;
/**

@@ -263,31 +278,47 @@ * Create a new untitled file or directory in the specified directory path.

* @param path: The directory in which to create the new file/directory.
* @param options: Use `ext` and `type` options to choose the type of file.
*
* @param options: The options describing the new item.
*
* @returns A promise which resolves with the created file content when the
* file is created.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
newUntitled(path: string, options?: IContentsOpts, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
newUntitled(path: string, options?: IContentsOpts): Promise<IContentsModel>;
/**
* Delete a file.
*
* @param path - The path to the file.
*
* @returns A promise which resolves when the file is deleted.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
delete(path: string, ajaxOptions?: IAjaxOptions): Promise<void>;
delete(path: string): Promise<void>;
/**
* Rename a file.
* Rename a file or directory.
*
* @param path - The original file path.
*
* @param newPath - The new file path.
*
* @returns A promise which resolves with the new file contents model when
* the file is renamed.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
rename(path: string, newPath: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
rename(path: string, newPath: string): Promise<IContentsModel>;
/**
* Save a file.
*
* @param path - The desired file path.
*
* @param model - The file model to save.
*
* @returns A promise which resolves with the file contents model when the
* file is saved.
*
* #### Notes

@@ -297,9 +328,14 @@ * Ensure that `model.content` is populated for the file.

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
save(path: string, model: IContentsOpts, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
save(path: string, model: IContentsOpts): Promise<IContentsModel>;
/**
* Copy a file into a given directory.
*
* @param path - The original file path.
*
* @param toDir - The destination directory path.
*
* @returns A promise which resolves with the new contents model when the
* file is copied.
*
* #### Notes

@@ -309,58 +345,72 @@ * The server will select the name of the copied file.

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
copy(fromFile: string, toDir: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
copy(fromFile: string, toDir: string): Promise<IContentsModel>;
/**
* List notebooks and directories at a given path.
*
* @param: path: The path to list notebooks in.
* @param: path - The path in which to list the contents.
*
* @returns A promise which resolves with a model with the directory
* contents.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
listContents(path: string, ajaxOptions?: IAjaxOptions): Promise<IContentsModel>;
listContents(path: string): Promise<IContentsModel>;
/**
* Create a checkpoint for a file.
*
* @param path - The path of the file.
*
* @returns A promise which resolves with the new checkpoint model when the
* checkpoint is created.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
createCheckpoint(path: string, ajaxOptions?: IAjaxOptions): Promise<ICheckpointModel>;
createCheckpoint(path: string): Promise<ICheckpointModel>;
/**
* List available checkpoints for a file.
*
* @param path - The path of the file.
*
* @returns A promise which resolves with a list of checkpoint models for
* the file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
listCheckpoints(path: string, ajaxOptions?: IAjaxOptions): Promise<ICheckpointModel[]>;
listCheckpoints(path: string): Promise<ICheckpointModel[]>;
/**
* Restore a file to a known checkpoint state.
*
* @param path - The path of the file.
*
* @param checkpointID - The id of the checkpoint to restore.
*
* @returns A promise which resolves when the checkpoint is restored.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
restoreCheckpoint(path: string, checkpointID: string, ajaxOptions?: IAjaxOptions): Promise<void>;
restoreCheckpoint(path: string, checkpointID: string): Promise<void>;
/**
* Delete a checkpoint for a file.
*
* @param path - The path of the file.
*
* @param checkpointID - The id of the checkpoint to delete.
*
* @returns A promise which resolves when the checkpoint is deleted.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
deleteCheckpoint(path: string, checkpointID: string, ajaxOptions?: IAjaxOptions): Promise<void>;
deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
/**
* Get an REST url for this file given a path.
* Get a REST url for this file given a path.
*/
private _getUrl(...args);
private _apiUrl;
private _ajaxSettings;
}

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

// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var utils = require('./utils');

@@ -10,14 +8,38 @@ var validate = require('./validate');

/**
* A contents handle passing file operations to the back-end.
* A contents manager that passes file operations to the server.
*
* This includes checkpointing with the normal file operations.
*/
var Contents = (function () {
var ContentsManager = (function () {
/**
* Create a new contents object.
* Construct a new contents manager object.
*
* @param baseUrl - The base URL for the server.
*
* @param ajaxSettings - Optional initial ajax settings.
*/
function Contents(baseUrl) {
function ContentsManager(baseUrl, ajaxSettings) {
this._apiUrl = "unknown";
this._ajaxSettings = '{}';
baseUrl = baseUrl || utils.DEFAULT_BASE_URL;
if (ajaxSettings)
this.ajaxSettings = ajaxSettings;
this._apiUrl = utils.urlPathJoin(baseUrl, SERVICE_CONTENTS_URL);
}
Object.defineProperty(ContentsManager.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the contents manager.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the contents manager.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
/**

@@ -27,27 +49,31 @@ * Get a file or directory.

* @param path: Path to the file or directory.
* @param options: Use `options.content = true` to return file contents.
*
* @param options: The options describing the file.
* Use `options.content = true` to return file contents.
*
* @returns A promise which resolves with the file content.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.get = function (path, options, ajaxOptions) {
var settings = {
method: "GET",
dataType: "json",
};
ContentsManager.prototype.get = function (path, options) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
var url = this._getUrl(path);
var params = {};
if (options.type) {
params.type = options.type;
if (options) {
var params = {};
if (options.type) {
params.type = options.type;
}
if (options.format) {
params.format = options.format;
}
if (options.content === false) {
params.content = '0';
}
url += utils.jsonToQueryString(params);
}
if (options.format) {
params.format = options.format;
}
if (options.content === false) {
params.content = '0';
}
url = url + utils.jsonToQueryString(params);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -64,14 +90,15 @@ throw Error('Invalid Status: ' + success.xhr.status);

* @param path: The directory in which to create the new file/directory.
* @param options: Use `ext` and `type` options to choose the type of file.
*
* @param options: The options describing the new item.
*
* @returns A promise which resolves with the created file content when the
* file is created.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.newUntitled = function (path, options, ajaxOptions) {
var settings = {
method: "POST",
dataType: "json",
};
ContentsManager.prototype.newUntitled = function (path, options) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
if (options) {

@@ -82,7 +109,7 @@ var data = JSON.stringify({

});
settings.data = data;
settings.contentType = 'application/json';
ajaxSettings.data = data;
ajaxSettings.contentType = 'application/json';
}
var url = this._getUrl(path);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {

@@ -98,19 +125,20 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param path - The path to the file.
*
* @returns A promise which resolves when the file is deleted.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.delete = function (path, ajaxOptions) {
var settings = {
method: "DELETE",
dataType: "json",
};
ContentsManager.prototype.delete = function (path) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
var url = this._getUrl(path);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw Error('Invalid Status: ' + success.xhr.status);
}
}, // Translate certain errors to more specific ones.
function (error) {
}, function (error) {
// Translate certain errors to more specific ones.
// TODO: update IPEP27 to specify errors more precisely, so

@@ -125,19 +153,22 @@ // that error types can be detected here with certainty.

/**
* Rename a file.
* Rename a file or directory.
*
* @param path - The original file path.
*
* @param newPath - The new file path.
*
* @returns A promise which resolves with the new file contents model when
* the file is renamed.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.rename = function (path, newPath, ajaxOptions) {
var data = { path: newPath };
var settings = {
method: "PATCH",
data: JSON.stringify(data),
dataType: "json",
contentType: 'application/json',
};
ContentsManager.prototype.rename = function (path, newPath) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.dataType = 'json';
ajaxSettings.contentType = 'application/json';
ajaxSettings.data = JSON.stringify({ path: newPath });
var url = this._getUrl(path);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -153,2 +184,9 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param path - The desired file path.
*
* @param model - The file model to save.
*
* @returns A promise which resolves with the file contents model when the
* file is saved.
*
* #### Notes

@@ -158,14 +196,12 @@ * Ensure that `model.content` is populated for the file.

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.save = function (path, model, ajaxOptions) {
var settings = {
method: "PUT",
dataType: "json",
data: JSON.stringify(model),
contentType: 'application/json',
};
ContentsManager.prototype.save = function (path, model) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PUT';
ajaxSettings.dataType = 'json';
ajaxSettings.data = JSON.stringify(model);
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
var url = this._getUrl(path);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
// will return 200 for an existing file and 201 for a new file

@@ -182,2 +218,9 @@ if (success.xhr.status !== 200 && success.xhr.status !== 201) {

*
* @param path - The original file path.
*
* @param toDir - The destination directory path.
*
* @returns A promise which resolves with the new contents model when the
* file is copied.
*
* #### Notes

@@ -187,14 +230,11 @@ * The server will select the name of the copied file.

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.copy = function (fromFile, toDir, ajaxOptions) {
var settings = {
method: "POST",
data: JSON.stringify({ copy_from: fromFile }),
contentType: 'application/json',
dataType: "json",
};
ContentsManager.prototype.copy = function (fromFile, toDir) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'POST';
ajaxSettings.data = JSON.stringify({ copy_from: fromFile });
ajaxSettings.contentType = 'application/json';
ajaxSettings.dataType = 'json';
var url = this._getUrl(toDir);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {

@@ -210,11 +250,12 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param: path: The path to list notebooks in.
* @param: path - The path in which to list the contents.
*
* @returns A promise which resolves with a model with the directory
* contents.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.listContents = function (path, ajaxOptions) {
return this.get(path, { type: 'directory' }, ajaxOptions);
ContentsManager.prototype.listContents = function (path) {
return this.get(path, { type: 'directory' });
};

@@ -224,14 +265,16 @@ /**

*
* @param path - The path of the file.
*
* @returns A promise which resolves with the new checkpoint model when the
* checkpoint is created.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.createCheckpoint = function (path, ajaxOptions) {
var settings = {
method: "POST",
dataType: "json",
};
ContentsManager.prototype.createCheckpoint = function (path) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
var url = this._getUrl(path, 'checkpoints');
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {

@@ -247,14 +290,17 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param path - The path of the file.
*
* @returns A promise which resolves with a list of checkpoint models for
* the file.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.listCheckpoints = function (path, ajaxOptions) {
var settings = {
method: "GET",
dataType: "json",
};
ContentsManager.prototype.listCheckpoints = function (path) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
var url = this._getUrl(path, 'checkpoints');
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -275,14 +321,17 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param path - The path of the file.
*
* @param checkpointID - The id of the checkpoint to restore.
*
* @returns A promise which resolves when the checkpoint is restored.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.restoreCheckpoint = function (path, checkpointID, ajaxOptions) {
var settings = {
method: "POST",
dataType: "json",
};
ContentsManager.prototype.restoreCheckpoint = function (path, checkpointID) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
var url = this._getUrl(path, 'checkpoints', checkpointID);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {

@@ -296,14 +345,17 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* @param path - The path of the file.
*
* @param checkpointID - The id of the checkpoint to delete.
*
* @returns A promise which resolves when the checkpoint is deleted.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/contents).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
Contents.prototype.deleteCheckpoint = function (path, checkpointID, ajaxOptions) {
var settings = {
method: "DELETE",
dataType: "json",
};
ContentsManager.prototype.deleteCheckpoint = function (path, checkpointID) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
var url = this._getUrl(path, 'checkpoints', checkpointID);
return utils.ajaxRequest(url, settings, ajaxOptions).then(function (success) {
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {

@@ -315,5 +367,5 @@ throw Error('Invalid Status: ' + success.xhr.status);

/**
* Get an REST url for this file given a path.
* Get a REST url for this file given a path.
*/
Contents.prototype._getUrl = function () {
ContentsManager.prototype._getUrl = function () {
var args = [];

@@ -326,5 +378,4 @@ for (var _i = 0; _i < arguments.length; _i++) {

};
return Contents;
return ContentsManager;
})();
exports.Contents = Contents;
//# sourceMappingURL=contents.js.map
exports.ContentsManager = ContentsManager;
import { IDisposable } from 'phosphor-disposable';
import { ISignal } from 'phosphor-signaling';
import { IAjaxOptions } from './utils';
import { IAjaxSettings } from './utils';
/**

@@ -11,3 +11,3 @@ * The options object used to initialize a kernel.

*/
name: string;
name?: string;
/**

@@ -30,2 +30,6 @@ * The root url of the kernel server.

clientId?: string;
/**
* The default ajax settings to use for the kernel.
*/
ajaxSettings?: IAjaxSettings;
}

@@ -358,3 +362,3 @@ /**

* If `expectReply` is given and `true`, the future is disposed when both a
* shell reply and an idle status message are received. If `expectReply`
* shell reply and an idle status message are received. If `expectReply`
* is not given or is `false`, the future is disposed when an idle status

@@ -385,3 +389,3 @@ * message is received.

*/
interrupt(ajaxOptions?: IAjaxOptions): Promise<void>;
interrupt(): Promise<void>;
/**

@@ -402,3 +406,3 @@ * Restart a kernel.

*/
restart(ajaxOptions?: IAjaxOptions): Promise<void>;
restart(): Promise<void>;
/**

@@ -418,3 +422,3 @@ * Shutdown a kernel.

*/
shutdown(ajaxOptions?: IAjaxOptions): Promise<void>;
shutdown(): Promise<void>;
/**

@@ -496,4 +500,29 @@ * Send a `kernel_info_request` message.

connectToComm(targetName: string, commId?: string): IComm;
/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
}
/**
* Object which manages kernel instances.
*/
export interface IKernelManager {
/**
* Get the available kernel specs.
*/
getSpecs(options?: IKernelOptions): Promise<IKernelSpecIds>;
/**
* Get a list of running kernels.
*/
listRunning(options?: IKernelOptions): Promise<IKernelId[]>;
/**
* Start a new kernel.
*/
startNew(options?: IKernelOptions): Promise<IKernel>;
/**
* Connect to an existing kernel.
*/
connectTo(id: string, options?: IKernelOptions): Promise<IKernel>;
}
/**
* Object providing a Future interface for message callbacks.

@@ -505,3 +534,3 @@ *

* If a `reply` is expected, the Future is considered done when
* both a `reply` message and a an `idle` iopub status message have
* both a `reply` message and an `idle` iopub status message have
* been received. Otherwise, it is considered done when the `idle` status is

@@ -508,0 +537,0 @@ * received.

@@ -17,2 +17,1 @@ // Copyright (c) Jupyter Development Team.

var KernelStatus = exports.KernelStatus;
//# sourceMappingURL=ikernel.js.map

@@ -7,2 +7,2 @@ export * from './config';

export * from './session';
export { IAjaxOptions } from './utils';
export { IAjaxSettings } from './utils';

@@ -13,2 +13,1 @@ // Copyright (c) Jupyter Development Team.

__export(require('./session'));
//# sourceMappingURL=index.js.map

@@ -0,4 +1,5 @@

import { IDisposable } from 'phosphor-disposable';
import { ISignal } from 'phosphor-signaling';
import { IKernel, IKernelId } from './ikernel';
import { IAjaxOptions } from './utils';
import { IKernel, IKernelId, KernelStatus } from './ikernel';
import { IAjaxSettings } from './utils';
/**

@@ -31,11 +32,11 @@ * Notebook Identification specification.

*/
notebookPath: string;
notebookPath?: string;
/**
* The type of kernel (e.g. python3).
*/
kernelName: string;
kernelName?: string;
/**
* The root url of the notebook server.
*/
baseUrl: string;
baseUrl?: string;
/**

@@ -53,7 +54,25 @@ * The url to access websockets.

clientId?: string;
/**
* The default ajax settings to use for the session.
*/
ajaxSettings?: IAjaxSettings;
}
/**
* Object which manages notebook session instances.
*/
export interface INotebookSessionManager {
listRunning(options?: ISessionOptions): Promise<ISessionId[]>;
/**
* Start a new session.
*/
startNew(options: ISessionOptions): Promise<INotebookSession>;
/**
* Connect to a running notebook session.
*/
connectTo(id: string, options?: ISessionOptions): Promise<INotebookSession>;
}
/**
* Interface of a notebook session object.
*/
export interface INotebookSession {
export interface INotebookSession extends IDisposable {
/**

@@ -85,2 +104,9 @@ * A signal emitted when the session dies.

/**
* The current status of the session.
*
* #### Notes
* This is a read-only property, and is a delegate to the kernel status.
*/
status: KernelStatus;
/**
* Rename or move a notebook.

@@ -94,3 +120,3 @@ *

*/
renameNotebook(path: string, ajaxOptions?: IAjaxOptions): Promise<void>;
renameNotebook(path: string, ajaxSettings?: IAjaxSettings): Promise<void>;
/**

@@ -103,3 +129,7 @@ * Kill the kernel and shutdown the session.

*/
shutdown(ajaxOptions?: IAjaxOptions): Promise<void>;
shutdown(ajaxSettings?: IAjaxSettings): Promise<void>;
/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
}
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';
//# sourceMappingURL=isession.js.map

@@ -1,4 +0,43 @@

import { IKernel, IKernelId, IKernelMessage, IKernelMessageOptions, IKernelOptions, IKernelSpecIds } from './ikernel';
import { IAjaxOptions } from './utils';
import { IKernel, IKernelId, IKernelManager, IKernelMessage, IKernelMessageOptions, IKernelOptions, IKernelSpecIds } from './ikernel';
/**
* An implementation of a kernel manager.
*/
export declare class KernelManager implements IKernelManager {
/**
* Construct a new kernel manager.
*
* @param options - The default options for kernel.
*/
constructor(options: IKernelOptions);
/**
* Get the kernel specs. See also [[getKernelSpecs]].
*
* @param options - Overrides for the default options.
*/
getSpecs(options?: IKernelOptions): Promise<IKernelSpecIds>;
/**
* List the running kernels. See also [[listRunningKernels]].
*
* @param options - Overrides for the default options.
*/
listRunning(options?: IKernelOptions): Promise<IKernelId[]>;
/**
* Start a new kernel. See also [[startNewKernel]].
*
* @param options - Overrides for the default options.
*/
startNew(options?: IKernelOptions): Promise<IKernel>;
/**
* Connect to a running kernel. See also [[connectToKernel]].
*
* @param options - Overrides for the default options.
*/
connectTo(id: string, options?: IKernelOptions): Promise<IKernel>;
/**
* Get optionally overidden options.
*/
private _getOptions(options);
private _options;
}
/**
* Fetch the kernel specs.

@@ -8,6 +47,4 @@ *

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/kernelspecs).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
export declare function getKernelSpecs(baseUrl?: string, ajaxOptions?: IAjaxOptions): Promise<IKernelSpecIds>;
export declare function getKernelSpecs(options: IKernelOptions): Promise<IKernelSpecIds>;
/**

@@ -21,3 +58,3 @@ * Fetch the running kernels.

*/
export declare function listRunningKernels(baseUrl?: string, ajaxOptions?: IAjaxOptions): Promise<IKernelId[]>;
export declare function listRunningKernels(options: IKernelOptions): Promise<IKernelId[]>;
/**

@@ -29,7 +66,7 @@ * Start a new kernel.

*
* Wraps the result in an Kernel object. The promise is fulfilled
* Wraps the result in a Kernel object. The promise is fulfilled
* when the kernel is fully ready to send the first message. If
* the kernel fails to become ready, the promise is rejected.
*/
export declare function startNewKernel(options: IKernelOptions, ajaxOptions?: IAjaxOptions): Promise<IKernel>;
export declare function startNewKernel(options: IKernelOptions): Promise<IKernel>;
/**

@@ -51,3 +88,3 @@ * Connect to a running kernel.

*/
export declare function connectToKernel(id: string, options?: IKernelOptions, ajaxOptions?: IAjaxOptions): Promise<IKernel>;
export declare function connectToKernel(id: string, options?: IKernelOptions): Promise<IKernel>;
/**

@@ -54,0 +91,0 @@ * Create a well-formed Kernel Message.

@@ -28,15 +28,67 @@ // Copyright (c) Jupyter Development Team.

/**
* handle default logic for baseUrl
* An implementation of a kernel manager.
*/
function defaultBaseUrl(baseUrl) {
if (baseUrl !== undefined) {
return baseUrl;
var KernelManager = (function () {
/**
* Construct a new kernel manager.
*
* @param options - The default options for kernel.
*/
function KernelManager(options) {
this._options = null;
this._options = utils.copy(options);
}
if (typeof location === undefined) {
return 'http://localhost:8888/';
}
else {
return location.origin + '/';
}
}
/**
* Get the kernel specs. See also [[getKernelSpecs]].
*
* @param options - Overrides for the default options.
*/
KernelManager.prototype.getSpecs = function (options) {
return getKernelSpecs(this._getOptions(options));
};
/**
* List the running kernels. See also [[listRunningKernels]].
*
* @param options - Overrides for the default options.
*/
KernelManager.prototype.listRunning = function (options) {
return listRunningKernels(this._getOptions(options));
};
/**
* Start a new kernel. See also [[startNewKernel]].
*
* @param options - Overrides for the default options.
*/
KernelManager.prototype.startNew = function (options) {
return startNewKernel(this._getOptions(options));
};
/**
* Connect to a running kernel. See also [[connectToKernel]].
*
* @param options - Overrides for the default options.
*/
KernelManager.prototype.connectTo = function (id, options) {
if (options) {
options = this._getOptions(options);
}
else {
options = utils.copy(this._options);
}
return connectToKernel(id, options);
};
/**
* Get optionally overidden options.
*/
KernelManager.prototype._getOptions = function (options) {
if (options) {
options = utils.extend(utils.copy(this._options), options);
}
else {
options = this._options;
}
return options;
};
return KernelManager;
})();
exports.KernelManager = KernelManager;
/**

@@ -47,12 +99,10 @@ * Fetch the kernel specs.

* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter-js-services/master/rest_api.yaml#!/kernelspecs).
*
* The promise is fulfilled on a valid response and rejected otherwise.
*/
function getKernelSpecs(baseUrl, ajaxOptions) {
baseUrl = defaultBaseUrl(baseUrl);
function getKernelSpecs(options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
var url = utils.urlPathJoin(baseUrl, KERNELSPEC_SERVICE_URL);
return utils.ajaxRequest(url, {
method: "GET",
dataType: "json"
}, ajaxOptions).then(function (success) {
var ajaxSettings = utils.copy(options.ajaxSettings) || {};
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
var err = new Error('Invalid KernelSpecs Model');

@@ -90,9 +140,10 @@ if (success.xhr.status !== 200) {

*/
function listRunningKernels(baseUrl, ajaxOptions) {
baseUrl = defaultBaseUrl(baseUrl);
function listRunningKernels(options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL);
return utils.ajaxRequest(url, {
method: "GET",
dataType: "json"
}, ajaxOptions).then(function (success) {
var ajaxSettings = utils.copy(options.ajaxSettings) || {};
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -117,13 +168,15 @@ throw Error('Invalid Status: ' + success.xhr.status);

*
* Wraps the result in an Kernel object. The promise is fulfilled
* Wraps the result in a Kernel object. The promise is fulfilled
* when the kernel is fully ready to send the first message. If
* the kernel fails to become ready, the promise is rejected.
*/
function startNewKernel(options, ajaxOptions) {
var url = utils.urlPathJoin(defaultBaseUrl(options.baseUrl), KERNEL_SERVICE_URL);
return utils.ajaxRequest(url, {
method: "POST",
data: JSON.stringify({ name: options.name }),
dataType: "json"
}, ajaxOptions).then(function (success) {
function startNewKernel(options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL);
var ajaxSettings = utils.copy(options.ajaxSettings) || {};
ajaxSettings.method = 'POST';
ajaxSettings.data = JSON.stringify({ name: options.name });
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {

@@ -153,3 +206,3 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
function connectToKernel(id, options, ajaxOptions) {
function connectToKernel(id, options) {
var kernel = runningKernels.get(id);

@@ -162,3 +215,4 @@ if (kernel) {

}
return listRunningKernels(options.baseUrl, ajaxOptions).then(function (kernelIds) {
options.baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
return listRunningKernels(options).then(function (kernelIds) {
if (!kernelIds.some(function (k) { return k.id === id; })) {

@@ -233,2 +287,3 @@ throw new Error('No running kernel with id: ' + id);

this._username = '';
this._ajaxSettings = '{}';
this._reconnectLimit = 7;

@@ -240,5 +295,6 @@ this._reconnectAttempt = 0;

this._comms = null;
this.ajaxSettings = options.ajaxSettings || {};
this._name = options.name;
this._id = id;
this._baseUrl = defaultBaseUrl(options.baseUrl);
this._baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
if (options.wsUrl) {

@@ -352,2 +408,18 @@ this._wsUrl = options.wsUrl;

});
Object.defineProperty(Kernel.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the kernel.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the kernel.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Kernel.prototype, "isDisposed", {

@@ -380,2 +452,4 @@ /**

this._ws = null;
phosphor_signaling_1.clearSignalData(this);
runningKernels.delete(this._id);
};

@@ -390,3 +464,3 @@ /**

* If `expectReply` is given and `true`, the future is disposed when both a
* shell reply and an idle status message are received. If `expectReply`
* shell reply and an idle status message are received. If `expectReply`
* is not given or is `false`, the future is resolved when an idle status

@@ -428,4 +502,4 @@ * message is received.

*/
Kernel.prototype.interrupt = function (ajaxOptions) {
return interruptKernel(this, this._baseUrl, ajaxOptions);
Kernel.prototype.interrupt = function () {
return interruptKernel(this, this._baseUrl, this.ajaxSettings);
};

@@ -447,3 +521,3 @@ /**

*/
Kernel.prototype.restart = function (ajaxOptions) {
Kernel.prototype.restart = function () {
// clear internal state

@@ -460,3 +534,3 @@ this._futures.forEach(function (future, key) {

this._comms = new Map();
return restartKernel(this, this._baseUrl, ajaxOptions);
return restartKernel(this, this._baseUrl, this.ajaxSettings);
};

@@ -477,5 +551,5 @@ /**

*/
Kernel.prototype.shutdown = function (ajaxOptions) {
Kernel.prototype.shutdown = function () {
var _this = this;
return shutdownKernel(this, this._baseUrl, ajaxOptions).then(function () {
return shutdownKernel(this, this._baseUrl, this.ajaxSettings).then(function () {
_this._status = ikernel_1.KernelStatus.Dead;

@@ -558,6 +632,7 @@ _this._ws.close();

* Future `onReply` is called with the `execute_reply` content when the
* shell reply is received and validated. The future will resolve when
* shell reply is received and validated. The future will resolve when
* this message is received and the `idle` iopub status is received.
* The future will also be disposed at this point unless `disposeOnDone`
* is specified and `false`, in which case it is up to the caller to dispose of the future.
* is specified and `false`, in which case it is up to the caller to dispose
* of the future.
*

@@ -796,3 +871,3 @@ * **See also:** [[IExecuteReply]]

/**
* Handle `comm_open` kernel message.
* Handle a `comm_open` kernel message.
*/

@@ -869,3 +944,3 @@ Kernel.prototype._handleCommOpen = function (msg) {

/**
* Handle 'comm_msg' kernel message.
* Handle a 'comm_msg' kernel message.
*/

@@ -953,8 +1028,9 @@ Kernel.prototype._handleCommMsg = function (msg) {

*/
function restartKernel(kernel, baseUrl, ajaxOptions) {
function restartKernel(kernel, baseUrl, ajaxSettings) {
var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL, utils.urlJoinEncode(kernel.id, 'restart'));
return utils.ajaxRequest(url, {
method: "POST",
dataType: "json"
}, ajaxOptions).then(function (success) {
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -969,3 +1045,3 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
function interruptKernel(kernel, baseUrl, ajaxOptions) {
function interruptKernel(kernel, baseUrl, ajaxSettings) {
if (kernel.status === ikernel_1.KernelStatus.Dead) {

@@ -975,6 +1051,7 @@ return Promise.reject(new Error('Kernel is dead'));

var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL, utils.urlJoinEncode(kernel.id, 'interrupt'));
return utils.ajaxRequest(url, {
method: "POST",
dataType: "json"
}, ajaxOptions).then(function (success) {
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {

@@ -988,3 +1065,3 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
function shutdownKernel(kernel, baseUrl, ajaxOptions) {
function shutdownKernel(kernel, baseUrl, ajaxSettings) {
if (kernel.status === ikernel_1.KernelStatus.Dead) {

@@ -994,6 +1071,7 @@ return Promise.reject(new Error('Kernel is dead'));

var url = utils.urlPathJoin(baseUrl, KERNEL_SERVICE_URL, utils.urlJoinEncode(kernel.id));
return utils.ajaxRequest(url, {
method: "DELETE",
dataType: "json"
}, ajaxOptions).then(function (success) {
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {

@@ -1443,2 +1521,1 @@ throw Error('Invalid Status: ' + success.xhr.status);

})(phosphor_disposable_1.DisposableDelegate);
//# sourceMappingURL=kernel.js.map

@@ -110,2 +110,1 @@ // Copyright (c) Jupyter Development Team.

}
//# sourceMappingURL=serialize.js.map

@@ -1,5 +0,39 @@

import { INotebookSession, ISessionId, ISessionOptions } from './isession';
import { IAjaxOptions } from './utils';
import { INotebookSession, INotebookSessionManager, ISessionId, ISessionOptions } from './isession';
/**
* Fetch the running sessions.
* An implementation of a notebook session manager.
*/
export declare class NotebookSessionManager implements INotebookSessionManager {
/**
* Construct a new notebook session manager.
*
* @param options - The default options for each session.
*/
constructor(options: ISessionOptions);
/**
* List the running sessions. See also [[listRunningSessions]].
*
* @param options - Overrides for the default options.
*/
listRunning(options?: ISessionOptions): Promise<ISessionId[]>;
/**
* Start a new session. See also [[startNewSession]].
*
* @param options - Overrides for the default options, must include a
* `'notebookPath'`.
*/
startNew(options: ISessionOptions): Promise<INotebookSession>;
/**
* Connect to a running session. See also [[connectToSession]].
*
* @param options - Overrides for the default options.
*/
connectTo(id: string, options?: ISessionOptions): Promise<INotebookSession>;
/**
* Get optionally overidden options.
*/
private _getOptions(options);
private _options;
}
/**
* List the running sessions.
*

@@ -11,3 +45,3 @@ * #### Notes

*/
export declare function listRunningSessions(baseUrl: string, ajaxOptions?: IAjaxOptions): Promise<ISessionId[]>;
export declare function listRunningSessions(options: ISessionOptions): Promise<ISessionId[]>;
/**

@@ -25,3 +59,3 @@ * Start a new session.

*/
export declare function startNewSession(options: ISessionOptions, ajaxOptions?: IAjaxOptions): Promise<INotebookSession>;
export declare function startNewSession(options: ISessionOptions): Promise<INotebookSession>;
/**

@@ -43,2 +77,2 @@ * Connect to a running notebook session.

*/
export declare function connectToSession(id: string, options?: ISessionOptions, ajaxOptions?: IAjaxOptions): Promise<INotebookSession>;
export declare function connectToSession(id: string, options?: ISessionOptions): Promise<INotebookSession>;

@@ -14,3 +14,62 @@ // Copyright (c) Jupyter Development Team.

/**
* Fetch the running sessions.
* An implementation of a notebook session manager.
*/
var NotebookSessionManager = (function () {
/**
* Construct a new notebook session manager.
*
* @param options - The default options for each session.
*/
function NotebookSessionManager(options) {
this._options = null;
this._options = utils.copy(options);
}
/**
* List the running sessions. See also [[listRunningSessions]].
*
* @param options - Overrides for the default options.
*/
NotebookSessionManager.prototype.listRunning = function (options) {
return listRunningSessions(this._getOptions(options));
};
/**
* Start a new session. See also [[startNewSession]].
*
* @param options - Overrides for the default options, must include a
* `'notebookPath'`.
*/
NotebookSessionManager.prototype.startNew = function (options) {
return startNewSession(this._getOptions(options));
};
/**
* Connect to a running session. See also [[connectToSession]].
*
* @param options - Overrides for the default options.
*/
NotebookSessionManager.prototype.connectTo = function (id, options) {
if (options) {
options = this._getOptions(options);
}
else {
options = utils.copy(this._options);
}
return connectToSession(id, options);
};
/**
* Get optionally overidden options.
*/
NotebookSessionManager.prototype._getOptions = function (options) {
if (options) {
options = utils.extend(utils.copy(this._options), options);
}
else {
options = this._options;
}
return options;
};
return NotebookSessionManager;
})();
exports.NotebookSessionManager = NotebookSessionManager;
/**
* List the running sessions.
*

@@ -22,8 +81,10 @@ * #### Notes

*/
function listRunningSessions(baseUrl, ajaxOptions) {
var url = utils.urlPathJoin(baseUrl, SESSION_SERVICE_URL);
return utils.ajaxRequest(url, {
method: "GET",
dataType: "json"
}, ajaxOptions).then(function (success) {
function listRunningSessions(options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
var url = utils.urlPathJoin(options.baseUrl, SESSION_SERVICE_URL);
var ajaxSettings = utils.copy(options.ajaxSettings) || {};
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -54,4 +115,5 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
function startNewSession(options, ajaxOptions) {
var url = utils.urlPathJoin(options.baseUrl, SESSION_SERVICE_URL);
function startNewSession(options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
var url = utils.urlPathJoin(baseUrl, SESSION_SERVICE_URL);
var model = {

@@ -61,8 +123,9 @@ kernel: { name: options.kernelName },

};
return utils.ajaxRequest(url, {
method: "POST",
dataType: "json",
data: JSON.stringify(model),
contentType: 'application/json'
}, ajaxOptions).then(function (success) {
var ajaxSettings = utils.copy(options.ajaxSettings) || {};
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
ajaxSettings.data = JSON.stringify(model);
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {

@@ -93,3 +156,3 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
function connectToSession(id, options, ajaxOptions) {
function connectToSession(id, options) {
var session = runningSessions.get(id);

@@ -102,12 +165,8 @@ if (session) {

}
return new Promise(function (resolve, reject) {
listRunningSessions(options.baseUrl, ajaxOptions).then(function (sessionIds) {
var sessionIds = sessionIds.filter(function (k) { return k.id === id; });
if (!sessionIds.length) {
reject(new Error('No running session with id: ' + id));
}
createSession(sessionIds[0], options).then(function (session) {
resolve(session);
});
});
return listRunningSessions(options).then(function (sessionIds) {
sessionIds = sessionIds.filter(function (k) { return k.id === id; });
if (!sessionIds.length) {
throw new Error('No running session with id: ' + id);
}
return createSession(sessionIds[0], options);
});

@@ -121,20 +180,20 @@ }

*/
function createSession(sessionId, options, ajaxOptions) {
return new Promise(function (resolve, reject) {
options.notebookPath = sessionId.notebook.path;
var kernelOptions = {
name: sessionId.kernel.name,
baseUrl: options.baseUrl,
wsUrl: options.wsUrl,
username: options.username,
clientId: options.clientId
};
var kernelPromise = kernel_1.connectToKernel(sessionId.kernel.id, kernelOptions, ajaxOptions);
kernelPromise.then(function (kernel) {
var session = new NotebookSession(options, sessionId.id, kernel);
runningSessions.set(session.id, session);
resolve(session);
}).catch(function () {
reject(new Error('Session failed to start'));
});
function createSession(sessionId, options) {
var baseUrl = options.baseUrl || utils.DEFAULT_BASE_URL;
options.notebookPath = sessionId.notebook.path;
var kernelOptions = {
name: sessionId.kernel.name,
baseUrl: options.baseUrl,
wsUrl: options.wsUrl,
username: options.username,
clientId: options.clientId,
ajaxSettings: options.ajaxSettings
};
return kernel_1.connectToKernel(sessionId.kernel.id, kernelOptions).then(function (kernel) {
var session = new NotebookSession(options, sessionId.id, kernel);
runningSessions.set(session.id, session);
return session;
}).catch(function (error) {
throw Error('Session failed to start: ' + error.message);
return null;
});

@@ -156,7 +215,9 @@ }

function NotebookSession(options, id, kernel) {
this._id = "";
this._notebookPath = "";
this._id = '';
this._notebookPath = '';
this._ajaxSettings = '';
this._kernel = null;
this._url = '';
this._isDead = false;
this.ajaxSettings = options.ajaxSettings || {};
this._id = id;

@@ -204,2 +265,15 @@ this._notebookPath = options.notebookPath;

});
Object.defineProperty(NotebookSession.prototype, "status", {
/**
* The current status of the session, and is a delegate to the kernel status.
*
* #### Notes
* This is a read-only property.
*/
get: function () {
return this._kernel.status;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NotebookSession.prototype, "notebookPath", {

@@ -218,3 +292,40 @@ /**

});
Object.defineProperty(NotebookSession.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the session.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the session.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NotebookSession.prototype, "isDisposed", {
/**
* Test whether the session has been disposed.
*
* #### Notes
* This is a read-only property which is always safe to access.
*/
get: function () {
return (this._kernel !== null);
},
enumerable: true,
configurable: true
});
/**
* Dispose of the resources held by the session.
*/
NotebookSession.prototype.dispose = function () {
this._kernel = null;
phosphor_signaling_1.clearSignalData(this);
runningSessions.delete(this._id);
};
/**
* Rename or move a notebook.

@@ -228,3 +339,3 @@ *

*/
NotebookSession.prototype.renameNotebook = function (path, ajaxOptions) {
NotebookSession.prototype.renameNotebook = function (path) {
var _this = this;

@@ -238,8 +349,9 @@ if (this._isDead) {

};
return utils.ajaxRequest(this._url, {
method: "PATCH",
dataType: "json",
data: JSON.stringify(model),
contentType: 'application/json'
}, ajaxOptions).then(function (success) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.dataType = 'json';
ajaxSettings.data = JSON.stringify(model);
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {

@@ -261,3 +373,3 @@ throw Error('Invalid Status: ' + success.xhr.status);

*/
NotebookSession.prototype.shutdown = function (ajaxOptions) {
NotebookSession.prototype.shutdown = function () {
var _this = this;

@@ -268,6 +380,7 @@ if (this._isDead) {

this._isDead = true;
return utils.ajaxRequest(this._url, {
method: "DELETE",
dataType: "json"
}, ajaxOptions).then(function (success) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(this._url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {

@@ -309,2 +422,1 @@ throw Error('Invalid Status: ' + success.xhr.status);

}
//# sourceMappingURL=session.js.map
/**
* Default base URL.
*/
export declare const DEFAULT_BASE_URL: string;
/**
* Copy the contents of one object to another, recursively.

@@ -8,2 +12,6 @@ *

/**
* Get a copy of an object, or null.
*/
export declare function copy(object: any): any;
/**
* Get a random 128b hex string (not a formal UUID)

@@ -36,17 +44,47 @@ */

export interface IAjaxSettings {
method: string;
dataType: string;
/**
* The HTTP method to use. Defaults to `'GET'`.
*/
method?: string;
/**
* The return data type (used to parse the return data).
*/
dataType?: string;
/**
* The outgoing content type, used to set the `Content-Type` header.
*/
contentType?: string;
/**
* The request data.
*/
data?: any;
}
/**
* Options for AJAX calls.
*/
export interface IAjaxOptions {
/**
* Whether to cache the response. Defaults to `true`.
*/
cache?: boolean;
/**
* The number of milliseconds a request can take before automatically
* being terminated. A value of 0 (which is the default) means there is
* no timeout.
*/
timeout?: number;
/**
* A mapping of request headers, used via `setRequestHeader`.
*/
requestHeaders?: {
[key: string]: string;
};
/**
* Is a Boolean that indicates whether or not cross-site Access-Control
* requests should be made using credentials such as cookies or
* authorization headers. Defaults to `false`.
*/
withCredentials?: boolean;
/**
* The user name associated with the request. Defaults to `''`.
*/
user?: string;
/**
* The password associated with the request. Defaults to `''`.
*/
password?: string;

@@ -58,4 +96,13 @@ }

export interface IAjaxSuccess {
/**
* The data returned by the ajax call.
*/
data: any;
/**
* The status text of the response.
*/
statusText: string;
/**
* The XHR object.
*/
xhr: XMLHttpRequest;

@@ -67,4 +114,13 @@ }

export interface IAjaxError {
/**
* The XHR object.
*/
xhr: XMLHttpRequest;
/**
* The status text of the response.
*/
statusText: string;
/**
* The response error object.
*/
error: ErrorEvent;

@@ -75,5 +131,10 @@ }

*
* @param url - The url to request.
*
* @param settings - The settings to apply to the request and response.
*
* #### Notes
* Based on this [example](http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promisifying-xmlhttprequest).
*/
export declare function ajaxRequest(url: string, settings: IAjaxSettings, options?: IAjaxOptions): Promise<any>;
export declare function ajaxRequest(url: string, settings: IAjaxSettings): Promise<IAjaxSuccess>;
/**

@@ -80,0 +141,0 @@ * A Promise that can be resolved or rejected by another object.

@@ -5,2 +5,7 @@ // Copyright (c) Jupyter Development Team.

/**
* Default base URL.
*/
exports.DEFAULT_BASE_URL = (typeof location === 'undefined' ?
'http://localhost:8888/' : location.origin + '/');
/**
* Copy the contents of one object to another, recursively.

@@ -24,2 +29,12 @@ *

/**
* Get a copy of an object, or null.
*/
function copy(object) {
if (object !== null && typeof object === 'object') {
return JSON.parse(JSON.stringify(object));
}
return null;
}
exports.copy = copy;
/**
* Get a random 128b hex string (not a formal UUID)

@@ -98,23 +113,39 @@ */

*
* @param url - The url to request.
*
* @param settings - The settings to apply to the request and response.
*
* #### Notes
* Based on this [example](http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promisifying-xmlhttprequest).
*/
function ajaxRequest(url, settings, options) {
options = options || {};
function ajaxRequest(url, settings) {
var method = settings.method || 'GET';
var user = settings.user || '';
var password = settings.password || '';
if (!!settings.cache) {
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache.
url += ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
}
return new Promise(function (resolve, reject) {
var req = new XMLHttpRequest();
req.open(settings.method, url, true, options.user, options.password);
if (settings.contentType) {
req.open(method, url, true, user, password);
if (settings.contentType !== void 0) {
req.setRequestHeader('Content-Type', settings.contentType);
}
if (options.timeout !== void 0)
req.timeout = options.timeout;
if (options.withCredentials !== void 0) {
req.withCredentials = options.withCredentials;
if (settings.timeout !== void 0)
req.timeout = settings.timeout;
if (!!settings.withCredentials) {
req.withCredentials = true;
}
if (options.requestHeaders !== void 0) {
for (var prop in options.requestHeaders) {
req.setRequestHeader(prop, options.requestHeaders[prop]);
if (settings.requestHeaders !== void 0) {
for (var prop in settings.requestHeaders) {
req.setRequestHeader(prop, settings.requestHeaders[prop]);
}
}
req.onload = function () {
if (req.status >= 400) {
var error = new Error(req.statusText);
reject({ xhr: req, statusText: req.statusText, error: error });
return;
}
var response = req.responseText;

@@ -178,3 +209,3 @@ if (settings.dataType === 'json' && response) {

PromiseDelegate.prototype.reject = function (reason) {
// Note: according to the Promise spec, and the `this` context for resolve
// Note: according to the Promise spec, the `this` context for resolve
// and reject are ignored

@@ -186,2 +217,1 @@ this._reject(reason);

exports.PromiseDelegate = PromiseDelegate;
//# sourceMappingURL=utils.js.map

@@ -5,3 +5,3 @@ import { ICheckpointModel, IContentsModel } from './contents';

/**
* Validate an Kernel Message as being a valid Comm Message.
* Validate an `IKernelMessage` as being a valid Comm Message.
*/

@@ -14,3 +14,3 @@ export declare function validateCommMessage(msg: IKernelMessage): boolean;

/**
* Validate an `KernelId` object.
* Validate an `IKernelId` object.
*/

@@ -17,0 +17,0 @@ export declare function validateKernelId(info: IKernelId): void;

@@ -18,3 +18,3 @@ // Copyright (c) Jupyter Development Team.

/**
* Validate an Kernel Message as being a valid Comm Message.
* Validate an `IKernelMessage` as being a valid Comm Message.
*/

@@ -79,3 +79,3 @@ function validateCommMessage(msg) {

/**
* Validate an `KernelId` object.
* Validate an `IKernelId` object.
*/

@@ -186,2 +186,1 @@ function validateKernelId(info) {

exports.validateCheckpointModel = validateCheckpointModel;
//# sourceMappingURL=validate.js.map
{
"name": "jupyter-js-services",
"version": "0.2.2",
"version": "0.3.0-alpha",
"description": "Client APIs for the Jupyter services REST APIs",

@@ -8,4 +8,4 @@ "main": "lib/index.js",

"dependencies": {
"phosphor-disposable": "^1.0.4",
"phosphor-signaling": "^1.1.2"
"phosphor-disposable": "^1.0.5",
"phosphor-signaling": "^1.2.0"
},

@@ -53,4 +53,3 @@ "devDependencies": {

"lib/*.js",
"lib/*.d.ts",
"lib/*.map"
"lib/*.d.ts"
],

@@ -57,0 +56,0 @@ "author": "Project Jupyter",

@@ -10,3 +10,3 @@ Jupyter JS Services

Note: All functions and methods using the REST API allow an optional
Note: All functions and methods using the REST API allow an optional
`ajaxOptions` parameter to configure the request.

@@ -122,3 +122,3 @@

```typescript
import {
import {
listRunningKernels, connectToKernel, startNewKernel, getKernelSpecs

@@ -128,3 +128,3 @@ } from 'jupyter-js-services';

// get a list of available kernels and connect to one
listRunningKernels('http://localhost:8000').then((kernelModels) => {
listRunningKernels({ baseUrl: 'http://localhost:8000' }).then(kernelModels => {
var options = {

@@ -142,3 +142,3 @@ baseUrl: 'http://localhost:8000',

// get info about the available kernels and start a new one
getKernelSpecs('http://localhost:8888').then((kernelSpecs) => {
getKernelSpecs({ baseUrl: 'http://localhost:8888' }).then(kernelSpecs => {
console.log('Default spec:', kernelSpecs.default);

@@ -198,3 +198,4 @@ console.log('Available specs', Object.keys(kernelSpecs.kernelspecs));

// get a list of available sessions and connect to one
listRunningSessions('http://localhost:8000').then((sessionModels) => {
listRunningSessions({ baseUrl: 'http://localhost:8000' }
).then(sessionModels => {
var options = {

@@ -256,3 +257,3 @@ baseUrl: 'http://localhost:8000',

// get info about the available kernels and connect to one
getKernelSpecs(BASEURL).then(kernelSpecs => {
getKernelSpecs({ baseUrl: BASEURL }).then(kernelSpecs => {
return startNewKernel({

@@ -271,3 +272,3 @@ baseUrl: BASEURL,

// Create a comm from the client side.
getKernelSpecs(BASEURL).then(kernelSpecs => {
getKernelSpecs({ baseUrl: BASEURL }).then(kernelSpecs => {
return startNewKernel({

@@ -305,6 +306,6 @@ baseUrl: BASEURL,

import {
Contents
ContentsManager
} from 'jupyter-js-services';
var contents = new Contents('http://localhost:8000');
var contents = new ContentsManager('http://localhost:8000');

@@ -365,3 +366,3 @@ // create a new python file

getKernelSpecs(BASEURL).then(kernelSpecs => {
getKernelSpecs({ baseUrl: BASEURL }).then(kernelSpecs => {
return startNewKernel({

@@ -368,0 +369,0 @@ baseUrl: BASEURL,

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