Skip to content

Commit

Permalink
Relaxing route query request
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhtr committed May 25, 2020
1 parent fde4c37 commit f3113c1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 68 deletions.
122 changes: 55 additions & 67 deletions maas-schemas-ts/src/maas-backend/routes/routes-query/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const schemaId =
// Payload
// The purpose of this remains a mystery
export type Payload = t.Branded<
({
{
from?: UnitsGeo_.ShortLocationString;
fromName?: Address_.PlaceName;
fromAddress?: Address_.ComponentAddress;
Expand Down Expand Up @@ -75,30 +75,56 @@ export type Payload = t.Branded<
| Units_.Uuid
| Common_.RequestId
| (string | number | boolean)
>) & {
from: Defined;
to: Defined;
},
>,
PayloadBrand
>;
export const Payload = t.brand(
t.intersection([
t.intersection([
t.partial({
from: UnitsGeo_.ShortLocationString,
fromName: Address_.PlaceName,
fromAddress: Address_.ComponentAddress,
fromStationId: Station_.Id,
to: UnitsGeo_.ShortLocationString,
toName: Address_.PlaceName,
toAddress: Address_.ComponentAddress,
toStationId: Station_.Id,
leaveAt: Units_.Time,
arriveBy: Units_.Time,
leaveAtReturn: Units_.Time,
arriveByReturn: Units_.Time,
modes: t.string,
transitMode: t.intersection([
t.partial({
from: UnitsGeo_.ShortLocationString,
fromName: Address_.PlaceName,
fromAddress: Address_.ComponentAddress,
fromStationId: Station_.Id,
to: UnitsGeo_.ShortLocationString,
toName: Address_.PlaceName,
toAddress: Address_.ComponentAddress,
toStationId: Station_.Id,
leaveAt: Units_.Time,
arriveBy: Units_.Time,
leaveAtReturn: Units_.Time,
arriveByReturn: Units_.Time,
modes: t.string,
transitMode: t.intersection([
t.string,
t.union([
t.literal('TRAIN'),
t.literal('BUS'),
t.literal('SUBWAY'),
t.literal('TRAM'),
t.literal('RAIL'),
]),
]),
options: t.type({}),
bookingIdToExtend: Units_.Uuid,
requestId: Common_.RequestId,
}),
t.record(
t.string,
t.union([
UnitsGeo_.ShortLocationString,
Address_.PlaceName,
Address_.ComponentAddress,
Station_.Id,
UnitsGeo_.ShortLocationString,
Address_.PlaceName,
Address_.ComponentAddress,
Station_.Id,
Units_.Time,
Units_.Time,
Units_.Time,
Units_.Time,
t.string,
t.intersection([
t.string,
t.union([
t.literal('TRAIN'),
Expand All @@ -108,52 +134,17 @@ export const Payload = t.brand(
t.literal('RAIL'),
]),
]),
options: t.type({}),
bookingIdToExtend: Units_.Uuid,
requestId: Common_.RequestId,
}),
t.record(
t.string,
t.union([
UnitsGeo_.ShortLocationString,
Address_.PlaceName,
Address_.ComponentAddress,
Station_.Id,
UnitsGeo_.ShortLocationString,
Address_.PlaceName,
Address_.ComponentAddress,
Station_.Id,
Units_.Time,
Units_.Time,
Units_.Time,
Units_.Time,
t.string,
t.intersection([
t.string,
t.union([
t.literal('TRAIN'),
t.literal('BUS'),
t.literal('SUBWAY'),
t.literal('TRAM'),
t.literal('RAIL'),
]),
]),
t.type({}),
Units_.Uuid,
Common_.RequestId,
t.union([t.string, t.number, t.boolean]),
]),
),
]),
t.type({
from: Defined,
to: Defined,
}),
t.type({}),
Units_.Uuid,
Common_.RequestId,
t.union([t.string, t.number, t.boolean]),
]),
),
]),
(
x,
): x is t.Branded<
({
{
from?: UnitsGeo_.ShortLocationString;
fromName?: Address_.PlaceName;
fromAddress?: Address_.ComponentAddress;
Expand Down Expand Up @@ -191,10 +182,7 @@ export const Payload = t.brand(
| Units_.Uuid
| Common_.RequestId
| (string | number | boolean)
>) & {
from: Defined;
to: Defined;
},
>,
PayloadBrand
> => true,
'Payload',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"type": ["string", "number", "boolean"]
}
},
"required": ["from", "to"],
"additionalProperties": false
}
}
Expand Down

0 comments on commit f3113c1

Please sign in to comment.