Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDI: Update dependencies #235

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/check-prettify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Prettify sources
run: ./scripts/prettify.sh
- uses: actions/setup-node@v4
with:
node-version: '18.19.0'
cache: 'yarn'
cache-dependency-path: test/hasura/yarn.lock

- name: Verify that prettify command made no changes
run: '[ -z "$(git status --porcelain)" ]'
- name: Install node_modules
run: cd test/hasura && yarn install --frozen-lockfile

- name: Verify that prettier has been run
run: cd test/hasura && yarn prettier:check
6 changes: 5 additions & 1 deletion scripts/prettify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

set -eu

npx [email protected] --write .
# allow running from any working directory
WD=$(dirname "$0")
cd "${WD}/../test/hasura"

yarn prettier
4 changes: 4 additions & 0 deletions test/hasura/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ module.exports = {
},
],
'jest/expect-expect': 'off', // most of the tests call the assertions through an external function

// Previously enabled by-default by the recommended rule set.
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-empty-function': 'error',
},
};
17 changes: 15 additions & 2 deletions test/hasura/generic/networkdb/datasets/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { GeometryObject } from 'geojson';
import { DateTime } from 'luxon';

export type NamedCoordinateReferenceSystemObject = {
type: 'name';
properties: {
name: string;
};
};

// The Coordinate reference system was dropped from the GeoJSON spec RFC7946.
// Thus the @types/geojson types do not support them
export type GeometryObjectWithOptionalCRS = GeometryObject & {
crs?: NamedCoordinateReferenceSystemObject;
};

export function isGeoProperty(prop: Property): prop is GeoProperty {
return Object.prototype.hasOwnProperty.call(prop, 'isGeoProp');
}
Expand Down Expand Up @@ -60,7 +73,7 @@ export enum TypeOfLine {
export type InfrastructureLink = {
infrastructure_link_id: string;
direction: LinkDirection;
shape: GeometryObject;
shape: GeometryObjectWithOptionalCRS;
estimated_length_in_metres: number | null;
external_link_source: string;
external_link_id: string;
Expand Down Expand Up @@ -92,7 +105,7 @@ export type ScheduledStopPoint = {
scheduled_stop_point_id: string;
located_on_infrastructure_link_id: string;
direction: LinkDirection;
measured_location: GeometryObject;
measured_location: GeometryObjectWithOptionalCRS;
label: string;
priority: number;
validity_start: DateTime | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ describe('Function maximum_priority_validity_spans should return correct route r
FROM journey_pattern.maximum_priority_validity_spans('route', '{ "${
routeLabel !== undefined ? routeLabel : defaultRouteLabel
}" }', ${
validityStart !== undefined ? `'${validityStart.toISODate()}'` : 'NULL'
}, ${
validityEnd !== undefined ? `'${validityEnd.toISODate()}'` : 'NULL'
}, ${upperPriorityLimit !== undefined ? upperPriorityLimit : 'NULL'})`,
validityStart !== undefined ? `'${validityStart.toISODate()}'` : 'NULL'
}, ${
validityEnd !== undefined ? `'${validityEnd.toISODate()}'` : 'NULL'
}, ${upperPriorityLimit !== undefined ? upperPriorityLimit : 'NULL'})`,
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ describe('Function maximum_priority_validity_spans should return correct schedul
FROM journey_pattern.maximum_priority_validity_spans('scheduled_stop_point', '{ "${
routeLabel !== undefined ? routeLabel : defaultRouteLabel
}" }', ${
validityStart !== undefined ? `'${validityStart.toISODate()}'` : 'NULL'
}, ${
validityEnd !== undefined ? `'${validityEnd.toISODate()}'` : 'NULL'
}, ${upperPriorityLimit !== undefined ? upperPriorityLimit : 'NULL'})`,
validityStart !== undefined ? `'${validityStart.toISODate()}'` : 'NULL'
}, ${
validityEnd !== undefined ? `'${validityEnd.toISODate()}'` : 'NULL'
}, ${upperPriorityLimit !== undefined ? upperPriorityLimit : 'NULL'})`,
);
};

