Members
(constant) datasetStatusEnum
The values of this enum should match values of the 'status' column
in the query in fetchLpaOverview middleware
- Source:
(constant) fetchLocalAuthorities
Fetches a list of local authority names from a specified dataset.
This function queries a dataset for local authorities, extracting a distinct list of names. It performs an HTTP GET request to retrieve the data, then processes the response to return only the names of the local authorities.
(constant) fetchPaginated
- Source:
(constant) fieldToColumnMapping
- Source:
(constant) generatePaginatedGeoJsonLinks
- Source:
(constant) getDeadlineHistory
Calculates the deadline date and its historical dates (last year's deadline, two years ago's deadline) based on the provided deadline string.
- Source:
Example
const deadline = 'XXXX-03-15T14:30:00Z';
const deadlines = getDeadlineHistory(deadline);
console.log(deadlines);
// Output:
// {
// deadlineDate: <Date>,
// lastYearDeadline: <Date>,
// twoYearsAgoDeadline: <Date>
// }
(constant) getIssueDetails
Middleware. Renders the issue details page with the list of issues, entry data, and organisation and dataset details.
(constant) getIssueField
Returns a data in a format used by the govukSummaryList component.
(constant) invalidSchemaPaths
Extract invalid schema paths from a validation error
- Source:
(constant) isFeatureEnabled
- Source:
(constant) makeDatasetSlugToReadableNameFilter
Creates a filter function that takes a dataset slug as input and returns its corresponding readable name. The filter function uses a provided dataset name mapping to look up the readable name.
(constant) prepareDatasetEndpointIssueTemplateParams
(constant) prepareGetOrganisationsTemplateParams
Middleware. Updates req with templateParams.
(constant) prepareTask
Middleware. Updates req.locals with task, field and issueType
(constant) proto
We wanto to override nunjucks.render() with a function that validates the params against a schema.
- Source:
(constant) render
Render a template with validation in non-production environments
If validation error is raised, it's logged and re-thrown.
Motivation: we want to ensure in development/test environments, that the data passed to our templates is valid. This will help us ensure that we're testing the right thing.
Note: Relies on config.environment
- Source:
(constant) requiredDatasets :Array.<RequiredDataset>
Type:
- Array.<RequiredDataset>
- Source:
(constant) show404ifNoIssues
(constant) splitByLeading
Makes sure the 'reference' and 'name' columns come first.
- Source:
(constant) statusToTagClassMapping
maps dataset status (as returned by fetchLpaOverview middleware to a
CSS class used by the govuk-tag component
- Source:
(constant) taskStatus :Object
Type:
- Object
- Source:
(constant) templateSchema
This acts as a registry of template -> schema for convenience.
- Source:
(constant) types
Types of logging events.
Use as a value for 'type' entry of info objects
- Source:
Methods
aggregateIssues(req, res, next)
Aggregate issues by issue_type into tasks
Updates req with aggregatedTasks: Map<string, task> (keys are composites of issue type and field),
and tasks array.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
* | request |
res |
* | response |
next |
* | next function |
- Source:
attachFileToIssue(issueKey, file) → {Promise}
Attaches a file to an existing JIRA issue.
Parameters:
| Name | Type | Description |
|---|---|---|
issueKey |
string | The key of the issue to which the file will be attached. |
file |
File | The file to be attached to the issue. |
- Source:
Throws:
-
- Throws an error if JIRA_URL, JIRA_BASIC_AUTH, or JIRA_SERVICE_DESK_ID are not set.
- Type
- Error
Returns:
- A promise that resolves to the response of the JIRA API.
- Type
- Promise
availableDatasets(dataSubjects) → {Array.<Dataset>}
Gets the list of available datasets sorted by display text
Parameters:
| Name | Type | Description |
|---|---|---|
dataSubjects |
Object | Data subjects configuration object |
- Source:
Returns:
Array of available datasets sorted by text property
- Type
- Array.<Dataset>
checkToolDeepLink(organisation, dataset) → {string}
Returns the deep link to the check tool for a given dataset and organisation
Parameters:
| Name | Type | Description |
|---|---|---|
organisation |
Object | |
dataset |
Object |
- Source:
Returns:
- Type
- string
createCustomerRequest(summary, description, requestTypeId) → {Promise}
Creates a customer request in JIRA Service Desk.
Parameters:
| Name | Type | Description |
|---|---|---|
summary |
string | The summary of the customer request. |
description |
string | The description of the customer request. |
requestTypeId |
string | The ID of the request type. |
- Source:
Throws:
-
- Throws an error if JIRA_URL, JIRA_BASIC_AUTH, or JIRA_SERVICE_DESK_ID are not set.
- Type
- Error
Returns:
- A promise that resolves to the response of the JIRA API.
- Type
- Promise
endpointSubmissionFormToolDeepLink(organisation, dataset) → {string}
Returns the deep link to the endpoint submission form for a given dataset and organisation
Parameters:
| Name | Type | Description |
|---|---|---|
organisation |
Object | |
dataset |
Object |
Returns:
- Type
- string
(async) fetchBatched(options) → {Promise.<Array.<Array.<Object>>>}
Given a task factor function, executes a number of async tasks in parallel,
but only at most options.concurrency tasks are in flight.
Note: the tasks should be IO bound.
If any of the tasks fail, the whole operation fails (in other words: no partial results).
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object |
- Source:
Returns:
- Type
- Promise.<Array.<Array.<Object>>>
(async) fetchDatasetTypology(req, res, next)
Middleware to fetch typology of dataset.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
* | request object |
res |
* | response object |
next |
* | next middleware function |
- Source:
fetchResponseDetails(req, res, next) → {Promise.<void>}
Parameters:
| Name | Type | Description |
|---|---|---|
req |
RequestWithDetails | Request object |
res |
Object | Response object |
next |
function | Next middleware function |
- Source:
Returns:
- Type
- Promise.<void>
(async) fetchResponseDetails(pageOffsetopt, limitopt, optsopt) → {Promise.<ResponseDetails>}
Fetches check results details, optionally filtered by issue (type and field), or severity (but not both).
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pageOffset |
number |
<optional> |
0 | Zero based page offset |
||||||||||||||||||||||||
limit |
number |
<optional> |
50 | Results per page limit |
||||||||||||||||||||||||
opts |
Object |
<optional> |
Filter options Properties
|
- Source:
Returns:
Response details
- Type
- Promise.<ResponseDetails>
formatData(columns, rows) → {Array.<object>}
Formats an array of rows into an easier to access format, where each row is an object with column names as keys.
Parameters:
| Name | Type | Description |
|---|---|---|
columns |
Array.<string> | An array of column names |
rows |
Array.<Array.<any>> | A 2D array of row data, where each inner array represents a row |
- Source:
Returns:
- An array of objects, where each object represents a row with column names as keys
- Type
- Array.<object>
getBlockingTasks(req, res, next)
Middleware. Updates req.locals with tasksBlocking and potentially updates
req.aggregatedTasks map with entries for missing columns.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
req |
Object | Express request object Properties
|
||||||
res |
Object | Response object |
||||||
next |
function | Next middleware function |
- Source:
getColumnFieldLog() → {Array.<any>}
- Source:
Returns:
- Type
- Array.<any>
getColumnFieldLog() → {Array.<Object>}
- Source:
Returns:
- Type
- Array.<Object>
getDatasets()
Map of dataset identifiers to their configuration objects
- Source:
getFields() → {Array.<string>}
Returns a collection of field names, where each name is either a column name from input data or field name from the column field log. The resulting collection includes fields that the submitted data might be missing.
Note: fields are converted_row.column | columnFieldLog.field
- Source:
Returns:
- Type
- Array.<string>
getFileNameOrUrlAndCheckedTime(req, res, next)
Middleware to extract file name, URL, and checked time from the request data.
Updates req.locals.uploadInfo with the extracted information.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
module:express~Request | The request object. |
res |
module:express~Response | The response object. |
next |
module:express~NextFunction | The next middleware function. |
- Source:
getGeometries() → {Array.<any>|undefined}
Returns array of geometries when available, undefined otherwise.
- Source:
Returns:
- Type
- Array.<any> | undefined
getLastPage(req) → (nullable) {string}
Attempts to infer how we ended up on this page.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
- Source:
Returns:
- Type
- string
getNavigationLinks(currentUrl, links) → {Array.<object>}
Returns navigation links based on the provided page names and current URL.
Parameters:
| Name | Type | Description |
|---|---|---|
currentUrl |
string | The current URL. |
links |
Array.<string> | An array of page names for the links. |
- Source:
Returns:
An array of navigation link objects.
- Type
- Array.<object>
getPagination(pageNumber, optsopt) → {PaginationResult}
Get pagination details for the current response
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
pageNumber |
number | ||
opts |
PaginationOptions |
<optional> |
Pagination options |
- Source:
Returns:
Pagination result object
- Type
- PaginationResult
getRowsWithVerboseColumns(filterNonErrorsopt) → {Array.<object>}
Returns an array of rows with verbose columns, optionally filtering out rows without errors.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filterNonErrors |
boolean |
<optional> |
false | If true, only return rows that have at least one error. |
- Source:
Returns:
An array of rows with verbose columns, each containing:
entryNumber: the entry number of the rowhasErrors: a boolean indicating whether the row has any errorscolumns: an array of verbose column details, each containing:key: the column keyvalue: the column valuecolumn: the column namefield: the field nameerror: an error message if data was missing
- Type
- Array.<object>
getTasksByLevel(req, level, status)
Parameters:
| Name | Type | Description |
|---|---|---|
req |
* | request |
level |
number | criteria level |
status |
Status | status meta data |
- Source:
getVerboseColumns(row, columnFieldLog) → {Array.<Object>}
Returns an array of verbose column objects from a given row and column field log.
If either the column field log or issue logs are missing, returns a fallback array with warnings logged for missing data.
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | The row object containing converted row data and issue logs. |
columnFieldLog |
Object | The column field log object. |
- Source:
Returns:
An array of verbose column objects, each containing:
key: the column keyvalue: the column valuecolumn: the column namefield: the field nameerror: an error message if data was missing
- Type
- Array.<Object>
initialiseMessages()
Reads messages from CSV files and populates messages map.
- Source:
initiateJsHiddenChecks()
Initiates checks for elements with the class 'js-hidden' and updates their display and visibility styles accordingly.
When an element gains the 'js-hidden' class, its display and visibility styles are set to 'none' and 'hidden', respectively. When an element loses the 'js-hidden' class, its display and visibility styles are reset to their default values.
This function also hides any elements that already have the 'js-hidden' class when it is called.
- Source:
lpaOverviewQuery(lpa, params) → {string}
Generates a query for LPA overview data
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lpa |
string | The LPA identifier |
|||||||||||||||||||||||||
params |
Object | Query parameters Properties
|
- Source:
Returns:
The generated SQL query
- Type
- string
makeDatasetsLookup(dataSubjects) → {Map}
Flattens the nested dataSubjects object into a two-dimensional Map for quick lookup. Each entry in the returned Map uses the dataSet's value as the key and an object containing the dataSet properties along with its parent dataSubject key.
Parameters:
| Name | Type | Description |
|---|---|---|
dataSubjects |
Object | An object where each key is a dataSubject and its value contains a dataSets array. |
- Source:
Returns:
A Map where each key is a dataSet value and each value is the corresponding dataSet object with an added dataSubject property.
- Type
- Map
makeTaskParam(req, options) → {Object}
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | Express request object |
||||||||||||||||||||
options |
Object | Task options Properties
|
- Source:
Returns:
Task parameter object
- Type
- Object
maybeSetReferrer(req, sessionData)
Potentially updates sessionData with 'referrer'
Parameters:
| Name | Type | Description |
|---|---|---|
req |
||
sessionData |
maybeSetReferrer(req, sessionData)
Potentially updates sessionData with 'referrer'
Parameters:
| Name | Type | Description |
|---|---|---|
req |
||
sessionData |
(generator) offsets(limit, offset, maxOffset)
Returns a generator of offset values.
Parameters:
| Name | Type | Description |
|---|---|---|
limit |
number | |
offset |
number | |
maxOffset |
number |
- Source:
(async) postRequest(formData) → {Promise.<string>}
POSTs a requeset to the 'publish' API.
Parameters:
| Name | Type | Description |
|---|---|---|
formData |
* |
- Source:
Returns:
uuid - unique id of the uploaded file
- Type
- Promise.<string>
prepareEntity(req, res, next)
Updates req with entry object.
- takes an issueEntity (based on current
pageNumber) - selects
issuesfor that entity - creates a map of field names to objects (in shape required by govuk component)
- decorates (with some HTML markup) data in those objects if the field has issues
- potentially extracts geometry from the entity
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Object | request object |
res |
Object | response object |
next |
function | next function |
(async) queryPlatformAPI(url, params) → {Promise.<Object>}
Generic query function for Platform API
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The full URL to query |
params |
Object | Query parameters for logging |
- Source:
Returns:
- Raw response data from Platform API
- Type
- Promise.<Object>
referencePopup(options) → {string}
Contents of a popup element shows when user clicks on a geometry (point or polygon).
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
- Type
- string
requiresGeometryTypeToBeSelected(req) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Object |
- Source:
Returns:
- Type
- boolean
requiresGeometryTypeToBeSelectedViaDeepLink(req) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
req |
Object | The HTTP request object. |
- Source:
Returns:
- Type
- boolean
schemaIssues(error) → {Array.<Object>|Array.<string>|string}
Takes an Error and if it's a ValiError, returns an array of issue summaries (with paths). Empty array otherwise.
Useful to show the schema issues in a consise way.
Parameters:
| Name | Type | Description |
|---|---|---|
error |
Error | The error to check for schema issues |
- Source:
Returns:
-
Array of issue objects with path and message properties
- Type
- Array.<Object>
-
returns[].path - The path to the issue
- Type
- Array.<string>
-
returns[].message - The error message
- Type
- string
setPagination()
setupNunjucks(config) → {Object}
Setup Nunjucks template engine with custom configuration
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | Configuration object Properties
|
- Source:
Returns:
Configured Nunjucks instance
- Type
- Object
setupTableParams(req, res, next) → {void}
Parameters:
| Name | Type | Description |
|---|---|---|
req |
RequestWithDetails | Request object |
res |
Object | Response object |
next |
function | Next middleware function |
- Source:
Returns:
- Type
- void
startRequests(numTasks, gen, taskFactory) → {Array.<Promise>}
Parameters:
| Name | Type | Description |
|---|---|---|
numTasks |
number | max number of tasks to run |
gen |
Object | offset generator |
taskFactory |
function | (taskIndex, offset) => Promise<> |
- Source:
Returns:
- Type
- Array.<Promise>
validationErrorMessage(error, template)
Creates an error message from the given error
Parameters:
| Name | Type | Description |
|---|---|---|
error |
ValiError | validation error |
template |
string | template name |
- Source:
Returns:
string
wizardBackLink(url, deepLinkInfo) → {string|undefined}
If we arrived at the page via deep from another page, we'll use that page as the back link.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | current page URL |
||||||||||||
deepLinkInfo |
Object | deep link info from the session Properties
|
- Source:
Returns:
back link URL
- Type
- string | undefined
Type Definitions
ConfigSchema
Type:
- Object
- Source:
Dataset
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
status |
string | One of: 'Not submitted', 'Error', 'Needs improving', 'Warning', 'Live' |
|
endpoint |
string | ||
issue_count |
number | ||
error |
string |
<nullable> |
- Source:
Dataset
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
value |
string | Dataset value/identifier |
|
text |
string | Display text for the dataset |
|
available |
boolean | Whether the dataset is available |
|
dataSubject |
string | The data subject this dataset belongs to |
|
requiresGeometryTypeSelection |
boolean |
<optional> |
Whether geometry type selection is required |
- Source:
DatasetInfo
Properties:
| Name | Type | Description |
|---|---|---|
name |
string | Full name of the dataset |
dataset |
string | Short name of the dataset (aka 'slug') |
- Source:
DetailsOptions
Type:
- Object
Properties:
| Name | Type | Attributes | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
severity |
string |
<optional> |
Severity filter |
|||||||||
issue |
Object |
<optional> |
Issue filter Properties
|
- Source:
Issue
Properties:
| Name | Type | Description |
|---|---|---|
status |
string | |
issue_type |
string | |
field |
string |
- Source:
LeadingTrailingSplit
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
leading |
Array.<string> | |
trailing |
Array.<string> |
- Source:
LpaOverview
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
datasets |
Object.<string, Dataset> | Map of dataset names to Dataset objects |
- Source:
MapGeometry
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
geo |
string | ||
reference |
string |
<optional> |
|
name |
string |
<optional> |
- Source:
MapOptions
Options for creating a Map instance.
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
containerId |
string | Required - The ID of the HTML container element for the map. |
|
data |
Array.<string> | Array.<MapGeometry> | Required - An array of URLs or WKT geometries to be added to the map. |
|
boundaryGeoJsonUrl |
string |
<optional> |
Optional - The URL of the boundary GeoJSON to be added to the map. |
interactive |
boolean |
<optional> |
Optional - Indicates whether the map should be interactive. Default is true. |
wktFormat |
boolean |
<optional> |
Optional - Indicates whether the data is in WKT format. Default is false. |
limitMaxZoom |
boolean |
<optional> |
Optional - Indicates whether to limit the maximum zoom level when fitting bounds. Default is false. |
boundingBox |
Array.<number> |
<optional> |
Optional - The bounding box coordinates [minX, minY, maxX, maxY] to set the initial view of the map. |
- Source:
OrgInfo
Properties:
| Name | Type | Description |
|---|---|---|
name |
string | Full name of the organisation |
organisation |
string |
- Source:
PaginationItem
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
href |
string | Link URL |
|
ellipsis |
boolean |
<optional> |
Whether this is an ellipsis item |
- Source:
PaginationOptions
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
hash |
string |
<optional> |
Hash option (should include the '#' character) |
href |
function |
<optional> |
Function to generate href (item: number) => string |
- Source:
PaginationResult
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
totalResults |
number | Total number of results |
offset |
number | Current offset |
limit |
number | Results per page limit |
currentPage |
number | Current page number |
nextPage |
number | null | Next page number or null |
previousPage |
number | null | Previous page number or null |
totalPages |
number | Total number of pages |
items |
Array.<{href: string}> | Pagination items with hrefs |
- Source:
RequestWithDetails
Type:
- Object
Properties:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parsedParams |
Object | |||||||||||||||||||||
locals |
Object | Request locals Properties
|
- Source:
RequiredDataset
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
dataset |
string | The dataset identifier |
deadline |
string | The deadline pattern in ISO format with YYYY placeholder |
noticePeriod |
number | Number of months before deadline to show notice |
- Source:
Source
Properties:
| Name | Type | Description |
|---|---|---|
endpoint |
string | |
endpoint_url |
string | |
status |
number | null | |
exception |
string | |
latest_log_entry_date |
string | |
resource_start_date |
string | |
documentation_url |
string |
- Source:
Status
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
text |
string | Status text |
link |
boolean | Whether status has a link |
colour |
string | Status color |
- Source:
SummaryItem
Type:
- Object
Properties:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
key |
Object |
Properties
|
|||||||||
value |
Object |
Properties
|
|||||||||
classes |
string |
TaskMessageOptions
Type:
- Object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
issue_type |
string | Type of issue |
|
num_issues |
number | Number of issues |
|
rowCount |
number | Total row count |
|
field |
string | Field name |
|
format |
'html' | 'text' |
<optional> |
Output format |
dataset |
string |
<optional> |
Dataset name for dataset-specific messages |
- Source: