Compare commits
16 Commits
v3.0.0-alp
...
v3.0.3-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 25c1793df3 | |||
| 48f1a31378 | |||
| 376370c729 | |||
| 180886fd68 | |||
| 513196c43d | |||
| 5d4271c193 | |||
| c02ff3ebab | |||
| 519acebcba | |||
| 645faf1003 | |||
| a2308198e9 | |||
| 8c2ed1ad8f | |||
| 0848fe3b27 | |||
| 8ac0215247 | |||
| 07f224ff18 | |||
| 91e9432a07 | |||
| 50e2907f47 |
@@ -59,9 +59,29 @@ jobs:
|
||||
}' >> index.ts
|
||||
|
||||
VERSION="${{ steps.get_version.outputs.VERSION }}"
|
||||
REPO_URL="${{ github.server_url }}/${{ github.repository }}.git"
|
||||
jq --arg ver "$VERSION" \
|
||||
--arg name "@owlboard/api-schema-types" \
|
||||
'.name = $name | .version = $ver | .type = "module" | .main = "./dist/index.js" | .types = "./dist/index.d.ts"' \
|
||||
--arg repo "$REPO_URL" \
|
||||
'.name = $name |
|
||||
.description = "TypeScript type definitions for OwlBoard API schemas" |
|
||||
.author = "Frederick Boniface" |
|
||||
.version = $ver |
|
||||
.type = "module" |
|
||||
.main = "./dist/index.js" |
|
||||
.license = "MIT" |
|
||||
.repository = { "type": "git", "url": $repo } |
|
||||
.files = ["dist"] |
|
||||
.sideEffects = false |
|
||||
.dependencies = {} |
|
||||
.devDependencies = {} |
|
||||
.exports = {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
} |
|
||||
.types = "./dist/index.d.ts"' \
|
||||
package.json > package.json.new && mv package.json.new package.json
|
||||
|
||||
# Compile
|
||||
@@ -74,7 +94,7 @@ jobs:
|
||||
- name: Publish Go
|
||||
run: |
|
||||
VERSION="v${{ steps.get_version.outputs.VERSION }}"
|
||||
MOD_NAME="git.fjla.uk/owlboard/api-schema-types"
|
||||
MOD_NAME="git.fjla.uk/owlboard/api-schema-types/v3"
|
||||
ZIP_ROOT="/tmp/go_upload"
|
||||
FULL_PATH="$ZIP_ROOT/$MOD_NAME@$VERSION"
|
||||
|
||||
|
||||
@@ -11,11 +11,7 @@
|
||||
"description": "Unix timestamp showing when the data was generated, or the time the error was encountered"
|
||||
},
|
||||
"d": {
|
||||
"description": "Payload data. Type depends on request endpoint",
|
||||
"anyOf": [
|
||||
{"type": "object"},
|
||||
{"type": "array"}
|
||||
]
|
||||
"description": "Payload data. Type depends on request endpoint, typically an array of the response type"
|
||||
},
|
||||
"e": {
|
||||
"type": "object",
|
||||
|
||||
31
schemas/api/location-filter.json
Normal file
31
schemas/api/location-filter.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$id": "https://schema.owlboard.info/api/location-filter.schema.json",
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"title": "LocationFilterObject",
|
||||
"description": "Location filter API Response. Provides a location's data for filtering on the frontend",
|
||||
"type": "object",
|
||||
"required": ["n", "s"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"n": {
|
||||
"type": "string",
|
||||
"name": "Name",
|
||||
"description": "Name of the location"
|
||||
},
|
||||
"t": {
|
||||
"type": "string",
|
||||
"name": "TIPLOC",
|
||||
"description": "TIPLOC of the location"
|
||||
},
|
||||
"c": {
|
||||
"type": "string",
|
||||
"name": "CRS",
|
||||
"description": "CRS of the location"
|
||||
},
|
||||
"s": {
|
||||
"type": "string",
|
||||
"name": "searchString",
|
||||
"description": "Generated string for efficient filtering"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,20 @@
|
||||
"pattern": "^[a-zA-Z0-9]+$"
|
||||
},
|
||||
"description": "List of TIPLOC Codes"
|
||||
},
|
||||
"skip": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"skip": {
|
||||
"type": "integer",
|
||||
"description": "Number of stops to skip"
|
||||
},
|
||||
"position": {
|
||||
"type": "string",
|
||||
"enum": ["head", "tail"],
|
||||
"description": "Position of stops to be skipped, either 'head' or 'tail'"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["code"],
|
||||
|
||||
19
schemas/api/stations/nearest-stations.json
Normal file
19
schemas/api/stations/nearest-stations.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"$id": "https://schema.owlboard.info/api/stations/nearestStations.schema.json",
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"title": "StationsNearestStations",
|
||||
"description": "Nearest Stations API Resonse. Returned as an Array of the object. Response array will be sorted - nearest first",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"c": {
|
||||
"type": "string",
|
||||
"name": "CRS"
|
||||
},
|
||||
"n": {
|
||||
"type": "string",
|
||||
"name": "Station Name"
|
||||
}
|
||||
},
|
||||
"required": ["c", "n"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
47
schemas/api/trains/TrainByHeadcode.json
Normal file
47
schemas/api/trains/TrainByHeadcode.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"title": "TrainByHeadcodeResponse",
|
||||
"type": "object",
|
||||
"required": ["r", "ot", "od", "dt", "o"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"r": {
|
||||
"type": "string",
|
||||
"name": "rid",
|
||||
"description": "The RID of the service described"
|
||||
},
|
||||
"ot": {
|
||||
"type": "string",
|
||||
"name": "Origin TIPLOC",
|
||||
"description": "The TIPLOC at which the service originates",
|
||||
"minLength": 4,
|
||||
"maxLength": 7
|
||||
},
|
||||
"od": {
|
||||
"type": "string",
|
||||
"name": "Origin Departure",
|
||||
"format": "date-time",
|
||||
"description": "The time that the service departs the originating location"
|
||||
},
|
||||
"dt": {
|
||||
"type": "string",
|
||||
"name": "Destination TIPLOC",
|
||||
"description": "The TIPLOC at which the service terminates",
|
||||
"minimum": 4,
|
||||
"maximum": 7
|
||||
},
|
||||
"o": {
|
||||
"type": "string",
|
||||
"name": "Operator (TOC)",
|
||||
"description": "The TOC operating the service",
|
||||
"minLength": 2,
|
||||
"maxLength": 2
|
||||
},
|
||||
"ct": {
|
||||
"type": "boolean",
|
||||
"title": "Cancelled Throughout",
|
||||
"name": "Cancelled Throughout",
|
||||
"description": "Whether the train is cancelled throughout"
|
||||
}
|
||||
}
|
||||
}
|
||||
224
schemas/api/trains/TrainDetails.json
Normal file
224
schemas/api/trains/TrainDetails.json
Normal file
@@ -0,0 +1,224 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft-07/schema#",
|
||||
"title": "TrainDetailsResponse",
|
||||
"$defs": {
|
||||
"ServiceLocation": {
|
||||
"type": "object",
|
||||
"description": "A specific location along the services journey",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"t": {
|
||||
"type": "string",
|
||||
"title": "TIPLOC",
|
||||
"description": "The TIPLOC of the location"
|
||||
},
|
||||
"r": {
|
||||
"type": "string",
|
||||
"enum": ["ORIG", "CALL", "PASS", "DEST"],
|
||||
"title": "Location Role",
|
||||
"description": "The role of this location in the journey"
|
||||
},
|
||||
"s": {
|
||||
"type": "integer",
|
||||
"title": "Sequence Number",
|
||||
"description": "The sequence at which this location sits in the schedule"
|
||||
},
|
||||
"act": {
|
||||
"title": "activities",
|
||||
"description": "Activities carried out at this location",
|
||||
"type": "string"
|
||||
},
|
||||
"p": {
|
||||
"title": "Platform",
|
||||
"type": "string",
|
||||
"description": "The platform that this event takes place"
|
||||
},
|
||||
"pc": {
|
||||
"title": "Platform Changed",
|
||||
"type": "boolean"
|
||||
},
|
||||
"pcn": {
|
||||
"title": "Platform Confirmed",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ps": {
|
||||
"title": "Platform Surpressed",
|
||||
"description": "Whether platform data is surpressed",
|
||||
"type": "boolean"
|
||||
},
|
||||
"can": {
|
||||
"title": "Cancelled",
|
||||
"description": "Whether this location is cancelled in the journey",
|
||||
"type": "boolean"
|
||||
},
|
||||
"al": {
|
||||
"type": "integer",
|
||||
"title": "Average Loading",
|
||||
"description": "The average loading at this location"
|
||||
},
|
||||
"fid": {
|
||||
"type": "string",
|
||||
"title": "Formation ID",
|
||||
"description": "The formation ID at this location"
|
||||
},
|
||||
"pta": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Public time of arrival"
|
||||
},
|
||||
"wta": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Working time of arrival"
|
||||
},
|
||||
"wtp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Working time of pass"
|
||||
},
|
||||
"ptd": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Public time of departure"
|
||||
},
|
||||
"wtd": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Working time of departure"
|
||||
},
|
||||
"eta": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Estimated time of arrival"
|
||||
},
|
||||
"etd": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Estimated time of departure"
|
||||
},
|
||||
"etp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Estimated time of pass"
|
||||
},
|
||||
"ata": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Actual time of arrival"
|
||||
},
|
||||
"atd": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Actual time of departure"
|
||||
},
|
||||
"atp": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Actual time of pass"
|
||||
}
|
||||
},
|
||||
"required": ["t", "r", "s", "act"]
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": ["header", "locations"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"header": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"r": {
|
||||
"type": "string",
|
||||
"title": "RID",
|
||||
"description": "The RID of the service",
|
||||
"maxLength": 16
|
||||
},
|
||||
"u": {
|
||||
"title": "UID",
|
||||
"description": "The UID of the service",
|
||||
"type": "string"
|
||||
},
|
||||
"s": {
|
||||
"title": "SSD",
|
||||
"description": "The SSD of the service",
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"h": {
|
||||
"title": "train_id",
|
||||
"description": "Headcode",
|
||||
"maxLength": 4,
|
||||
"minLength": 4,
|
||||
"type": "string"
|
||||
},
|
||||
"t": {
|
||||
"title": "TOC",
|
||||
"description": "The TOC operating the service",
|
||||
"type": "string",
|
||||
"maxLength": 3,
|
||||
"minLength": 2
|
||||
},
|
||||
"st": {
|
||||
"title": "Status",
|
||||
"description": "Train status",
|
||||
"type": "string"
|
||||
},
|
||||
"cr": {
|
||||
"title": "Cancel Reason",
|
||||
"type": "integer"
|
||||
},
|
||||
"cl": {
|
||||
"title": "Cancel Location",
|
||||
"type": "string",
|
||||
"maxLength": 7
|
||||
},
|
||||
"cn": {
|
||||
"title": "Cancel Near",
|
||||
"description": "Whether the train was cancelled NEAR the 'cancel_loation', else at the 'cancel_location'",
|
||||
"type": "boolean"
|
||||
},
|
||||
"dr": {
|
||||
"title": "Delay Reason",
|
||||
"type": "integer"
|
||||
},
|
||||
"dl": {
|
||||
"title": "Delay Location",
|
||||
"type": "string",
|
||||
"maxLength": 7
|
||||
},
|
||||
"dn": {
|
||||
"title": "Delay Near",
|
||||
"description": "Whether the train was delayed NEAR the 'delay_loation', else at the 'delay_location'",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ip": {
|
||||
"title": "is_passenger",
|
||||
"description": "Whether this is a passenger service",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ic": {
|
||||
"title": "is_charter",
|
||||
"description": "Whether this is a charter service",
|
||||
"type": "boolean"
|
||||
},
|
||||
"rs": {
|
||||
"title": "RSID",
|
||||
"description": "Retail Service ID",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["r", "s", "h", "t", "ip", "ic"]
|
||||
},
|
||||
"locations": {
|
||||
"type": "array",
|
||||
"additionalItems": false,
|
||||
"items": {
|
||||
"$ref": "#/$defs/ServiceLocation"
|
||||
}
|
||||
},
|
||||
"pis": {
|
||||
"description": "PIS data for the service (if available)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ for file in $FILES; do
|
||||
clean_name=$(echo "${file#schemas/}" | sed 's/\//_/g' | sed 's/\.json//g')
|
||||
|
||||
# OGenerate TS
|
||||
npx --yes json-schema-to-typescript "$file" > "gen/ts/${clean_name}.ts"
|
||||
npx --yes json-schema-to-typescript "$file" > "./gen/ts/${clean_name}.ts"
|
||||
|
||||
# Generate Go
|
||||
go-jsonschema -p contracts "$file" > "gen/go/models/${clean_name}.go"
|
||||
go-jsonschema -p contracts "$file" > "./gen/go/models/${clean_name}.go"
|
||||
done
|
||||
|
||||
echo "✅ Generated single TS package in gen/ts"
|
||||
|
||||
Reference in New Issue
Block a user