@oceanum/datamesh / index / Connector
Defined in: packages/datamesh/src/lib/connector.ts:20
new Connector(
token?,options?):Connector
Defined in: packages/datamesh/src/lib/connector.ts:46
Datamesh connector constructor
string = ...
Your datamesh access token. Defaults to environment variable DATAMESH_TOKEN is defined else as literal string “DATAMESH_TOKEN”. DO NOT put your Datamesh token directly into public facing browser code.
Constructor options.
string
URL of gateway service. Defaults to “https://gateway.
string
JWT for Oceanum service.
boolean
Disable caching of datamesh results.
string
URL of datamesh service. Defaults to environment variable DATAMESH_SERVICE or “https://datamesh.oceanum.io”.
number
The desired length of time for acquired datamesh sessions in hours. Will be 1 hour by default.
Connector
optionalgateway?:string
Defined in: packages/datamesh/src/lib/connector.ts:31
optionalservice?:string
Defined in: packages/datamesh/src/lib/connector.ts:30
staticLAZY_LOAD_SIZE:number=1e8
Defined in: packages/datamesh/src/lib/connector.ts:21
get host():
string
Defined in: packages/datamesh/src/lib/connector.ts:101
Get datamesh host.
string
The datamesh server host.
closeSession(
finaliseWrite?):Promise<void>
Defined in: packages/datamesh/src/lib/connector.ts:460
Close the current session if one exists.
boolean = false
Whether to finalise any write operations. Defaults to false.
Promise<void>
A promise that resolves when the session is closed.
createSession(
options?):Promise<Session>
Defined in: packages/datamesh/src/lib/connector.ts:144
Create a new session.
Session options.
number
The desired length of time for the session in hours. Defaults to the value set in the constructor or 1 hour.
Promise<Session>
A new session instance.
getDataObject(
qhash,format):Promise<ArrayBuffer>
Defined in: packages/datamesh/src/lib/connector.ts:291
Download a staged query’s data in a given file format.
Fetches the staged result from the gateway with the requested f format
(e.g. “nc” for NetCDF, “csv”, “geojson”, “arrow”) and returns the raw
response bytes. Use stageRequest first to obtain the qhash (and
to inspect formats/coordkeys).
string
The hash of a staged query (from stageRequest).
string
The f query parameter, e.g. “nc” for NetCDF.
Promise<ArrayBuffer>
The raw response body as an ArrayBuffer.
getDatasource(
datasourceId):Promise<Datasource>
Defined in: packages/datamesh/src/lib/connector.ts:424
Get a datasource instance from the datamesh.
string
Unique datasource ID.
Promise<Datasource>
The datasource instance.
getSession():
Promise<Session>
Defined in: packages/datamesh/src/lib/connector.ts:158
Get the current session, or create a new one if none exists or the current one has expired.
Promise<Session>
The current session.
loadDatasource(
datasourceId,parameters?):Promise<Dataset<HttpZarr|TempZarr> |null>
Defined in: packages/datamesh/src/lib/connector.ts:445
Load a datasource into the work environment.
string
Unique datasource ID.
Record<string, string | number> = {}
Additional datasource parameters.
Promise<Dataset<HttpZarr | TempZarr> | null>
The dataset.
openZarr(
url,options?):Promise<Dataset<HttpZarr>>
Defined in: packages/datamesh/src/lib/connector.ts:408
Open a staged query’s zarr store with the connector’s session attached.
Use this for lazy or schema-only access to a staged result — e.g. reading
dimensions and variables from .zmetadata without downloading chunks. It
attaches the same session + auth headers as query, so callers never
hand-roll zarr auth headers: the gateway requires a v1 session on every
/zarr/query request and returns 401 "Session ID required" without it.
string
Full zarr store URL, e.g. ${gateway}${stage.zarr_endpoint}.
ZarrOptions = {}
Zarr open options (coordkeys, parameters, ttl, timeout, …).
Promise<Dataset<HttpZarr>>
A lazily-opened Dataset backed by the staged zarr store.
query(
query,options?):Promise<Dataset<HttpZarr|TempZarr> |null>
Defined in: packages/datamesh/src/lib/connector.ts:344
Execute a query to the datamesh.
The query to execute.
number
Additional options for the query.
Promise<Dataset<HttpZarr | TempZarr> | null>
The response from the server.
renewSession(
stale?):Promise<Session>
Defined in: packages/datamesh/src/lib/connector.ts:207
Replace a session the gateway has rejected (401): oceanql sessions can be terminated server-side after inactivity, BEFORE their declared end time, so the endTime check in getSession() is not sufficient. Drops the cached session only if it is still the stale one (a concurrent caller may already have replaced it) and acquires a fresh session — concurrent renewals share one acquisition via getSession()’s single-flight.
Session
The session that was rejected.
Promise<Session>
A fresh session.
stageRequest(
query):Promise<Stage|null>
Defined in: packages/datamesh/src/lib/connector.ts:311
Stage a query to the datamesh.
The query to stage.
Promise<Stage | null>
The staged response.
status():
Promise<boolean>
Defined in: packages/datamesh/src/lib/connector.ts:110
Check the status of the metadata server.
Promise<boolean>
True if the server is up, false otherwise.