Expand Down
54 changes: 27 additions & 27 deletions test/hasura/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,44 @@
"timetables-data-inserter:cli": "node dist/timetables-data-inserter/cli.js"
},
"dependencies": {
"@jest/globals": "^29.4.2",
"@types/geojson": "1.0.6",
"@types/jest": "^29.4.0",
"@types/lodash": "^4.14.181",
"@types/luxon": "^3.2.0",
"@types/pg": "^8.6.1",
"@types/request-promise": "^4.1.48",
"@types/uuid": "^9.0.3",
"@types/uuid-validate": "^0.0.1",
"commander": "^11.0.0",
"dotenv": "^10.0.0",
"@jest/globals": "^29.7.0",
"@types/geojson": "^7946.0.14",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.7",
"@types/luxon": "^3.4.2",
"@types/pg": "^8.11.8",
"@types/request-promise": "^4.1.51",
"@types/uuid": "^9.0.8",
"@types/uuid-validate": "^0.0.3",
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"geojson": "^0.5.0",
"jest": "^29.4.2",
"knex": "^2.4.0",
"jest": "^29.7.0",
"knex": "^3.1.0",
"lodash": "^4.17.21",
"luxon": "^3.2.1",
"pg": "^8.7.1",
"prettier": "^2.8.3",
"luxon": "^3.5.0",
"pg": "^8.12.0",
"prettier": "^3.3.3",
"request": "^2.88.2",
"request-promise": "^4.2.6",
"ts-jest": "^29.0.5",
"tsc-alias": "^1.8.7",
"typescript": "^4.9.5",
"ts-jest": "^29.2.5",
"tsc-alias": "^1.8.10",
"typescript": "^5.5.4",
"uuid": "^9.0.1",
"uuid-validate": "^0.0.3",
"wkx": "^0.5.0",
"zod": "^3.21.4"
"zod": "^3.23.8"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"eslint": "^8.33.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest-formatting": "^3.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,45 @@ export const createTimetablesDatasetHelper = <
// TODO: could these be done with generics?..
const vehicleServicesByLabel = flattened.vehicleScheduleFrames
.flatMap((vsf) => Object.entries(vsf._vehicle_services))
.reduce((result, [label, vss]) => {
const labelGroup = result[label] || [];
labelGroup.push(vss);
return {
...result,
[label]: labelGroup,
};
}, {} as Record<string, GenericVehicleServiceOutput[]>);
.reduce(
(result, [label, vss]) => {
const labelGroup = result[label] || [];
labelGroup.push(vss);
return {
...result,
[label]: labelGroup,
};
},
{} as Record<string, GenericVehicleServiceOutput[]>,
);

const blocksByLabel = flattened.vehicleServices
.flatMap((vs) => Object.entries(vs._blocks))
.reduce((result, [label, block]) => {
const labelGroup = result[label] || [];
labelGroup.push(block);
return {
...result,
[label]: labelGroup,
};
}, {} as Record<string, GenericVehicleServiceBlockOutput[]>);
.reduce(
(result, [label, block]) => {
const labelGroup = result[label] || [];
labelGroup.push(block);
return {
...result,
[label]: labelGroup,
};
},
{} as Record<string, GenericVehicleServiceBlockOutput[]>,
);

const vehicleJourneysByLabel = flattened.blocks
.flatMap((block) => Object.entries(block._vehicle_journeys))
.reduce((result, [label, vj]) => {
const labelGroup = result[label] || [];
labelGroup.push(vj);
return {
...result,
[label]: labelGroup,
};
}, {} as Record<string, GenericVehicleJourneyOutput[]>);
.reduce(
(result, [label, vj]) => {
const labelGroup = result[label] || [];
labelGroup.push(vj);
return {
...result,
[label]: labelGroup,
};
},
{} as Record<string, GenericVehicleJourneyOutput[]>,
);

return {
...builtDataset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ export const createHslTimetablesDatasetHelper = (
.flatMap((sop) =>
Object.entries(sop._substitute_operating_day_by_line_types),
)
.reduce((result, [label, sodblt]) => {
const labelGroup = result[label] || [];
labelGroup.push(sodblt);
return {
...result,
[label]: labelGroup,
};
}, {} as Record<string, SubstituteOperatingDayByLineTypeOutput[]>);
.reduce(
(result, [label, sodblt]) => {
const labelGroup = result[label] || [];
labelGroup.push(sodblt);
return {
...result,
[label]: labelGroup,
};
},
{} as Record<string, SubstituteOperatingDayByLineTypeOutput[]>,
);

const genericTimetablesHelper = createTimetablesDatasetHelper(builtDataset);

Expand Down
Loading
Loading