Global

Members

# ASSISTANT_GREETING_MESSAGE

Assistant greeting message to the user

View Source config/env.js, line 79

# AUTH_GRPC_HOST

Authentication gRPC service hostname

View Source config/env.js, line 44

# AUTH_GRPC_PORT

Authentication gRPC service port

View Source config/env.js, line 49

# constant AssistantSchema

Embedded schema representing assistant responses in the chat history.

View Source models/Chat.model.js, line 17

# CACHE_DURATION_DEFAULT

Cache Configuration

View Source config/env.js, line 86

# CACHE_DURATION_LONG

Cache duration long

View Source config/env.js, line 104

# CACHE_DURATION_SHORT

Cache duration short

View Source config/env.js, line 95

# constant Chat

Chat model used to persist conversation history.

View Source models/Chat.model.js, line 48

# constant ChatHistorySchema

Chat history entry schema combining user and assistant messages.

View Source models/Chat.model.js, line 28

# constant ChatSchema

Root schema representing a chat session and associated investigation reference.

View Source models/Chat.model.js, line 38

string

# DatabaseOperation

Database Operation Enum - For database operations

View Source types/enums.js, line 12

# constant EditableFieldSchema

General EditableField Schema - Base schema for all editable fields This schema provides the common structure for AI-generated and human-editable content

View Source models/investigation/schema-definition.js, line 20

# constant EditableVector3Schema

Vector3 Schema - 3D vector with x, y, z coordinates

View Source models/investigation/schema-definition.js, line 89

string

# ErrorCode

Error Code Enum - Application error codes

View Source types/enums.js, line 24

# constant FieldHistoryEntrySchema

Field History Entry Schema - Schema for a single history entry

View Source models/investigation/schema-definition.js, line 10

# GRPC_HTTP2_PING_INTERVAL_MS

gRPC HTTP2 ping interval

View Source config/env.js, line 122

# GRPC_KEEPALIVE_TIME_MS

gRPC Configuration

View Source config/env.js, line 113

string

# Intents

AI Assistant's Intents Enum - For Assistant process message

View Source types/intent/enums.js, line 6

# constant Investigation

Investigation Model This is the main model file that assembles all components

View Source models/investigation/investigation.model.js, line 8

# constant InvestigationMetadataSchema

Investigation Metadata Schema - Metadata for an investigation

View Source models/investigation/schema-definition.js, line 312

# constant InvestigationSchema

Investigation Schema Definition This file contains the main mongoose schema definition for investigations

View Source models/investigation/schema-definition.js, line 358

string

# InvestigationStatus

Investigation Status Enum

View Source types/investigation/enums.js, line 11

# MONGO_URI

MongoDB connection URI - must be provided

View Source config/env.js, line 29

# constant Metadata

Metadata model exposing catalog metadata persistence APIs.

View Source models/Metadata.model.js, line 81

# constant MetadataSchema

Metadata schema describing investigation catalog entries.

View Source models/Metadata.model.js, line 6

string

# ModifyInvestigationIntents

AI Assistant's Modify InvestigationIntents Enum - For Assistant investigation modification

View Source types/intent/enums.js, line 22

# NODE_ENV

Node.js environment (development, production, test)

View Source config/env.js, line 24

# OPENAI_API_KEY

OpenAI Key

View Source config/env.js, line 54

# OPENAI_MODEL

OpenAI LLM model

View Source config/env.js, line 69

# OPENAI_MODEL_TEMPERATURE

OpenAI LLM model temperature

View Source config/env.js, line 74

# constant ObjectSchema

Object Schema - 3D object with position, rotation, size, view and components

View Source models/investigation/schema-definition.js, line 260

# PORT

HTTP server port

View Source config/env.js, line 14

# constant Prompt

Prompt model providing access to reusable LLM prompt templates.

View Source models/Prompt.model.js, line 22

# constant PromptSchema

Prompt Schema

View Source models/Prompt.model.js, line 6

number

# ProtoUserRole

Proto UserRole enum values for gRPC communication with Auth Service

View Source types/auth/enums.js, line 17

# REDIS_DB_INDEX

Redis database index

View Source config/env.js, line 39

# REDIS_URI

Redis connection URI - must be provided

View Source config/env.js, line 34

# REPLICATE_API_TOKEN

Replicate Key

View Source config/env.js, line 64

# SOCKET_PORT

Socket IO server port

