@tmlmobilidade/interfaces
Version:
This package provides SDK-style connectors for interacting with databases (e.g., stops, plans, rides, alerts) and external providers (e.g., authentication, storage). It simplifies data access and integration across projects.
290 lines (289 loc) • 12.4 kB
TypeScript
import { MongoCollectionClass } from '../../common/mongo-collection.js';
import { type CreateStopDto, type Stop, type UpdateStopDto } from '@tmlmobilidade/types';
import { type DeleteResult, type IndexDescription, type Sort } from 'mongodb';
import { z } from 'zod';
declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, UpdateStopDto> {
private static _instance;
protected createSchema: z.ZodSchema;
protected updateSchema: z.ZodSchema;
private constructor();
static getInstance(): Promise<StopsClass>;
/**
* Override deleteById to prevent actual deletion of stop documents.
* Stops cannot be deleted, only archived.
* @param filter The filter used to select the document to "delete".
* @returns A promise that rejects with an error indicating deletion is not allowed.
*/
deleteById(): Promise<DeleteResult>;
/**
* Override deleteOne to prevent actual deletion of stop documents.
* Stops cannot be deleted, only archived.
* @param filter The filter used to select the document to "delete".
* @returns A promise that rejects with an error indicating deletion is not allowed.
*/
deleteOne(): Promise<DeleteResult>;
/**
* Override deleteMany to prevent actual deletion of stop documents.
* Stops cannot be deleted, only archived.
* @param filter The filter used to select the documents to "delete".
* @returns A promise that rejects with an error indicating deletion is not allowed.
*/
deleteMany(): Promise<DeleteResult>;
/**
* Finds stop documents by municipality ID with optional pagination and sorting.
* @param id The municipality ID to search for
* @param perPage Optional number of documents per page for pagination
* @param page Optional page number for pagination
* @param sort Optional sort specification
* @returns A promise that resolves to an array of matching stop documents
*/
findByMunicipalityId(id: string, perPage?: number, page?: number, sort?: Sort): Promise<import("mongodb").WithId<{
_id: number;
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
is_locked: boolean;
updated_at: number & {
__brand: "UnixTimestamp";
};
name: string;
short_name: string;
associated_patterns: {
_id: string;
code: string;
headsign: string;
line_id: string;
route_id: string;
}[];
comments: ({
message: string;
type: "note";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
_id?: string | undefined;
updated_by?: string | undefined;
} | {
type: "field_changed";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
field: string;
_id?: string | undefined;
updated_by?: string | undefined;
curr_value?: any;
prev_value?: any;
metadata?: {
changes?: {
field: string;
curr_value?: any;
prev_value?: any;
}[] | undefined;
} | null | undefined;
} | {
type: "crud";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
action: "create" | "update" | "delete" | "archive" | "restore";
_id?: string | undefined;
updated_by?: string | undefined;
})[];
flags: {
short_name: string;
agency_ids: string[];
is_harmonized: boolean;
stop_id: string;
}[];
jurisdiction: "unknown" | "ip" | "municipality" | "other";
legacy_id: string | null;
legacy_ids: string[];
lifecycle_status: "draft" | "active" | "inactive" | "provisional" | "seasonal" | "voided";
new_name: string | null;
previous_go_id: string | null;
tts_name: string;
district_id: string;
latitude: number;
locality_id: string | null;
longitude: number;
municipality_id: string;
parish_id: string | null;
bench_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
electricity_status: "unknown" | "available" | "unavailable";
pole_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
road_type: "unknown" | "complementary_itinerary" | "highway" | "main_itinerary" | "national_road" | "regional_road" | "secondary_road";
shelter_code: string | null;
shelter_frame_size: [number, number] | null;
shelter_installation_date: import("@tmlmobilidade/types").UnixTimestamp | null;
shelter_maintainer: string | null;
shelter_make: string | null;
shelter_model: string | null;
shelter_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
last_infrastructure_check: import("@tmlmobilidade/types").UnixTimestamp | null;
last_infrastructure_maintenance: import("@tmlmobilidade/types").UnixTimestamp | null;
last_schedules_check: import("@tmlmobilidade/types").UnixTimestamp | null;
last_schedules_maintenance: import("@tmlmobilidade/types").UnixTimestamp | null;
connections: ("ferry" | "light_rail" | "subway" | "train" | "boat" | "airport" | "bike_sharing" | "bike_parking" | "car_parking")[];
facilities: ("fire_station" | "health_clinic" | "historic_building" | "hospital" | "police_station" | "school" | "shopping" | "transit_office" | "university" | "beach")[];
equipment: ("pip" | "mupi" | "mini_pip")[];
has_bench: "unknown" | "available" | "unavailable";
has_mupi: "unknown" | "available" | "unavailable";
has_network_map: "unknown" | "available" | "unavailable";
has_schedules: "unknown" | "available" | "unavailable";
has_shelter: "unknown" | "available" | "unavailable";
has_stop_sign: "unknown" | "available" | "unavailable";
observations: string | null;
is_deleted: boolean;
tts_hash: string;
file_ids: string[];
image_ids: string[];
updated_by?: string | undefined;
}>[]>;
/**
* Finds multiple stop documents by their IDs.
* @param ids Array of stop IDs to search for
* @returns A promise that resolves to an array of matching stop documents
*/
findManyByIds(ids: number[]): Promise<import("mongodb").WithId<{
_id: number;
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
is_locked: boolean;
updated_at: number & {
__brand: "UnixTimestamp";
};
name: string;
short_name: string;
associated_patterns: {
_id: string;
code: string;
headsign: string;
line_id: string;
route_id: string;
}[];
comments: ({
message: string;
type: "note";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
_id?: string | undefined;
updated_by?: string | undefined;
} | {
type: "field_changed";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
field: string;
_id?: string | undefined;
updated_by?: string | undefined;
curr_value?: any;
prev_value?: any;
metadata?: {
changes?: {
field: string;
curr_value?: any;
prev_value?: any;
}[] | undefined;
} | null | undefined;
} | {
type: "crud";
created_at: number & {
__brand: "UnixTimestamp";
};
created_by: string | null;
updated_at: number & {
__brand: "UnixTimestamp";
};
action: "create" | "update" | "delete" | "archive" | "restore";
_id?: string | undefined;
updated_by?: string | undefined;
})[];
flags: {
short_name: string;
agency_ids: string[];
is_harmonized: boolean;
stop_id: string;
}[];
jurisdiction: "unknown" | "ip" | "municipality" | "other";
legacy_id: string | null;
legacy_ids: string[];
lifecycle_status: "draft" | "active" | "inactive" | "provisional" | "seasonal" | "voided";
new_name: string | null;
previous_go_id: string | null;
tts_name: string;
district_id: string;
latitude: number;
locality_id: string | null;
longitude: number;
municipality_id: string;
parish_id: string | null;
bench_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
electricity_status: "unknown" | "available" | "unavailable";
pole_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
road_type: "unknown" | "complementary_itinerary" | "highway" | "main_itinerary" | "national_road" | "regional_road" | "secondary_road";
shelter_code: string | null;
shelter_frame_size: [number, number] | null;
shelter_installation_date: import("@tmlmobilidade/types").UnixTimestamp | null;
shelter_maintainer: string | null;
shelter_make: string | null;
shelter_model: string | null;
shelter_status: "unknown" | "not_applicable" | "missing" | "damaged" | "ok";
last_infrastructure_check: import("@tmlmobilidade/types").UnixTimestamp | null;
last_infrastructure_maintenance: import("@tmlmobilidade/types").UnixTimestamp | null;
last_schedules_check: import("@tmlmobilidade/types").UnixTimestamp | null;
last_schedules_maintenance: import("@tmlmobilidade/types").UnixTimestamp | null;
connections: ("ferry" | "light_rail" | "subway" | "train" | "boat" | "airport" | "bike_sharing" | "bike_parking" | "car_parking")[];
facilities: ("fire_station" | "health_clinic" | "historic_building" | "hospital" | "police_station" | "school" | "shopping" | "transit_office" | "university" | "beach")[];
equipment: ("pip" | "mupi" | "mini_pip")[];
has_bench: "unknown" | "available" | "unavailable";
has_mupi: "unknown" | "available" | "unavailable";
has_network_map: "unknown" | "available" | "unavailable";
has_schedules: "unknown" | "available" | "unavailable";
has_shelter: "unknown" | "available" | "unavailable";
has_stop_sign: "unknown" | "available" | "unavailable";
observations: string | null;
is_deleted: boolean;
tts_hash: string;
file_ids: string[];
image_ids: string[];
updated_by?: string | undefined;
}>[]>;
/**
* Toogle the delete status of a document by its ID.
* Stop documents are never truly deleted to preserve
* data integrity and prevent ID reuse.
* @param id The ID of the stop document to delete.
* @param forceValue Optional boolean to explicitly set the deleted status.
* @returns A promise that resolves to the result of the delete operation.
*/
toggleDeleteById(id: number, forceValue?: boolean): Promise<void>;
protected getCollectionIndexes(): IndexDescription[];
protected getCollectionName(): string;
protected getEnvName(): string;
}
export declare const stops: StopsClass;
export {};