diff --git a/crates/brk_bindgen/src/generators/javascript/client.rs b/crates/brk_bindgen/src/generators/javascript/client.rs index ab24cbb60..0c5cef793 100644 --- a/crates/brk_bindgen/src/generators/javascript/client.rs +++ b/crates/brk_bindgen/src/generators/javascript/client.rs @@ -51,19 +51,20 @@ class BrkError extends Error {{ /** * @template T - * @typedef {{Object}} Endpoint - * @property {{(onUpdate?: (value: T[]) => void) => Promise}} get - Fetch all data points - * @property {{(from?: number, to?: number, onUpdate?: (value: T[]) => void) => Promise}} range - Fetch data in range + * @typedef {{Object}} MetricEndpoint + * @property {{(onUpdate?: (value: MetricData) => void) => Promise>}} get - Fetch all data points + * @property {{(from?: number, to?: number, onUpdate?: (value: MetricData) => void) => Promise>}} range - Fetch data in range * @property {{string}} path - The endpoint path */ +/** @typedef {{MetricEndpoint}} AnyMetricEndpoint */ /** * @template T * @typedef {{Object}} MetricPattern * @property {{string}} name - The metric name - * @property {{Partial>>}} by - Index endpoints (lazy getters) + * @property {{Partial>>}} by - Index endpoints (lazy getters) * @property {{() => Index[]}} indexes - Get the list of available indexes - * @property {{(index: Index) => Endpoint|undefined}} get - Get an endpoint for a specific index + * @property {{(index: Index) => MetricEndpoint|undefined}} get - Get an endpoint for a specific index */ /** @typedef {{MetricPattern}} AnyMetricPattern */ @@ -74,7 +75,7 @@ class BrkError extends Error {{ * @param {{BrkClientBase}} client * @param {{string}} name - The metric vec name * @param {{Index}} index - The index name - * @returns {{Endpoint}} + * @returns {{MetricEndpoint}} */ function _endpoint(client, name, index) {{ const p = `/api/metric/${{name}}/${{index}}`; @@ -232,7 +233,7 @@ pub fn generate_index_accessors(output: &mut String, patterns: &[IndexSetPattern let by_fields: Vec = pattern .indexes .iter() - .map(|idx| format!("{}: Endpoint", idx.serialize_long())) + .map(|idx| format!("{}: MetricEndpoint", idx.serialize_long())) .collect(); let by_type = format!("{{ {} }}", by_fields.join(", ")); @@ -240,7 +241,7 @@ pub fn generate_index_accessors(output: &mut String, patterns: &[IndexSetPattern writeln!(output, " * @template T").unwrap(); writeln!( output, - " * @typedef {{{{ name: string, by: {}, indexes: () => Index[], get: (index: Index) => Endpoint|undefined }}}} {}", + " * @typedef {{{{ name: string, by: {}, indexes: () => Index[], get: (index: Index) => MetricEndpoint|undefined }}}} {}", by_type, pattern.name ) .unwrap();