View Source config/env.js, line 19

# constant StepSchema

Step Schema - Individual step in an investigation Each field is now wrapped with EditableFieldSchema for AI/human editing capabilities

View Source models/investigation/schema-definition.js, line 59

# TOGETHER_API_KEY

TogetherAI APR key (this is for future)

View Source config/env.js, line 59

# constant Url

URL model used to persist short links associated with investigations.

View Source models/urls/url.model.js, line 9

# constant UrlCountersSchema

URL Counters Schema - Mongoose schema for UrlCounters This is a subdocument schema with no _id

View Source models/urls/schema-definition.js, line 8

string

# UrlOrigin

URL Origin Enum - Indicates how the URL was created

View Source types/urls/enums.js, line 11

# constant UrlSchema

URL Schema Definition This file contains the main mongoose schema definition for URLs

View Source models/urls/schema-definition.js, line 25

string

# UserRole

User role enumeration - matches Auth Service definition Only admin and SME (Subject Matter Expert) roles are supported

View Source types/auth/enums.js, line 7

# constant UserSchema

Embedded schema representing a user entry in the chat history.

View Source models/Chat.model.js, line 8

# VAULT_API_VERSION

HashiCorp Vault API version

View Source config/env.js, line 162

# VAULT_KV_KEY

HashiCorp Vault KV key

View Source config/env.js, line 157

# VAULT_MOUNT_PATH

HashiCorp Vault secrets engine mount path

View Source config/env.js, line 152

# VAULT_ROLE_ID

HashiCorp Vault role ID for AppRole auth

View Source config/env.js, line 142

# VAULT_SECRET_ID

HashiCorp Vault secret ID for AppRole auth

View Source config/env.js, line 147

# VAULT_TOKEN

HashiCorp Vault authentication token

View Source config/env.js, line 137

# VAULT_URL

HashiCorp Vault Configuration

View Source config/env.js, line 132

# constant Vector3Schema

Vector3 validation schema

View Source schemas/investigation.validation.js, line 12

# constant asyncHandler

Wraps an async function to catch any rejections and forward them to the next middleware. This allows you to use async/await in route handlers without manually wrapping them in try-catch blocks.

View Source utils/asyncHandler.js, line 28

Example
```typescript
// Instead of:
app.get('/users', async (req, res, next) => {
  try {
    const users = await userService.getUsers();
    res.json(users);
  } catch (error) {
    next(error);
  }
});

// You can do:
app.get('/users', asyncHandler(async (req, res) => {
  const users = await userService.getUsers();
  res.json(users);
}));
```

# constant env

Parsed and validated environment variables.

View Source config/env.js, line 168

# constant envSchema

Environment variables schema and validation.

View Source config/env.js, line 9

# constant mongoOptions

MongoDB connection options used for the service-level connection pool.

View Source database/mongo.connection.js, line 8

# constant redisUtils

Convenience helpers for interacting with Redis commands.

View Source database/redis.client.js, line 100

# constant requireAuthenticated

Create middleware that requires authentication (admin or SME role)

View Source middlewares/auth.js, line 193

# constant router

REST endpoints that manage investigations.

View Source routes/investigation.routes.js, line 11

# constant subjectsFactory

Maps subject codes to their corresponding full names or educational levels.

  • "K" => Kindergarten
  • "1"-"5" => Elementary
  • "6"-"8" => Middle
  • "B" => Biology
  • "C" => Chemistry
  • "P" => Physics

View Source utils/subjectsFactory.js, line 28

Example
const subjectsFactory = {
  K: "Kindergarten",
  "1": "Elementary",
  "2": "Elementary",
  "3": "Elementary",
  "4": "Elementary",
  "5": "Elementary",
  "6": "Middle",
  "7": "Middle",
  "8": "Middle",
  B: "Biology",
  C: "Chemistry",
  P: "Physics",
};

Methods

# buildRelevanceScoreStage(escapedSearchTerm) → {object}

Builds MongoDB aggregation stage for relevance scoring with priorities Priority order: Title (highest) > Curriculum/Unit/Lesson/Grade > Objectives/Goals/AnalyticalFacts/NGSS > Day/Steps/Objects Exact matches score higher than partial matches

Parameters:
Name Type Description
escapedSearchTerm string

Escaped search term for regex matching

View Source services/investigation.service.js, line 23

MongoDB $addFields stage with relevanceScore calculation

