UNPKG

opensensemap-client

Version:

The library allows and improves type-based working with the openSenseMap API

1,124 lines (1,079 loc) 39.8 kB
/* * 📦 opensensemap-client * * 🏷️ Version: 1.8.1 * 📄 License: MIT * 🕒 Build: 2025-07-12T10:21:15.428Z * 🔗 Repository: [object Object] * 👤 Author: Julian Wowra <development@julianwowra.de> */ import * as superstruct from 'superstruct'; import { Infer } from 'superstruct'; /** * @see https://docs.opensensemap.org/#api-Boxes-claimBox */ declare function claimBox(transferToken: string, authorization: string): Promise<{ message: "Device successfully claimed!"; }>; /** * @see https://docs.opensensemap.org/#api-_ */ declare const OPENSENSEMAP_ID: superstruct.Struct<string, null>; type OpenSenseMapID = Infer<typeof OPENSENSEMAP_ID>; /** * @see https://docs.opensensemap.org/#api-_ */ declare const DATE_RFC3339: superstruct.Struct<string, null>; type DateRFC3339 = Infer<typeof DATE_RFC3339>; /** * 4 WGS84 coordinates separated by commas. You can use a tool like {@link http://bboxfinder.com|bboxfinder.com} to mark the box * @example "7.645503,51.962280,7.646168,51.962515" */ declare const COORDINATES_WGS84: superstruct.Struct<string, null>; type CoordinatesWGS84 = Infer<typeof COORDINATES_WGS84>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L31C2-L31C2|OpenSenseMap API code reference on GitHub} * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/measurement/measurement.js#L23|OpenSenseMap API code reference on GitHub} */ declare const COORDINATES: superstruct.Struct<{ lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined], null>; type Coordinates = Infer<typeof COORDINATES>; /** * @see https://docs.opensensemap.org/#api-Boxes-createTransfer */ declare function createTransfer(senseBoxId: OpenSenseMapID, expiresAt: DateRFC3339, authorization: string): Promise<{ message: "Box successfully prepared for transfer"; data: { token: string; boxId: string; _id: string; createdAt: string; updatedAt: string; expiresAt: string; }; }>; /** * @see https://docs.opensensemap.org/#api-Boxes-deleteBox */ declare function deleteBox(senseBoxId: OpenSenseMapID, password: string, authorization: string): Promise<{ message: "box and all associated measurements marked for deletion"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Boxes-getAllTags */ declare function getAllTags(): Promise<{ data: string[]; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Boxes-getBox */ declare function getBox(senseBoxId: OpenSenseMapID): Promise<{ exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; }>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L65|OpenSenseMap API code reference on GitHub} */ declare const EXPOSURE_TYPE: superstruct.Struct<"indoor" | "outdoor" | "mobile" | "unknown", { indoor: "indoor"; outdoor: "outdoor"; mobile: "mobile"; unknown: "unknown"; }>; type ExposureType = Infer<typeof EXPOSURE_TYPE>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/api/lib/controllers/measurementsController.js#L212|OpenSenseMap API code reference on GitHub} * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/api/lib/controllers/statisticsController.js#L232C29-L232C37|OpenSenseMap API code reference on GitHub} */ declare const COLUMNS: superstruct.Struct<"lat" | "height" | "boxId" | "boxName" | "exposure" | "lon" | "phenomenon" | "sensorType" | "unit", { lat: "lat"; height: "height"; boxId: "boxId"; boxName: "boxName"; exposure: "exposure"; lon: "lon"; phenomenon: "phenomenon"; sensorType: "sensorType"; unit: "unit"; }>; type Columns = Infer<typeof COLUMNS>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/861dd9b2e9498b380b52839da84aa9ab27f1fc42/packages/models/src/box/integrations.js#L8|OpenSenseMap API code reference on GitHub} */ declare const MQTT: superstruct.Struct<{ enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; }, { enabled: superstruct.Struct<boolean, null>; url: superstruct.Struct<string, null>; topic: superstruct.Struct<string, null>; messageFormat: superstruct.Struct<"json" | "csv", { json: "json"; csv: "csv"; }>; decodeOptions: superstruct.Struct<string, null>; connectionOptions: superstruct.Struct<string, null>; }>; type MQTT = Infer<typeof MQTT>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/861dd9b2e9498b380b52839da84aa9ab27f1fc42/packages/models/src/box/integrations.js#L23|OpenSenseMap API code reference on GitHub} */ declare const TTN: superstruct.Struct<{ dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; }, { dev_id: superstruct.Struct<string, null>; app_id: superstruct.Struct<string, null>; profile: superstruct.Struct<"json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp", { json: "json"; "lora-serialization": "lora-serialization"; "sensebox/home": "sensebox/home"; debug: "debug"; "cayenne-lpp": "cayenne-lpp"; }>; decodeOptions: superstruct.Struct<unknown[] | undefined, superstruct.Struct<unknown, null>>; port: superstruct.Struct<number, null>; }>; type TTN = Infer<typeof TTN>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/953c476b192bcb051823e67c2a3b3e9891eb7bea/packages/models/src/box/sensorLayouts/index.js#L34|OpenSenseMap API code reference on GitHub} */ declare const BOX_MODEL: superstruct.Struct<"homeV2Lora" | "homeV2Ethernet" | "homeV2EthernetFeinstaub" | "homeV2Wifi" | "homeV2WifiFeinstaub" | "homeEthernet" | "homeWifi" | "homeEthernetFeinstaub" | "homeWifiFeinstaub" | "luftdaten_sds011" | "luftdaten_sds011_dht11" | "luftdaten_sds011_dht22" | "luftdaten_sds011_bmp180" | "luftdaten_sds011_bme280" | "luftdaten_pms1003" | "luftdaten_pms1003_bme280" | "luftdaten_pms3003" | "luftdaten_pms3003_bme280" | "luftdaten_pms5003" | "luftdaten_pms5003_bme280" | "luftdaten_pms7003" | "luftdaten_pms7003_bme280" | "luftdaten_sps30_bme280" | "luftdaten_sps30_sht3x" | "hackair_home_v2", { homeV2Lora: "homeV2Lora"; homeV2Ethernet: "homeV2Ethernet"; homeV2EthernetFeinstaub: "homeV2EthernetFeinstaub"; homeV2Wifi: "homeV2Wifi"; homeV2WifiFeinstaub: "homeV2WifiFeinstaub"; homeEthernet: "homeEthernet"; homeWifi: "homeWifi"; homeEthernetFeinstaub: "homeEthernetFeinstaub"; homeWifiFeinstaub: "homeWifiFeinstaub"; luftdaten_sds011: "luftdaten_sds011"; luftdaten_sds011_dht11: "luftdaten_sds011_dht11"; luftdaten_sds011_dht22: "luftdaten_sds011_dht22"; luftdaten_sds011_bmp180: "luftdaten_sds011_bmp180"; luftdaten_sds011_bme280: "luftdaten_sds011_bme280"; luftdaten_pms1003: "luftdaten_pms1003"; luftdaten_pms1003_bme280: "luftdaten_pms1003_bme280"; luftdaten_pms3003: "luftdaten_pms3003"; luftdaten_pms3003_bme280: "luftdaten_pms3003_bme280"; luftdaten_pms5003: "luftdaten_pms5003"; luftdaten_pms5003_bme280: "luftdaten_pms5003_bme280"; luftdaten_pms7003: "luftdaten_pms7003"; luftdaten_pms7003_bme280: "luftdaten_pms7003_bme280"; luftdaten_sps30_bme280: "luftdaten_sps30_bme280"; luftdaten_sps30_sht3x: "luftdaten_sps30_sht3x"; hackair_home_v2: "hackair_home_v2"; }>; type BoxModel = Infer<typeof BOX_MODEL>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/953c476b192bcb051823e67c2a3b3e9891eb7bea/packages/models/src/box/sensorLayouts/index.js#L66|OpenSenseMap API code reference on GitHub} * @see {@link https://github.com/sensebox/openSenseMap-API/tree/953c476b192bcb051823e67c2a3b3e9891eb7bea/packages/models/src/box/sensorLayouts/sensorDefinitions|OpenSenseMap API code reference on GitHub} */ declare const SENSOR_TEMPLATES: superstruct.Struct<"BME280" | "BME680" | "BMP180" | "BMP280" | "DHT11" | "DHT22" | "DNMS" | "DPS310" | "HDC1008" | "PMS 1003" | "PMS 3003" | "PMS 5003" | "PMS 7003" | "SCD30" | "SDS 011" | "SHT3X" | "SMT50" | "SOUNDLEVELMETER" | "SPS30" | "TSL45315" | "VEML6070" | "WINDSPEED", { BME280: "BME280"; BME680: "BME680"; BMP180: "BMP180"; BMP280: "BMP280"; DHT11: "DHT11"; DHT22: "DHT22"; DNMS: "DNMS"; DPS310: "DPS310"; HDC1008: "HDC1008"; "PMS 1003": "PMS 1003"; "PMS 3003": "PMS 3003"; "PMS 5003": "PMS 5003"; "PMS 7003": "PMS 7003"; SCD30: "SCD30"; "SDS 011": "SDS 011"; SHT3X: "SHT3X"; SMT50: "SMT50"; SOUNDLEVELMETER: "SOUNDLEVELMETER"; SPS30: "SPS30"; TSL45315: "TSL45315"; VEML6070: "VEML6070"; WINDSPEED: "WINDSPEED"; }>; type SensorTemplates = Infer<typeof SENSOR_TEMPLATES>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/sensor/sensor.js#L8|OpenSenseMap API code reference on GitHub} */ declare const SENSOR: superstruct.Struct<{ unit: string; _id: string; title: string; sensorType?: string | undefined; icon?: string | undefined; }, { _id: superstruct.Struct<string, null>; title: superstruct.Struct<string, null>; unit: superstruct.Struct<string, null>; sensorType: superstruct.Struct<string | undefined, null>; icon: superstruct.Struct<string | undefined, null>; }>; type Sensor = Infer<typeof SENSOR>; /** * @see https://docs.opensensemap.org/#api-Boxes-getBoxes */ declare function getBoxes(bbox: CoordinatesWGS84, options?: GetBoxesOptions): Promise<{ exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; }[]>; type GetBoxesOptions = { date?: DateRFC3339 | Date; phenomenon?: string; grouptag?: string | string[]; model?: BoxModel; classify?: boolean; minimal?: boolean; full?: boolean; near?: string; maxDistance?: number; exposure?: string | ExposureType[]; }; /** * @see https://docs.opensensemap.org/#api-Boxes-getBoxLocations */ declare function getBoxLocations(senseBoxId: OpenSenseMapID, options?: GetBoxLocationsOptions): Promise<{ type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }[]>; type GetBoxLocationsOptions = { 'from-date': DateRFC3339 | Date; 'to-date': DateRFC3339 | Date; }; /** * @see https://docs.opensensemap.org/#api-Boxes-getSketch */ declare function getSketch(senseBoxId: OpenSenseMapID, authorization: string, options?: GetSketchOptions): Promise<string>; type GetSketchOptions = { serialPort?: 'Serial1' | 'Serial2'; soilDigitalPort?: 'A' | 'B' | 'C'; soundMeterPort?: 'A' | 'B' | 'C'; windSpeedPort?: 'A' | 'B' | 'C'; ssid?: string; password?: string; devEUI?: string; appEUI?: string; appKey?: string; display_enabled?: boolean; }; /** * @see https://docs.opensensemap.org/#api-Boxes-getTransfer */ declare function getTransfer(senseBoxId: OpenSenseMapID, authorization: string): Promise<{ data: { token: string; boxId: string; _id: string; createdAt: string; updatedAt: string; expiresAt: string; }; }>; /** * @see https://docs.opensensemap.org/#api-Boxes-postNewBox */ declare function postNewBox(name: string, exposure: ExposureType, location: Coordinates, authorization: string, options?: PostNewBoxOptions): Promise<{ message: "Box successfully created"; data: { exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; } & { integrations: { mqtt: { enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; } | { enabled: false; }; ttn?: { dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; } | undefined; }; access_token: string; useAuth?: boolean | undefined; }; }>; type PostNewBoxOptions = { description?: string; grouptag?: string; model?: BoxModel; sensors?: Omit<Sensor, '_id'>[]; sensorTemplates?: SensorTemplates[]; serialPort?: 'Serial1' | 'Serial2'; soilDigitalPort?: 'A' | 'B' | 'C'; soundMeterPort?: 'A' | 'B' | 'C'; windSpeedPort?: 'A' | 'B' | 'C'; mqtt?: MQTT; ttn?: TTN; useAuth?: boolean; sharedBox?: boolean; }; /** * @see https://docs.opensensemap.org/#api-Boxes-removeTransfer */ declare function removeTransfer(senseBoxId: OpenSenseMapID, transferToken: string, authorization: string): Promise<never>; /** * @see https://docs.opensensemap.org/#api-Boxes-updateBox */ declare function updateBox(senseBoxId: OpenSenseMapID, authorization: string, options: UpdateBoxOptions): Promise<{ data: { exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; } & { integrations: { mqtt: { enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; } | { enabled: false; }; ttn?: { dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; } | undefined; }; access_token: string; useAuth?: boolean | undefined; }; code: "Ok"; }>; type UpdateBoxOptions = { name?: string; grouptag?: string[]; location?: Coordinates; sensors?: (UpdateBoxSensorNew | UpdateBoxSensorEdited | UpdateBoxSensorDeleted)[]; mqtt?: MQTT; ttn?: TTN; description?: string; image?: string; addons?: Record<string | number, string | number>; }; /** * @see https://docs.opensensemap.org/#api-Boxes-updateBox * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L855C6-L855C6|OpenSenseMap API code reference on GitHub} */ type UpdateBoxSensorNew = Omit<Sensor, '_id'> & { new: true; }; /** * @see https://docs.opensensemap.org/#api-Boxes-updateBox * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L857C7-L857C7|OpenSenseMap API code reference on GitHub} */ type UpdateBoxSensorEdited = Sensor & { edited: true; }; /** * @see https://docs.opensensemap.org/#api-Boxes-updateBox * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L853|OpenSenseMap API code reference on GitHub} */ type UpdateBoxSensorDeleted = Pick<Sensor, '_id'> & { deleted: true; }; /** * @see https://docs.opensensemap.org/#api-Boxes-updateTransfer */ declare function updateTransfer(senseBoxId: OpenSenseMapID, transferToken: string, expiresAt: DateRFC3339, authorization: string): Promise<{ message: "Transfer successfully updated"; data: { token: string; boxId: string; _id: string; createdAt: string; updatedAt: string; expiresAt: string; }; }>; /** * @see https://docs.opensensemap.org/#api-Interpolation-calculateIdw */ declare function calculateIdw(phenomenon: string, bbox: CoordinatesWGS84, options?: CalculateIdwOptions): Promise<{ message: "no measurements found"; code: "NotFound"; } | { data: { breaks: number[]; featureCollection: { type: "FeatureCollection"; features: { type: string; geometry: { type: string; coordinates: number[][][]; }; properties?: { idwValues: number[]; } | undefined; }; }[]; timesteps: string[]; }; code: "Ok"; }>; type CalculateIdwOptions = { 'from-date'?: DateRFC3339 | Date; 'to-date'?: DateRFC3339 | Date; gridType?: 'hex' | 'square' | 'triangle'; cellWidth?: number; power?: number; numTimeSteps?: number; numClasses?: number; exposure?: string | ExposureType[]; }; /** * @see https://docs.opensensemap.org/#api-Measurements-deleteMeasurements */ declare function deleteMeasurements(senseBoxId: OpenSenseMapID, sensorId: OpenSenseMapID, authorization: string, options?: DeleteMeasurementsOptions): Promise<{ message: string; code: "Ok"; }>; type DeleteMeasurementsOptions = { 'from-date'?: DateRFC3339 | Date; 'to-date'?: DateRFC3339 | Date; timestamps?: Array<DateRFC3339 | Date>; deleteAllMeasurements?: boolean; }; /** * @see https://docs.opensensemap.org/#api-Measurements-getData */ declare function getData(senseBoxId: OpenSenseMapID, sensorId: OpenSenseMapID, options?: GetDataOptions): Promise<{ createdAt: string; location: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; value: string; isOutlier?: boolean | undefined; }[]>; type GetDataOptions = { 'from-date'?: DateRFC3339 | Date; 'to-date'?: DateRFC3339 | Date; outliers?: 'replace' | 'mark'; 'outlier-window'?: number; }; /** * @see https://docs.opensensemap.org/#api-Measurements-getDataByGroupTag */ declare function getDataByGroupTag(grouptag: string | string[]): Promise<{ boxId: string; createdAt: string; value: string; sensorId: string; }[]>; /** * @see https://docs.opensensemap.org/#api-Measurements-getDataMulti */ declare function getDataMulti(phenomenon: string, target: GetDataMultiParamTarget, options?: GetDataMultiOptions): Promise<({ createdAt: string; value: string; } & Record<"lat" | "height" | "boxId" | "boxName" | "exposure" | "lon" | "phenomenon" | "sensorType" | "unit", string | undefined>)[]>; type GetDataMultiParamTarget = { boxId: OpenSenseMapID | OpenSenseMapID[]; } | { bbox: CoordinatesWGS84; }; type GetDataMultiOptions = { 'from-date'?: DateRFC3339 | Date; 'to-date'?: DateRFC3339 | Date; columns?: string | Columns[]; exposure?: string | ExposureType[]; }; /** * @see https://docs.opensensemap.org/#api-Measurements-getLatestMeasurementOfSensor */ declare function getLatestMeasurementOfSensor(senseBoxId: OpenSenseMapID, sensorId: OpenSenseMapID, options?: GetLatestMeasurementOfSensorOptions): Promise<string | ({ unit: string; _id: string; title: string; sensorType?: string | undefined; icon?: string | undefined; } & { lastMeasurement?: { createdAt: string; value: string; } | undefined; }) | undefined>; type GetLatestMeasurementOfSensorOptions = { onlyValue?: boolean; }; type GetLatestMeasurementsOptions = { count: number; }; /** * @see https://docs.opensensemap.org/#api-Measurements-postNewMeasurement */ declare function postNewMeasurement(senseBoxId: OpenSenseMapID, sensorId: OpenSenseMapID, value: string | number, boxAuthorization?: string, options?: PostNewMeasurementOptions): Promise<"Measurement saved in box">; type PostNewMeasurementOptions = { createdAt?: DateRFC3339 | Date; location?: Location; }; /** * @see https://docs.opensensemap.org/#api-Measurements-postNewMeasurements */ declare function postNewMeasurements(senseBoxId: OpenSenseMapID, data: PostNewMeasurementsParamData, boxAuthorization?: string): Promise<"Measurements saved in box">; type PostNewMeasurementsParamData = { sensor: OpenSenseMapID; value: string | number; createdAt?: DateRFC3339 | Date; location?: Location; }[]; /** * @see https://docs.opensensemap.org/#api-Misc-getStatistics */ declare function getStatistics(options?: GetStatisticsOptions): Promise<string[] | number[]>; type GetStatisticsOptions = { human?: boolean; }; /** * @see https://docs.opensensemap.org/#api-Misc-printRoutes */ declare function printRoutes(): Promise<string>; declare const OPERATION: superstruct.Struct<"arithmeticMean" | "geometricMean" | "harmonicMean" | "max" | "median" | "min" | "mode" | "rootMeanSquare" | "standardDeviation" | "sum" | "variance", { arithmeticMean: "arithmeticMean"; geometricMean: "geometricMean"; harmonicMean: "harmonicMean"; max: "max"; median: "median"; min: "min"; mode: "mode"; rootMeanSquare: "rootMeanSquare"; standardDeviation: "standardDeviation"; sum: "sum"; variance: "variance"; }>; type Operation = Infer<typeof OPERATION>; /** * @see https://docs.opensensemap.org/#api-Statistics-descriptive */ declare function descriptive(target: DescriptiveParamTarget, phenomenon: string, fromDate: DateRFC3339 | Date, toDate: DateRFC3339 | Date, operation: Operation, window: string, options?: DescriptiveOptions): Promise<({ sensorId: string; } & Record<"lat" | "height" | "boxId" | "boxName" | "exposure" | "lon" | "phenomenon" | "sensorType" | "unit", string | undefined> & Record<string, number>)[]>; type DescriptiveParamTarget = { boxId: OpenSenseMapID | OpenSenseMapID[]; } | { bbox: CoordinatesWGS84; }; type DescriptiveOptions = { columns?: string | Columns[]; exposure?: string | ExposureType[]; }; /** * @see https://docs.opensensemap.org/#api-Users-confirm_email */ declare function confirmEmail(email: string, confirmationToken: string): Promise<{ message: "E-Mail successfully confirmed. Thank you"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-deleteUser */ declare function deleteUser(password: string, authorization: string): Promise<{ message: "User and all boxes of user marked for deletion. Bye Bye!"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-getUser */ declare function getUser(authorization: string): Promise<{ data: { me: { name: string; email: string; role: "user" | "admin"; language: "de_DE" | "en_US"; boxes: string[]; emailIsConfirmed: boolean; integrations?: Record<string, unknown> | undefined; sharedBoxes?: string[] | undefined; }; }; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-getUserBox */ declare function getUserBox(senseBoxId: OpenSenseMapID, authorization: string): Promise<{ data: { box: { exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; } & { integrations: { mqtt: { enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; } | { enabled: false; }; ttn?: { dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; } | undefined; }; access_token: string; useAuth?: boolean | undefined; }; }; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-getUserBoxes */ declare function getUserBoxes(authorization: string, options?: GetUserBoxesOptions): Promise<{ data: { boxes: ({ exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; } & { integrations: { mqtt: { enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; } | { enabled: false; }; ttn?: { dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; } | undefined; }; access_token: string; useAuth?: boolean | undefined; })[]; sharedBoxes: ({ exposure: "indoor" | "outdoor" | "mobile" | "unknown"; _id: string; name: string; createdAt: string; model: string; currentLocation: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; loc: { type: "Feature"; geometry: { type: "Point"; coordinates: { lat: number; lng: number; height?: number | undefined; } | [number, number, number | undefined]; timestamp: string; }; }[]; updatedAt: string; sensor: unknown[]; descriptiom?: string | undefined; grouptag?: ("indoor" | "outdoor" | "mobile" | "unknown")[] | undefined; weblink?: string | undefined; image?: string | undefined; lastMeasurementAt?: string | undefined; } & { integrations: { mqtt: { enabled: boolean; url: string; topic: string; messageFormat: "json" | "csv"; decodeOptions: string; connectionOptions: string; } | { enabled: false; }; ttn?: { dev_id: string; app_id: string; profile: "json" | "lora-serialization" | "sensebox/home" | "debug" | "cayenne-lpp"; port: number; decodeOptions?: unknown[] | undefined; } | undefined; }; access_token: string; useAuth?: boolean | undefined; })[]; boxes_count: number; }; code: "Ok"; }>; type GetUserBoxesOptions = { page?: number; }; /** * @see https://docs.opensensemap.org/#api-Users-password_reset */ declare function passwordReset(newPassword: string, confirmationToken: string): Promise<{ message: "Password successfully changed. You can now login with your new password"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-refresh_auth */ declare function refreshAuth(refreshToken: string): Promise<{ token: string; message: "Successfully refreshed auth"; data: { user: { name: string; email: string; role: "user" | "admin"; language: "de_DE" | "en_US"; boxes: string[]; emailIsConfirmed: boolean; integrations?: Record<string, unknown> | undefined; sharedBoxes?: string[] | undefined; }; }; code: "Authorized"; refreshToken: string; }>; /** * The user name must consist of at least 3 and up to 40 characters and only allows to use alphanumerics (a-zA-Z0-9), dots (.), dashes (-), underscores (_) and spaces. The first character must be a letter or number. * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/user/user.js#L30|OpenSenseMap API code reference on GitHub} */ declare const USER_NAME: superstruct.Struct<string, null>; type UserName = Infer<typeof USER_NAME>; /** * @see {@link https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/user/user.js#L68|OpenSenseMap API code reference on GitHub} */ declare const LANGUAGE: superstruct.Struct<"de_DE" | "en_US", { de_DE: "de_DE"; en_US: "en_US"; }>; type Language = Infer<typeof LANGUAGE>; /** * @see https://docs.opensensemap.org/#api-Users-register */ declare function register(userName: UserName, email: string, password: string, options?: RegisterOptions): Promise<{ token: string; message: "Successfully registered new user"; data: { user: { name: string; email: string; role: "user" | "admin"; language: "de_DE" | "en_US"; boxes: string[]; emailIsConfirmed: boolean; integrations?: Record<string, unknown> | undefined; sharedBoxes?: string[] | undefined; }; }; code: "Created"; refreshToken: string; }>; type RegisterOptions = { language?: Language; integrations?: object; }; /** * @see https://docs.opensensemap.org/#api-Users-request_password_reset */ declare function requestPasswordReset(email: string): Promise<{ message: "Password reset initiated"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-resend_email_confirmation */ declare function resendEmailConfirmation(authorization: string): Promise<{ message: string; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-sign_in */ declare function signIn(email: string, password: string): Promise<{ token: string; message: "Successfully signed in"; data: { user: { name: string; email: string; role: "user" | "admin"; language: "de_DE" | "en_US"; boxes: string[]; emailIsConfirmed: boolean; integrations?: Record<string, unknown> | undefined; sharedBoxes?: string[] | undefined; }; }; code: "Authorized"; refreshToken: string; }>; /** * @see https://docs.opensensemap.org/#api-Users-sign_out */ declare function signOut(authorization: string): Promise<{ message: "Successfully signed out"; code: "Ok"; }>; /** * @see https://docs.opensensemap.org/#api-Users-updateUser */ declare function updateUser(currentPassword: string, authorization: string, options: UpdateUserOptions): Promise<{ message: "User successfully saved." | "User successfully saved. E-Mail changed. Please confirm your new address. Until confirmation, sign in using your old address" | "User successfully saved. Password changed. Please sign in with your new password"; data: { me: { name: string; email: string; role: "user" | "admin"; language: "de_DE" | "en_US"; boxes: string[]; emailIsConfirmed: boolean; integrations?: Record<string, unknown> | undefined; sharedBoxes?: string[] | undefined; }; }; code: "Ok"; } | { message: "User not updated. No changed properties supplied."; code: "Ok"; }>; type UpdateUserOptions = { email?: string; language?: Language; name?: string; newPassword?: string; integrations?: object; }; export { type BoxModel, type CalculateIdwOptions, type Columns, type Coordinates, type CoordinatesWGS84, type DateRFC3339, type DeleteMeasurementsOptions, type DescriptiveOptions, type DescriptiveParamTarget, type ExposureType, type GetBoxLocationsOptions, type GetBoxesOptions, type GetDataMultiOptions, type GetDataMultiParamTarget, type GetDataOptions, type GetLatestMeasurementOfSensorOptions, type GetLatestMeasurementsOptions, type GetSketchOptions, type GetStatisticsOptions, type GetUserBoxesOptions, type Language, type OpenSenseMapID, type PostNewBoxOptions, type PostNewMeasurementOptions, type PostNewMeasurementsParamData, type RegisterOptions, type Sensor, type SensorTemplates, type UpdateBoxOptions, type UpdateBoxSensorDeleted, type UpdateBoxSensorEdited, type UpdateBoxSensorNew, type UpdateUserOptions, calculateIdw, claimBox, confirmEmail, createTransfer, deleteBox, deleteMeasurements, deleteUser, descriptive, getAllTags, getBox, getBoxLocations, getBoxes, getData, getDataByGroupTag, getDataMulti, getLatestMeasurementOfSensor, getSketch, getStatistics, getTransfer, getUser, getUserBox, getUserBoxes, passwordReset, postNewBox, postNewMeasurement, postNewMeasurements, printRoutes, refreshAuth, register, removeTransfer, requestPasswordReset, resendEmailConfirmation, signIn, signOut, updateBox, updateTransfer, updateUser };