The ApiAdapter interface defines the contract for all data access operations in the CDT platform. It serves as a port in the hexagonal architecture, allowing the core application logic to remain decoupled from specific data fetching implementations (REST, GraphQL, mock data, etc.). This interface covers buildings, files, sites, users, organizations, comments, sensors, and infrastructure domains.
Methods by Domain
| Domain | Methods |
|---|
| Buildings | getBuildings, getBuilding, getBuildingsByOsm, getBuildingsByFeatureId, getBuildingOsmIds, updateBuilding, createBuilding |
| Files | listFiles, listFile, updateFile, listFilesByBuilding, listFilesBySite, uploadFileToBuilding, uploadFileToSite, uploadFileToUser, deleteFile |
| Open Data Portals | listOpenDataPortals, getOpenDataPortal, listOpenDataPortalsByMunicipality, listOpenDataPortalsByMunicipalityAndCountrySubdivision, listOpenDataPortalsByCountrySubdivision, listOpenDataPortalsByGroup, listOpenDataPortalsByName |
| Sites | listSites, getSite, updateSite, createSite, deleteSite |
| Users | getUsers, getUser, updateUser, deleteUser, verifyUserPassword, changeUserPassword, createUser, getUserRole, updateUserRole |
| Organizations | getOrganization, updateOrganization, getOrganizationByName, getOrganizationRoles |
| Comments | getComments, getCommentsByBuilding, getComment, updateComment, deleteComment, createComment, getCommentsByAuthor |
| Sensors | getSensors, getSensorsByBuilding, getSensor, updateSensor, deleteSensor, createSensor, getSensorsByAuthor |
| Sensor Types | getSensorTypes, getSensorType, updateSensorType, deleteSensorType, createSensorType |
| Infrastructure | listInfrastructure, getInfrastructure, updateInfrastructure, createInfrastructure, deleteInfrastructure |
Buildings
Methods for managing building entities, including lookups by OSM ID and feature ID.
getBuildings
getBuildings(): Promise<Building[]>
Returns all buildings in the system.
getBuilding
getBuilding(id: number): Promise<Building | null>
| Param | Type | Required | Description |
|---|
id | number | Yes | Building primary key |
getBuildingsByOsm
getBuildingsByOsm(osmId: number): Promise<Building[]>
| Param | Type | Required | Description |
|---|
osmId | number | Yes | OpenStreetMap identifier |
getBuildingsByFeatureId
getBuildingsByFeatureId(featureId: string): Promise<Building[]>
| Param | Type | Required | Description |
|---|
featureId | string | Yes | GeoJSON feature identifier |
getBuildingOsmIds
getBuildingOsmIds(): Promise<number[]>
Returns all OSM IDs for buildings in the system.
updateBuilding
updateBuilding(id: number, patch: Partial<Building>): Promise<Building>
| Param | Type | Required | Description |
|---|
id | number | Yes | Building primary key |
patch | Partial<Building> | Yes | Fields to update |
createBuilding
createBuilding(input: { buildingData: Partial<Building>; organizationId: string }): Promise<Building>
| Param | Type | Required | Description |
|---|
input.buildingData | Partial<Building> | Yes | Building properties |
input.organizationId | string | Yes | Owning organization ID |
Files
Methods for file management with MinIO storage, supporting attachments to buildings, sites, and users.
listFiles
listFiles(): Promise<DbFile[]>
listFile
listFile(id: number): Promise<DbFile>
| Param | Type | Required | Description |
|---|
id | number | Yes | File primary key |
listFilesByBuilding
listFilesByBuilding(buildingId: number, opts?: { tag?: string }): Promise<DbFile[]>
| Param | Type | Required | Description |
|---|
buildingId | number | Yes | Building primary key |
opts.tag | string | No | Filter by file tag |
listFilesBySite
listFilesBySite(siteId: number, opts?: { tag?: string }): Promise<DbFile[]>
| Param | Type | Required | Description |
|---|
siteId | number | Yes | Site primary key |
opts.tag | string | No | Filter by file tag |
uploadFileToBuilding
uploadFileToBuilding(buildingId: number, input: Partial<DbFile>): Promise<DbFile>
| Param | Type | Required | Description |
|---|
buildingId | number | Yes | Target building ID |
input | Partial<DbFile> | Yes | File metadata |
uploadFileToSite
uploadFileToSite(siteId: number, input: Partial<DbFile>): Promise<DbFile>
| Param | Type | Required | Description |
|---|
siteId | number | Yes | Target site ID |
input | Partial<DbFile> | Yes | File metadata |
uploadFileToUser
uploadFileToUser(userId: number, input: Partial<DbFile>): Promise<DbFile>
| Param | Type | Required | Description |
|---|
userId | number | Yes | Target user ID |
input | Partial<DbFile> | Yes | File metadata |
updateFile
updateFile(id: number, patch: Partial<DbFile>): Promise<DbFile>
deleteFile
deleteFile(fileId: number): Promise<DbFile>
Sites
Methods for managing site entities, which can contain multiple buildings.
listSites
listSites(): Promise<Site[]>
getSite
getSite(id: string): Promise<Site | null>
| Param | Type | Required | Description |
|---|
id | string | Yes | Site primary key |
createSite
createSite(input: Partial<Site>): Promise<Site>
updateSite
updateSite(id: string, patch: Partial<Site> & {
siteBuildings?: {
connect?: { id: number }[];
disconnect?: { id: number }[];
};
}): Promise<Site>
| Param | Type | Required | Description |
|---|
id | string | Yes | Site primary key |
patch | Partial<Site> | Yes | Fields to update |
patch.siteBuildings.connect | { id: number }[] | No | Buildings to associate |
patch.siteBuildings.disconnect | { id: number }[] | No | Buildings to disassociate |
deleteSite
deleteSite(id: string | number): Promise<Site>
Users
Methods for user management including authentication and role assignment.
getUsers
getUsers(): Promise<User[]>
getUser
getUser(id: string): Promise<User | null>
createUser
createUser(input: { userData: Partial<User> }): Promise<User>
updateUser
updateUser(id: string, patch: Partial<User>): Promise<User>
deleteUser
deleteUser(id: string): Promise<User>
verifyUserPassword
verifyUserPassword(id: string, password: string): Promise<boolean>
| Param | Type | Required | Description |
|---|
id | string | Yes | User primary key |
password | string | Yes | Password to verify |
changeUserPassword
changeUserPassword(id: string, oldPassword: string, newPassword: string): Promise<User>
| Param | Type | Required | Description |
|---|
id | string | Yes | User primary key |
oldPassword | string | Yes | Current password |
newPassword | string | Yes | New password |
getUserRole
getUserRole(id: string): Promise<Role>
updateUserRole
updateUserRole(userId: string, roleId: number): Promise<User>
Organizations
Methods for organization management and role retrieval.
getOrganization
getOrganization(id: string): Promise<Organization | null>
getOrganizationByName
getOrganizationByName(name: string): Promise<Organization | null>
updateOrganization
updateOrganization(id: string, patch: Partial<Organization>): Promise<Organization>
getOrganizationRoles
getOrganizationRoles(orgId: string): Promise<Role[]>
Open Data Portals
Methods for querying external open data portal references by geographic and categorical filters.
listOpenDataPortals
listOpenDataPortals(): Promise<OpenDataPortal[]>
getOpenDataPortal
getOpenDataPortal(id: number): Promise<OpenDataPortal | null>
listOpenDataPortalsByMunicipality
listOpenDataPortalsByMunicipality(municipality: string): Promise<OpenDataPortal[]>
listOpenDataPortalsByCountrySubdivision
listOpenDataPortalsByCountrySubdivision(countrySubdivision: string): Promise<OpenDataPortal[]>
listOpenDataPortalsByMunicipalityAndCountrySubdivision
listOpenDataPortalsByMunicipalityAndCountrySubdivision(
municipality: string,
countrySubdivision: string
): Promise<OpenDataPortal[]>
listOpenDataPortalsByGroup
listOpenDataPortalsByGroup(group: DatasetGroup): Promise<OpenDataPortal[]>
listOpenDataPortalsByName
listOpenDataPortalsByName(name: string): Promise<OpenDataPortal[]>
Methods for managing comments attached to buildings.
getComments(): Promise<Comment[]>
getComment(id: number): Promise<Comment>
getCommentsByBuilding(buildingId: number): Promise<Comment[]>
getCommentsByAuthor(authorId: number): Promise<Comment[]>
createComment(input: { commentData: Partial<Comment> }): Promise<Comment>
updateComment(id: number, patch: Partial<Comment>): Promise<Comment>
deleteComment(id: number): Promise<Comment>
Sensors
Methods for managing sensor entities and their types.
getSensors
getSensors(): Promise<Sensor[]>
getSensor
getSensor(id: number): Promise<Sensor>
getSensorsByBuilding
getSensorsByBuilding(buildingId: number): Promise<Sensor[]>
getSensorsByAuthor
getSensorsByAuthor(authorId: number): Promise<Sensor[]>
createSensor
createSensor(input: { sensorData: Partial<Sensor> }): Promise<Sensor>
updateSensor
updateSensor(id: number, patch: Partial<Sensor>): Promise<Sensor>
deleteSensor
deleteSensor(id: number): Promise<Sensor>
Sensor Types
getSensorTypes
getSensorTypes(): Promise<SensorType[]>
getSensorType
getSensorType(id: number): Promise<SensorType>
createSensorType
createSensorType(input: { sensorTypeData: Partial<SensorType> }): Promise<SensorType>
updateSensorType
updateSensorType(id: number, sensorTypeData: Partial<SensorType>): Promise<SensorType>
deleteSensorType
deleteSensorType(id: number): Promise<SensorType>
Infrastructure
Methods for managing infrastructure entities.
listInfrastructure
listInfrastructure(): Promise<Infrastructure[]>
getInfrastructure
getInfrastructure(id: number): Promise<Infrastructure | null>
createInfrastructure
createInfrastructure(input: Partial<Infrastructure>): Promise<Infrastructure>
updateInfrastructure
updateInfrastructure(id: number, patch: Partial<Infrastructure>): Promise<Infrastructure>
deleteInfrastructure
deleteInfrastructure(id: number): Promise<Infrastructure>