object

# closeDatabaseConnection() → {Promise.<void>}

Close the active MongoDB connection if one exists.

View Source database/mongo.connection.js, line 101

Resolves after the connection is terminated.

Promise.<void>

# closeDatabases() → {Promise.<void>}

Close database connections.

View Source database/index.js, line 31

Propagates shutdown errors.

unknown

Resolves when MongoDB and Redis connections are closed.

Promise.<void>

# closeRedisConnection() → {Promise.<void>}

Gracefully close the Redis connection if active.

View Source database/redis.client.js, line 66

Resolves when the connection quits.

Promise.<void>

# closeVault() → {void}

Closes the Vault service.

View Source vault/index.js, line 31

  • If the Vault service cannot be closed.
Error
  • Closes the Vault service.
void

# connectToDatabase() → {Promise.<void>}

Connect to MongoDB using the configured connection options.

View Source database/mongo.connection.js, line 32

Propagates connection errors once the retry budget is exhausted.

unknown

Resolves when the connection is established.

Promise.<void>

# connectToRedis()

Establish Redis connection for caching and pub/sub use cases.

View Source database/redis.client.js, line 10

# convertEditableFieldToSimple(investigation) → {function}

Creates a helper function to extract a simplified version of an EditableField from an investigation object.

The returned function allows retrieving a specific field by name and converts it into a plain IEditableFieldSimple object, providing default values for missing properties.

Parameters:
Name Type Description
investigation IInvestigation

The investigation object containing EditableField properties.

View Source utils/step-conversion.utils.js, line 152

  • A function that accepts:
    • fieldName: The key of the field to extract.
    • defaultValue: The fallback value if the field's value is missing (default: ""). Returns IEditableFieldSimple or null if the field does not exist.
function

# convertInvestigationFromModel(investigation) → {ICreateInvestigationDto}

Converts an investigation from the database/model format to a simple DTO format suitable for API input or further processing.

Parameters:
Name Type Description
investigation IInvestigation

The investigation in the model format.

View Source helpers/investigation.js, line 9

The investigation converted to a simple ICreateInvestigationDto format.

ICreateInvestigationDto

# convertObjectsToInputFormat(objects, withCoordinates) → {Array.<object>}

Converts an array of IObjectBase objects with EditableField structures into a plain input format suitable for API requests or other processing.

Extracts the value from each editable field and provides default fallbacks:

  • Empty string for name and objectId
  • 0 for position and rotation coordinates
  • null for size if not defined
Parameters:
Name Type Description
objects Array.<IObjectBase>

Array of objects with EditableField properties.

withCoordinates boolean

If true, it converts with coordinates fields(position, rotation, size), otherwise converts without them.

View Source utils/step-conversion.utils.js, line 36

  • Array of plain objects with name, objectId, position, rotation, and size.
Array.<object>

# convertObjectsToSimple(objects) → {Array.<object>}

Convert database objects (IObject[]) to simple objects (ISimpleObject[]) for API response

Parameters:
Name Type Description
objects Array.<IObjectBase>

Database objects with EditableField structure

View Source utils/step-conversion.utils.js, line 73

  • Simple objects for API response with default values instead of null/undefined
Array.<object>

# convertObjectsToUpdateFormat(objects) → {Array.<IUpdateObjectDto>}

Converts an array of simple objects (from AI response or plain format) to IUpdateObjectDto format. This is the reverse of convertObjectsToInputFormat - it converts from simple format to update DTO format.

Parameters:
Name Type Description
objects Array.<ISimpleObject> | Array.<ISimpleResponseObject>

Array of simple objects with plain values.

View Source utils/step-conversion.utils.js, line 113

  • Array of objects in IUpdateObjectDto format suitable for update requests.
Array.<IUpdateObjectDto>

# convertStepsToSimple(steps) → {Array.<IStep>}

Convert database steps (IStep[]) to simple steps (ISimpleStep[]) for API response

Parameters:
Name Type Description
steps Array.<IInvestigationBaseStepModel>

Database steps with EditableField structure

View Source utils/step-conversion.utils.js, line 13

  • Simple steps for API response with empty strings instead of undefined
Array.<IStep>

# createAuthMiddleware(options) → {function}

Create authentication middleware for Express routes

Parameters:
Name Type Description
options IAuthMiddlewareOptions

Configuration options for the middleware

View Source middlewares/auth.js, line 24

