Datalayer VS Code Extension - v0.0.6
    Preparing search index...

    Validation helper utilities for kernel and session managers.

    Centralizes validation logic to ensure consistent error messages and behavior across all manager types.

    Index

    Constructors

    Methods

    • Check if an object appears to be disposed.

      Parameters

      • obj: { isDisposed?: boolean }

        Object to check

      Returns boolean

      True if object appears disposed

      if (ValidationHelpers.isDisposed(kernel)) {
      console.warn('Kernel already disposed');
      return;
      }
    • Throw error if object is disposed.

      Parameters

      • obj: { isDisposed?: boolean }

        Object to check

      • label: string = "object"

        Label for the object in error message

      Returns void

      If object is disposed

      ValidationHelpers.throwIfDisposed(this._activeKernel, 'kernel');
      // Safe to use kernel now
    • Validate that an ID is a non-empty string.

      Parameters

      • id: string

        Identifier to validate

      • label: string = "identifier"

        Label for the ID (e.g., "kernel", "session")

      Returns asserts id is string

      If ID is empty or not a string

      ValidationHelpers.validateId(kernelId, 'kernel');
      // kernelId is now guaranteed to be a non-empty string
    • Validate that a kernel connection exists and matches the given ID.

      Parameters

      • kernel: IKernelConnection

        Kernel connection to validate (may be null)

      • id: string

        Expected kernel identifier

      • OptionalmanagerType: string

        Type of manager for better error messages

      Returns asserts kernel is IKernelConnection

      If no active kernel or ID doesn't match

      ValidationHelpers.validateKernel(this._activeKernel, id, 'pyodide');
      // Now safe to use this._activeKernel
    • Validate that a path is a non-empty string.

      Parameters

      • path: string

        Path to validate

      • label: string = "path"

        Label for the path (e.g., "notebook path")

      Returns asserts path is string

      If path is empty or not a string

      ValidationHelpers.validatePath(notebookPath, 'notebook path');
      // notebookPath is now guaranteed to be a non-empty string
    • Validate that a session connection exists and matches the given ID.

      Parameters

      • session: ISessionConnection

        Session connection to validate (may be null)

      • id: string

        Expected session identifier

      • OptionalmanagerType: string

        Type of manager for better error messages

      Returns asserts session is ISessionConnection

      If no active session or ID doesn't match

      ValidationHelpers.validateSession(this._activeSession, id, 'local');
      // Now safe to use this._activeSession
    • Validate that a session connection exists and matches the given path.

      Parameters

      • session: ISessionConnection

        Session connection to validate (may be null)

      • path: string

        Expected session path (notebook path)

      • OptionalmanagerType: string

        Type of manager for better error messages

      Returns asserts session is ISessionConnection

      If no active session or path doesn't match

      ValidationHelpers.validateSessionPath(this._activeSession, '/notebooks/test.ipynb', 'remote');
      // Now safe to use this._activeSession