Socket
Socket
Sign inDemoInstall

@jupyterlab/services

Package Overview
Dependencies
Maintainers
4
Versions
387
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlab/services - npm Package Compare versions

Comparing version 0.43.0 to 0.44.0

lib/serverconnection.d.ts

18

lib/config/index.d.ts
import { JSONObject, JSONValue } from '@phosphor/coreutils';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
/**

@@ -21,5 +21,5 @@ * A Configurable data section.

/**
* Optional default settings for ajax requests, if applicable.
* The server settings for the section.
*/
ajaxSettings?: IAjaxSettings;
readonly serverSettings: ServerConnection.ISettings;
}

@@ -45,13 +45,5 @@ /**

/**
* The server base url.
* The optional server settings.
*/
baseUrl?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The default ajax settings.
*/
ajaxSettings?: IAjaxSettings;
serverSettings?: ServerConnection.ISettings;
}

@@ -58,0 +50,0 @@ }

@@ -14,4 +14,3 @@ "use strict";

var coreutils_1 = require("@jupyterlab/coreutils");
var coreutils_2 = require("@phosphor/coreutils");
var utils = require("../utils");
var __1 = require("..");
/**

@@ -49,23 +48,5 @@ * The url for the config service.

this._data = null;
this._ajaxSettings = null;
var baseUrl = options.baseUrl || utils.getBaseUrl();
this.ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
this._url = coreutils_1.URLExt.join(baseUrl, SERVICE_CONFIG_URL, encodeURIComponent(options.name));
var settings = this.serverSettings = (options.serverSettings || __1.ServerConnection.makeSettings());
this._url = coreutils_1.URLExt.join(settings.baseUrl, SERVICE_CONFIG_URL, encodeURIComponent(options.name));
}
Object.defineProperty(DefaultConfigSection.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the section.
*/
get: function () {
return coreutils_2.JSONExt.deepCopy(this._ajaxSettings);
},
/**
* Set the default ajax settings for the section.
*/
set: function (value) {
this._ajaxSettings = coreutils_2.JSONExt.deepCopy(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DefaultConfigSection.prototype, "data", {

@@ -91,11 +72,11 @@ /**

var _this = this;
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) {
throw utils.makeAjaxError(success);
var request = {
url: this._url,
method: 'GET'
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
_this._data = success.data;
_this._data = response.data;
});

@@ -118,12 +99,12 @@ };

this._data = __assign({}, this._data, newdata);
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) {
throw utils.makeAjaxError(success);
var request = {
url: this._url,
method: 'PATCH',
data: JSON.stringify(newdata)
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
_this._data = success.data;
_this._data = response.data;
return _this._data;

@@ -130,0 +111,0 @@ });

import { JSONObject } from '@phosphor/coreutils';
import { IDisposable } from '@phosphor/disposable';
import { ISignal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
/**

@@ -144,5 +144,5 @@ * A namespace for contents interfaces.

/**
* The base url of the manager.
* The server settings of the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**

@@ -257,6 +257,2 @@ * A signal emitted when a file operation takes place.

deleteCheckpoint(path: string, checkpointID: string): Promise<void>;
/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
}

@@ -281,2 +277,6 @@ }

/**
* The server settings of the manager.
*/
readonly serverSettings: ServerConnection.ISettings;
/**
* Test whether the manager has been disposed.

@@ -290,13 +290,2 @@ */

/**
* Get the base url of the manager.
*/
readonly baseUrl: string;
/**
* 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.

@@ -445,5 +434,3 @@ *

private _getUrl(...args);
private _baseUrl;
private _isDisposed;
private _ajaxSettings;
private _fileChanged;

@@ -460,14 +447,6 @@ }

/**
* The root url of the server.
* The server settings for the server.
*/
baseUrl?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The default ajax settings to use for the kernel.
*/
ajaxSettings?: IAjaxSettings;
serverSettings?: ServerConnection.ISettings;
}
}

@@ -8,3 +8,3 @@ "use strict";

var signaling_1 = require("@phosphor/signaling");
var utils = require("../utils");
var __1 = require("..");
var validate = require("./validate");

@@ -32,8 +32,5 @@ /**

if (options === void 0) { options = {}; }
this._baseUrl = '';
this._isDisposed = false;
this._ajaxSettings = null;
this._fileChanged = new signaling_1.Signal(this);
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
this.serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
}

@@ -70,28 +67,2 @@ Object.defineProperty(ContentsManager.prototype, "fileChanged", {

};
Object.defineProperty(ContentsManager.prototype, "baseUrl", {
/**
* Get the base url of the manager.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ContentsManager.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the contents manager.
*/
get: function () {
return coreutils_2.JSONExt.deepCopy(this._ajaxSettings);
},
/**
* Set the default ajax settings for the contents manager.
*/
set: function (value) {
this._ajaxSettings = coreutils_2.JSONExt.deepCopy(value);
},
enumerable: true,
configurable: true
});
/**

@@ -109,6 +80,2 @@ * Get a file or directory.

ContentsManager.prototype.get = function (path, options) {
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
var url = this._getUrl(path);

@@ -124,13 +91,18 @@ if (options) {

}
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
var request = {
url: url,
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
try {
validate.validateContentsModel(success.data);
validate.validateContentsModel(response.data);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
return success.data;
return response.data;
});

@@ -147,3 +119,4 @@ };

ContentsManager.prototype.getDownloadUrl = function (path) {
return Promise.resolve(coreutils_1.URLExt.join(this._baseUrl, FILES_URL, coreutils_1.URLExt.encodeParts(path)));
var baseUrl = this.serverSettings.baseUrl;
return Promise.resolve(coreutils_1.URLExt.join(baseUrl, FILES_URL, coreutils_1.URLExt.encodeParts(path)));
};

@@ -164,6 +137,3 @@ /**

if (options === void 0) { options = {}; }
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'POST';
ajaxSettings.contentType = 'application/json';
ajaxSettings.dataType = 'json';
var data = '{}';
if (options) {

@@ -173,10 +143,14 @@ if (options.ext) {

}
ajaxSettings.data = JSON.stringify(options);
data = JSON.stringify(options);
}
var url = this._getUrl(options.path || '');
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(options.path || ''),
method: 'POST',
data: data,
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -186,3 +160,3 @@ validate.validateContentsModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -209,9 +183,9 @@ _this._fileChanged.emit({

var _this = this;
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
var url = this._getUrl(path);
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path),
method: 'DELETE'
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -230,3 +204,3 @@ _this._fileChanged.emit({

if (err.message) {
error.throwError = err.message;
error.message = err.message;
}

@@ -252,13 +226,12 @@ }

var _this = this;
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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path),
method: 'PATCH',
data: JSON.stringify({ path: newPath })
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -268,3 +241,3 @@ validate.validateContentsModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -297,15 +270,14 @@ _this._fileChanged.emit({

if (options === void 0) { options = {}; }
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PUT';
ajaxSettings.dataType = 'json';
ajaxSettings.data = JSON.stringify(options);
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
var url = this._getUrl(path);
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
var request = {
url: this._getUrl(path),
method: 'PUT',
cache: false,
data: JSON.stringify(options)
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
// will return 200 for an existing file and 201 for a new file
if (success.xhr.status !== 200 && success.xhr.status !== 201) {
throw utils.makeAjaxError(success);
if (response.xhr.status !== 200 && response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -315,3 +287,3 @@ validate.validateContentsModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -343,13 +315,12 @@ _this._fileChanged.emit({

var _this = this;
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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(toDir),
method: 'POST',
data: JSON.stringify({ copy_from: fromFile })
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -359,3 +330,3 @@ validate.validateContentsModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -382,17 +353,18 @@ _this._fileChanged.emit({

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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path, 'checkpoints'),
method: 'POST'
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
var data = response.data;
try {
validate.validateCheckpointModel(success.data);
validate.validateCheckpointModel(data);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
return success.data;
return data;
});

@@ -412,23 +384,23 @@ };

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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path, 'checkpoints'),
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
if (!Array.isArray(success.data)) {
throw utils.makeAjaxError(success, 'Invalid Checkpoint list');
if (!Array.isArray(response.data)) {
throw __1.ServerConnection.makeError(response, 'Invalid Checkpoint list');
}
for (var i = 0; i < success.data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
try {
validate.validateCheckpointModel(success.data[i]);
validate.validateCheckpointModel(response.data[i]);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
}
return success.data;
return response.data;
});

@@ -449,9 +421,9 @@ };

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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path, 'checkpoints', checkpointID),
method: 'POST'
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -473,9 +445,9 @@ });

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, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
var request = {
url: this._getUrl(path, 'checkpoints', checkpointID),
method: 'DELETE'
};
return __1.ServerConnection.makeRequest(request, this.serverSettings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -493,3 +465,4 @@ });

var parts = args.map(function (path) { return coreutils_1.URLExt.encodeParts(path); });
return coreutils_1.URLExt.join.apply(coreutils_1.URLExt, [this._baseUrl, SERVICE_CONTENTS_URL].concat(parts));
var baseUrl = this.serverSettings.baseUrl;
return coreutils_1.URLExt.join.apply(coreutils_1.URLExt, [baseUrl, SERVICE_CONTENTS_URL].concat(parts));
};

@@ -496,0 +469,0 @@ return ContentsManager;

@@ -7,7 +7,5 @@ import { Token } from '@phosphor/coreutils';

export * from './manager';
export * from './serverconnection';
export * from './session';
export * from './terminal';
export { IAjaxSettings } from './utils';
import * as utils from './utils';
export { utils };
/**

@@ -14,0 +12,0 @@ * The default services provider token.

@@ -13,6 +13,5 @@ "use strict";

__export(require("./manager"));
__export(require("./serverconnection"));
__export(require("./session"));
__export(require("./terminal"));
var utils = require("./utils");
exports.utils = utils;
/* tslint:disable */

@@ -19,0 +18,0 @@ /**

import { IDisposable } from '@phosphor/disposable';
import { ISignal, Signal } from '@phosphor/signaling';
import { ServerConnection } from '..';
import { Kernel } from './kernel';
import { KernelMessage } from './messages';
import { IAjaxSettings } from '../utils';
/**

@@ -19,2 +19,6 @@ * Implementation of the Kernel object

/**
* The server settings for the kernel.
*/
readonly serverSettings: ServerConnection.ISettings;
/**
* A signal emitted when the kernel status changes.

@@ -56,13 +60,2 @@ */

/**
* The base url of the kernel.
*/
readonly baseUrl: string;
/**
* Get a copy of the default ajax settings for the kernel.
*/
/**
* Set the default ajax settings for the kernel.
*/
ajaxSettings: IAjaxSettings;
/**
* Test whether the kernel has been disposed.

@@ -339,6 +332,3 @@ */

private _id;
private _token;
private _name;
private _baseUrl;
private _wsUrl;
private _status;

@@ -348,3 +338,2 @@ private _clientId;

private _username;
private _ajaxSettings;
private _reconnectLimit;

@@ -372,2 +361,8 @@ private _reconnectAttempt;

*
* @param id - The id of the kernel of interest.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the model for the kernel.
*
* #### Notes

@@ -377,3 +372,3 @@ * If the kernel was already started via `startNewKernel`, we return its

*
* Otherwise, if `options` are given, we attempt to find the existing
* Otherwise, we attempt to find to the existing
* kernel.

@@ -383,13 +378,21 @@ * The promise is fulfilled when the kernel is found,

