Typesense_auth.SessionSession management for Typesense CLI with profile support.
This module provides session persistence for Typesense authentication using API keys. Sessions are stored in profile-specific directories under ~/.config/typesense/profiles/<profile>/session.json.
~/.config/typesense/
config.json # Stores current_profile setting
profiles/
default/
session.json # Session for "default" profile
prod/
session.json # Session for "prod" profile (* Login with API key *)
let session = Session.create
~server_url:"http://localhost:8108"
~api_key:"xyz"
() in
Session.save fs ~profile:"default" sessionval create : server_url:string -> api_key:string -> unit -> tcreate ~server_url ~api_key () creates a new session with the current timestamp.
val server_url : t -> stringserver_url t returns the server URL.
val api_key : t -> stringapi_key t returns the API key.
val created_at : t -> stringcreated_at t returns the creation timestamp (RFC 3339).
val get_current_profile : Eio.Fs.dir_ty Eio.Path.t -> stringget_current_profile fs returns the current profile name. Returns default_profile if no profile has been set.
val set_current_profile : Eio.Fs.dir_ty Eio.Path.t -> string -> unitset_current_profile fs profile sets the current profile.
val list_profiles : Eio.Fs.dir_ty Eio.Path.t -> string listlist_profiles fs returns all profiles that have sessions. Returns profile names sorted alphabetically.
val base_config_dir : Eio.Fs.dir_ty Eio.Path.t -> Eio.Fs.dir_ty Eio.Path.tbase_config_dir fs returns the base config directory (~/.config/typesense), creating it if needed.
val config_dir :
Eio.Fs.dir_ty Eio.Path.t ->
?profile:string ->
unit ->
Eio.Fs.dir_ty Eio.Path.tconfig_dir fs ?profile () returns the config directory for a profile, creating it if needed.
val save : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> t -> unitsave fs ?profile session saves the session.
val load : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> t optionload fs ?profile () loads a saved session.
val clear : Eio.Fs.dir_ty Eio.Path.t -> ?profile:string -> unit -> unitclear fs ?profile () removes the saved session.