diff --git a/data/instance/volebnakalkulacka.sk/nrsr-2023/election.json b/data/instance/volebnakalkulacka.sk/nrsr-2023/election.json index bbaa517ea..d18c553c7 100644 --- a/data/instance/volebnakalkulacka.sk/nrsr-2023/election.json +++ b/data/instance/volebnakalkulacka.sk/nrsr-2023/election.json @@ -8,15 +8,10 @@ "id": "05c64bc5-aa2e-4457-ab30-336f7cf9131b", "key": "nrsr-2023" }, - "rounds": [ + "votingHours": [ { - "number": 0, - "votingHours": [ - { - "start": "2023-09-30T07:00:00+02:00", - "end": "2023-09-30T22:00:00+02:00" - } - ] + "start": "2023-09-30T07:00:00+02:00", + "end": "2023-09-30T22:00:00+02:00" } ] } diff --git a/data/schemas/candidates-answers.schema.json b/data/schemas/candidates-answers.schema.json index e3a917860..23296df59 100644 --- a/data/schemas/candidates-answers.schema.json +++ b/data/schemas/candidates-answers.schema.json @@ -9,5 +9,5 @@ "$ref": "./answers.schema.json" } }, - "additionalProperties": false + "unevaluatedProperties": false } diff --git a/data/schemas/election.schema.json b/data/schemas/election.schema.json index 742453d23..2c2d4ba34 100644 --- a/data/schemas/election.schema.json +++ b/data/schemas/election.schema.json @@ -118,8 +118,18 @@ "items": { "$ref": "./round.schema.json" } + }, + "votingHours": { + "title": "Voting hours", + "description": "One or multiple voting hours for the election", + "type": "array", + "minItems": 1, + "items": { + "$ref": "./time-period.schema.json" + } } }, + "unevaluatedProperties": false, "required": [ "id", "key", @@ -127,5 +137,17 @@ "title", "shortTitle", "calculatorGroup" - ] + ], + "dependentSchemas": { + "rounds": { + "not": { + "required": ["votingHours"] + } + }, + "votingHours": { + "not": { + "required": ["rounds"] + } + } + } } diff --git a/data/schemas/round.schema.json b/data/schemas/round.schema.json index 09c36ee6b..6fac631d8 100644 --- a/data/schemas/round.schema.json +++ b/data/schemas/round.schema.json @@ -18,44 +18,7 @@ "type": "array", "minItems": 1, "items": { - "title": "Voting period", - "type": "object", - "unevaluatedProperties": false, - "properties": { - "start": { - "title": "Start time", - "description": "Start date (or time) of a voting period in the ISO 8601 format", - "oneOf": [ - { - "type": "string", - "format": "date", - "examples": ["2023-01-13"] - }, - { - "type": "string", - "format": "date-time", - "examples": ["2023-01-13T14:00:00+01:00"] - } - ] - }, - "end": { - "title": "End time", - "description": "End date (or time) of a voting period in the ISO 8601 format", - "oneOf": [ - { - "type": "string", - "format": "date", - "examples": ["2023-01-13"] - }, - { - "type": "string", - "format": "date-time", - "examples": ["2023-01-13T14:00:00+01:00"] - } - ] - } - }, - "required": ["start", "end"] + "$ref": "./time-period.schema.json" } } }, diff --git a/data/schemas/time-period.schema.json b/data/schemas/time-period.schema.json new file mode 100644 index 000000000..73d4b4190 --- /dev/null +++ b/data/schemas/time-period.schema.json @@ -0,0 +1,43 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://www.volebnikalkulacka.cz/data/schemas/time-period.schema.json", + "title": "Time period", + "description": "Time period from–to", + "type": "object", + "properties": { + "start": { + "title": "Start time", + "description": "Start date (or time) of a voting period in the ISO 8601 format", + "oneOf": [ + { + "type": "string", + "format": "date", + "examples": ["2023-01-13"] + }, + { + "type": "string", + "format": "date-time", + "examples": ["2023-01-13T14:00:00+01:00"] + } + ] + }, + "end": { + "title": "End time", + "description": "End date (or time) of a voting period in the ISO 8601 format", + "oneOf": [ + { + "type": "string", + "format": "date", + "examples": ["2023-01-13"] + }, + { + "type": "string", + "format": "date-time", + "examples": ["2023-01-13T14:00:00+01:00"] + } + ] + } + }, + "unevaluatedProperties": false, + "required": ["start", "end"] +} diff --git a/data/types/election.ts b/data/types/election.ts index c951298b2..09d83f030 100644 --- a/data/types/election.ts +++ b/data/types/election.ts @@ -70,7 +70,7 @@ export type Number = number; * * @minItems 1 */ -export type VotingHours = [VotingPeriod, ...VotingPeriod[]]; +export type VotingHours = [TimePeriod, ...TimePeriod[]]; /** * Start date (or time) of a voting period in the ISO 8601 format */ @@ -79,6 +79,12 @@ export type StartTime = string | string; * End date (or time) of a voting period in the ISO 8601 format */ export type EndTime = string | string; +/** + * One or multiple voting hours for the election + * + * @minItems 1 + */ +export type VotingHours1 = [TimePeriod, ...TimePeriod[]]; /** * Election provides various details about an election such as districts and rounds @@ -95,6 +101,7 @@ export interface Election { calculatorGroup: CalculatorGroup; districts?: OrderedListOfElectionDistricts; rounds?: OrderedListOfElectionRounds; + votingHours?: VotingHours1; [k: string]: unknown; } /** @@ -121,7 +128,10 @@ export interface Round { votingHours?: VotingHours; [k: string]: unknown; } -export interface VotingPeriod { +/** + * Time period from–to + */ +export interface TimePeriod { start: StartTime; end: EndTime; [k: string]: unknown; diff --git a/data/types/elections.ts b/data/types/elections.ts index f40676a33..c943114f5 100644 --- a/data/types/elections.ts +++ b/data/types/elections.ts @@ -70,7 +70,7 @@ export type Number = number; * * @minItems 1 */ -export type VotingHours = [VotingPeriod, ...VotingPeriod[]]; +export type VotingHours = [TimePeriod, ...TimePeriod[]]; /** * Start date (or time) of a voting period in the ISO 8601 format */ @@ -79,6 +79,12 @@ export type StartTime = string | string; * End date (or time) of a voting period in the ISO 8601 format */ export type EndTime = string | string; +/** + * One or multiple voting hours for the election + * + * @minItems 1 + */ +export type VotingHours1 = [TimePeriod, ...TimePeriod[]]; /** * List of elections */ @@ -99,6 +105,7 @@ export interface Election { calculatorGroup: CalculatorGroup; districts?: OrderedListOfElectionDistricts; rounds?: OrderedListOfElectionRounds; + votingHours?: VotingHours1; [k: string]: unknown; } /** @@ -125,7 +132,10 @@ export interface Round { votingHours?: VotingHours; [k: string]: unknown; } -export interface VotingPeriod { +/** + * Time period from–to + */ +export interface TimePeriod { start: StartTime; end: EndTime; [k: string]: unknown; diff --git a/data/types/round.ts b/data/types/round.ts index 6e09a8eb4..c39cee138 100644 --- a/data/types/round.ts +++ b/data/types/round.ts @@ -14,7 +14,7 @@ export type Number = number; * * @minItems 1 */ -export type VotingHours = [VotingPeriod, ...VotingPeriod[]]; +export type VotingHours = [TimePeriod, ...TimePeriod[]]; /** * Start date (or time) of a voting period in the ISO 8601 format */ @@ -32,7 +32,10 @@ export interface Round { votingHours?: VotingHours; [k: string]: unknown; } -export interface VotingPeriod { +/** + * Time period from–to + */ +export interface TimePeriod { start: StartTime; end: EndTime; [k: string]: unknown; diff --git a/data/types/timePeriod.ts b/data/types/timePeriod.ts new file mode 100644 index 000000000..4b1324aa7 --- /dev/null +++ b/data/types/timePeriod.ts @@ -0,0 +1,24 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +/** + * Start date (or time) of a voting period in the ISO 8601 format + */ +export type StartTime = string; +/** + * End date (or time) of a voting period in the ISO 8601 format + */ +export type EndTime = string; + +/** + * Time period from–to + */ +export interface TimePeriod { + start: StartTime; + end: EndTime; + [k: string]: unknown; +}