Skip to main content

ApiAdapter Interface

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

DomainMethods
BuildingsgetBuildings, getBuilding, getBuildingsByOsm, getBuildingsByFeatureId, getBuildingOsmIds, updateBuilding, createBuilding
FileslistFiles, listFile, updateFile, listFilesByBuilding, listFilesBySite, uploadFileToBuilding, uploadFileToSite, uploadFileToUser, deleteFile
Open Data PortalslistOpenDataPortals, getOpenDataPortal, listOpenDataPortalsByMunicipality, listOpenDataPortalsByMunicipalityAndCountrySubdivision, listOpenDataPortalsByCountrySubdivision, listOpenDataPortalsByGroup, listOpenDataPortalsByName
SiteslistSites, getSite, updateSite, createSite, deleteSite
UsersgetUsers, getUser, updateUser, deleteUser, verifyUserPassword, changeUserPassword, createUser, getUserRole, updateUserRole
OrganizationsgetOrganization, updateOrganization, getOrganizationByName, getOrganizationRoles
CommentsgetComments, getCommentsByBuilding, getComment, updateComment, deleteComment, createComment, getCommentsByAuthor
SensorsgetSensors, getSensorsByBuilding, getSensor, updateSensor, deleteSensor, createSensor, getSensorsByAuthor
Sensor TypesgetSensorTypes, getSensorType, updateSensorType, deleteSensorType, createSensorType
InfrastructurelistInfrastructure, 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>
ParamTypeRequiredDescription
idnumberYesBuilding primary key

getBuildingsByOsm

getBuildingsByOsm(osmId: number): Promise<Building[]>
ParamTypeRequiredDescription
osmIdnumberYesOpenStreetMap identifier

getBuildingsByFeatureId

getBuildingsByFeatureId(featureId: string): Promise<Building[]>
ParamTypeRequiredDescription
featureIdstringYesGeoJSON feature identifier

getBuildingOsmIds

getBuildingOsmIds(): Promise<number[]>

Returns all OSM IDs for buildings in the system.

updateBuilding

updateBuilding(id: number, patch: Partial<Building>): Promise<Building>
ParamTypeRequiredDescription
idnumberYesBuilding primary key
patchPartial<Building>YesFields to update

createBuilding

createBuilding(input: { buildingData: Partial<Building>; organizationId: string }): Promise<Building>
ParamTypeRequiredDescription
input.buildingDataPartial<Building>YesBuilding properties
input.organizationIdstringYesOwning 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>
ParamTypeRequiredDescription
idnumberYesFile primary key

listFilesByBuilding

listFilesByBuilding(buildingId: number, opts?: { tag?: string }): Promise<DbFile[]>
ParamTypeRequiredDescription
buildingIdnumberYesBuilding primary key
opts.tagstringNoFilter by file tag

listFilesBySite

listFilesBySite(siteId: number, opts?: { tag?: string }): Promise<DbFile[]>
ParamTypeRequiredDescription
siteIdnumberYesSite primary key
opts.tagstringNoFilter by file tag

uploadFileToBuilding

uploadFileToBuilding(buildingId: number, input: Partial<DbFile>): Promise<DbFile>
ParamTypeRequiredDescription
buildingIdnumberYesTarget building ID
inputPartial<DbFile>YesFile metadata

uploadFileToSite

uploadFileToSite(siteId: number, input: Partial<DbFile>): Promise<DbFile>
ParamTypeRequiredDescription
siteIdnumberYesTarget site ID
inputPartial<DbFile>YesFile metadata

uploadFileToUser

uploadFileToUser(userId: number, input: Partial<DbFile>): Promise<DbFile>
ParamTypeRequiredDescription
userIdnumberYesTarget user ID
inputPartial<DbFile>YesFile 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>
ParamTypeRequiredDescription
idstringYesSite 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>
ParamTypeRequiredDescription
idstringYesSite primary key
patchPartial<Site>YesFields to update
patch.siteBuildings.connect{ id: number }[]NoBuildings to associate
patch.siteBuildings.disconnect{ id: number }[]NoBuildings 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>
ParamTypeRequiredDescription
idstringYesUser primary key
passwordstringYesPassword to verify

changeUserPassword

changeUserPassword(id: string, oldPassword: string, newPassword: string): Promise<User>
ParamTypeRequiredDescription
idstringYesUser primary key
oldPasswordstringYesCurrent password
newPasswordstringYesNew 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[]>

Comments

Methods for managing comments attached to buildings.

getComments

getComments(): Promise<Comment[]>

getComment

getComment(id: number): Promise<Comment>

getCommentsByBuilding

getCommentsByBuilding(buildingId: number): Promise<Comment[]>

getCommentsByAuthor

getCommentsByAuthor(authorId: number): Promise<Comment[]>

createComment

createComment(input: { commentData: Partial<Comment> }): Promise<Comment>

updateComment

updateComment(id: number, patch: Partial<Comment>): Promise<Comment>

deleteComment

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>