HydrologicEngineeringCenter / cwms-data-api-client-javascript

A JavaScript wrapper for the CWMS Data API (CDA), a RESTful web service for managing water data. https://www.npmjs.com/package/cwmsjs The Documentation is the link below:
https://hydrologicengineeringcenter.github.io/cwms-data-api-client-javascript/
2 stars 0 forks source link

TS Group endpoint returns undefined for all entries #2

Closed jbkolze closed 3 weeks ago

jbkolze commented 1 month ago

Data appears to be getting lost between the actual response and the returned object.

Using the getCwmsDataTimeseriesGroupWithGroupId() function with the following parameters: { groupId: "USGS TS Data Acquisition", office: "CWMS", categoryId: "Data Acquisition", }

The following response is returned:

{
    "office-id": "CWMS",
    "id": "USGS TS Data Acquisition",
    "time-series-category": {
        "office-id": "CWMS",
        "id": "Data Acquisition",
        "description": "These TS Groups are used to manage data aquisition from other organizations"
    },
    "description": "These TS Id's will be used to store data acquired from the USGS",
    "assigned-time-series": [
        {
            "office-id": "LRL",
            "timeseries-id": "Nolin-Lake.Stage.Inst.5Minutes.0.USGS-raw",
            "ts-code": 6317109,
            "alias-id": "60325",
            "attribute": 0
        },
...

but in the returned object the assignedTimeSeries entries are all like this:

{
    "office-id": undefined
    "timeseries-id": undefined
    "ts-code": undefined
    "alias-id": undefined
    "attribute": 0
},
jbkolze commented 1 month ago

Code, as requested:

import { useQuery } from "@tanstack/react-query";
import { Configuration, TimeseriesGroupsApi } from "cwmsjs";

const useCdaTimeSeriesGroup = ({ cdaParams, cdaUrl, queryOptions }) => {
  const configOptions = {
    headers: {
      accept: "application/json",
    },
  };
  if (cdaUrl) configOptions.basePath = cdaUrl;
  const configV2 = new Configuration(configOptions);
  const timeseriesGroupsApi = new TimeseriesGroupsApi(configV2);

  return useQuery({
    queryKey: ["cda", "timeseries-group", cdaParams.groupId],
    queryFn: async () =>
      timeseriesGroupsApi.getCwmsDataTimeseriesGroupWithGroupId(cdaParams),
    ...queryOptions,
  });
};

export { useCdaTimeSeriesGroup };
export default useCdaTimeSeriesGroup;
useCdaTimeSeriesGroup({
    cdaParams: {
      groupId: "USGS TS Data Acquisition",
      office: "CWMS",
      categoryId: "Data Acquisition",
    },
  });
krowvin commented 3 weeks ago

Believe this was resolved and we are waiting to push the code because of the typescript changes