Skip to content

Commit

Permalink
Use 13.x schemas version
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhtr committed Jun 30, 2020
1 parent 6ba0f5d commit 22dc9a3
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 83 deletions.
2 changes: 1 addition & 1 deletion maas-schemas-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maas-schemas-ts",
"version": "13.6.1",
"version": "13.7.0",
"description": "TypeScript types and io-ts validators for maas-schemas",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion maas-schemas-ts/src/core/components/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MaaS common components that are used consistently within our own objects
*/

import * as t from 'io-ts';
import * as Units_ from './units';
import * as Units_ from 'maas-schemas-ts/core/components/units';
import { NonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
import { nonEmptyArray } from 'io-ts-types/lib/nonEmptyArray';

Expand Down
43 changes: 22 additions & 21 deletions maas-schemas-ts/src/core/itinerary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ OpenTripPlanner itinerary, augmented with leg bookings per leg
*/

import * as Units_ from "maas-schemas-ts/core/components/units";
import * as t from "io-ts";
import * as Common_ from "maas-schemas-ts/core/components/common";
import * as State_ from "maas-schemas-ts/core/components/state";
import * as Fare_ from "maas-schemas-ts/core/components/fare";
import * as Leg_ from "maas-schemas-ts/core/leg";
import * as ProductOption_ from "maas-schemas-ts/core/product-option";
import * as Booking_ from "maas-schemas-ts/core/booking";
import * as Units_ from 'maas-schemas-ts/core/components/units';
import * as t from 'io-ts';
import * as Common_ from 'maas-schemas-ts/core/components/common';
import * as State_ from 'maas-schemas-ts/core/components/state';
import * as Fare_ from 'maas-schemas-ts/core/components/fare';
import * as Leg_ from 'maas-schemas-ts/core/leg';
import * as ProductOption_ from 'maas-schemas-ts/core/product-option';
import * as Booking_ from 'maas-schemas-ts/core/booking';
import * as TravelMode_ from 'maas-schemas-ts/core/components/travel-mode';

type Defined =
| Record<string, unknown>
Expand All @@ -32,7 +33,7 @@ const Defined = t.union([
t.null,
]);

export const schemaId = "http://maasglobal.com/core/itinerary.json";
export const schemaId = 'http://maasglobal.com/core/itinerary.json';

// Id
// The purpose of this remains a mystery
Expand All @@ -42,25 +43,25 @@ export const Id = Units_.Uuid;
// ItineraryProgress
// The purpose of this remains a mystery
export type ItineraryProgress = t.Branded<
string & ("IN_PROGRESS" | "IN_PROGRESS_PURCHASABLE" | "FINISHED"),
string & ('IN_PROGRESS' | 'IN_PROGRESS_PURCHASABLE' | 'FINISHED'),
ItineraryProgressBrand
>;
export const ItineraryProgress = t.brand(
t.intersection([
t.string,
t.union([
t.literal("IN_PROGRESS"),
t.literal("IN_PROGRESS_PURCHASABLE"),
t.literal("FINISHED"),
t.literal('IN_PROGRESS'),
t.literal('IN_PROGRESS_PURCHASABLE'),
t.literal('FINISHED'),
]),
]),
(
x
x,
): x is t.Branded<
string & ("IN_PROGRESS" | "IN_PROGRESS_PURCHASABLE" | "FINISHED"),
string & ('IN_PROGRESS' | 'IN_PROGRESS_PURCHASABLE' | 'FINISHED'),
ItineraryProgressBrand
> => true,
"ItineraryProgress"
'ItineraryProgress',
);
export interface ItineraryProgressBrand {
readonly ItineraryProgress: unique symbol;
Expand All @@ -82,7 +83,7 @@ export type Itinerary = t.Branded<
fares?: Array<Fare_.Fare>;
legs?: Array<Leg_.Leg>;
productOptions?: Array<ProductOption_.ProductOption>;
type?: "outward" | "return";
type?: 'outward' | 'return';
bookings?: Array<Booking_.Booking>;
progress?: ItineraryProgress;
fingerprint?: string;
Expand Down Expand Up @@ -114,7 +115,7 @@ export const Itinerary = t.brand(
fares: t.array(Fare_.Fare),
legs: t.array(Leg_.Leg),
productOptions: t.array(ProductOption_.ProductOption),
type: t.union([t.literal("outward"), t.literal("return")]),
type: t.union([t.literal('outward'), t.literal('return')]),
bookings: t.array(Booking_.Booking),
progress: ItineraryProgress,
fingerprint: t.string,
Expand All @@ -132,7 +133,7 @@ export const Itinerary = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
id?: Id;
Expand All @@ -147,7 +148,7 @@ export const Itinerary = t.brand(
fares?: Array<Fare_.Fare>;
legs?: Array<Leg_.Leg>;
productOptions?: Array<ProductOption_.ProductOption>;
type?: "outward" | "return";
type?: 'outward' | 'return';
bookings?: Array<Booking_.Booking>;
progress?: ItineraryProgress;
fingerprint?: string;
Expand All @@ -164,7 +165,7 @@ export const Itinerary = t.brand(
},
ItineraryBrand
> => true,
"Itinerary"
'Itinerary',
);
export interface ItineraryBrand {
readonly Itinerary: unique symbol;
Expand Down
42 changes: 18 additions & 24 deletions maas-schemas-ts/src/core/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ OpenTripPlanner compatible format for plans, extended with id for legs and itine
*/

import * as t from "io-ts";
import * as Place_ from "maas-schemas-ts/core/components/place";
import * as Units_ from "maas-schemas-ts/core/components/units";
import * as Itinerary_ from "maas-schemas-ts/core/itinerary";
import * as t from 'io-ts';
import * as Place_ from 'maas-schemas-ts/core/components/place';
import * as Units_ from 'maas-schemas-ts/core/components/units';
import * as Common_ from 'maas-schemas-ts/core/components/common';
import * as Itinerary_ from 'maas-schemas-ts/core/itinerary';

type Defined =
| Record<string, unknown>
Expand All @@ -28,45 +29,38 @@ const Defined = t.union([
t.null,
]);

export const schemaId = "http://maasglobal.com/core/plan.json";
export const schemaId = 'http://maasglobal.com/core/plan.json';

// PlanProgress
// The purpose of this remains a mystery
export type PlanProgress = t.Branded<
string & ("IN_PROGRESS" | "FINISHED" | "FAILED"),
string & ('IN_PROGRESS' | 'FINISHED' | 'FAILED'),
PlanProgressBrand
>;
export const PlanProgress = t.brand(
t.intersection([
t.string,
t.union([
t.literal("IN_PROGRESS"),
t.literal("FINISHED"),
t.literal("FAILED"),
]),
t.union([t.literal('IN_PROGRESS'), t.literal('FINISHED'), t.literal('FAILED')]),
]),
(
x
x,
): x is t.Branded<
string & ("IN_PROGRESS" | "FINISHED" | "FAILED"),
string & ('IN_PROGRESS' | 'FINISHED' | 'FAILED'),
PlanProgressBrand
> => true,
"PlanProgress"
'PlanProgress',
);
export interface PlanProgressBrand {
readonly PlanProgress: unique symbol;
}

// Itineraries
// The purpose of this remains a mystery
export type Itineraries = t.Branded<
Array<Itinerary_.Itinerary>,
ItinerariesBrand
>;
export type Itineraries = t.Branded<Array<Itinerary_.Itinerary>, ItinerariesBrand>;
export const Itineraries = t.brand(
t.array(Itinerary_.Itinerary),
(x): x is t.Branded<Array<Itinerary_.Itinerary>, ItinerariesBrand> => true,
"Itineraries"
'Itineraries',
);
export interface ItinerariesBrand {
readonly Itineraries: unique symbol;
Expand Down Expand Up @@ -108,7 +102,7 @@ export const Plan1 = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
from?: Place_.Place;
Expand All @@ -125,7 +119,7 @@ export const Plan1 = t.brand(
},
Plan1Brand
> => true,
"Plan1"
'Plan1',
);
export interface Plan1Brand {
readonly Plan1: unique symbol;
Expand Down Expand Up @@ -159,7 +153,7 @@ export const Plan2 = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
from?: Place_.Place;
Expand All @@ -172,7 +166,7 @@ export const Plan2 = t.brand(
},
Plan2Brand
> => true,
"Plan2"
'Plan2',
);
export interface Plan2Brand {
readonly Plan2: unique symbol;
Expand All @@ -184,7 +178,7 @@ export type Plan = t.Branded<Plan1 | Plan2, PlanBrand>;
export const Plan = t.brand(
t.union([Plan1, Plan2]),
(x): x is t.Branded<Plan1 | Plan2, PlanBrand> => true,
"Plan"
'Plan',
);
export interface PlanBrand {
readonly Plan: unique symbol;
Expand Down
54 changes: 28 additions & 26 deletions maas-schemas-ts/src/maas-backend/routes/routes-query/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ Request schema for routes query
*/

import * as t from "io-ts";
import * as UnitsGeo_ from "maas-schemas-ts/core/components/units-geo";
import * as Address_ from "maas-schemas-ts/core/components/address";
import * as Station_ from "maas-schemas-ts/core/components/station";
import * as Units_ from "maas-schemas-ts/core/components/units";
import * as ApiCommon_ from "maas-schemas-ts/core/components/api-common";
import * as t from 'io-ts';
import * as UnitsGeo_ from 'maas-schemas-ts/core/components/units-geo';
import * as Address_ from 'maas-schemas-ts/core/components/address';
import * as Station_ from 'maas-schemas-ts/core/components/station';
import * as Units_ from 'maas-schemas-ts/core/components/units';
import * as TravelMode_ from 'maas-schemas-ts/core/components/travel-mode';
import * as Common_ from 'maas-schemas-ts/core/components/common';
import * as ApiCommon_ from 'maas-schemas-ts/core/components/api-common';

type Defined =
| Record<string, unknown>
Expand All @@ -31,7 +33,7 @@ const Defined = t.union([
]);

export const schemaId =
"http://maasglobal.com/maas-backend/routes/routes-query/request.json";
'http://maasglobal.com/maas-backend/routes/routes-query/request.json';

// Payload
// The purpose of this remains a mystery
Expand All @@ -50,7 +52,7 @@ export type Payload = t.Branded<
leaveAtReturn?: Units_.Time;
arriveByReturn?: Units_.Time;
modes?: TravelMode_.SuperMode;
transitMode?: string & ("TRAIN" | "BUS" | "SUBWAY" | "TRAM" | "RAIL");
transitMode?: string & ('TRAIN' | 'BUS' | 'SUBWAY' | 'TRAM' | 'RAIL');
options?: {};
bookingIdToExtend?: Units_.Uuid;
requestId?: Common_.RequestId;
Expand All @@ -69,7 +71,7 @@ export type Payload = t.Branded<
| Units_.Time
| Units_.Time
| TravelMode_.SuperMode
| (string & ("TRAIN" | "BUS" | "SUBWAY" | "TRAM" | "RAIL"))
| (string & ('TRAIN' | 'BUS' | 'SUBWAY' | 'TRAM' | 'RAIL'))
| {}
| Units_.Uuid
| Common_.RequestId
Expand All @@ -96,11 +98,11 @@ export const Payload = t.brand(
transitMode: t.intersection([
t.string,
t.union([
t.literal("TRAIN"),
t.literal("BUS"),
t.literal("SUBWAY"),
t.literal("TRAM"),
t.literal("RAIL"),
t.literal('TRAIN'),
t.literal('BUS'),
t.literal('SUBWAY'),
t.literal('TRAM'),
t.literal('RAIL'),
]),
]),
options: t.type({}),
Expand All @@ -126,22 +128,22 @@ export const Payload = t.brand(
t.intersection([
t.string,
t.union([
t.literal("TRAIN"),
t.literal("BUS"),
t.literal("SUBWAY"),
t.literal("TRAM"),
t.literal("RAIL"),
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]),
])
]),
),
]),
(
x
x,
): x is t.Branded<
{
from?: UnitsGeo_.ShortLocationString;
Expand All @@ -157,7 +159,7 @@ export const Payload = t.brand(
leaveAtReturn?: Units_.Time;
arriveByReturn?: Units_.Time;
modes?: TravelMode_.SuperMode;
transitMode?: string & ("TRAIN" | "BUS" | "SUBWAY" | "TRAM" | "RAIL");
transitMode?: string & ('TRAIN' | 'BUS' | 'SUBWAY' | 'TRAM' | 'RAIL');
options?: {};
bookingIdToExtend?: Units_.Uuid;
requestId?: Common_.RequestId;
Expand All @@ -176,15 +178,15 @@ export const Payload = t.brand(
| Units_.Time
| Units_.Time
| TravelMode_.SuperMode
| (string & ("TRAIN" | "BUS" | "SUBWAY" | "TRAM" | "RAIL"))
| (string & ('TRAIN' | 'BUS' | 'SUBWAY' | 'TRAM' | 'RAIL'))
| {}
| Units_.Uuid
| Common_.RequestId
| (string | number | boolean)
>,
PayloadBrand
> => true,
"Payload"
'Payload',
);
export interface PayloadBrand {
readonly Payload: unique symbol;
Expand Down Expand Up @@ -216,7 +218,7 @@ export const Request = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
identityId?: Units_.IdentityId;
Expand All @@ -228,7 +230,7 @@ export const Request = t.brand(
},
RequestBrand
> => true,
"Request"
'Request',
);
export interface RequestBrand {
readonly Request: unique symbol;
Expand Down
Loading

0 comments on commit 22dc9a3

Please sign in to comment.