UNPKG

@deltares/fews-pi-requests

Version:

Library for making requests to the FEWS PI webservice

1,110 lines 44.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PiWebserviceProvider = void 0; const index_js_1 = require("./requestParameters/index.js"); const convertToParameterGroups_js_1 = require("./output/parameters/convertToParameterGroups.js"); const index_js_2 = require("./utils/index.js"); const fews_web_oc_utils_1 = require("@deltares/fews-web-oc-utils"); class PiWebserviceProvider { _baseUrl; maxUrlLength; API_ENDPOINT = 'rest/fewspiservice/v1'; webservice; /** * Constructor for PiWebserviceProvider * * @param url the base url where the PI service is available * @param {Object} [options] Optional constructor options * @param {number} [options.maxUrlLength] A number that specifies the maximum length of the URL. If the URL length exceeds this value, the requests will be split up. * @param {TransformRequestFunction} [options.transformRequestFn] A function that can be used to modify the Request * before it is sent to the server. This function takes a Request as a parameter and returns the modified Request. * If this option is not specified, the Request will be sent as is. */ constructor(url, options = {}) { if (!url.endsWith("/")) { url += "/"; } this._baseUrl = (0, index_js_2.absoluteUrl)(url); this.maxUrlLength = options.maxUrlLength ?? Infinity; this.webservice = new fews_web_oc_utils_1.PiRestService(url, options.transformRequestFn); } /** * Request locations * * @param filter an object with request query parameters * @returns Locations PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getLocations(filter) { const url = this.locationsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request log displays * * @returns Locations PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getLogDisplays(filter) { const url = this.logDisplaysUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request locations * * @param filter an object with request query parameters * @returns LocationsTooltip API response * @throws 'Fetch Error' if fetch result is not ok */ async getLocationsTooltip(filter) { const url = this.locationsTooltipUrl(filter).toString(); const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.startsWith('http'); const res = await this.webservice.getDataWithParser(url, requestOptions, parser); return res.data; } /** * Request the history of the edits * * @param filter an object with request query parameters * @returns Locations PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getHistoryEdits(filter) { let url = filter.editUrl; for (const time in filter.times) { url = url + "&times=" + filter.times[time]; } const res = await this.webservice.getData(url); return res.data; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async getParameters(filter, output) { const url = this.parametersUrl(filter); const res = await this.webservice.getData(url.toString()); if (output?.type === 'parameterGroups') { return (0, convertToParameterGroups_js_1.convertToParameterGroups)(res.data); } return res.data; } /** * Request time series with a relative url * @param relativeUrl * @returns time series api response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeriesWithRelativeUrl(relativeUrl) { const url = new URL(relativeUrl, this._baseUrl); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request Time Series * * @param filter an object with request query parameters * @returns Time Series PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeriesTopologyActions(filter) { const defaults = { documentFormat: index_js_1.DocumentFormat.PI_JSON, }; const filterWithDefaults = { ...defaults, ...filter }; const url = this.timeSeriesTopologyActionsUrl(filterWithDefaults); return await this.getTimeSeriesResponse(url); } /** * Request Time Series * * @param filter an object with request query parameters * @returns Time Series PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeries(filter) { const defaults = { documentFormat: index_js_1.DocumentFormat.PI_JSON, }; const filterWithDefaults = { ...defaults, ...filter }; const url = this.timeSeriesUrl(filterWithDefaults); return await this.getTimeSeriesResponse(url); } async getTimeSeriesResponse(url) { if (url.toString().length <= this.maxUrlLength) { const res = await this.webservice.getData(url.toString()); return res.data; } else { const urls = (0, index_js_2.splitUrl)(url, this.maxUrlLength); const promises = urls.map((u) => this.webservice.getData(u.toString())); return Promise.all(promises).then((responses) => { const response = responses[0].data; if (response.timeSeries !== undefined) { for (let i = 1; i < responses.length; i++) { if (responses[i].data.timeSeries === undefined) continue; response.timeSeries.push(...responses[i].data.timeSeries || []); } } return response; }); } } /** * Request Time Series Grid * * @param filter an object with request query parameters * @returns Time Series Grid PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeriesGrid(filter) { const defaults = { documentFormat: index_js_1.DocumentFormat.PI_JSON, }; const filterWithDefaults = { ...defaults, ...filter }; const url = this.timeSeriesGridUrl(filterWithDefaults); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request Time Series Grid Actions * * @param filter an object with request query parameters * @returns Time Series Grid Actions PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeriesGridActions(filter) { const url = this.timeSeriesGridActionsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request time series maximum values for a WMS layer. * * @param filter an object with request query parameters * @returns Time series with maximum values for a WMS layer. * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSeriesGridMaxValues(filter) { const url = this.timeSeriesGridMaxValuesUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Request scheduled tasks * * @param filter an object with request query parameters * @returns task runs PI API response * @throws 'Fetch Error' if fetch result is not ok */ async getTaskRuns(filter) { const defaults = {}; const filterWithDefaults = { ...defaults, ...filter }; const url = this.taskRunsUrl(filterWithDefaults); return await this.getTaskRunsResponse(url); } async getTaskRunsResponse(url) { if (url.toString().length <= this.maxUrlLength) { const res = await this.webservice.getData(url.toString()); return res.data; } const urls = (0, index_js_2.splitUrl)(url, this.maxUrlLength).map((u) => u.toString()); const promises = urls.map((url) => this.webservice.getData(url)); const responses = await Promise.all(promises); const taskRuns = responses.flatMap(res => res.data.taskRuns ?? []); const response = responses[0].data; if (taskRuns.length) { response.taskRuns = taskRuns; } return response; } /** * Get all the topology nodes of FEWS * * @returns all the topology nodes configured in FEWS * @throws 'Fetch Error' if fetch result is not ok */ async getTopologyNodes() { const url = this.topologyNodesUrl(); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get all the active thresholds for the topology nodes * * @param filter an object with request query parameters * @returns all the active thresholds for the topology nodes * @throws 'Fetch Error' if fetch result is not ok */ async getTopologyThresholds(filter) { const url = this.topologyThresholdsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the import status of FEWS * * @returns import status API response * @throws 'Fetch Error' if fetch result is not ok */ async getImportStatus() { const url = this.importStatusUrl(); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the import status of FEWS * * @returns import status API response * @throws 'Fetch Error' if fetch result is not ok */ async getVersion() { const queryParameters = "documentFormat=PI_JSON"; const url = this.versionUrl(queryParameters); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the time zone used in FEWS * * @returns import status API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeZoneId() { const url = this.timeZoneIdUrl().toString(); const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.startsWith('http'); const res = await this.webservice.getDataWithParser(url.toString(), requestOptions, parser); return res.data; } /** * Get the configuration of FEWS related to the Web OC. * * @returns Web OC configuration API response * @throws 'Fetch Error' if fetch result is not ok */ async getWebOcConfiguration() { const defaults = { documentFormat: index_js_1.DocumentFormat.PI_JSON, }; const url = this.webOcConfigurationUrl(defaults); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the configuration of FEWS related to the Web OC that is always available. * * @returns Web OC public configuration API response * @throws 'Fetch Error' if fetch result is not ok */ async getWebOcPublicConfiguration() { const defaults = { documentFormat: index_js_1.DocumentFormat.PI_JSON, }; const url = this.webOcPublicConfigurationUrl(defaults); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get colors that should be used for plotting * @returns colors API response * @throws 'Fetch Error' if fetch result is not ok */ async getColors() { const url = new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/colors/default`, this._baseUrl); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the actions for a certain topology node * * @param filter search options for the displays (nodeId) * @returns Display groups API response * @throws 'Fetch Error' if fetch result is not ok */ async getTopologyActions(filter) { const url = this.topologyActionsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } async getDisplayGroupsNodes() { const url = this.displayGroupsNodesUrl(); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the time series flags * * @returns Time series flags API response * @throws 'Fetch Error' if fetch result is not ok */ async getFlags() { const url = this.flagsUrl(); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the time series flag sources * * @returns Time series flag sources API response * @throws 'Fetch Error' if fetch result is not ok */ async getFlagSources() { const url = this.flagSourcesUrl(); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the actions for filter * * @param filter search options * @returns Actions API response * @throws 'Fetch Error' if fetch result is not ok */ async getFilterActions(filter) { const url = this.filterActionsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the workflows * * @param filter search options * @returns Workflows API response * @throws 'Fetch Error' if fetch result is not ok */ async getWorkflows(filter) { const url = this.workflowsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the module run times * * @param filter search options * @returns Module run times API response * @throws 'Fetch Error' if fetch result is not ok */ async getModuleRunTimes(filter) { const url = this.moduleRunTimesUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the dashboards * * @param filter search options * @returns Dashboards API response * @throws 'Fetch Error' if fetch result is not ok */ async getDashboards(filter) { const url = this.dashboardsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the logdisplay logs * * @param filter search options * @returns LogsDisplayLogsResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getLogDisplayLogs(filter) { const url = this.logDisplayLogsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Post a log display action * * @param request the log display action request * @returns the response from the server * @throws 'Fetch Error' if fetch result is not ok * */ async postLogDisplaysAction(request) { const { logDisplayId, ...body } = request; const url = this.logDisplayActionUrl(logDisplayId); const headers = { 'Content-Type': "application/json" }; const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.toString().startsWith("http"); const res = await this.webservice.postDataWithParser(url.toString(), requestOptions, parser, JSON.stringify(body), headers); return res.data; } /** * Get the what if templates * * @param filter search options * @returns WhatIfTemplates API response * @throws 'Fetch Error' if fetch result is not ok */ async getWhatIfTemplates(filter) { const url = this.whatIfTemplatesUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the component settings * * @param filter search options * @returns ComponentSettings API response * @throws 'Fetch Error' if fetch result is not ok */ async getComponentSettings(filter) { const url = this.componentSettingsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the forecaster notes * * @param filter search options * @returns ForecasterNotes API response * @throws 'Fetch Error' if fetch result is not ok */ async getForecasterNotes(filter) { const url = this.forecasterNotesUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the FSS info * * @param filter search options * @returns WorkflowFssInfo API response * @throws 'Fetch Error' if fetch result is not ok */ async getFssInfo(filter) { const url = this.fssInfoUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the forecast times * * @param filter search options * @returns WorkflowForecastTimes API response * @throws 'Fetch Error' if fetch result is not ok */ async getForecastTimes(filter) { const url = this.forecastTimesUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } async postForecasterNoteHelper(body, url) { const headers = { 'Content-Type': "application/json" }; const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.toString().startsWith("http"); const res = await this.webservice.postDataWithParser(url.toString(), requestOptions, parser, JSON.stringify(body), headers); return res.data; } /** * Post or update a forecaster note * * @param note the forecaster note to post * @returns whether the post was successful * @throws 'Fetch Error' if fetch result is not ok */ async postForecasterNote(note) { const url = this.forecasterNotesUrl({}); return await this.postForecasterNoteHelper(note, url); } /** * Delete forecaster notes * * @param keys the forecaster note to post * @returns whether the deletion was successful * @throws 'Fetch Error' if fetch result is not ok */ async deleteForecasterNote(keys) { const url = this.forecasterNotesUrl({}, "delete"); return await this.postForecasterNoteHelper(keys, url); } /** * Acknowledge forecaster notes * * @param keys the forecaster notes to acknowledge * @returns whether the acknowledgement was successful * @throws 'Fetch Error' if fetch result is not ok */ async acknowledgeForecasterNote(keys) { const url = this.forecasterNotesUrl({}, "acknowledge"); return await this.postForecasterNoteHelper(keys, url); } /** * Unacknowledge forecaster notes * * @param keys the forecaster notes to unacknowledge * @returns whether the acknowledgement was successful * @throws 'Fetch Error' if fetch result is not ok */ async unacknowledgeForecasterNote(keys) { const url = this.forecasterNotesUrl({}, "unacknowledge"); return await this.postForecasterNoteHelper(keys, url); } /** * Get the what if scenarios * * @param filter search options * @returns WhatIfScenarios API response * @throws 'Fetch Error' if fetch result is not ok */ async getWhatIfScenarios(filter) { const url = this.whatIfScenariosUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Post time series edits. * * @param editUrl URL to post the time series edits to * @param timeSeriesEvents Time Series Events to be updated * @returns Updated time series events * @throws 'Fetch Error' if fetch result is not ok */ async postTimeSeriesEdit(editUrl, timeSeriesEvents) { const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !editUrl.toString().startsWith("http"); const headers = { 'Content-Type': "application/json" }; const res = await this.webservice.postDataWithParser(editUrl, requestOptions, new fews_web_oc_utils_1.PlainTextParser(), JSON.stringify(timeSeriesEvents), headers); return res.data; } /** * Runs a workflow task for a given workflowId. * * @param filter an object with request query parameters * @param piParametersXmlContent URL Encoded model parameters content that validates against the * following xsd: https://fewsdocs.deltares.nl/schemas/version1.0/pi-schemas/pi_modelparameters.xsd * * @returns the taskId of the submitted job. * @throws 'Fetch Error' if fetch result is not ok */ async postRunTask(filter, piParametersXmlContent) { const url = this.runTaskUrl(filter); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.toString().startsWith("http"); const headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; const res = await this.webservice.postDataWithParser(url.toString(), requestOptions, new fews_web_oc_utils_1.PlainTextParser(), piParametersXmlContent, headers); return res.data; } /** * Runs a what if scenario for a given whatIfTemplateId. * * @param filter an object with request query parameters * @param piParametersXmlContent URL Encoded model parameters content that validates against the * following xsd: https://fewsdocs.deltares.nl/schemas/version1.0/pi-schemas/pi_modelparameters.xsd * @returns the WhatIfScenario of the submitted job. * @throws 'Fetch Error' if fetch result is not ok */ async postWhatIfScenario(filter, piParametersXmlContent) { const url = this.postWhatIfScenarioUrl(filter); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.toString().startsWith("http"); const headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; const res = await this.webservice.postDataWithParser(url.toString(), requestOptions, new fews_web_oc_utils_1.DefaultParser(), piParametersXmlContent, headers); return res.data; } /** * Get the reports for filter * * @param filter search options * @returns Reports API response * @throws 'Fetch Error' if fetch result is not ok */ async getReports(filter) { const url = this.reportsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the report for filter * * @param filter search options * @returns Report API response * @throws 'Fetch Error' if fetch result is not ok */ async getReport(filter) { const url = this.reportUrl(filter).toString(); const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.startsWith('http'); const res = await this.webservice.getDataWithParser(url, requestOptions, parser); return res.data; } /** * Get the dynamic display for filter * * @param filter search options * @returns Report API response * @throws 'Fetch Error' if fetch result is not ok */ async getDynamicReportDisplay(filter) { const url = this.dynamicReportDisplayUrl(filter).toString(); const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.startsWith('http'); const res = await this.webservice.getDataWithParser(url, requestOptions, parser); return res.data; } /** * Get the dynamic display capabilities for filter * * @param filter search options * @returns Report API response * @throws 'Fetch Error' if fetch result is not ok */ async getDynamicReportDisplayCapabilities(filter) { const url = this.dynamicReportDisplayUrl(filter, 'capabilities').toString(); const res = await this.webservice.getData(url); return res.data; } /** * Get the dynamic display data for filter * * @param filter search options * @returns Report API response * @throws 'Fetch Error' if fetch result is not ok */ async getDynamicReportDisplayData(filter) { const url = this.dynamicReportDisplayUrl(filter, 'data').toString(); const res = await this.webservice.getData(url); return res.data; } /** * Get the time steps for filter * * @param filter search options * @returns TimeStepsResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getTimeSteps(filter) { const url = this.timeStepsUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the correlation for filter * * @param filter search options * @returns CorrelationResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getCorrelation(filter) { const url = this.correlationUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the data analysis displays for filter * * @param filter search options * @returns DataAnalysisDisplaysResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getDataAnalysisDisplays(filter) { const url = this.dataAnalysisDisplaysUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the task run status for filter * * @param filter search options * @returns TaskRunStatusResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getTaskRunStatus(filter) { const url = this.taskRunStatusUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Get the user settings for filter * * @param filter search options * @returns UserSettingsResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getUserSettings(filter, parser) { const url = this.userSettingsUrl(filter); const requestOption = new fews_web_oc_utils_1.RequestOptions(); requestOption.relativeUrl = !url.toString().startsWith("http"); const res = await this.webservice.getDataWithParser(url.toString(), requestOption, parser ?? new fews_web_oc_utils_1.DefaultParser()); return res.data; } /** * Post the user settings for filter * * @param filter search options * @param body the body of the request * @returns the response from the server * @throws 'Fetch Error' if fetch result is not ok */ async postUserSettings(filter, body) { const url = this.userSettingsUrl(filter); const headers = { 'Content-Type': "application/json" }; const parser = new fews_web_oc_utils_1.PlainTextParser(); const requestOptions = new fews_web_oc_utils_1.RequestOptions(); requestOptions.relativeUrl = !url.toString().startsWith("http"); const res = await this.webservice.postDataWithParser(url.toString(), requestOptions, parser, body, headers); return res.data; } /** * Get the user settings users for filter * * @param filter search options * @returns UserSettingUsersResponse API response * @throws 'Fetch Error' if fetch result is not ok */ async getUserSettingsUsers(filter) { const url = this.userSettingsUsersUrl(filter); const res = await this.webservice.getData(url.toString()); return res.data; } /** * Construct URL for locations request * * @param filter an object with request query parameters * @returns complete url for making a request */ locationsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/locations${queryParameters}`, this._baseUrl); } /** * Construct URL for log displays request * * @returns complete url for making a request */ logDisplaysUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/logdisplays${queryParameters}`, this._baseUrl); } /** * Construct URL for locations tooltip request * * @param filter an object with request query parameters * @returns complete url for making a request */ locationsTooltipUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/locations/tooltip${queryParameters}`, this._baseUrl); } /** * Construct URL for history edits request * * @param filter an object with request query parameters * @returns complete url for making a request */ historyEditsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/history/${queryParameters}`, this._baseUrl); } /** * Construct URL for parameters request * * @param filter an object with request query parameters * @returns complete url for making a request */ parametersUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/parameters${queryParameters}`, this._baseUrl); } /** * Construct URL for time series request * * @param filter an object with request query parameters * @returns complete url for making a request */ timeSeriesUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries${queryParameters}`, this._baseUrl); } /** * Construct URL for time series grid request * * @param filter an object with request query parameters * @returns complete url for making a request */ timeSeriesGridUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/grid${queryParameters}`, this._baseUrl); } /** * Constructs URL for time series grid max values request * * @param filter an object with request query parameters * @returns complete url for making a request */ timeSeriesGridMaxValuesUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/grid/maxvalues${queryParameters}`, this._baseUrl); } /** * Construct URL for display groups request * * @param filter an object with request query parameters * @returns complete url for making a request */ topologyActionsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/topology/actions${queryParameters}`, this._baseUrl); } /** * Construct URL for time series grid actions request * @param filter an object with request query parameters * @returns */ timeSeriesGridActionsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/grid/actions${queryParameters}`, this._baseUrl); } /** * Construct URL for filter actions request * * @param filter an object with request query parameters * @returns complete url for making a request */ filterActionsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/filters/actions${queryParameters}`, this._baseUrl); } /** * Construct URL for display group nodes request * * @returns complete url for making a request */ displayGroupsNodesUrl() { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/displaygroups/nodes`, this._baseUrl); } /** * Construct URL for module run times request * * @param filter an object with request query parameters * @returns complete url for making a request */ taskRunsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/taskruns${queryParameters}`, this._baseUrl); } /** * Construct URL for import status request * * @returns complete url for making a request */ importStatusUrl() { const queryParameters = "documentFormat=PI_JSON"; return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/import/status?${queryParameters}`, this._baseUrl); } /** * Construct URL for version information * * @param queryParameters query string * @returns complete url for making a request */ versionUrl(queryParameters) { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/version?${queryParameters}`, this._baseUrl); } /** * Construct URL for time zone information * * @returns complete url for making a request */ timeZoneIdUrl() { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timezoneid`, this._baseUrl); } /** * Construct URL for Web OC configuration * * @returns complete url for making a request */ webOcConfigurationUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/weboc/config${queryParameters}`, this._baseUrl); } /** * Construct URL for Web OC configuration * * @returns complete url for making a request */ webOcPublicConfigurationUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/weboc/config/public${queryParameters}`, this._baseUrl); } /** * * Construct URL for static resources from the Delft-FEWS WebResourceFiles configuration folder. * In case an absolute URL is passed, the passed path will be returned as URL. * * @returns complete url for making a request */ resourcesStaticUrl(resource) { if (resource.startsWith("http://") || resource.startsWith("https://")) return new URL(resource); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/resources/static/${resource}`, this._baseUrl); } /** * * Construct URL for icon file from the IconFiles folder. * In case an absolute URL is passed, the passed path will be returned as URL. * * @returns complete url for making a request */ resourcesIconsUrl(resource) { if (resource.startsWith("http://") || resource.startsWith("https://")) return new URL(resource); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/resources/icons/${resource}`, this._baseUrl); } /** * Construct URL for topology nodes request * * @returns complete url for making a request */ topologyNodesUrl() { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/topology/nodes`, this._baseUrl); } /** * Construct URL for topology thresholds request * * @param filter an object with request query parameters * @returns complete url for making a request */ topologyThresholdsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/topology/thresholds${queryParameters}`, this._baseUrl); } timeSeriesTopologyActionsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/topology/actions${queryParameters}`, this._baseUrl); } flagsUrl() { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/flags`, this._baseUrl); } flagSourcesUrl() { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/flagsources`, this._baseUrl); } processDataUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/processdata${queryParameters}`, this._baseUrl); } runTaskUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/runtask${queryParameters}`, this._baseUrl); } reportsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/reports${queryParameters}`, this._baseUrl); } reportUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/report${queryParameters}`, this._baseUrl); } dynamicReportDisplayUrl(filter, path) { const queryParameters = (0, index_js_2.filterToParams)(filter); if (path) { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/dynamicreportdisplays/${path}${queryParameters}`, this._baseUrl); } return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/dynamicreportdisplays${queryParameters}`, this._baseUrl); } workflowsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/workflows${queryParameters}`, this._baseUrl); } moduleRunTimesUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/moduleruntimes${queryParameters}`, this._baseUrl); } dashboardsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/dashboards${queryParameters}`, this._baseUrl); } logDisplayLogsUrl(filter) { const { logDisplayId, ...remainingFilter } = filter; const queryParameters = (0, index_js_2.filterToParams)(remainingFilter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/logdisplays/${logDisplayId}/logs${queryParameters}`, this._baseUrl); } logDisplayActionUrl(logDisplayId) { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/logdisplays/${logDisplayId}/action`, this._baseUrl); } whatIfScenariosUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/whatifscenarios${queryParameters}`, this._baseUrl); } whatIfTemplatesUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/whatiftemplates${queryParameters}`, this._baseUrl); } postWhatIfScenarioUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/whatifscenarios${queryParameters}`, this._baseUrl); } componentSettingsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/weboc/config/componentsettings${queryParameters}`, this._baseUrl); } forecasterNotesUrl(filter, action) { const queryParameters = (0, index_js_2.filterToParams)(filter); if (action) { return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/forecasternotes/${action}/${queryParameters}`, this._baseUrl); } return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/forecasternotes${queryParameters}`, this._baseUrl); } fssInfoUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/workflows/fssinfo${queryParameters}`, this._baseUrl); } forecastTimesUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/workflows/forecasttimes${queryParameters}`, this._baseUrl); } timeSeriesFilterActionsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timeseries/filters/actions${queryParameters}`, this._baseUrl); } timeStepsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/timesteps${queryParameters}`, this._baseUrl); } correlationUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/statistics/correlation${queryParameters}`, this._baseUrl); } dataAnalysisDisplaysUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/dataanalysisdisplays${queryParameters}`, this._baseUrl); } taskRunStatusUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/taskrunstatus${queryParameters}`, this._baseUrl); } userSettingsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/usersettings${queryParameters}`, this._baseUrl); } postUserSettingsUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/usersettings${queryParameters}`, this._baseUrl); } userSettingsUsersUrl(filter) { const queryParameters = (0, index_js_2.filterToParams)(filter); return new URL(`${this._baseUrl.pathname}${this.API_ENDPOINT}/usersettings/users${queryParameters}`, this._baseUrl); } } exports.PiWebserviceProvider = PiWebserviceProvider; //# sourceMappingURL=piWebserviceProvider.js.map