Typesense_auth.ClientAuthenticated Typesense client with session persistence and profile support.
This module provides a high-level client that wraps the generated Typesense module with authentication support. Sessions are stored in profile-specific directories.
let t = Client.login ~sw ~env
~server_url:"http://localhost:8108"
~api_key:"xyz123"
() in
let collections = Typesense.Collections.list_collections (Client.client t) () match Session.load fs () with
| Some session ->
let t = Client.resume ~sw ~env ~session () in
...
| None ->
Fmt.epr "Not logged in@."val login :
sw:Eio.Switch.t ->
env:
< clock : _ Eio.Time.clock
; net : _ Eio.Net.t
; fs : Eio.Fs.dir_ty Eio.Path.t.. > ->
?requests_config:Requests.Cmd.config ->
?profile:string ->
server_url:string ->
api_key:string ->
unit ->
tlogin ~sw ~env ?requests_config ?profile ~server_url ~api_key () authenticates using an API key. The API key is sent in the X-TYPESENSE-API-KEY header for all requests.
val resume :
sw:Eio.Switch.t ->
env:
< clock : _ Eio.Time.clock
; net : _ Eio.Net.t
; fs : Eio.Fs.dir_ty Eio.Path.t.. > ->
?requests_config:Requests.Cmd.config ->
?profile:string ->
session:Session.t ->
unit ->
tresume ~sw ~env ?requests_config ?profile ~session () resumes from a saved session.
val logout : t -> unitlogout t clears the session from disk.
val client : t -> Typesense.tclient t returns the underlying Typesense client for API calls.
val profile : t -> string optionprofile t returns the current profile name, if set.
val fs : t -> Eio.Fs.dir_ty Eio.Path.tfs t returns the filesystem capability.
These functions provide bulk document operations using JSONL format, which is more efficient than individual API calls for large batches.
Result of importing a single document.
val import :
t ->
collection:string ->
?action:import_action ->
?batch_size:int ->
?return_doc:bool ->
?return_id:bool ->
Jsont.json list ->
import_result listimport t ~collection documents imports documents using JSONL format.
val export_params :
?filter_by:string ->
?include_fields:string list ->
?exclude_fields:string list ->
unit ->
export_paramsCreate export parameters.
val export :
t ->
collection:string ->
?params:export_params ->
unit ->
Jsont.json listexport t ~collection ?params () exports documents as JSONL.