Skip to content

Commit

Permalink
Amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhtr committed Jun 22, 2020
1 parent a24c34d commit 7b75243
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 153 deletions.
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 @@ -9,7 +9,7 @@ See https://www.npmjs.com/package/io-ts-from-json-schema
*/

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

Expand Down
46 changes: 22 additions & 24 deletions maas-schemas-ts/src/core/itinerary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ See https://www.npmjs.com/package/io-ts-from-json-schema
*/

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

type Defined =
| Record<string, unknown>
Expand All @@ -33,7 +34,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 @@ -43,25 +44,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 @@ -83,15 +84,14 @@ 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;
explanation?: string;
superMode?: TravelMode_.SuperMode;
tags?: Array<string>;
label?: string;
n?: number;
isWhimRide?: boolean;
provider?: string;
} & {
Expand All @@ -116,15 +116,14 @@ 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,
explanation: t.string,
superMode: TravelMode_.SuperMode,
tags: t.array(t.string),
label: t.string,
n: t.number,
isWhimRide: t.boolean,
provider: t.string,
}),
Expand All @@ -135,7 +134,7 @@ export const Itinerary = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
id?: Id;
Expand All @@ -150,15 +149,14 @@ 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;
explanation?: string;
superMode?: TravelMode_.SuperMode;
tags?: Array<string>;
label?: string;
n?: number;
isWhimRide?: boolean;
provider?: string;
} & {
Expand All @@ -168,7 +166,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 @@ -8,10 +8,11 @@ See https://www.npmjs.com/package/io-ts-from-json-schema
*/

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

type Defined =
| Record<string, unknown>
Expand All @@ -29,45 +30,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 @@ -109,7 +103,7 @@ export const Plan1 = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
from?: Place_.Place;
Expand All @@ -126,7 +120,7 @@ export const Plan1 = t.brand(
},
Plan1Brand
> => true,
"Plan1"
'Plan1',
);
export interface Plan1Brand {
readonly Plan1: unique symbol;
Expand Down Expand Up @@ -160,7 +154,7 @@ export const Plan2 = t.brand(
}),
]),
(
x
x,
): x is t.Branded<
{
from?: Place_.Place;
Expand All @@ -173,7 +167,7 @@ export const Plan2 = t.brand(
},
Plan2Brand
> => true,
"Plan2"
'Plan2',
);
export interface Plan2Brand {
readonly Plan2: unique symbol;
Expand All @@ -185,7 +179,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
Loading

0 comments on commit 7b75243

Please sign in to comment.