Express middleware function

function

# createSampleInvestigation() → {IInvestigation}

Create a sample investigation based on the Galileo Cloud interface

View Source scripts/seed-investigation.js, line 20

The sample investigation

IInvestigation

# enrichInvestigationResponse(investigation, dto, grpcClient, profileCache) → {Promise.<void>}

Enriches an investigation response DTO with detailed author and editor profile information.

Fetches user profiles from the Auth gRPC service (or cache if provided) and populates the metadata.author and metadata.editorsDetailed fields with user details such as name, email, and avatar.

Parameters:
Name Type Description
investigation IInvestigation

The investigation object containing metadata.

dto IInvestigationResponseDto

The investigation response DTO to enrich.

grpcClient AuthGrpcService

The Auth gRPC client used to fetch user profiles.

profileCache Map.<string, (IUserProfile|Promise.<IUserProfile>)>

Optional cache to store/reuse fetched user profiles.

View Source utils/investigation-response.utils.js, line 15

  • Enriches the dto object in-place.
Promise.<void>

# errorHandler(error, req, res, _next) → {void}

Error Handler Middleware

Parameters:
Name Type Description
error IApiError

The error object

req Request

The request object

res Response

The response object

_next NextFunction

The next function

View Source middlewares/errorHandler.js, line 12

void

# fetchUserProfile(userId, profileCache, grpcClient) → {Promise.<IUserProfile>}

Fetches a user profile using a multi-layered caching strategy.

The function attempts to retrieve the profile in the following order:

  1. Memoization cache (if provided) to prevent duplicate fetches in-flight.
  2. Redis cache for fast retrieval.
  3. gRPC Auth service if cache misses occur.
  4. Falls back to null fields if gRPC fails (best-effort approach).

If a profileCache map is provided, this function will store both in-flight promises and resolved profiles to handle concurrent requests safely.

Parameters:
Name Type Description
userId string

The ID of the user whose profile is being fetched.

profileCache Map.<string, (IUserProfile|Promise.<IUserProfile>)>

Optional memoization cache to prevent duplicate fetches.

grpcClient AuthGrpcService

The gRPC client used to fetch the user if cache misses.

View Source utils/user-profile.utils.js, line 23

  • The resolved user profile with name, avatar, and email fields (nullable if unavailable).
Promise.<IUserProfile>

# formatHistory(chatHistory) → {Array.<IFormattedHistory>}

Formats chat history into the OpenAI message format for LLM requests.

Parameters:
Name Type Description
chatHistory Array.<IChatHistory>

Chat exchanges between the user and assistant.

View Source helpers/history.js, line 7

Array of formatted messages ready for LLM consumption.

Array.<IFormattedHistory>

# fromEditableField(field, defaultValue) → {IInvestigationResponseDto}

Convert Investigation database model to Response DTO

Parameters:
Name Type Description
field IEditableField.<unknown>

The editable field to convert

defaultValue unknown

The default value to use if the field is null or undefined

View Source types/investigation/dto.js, line 17

  • The formatted response DTO
IInvestigationResponseDto

# getDatabaseStatus() → {object}

Snapshot of the current MongoDB connection state.

View Source database/mongo.connection.js, line 124

Connection metadata.

object

# getLessonData(unit, hasInvestigation) → {Promise.<string>}

Retrieves lesson metadata for a given unit and formats it as a string.

Can optionally filter lessons based on whether they have an associated investigation. The returned string includes the unit name and a list of lessons with their numbers, titles, and optionally whether they have an investigation.

Parameters:
Name Type Description
unit string

The unit identifier to fetch lessons for.

hasInvestigation boolean | null

Optional filter to only include lessons that do (true) or do not (false) have an investigation. If null, includes all lessons and shows their investigation status.

View Source utils/lessonsFactory.js, line 13

  • A formatted string containing the unit and lesson information.
Promise.<string>

# getLogger() → {Logger}

Get the logger from the async local storage context

View Source utils/asyncLocalStorage.js, line 8

Logger instance with request ID, or base logger if no context

Logger

# getRedisStatus() → {object}

Snapshot of the Redis client status.

View Source database/redis.client.js, line 90

High-level connection flags.

object

# getRequestId() → {string|undefined}

Get the request ID from the async local storage context

View Source utils/asyncLocalStorage.js, line 19

Request ID string or undefined if not in context

string | undefined