*/
function findById(id: string, options?: Kernel.IOptions): Promise<Kernel.IModel>;
function findById(id: string, settings?: ServerConnection.ISettings): Promise<Kernel.IModel>;
/**
* Fetch all of the kernel specs.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
*/
function getSpecs(options?: Kernel.IOptions): Promise<Kernel.ISpecModels>;
function getSpecs(settings?: ServerConnection.ISettings): Promise<Kernel.ISpecModels>;
/**
* Fetch the running kernels.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the list of running kernels.
*
* #### Notes

@@ -400,6 +403,10 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*/
function listRunning(options?: Kernel.IOptions): Promise<Kernel.IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<Kernel.IModel[]>;
/**
* Start a new kernel.
*
* @param options - The options used to create the kernel.
*
* @returns A promise that resolves with a kernel object.
*
* #### Notes

@@ -418,2 +425,8 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves with the kernel object.
*
* #### Notes

@@ -431,7 +444,13 @@ * If the kernel was already started via `startNewKernel`, the existing

*/
function connectTo(id: string, options?: Kernel.IOptions): Promise<Kernel.IKernel>;
function connectTo(id: string, settings?: ServerConnection.ISettings): Promise<Kernel.IKernel>;
/**
* Shut down a kernel by id.
*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves when the kernel is shut down.
*/
function shutdown(id: string, options?: Kernel.IOptions): Promise<void>;
function shutdown(id: string, settings?: ServerConnection.ISettings): Promise<void>;
}

@@ -18,2 +18,3 @@ "use strict";

var signaling_1 = require("@phosphor/signaling");
var __1 = require("..");
var comm_1 = require("./comm");

@@ -24,3 +25,2 @@ var messages_1 = require("./messages");

