UNPKG

@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.

404 lines (403 loc) • 15.2 kB
import { MongoCollectionClass } from '../../common/mongo-collection.js'; import { type CreateRoleDto, type Role, type UpdateRoleDto } from '@tmlmobilidade/types'; import { type Filter, type FindOptions, type IndexDescription } from 'mongodb'; import { z } from 'zod'; declare class RolesClass extends MongoCollectionClass<Role, CreateRoleDto, UpdateRoleDto> { private static _instance; protected createSchema: z.ZodSchema; protected updateSchema: z.ZodSchema; private constructor(); static getInstance(): Promise<RolesClass>; /** * Finds a user document by its ID. * @param id The ID of the user document to find * @param includePasswordHash Whether to include the password hash in the result * @returns A promise that resolves to the matching user document or null if not found */ findById(id: string, options?: FindOptions): Promise<{ permissions: ({ scope: "agencies"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "alerts"; action: "create" | "delete" | "read" | "lock" | "update" | "update_texts" | "update_dates" | "update_publish_status"; resources: { agency_ids: string[]; reference_types: string[]; }; } | { scope: "rides"; action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update" | "acceptance_comment_activity"; resources: { agency_ids: string[]; }; } | { scope: "sams"; action: "read" | "export"; } | { scope: "gtfs_validations"; action: "create" | "read" | "lock" | "request_approval" | "update_processing_status"; resources: { agency_ids: string[]; }; } | { scope: "home"; action: "read_links" | "read_wiki"; } | { scope: "organizations"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "performance"; action: "read"; } | { scope: "plans"; action: "create" | "delete" | "read" | "lock" | "update" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy" | "read_apex_file" | "update_apex_file" | "delete_apex_file"; resources: { agency_ids: string[]; }; } | { scope: "roles"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "stops"; action: "create" | "delete" | "read" | "lock" | "update" | "export" | "edit_coordinates" | "edit_name"; resources: { municipality_ids: string[]; agency_ids: string[]; }; } | { scope: "users"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "vehicles"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "fares"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "annotations"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "year_periods"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "holidays"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "events"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "zones"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "typologies"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "lines"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; })[]; created_at: number & { __brand: "UnixTimestamp"; }; created_by: string | null; updated_at: number & { __brand: "UnixTimestamp"; }; updated_by?: string | undefined; is_locked: boolean; name: string; _id: string; }>; /** * Finds multiple documents matching the filter criteria * with optional pagination and sorting. * @param filter (Optional) filter criteria to match documents. * @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 documents. */ findMany(filter?: Filter<Role>, options?: FindOptions): Promise<{ permissions: ({ scope: "agencies"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "alerts"; action: "create" | "delete" | "read" | "lock" | "update" | "update_texts" | "update_dates" | "update_publish_status"; resources: { agency_ids: string[]; reference_types: string[]; }; } | { scope: "rides"; action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update" | "acceptance_comment_activity"; resources: { agency_ids: string[]; }; } | { scope: "sams"; action: "read" | "export"; } | { scope: "gtfs_validations"; action: "create" | "read" | "lock" | "request_approval" | "update_processing_status"; resources: { agency_ids: string[]; }; } | { scope: "home"; action: "read_links" | "read_wiki"; } | { scope: "organizations"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "performance"; action: "read"; } | { scope: "plans"; action: "create" | "delete" | "read" | "lock" | "update" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy" | "read_apex_file" | "update_apex_file" | "delete_apex_file"; resources: { agency_ids: string[]; }; } | { scope: "roles"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "stops"; action: "create" | "delete" | "read" | "lock" | "update" | "export" | "edit_coordinates" | "edit_name"; resources: { municipality_ids: string[]; agency_ids: string[]; }; } | { scope: "users"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "vehicles"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "fares"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "annotations"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "year_periods"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "holidays"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "events"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "zones"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "typologies"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "lines"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; })[]; created_at: number & { __brand: "UnixTimestamp"; }; created_by: string | null; updated_at: number & { __brand: "UnixTimestamp"; }; updated_by?: string | undefined; is_locked: boolean; name: string; _id: string; }[]>; /** * Finds a single document matching the filter criteria. * @param filter Filter criteria to match the document. * @returns A promise that resolves to the matching document or null if not found. */ findOne(filter: Filter<Role>): Promise<{ permissions: ({ scope: "agencies"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "alerts"; action: "create" | "delete" | "read" | "lock" | "update" | "update_texts" | "update_dates" | "update_publish_status"; resources: { agency_ids: string[]; reference_types: string[]; }; } | { scope: "rides"; action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update" | "acceptance_comment_activity"; resources: { agency_ids: string[]; }; } | { scope: "sams"; action: "read" | "export"; } | { scope: "gtfs_validations"; action: "create" | "read" | "lock" | "request_approval" | "update_processing_status"; resources: { agency_ids: string[]; }; } | { scope: "home"; action: "read_links" | "read_wiki"; } | { scope: "organizations"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "performance"; action: "read"; } | { scope: "plans"; action: "create" | "delete" | "read" | "lock" | "update" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy" | "read_apex_file" | "update_apex_file" | "delete_apex_file"; resources: { agency_ids: string[]; }; } | { scope: "roles"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "stops"; action: "create" | "delete" | "read" | "lock" | "update" | "export" | "edit_coordinates" | "edit_name"; resources: { municipality_ids: string[]; agency_ids: string[]; }; } | { scope: "users"; action: "create" | "delete" | "read" | "lock" | "update"; } | { scope: "vehicles"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "fares"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "annotations"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "year_periods"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "holidays"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "events"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; } | { scope: "zones"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "typologies"; action: "create" | "delete" | "lock" | "update" | "nav"; resources: { agency_ids: string[]; }; } | { scope: "lines"; action: "create" | "delete" | "read" | "lock" | "update"; resources: { agency_ids: string[]; }; })[]; created_at: number & { __brand: "UnixTimestamp"; }; created_by: string | null; updated_at: number & { __brand: "UnixTimestamp"; }; updated_by?: string | undefined; is_locked: boolean; name: string; _id: string; }>; protected getCollectionIndexes(): IndexDescription[]; protected getCollectionName(): string; protected getEnvName(): string; } /** * @deprecated This class is deprecated and will be removed in the future. * Use `@tmlmobilidade/go-interfaces-go-db` instead. */ export declare const roles: RolesClass; export {};