Skip to content

Commit

Permalink
Merge branch 'develop' into documentation/neil/add-descriptions-to-co…
Browse files Browse the repository at this point in the history
…mpliance-api-spec
  • Loading branch information
Russen Guggemos authored Jan 25, 2022
2 parents 33c4425 + 0eb465e commit 519692b
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-points-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mds-core/mds-transaction-service": minor
---

Update TripReceiptDetailsDomainModel to account for properties that are potentially underivable.
40 changes: 19 additions & 21 deletions packages/mds-transaction-api/schema-gen/TransactionSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,33 @@
"minimum": 100000000000,
"maximum": 99999999999999
},
"vehicle_type": {
"type": "string",
"enum": [
"car",
"bicycle",
"scooter",
"moped",
"other"
]
},
"start_geography_id": {
"type": "string",
"format": "uuid"
"format": "uuid",
"nullable": true,
"default": null
},
"start_geography_type": {
"type": "string"
},
"end_geography_id": {
"type": "string",
"format": "uuid",
"nullable": true
"nullable": true,
"default": null
},
"end_geography_type": {
"type": "string"
},
"duration": {
"type": "integer"
"type": "integer",
"nullable": true,
"default": null
},
"distance": {
"type": "integer"
"type": "integer",
"nullable": true,
"default": null
},
"trip_events": {
"type": "array",
Expand Down Expand Up @@ -415,15 +418,10 @@
}
},
"required": [
"distance",
"duration",
"end_geography_id",
"end_timestamp",
"start_geography_id",
"start_timestamp",
"end_timestamp",
"trip_events",
"trip_id",
"vehicle_type"
"trip_id"
]
},
{
Expand Down
40 changes: 19 additions & 21 deletions packages/mds-transaction-api/spec/flat-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,33 @@
"minimum": 100000000000,
"maximum": 99999999999999
},
"vehicle_type": {
"type": "string",
"enum": [
"car",
"bicycle",
"scooter",
"moped",
"other"
]
},
"start_geography_id": {
"type": "string",
"format": "uuid"
"format": "uuid",
"nullable": true,
"default": null
},
"start_geography_type": {
"type": "string"
},
"end_geography_id": {
"type": "string",
"format": "uuid",
"nullable": true
"nullable": true,
"default": null
},
"end_geography_type": {
"type": "string"
},
"duration": {
"type": "integer"
"type": "integer",
"nullable": true,
"default": null
},
"distance": {
"type": "integer"
"type": "integer",
"nullable": true,
"default": null
},
"trip_events": {
"type": "array",
Expand Down Expand Up @@ -437,15 +440,10 @@
}
},
"required": [
"distance",
"duration",
"end_geography_id",
"end_timestamp",
"start_geography_id",
"start_timestamp",
"end_timestamp",
"trip_events",
"trip_id",
"vehicle_type"
"trip_id"
]
},
{
Expand Down
45 changes: 42 additions & 3 deletions packages/mds-transaction-service/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,52 @@ export interface PaginationLinks {
// one example -- many others are possible
export interface TripReceiptDetailsDomainModel {
trip_id: UUID
/**
* Should be populated with the timestamp of the starting event
* (trip_enter_jurisdiction | enter_jurisdiction | trip_start) for the trip.
* If there is none, then this defaults to the ending event timestamp.
*/
start_timestamp: Timestamp
/**
* Should be populated with the timestamp of the terminus event (trip_leave_jurisdiction | trip_end) for the trip.
* If there is none, then this defaults to the starting event timestamp.
*/
end_timestamp: Timestamp
vehicle_type: VEHICLE_TYPE
/**
* Start geography used for billing.
*
* Because geographies may overlap, the ordering of the geographies is at the discretion of the regulating agency,
* and their policies.
*/
start_geography_id: Nullable<UUID>
/**
* Type of the starting geography. If start_geography_id is null, then this field should default to 'out_of_bound'.
*/
start_geography_type: string
/**
* End geography used for billing.
*
* Because geographies may overlap, the ordering of the geographies is at the discretion of the regulating agency,
* and their policies.
*/
end_geography_id: Nullable<UUID>
duration: number // seconds
distance: number // meters
/**
* Type of the ending geography. If start_geography_id is null, then this field should default to 'out_of_bound'.
*/
end_geography_type: string
/**
* Duration of the trip in milliseconds. Null if one endpoint of the trip was out of bounds
* and we do not know the duration. */
duration: Nullable<number>
/**
* Distance in meters, given the great-circle-distance between the start & end points of the trip.
* NOTE: This will be an under-estimate of the actual distance.
* Null if one endpoint of the trip was out of bounds and we don't know where it started or ended.
*/
distance: Nullable<number>
/**
* All events that contain this trip_id.
*/
trip_events: EventDomainModel[]
}

Expand Down
23 changes: 7 additions & 16 deletions packages/mds-transaction-service/service/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,15 @@ const tripReceiptSchema: JSONSchemaType<TripReceiptDetailsDomainModel> = {
trip_id: uuidSchema,
start_timestamp: timestampSchema,
end_timestamp: timestampSchema,
vehicle_type: { type: 'string', enum: [...VEHICLE_TYPES] },
start_geography_id: uuidSchema,
end_geography_id: { ...uuidSchema, nullable: true },
duration: { type: 'integer' }, // duration of the trip in seconds
distance: { type: 'integer' }, // distance traveled in trip, in meters
start_geography_id: { ...uuidSchema, nullable: true, default: null },
start_geography_type: { type: 'string' },
end_geography_id: { ...uuidSchema, nullable: true, default: null },
end_geography_type: { type: 'string' },
duration: { type: 'integer', nullable: true, default: null },
distance: { type: 'integer', nullable: true, default: null },
trip_events: { type: 'array', items: usableEventSchema }
},
required: [
'distance',
'duration',
'end_geography_id',
'end_timestamp',
'start_geography_id',
'start_timestamp',
'trip_events',
'trip_id',
'vehicle_type'
]
required: ['start_timestamp', 'end_timestamp', 'trip_events', 'trip_id']
}

/**
Expand Down

0 comments on commit 519692b

Please sign in to comment.