@maximai/maxim-js
Version:
Maxim AI JS SDK. Visit https://getmaxim.ai for more info.
87 lines • 2.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommitLog = exports.Entity = void 0;
/**
* Enumeration of all entity types supported by the Maxim logging system.
*
* These entities represent different types of components
* that can be logged and tracked within the Maxim observability platform.
*
* @enum {string}
* @readonly
* @example
* // Entity types are used internally by container classes
* const session = new Session(config, writer); // Uses Entity.SESSION
* const trace = new Trace(config, writer); // Uses Entity.TRACE
*/
var Entity;
(function (Entity) {
/** User or system session containing multiple traces */
Entity["SESSION"] = "session";
/** Individual execution trace containing spans and operations */
Entity["TRACE"] = "trace";
/** Hierarchical span within a trace for grouping operations */
Entity["SPAN"] = "span";
/** LLM generation or completion operation */
Entity["GENERATION"] = "generation";
/** User or system feedback on operations */
Entity["FEEDBACK"] = "feedback";
/** Document or information retrieval operation */
Entity["RETRIEVAL"] = "retrieval";
/** Function or tool call execution */
Entity["TOOL_CALL"] = "tool_call";
/** Error or exception occurrence */
Entity["ERROR"] = "error";
/** Storage entity */
Entity["STORAGE"] = "storage";
})(Entity || (exports.Entity = Entity = {}));
/**
* Represents a log action within the Maxim system.
*
* CommitLog instances are used to record all changes to components,
* they are used by the log writer to persist data to the backend.
*
* @class CommitLog
*/
class CommitLog {
/**
* Creates a new commit log entry.
*
* @param entity - The type of entity being logged
* @param entityId - Unique identifier for the entity instance
* @param action - The action being performed (e.g., 'create', 'update', 'end')
* @param data - Data associated with the action
*/
constructor(entity, entityId, action, data) {
this.entity = entity;
this.entityId = entityId;
this.action = action;
this.data = data;
}
/**
* Gets the unique identifier for the entity associated with this log entry.
*
* @returns The entity's unique ID
*/
get id() {
return this.entityId;
}
/**
* Gets the entity type for this log entry.
*
* @returns The entity type enum value
*/
get type() {
return this.entity;
}
/**
* Serializes the commit log to a formatted string representation for logging.
*
* @returns A string representation of the log entry with entity, ID, action, and data
*/
serialize() {
return `${this.entity}{id=${this.entityId},action=${this.action},data=${JSON.stringify(this.data)}}`;
}
}
exports.CommitLog = CommitLog;
//# sourceMappingURL=types.js.map