CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-elyra--application

JupyterLab utilities for API communication and metadata management in Elyra extensions

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

requests.mddocs/

HTTP Request Handling

Low-level HTTP request abstraction for communicating with the Jupyter Lab server. The RequestHandler class provides GET, POST, PUT, and DELETE methods with built-in error handling, user feedback dialogs, and support for long-running requests.

import { RequestHandler } from "@elyra/application";
import { Dialog } from '@jupyterlab/apputils';

Capabilities

Request Handler Class

Service class for making requests to the Jupyter Lab server with comprehensive error handling.

/**
 * Service class for making requests to the jupyter lab server.
 */
class RequestHandler {
  /**
   * Make a GET request to the jupyter lab server.
   * @param requestPath - The url path for the request. This path is appended to the base path of the server.
   * @param longRequest - Whether the request is expected to take a long time. If true, displays a dialog warning.
   * @returns A promise that resolves with the server response on success or an error dialog result on failure.
   */
  static makeGetRequest(requestPath: string, longRequest: boolean): Promise<any>;
  
  /**
   * Make a POST request to the jupyter lab server.
   * @param requestPath - The url path for the request. This path is appended to the base path of the server.
   * @param requestBody - The body of the request. Will be included in the RequestInit object.
   * @param longRequest - Whether the request is expected to take a long time. If true, displays a dialog warning.
   * @returns A promise that resolves with the server response on success or an error dialog result on failure.
   */
  static makePostRequest(requestPath: string, requestBody: any, longRequest: boolean): Promise<any>;
  
  /**
   * Make a PUT request to the jupyter lab server.
   * @param requestPath - The url path for the request. This path is appended to the base path of the server.
   * @param requestBody - The body of the request. Will be included in the RequestInit object.
   * @param longRequest - Whether the request is expected to take a long time. If true, displays a dialog warning.
   * @returns A promise that resolves with the server response on success or an error dialog result on failure.
   */
  static makePutRequest(requestPath: string, requestBody: any, longRequest: boolean): Promise<any>;
  
  /**
   * Make a DELETE request to the jupyter lab server.
   * @param requestPath - The url path for the request. This path is appended to the base path of the server.
   * @param longRequest - Whether the request is expected to take a long time. If true, displays a dialog warning.
   * @returns A promise that resolves with the server response on success or an error dialog result on failure.
   */
  static makeDeleteRequest(requestPath: string, longRequest: boolean): Promise<any>;
  
  /**
   * Make a request to the jupyter lab server.
   * @param requestPath - The url path for the request. This path is appended to the base path of the server.
   * @param requestInit - The initialization options for the request. A RequestInit object that must include a value for method.
   * @param longRequest - Whether the request is expected to take a long time. If true, displays a dialog warning.
   * @returns A promise that resolves with the server response on success or an error dialog result on failure.
   */
  static makeServerRequest(requestPath: string, requestInit: RequestInit, longRequest: boolean): Promise<any>;
}

GET Requests

Make GET requests to retrieve data from the Jupyter Lab server.

/**
 * Make a GET request to the jupyter lab server.
 * @param requestPath - The url path for the request
 * @param longRequest - Whether to show a wait dialog for long operations
 * @returns Promise resolving with server response or error dialog result
 */
static makeGetRequest(requestPath: string, longRequest: boolean): Promise<any>;

Usage Examples:

import { RequestHandler } from "@elyra/application";

// Simple GET request
const response = await RequestHandler.makeGetRequest('elyra/schema/code-snippets', false);

// Long-running GET request with wait dialog
const largeData = await RequestHandler.makeGetRequest('elyra/export/large-dataset', true);

POST Requests

Make POST requests to create new resources on the Jupyter Lab server.

/**
 * Make a POST request to the jupyter lab server.
 * @param requestPath - The url path for the request
 * @param requestBody - The body of the request
 * @param longRequest - Whether to show a wait dialog for long operations
 * @returns Promise resolving with server response or error dialog result
 */
static makePostRequest(requestPath: string, requestBody: any, longRequest: boolean): Promise<any>;

Usage Examples:

import { RequestHandler } from "@elyra/application";

// Create new metadata
const newMetadata = {
  schema_name: 'code-snippet',
  display_name: 'My Snippet',
  name: 'my-snippet',
  metadata: { language: 'Python', code: ['print("hello")'] }
};

const result = await RequestHandler.makePostRequest(
  'elyra/metadata/code-snippets',
  JSON.stringify(newMetadata),
  false
);

PUT Requests

Make PUT requests to update existing resources on the Jupyter Lab server.

/**
 * Make a PUT request to the jupyter lab server.
 * @param requestPath - The url path for the request
 * @param requestBody - The body of the request
 * @param longRequest - Whether to show a wait dialog for long operations
 * @returns Promise resolving with server response or error dialog result
 */
static makePutRequest(requestPath: string, requestBody: any, longRequest: boolean): Promise<any>;

Usage Examples:

import { RequestHandler } from "@elyra/application";

// Update existing metadata
const updatedMetadata = {
  schema_name: 'code-snippet',
  display_name: 'Updated Snippet',
  name: 'my-snippet',
  metadata: { language: 'Python', code: ['print("updated")'] }
};

const result = await RequestHandler.makePutRequest(
  'elyra/metadata/code-snippets/my-snippet',
  JSON.stringify(updatedMetadata),
  false
);

DELETE Requests

Make DELETE requests to remove resources from the Jupyter Lab server.

/**
 * Make a DELETE request to the jupyter lab server.
 * @param requestPath - The url path for the request
 * @param longRequest - Whether to show a wait dialog for long operations
 * @returns Promise resolving with server response or error dialog result
 */
static makeDeleteRequest(requestPath: string, longRequest: boolean): Promise<any>;

Usage Examples:

import { RequestHandler } from "@elyra/application";

// Remove metadata
await RequestHandler.makeDeleteRequest('elyra/metadata/code-snippets/my-snippet', false);

Generic Server Requests

Core method for making requests with custom RequestInit options.

/**
 * Make a request to the jupyter lab server.
 * @param requestPath - The url path for the request
 * @param requestInit - The initialization options including method
 * @param longRequest - Whether to show a wait dialog for long operations
 * @returns Promise resolving with server response or error dialog result
 */
static makeServerRequest(requestPath: string, requestInit: RequestInit, longRequest: boolean): Promise<any>;

Error Handling

All RequestHandler methods include automatic error handling:

  • Server Errors: Display expandable error dialogs with details like reason, message, timestamp, and traceback
  • 404 Errors: Show specific "endpoint not found" dialogs
  • Network Errors: Handle connection failures with appropriate user feedback
  • Long Request Support: Show progress dialogs for operations expected to take time

The error dialogs are implemented using JupyterLab's dialog system and Elyra's expandable error components.

Install with Tessl CLI

npx tessl i tessl/npm-elyra--application

docs

index.md

parsing.md

requests.md

services.md

tile.json