"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VPTripsModel = void 0;
const schema_definitions_1 = require("@golemio/core/dist/schema-definitions");
const sequelize_1 = require("@golemio/core/dist/shared/sequelize");
class VPTripsModel extends sequelize_1.Model {
}
exports.VPTripsModel = VPTripsModel;
VPTripsModel.TABLE_NAME = "vehiclepositions_trips";
VPTripsModel.TABLE_NAME_HISTORY = "vehiclepositions_trips_history";
VPTripsModel.attributeModel = {
    agency_name_real: sequelize_1.DataTypes.STRING, // doprSkut "Jaroslav Štěpánek"
    agency_name_scheduled: sequelize_1.DataTypes.STRING, // dopr "Jaroslav Štěpánek"
    cis_line_id: sequelize_1.DataTypes.STRING, // lin "100155", "X7"
    cis_line_short_name: sequelize_1.DataTypes.STRING, // alias "155", "X7"
    cis_trip_number: sequelize_1.DataTypes.INTEGER, // spoj "40"
    gtfs_block_id: sequelize_1.DataTypes.STRING, // 1345_1573_201213
    gtfs_route_id: sequelize_1.DataTypes.STRING,
    gtfs_route_short_name: sequelize_1.DataTypes.STRING,
    gtfs_route_type: sequelize_1.DataTypes.INTEGER,
    gtfs_trip_headsign: sequelize_1.DataTypes.STRING,
    gtfs_trip_short_name: sequelize_1.DataTypes.STRING,
    gtfs_trip_id: sequelize_1.DataTypes.STRING,
    gtfs_date: sequelize_1.DataTypes.DATEONLY,
    gtfs_direction_id: sequelize_1.DataTypes.SMALLINT,
    gtfs_shape_id: sequelize_1.DataTypes.STRING(15),
    // ⬐ hash(start_timestamp, cis_id, cis_short_name, cis_number);
    id: {
        primaryKey: true,
        type: sequelize_1.DataTypes.STRING,
    },
    is_canceled: sequelize_1.DataTypes.BOOLEAN, // zrus "true"
    last_position_id: sequelize_1.DataTypes.BIGINT,
    last_position_context: sequelize_1.DataTypes.JSON,
    origin_route_name: sequelize_1.DataTypes.STRING, // kmenl "110"
    run_number: sequelize_1.DataTypes.INTEGER, // po "1"
    start_asw_stop_id: sequelize_1.DataTypes.STRING, // zast[0].zast "1234/1"
    start_cis_stop_id: sequelize_1.DataTypes.INTEGER, // zast[0].zast "57517"
    start_cis_stop_platform_code: sequelize_1.DataTypes.STRING, // zast[0].stan "C"
    start_time: sequelize_1.DataTypes.TIME, // zast[0].prij "" || "11:00"
    // ⬐ Převod příjezdu první zastávky na date (pozor, čas 23:59 který přišel v 0:01 bude mít včerejší datum!)
    start_timestamp: sequelize_1.DataTypes.DATE, // zast[0].prij "" || "11:00" --- po nalezení gtfs_trip_id nahrazeno JŘ
    end_timestamp: sequelize_1.DataTypes.DATE, // --- po nalezení gtfs_trip_id vyplněno z JŘ
    vehicle_registration_number: sequelize_1.DataTypes.INTEGER, // vuzevc "1030"
    vehicle_type_id: sequelize_1.DataTypes.INTEGER, // t "3"
    wheelchair_accessible: sequelize_1.DataTypes.BOOLEAN, // np "true"
    internal_route_name: sequelize_1.DataTypes.STRING(50),
    internal_run_number: sequelize_1.DataTypes.INTEGER,
    provider_source_type: sequelize_1.DataTypes.STRING(1),
};
VPTripsModel.jsonSchema = {
    oneOf: [
        {
            type: "array",
            items: {
                $ref: "#/definitions/trip",
            },
        },
        {
            $ref: "#/definitions/trip",
        },
    ],
    definitions: {
        // @ts-expect-error
        geometry: schema_definitions_1.SharedSchemaProvider.Geometry,
        // @ts-expect-error JSONSchemaType does not like type pairings in definitions
        trip: {
            title: "trip",
            description: "Vehicle Positions Trip",
            type: "object",
            properties: {
                cis_line_id: {
                    type: ["string", "null"],
                },
                cis_trip_number: {
                    type: ["number", "null"],
                },
                run_number: {
                    type: ["number", "null"],
                },
                internal_run_number: {
                    type: ["number", "null"],
                },
                cis_line_short_name: {
                    type: ["string", "null"],
                },
                gtfs_route_id: {
                    type: ["string", "null"],
                },
                gtfs_route_short_name: {
                    type: ["string", "null"],
                },
                gtfs_trip_id: {
                    type: ["string", "null"],
                },
                gtfs_date: {
                    oneOf: [
                        { type: "object", required: ["toISOString"] },
                        { type: "null", nullable: true },
                    ],
                },
                gtfs_direction_id: {
                    type: ["number", "null"],
                },
                gtfs_shape_id: {
                    type: ["string", "null"],
                },
                id: {
                    type: "string",
                },
                start_cis_stop_id: {
                    type: ["number", "null"],
                },
                start_cis_stop_platform_code: {
                    type: ["string", "null"],
                },
                start_time: {
                    type: ["string", "null"],
                },
                start_timestamp: {
                    type: ["object", "null"],
                    required: ["toISOString"],
                },
                vehicle_type_id: {
                    type: "number",
                },
                wheelchair_accessible: {
                    type: ["boolean", "null"],
                },
                agency_name_scheduled: {
                    type: ["string", "null"],
                },
                origin_route_name: {
                    type: ["string", "null"],
                },
                internal_route_name: {
                    type: ["string", "null"],
                },
                agency_name_real: {
                    type: ["string", "null"],
                },
                vehicle_registration_number: {
                    type: ["number", "null"],
                },
                gtfs_trip_headsign: {
                    type: ["string", "null"],
                },
                start_asw_stop_id: {
                    type: ["string", "null"],
                },
                gtfs_route_type: {
                    type: ["string", "number", "null"],
                },
                gtfs_block_id: {
                    type: ["string", "null"],
                },
                last_position_id: {
                    type: ["string", "null"],
                },
                is_canceled: {
                    type: ["boolean", "null"],
                },
                end_timestamp: {
                    type: ["object", "null"],
                    required: ["toISOString"],
                },
                gtfs_trip_short_name: {
                    type: ["string", "null"],
                },
                last_position_context: {
                    oneOf: [
                        {
                            $ref: "#/definitions/context",
                        },
                        {
                            type: "null",
                        },
                    ],
                },
                provider_source_type: {
                    type: ["string"],
                },
            },
            required: ["id"],
        },
        // @ts-expect-error JSONSchemaType does not like type pairings in definitions
        context: {
            title: "context",
            description: "Last position's context",
            type: "object",
            properties: {
                lastPositionId: {
                    type: ["string", "null"],
                },
                lastPositionLat: {
                    type: ["number", "null"],
                },
                lastPositionLng: {
                    type: ["number", "null"],
                },
                lastStopSequence: {
                    type: ["number", "null"],
                },
                lastPositionOriginTimestamp: {
                    type: ["number", "null"],
                },
                lastPositionTracking: {
                    oneOf: [
                        {
                            type: "object",
                            properties: {
                                type: {
                                    type: "string",
                                    enum: ["Feature"],
                                },
                                properties: {
                                    type: "object",
                                    // TODO add properties after creating shared schema for VP positions
                                },
                                geometry: {
                                    $ref: "#/definitions/geometry",
                                },
                            },
                            required: ["type", "properties", "geometry"],
                        },
                        {
                            type: "null",
                        },
                    ],
                },
                lastPositionCanceled: {
                    type: ["boolean", "null"],
                },
                lastPositionLastStop: {
                    type: "object",
                    properties: {
                        id: {
                            type: ["string", "null"],
                        },
                        sequence: {
                            type: ["number", "null"],
                        },
                        arrival_time: {
                            type: ["number", "null"],
                        },
                        departure_time: {
                            type: ["number", "null"],
                        },
                    },
                    required: [],
                },
                lastPositionDelay: {
                    type: ["number", "null"],
                },
                atStopStreak: {
                    type: "object",
                    properties: {
                        firstPositionTimestamp: {
                            type: ["number", "null"],
                        },
                        firstPositionDelay: {
                            type: ["number", "null"],
                        },
                        stop_sequence: {
                            type: ["number", "null"],
                        },
                    },
                    required: [],
                },
                lastPositionBeforeTrackDelayed: {
                    oneOf: [
                        {
                            type: "object",
                            properties: {
                                delay: {
                                    oneOf: [
                                        {
                                            type: "number",
                                        },
                                        {
                                            type: "null",
                                            nullable: true,
                                        },
                                    ],
                                },
                                origin_timestamp: {
                                    oneOf: [
                                        {
                                            type: "object",
                                            required: ["toISOString"],
                                        },
                                        {
                                            type: "string",
                                        },
                                        {
                                            type: "null",
                                            nullable: true,
                                        },
                                    ],
                                },
                            },
                        },
                        {
                            type: "null",
                            nullable: true,
                        },
                    ],
                },
                lastPositionState: {
                    oneOf: [
                        {
                            type: "string",
                        },
                        {
                            type: "null",
                            nullable: true,
                        },
                    ],
                },
                lastPositionStateChange: {
                    oneOf: [
                        {
                            type: "string",
                            format: "date-time",
                        },
                        {
                            type: "null",
                            nullable: true,
                        },
                    ],
                },
                tripId: {
                    type: "string",
                },
            },
            required: ["lastPositionLastStop", "atStopStreak", "tripId"],
        },
    },
};
//# sourceMappingURL=VPTripsModel.js.map