# getUnitNames() → {Promise.<string>}

Retrieves all unique units with their names and descriptions, grouped by grade. Formats the output similar to the detect_unit_from_message prompt format.

View Source utils/lessonsFactory.js, line 43

  • A formatted string containing all units grouped by grade.
Promise.<string>

# hasArrayValue(value) → {boolean}

Type-safe version of hasValue for arrays

Parameters:
Name Type Description
value Array.<unknown> | undefined | null

The value to check

View Source utils/hasValue.js, line 31

  • true if the value is not null and is an array
boolean

# hasNumberValue(value) → {boolean}

Type-safe version of hasValue for numbers

Parameters:
Name Type Description
value number | undefined | null

The value to check

View Source utils/hasValue.js, line 22

  • true if the value is not null
boolean

# hasStringValue(value) → {boolean}

Type-safe version of hasValue for strings

Parameters:
Name Type Description
value string | undefined | null

The value to check

View Source utils/hasValue.js, line 13

  • true if the value is not null, undefined, or empty string
boolean

# initializeDatabases() → {Promise.<void>}

Initialize database connections.

View Source database/index.js, line 10

Propagates connection errors.

unknown

Resolves when MongoDB and Redis are ready.

Promise.<void>

# initializeVault() → {Promise.<void>}

Initializes the Vault service and loads secrets from Vault.

View Source vault/index.js, line 9

  • Promise that resolves when the Vault service is initialized and secrets are loaded.
Promise.<void>

# notFoundHandler(req, res) → {void}

Not Found Handler Middleware

Parameters:
Name Type Description
req Request

The request object

res Response

The response object

View Source middlewares/errorHandler.js, line 39

void

# optionalAuth(options) → {function}

Create optional authentication middleware

Parameters:
Name Type Description
options IAuthMiddlewareOptions

Configuration options for the middleware

View Source middlewares/auth.js, line 202

Express middleware function that optionally authenticates

function

# removeInvestigationObjectCoordinates(investigation) → {IInvestigationWithoutObjectsCoordinatesDto}

Removes the current investigation objects' coordinates

Parameters:
Name Type Description
investigation IInvestigation

The investigation in the model format.

View Source helpers/investigation.js, line 31

The investigation converted to a simple ICreateInvestigationDto format.

IInvestigationWithoutObjectsCoordinatesDto

# requestIdMiddleware(req, res, next)

Middleware to add request ID tracking to each request

Parameters:
Name Type Description
req Request

Express request object

res Response

Express response object

next NextFunction

Express next function

View Source middlewares/requestId.js, line 10

# requireAdmin(options) → {function}

Create middleware that requires admin role

Parameters:
Name Type Description
options Omit.<IAuthMiddlewareOptions, "requiredRoles">

Configuration options (excluding requiredRoles)

View Source middlewares/auth.js, line 181

Express middleware function that only allows admin users

function

# async seedInvestigation() → {Promise.<void>}

Main seed function

View Source scripts/seed-investigation.js, line 563

A promise that resolves when the seed script is completed

Promise.<void>

# setupConnectionEventListeners()

Register listeners for Mongo connection lifecycle events.

View Source database/mongo.connection.js, line 74

# setupRedisEventListeners(client)

Internal helper that wires Redis connection lifecycle logging.

Parameters:
Name Type Description
client Redis

Connected Redis instance.

View Source database/redis.client.js, line 37

# stripMarkdown(text) → {string}

Strips markdown formatting from text while preserving HTML/XML tags. Used to clean AI assistant responses before displaying to users.

Parameters:
Name Type Description
text string

The text containing markdown formatting

View Source utils/markdown.utils.js, line 7

The text with markdown formatting removed

string

# toInvestigationResponseDto(investigation) → {IInvestigationResponseDto}

Convert Investigation database model to Response DTO

Parameters:
Name Type Description
investigation IInvestigation

The investigation document from the database

View Source types/investigation/dto.js, line 40

  • The formatted response DTO
IInvestigationResponseDto

# validateRequest(schema) → {function}

Middleware factory for request validation

Parameters:
Name Type Description
schema object

The schema to validate the request

body ZodSchema.<unknown>

The schema to validate the request body

query ZodSchema.<unknown>

The schema to validate the request query

params ZodSchema.<Record.<string, string>>

The schema to validate the request parameters

View Source middlewares/validateRequest.js, line 16

Express middleware function

function