From a38b1e1d14700b14ca03e575f6e9eef6ff8a1cb9 Mon Sep 17 00:00:00 2001 From: marcin Date: Fri, 21 Jun 2024 14:28:10 +0200 Subject: [PATCH 1/3] Add new mode - Moped --- maas-schemas/package.json | 2 +- maas-schemas/schemas/core/booking-meta.json | 3 +- .../schemas/core/components/message.json | 3 +- .../schemas/core/components/travel-mode.json | 6 ++- .../schemas/core/components/vehicle.json | 1 + .../schemas/core/modes/MODE_MOPED.json | 16 ++++++++ maas-schemas/src/ajv/registry.ts | 1 + maas-schemas/src/io-ts/_translation.log | 2 + .../src/io-ts/_types/core/booking-meta.ts | 5 +++ .../io-ts/_types/core/components/message.ts | 4 ++ .../_types/core/components/travel-mode.ts | 41 ++++++++++++++++++- .../io-ts/_types/core/components/vehicle.ts | 4 ++ 12 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 maas-schemas/schemas/core/modes/MODE_MOPED.json diff --git a/maas-schemas/package.json b/maas-schemas/package.json index 08fc7591f..9ec8e7c72 100644 --- a/maas-schemas/package.json +++ b/maas-schemas/package.json @@ -1,6 +1,6 @@ { "name": "maas-schemas", - "version": "22.0.0", + "version": "23.0.0", "description": "Schemas for MaaS infrastructure", "main": "index.js", "engine": { diff --git a/maas-schemas/schemas/core/booking-meta.json b/maas-schemas/schemas/core/booking-meta.json index 4966deda2..39071d888 100644 --- a/maas-schemas/schemas/core/booking-meta.json +++ b/maas-schemas/schemas/core/booking-meta.json @@ -41,6 +41,7 @@ }, "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" } } } diff --git a/maas-schemas/schemas/core/components/message.json b/maas-schemas/schemas/core/components/message.json index 51245090e..63b91349c 100644 --- a/maas-schemas/schemas/core/components/message.json +++ b/maas-schemas/schemas/core/components/message.json @@ -32,7 +32,8 @@ "MODE_TRAINISH", "MODE_BUSISH", "MODE_TAXI", - "MODE_SCOOTER" + "MODE_SCOOTER", + "MODE_MOPED" ] }, "property": { diff --git a/maas-schemas/schemas/core/components/travel-mode.json b/maas-schemas/schemas/core/components/travel-mode.json index 5b3512b61..ef3ca85a3 100644 --- a/maas-schemas/schemas/core/components/travel-mode.json +++ b/maas-schemas/schemas/core/components/travel-mode.json @@ -35,7 +35,7 @@ "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", @@ -61,6 +61,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", diff --git a/maas-schemas/schemas/core/components/vehicle.json b/maas-schemas/schemas/core/components/vehicle.json index 8254b6de8..5cdb02e0b 100644 --- a/maas-schemas/schemas/core/components/vehicle.json +++ b/maas-schemas/schemas/core/components/vehicle.json @@ -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" }, diff --git a/maas-schemas/schemas/core/modes/MODE_MOPED.json b/maas-schemas/schemas/core/modes/MODE_MOPED.json new file mode 100644 index 000000000..d10a566a9 --- /dev/null +++ b/maas-schemas/schemas/core/modes/MODE_MOPED.json @@ -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"] + } + } +} diff --git a/maas-schemas/src/ajv/registry.ts b/maas-schemas/src/ajv/registry.ts index e4fd47022..2cfadb276 100644 --- a/maas-schemas/src/ajv/registry.ts +++ b/maas-schemas/src/ajv/registry.ts @@ -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'), diff --git a/maas-schemas/src/io-ts/_translation.log b/maas-schemas/src/io-ts/_translation.log index 301517a62..698f42172 100644 --- a/maas-schemas/src/io-ts/_translation.log +++ b/maas-schemas/src/io-ts/_translation.log @@ -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 diff --git a/maas-schemas/src/io-ts/_types/core/booking-meta.ts b/maas-schemas/src/io-ts/_types/core/booking-meta.ts index 63eb12893..10e8cde08 100644 --- a/maas-schemas/src/io-ts/_types/core/booking-meta.ts +++ b/maas-schemas/src/io-ts/_types/core/booking-meta.ts @@ -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'; @@ -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, BookingMetaBrand >; @@ -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, ] @@ -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), ]), @@ -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, BookingMetaBrand > => true, diff --git a/maas-schemas/src/io-ts/_types/core/components/message.ts b/maas-schemas/src/io-ts/_types/core/components/message.ts index ab0a0190c..2992192ce 100644 --- a/maas-schemas/src/io-ts/_types/core/components/message.ts +++ b/maas-schemas/src/io-ts/_types/core/components/message.ts @@ -54,6 +54,7 @@ export type Message = t.Branded< | 'MODE_BUSISH' | 'MODE_TAXI' | 'MODE_SCOOTER' + | 'MODE_MOPED' ); property?: string; } & { @@ -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'>, ] >, ] @@ -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, @@ -172,6 +175,7 @@ export const Message: MessageC = t.brand( | 'MODE_BUSISH' | 'MODE_TAXI' | 'MODE_SCOOTER' + | 'MODE_MOPED' ); property?: string; } & { diff --git a/maas-schemas/src/io-ts/_types/core/components/travel-mode.ts b/maas-schemas/src/io-ts/_types/core/components/travel-mode.ts index 969c142a9..d10dedd33 100644 --- a/maas-schemas/src/io-ts/_types/core/components/travel-mode.ts +++ b/maas-schemas/src/io-ts/_types/core/components/travel-mode.ts @@ -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< @@ -131,6 +139,7 @@ export type PersonalModeC = t.BrandC< t.LiteralC<'SHARED_BICYCLE'>, t.LiteralC<'WALK'>, t.LiteralC<'SHARED_E_BICYCLE'>, + t.LiteralC<'MOPED'>, ] >, ] @@ -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', @@ -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; +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 => 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< diff --git a/maas-schemas/src/io-ts/_types/core/components/vehicle.ts b/maas-schemas/src/io-ts/_types/core/components/vehicle.ts index 2f44d10e7..e1c136966 100644 --- a/maas-schemas/src/io-ts/_types/core/components/vehicle.ts +++ b/maas-schemas/src/io-ts/_types/core/components/vehicle.ts @@ -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; @@ -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; @@ -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, @@ -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; From 9033972eca5b4b9dbb328b1c711444a4b9281969 Mon Sep 17 00:00:00 2001 From: marcin Date: Fri, 21 Jun 2024 15:01:45 +0200 Subject: [PATCH 2/3] add missing import --- maas-schemas/schemas/core/booking-meta.json | 4 +++- maas-schemas/schemas/core/components/travel-mode.json | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/maas-schemas/schemas/core/booking-meta.json b/maas-schemas/schemas/core/booking-meta.json index 39071d888..03bc526eb 100644 --- a/maas-schemas/schemas/core/booking-meta.json +++ b/maas-schemas/schemas/core/booking-meta.json @@ -41,7 +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" } } } diff --git a/maas-schemas/schemas/core/components/travel-mode.json b/maas-schemas/schemas/core/components/travel-mode.json index ef3ca85a3..6f27c6f4b 100644 --- a/maas-schemas/schemas/core/components/travel-mode.json +++ b/maas-schemas/schemas/core/components/travel-mode.json @@ -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", "MOPED"] + "enum": [ + "BICYCLE", + "CAR", + "SCOOTER", + "SHARED_BICYCLE", + "WALK", + "SHARED_E_BICYCLE", + "MOPED" + ] }, "personalModeBICYCLE": { "default": "BICYCLE", From 002a6e3270b6f40592b2ed3305912750c3d79d5c Mon Sep 17 00:00:00 2001 From: marcin Date: Fri, 21 Jun 2024 15:04:26 +0200 Subject: [PATCH 3/3] add missing files --- .../src/io-ts/_types/core/modes/MODE_MOPED.ts | 106 ++++++++++++++++++ .../src/io-ts/core/modes/MODE_MOPED.ts | 3 + 2 files changed, 109 insertions(+) create mode 100644 maas-schemas/src/io-ts/_types/core/modes/MODE_MOPED.ts create mode 100644 maas-schemas/src/io-ts/core/modes/MODE_MOPED.ts diff --git a/maas-schemas/src/io-ts/_types/core/modes/MODE_MOPED.ts b/maas-schemas/src/io-ts/_types/core/modes/MODE_MOPED.ts new file mode 100644 index 000000000..7a6ce3fcc --- /dev/null +++ b/maas-schemas/src/io-ts/_types/core/modes/MODE_MOPED.ts @@ -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 { + 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) & { + id: Defined; + }; + } & Record, + 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.TypeC<{ + id: typeof Defined; + }>, + ] + >; + }>, + t.RecordC, + ] + >, + 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) & { + id: Defined; + }; + } & Record, + MODE_MOPEDBrand + > => true, + 'MODE_MOPED', +); +export type MODE_MOPEDBrand = { + readonly MODE_MOPED: unique symbol; +}; + +export default MODE_MOPED; + +// Success diff --git a/maas-schemas/src/io-ts/core/modes/MODE_MOPED.ts b/maas-schemas/src/io-ts/core/modes/MODE_MOPED.ts new file mode 100644 index 000000000..69e82c080 --- /dev/null +++ b/maas-schemas/src/io-ts/core/modes/MODE_MOPED.ts @@ -0,0 +1,3 @@ +// Generated by update-index.ts Do not edit! + +export * from '../../_types/core/modes/MODE_MOPED';