Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new mode - Moped #775

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maas-schemas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maas-schemas",
"version": "22.0.0",
"version": "23.0.0",
"description": "Schemas for MaaS infrastructure",
"main": "index.js",
"engine": {
Expand Down
5 changes: 4 additions & 1 deletion maas-schemas/schemas/core/booking-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
},
"MODE_BUSISH": { "$ref": "https://schemas.maas.global/core/modes/MODE_BUSISH.json" },
"MODE_TAXI": { "$ref": "https://schemas.maas.global/core/modes/MODE_TAXI.json" },
"MODE_SCOOTER": { "$ref": "https://schemas.maas.global/core/modes/MODE_SCOOTER.json" }
"MODE_SCOOTER": {
"$ref": "https://schemas.maas.global/core/modes/MODE_SCOOTER.json"
},
"MODE_MOPED": { "$ref": "https://schemas.maas.global/core/modes/MODE_MOPED.json" }
}
}
3 changes: 2 additions & 1 deletion maas-schemas/schemas/core/components/message.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"MODE_TRAINISH",
"MODE_BUSISH",
"MODE_TAXI",
"MODE_SCOOTER"
"MODE_SCOOTER",
"MODE_MOPED"
]
},
"property": {
Expand Down
14 changes: 13 additions & 1 deletion maas-schemas/schemas/core/components/travel-mode.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@
"personalMode": {
"description": "A mode that involves using your personal vehicle or legs",
"type": "string",
"enum": ["BICYCLE", "CAR", "SCOOTER", "SHARED_BICYCLE", "WALK", "SHARED_E_BICYCLE"]
"enum": [
"BICYCLE",
"CAR",
"SCOOTER",
"SHARED_BICYCLE",
"WALK",
"SHARED_E_BICYCLE",
"MOPED"
]
},
"personalModeBICYCLE": {
"default": "BICYCLE",
Expand All @@ -61,6 +69,10 @@
"default": "SHARED_E_BICYCLE",
"allOf": [{ "$ref": "#/definitions/personalMode" }, { "const": "SHARED_E_BICYCLE" }]
},
"personalModeMOPED": {
"default": "MOPED",
"allOf": [{ "$ref": "#/definitions/personalMode" }, { "const": "MOPED" }]
},
"publicTransitMode": {
"description": "A mode that involves transit with fixed schedules",
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions maas-schemas/schemas/core/components/vehicle.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"MODE_SHARED_BICYCLE": { "$ref": "#/definitions/vehicleIds" },
"MODE_SHARED_CAR": { "$ref": "#/definitions/vehicleIds" },
"MODE_SHARED_E_BICYCLE": { "$ref": "#/definitions/vehicleIds" },
"MODE_MOPED": { "$ref": "#/definitions/vehicleIds" },
"MODE_SUBWAY": { "$ref": "#/definitions/vehicleIds" },
"MODE_TAXI": { "$ref": "#/definitions/vehicleIds" },
"MODE_TRAIN": { "$ref": "#/definitions/vehicleIds" },
Expand Down
16 changes: 16 additions & 0 deletions maas-schemas/schemas/core/modes/MODE_MOPED.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schemas.maas.global/core/modes/MODE_MOPED.json",
"type": "object",
"properties": {
"scooter": {
"type": "object",
"properties": {
"id": {
"$ref": "https://schemas.maas.global/core/components/vehicle.json#/definitions/vehicleId"
}
},
"required": ["id"]
}
}
}
1 change: 1 addition & 0 deletions maas-schemas/src/ajv/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const registry: mjsv.Registry = {
require('../../schemas/core/modes/MODE_FERRY.json'),
require('../../schemas/core/modes/MODE_FUNICULAR.json'),
require('../../schemas/core/modes/MODE_GONDOLA.json'),
require('../../schemas/core/modes/MODE_MOPED.json'),
require('../../schemas/core/modes/MODE_RAIL.json'),
require('../../schemas/core/modes/MODE_SCOOTER.json'),
require('../../schemas/core/modes/MODE_SHARED_BICYCLE.json'),
Expand Down
2 changes: 2 additions & 0 deletions maas-schemas/src/io-ts/_translation.log
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ INFO: missing description
in schemas/core/components/travel-mode.json
INFO: missing description
in schemas/core/components/travel-mode.json
INFO: missing description
in schemas/core/components/travel-mode.json
INFO: missing description
in schemas/core/components/units.json
INFO: missing description
Expand Down
5 changes: 5 additions & 0 deletions maas-schemas/src/io-ts/_types/core/booking-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as MODE_CAR_4d30_ from './modes/MODE_CAR';
import * as MODE_FERRY_f954_ from './modes/MODE_FERRY';
import * as MODE_FUNICULAR_d8d1_ from './modes/MODE_FUNICULAR';
import * as MODE_GONDOLA_a364_ from './modes/MODE_GONDOLA';
import * as MODE_MOPED_b703_ from './modes/MODE_MOPED';
import * as MODE_RAIL_40d3_ from './modes/MODE_RAIL';
import * as MODE_SCOOTER_8025_ from './modes/MODE_SCOOTER';
import * as MODE_SHARED_BICYCLE_f843_ from './modes/MODE_SHARED_BICYCLE';
Expand Down Expand Up @@ -57,6 +58,7 @@ export type BookingMeta = t.Branded<
MODE_BUSISH?: MODE_BUSISH_89ff_.MODE_BUSISH;
MODE_TAXI?: MODE_TAXI_3ea5_.MODE_TAXI;
MODE_SCOOTER?: MODE_SCOOTER_8025_.MODE_SCOOTER;
MODE_MOPED?: MODE_MOPED_b703_.MODE_MOPED;
} & Record<string, unknown>,
BookingMetaBrand
>;
Expand Down Expand Up @@ -84,6 +86,7 @@ export type BookingMetaC = t.BrandC<
MODE_BUSISH: typeof MODE_BUSISH_89ff_.MODE_BUSISH;
MODE_TAXI: typeof MODE_TAXI_3ea5_.MODE_TAXI;
MODE_SCOOTER: typeof MODE_SCOOTER_8025_.MODE_SCOOTER;
MODE_MOPED: typeof MODE_MOPED_b703_.MODE_MOPED;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
Expand Down Expand Up @@ -113,6 +116,7 @@ export const BookingMeta: BookingMetaC = t.brand(
MODE_BUSISH: MODE_BUSISH_89ff_.MODE_BUSISH,
MODE_TAXI: MODE_TAXI_3ea5_.MODE_TAXI,
MODE_SCOOTER: MODE_SCOOTER_8025_.MODE_SCOOTER,
MODE_MOPED: MODE_MOPED_b703_.MODE_MOPED,
}),
t.record(t.string, t.unknown),
]),
Expand Down Expand Up @@ -140,6 +144,7 @@ export const BookingMeta: BookingMetaC = t.brand(
MODE_BUSISH?: MODE_BUSISH_89ff_.MODE_BUSISH;
MODE_TAXI?: MODE_TAXI_3ea5_.MODE_TAXI;
MODE_SCOOTER?: MODE_SCOOTER_8025_.MODE_SCOOTER;
MODE_MOPED?: MODE_MOPED_b703_.MODE_MOPED;
} & Record<string, unknown>,
BookingMetaBrand
> => true,
Expand Down
4 changes: 4 additions & 0 deletions maas-schemas/src/io-ts/_types/core/components/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type Message = t.Branded<
| 'MODE_BUSISH'
| 'MODE_TAXI'
| 'MODE_SCOOTER'
| 'MODE_MOPED'
);
property?: string;
} & {
Expand Down Expand Up @@ -93,6 +94,7 @@ export type MessageC = t.BrandC<
t.LiteralC<'MODE_BUSISH'>,
t.LiteralC<'MODE_TAXI'>,
t.LiteralC<'MODE_SCOOTER'>,
t.LiteralC<'MODE_MOPED'>,
]
>,
]
Expand Down Expand Up @@ -135,6 +137,7 @@ export const Message: MessageC = t.brand(
t.literal('MODE_BUSISH'),
t.literal('MODE_TAXI'),
t.literal('MODE_SCOOTER'),
t.literal('MODE_MOPED'),
]),
]),
property: t.string,
Expand Down Expand Up @@ -172,6 +175,7 @@ export const Message: MessageC = t.brand(
| 'MODE_BUSISH'
| 'MODE_TAXI'
| 'MODE_SCOOTER'
| 'MODE_MOPED'
);
property?: string;
} & {
Expand Down
41 changes: 39 additions & 2 deletions maas-schemas/src/io-ts/_types/core/components/travel-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ export const defaultTransferModeTRANSFER: TransferModeTRANSFER =
// A mode that involves using your personal vehicle or legs
export type PersonalMode = t.Branded<
string &
('BICYCLE' | 'CAR' | 'SCOOTER' | 'SHARED_BICYCLE' | 'WALK' | 'SHARED_E_BICYCLE'),
(
| 'BICYCLE'
| 'CAR'
| 'SCOOTER'
| 'SHARED_BICYCLE'
| 'WALK'
| 'SHARED_E_BICYCLE'
| 'MOPED'
),
PersonalModeBrand
>;
export type PersonalModeC = t.BrandC<
Expand All @@ -131,6 +139,7 @@ export type PersonalModeC = t.BrandC<
t.LiteralC<'SHARED_BICYCLE'>,
t.LiteralC<'WALK'>,
t.LiteralC<'SHARED_E_BICYCLE'>,
t.LiteralC<'MOPED'>,
]
>,
]
Expand All @@ -147,13 +156,22 @@ export const PersonalMode: PersonalModeC = t.brand(
t.literal('SHARED_BICYCLE'),
t.literal('WALK'),
t.literal('SHARED_E_BICYCLE'),
t.literal('MOPED'),
]),
]),
(
x,
): x is t.Branded<
string &
('BICYCLE' | 'CAR' | 'SCOOTER' | 'SHARED_BICYCLE' | 'WALK' | 'SHARED_E_BICYCLE'),
(
| 'BICYCLE'
| 'CAR'
| 'SCOOTER'
| 'SHARED_BICYCLE'
| 'WALK'
| 'SHARED_E_BICYCLE'
| 'MOPED'
),
PersonalModeBrand
> => true,
'PersonalMode',
Expand Down Expand Up @@ -294,6 +312,25 @@ export type PersonalModeSHARED_E_BICYCLEBrand = {
export const defaultPersonalModeSHARED_E_BICYCLE: PersonalModeSHARED_E_BICYCLE =
'SHARED_E_BICYCLE' as unknown as PersonalModeSHARED_E_BICYCLE;

// PersonalModeMOPED
// The purpose of this remains a mystery
export type PersonalModeMOPED = t.Branded<PersonalMode & 'MOPED', PersonalModeMOPEDBrand>;
export type PersonalModeMOPEDC = t.BrandC<
t.IntersectionC<[typeof PersonalMode, t.LiteralC<'MOPED'>]>,
PersonalModeMOPEDBrand
>;
export const PersonalModeMOPED: PersonalModeMOPEDC = t.brand(
t.intersection([PersonalMode, t.literal('MOPED')]),
(x): x is t.Branded<PersonalMode & 'MOPED', PersonalModeMOPEDBrand> => true,
'PersonalModeMOPED',
);
export type PersonalModeMOPEDBrand = {
readonly PersonalModeMOPED: unique symbol;
};
/** require('io-ts-validator').validator(PersonalModeMOPED).decodeSync(defaultPersonalModeMOPED) // => defaultPersonalModeMOPED */
export const defaultPersonalModeMOPED: PersonalModeMOPED =
'MOPED' as unknown as PersonalModeMOPED;

// PublicTransitMode
// A mode that involves transit with fixed schedules
export type PublicTransitMode = t.Branded<
Expand Down
4 changes: 4 additions & 0 deletions maas-schemas/src/io-ts/_types/core/components/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export type VehicleIdsByMode = t.Branded<
MODE_SHARED_BICYCLE?: VehicleIds;
MODE_SHARED_CAR?: VehicleIds;
MODE_SHARED_E_BICYCLE?: VehicleIds;
MODE_MOPED?: VehicleIds;
MODE_SUBWAY?: VehicleIds;
MODE_TAXI?: VehicleIds;
MODE_TRAIN?: VehicleIds;
Expand Down Expand Up @@ -118,6 +119,7 @@ export type VehicleIdsByModeC = t.BrandC<
MODE_SHARED_BICYCLE: typeof VehicleIds;
MODE_SHARED_CAR: typeof VehicleIds;
MODE_SHARED_E_BICYCLE: typeof VehicleIds;
MODE_MOPED: typeof VehicleIds;
MODE_SUBWAY: typeof VehicleIds;
MODE_TAXI: typeof VehicleIds;
MODE_TRAIN: typeof VehicleIds;
Expand Down Expand Up @@ -168,6 +170,7 @@ export const VehicleIdsByMode: VehicleIdsByModeC = t.brand(
MODE_SHARED_BICYCLE: VehicleIds,
MODE_SHARED_CAR: VehicleIds,
MODE_SHARED_E_BICYCLE: VehicleIds,
MODE_MOPED: VehicleIds,
MODE_SUBWAY: VehicleIds,
MODE_TAXI: VehicleIds,
MODE_TRAIN: VehicleIds,
Expand Down Expand Up @@ -216,6 +219,7 @@ export const VehicleIdsByMode: VehicleIdsByModeC = t.brand(
MODE_SHARED_BICYCLE?: VehicleIds;
MODE_SHARED_CAR?: VehicleIds;
MODE_SHARED_E_BICYCLE?: VehicleIds;
MODE_MOPED?: VehicleIds;
MODE_SUBWAY?: VehicleIds;
MODE_TAXI?: VehicleIds;
MODE_TRAIN?: VehicleIds;
Expand Down
106 changes: 106 additions & 0 deletions maas-schemas/src/io-ts/_types/core/modes/MODE_MOPED.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*

undefined
undefined

!!! AUTO GENERATED BY IOTSFJS REFRAIN FROM MANUAL EDITING !!!
See https://www.npmjs.com/package/io-ts-from-json-schema

*/

import * as t from 'io-ts';

import * as Vehicle_52ac_ from '../components/vehicle';

export type Defined = {} | null;
export class DefinedType extends t.Type<Defined> {
readonly _tag: 'DefinedType' = 'DefinedType';
constructor() {
super(
'defined',
(u): u is Defined => typeof u !== 'undefined',
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
t.identity,
);
}
}
export type DefinedC = {} & DefinedType;
export const Defined: DefinedC = new DefinedType();

export const schemaId = 'https://schemas.maas.global/core/modes/MODE_MOPED.json';

// MODE_MOPED
// The default export. More information at the top.
export type MODE_MOPED = t.Branded<
{
scooter?: ({
id?: Vehicle_52ac_.VehicleId;
} & Record<string, unknown>) & {
id: Defined;
};
} & Record<string, unknown>,
MODE_MOPEDBrand
>;
export type MODE_MOPEDC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
scooter: t.IntersectionC<
[
t.IntersectionC<
[
t.PartialC<{
id: typeof Vehicle_52ac_.VehicleId;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>,
t.TypeC<{
id: typeof Defined;
}>,
]
>;
}>,
t.RecordC<t.StringC, t.UnknownC>,
]
>,
MODE_MOPEDBrand
>;
export const MODE_MOPED: MODE_MOPEDC = t.brand(
t.intersection([
t.partial({
scooter: t.intersection([
t.intersection([
t.partial({
id: Vehicle_52ac_.VehicleId,
}),
t.record(t.string, t.unknown),
]),
t.type({
id: Defined,
}),
]),
}),
t.record(t.string, t.unknown),
]),
(
x,
): x is t.Branded<
{
scooter?: ({
id?: Vehicle_52ac_.VehicleId;
} & Record<string, unknown>) & {
id: Defined;
};
} & Record<string, unknown>,
MODE_MOPEDBrand
> => true,
'MODE_MOPED',
);
export type MODE_MOPEDBrand = {
readonly MODE_MOPED: unique symbol;
};

export default MODE_MOPED;

// Success
3 changes: 3 additions & 0 deletions maas-schemas/src/io-ts/core/modes/MODE_MOPED.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Generated by update-index.ts Do not edit!

export * from '../../_types/core/modes/MODE_MOPED';
Loading