var validate = require("./validate");
var utils = require("../utils");
/**

@@ -43,6 +43,3 @@ * The url for the kernel service.

this._id = '';
this._token = '';
this._name = '';
this._baseUrl = '';
this._wsUrl = '';
this._status = 'unknown';

@@ -52,3 +49,2 @@ this._clientId = '';

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

@@ -70,6 +66,3 @@ this._reconnectAttempt = 0;

this._id = id;
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl);
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, options.token));
this._token = options.token || utils.getConfigOption('token');
this.serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
this._clientId = options.clientId || coreutils_1.uuid();

@@ -174,28 +167,2 @@ this._username = options.username || '';

});
Object.defineProperty(DefaultKernel.prototype, "baseUrl", {
/**
* The base url of the kernel.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DefaultKernel.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(DefaultKernel.prototype, "isDisposed", {

@@ -254,7 +221,3 @@ /**

}
var options = {
baseUrl: this._baseUrl,
ajaxSettings: this.ajaxSettings
};
this._specPromise = Private.findSpecs(options).then(function (specs) {
this._specPromise = Private.findSpecs(this.serverSettings).then(function (specs) {
return specs.kernelspecs[_this._name];

@@ -268,11 +231,7 @@ });

DefaultKernel.prototype.clone = function () {
var options = {
baseUrl: this._baseUrl,
wsUrl: this._wsUrl,
return new DefaultKernel({
name: this._name,
username: this._username,
token: this._token,
ajaxSettings: this.ajaxSettings
};
return new DefaultKernel(options, this._id);
serverSettings: this.serverSettings
}, this._id);
};

@@ -355,3 +314,3 @@ /**

DefaultKernel.prototype.interrupt = function () {
return Private.interruptKernel(this, this._baseUrl, this.ajaxSettings);
return Private.interruptKernel(this, this.serverSettings);
};

@@ -376,3 +335,3 @@ /**

this._updateStatus('restarting');
return Private.restartKernel(this, this._baseUrl, this.ajaxSettings);
return Private.restartKernel(this, this.serverSettings);
};

@@ -421,3 +380,3 @@ /**

return this.ready.then(function () {
return Private.shutdownKernel(_this.id, _this._baseUrl, _this.ajaxSettings);
return Private.shutdownKernel(_this.id, _this.serverSettings);
});

@@ -677,3 +636,4 @@ };

var _this = this;
var partialUrl = coreutils_1.URLExt.join(this._wsUrl, KERNEL_SERVICE_URL, encodeURIComponent(this._id));
var settings = this.serverSettings;
var partialUrl = coreutils_1.URLExt.join(settings.wsUrl, KERNEL_SERVICE_URL, encodeURIComponent(this._id));
// Strip any authentication from the display string.

@@ -683,8 +643,9 @@ var parsed = coreutils_1.URLExt.parse(partialUrl);

var url = coreutils_1.URLExt.join(partialUrl, 'channels?session_id=' + encodeURIComponent(this._clientId));
// if token authentication is in use
if (this._token !== '') {
url = url + ("&token=" + encodeURIComponent(this._token));
// If token authentication is in use.
var token = settings.token;
if (token !== '') {
url = url + ("&token=" + encodeURIComponent(token));
}
this._connectionPromise = new coreutils_2.PromiseDelegate();
this._ws = new WebSocket(url);
this._ws = settings.wsFactory(url);
// Ensure incoming binary messages are not Blobs

@@ -852,3 +813,3 @@ this._ws.binaryType = 'arraybuffer';

var content = msg.content;
var promise = utils.loadObject(content.target_name, content.target_module, this._targetRegistry).then(function (target) {
var promise = Private.loadObject(content.target_name, content.target_module, this._targetRegistry).then(function (target) {
var comm = new comm_1.CommHandler(content.target_name, content.comm_id, _this, function () { _this._unregisterComm(content.comm_id); });

@@ -952,2 +913,8 @@ var response;

*
* @param id - The id of the kernel of interest.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the model for the kernel.
*
* #### Notes

@@ -957,3 +924,3 @@ * If the kernel was already started via `startNewKernel`, we return its

*
* Otherwise, if `options` are given, we attempt to find the existing
* Otherwise, we attempt to find to the existing
* kernel.

@@ -963,4 +930,4 @@ * The promise is fulfilled when the kernel is found,

*/
function findById(id, options) {
return Private.findById(id, options);
function findById(id, settings) {
return Private.findById(id, settings);
}

@@ -971,8 +938,11 @@ DefaultKernel.findById = findById;

*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
*/
function getSpecs(options) {
if (options === void 0) { options = {}; }
return Private.getSpecs(options);
function getSpecs(settings) {
return Private.getSpecs(settings);
}

@@ -983,2 +953,6 @@ DefaultKernel.getSpecs = getSpecs;

*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the list of running kernels.
*
* #### Notes

@@ -989,5 +963,4 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*/
function listRunning(options) {
if (options === void 0) { options = {}; }
return Private.listRunning(options);
function listRunning(settings) {
return Private.listRunning(settings);
}

@@ -998,2 +971,6 @@ DefaultKernel.listRunning = listRunning;

*
* @param options - The options used to create the kernel.
*
* @returns A promise that resolves with a kernel object.
*
* #### Notes

@@ -1009,3 +986,2 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

function startNew(options) {
options = options || {};
return Private.startNew(options);

@@ -1017,2 +993,8 @@ }

*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves with the kernel object.
*
* #### Notes

@@ -1030,4 +1012,4 @@ * If the kernel was already started via `startNewKernel`, the existing

*/
function connectTo(id, options) {
return Private.connectTo(id, options);
function connectTo(id, settings) {
return Private.connectTo(id, settings);
}

@@ -1037,6 +1019,11 @@ DefaultKernel.connectTo = connectTo;

* Shut down a kernel by id.
*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves when the kernel is shut down.
*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
return Private.shutdown(id, options);
function shutdown(id, settings) {
return Private.shutdownKernel(id, settings);
}

@@ -1062,3 +1049,3 @@ DefaultKernel.shutdown = shutdown;

*/
function findById(id, options) {
function findById(id, settings) {
var kernel = algorithm_1.find(Private.runningKernels, function (value) {

@@ -1070,3 +1057,3 @@ return (value.id === id);

}
return getKernelModel(id, options).catch(function () {
return getKernelModel(id, settings).catch(function () {
throw new Error("No running kernel with id: " + id);

@@ -1079,8 +1066,9 @@ });

*/
function findSpecs(options) {
var promise = Private.specs[options.baseUrl];
function findSpecs(settings) {
settings = settings || __1.ServerConnection.makeSettings();
var promise = Private.specs[settings.baseUrl];
if (promise) {
return promise;
}
return getSpecs(options);
return getSpecs(settings);
}

@@ -1094,21 +1082,21 @@ Private.findSpecs = findSpecs;

*/
function getSpecs(options) {
if (options === void 0) { options = {}; }
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, KERNELSPEC_SERVICE_URL);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
var promise = utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
function getSpecs(settings) {
settings = settings || __1.ServerConnection.makeSettings();
var request = {
url: coreutils_1.URLExt.join(settings.baseUrl, KERNELSPEC_SERVICE_URL),
method: 'GET',
cache: false
};
var promise = __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
try {
return validate.validateSpecModels(success.data);
return validate.validateSpecModels(response.data);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
});
Private.specs[baseUrl] = promise;
Private.specs[settings.baseUrl] = promise;
return promise;

@@ -1125,26 +1113,25 @@ }

*/
function listRunning(options) {
if (options === void 0) { options = {}; }
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
function listRunning(settings) {
settings = settings || __1.ServerConnection.makeSettings();
var request = {
url: coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL),
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
if (!Array.isArray(success.data)) {
throw utils.makeAjaxError(success, 'Invalid kernel list');
if (!Array.isArray(response.data)) {
throw __1.ServerConnection.makeError(response, 'Invalid kernel list');
}
for (var i = 0; i < success.data.length; i++) {
for (var i = 0; i < response.data.length; i++) {
try {
validate.validateModel(success.data[i]);
validate.validateModel(response.data[i]);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
}
return updateRunningKernels(success.data);
return updateRunningKernels(response.data);
}, onKernelError);

@@ -1176,19 +1163,16 @@ }

function startNew(options) {
options = options || {};
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'POST';
ajaxSettings.data = JSON.stringify({ name: options.name });
ajaxSettings.dataType = 'json';
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 201) {
throw utils.makeAjaxError(success);
if (options === void 0) { options = {}; }
var settings = options.serverSettings || __1.ServerConnection.makeSettings();
var request = {
url: coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL),
method: 'POST',
data: JSON.stringify({ name: options.name }),
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
validate.validateModel(success.data);
options = coreutils_2.JSONExt.deepCopy(options);
options.name = success.data.name;
return new DefaultKernel(options, success.data.id);
validate.validateModel(response.data);
return new DefaultKernel(__assign({}, options, { name: response.data.name, serverSettings: settings }), response.data.id);
}, onKernelError);

@@ -1212,3 +1196,4 @@ }

*/
function connectTo(id, options) {
function connectTo(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var kernel = algorithm_1.find(Private.runningKernels, function (value) {

@@ -1220,6 +1205,7 @@ return value.id === id;

}
return getKernelModel(id, options).then(function (model) {
options = coreutils_2.JSONExt.deepCopy(options);
options.name = model.name;
return new DefaultKernel(options, id);
return getKernelModel(id, settings).then(function (model) {
return new DefaultKernel({
name: model.name,
serverSettings: settings
}, id);
}).catch(function () {

@@ -1231,32 +1217,24 @@ throw new Error("No running kernel with id: " + id);

/**
* Shut down a kernel by id.
*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
var baseUrl = options.baseUrl || utils.getBaseUrl();
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
return shutdownKernel(id, baseUrl, ajaxSettings);
}
Private.shutdown = shutdown;
/**
* Restart a kernel.
*/
function restartKernel(kernel, baseUrl, ajaxSettings) {
function restartKernel(kernel, settings) {
if (kernel.status === 'dead') {
return Promise.reject(new Error('Kernel is dead'));
}
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(kernel.id), 'restart');
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
settings = settings || __1.ServerConnection.makeSettings();
var url = coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(kernel.id), 'restart');
var request = {
url: url,
method: 'POST',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
try {
validate.validateModel(success.data);
validate.validateModel(response.data);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -1269,14 +1247,16 @@ }, onKernelError);

*/
function interruptKernel(kernel, baseUrl, ajaxSettings) {
function interruptKernel(kernel, settings) {
if (kernel.status === 'dead') {
return Promise.reject(new Error('Kernel is dead'));
}
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(kernel.id), 'interrupt');
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
settings = settings || __1.ServerConnection.makeSettings();
var url = coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(kernel.id), 'interrupt');
var request = {
url: url,
method: 'POST',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -1289,11 +1269,13 @@ }, onKernelError);

*/
function shutdownKernel(id, baseUrl, ajaxSettings) {
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
ajaxSettings = ajaxSettings || {};
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
function shutdownKernel(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var url = coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
var request = {
url: url,
method: 'DELETE',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -1327,15 +1309,15 @@ killKernels(id);

*/
function getKernelModel(id, options) {
options = options || {};
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
function getKernelModel(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var url = coreutils_1.URLExt.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
var request = {
url: url,
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -1345,3 +1327,3 @@ validate.validateModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}

@@ -1371,3 +1353,3 @@ return data;

function onKernelError(error) {
var text = (error.throwError ||
var text = (error.message ||
error.xhr.statusText ||

@@ -1398,2 +1380,38 @@ error.xhr.responseText);

Private.handleShellMessage = handleShellMessage;
/**
* Try to load an object from a module or a registry.
*
* Try to load an object from a module asynchronously if a module
* is specified, otherwise tries to load an object from the global
* registry, if the global registry is provided.
*/
function loadObject(name, moduleName, registry) {
return new Promise(function (resolve, reject) {
// Try loading the view module using require.js
if (moduleName) {
if (typeof requirejs === 'undefined') {
throw new Error('requirejs not found');
}
requirejs([moduleName], function (mod) {
if (mod[name] === void 0) {
var msg = "Object '" + name + "' not found in module '" + moduleName + "'";
reject(new Error(msg));
}
else {
resolve(mod[name]);
}
}, reject);
}
else {
if (registry && registry[name]) {
resolve(registry[name]);
}
else {
reject(new Error("Object '" + name + "' not found in registry"));
}
}
});
}
Private.loadObject = loadObject;
;
})(Private || (Private = {}));

@@ -5,3 +5,3 @@ import { IIterator } from '@phosphor/algorithm';

import { ISignal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
import { KernelMessage } from './messages';

@@ -319,10 +319,6 @@ /**

/**
* The base url of the kernel.
* The server settings for the kernel.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* The Ajax settings used for server requests.
*/
ajaxSettings: IAjaxSettings;
/**
* Shutdown a kernel.

@@ -349,2 +345,8 @@ *

*
* @param id - The id of the kernel of interest.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the model for the kernel.
*
* #### Notes

@@ -354,3 +356,3 @@ * If the kernel was already started via `startNewKernel`, we return its

*
* Otherwise, if `options` are given, we attempt to find to the existing
* Otherwise, we attempt to find to the existing
* kernel.

@@ -360,13 +362,21 @@ * The promise is fulfilled when the kernel is found,

*/
function findById(id: string, options?: IOptions): Promise<IModel>;
function findById(id: string, settings?: ServerConnection.ISettings): Promise<IModel>;
/**
* Fetch all of the kernel specs.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
*/
function getSpecs(options?: Kernel.IOptions): Promise<Kernel.ISpecModels>;
function getSpecs(settings?: ServerConnection.ISettings): Promise<Kernel.ISpecModels>;
/**
* Fetch the running kernels.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the list of running kernels.
*
* #### Notes

@@ -377,6 +387,10 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*/
function listRunning(options?: Kernel.IOptions): Promise<Kernel.IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<Kernel.IModel[]>;
/**
* Start a new kernel.
*
* @param options - The options used to create the kernel.
*
* @returns A promise that resolves with a kernel object.
*
* #### Notes

@@ -395,2 +409,8 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves with the kernel object.
*
* #### Notes

@@ -408,13 +428,17 @@ * If the kernel was already started via `startNewKernel`, the existing

*/
function connectTo(id: string, options?: Kernel.IOptions): Promise<IKernel>;
function connectTo(id: string, settings?: ServerConnection.ISettings): Promise<IKernel>;
/**
* Shut down a kernel by id.
*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves when the kernel is shut down.
*/
function shutdown(id: string, options?: Kernel.IOptions): Promise<void>;
function shutdown(id: string, settings?: ServerConnection.ISettings): Promise<void>;
/**
* The interface of a kernel
/**
* The options object used to initialize a kernel.
*/
interface IOptions extends JSONObject {
interface IOptions {
/**

@@ -425,11 +449,6 @@ * The kernel type (e.g. python3).

/**
* The root url of the kernel server.
* Default is location.origin in browsers, notebook-server default otherwise.
* The server settings for the kernel.
*/
baseUrl?: string;
serverSettings?: ServerConnection.ISettings;
/**
* The url to access websockets, if different from baseUrl.
*/
wsUrl?: string;
/**
* The username of the kernel client.

@@ -442,10 +461,2 @@ */

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

@@ -469,14 +480,6 @@ /**

/**
* The base url of the manager.
* The server settings for the manager.
*/
readonly baseUrl: string;
serverSettings?: ServerConnection.ISettings;
/**
* The base ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
ajaxSettings?: IAjaxSettings;
/**
* The kernel spec models.

@@ -530,5 +533,3 @@ *

* #### Notes
* If options are given, the baseUrl and wsUrl will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The manager `serverSettings` will be always be used.
*/

@@ -545,16 +546,9 @@ startNew(options?: IOptions): Promise<IKernel>;

/**
* Connect to an existing kernel.
* Connect to an existing kernel.
*
* @param id - The id of the target kernel.
*
* @param options - The kernel options to use.
*
* @returns A promise that resolves with the new kernel instance.
*
* #### Notes
* If options are given, the baseUrl and wsUrl will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
*/
connectTo(id: string, options?: IOptions): Promise<IKernel>;
connectTo(id: string): Promise<IKernel>;
/**

@@ -561,0 +555,0 @@ * Shut down a kernel by id.

@@ -14,2 +14,8 @@ "use strict";

*
* @param id - The id of the kernel of interest.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the model for the kernel.
*
* #### Notes

@@ -19,3 +25,3 @@ * If the kernel was already started via `startNewKernel`, we return its

*
* Otherwise, if `options` are given, we attempt to find to the existing
* Otherwise, we attempt to find to the existing
* kernel.

@@ -25,4 +31,4 @@ * The promise is fulfilled when the kernel is found,

*/
function findById(id, options) {
return default_1.DefaultKernel.findById(id, options);
function findById(id, settings) {
return default_1.DefaultKernel.findById(id, settings);
}

@@ -33,8 +39,11 @@ Kernel.findById = findById;

*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernelspecs).
*/
function getSpecs(options) {
if (options === void 0) { options = {}; }
return default_1.DefaultKernel.getSpecs(options);
function getSpecs(settings) {
return default_1.DefaultKernel.getSpecs(settings);
}

@@ -45,2 +54,6 @@ Kernel.getSpecs = getSpecs;

*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the list of running kernels.
*
* #### Notes

@@ -51,5 +64,4 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*/
function listRunning(options) {
if (options === void 0) { options = {}; }
return default_1.DefaultKernel.listRunning(options);
function listRunning(settings) {
return default_1.DefaultKernel.listRunning(settings);
}

@@ -60,2 +72,6 @@ Kernel.listRunning = listRunning;

*
* @param options - The options used to create the kernel.
*
* @returns A promise that resolves with a kernel object.
*
* #### Notes

@@ -78,2 +94,8 @@ * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) and validates the response model.

*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves with the kernel object.
*
* #### Notes

@@ -91,4 +113,4 @@ * If the kernel was already started via `startNewKernel`, the existing

*/
function connectTo(id, options) {
return default_1.DefaultKernel.connectTo(id, options);
function connectTo(id, settings) {
return default_1.DefaultKernel.connectTo(id, settings);
}

@@ -98,8 +120,13 @@ Kernel.connectTo = connectTo;

* Shut down a kernel by id.
*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves when the kernel is shut down.
*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
return default_1.DefaultKernel.shutdown(id, options);
function shutdown(id, settings) {
return default_1.DefaultKernel.shutdown(id, settings);
}
Kernel.shutdown = shutdown;
})(Kernel = exports.Kernel || (exports.Kernel = {}));
import { IIterator } from '@phosphor/algorithm';
import { ISignal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
import { Kernel } from './kernel';

@@ -14,3 +14,3 @@ /**

*/
constructor(options?: Kernel.IOptions);
constructor(options?: KernelManager.IOptions);
/**

@@ -33,17 +33,6 @@ * A signal emitted when the specs change.

/**
* Get the base url of the manager.
* The server settings for the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* Get the ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
/**
* Set the default ajax settings for the manager.
*/
ajaxSettings: IAjaxSettings;
/**
* Get the most recently fetched kernel specs.

@@ -87,5 +76,10 @@ */

/**
* Start a new kernel. See also [[startNewKernel]].
* Start a new kernel.
*
* @param options - Overrides for the default options.
* @param options - The kernel options to use.
*
* @returns A promise that resolves with the kernel instance.
*
* #### Notes
* The manager `serverSettings` will be always be used.
*/

@@ -96,16 +90,22 @@ startNew(options?: Kernel.IOptions): Promise<Kernel.IKernel>;

*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves with the kernel's model.
*/
findById(id: string, options?: Kernel.IOptions): Promise<Kernel.IModel>;
findById(id: string): Promise<Kernel.IModel>;
/**
* Connect to a running kernel. See also [[connectToKernel]].
* Connect to an existing kernel.
*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves with the new kernel instance.
*/
connectTo(id: string, options?: Kernel.IOptions): Promise<Kernel.IKernel>;
connectTo(id: string): Promise<Kernel.IKernel>;
/**
* Shut down a kernel by id.
*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves when the operation is complete.
*
* #### Notes

@@ -115,3 +115,3 @@ * This will emit [[runningChanged]] if the running kernels list

*/
shutdown(id: string, options?: Kernel.IOptions): Promise<void>;
shutdown(id: string): Promise<void>;
/**

@@ -133,10 +133,2 @@ * Handle a kernel terminating.

private _refreshRunning();
/**
* Get optionally overidden options.
*/
private _getOptions(options?);
private _baseUrl;
private _wsUrl;
private _token;
private _ajaxSettings;
private _running;

@@ -152,1 +144,15 @@ private _specs;

}
/**
* The namespace for `KernelManager` class statics.
*/
export declare namespace KernelManager {
/**
* The options used to initialize a KernelManager.
*/
interface IOptions {
/**
* The server settings for the manager.
*/
serverSettings?: ServerConnection.ISettings;
}
}
"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,3 +16,3 @@ var algorithm_1 = require("@phosphor/algorithm");

var signaling_1 = require("@phosphor/signaling");
var utils = require("../utils");
var __1 = require("..");
var kernel_1 = require("./kernel");

@@ -23,6 +31,2 @@ /**

var _this = this;
this._baseUrl = '';
this._wsUrl = '';
this._token = '';
this._ajaxSettings = '';
this._running = [];

@@ -36,6 +40,3 @@ this._specs = null;

this._runningChanged = new signaling_1.Signal(this);
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl);
this._token = options.token || utils.getConfigOption('token');
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, options.token));
this.serverSettings = (options.serverSettings || __1.ServerConnection.makeSettings());
// Initialize internal data.

@@ -97,38 +98,2 @@ this._readyPromise = this._refreshSpecs().then(function () {

};
Object.defineProperty(KernelManager.prototype, "baseUrl", {
/**
* Get the base url of the manager.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KernelManager.prototype, "wsUrl", {
/**
* Get the ws url of the manager.
*/
get: function () {
return this._wsUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KernelManager.prototype, "ajaxSettings", {
/**
* The default ajax settings for the manager.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the manager.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(KernelManager.prototype, "specs", {

@@ -197,9 +162,16 @@ /**

/**
* Start a new kernel. See also [[startNewKernel]].
* Start a new kernel.
*
* @param options - Overrides for the default options.
* @param options - The kernel options to use.
*
* @returns A promise that resolves with the kernel instance.
*
* #### Notes
* The manager `serverSettings` will be always be used.
*/
KernelManager.prototype.startNew = function (options) {
var _this = this;
return kernel_1.Kernel.startNew(this._getOptions(options)).then(function (kernel) {
if (options === void 0) { options = {}; }
var newOptions = __assign({}, options, { serverSettings: this.serverSettings });
return kernel_1.Kernel.startNew(newOptions).then(function (kernel) {
_this._onStarted(kernel);

@@ -212,15 +184,19 @@ return kernel;

*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves with the kernel's model.
*/
KernelManager.prototype.findById = function (id, options) {
return kernel_1.Kernel.findById(id, this._getOptions(options));
KernelManager.prototype.findById = function (id) {
return kernel_1.Kernel.findById(id, this.serverSettings);
};
/**
* Connect to a running kernel. See also [[connectToKernel]].
* Connect to an existing kernel.
*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves with the new kernel instance.
*/
KernelManager.prototype.connectTo = function (id, options) {
KernelManager.prototype.connectTo = function (id) {
var _this = this;
return kernel_1.Kernel.connectTo(id, this._getOptions(options)).then(function (kernel) {
return kernel_1.Kernel.connectTo(id, this.serverSettings).then(function (kernel) {
_this._onStarted(kernel);

@@ -233,4 +209,6 @@ return kernel;

*
* @param options - Overrides for the default options.
* @param id - The id of the target kernel.
*
* @returns A promise that resolves when the operation is complete.
*
* #### Notes

@@ -240,5 +218,5 @@ * This will emit [[runningChanged]] if the running kernels list

*/
KernelManager.prototype.shutdown = function (id, options) {
KernelManager.prototype.shutdown = function (id) {
var _this = this;
return kernel_1.Kernel.shutdown(id, this._getOptions(options)).then(function () {
return kernel_1.Kernel.shutdown(id, this.serverSettings).then(function () {
_this._onTerminated(id);

@@ -277,8 +255,3 @@ });

var _this = this;
var options = {
baseUrl: this._baseUrl,
token: this._token,
ajaxSettings: this.ajaxSettings
};
return kernel_1.Kernel.getSpecs(options).then(function (specs) {
return kernel_1.Kernel.getSpecs(this.serverSettings).then(function (specs) {
if (!coreutils_1.JSONExt.deepEqual(specs, _this._specs)) {

@@ -295,3 +268,3 @@ _this._specs = specs;

var _this = this;
return kernel_1.Kernel.listRunning(this._getOptions({})).then(function (running) {
return kernel_1.Kernel.listRunning(this.serverSettings).then(function (running) {
_this._isReady = true;

@@ -304,15 +277,4 @@ if (!coreutils_1.JSONExt.deepEqual(running, _this._running)) {

};
/**
* Get optionally overidden options.
*/
KernelManager.prototype._getOptions = function (options) {
if (options === void 0) { options = {}; }
options.baseUrl = this._baseUrl || '';
options.wsUrl = this._wsUrl || '';
options.token = this._token || '';
options.ajaxSettings = options.ajaxSettings || this.ajaxSettings;
return options;
};
return KernelManager;
}());
exports.KernelManager = KernelManager;

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

import { JSONObject } from '@phosphor/coreutils';
import { IDisposable } from '@phosphor/disposable';

@@ -8,3 +7,3 @@ import { ISignal } from '@phosphor/signaling';

import { TerminalSession, TerminalManager } from './terminal';
import { IAjaxSettings } from './utils';
import { ServerConnection } from './serverconnection';
/**

@@ -35,5 +34,5 @@ * A Jupyter services manager.

/**
* Get the base url of the server.
* The server settings of the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**

@@ -83,5 +82,5 @@ * Get the session manager instance.

/**
* The base url of the manager.
* The server settings of the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**

@@ -111,20 +110,8 @@ * The session manager for the manager.

*/
interface IOptions extends JSONObject {
interface IOptions {
/**
* The base url of the server.
* The server settings of the manager.
*/
baseUrl?: string;
/**
* The base ws url of the server.
*/
wsUrl?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The ajax settings for the manager.
*/
ajaxSettings?: IAjaxSettings;
readonly serverSettings?: ServerConnection.ISettings;
}
}

@@ -9,3 +9,3 @@ "use strict";

var terminal_1 = require("./terminal");
var utils_1 = require("./utils");
var serverconnection_1 = require("./serverconnection");
/**

@@ -19,2 +19,3 @@ * A Jupyter services manager.

function ServiceManager(options) {
if (options === void 0) { options = {}; }
var _this = this;

@@ -26,6 +27,3 @@ this._sessionManager = null;

this._specsChanged = new signaling_1.Signal(this);
options = options || {};
options.wsUrl = options.wsUrl || utils_1.getWsUrl();
options.baseUrl = options.baseUrl || utils_1.getBaseUrl();
options.ajaxSettings = utils_1.ajaxSettingsWithToken(options.ajaxSettings, options.token);
this.serverSettings = (options.serverSettings || serverconnection_1.ServerConnection.makeSettings());
this._sessionManager = new session_1.SessionManager(options);

@@ -86,12 +84,2 @@ this._contentsManager = new contents_1.ContentsManager(options);

});
Object.defineProperty(ServiceManager.prototype, "baseUrl", {
/**
* Get the base url of the server.
*/
get: function () {
return this._sessionManager.baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ServiceManager.prototype, "sessions", {

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

import { ISignal, Signal } from '@phosphor/signaling';
import { Kernel, KernelMessage } from '../kernel';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
import { Session } from './session';

@@ -68,13 +68,6 @@ /**

/**
* Get the base url of the session.
* The server settings of the session.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* Get a copy of the default ajax settings for the session.
*/
/**
* Set the default ajax settings for the session.
*/
ajaxSettings: IAjaxSettings;
/**
* Test whether the session has been disposed.

@@ -142,6 +135,2 @@ */

/**
* Get the options used to create a new kernel.
*/
private _getKernelOptions();
/**
* Send a PATCH to the server, updating the session path or the kernel.

@@ -152,8 +141,5 @@ */

private _path;
private _ajaxSettings;
private _token;
private _kernel;
private _uuid;
private _baseUrl;
private _options;
private _isDisposed;
private _updating;

@@ -173,3 +159,3 @@ private _kernelChanged;

*/
function listRunning(options?: Session.IOptions): Promise<Session.IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<Session.IModel[]>;
/**

@@ -182,15 +168,15 @@ * Start a new session.

*/
function findById(id: string, options?: Session.IOptions): Promise<Session.IModel>;
function findById(id: string, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**
* Find a session by path.
*/
function findByPath(path: string, options?: Session.IOptions): Promise<Session.IModel>;
function findByPath(path: string, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**
* Connect to a running session.
*/
function connectTo(id: string, options?: Session.IOptions): Promise<Session.ISession>;
function connectTo(id: string, settings?: ServerConnection.ISettings): Promise<Session.ISession>;
/**
* Shut down a session by id.
*/
function shutdown(id: string, options?: Session.IOptions): Promise<void>;
function shutdown(id: string, settings?: ServerConnection.ISettings): Promise<void>;
}

@@ -7,6 +7,5 @@ "use strict";

var algorithm_1 = require("@phosphor/algorithm");
var coreutils_2 = require("@phosphor/coreutils");
var signaling_1 = require("@phosphor/signaling");
var kernel_1 = require("../kernel");
var utils = require("../utils");
var __1 = require("..");
var validate = require("./validate");

@@ -29,8 +28,5 @@ /**

this._path = '';
this._ajaxSettings = '';
this._token = '';
this._kernel = null;
this._uuid = '';
this._baseUrl = '';
this._options = null;
this._isDisposed = false;
this._updating = false;

@@ -44,9 +40,6 @@ this._kernelChanged = new signaling_1.Signal(this);

this._path = options.path;
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this.serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
this._uuid = coreutils_1.uuid();
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings || {}, options.token));
this._token = options.token || utils.getConfigOption('token');
Private.runningSessions.push(this);
Private.addRunning(this);
this.setupKernel(kernel);
this._options = coreutils_2.JSONExt.deepCopy(options);
this.terminated = new signaling_1.Signal(this);

@@ -168,28 +161,2 @@ }

});
Object.defineProperty(DefaultSession.prototype, "baseUrl", {
/**
* Get the base url of the session.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DefaultSession.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(DefaultSession.prototype, "isDisposed", {

@@ -200,3 +167,3 @@ /**

get: function () {
return this._options === null;
return this._isDisposed === true;
},

@@ -211,7 +178,7 @@ enumerable: true,

var _this = this;
var options = this._getKernelOptions();
return kernel_1.Kernel.connectTo(this.kernel.id, options).then(function (kernel) {
options = coreutils_2.JSONExt.deepCopy(_this._options);
options.ajaxSettings = _this.ajaxSettings;
return new DefaultSession(options, _this._id, kernel);
return kernel_1.Kernel.connectTo(this.kernel.id, this.serverSettings).then(function (kernel) {
return new DefaultSession({
path: _this._path,
serverSettings: _this.serverSettings
}, _this._id, kernel);
});

@@ -231,5 +198,3 @@ };

if (this._kernel.isDisposed || model.kernel.id !== this._kernel.id) {
var options = this._getKernelOptions();
options.name = model.kernel.name;
return kernel_1.Kernel.connectTo(model.kernel.id, options).then(function (kernel) {
return kernel_1.Kernel.connectTo(model.kernel.id, this.serverSettings).then(function (kernel) {
_this.setupKernel(kernel);

@@ -254,7 +219,7 @@ _this._kernelChanged.emit(kernel);

}
this._options = null;
this._isDisposed = true;
if (this._kernel) {
this._kernel.dispose();
}
algorithm_1.ArrayExt.removeFirstOf(Private.runningSessions, this);
Private.removeRunning(this);
this._kernel = null;

@@ -320,6 +285,6 @@ signaling_1.Signal.clearData(this);

return this._kernel.ready.then(function () {
return Private.shutdownSession(_this.id, _this._baseUrl, _this.ajaxSettings);
return Private.shutdownSession(_this.id, _this.serverSettings);
});
}
return Private.shutdownSession(this.id, this._baseUrl, this.ajaxSettings);
return Private.shutdownSession(this.id, this.serverSettings);
};

@@ -354,13 +319,2 @@ /**

/**
* Get the options used to create a new kernel.
*/
DefaultSession.prototype._getKernelOptions = function () {
return {
baseUrl: this._options.baseUrl || '',
wsUrl: this._options.wsUrl || '',
username: this.kernel.username,
ajaxSettings: this.ajaxSettings
};
};
/**
* Send a PATCH to the server, updating the session path or the kernel.

@@ -370,16 +324,16 @@ */

var _this = this;
var url = Private.getSessionUrl(this._baseUrl, this._id);
var ajaxSettings = this.ajaxSettings;
ajaxSettings.method = 'PATCH';
ajaxSettings.dataType = 'json';
ajaxSettings.data = data;
ajaxSettings.contentType = 'application/json';
ajaxSettings.cache = false;
this._updating = true;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
var settings = this.serverSettings;
var request = {
url: Private.getSessionUrl(settings.baseUrl, this._id),
method: 'PATCH',
data: data,
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
_this._updating = false;
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var value = success.data;
var value = response.data;
try {

@@ -389,5 +343,5 @@ validate.validateModel(value);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
return Private.updateFromServer(value);
return Private.updateFromServer(value, settings.baseUrl);
}, function (error) {

@@ -408,4 +362,4 @@ _this._updating = false;

*/
function listRunning(options) {
return Private.listRunning(options);
function listRunning(settings) {
return Private.listRunning(settings);
}

@@ -423,4 +377,4 @@ DefaultSession.listRunning = listRunning;

*/
function findById(id, options) {
return Private.findById(id, options);
function findById(id, settings) {
return Private.findById(id, settings);
}

@@ -431,4 +385,4 @@ DefaultSession.findById = findById;

*/
function findByPath(path, options) {
return Private.findByPath(path, options);
function findByPath(path, settings) {
return Private.findByPath(path, settings);
}

@@ -439,4 +393,4 @@ DefaultSession.findByPath = findByPath;

*/
function connectTo(id, options) {
return Private.connectTo(id, options);
function connectTo(id, settings) {
return Private.connectTo(id, settings);
}

@@ -447,5 +401,4 @@ DefaultSession.connectTo = connectTo;

*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
return Private.shutdown(id, options);
function shutdown(id, settings) {
return Private.shutdownSession(id, settings);
}

@@ -461,16 +414,34 @@ DefaultSession.shutdown = shutdown;

/**
* The running sessions.
* The running sessions mapped by base url.
*/
Private.runningSessions = [];
var runningSessions = new Map();
/**
* Add a session to the running sessions.
*/
function addRunning(session) {
var running = (runningSessions.get(session.serverSettings.baseUrl) || []);
running.push(session);
runningSessions.set(session.serverSettings.baseUrl, running);
}
Private.addRunning = addRunning;
/**
* Remove a session from the running sessions.
*/
function removeRunning(session) {
var running = runningSessions.get(session.serverSettings.baseUrl);
algorithm_1.ArrayExt.removeFirstOf(running, session);
}
Private.removeRunning = removeRunning;
/**
* Connect to a running session.
*/
function connectTo(id, options) {
if (options === void 0) { options = {}; }
var session = algorithm_1.find(Private.runningSessions, function (value) { return value.id === id; });
function connectTo(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var running = runningSessions.get(settings.baseUrl) || [];
var session = algorithm_1.find(running, function (value) { return value.id === id; });
if (session) {
return Promise.resolve(session.clone());
}
return getSessionModel(id, options).then(function (model) {
return createSession(model, options);
return getSessionModel(id, settings).then(function (model) {
return createSession(model, settings);
}).catch(function () {

@@ -483,17 +454,2 @@ var msg = "No running session with id: " + id;

/**
* Create a Promise for a kernel object given a session model and options.
*/
function createKernel(options) {
var kernelOptions = {
name: options.kernelName || '',
baseUrl: options.baseUrl || utils.getBaseUrl(),
wsUrl: options.wsUrl || '',
username: options.username || '',
clientId: options.clientId || '',
token: options.token || '',
ajaxSettings: options.ajaxSettings || {}
};
return kernel_1.Kernel.connectTo(options.kernelId, kernelOptions);
}
/**
* Create a Session object.

@@ -504,7 +460,8 @@ *

function createSession(model, options) {
options.kernelName = model.kernel.name;
options.kernelId = model.kernel.id;
options.path = model.notebook.path;
return createKernel(options).then(function (kernel) {
return new DefaultSession(options, model.id, kernel);
var settings = options.serverSettings || __1.ServerConnection.makeSettings();
return kernel_1.Kernel.connectTo(model.kernel.id, settings).then(function (kernel) {
return new DefaultSession({
path: model.notebook.path,
serverSettings: settings
}, model.id, kernel);
}).catch(function (error) {

@@ -518,9 +475,10 @@ return typedThrow('Session failed to start: ' + error.message);

*/
function findById(id, options) {
if (options === void 0) { options = {}; }
var session = algorithm_1.find(Private.runningSessions, function (value) { return value.id === id; });
function findById(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var running = runningSessions.get(settings.baseUrl) || [];
var session = algorithm_1.find(running, function (value) { return value.id === id; });
if (session) {
return Promise.resolve(session.model);
}
return getSessionModel(id, options).catch(function () {
return getSessionModel(id, settings).catch(function () {
var msg = "No running session for id: " + id;

@@ -534,9 +492,10 @@ return typedThrow(msg);

*/
function findByPath(path, options) {
if (options === void 0) { options = {}; }
var session = algorithm_1.find(Private.runningSessions, function (value) { return value.path === path; });
function findByPath(path, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var running = runningSessions.get(settings.baseUrl) || [];
var session = algorithm_1.find(running, function (value) { return value.path === path; });
if (session) {
return Promise.resolve(session.model);
}
return listRunning(options).then(function (models) {
return listRunning(settings).then(function (models) {
var model = algorithm_1.find(models, function (value) {

@@ -556,15 +515,14 @@ return value.notebook.path === path;

*/
function getSessionModel(id, options) {
options = options || {};
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = getSessionUrl(baseUrl, id);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
function getSessionModel(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var request = {
url: getSessionUrl(settings.baseUrl, id),
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
try {

@@ -574,5 +532,5 @@ validate.validateModel(data);

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
return updateFromServer(data);
return updateFromServer(data, settings.baseUrl);
}, Private.onSessionError);

@@ -591,4 +549,5 @@ }

*/
function killSessions(id) {
algorithm_1.each(algorithm_1.toArray(Private.runningSessions), function (session) {
function killSessions(id, baseUrl) {
var running = runningSessions.get(baseUrl) || [];
algorithm_1.each(running.slice(), function (session) {
if (session.id === id) {

@@ -603,17 +562,16 @@ session.terminated.emit(void 0);

*/
function listRunning(options) {
if (options === void 0) { options = {}; }
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, SESSION_SERVICE_URL);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
function listRunning(settings) {
settings = settings || __1.ServerConnection.makeSettings();
var request = {
url: coreutils_1.URLExt.join(settings.baseUrl, SESSION_SERVICE_URL),
method: 'GET',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
if (!Array.isArray(success.data)) {
throw utils.makeAjaxError(success, 'Invalid Session list');
var data = response.data;
if (!Array.isArray(response.data)) {
throw __1.ServerConnection.makeError(response, 'Invalid Session list');
}

@@ -625,6 +583,6 @@ for (var i = 0; i < data.length; i++) {

catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
}
return updateRunningSessions(data);
return updateRunningSessions(data, settings.baseUrl);
}, Private.onSessionError);

@@ -637,3 +595,3 @@ }

function onSessionError(error) {
var text = (error.throwError ||
var text = (error.message ||
error.xhr.statusText ||

@@ -649,23 +607,14 @@ error.xhr.responseText);

*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
var baseUrl = options.baseUrl || utils.getBaseUrl();
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
return shutdownSession(id, baseUrl, ajaxSettings);
}
Private.shutdown = shutdown;
/**
* Shut down a session by id.
*/
function shutdownSession(id, baseUrl, ajaxSettings) {
if (ajaxSettings === void 0) { ajaxSettings = {}; }
var url = getSessionUrl(baseUrl, id);
ajaxSettings.method = 'DELETE';
ajaxSettings.dataType = 'json';
ajaxSettings.cache = false;
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
function shutdownSession(id, settings) {
settings = settings || __1.ServerConnection.makeSettings();
var request = {
url: getSessionUrl(settings.baseUrl, id),
method: 'DELETE',
cache: false
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}
killSessions(id);
killSessions(id, settings.baseUrl);
}, function (err) {

@@ -675,7 +624,7 @@ if (err.xhr.status === 404) {

console.warn(response['message']);
killSessions(id);
killSessions(id, settings.baseUrl);
return;
}
if (err.xhr.status === 410) {
err.throwError = 'The kernel was deleted but the session was not';
err.message = 'The kernel was deleted but the session was not';
}

@@ -703,4 +652,3 @@ return onSessionError(err);

function startSession(options) {
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = coreutils_1.URLExt.join(baseUrl, SESSION_SERVICE_URL);
var settings = options.serverSettings || __1.ServerConnection.makeSettings();
var model = {

@@ -710,20 +658,20 @@ kernel: { name: options.kernelName, id: options.kernelId },

};
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
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) {
throw utils.makeAjaxError(success);
var request = {
url: coreutils_1.URLExt.join(settings.baseUrl, SESSION_SERVICE_URL),
method: 'POST',
cache: false,
data: JSON.stringify(model)
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 201) {
throw __1.ServerConnection.makeError(response);
}
try {
validate.validateModel(success.data);
validate.validateModel(response.data);
}
catch (err) {
throw utils.makeAjaxError(success, err.message);
throw __1.ServerConnection.makeError(response, err.message);
}
var data = success.data;
return updateFromServer(data);
var data = response.data;
return updateFromServer(data, settings.baseUrl);
}, onSessionError);

@@ -742,5 +690,6 @@ }

*/
function updateFromServer(model) {
function updateFromServer(model, baseUrl) {
var promises = [];
algorithm_1.each(Private.runningSessions, function (session) {
var running = runningSessions.get(baseUrl) || [];
algorithm_1.each(running.slice(), function (session) {
if (session.id === model.id) {

@@ -756,5 +705,6 @@ promises.push(session.update(model));

*/
function updateRunningSessions(sessions) {
function updateRunningSessions(sessions, baseUrl) {
var promises = [];
algorithm_1.each(Private.runningSessions, function (session) {
var running = runningSessions.get(baseUrl) || [];
algorithm_1.each(running.slice(), function (session) {
var updated = algorithm_1.find(sessions, function (sId) {

@@ -761,0 +711,0 @@ if (session.id === sId.id) {

import { IIterator } from '@phosphor/algorithm';
import { ISignal } from '@phosphor/signaling';
import { Kernel } from '../kernel';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
import { Session } from './session';

@@ -29,14 +29,6 @@ /**

/**
* The base url of the manager.
* The server settings of the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* The base ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
ajaxSettings: IAjaxSettings;
/**
* Get the most recently fetched kernel specs.

@@ -102,17 +94,13 @@ */

*/
findById(id: string, options?: Session.IOptions): Promise<Session.IModel>;
findById(id: string): Promise<Session.IModel>;
/**
* Find a session by path.
*/
findByPath(path: string, options?: Session.IOptions): Promise<Session.IModel>;
connectTo(id: string, options?: Session.IOptions): Promise<Session.ISession>;
findByPath(path: string): Promise<Session.IModel>;
connectTo(id: string): Promise<Session.ISession>;
/**
* Shut down a session by id.
*/
shutdown(id: string, options?: Session.IOptions): Promise<void>;
shutdown(id: string): Promise<void>;
/**
* Get optionally overidden options.
*/
private _getOptions(options?);
/**
* Handle a session terminating.

@@ -137,5 +125,2 @@ */

private _refreshRunning();
private _baseUrl;
private _wsUrl;
private _ajaxSettings;
private _isDisposed;

@@ -142,0 +127,0 @@ private _running;

"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,3 +17,3 @@ var algorithm_1 = require("@phosphor/algorithm");

var kernel_1 = require("../kernel");
var utils = require("../utils");
var __1 = require("..");
var session_1 = require("./session");

@@ -24,5 +32,2 @@ /**

var _this = this;
this._baseUrl = '';
this._wsUrl = '';
this._ajaxSettings = '';
this._isDisposed = false;

@@ -35,5 +40,3 @@ this._running = [];

this._runningChanged = new signaling_1.Signal(this);
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl);
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {});
this.serverSettings = (options.serverSettings || __1.ServerConnection.makeSettings());
// Initialize internal data.

@@ -81,35 +84,2 @@ this._readyPromise = this._refreshSpecs().then(function () {

});
Object.defineProperty(SessionManager.prototype, "baseUrl", {
/**
* The base url of the manager.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SessionManager.prototype, "wsUrl", {
/**
* The base ws url of the manager.
*/
get: function () {
return this._wsUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SessionManager.prototype, "ajaxSettings", {
/**
* The default ajax settings for the manager.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(SessionManager.prototype, "specs", {

@@ -198,3 +168,4 @@ /**

var _this = this;
return session_1.Session.startNew(this._getOptions(options)).then(function (session) {
var serverSettings = this.serverSettings;
return session_1.Session.startNew(__assign({}, options, { serverSettings: serverSettings })).then(function (session) {
_this._onStarted(session);

@@ -214,3 +185,3 @@ return session;

var _this = this;
return session_1.Session.listRunning().then(function (sessions) {
return session_1.Session.listRunning(this.serverSettings).then(function (sessions) {
var matches = sessions.filter(function (value) { return value.notebook.path === path; });

@@ -226,4 +197,4 @@ if (matches.length === 1) {

*/
SessionManager.prototype.findById = function (id, options) {
return session_1.Session.findById(id, this._getOptions(options));
SessionManager.prototype.findById = function (id) {
return session_1.Session.findById(id, this.serverSettings);
};

@@ -233,4 +204,4 @@ /**

*/
SessionManager.prototype.findByPath = function (path, options) {
return session_1.Session.findByPath(path, this._getOptions(options));
SessionManager.prototype.findByPath = function (path) {
return session_1.Session.findByPath(path, this.serverSettings);
};

@@ -240,5 +211,5 @@ /*

*/
SessionManager.prototype.connectTo = function (id, options) {
SessionManager.prototype.connectTo = function (id) {
var _this = this;
return session_1.Session.connectTo(id, this._getOptions(options)).then(function (session) {
return session_1.Session.connectTo(id, this.serverSettings).then(function (session) {
_this._onStarted(session);

@@ -251,5 +222,5 @@ return session;

*/
SessionManager.prototype.shutdown = function (id, options) {
SessionManager.prototype.shutdown = function (id) {
var _this = this;
return session_1.Session.shutdown(id, this._getOptions(options)).then(function () {
return session_1.Session.shutdown(id, this.serverSettings).then(function () {
_this._onTerminated(id);

@@ -259,12 +230,2 @@ });

/**
* Get optionally overidden options.
*/
SessionManager.prototype._getOptions = function (options) {
if (options === void 0) { options = {}; }
options.baseUrl = this._baseUrl;
options.wsUrl = this._wsUrl;
options.ajaxSettings = options.ajaxSettings || this.ajaxSettings;
return options;
};
/**
* Handle a session terminating.

@@ -315,7 +276,3 @@ */

var _this = this;
var options = {
baseUrl: this._baseUrl,
ajaxSettings: this.ajaxSettings
};
return kernel_1.Kernel.getSpecs(options).then(function (specs) {
return kernel_1.Kernel.getSpecs(this.serverSettings).then(function (specs) {
if (!coreutils_1.JSONExt.deepEqual(specs, _this._specs)) {

@@ -332,3 +289,3 @@ _this._specs = specs;

var _this = this;
return session_1.Session.listRunning(this._getOptions({})).then(function (running) {
return session_1.Session.listRunning(this.serverSettings).then(function (running) {
if (!coreutils_1.JSONExt.deepEqual(running, _this._running)) {

@@ -335,0 +292,0 @@ _this._running = running.slice();

@@ -6,3 +6,3 @@ import { IIterator } from '@phosphor/algorithm';

import { Kernel, KernelMessage } from '../kernel';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
/**

@@ -49,5 +49,5 @@ * A namespace for session interfaces and factory functions.

/**
* The base url of the session.
* The server settings of the session.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**

@@ -72,6 +72,2 @@ * The model associated with the session.

/**
* Optional default settings for ajax requests, if applicable.
*/
ajaxSettings?: IAjaxSettings;
/**
* Change the session path.

@@ -114,3 +110,3 @@ *

*
* @param options - The options used for the request.
* @param settings - The server settings to use for the request.
*

@@ -126,3 +122,3 @@ * @returns A promise that resolves with the list of session models.

*/
function listRunning(options?: Session.IOptions): Promise<Session.IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<Session.IModel[]>;
/**

@@ -154,3 +150,3 @@ * Start a new session.

*
* @param options - The options used to fetch the session.
* @param settings - The server settings.
*

@@ -163,8 +159,7 @@ * @returns A promise that resolves with the session model.

*
* Otherwise, if `options` are given, we attempt to find to the existing
* session.
* Otherwise, we attempt to find to the existing session.
* The promise is fulfilled when the session is found,
* otherwise the promise is rejected.
*/
function findById(id: string, options?: Session.IOptions): Promise<Session.IModel>;
function findById(id: string, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**

@@ -175,3 +170,3 @@ * Find a session by path.

*
* @param options - The options used to fetch the session.
* @param settings: The server settings.
*

@@ -184,3 +179,3 @@ * @returns A promise that resolves with the session model.

*
* Otherwise, if `options` are given, we attempt to find to the existing
* Otherwise, we attempt to find to the existing
* session using [listRunningSessions].

@@ -193,3 +188,3 @@ * The promise is fulfilled when the session is found,

*/
function findByPath(path: string, options?: Session.IOptions): Promise<Session.IModel>;
function findByPath(path: string, settings?: ServerConnection.ISettings): Promise<Session.IModel>;
/**

@@ -200,3 +195,3 @@ * Connect to a running session.

*
* @param options - The options used to fetch the session.
* @param settigns - The server settings.
*

@@ -209,4 +204,3 @@ * @returns A promise that resolves with the session instance.

*
* Otherwise, if `options` are given, we attempt to connect to the existing
* session.
* Otherwise, we attempt to connect to the existing session.
* The promise is fulfilled when the session is ready on the server,

@@ -218,3 +212,3 @@ * otherwise the promise is rejected.

*/
function connectTo(id: string, options?: Session.IOptions): Promise<ISession>;
function connectTo(id: string, settings?: ServerConnection.ISettings): Promise<ISession>;
/**

@@ -225,3 +219,3 @@ * Shut down a session by id.

*
* @param options - The options used to fetch the session.
* @param settings - The server settings.
*

@@ -231,7 +225,7 @@ * @returns A promise that resolves when the session is shut down.

*/
function shutdown(id: string, options?: Session.IOptions): Promise<void>;
function shutdown(id: string, settings?: ServerConnection.ISettings): Promise<void>;
/**
* The session initialization options.
*/
interface IOptions extends JSONObject {
interface IOptions {
/**

@@ -250,10 +244,6 @@ * The path (not including name) to the session.

/**
* The root url of the server.
* The server settings.
*/
baseUrl?: string;
serverSettings?: ServerConnection.ISettings;
/**
* The url to access websockets.
*/
wsUrl?: string;
/**
* The username of the session client.

@@ -266,10 +256,2 @@ */

clientId?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The default ajax settings to use for the session.
*/
ajaxSettings?: IAjaxSettings;
}

@@ -293,14 +275,6 @@ /**

/**
* The base url of the manager.
* The server settings for the manager.
*/
readonly baseUrl: string;
serverSettings?: ServerConnection.ISettings;
/**
* The base ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
ajaxSettings?: IAjaxSettings;
/**
* The cached kernel specs.

@@ -334,5 +308,3 @@ *

* #### Notes
* The baseUrl and wsUrl of the options will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The `serverSettings` of the manager will be used.
*/

@@ -364,9 +336,4 @@ startNew(options: IOptions): Promise<ISession>;

* @returns A promise that resolves with the new session instance.
*
* #### Notes
* If options are given, the baseUrl and wsUrl will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
*/
connectTo(id: string, options?: IOptions): Promise<ISession>;
connectTo(id: string): Promise<ISession>;
/**

@@ -373,0 +340,0 @@ * Shut down a session by id.

@@ -14,3 +14,3 @@ "use strict";

*
* @param options - The options used for the request.
* @param settings - The server settings to use for the request.
*

@@ -26,4 +26,4 @@ * @returns A promise that resolves with the list of session models.

*/
function listRunning(options) {
return default_1.DefaultSession.listRunning(options);
function listRunning(settings) {
return default_1.DefaultSession.listRunning(settings);
}

@@ -60,3 +60,3 @@ Session.listRunning = listRunning;

*
* @param options - The options used to fetch the session.
* @param settings - The server settings.
*

@@ -69,9 +69,8 @@ * @returns A promise that resolves with the session model.

*
* Otherwise, if `options` are given, we attempt to find to the existing
* session.
* Otherwise, we attempt to find to the existing session.
* The promise is fulfilled when the session is found,
* otherwise the promise is rejected.
*/
function findById(id, options) {
return default_1.DefaultSession.findById(id, options);
function findById(id, settings) {
return default_1.DefaultSession.findById(id, settings);
}

@@ -84,3 +83,3 @@ Session.findById = findById;

*
* @param options - The options used to fetch the session.
* @param settings: The server settings.
*

@@ -93,3 +92,3 @@ * @returns A promise that resolves with the session model.

*
* Otherwise, if `options` are given, we attempt to find to the existing
* Otherwise, we attempt to find to the existing
* session using [listRunningSessions].

@@ -102,4 +101,4 @@ * The promise is fulfilled when the session is found,

*/
function findByPath(path, options) {
return default_1.DefaultSession.findByPath(path, options);
function findByPath(path, settings) {
return default_1.DefaultSession.findByPath(path, settings);
}

@@ -112,3 +111,3 @@ Session.findByPath = findByPath;

*
* @param options - The options used to fetch the session.
* @param settigns - The server settings.
*

@@ -121,4 +120,3 @@ * @returns A promise that resolves with the session instance.

*
* Otherwise, if `options` are given, we attempt to connect to the existing
* session.
* Otherwise, we attempt to connect to the existing session.
* The promise is fulfilled when the session is ready on the server,

@@ -130,4 +128,4 @@ * otherwise the promise is rejected.

*/
function connectTo(id, options) {
return default_1.DefaultSession.connectTo(id, options);
function connectTo(id, settings) {
return default_1.DefaultSession.connectTo(id, settings);
}

@@ -140,3 +138,3 @@ Session.connectTo = connectTo;

*
* @param options - The options used to fetch the session.
* @param settings - The server settings.
*

@@ -146,7 +144,6 @@ * @returns A promise that resolves when the session is shut down.

*/
function shutdown(id, options) {
if (options === void 0) { options = {}; }
return default_1.DefaultSession.shutdown(id, options);
function shutdown(id, settings) {
return default_1.DefaultSession.shutdown(id, settings);
}
Session.shutdown = shutdown;
})(Session = exports.Session || (exports.Session = {}));
import { ISignal, Signal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import { ServerConnection } from '..';
import { TerminalSession } from './terminal';

@@ -29,13 +29,6 @@ /**

/**
* The base url of the terminal.
* The server settings for the session.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* Get a copy of the default ajax settings for the terminal.
*/
/**
* Set the default ajax settings for the terminal.
*/
ajaxSettings: IAjaxSettings;
/**
* Test whether the session is ready.

@@ -75,7 +68,3 @@ */

private _name;
private _baseUrl;
private _wsUrl;
private _url;
private _token;
private _ajaxSettings;
private _ws;

@@ -107,7 +96,7 @@ private _isDisposed;

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves with the list of running session models.
*/
function listRunning(options?: TerminalSession.IOptions): Promise<TerminalSession.IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<TerminalSession.IModel[]>;
/**

@@ -118,7 +107,7 @@ * Shut down a terminal session by name.

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves when the session is shut down.
*/
function shutdown(name: string, options?: TerminalSession.IOptions): Promise<void>;
function shutdown(name: string, settings?: ServerConnection.ISettings): Promise<void>;
}
"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,3 +16,3 @@ var coreutils_1 = require("@jupyterlab/coreutils");

var signaling_1 = require("@phosphor/signaling");
var utils = require("../utils");
var __1 = require("..");
var terminal_1 = require("./terminal");

@@ -24,4 +32,2 @@ /**

if (options === void 0) { options = {}; }
this._token = '';
this._ajaxSettings = '';
this._ws = null;

@@ -32,6 +38,3 @@ this._isDisposed = false;

this._name = name;
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._token = options.token || utils.getConfigOption('token');
this._ajaxSettings = JSON.stringify(utils.ajaxSettingsWithToken(options.ajaxSettings, this._token));
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl);
this.serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
this._readyPromise = this._initializeSocket();

@@ -70,28 +73,2 @@ this.terminated = new signaling_1.Signal(this);

});
Object.defineProperty(DefaultTerminalSession.prototype, "baseUrl", {
/**
* The base url of the terminal.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DefaultTerminalSession.prototype, "ajaxSettings", {
/**
* Get a copy of the default ajax settings for the terminal.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the terminal.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DefaultTerminalSession.prototype, "isReady", {

@@ -175,7 +152,3 @@ /**

DefaultTerminalSession.prototype.shutdown = function () {
var options = {
baseUrl: this._baseUrl,
ajaxSettings: this.ajaxSettings
};
return DefaultTerminalSession.shutdown(this.name, options);
return DefaultTerminalSession.shutdown(this.name, this.serverSettings);
};

@@ -192,9 +165,11 @@ /**

this._isReady = false;
this._url = Private.getTermUrl(this._baseUrl, this._name);
var settings = this.serverSettings;
this._url = Private.getTermUrl(settings.baseUrl, this._name);
Private.running[this._url] = this;
var wsUrl = coreutils_1.URLExt.join(this._wsUrl, "terminals/websocket/" + name);
if (this._token) {
wsUrl = wsUrl + ("?token=" + this._token);
var wsUrl = coreutils_1.URLExt.join(settings.wsUrl, "terminals/websocket/" + name);
var token = this.serverSettings.token;
if (token) {
wsUrl = wsUrl + ("?token=" + token);
}
this._ws = new WebSocket(wsUrl);
this._ws = settings.wsFactory(wsUrl);
this._ws.onmessage = function (event) {

@@ -237,3 +212,3 @@ if (_this._isDisposed) {

function isAvailable() {
var available = String(utils.getConfigOption('terminalsAvailable'));
var available = String(coreutils_1.PageConfig.getOption('terminalsAvailable'));
return available.toLowerCase() === 'true';

@@ -254,13 +229,13 @@ }

}
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = Private.getBaseUrl(baseUrl);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'POST';
ajaxSettings.dataType = 'json';
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
var serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
var request = {
url: Private.getServiceUrl(serverSettings.baseUrl),
method: 'POST'
};
return __1.ServerConnection.makeRequest(request, serverSettings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var name = success.data.name;
return new DefaultTerminalSession(name, options);
var name = response.data.name;
return new DefaultTerminalSession(name, __assign({}, options, { serverSettings: serverSettings }));
});

@@ -292,8 +267,8 @@ }

}
var baseUrl = options.baseUrl || utils.getBaseUrl();
var url = Private.getTermUrl(baseUrl, name);
var serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
var url = Private.getTermUrl(serverSettings.baseUrl, name);
if (url in Private.running) {
return Promise.resolve(Private.running[url]);
}
return listRunning(options).then(function (models) {
return listRunning(serverSettings).then(function (models) {
var index = algorithm_1.ArrayExt.findFirstIndex(models, function (model) {

@@ -303,3 +278,3 @@ return model.name === name;

if (index !== -1) {
var session = new DefaultTerminalSession(name, options);
var session = new DefaultTerminalSession(name, __assign({}, options, { serverSettings: serverSettings }));
return Promise.resolve(session);

@@ -314,22 +289,23 @@ }

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves with the list of running session models.
*/
function listRunning(options) {
if (options === void 0) { options = {}; }
function listRunning(settings) {
if (!terminal_1.TerminalSession.isAvailable()) {
return Promise.reject(Private.unavailableMsg);
}
var url = Private.getBaseUrl(options.baseUrl);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'GET';
ajaxSettings.dataType = 'json';
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 200) {
throw utils.makeAjaxError(success);
settings = settings || __1.ServerConnection.makeSettings();
var url = Private.getServiceUrl(settings.baseUrl);
var request = {
url: url,
method: 'GET'
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 200) {
throw __1.ServerConnection.makeError(response);
}
var data = success.data;
var data = response.data;
if (!Array.isArray(data)) {
throw utils.makeAjaxError(success, 'Invalid terminal data');
throw __1.ServerConnection.makeError(response, 'Invalid terminal data');
}

@@ -356,17 +332,19 @@ // Update the local data store.

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves when the session is shut down.
*/
function shutdown(name, options) {
if (options === void 0) { options = {}; }
function shutdown(name, settings) {
if (!terminal_1.TerminalSession.isAvailable()) {
return Promise.reject(Private.unavailableMsg);
}
var url = Private.getTermUrl(options.baseUrl, name);
var ajaxSettings = utils.ajaxSettingsWithToken(options.ajaxSettings, options.token);
ajaxSettings.method = 'DELETE';
return utils.ajaxRequest(url, ajaxSettings).then(function (success) {
if (success.xhr.status !== 204) {
throw utils.makeAjaxError(success);
settings = settings || __1.ServerConnection.makeSettings();
var url = Private.getTermUrl(settings.baseUrl, name);
var request = {
url: url,
method: 'DELETE'
};
return __1.ServerConnection.makeRequest(request, settings).then(function (response) {
if (response.xhr.status !== 204) {
throw __1.ServerConnection.makeError(response);
}

@@ -410,6 +388,6 @@ Private.killTerminal(url);

*/
function getBaseUrl(baseUrl) {
function getServiceUrl(baseUrl) {
return coreutils_1.URLExt.join(baseUrl, TERMINAL_SERVICE_URL);
}
Private.getBaseUrl = getBaseUrl;
Private.getServiceUrl = getServiceUrl;
/**

@@ -416,0 +394,0 @@ * Kill a terminal by url.

import { IIterator } from '@phosphor/algorithm';
import { ISignal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import * as utils from '../utils';
import { ServerConnection } from '..';
import { TerminalSession } from './terminal';

@@ -23,17 +22,6 @@ /**

/**
* The base url of the manager.
* The server settings of the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* The base ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
/**
* Set the default ajax settings for the manager.
*/
ajaxSettings: IAjaxSettings;
/**
* Test whether the manger is ready.

@@ -63,4 +51,3 @@ */

*
* @param ajaxSettings - The ajaxSettings to use, overrides manager
* settings.
* @param options - The options used to connect to the session.
*

@@ -70,8 +57,7 @@ * @returns A promise that resolves with the terminal instance.

* #### Notes
* The baseUrl and wsUrl of the options will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The manager `serverSettings` will be used unless overridden in the
* options.
*/
startNew(options?: TerminalSession.IOptions): Promise<TerminalSession.ISession>;
connectTo(name: string, options?: IAjaxSettings): Promise<TerminalSession.ISession>;
connectTo(name: string, options?: TerminalSession.IOptions): Promise<TerminalSession.ISession>;
/**

@@ -107,5 +93,2 @@ * Shut down a terminal session by name.

private _getOptions(options?);
private _baseUrl;
private _wsUrl;
private _ajaxSettings;
private _running;

@@ -127,18 +110,6 @@ private _isDisposed;

/**
* The base url.
* The server settings used by the manager.
*/
baseUrl?: string;
/**
* The base websocket url.
*/
wsUrl?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The Ajax settings used for server requests.
*/
ajaxSettings?: utils.IAjaxSettings;
serverSettings?: ServerConnection.ISettings;
}
}
"use strict";
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,3 +16,3 @@ var algorithm_1 = require("@phosphor/algorithm");

var signaling_1 = require("@phosphor/signaling");
var utils = require("../utils");
var __1 = require("..");
var terminal_1 = require("./terminal");

@@ -21,5 +29,2 @@ /**

var _this = this;
this._baseUrl = '';
this._wsUrl = '';
this._ajaxSettings = '';
this._running = [];

@@ -30,5 +35,3 @@ this._isDisposed = false;

this._runningChanged = new signaling_1.Signal(this);
this._baseUrl = options.baseUrl || utils.getBaseUrl();
this._wsUrl = options.wsUrl || utils.getWsUrl(this._baseUrl);
this._ajaxSettings = JSON.stringify(options.ajaxSettings || {});
this.serverSettings = options.serverSettings || __1.ServerConnection.makeSettings();
// Set up state handling if terminals are available.

@@ -64,38 +67,2 @@ if (terminal_1.TerminalSession.isAvailable()) {

});
Object.defineProperty(TerminalManager.prototype, "baseUrl", {
/**
* The base url of the manager.
*/
get: function () {
return this._baseUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TerminalManager.prototype, "wsUrl", {
/**
* The base ws url of the manager.
*/
get: function () {
return this._wsUrl;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TerminalManager.prototype, "ajaxSettings", {
/**
* The default ajax settings for the manager.
*/
get: function () {
return JSON.parse(this._ajaxSettings);
},
/**
* Set the default ajax settings for the manager.
*/
set: function (value) {
this._ajaxSettings = JSON.stringify(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TerminalManager.prototype, "isReady", {

@@ -150,4 +117,3 @@ /**

*
* @param ajaxSettings - The ajaxSettings to use, overrides manager
* settings.
* @param options - The options used to connect to the session.
*

@@ -157,5 +123,4 @@ * @returns A promise that resolves with the terminal instance.

* #### Notes
* The baseUrl and wsUrl of the options will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The manager `serverSettings` will be used unless overridden in the
* options.
*/

@@ -174,4 +139,3 @@ TerminalManager.prototype.startNew = function (options) {

*
* @param ajaxSettings - The ajaxSettings to use, overrides manager
* settings.
* @param options - The options used to connect to the session.
*

@@ -181,5 +145,4 @@ * @returns A promise that resolves with the new session instance.

* #### Notes
* The baseUrl and wsUrl of the options will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The manager `serverSettings` will be used unless overridden in the
* options.
*/

@@ -198,3 +161,3 @@ TerminalManager.prototype.connectTo = function (name, options) {

var _this = this;
return terminal_1.TerminalSession.shutdown(name, this._getOptions()).then(function () {
return terminal_1.TerminalSession.shutdown(name, this.serverSettings).then(function () {
_this._onTerminated(name);

@@ -245,3 +208,3 @@ });

var _this = this;
return terminal_1.TerminalSession.listRunning(this._getOptions({})).then(function (running) {
return terminal_1.TerminalSession.listRunning(this.serverSettings).then(function (running) {
_this._isReady = true;

@@ -259,9 +222,7 @@ if (!coreutils_1.JSONExt.deepEqual(running, _this._running)) {

if (options === void 0) { options = {}; }
options.baseUrl = this.baseUrl;
options.wsUrl = this.wsUrl;
options.ajaxSettings = options.ajaxSettings || this.ajaxSettings;
return options;
return __assign({}, options, { serverSettings: this.serverSettings });
};
;
return TerminalManager;
}());
exports.TerminalManager = TerminalManager;

@@ -5,4 +5,3 @@ import { IIterator } from '@phosphor/algorithm';

import { ISignal } from '@phosphor/signaling';
import { IAjaxSettings } from '../utils';
import * as utils from '../utils';
import { ServerConnection } from '..';
/**

@@ -33,10 +32,6 @@ * The namespace for ISession statics.

/**
* The base url of the session.
* The server settings for the session.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* The Ajax settings used for server requests.
*/
ajaxSettings: utils.IAjaxSettings;
/**
* Test whether the session is ready.

@@ -80,7 +75,7 @@ */

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves with the list of running session models.
*/
function listRunning(options?: IOptions): Promise<IModel[]>;
function listRunning(settings?: ServerConnection.ISettings): Promise<IModel[]>;
/**

@@ -91,27 +86,15 @@ * Shut down a terminal session by name.

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves when the session is shut down.
*/
function shutdown(name: string, options?: IOptions): Promise<void>;
function shutdown(name: string, settings?: ServerConnection.ISettings): Promise<void>;
/**
* The options for intializing a terminal session object.
*/
interface IOptions extends JSONObject {
interface IOptions {
/**
* The base url.
* The server settings for the session.
*/
baseUrl?: string;
/**
* The base websocket url.
*/
wsUrl?: string;
/**
* The authentication token for the API.
*/
token?: string;
/**
* The Ajax settings used for server requests.
*/
ajaxSettings?: utils.IAjaxSettings;
serverSettings?: ServerConnection.ISettings;
}

@@ -157,14 +140,6 @@ /**

/**
* The base url of the manager.
* The server settings for the manager.
*/
readonly baseUrl: string;
readonly serverSettings: ServerConnection.ISettings;
/**
* The base ws url of the manager.
*/
readonly wsUrl: string;
/**
* The default ajax settings for the manager.
*/
ajaxSettings?: IAjaxSettings;
/**
* Test whether the manager is ready.

@@ -195,8 +170,6 @@ */

* #### Notes
* The baseUrl and wsUrl of the options will be forced
* to the ones used by the manager. The ajaxSettings of the manager
* will be used unless overridden.
* The manager `serverSettings` will be always be used.
*/
startNew(options?: IOptions): Promise<ISession>;
connectTo(name: string, options?: IOptions): Promise<ISession>;
connectTo(name: string): Promise<ISession>;
/**

@@ -203,0 +176,0 @@ * Shut down a terminal session by name.

@@ -54,8 +54,8 @@ "use strict";

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves with the list of running session models.
*/
function listRunning(options) {
return default_1.DefaultTerminalSession.listRunning(options);
function listRunning(settings) {
return default_1.DefaultTerminalSession.listRunning(settings);
}

@@ -68,10 +68,10 @@ TerminalSession.listRunning = listRunning;

*
* @param options - The session options to use.
* @param settings - The server settings to use.
*
* @returns A promise that resolves when the session is shut down.
*/
function shutdown(name, options) {
return default_1.DefaultTerminalSession.shutdown(name, options);
function shutdown(name, settings) {
return default_1.DefaultTerminalSession.shutdown(name, settings);
}
TerminalSession.shutdown = shutdown;
})(TerminalSession = exports.TerminalSession || (exports.TerminalSession = {}));
{
"name": "@jupyterlab/services",
"version": "0.43.0",
"version": "0.44.0",
"description": "Client APIs for the Jupyter services REST APIs",

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

"dependencies": {
"@jupyterlab/coreutils": "^0.4.0",
"@phosphor/algorithm": "^1.0.0",
"@phosphor/coreutils": "^1.0.0",
"@phosphor/disposable": "^1.0.0",
"@phosphor/signaling": "^1.0.0",
"@jupyterlab/coreutils": "^0.5.0",
"@phosphor/algorithm": "^1.1.0",
"@phosphor/coreutils": "^1.1.0",
"@phosphor/disposable": "^1.1.0",
"@phosphor/signaling": "^1.2.0",
"@types/minimist": "^1.2.0",

@@ -27,9 +27,8 @@ "@types/text-encoding": "0.0.30",

"mocha": "^3.2.0",
"requirejs": "^2.3.3",
"requirejs": "^2.2.0",
"rimraf": "^2.5.2",
"text-encoding": "^0.5.2",
"typedoc": "^0.5.0",
"typescript": "^2.2.1",
"webpack": "^2.2.1",
"ws": "^1.0.1",
"ws": "^1.1.1",
"xmlhttprequest": "^1.8.0"

@@ -42,10 +41,7 @@ },

"build": "npm run build:src",
"example:browser": "cd examples/browser && npm run update && npm run build",
"example:node": "cd examples/node && npm install",
"build:examples": "npm run example:browser && npm run example:node",
"test:coverage": "istanbul cover --dir test/coverage _mocha -- --retries 3 test/build/**/*.spec.js test/build*.spec.js --foo bar --terminalsAvailable True",
"test:coverage": "istanbul cover --dir test/coverage _mocha -- --retries 3 test/build/**/*.spec.js test/build/*.spec.js --jupyter-config-data=./test/config.json",
"test:integration": "cd test && python integration_test.py",
"test:devtool": "devtool node_modules/.bin/_mocha -qc test/build/*.spec.js test/build/**/*.spec.js --foo bar --terminalsAvailable True",
"test:debug": "mocha test/build/**/*.spec.js test/build*.spec.js --foo bar --terminalsAvailable True --debug-brk",
"test": "mocha --retries 3 test/build/**.spec.js test/build/**/*.spec.js --foo bar --terminalsAvailable True"
"test:devtool": "devtool node_modules/.bin/_mocha -qc ttest/build/**/*.spec.js test/build/*.spec.js --jupyter-config-data=./test/config.json --timeout=50000",
"test:debug": "mocha test/build/**/*.spec.js test/build/*.spec.js --jupyter-config-data=./test/config.json --debug-brk",
"test": "mocha --retries 3 test/build/**/*.spec.js test/build/*.spec.js --jupyter-config-data=./test/config.json"
},

@@ -52,0 +48,0 @@ "repository": {

@@ -123,10 +123,15 @@ JupyterLab Services

Override the global `XMLHttpRequest` and `WebSocket` (in ES6 syntax):
Use `XMLHttpRequest` and `WebSocket` in the server settings (in ES6 syntax):
```typescript
import { Kernel, ServerConnection } from '@jupyterlab/services';
import { XMLHttpRequest } from "xmlhttprequest";
import { default as WebSocket } from 'ws';
global.XMLHttpRequest = XMLHttpRequest;
global.WebSocket = WebSocket;
let serverSettings = ServerConnection.makeSettings({
xml: XMLHttpRequest,
webSocket: WebSocket
});
Kernel.startNew({ serverSettings }).then(...);
```

@@ -152,13 +157,6 @@

// The base url of the notebook server.
const BASE_URL = 'http://localhost:8000';
// Get a list of available kernels and connect to one.
Kernel.listRunning({ baseUrl: BASE_URL }).then(kernelModels => {
let options: Kernel.IOptions = {
baseUrl: BASE_URL,
name: kernelModels[0].name
};
Kernel.connectTo(kernelModels[0].id, options).then((kernel) => {
/ Get a list of available kernels and connect to one.
Kernel.listRunning().then(kernelModels => {
Kernel.connectTo(kernelModels[0].id).then((kernel) => {
console.log(kernel.name);

@@ -170,3 +168,3 @@ });

// Get info about the available kernels and start a new one.
Kernel.getSpecs({ baseUrl: BASE_URL }).then(kernelSpecs => {
Kernel.getSpecs().then(kernelSpecs => {
console.log('Default spec:', kernelSpecs.default);

@@ -176,3 +174,2 @@ console.log('Available specs', Object.keys(kernelSpecs.kernelspecs));

let options: Kernel.IOptions = {
baseUrl: BASE_URL,
name: kernelSpecs.default

@@ -218,2 +215,3 @@ };

});
```

@@ -229,14 +227,5 @@

// The base url of the Jupyter server.
const BASE_URL = 'http://localhost:8000';
// Get a list of available sessions and connect to one.
Session.listRunning({ baseUrl: BASE_URL }).then(sessionModels => {
let options = {
baseUrl: BASE_URL,
kernelName: sessionModels[0].kernel.name,
path: sessionModels[0].notebook.path
};
Session.connectTo(sessionModels[0].id, options).then((session) => {
Session.listRunning().then(sessionModels => {
Session.connectTo(sessionModels[0].id).then((session) => {
console.log(session.kernel.name);

@@ -248,3 +237,2 @@ });

let options = {
baseUrl: BASE_URL,
kernelName: 'python',

@@ -283,12 +271,8 @@ path: '/tmp/foo.ipynb'

```typescript
// The base url of the Jupyter server.
const BASE_URL = 'http://localhost:8000';
// Create a comm from the server side.
//
// Get info about the available kernels and connect to one.
Kernel.getSpecs({ baseUrl: BASE_URL }).then(kernelSpecs => {
Kernel.getSpecs().then(kernelSpecs => {
return Kernel.startNew({
baseUrl: BASE_URL,
name: kernelSpecs.default,

@@ -304,5 +288,4 @@ });

// Create a comm from the client side.
Kernel.getSpecs({ baseUrl: BASE_URL }).then(kernelSpecs => {
Kernel.getSpecs().then(kernelSpecs => {
return Kernel.startNew({
baseUrl: BASE_URL,
name: kernelSpecs.default,

@@ -340,8 +323,4 @@ });

// The base url of the Jupyter server.
let baseUrl = 'http://localhost:8000';
let contents = new ContentsManager();
let contents = new ContentsManager({ baseUrl });
// Create a new python file.

@@ -400,5 +379,4 @@ contents.newUntitled({ path: '/foo', type: 'file', ext: 'py' }).then(

// The base url of the Jupyter server.
let baseUrl = 'http://localhost:8000';
ConfigSection.create({ name: 'notebook', baseUrl }).then(section => {
ConfigSection.create({ name: 'notebook' }).then(section => {
let config = new ConfigWithDefaults({

@@ -405,0 +383,0 @@ section,

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