Skip to content

Commit

Permalink
feat: update to the osm-api version v11.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianWowra committed Nov 26, 2023
1 parent 3361e10 commit 39200b4
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 110 deletions.
223 changes: 122 additions & 101 deletions insomnia.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/api/box/_boxModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type BoxData = {
currentLocation: BoxLocation;
loc: BoxLoc[];
updatedAt: RFC3339Date;
sensors: Sensor<Measurement | LastMeasurement | Measurement['_id']>[];
sensors: Sensor<Measurement | LastMeasurement | Measurement['_id'] | null>[];
lastMeasurementAt?: RFC3339Date;
};

Expand Down Expand Up @@ -93,7 +93,7 @@ export type TTN = {
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/sensor/sensor.js#L8
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/box/box.js#L1057
*/
export type Sensor<T extends Measurement | LastMeasurement | Measurement['_id'] | undefined> = {
export type Sensor<T extends Measurement | LastMeasurement | Measurement['_id'] | null | undefined> = {
_id: OpenSenseMapID;
title: string;
unit: string;
Expand Down
1 change: 1 addition & 0 deletions src/api/box/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './_boxModels';
export * from './claimBox';
export * from './createTransfer';
export * from './deleteBox';
export * from './getAllTags';
export * from './getBox';
export * from './getBoxLocations';
export * from './getBoxes';
Expand Down
1 change: 0 additions & 1 deletion src/api/box/deleteBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import axios from 'axios';
import { OpenSenseMapID } from '../globalTypes';

/**
* ❗❗ BREAKING CHANGE!
* @see https://docs.opensensemap.org/#api-Boxes-deleteBox
*/
export async function deleteBox(senseBoxId: OpenSenseMapID, password: string, authorization: string): Promise<DeleteBoxResult> {
Expand Down
16 changes: 16 additions & 0 deletions src/api/box/getAllTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import axios from 'axios';

/**
* @see https://docs.opensensemap.org/#api-Boxes-getAllTags
*/
export async function getAllTags(): Promise<GetAllTagsResult> {
return (await axios.get(`https://api.opensensemap.org/tags`)).data;
}

/**
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/11695a33cf0260a62aecbefd76c46735b690be62/packages/api/lib/controllers/boxesController.js#L704C5-L704C5
*/
export type GetAllTagsResult = {
code: 'Ok';
data: string[];
};
5 changes: 5 additions & 0 deletions src/api/box/postNewBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ export async function postNewBox(
}

export type PostNewBoxOptions = {
description?: string;
grouptag?: string;
model?: BoxModel;
sensors?: PostNewBoxSensor[];
sensorTemplates?: SensorTemplates[];
serialPort?: 'Serial1' | 'Serial2';
soilDigitalPort?: 'A' | 'B' | 'C';
soundMeterPort?: 'A' | 'B' | 'C';
windSpeedPort?: 'A' | 'B' | 'C';
mqtt?: MQTT;
ttn?: TTN;
useAuth?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/api/user/_userModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type UserData = {
boxes: OpenSenseMapID[];
sharedBoxes?: OpenSenseMapID[];
emailIsConfirmed: boolean;
integrations?: object;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/api/user/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export async function register(userName: UserName, email: string, password: stri
}

export type RegisterOptions = {
language: Language;
language?: Language;
integrations?: object;
};

/**
Expand Down
8 changes: 3 additions & 5 deletions src/api/user/updateUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type UpdateUserOptions = {
language?: Language;
name?: string;
newPassword?: string;
integrations?: object;
};

export type UpdateUserResult = UpdateUserResultResultUpdated | UpdateUserResultUserNotUpdated;
Expand All @@ -47,12 +48,9 @@ export type UpdateUserResultResultUpdated = {
};

/**
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/models/src/user/user.js#L533
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/11695a33cf0260a62aecbefd76c46735b690be62/packages/api/lib/controllers/usersController.js#L320
*/
export type UpdateUserResultUserNotUpdated = {
code: 'Ok';
message: 'User successfully saved.';
data: {
me: { updated: false };
};
message: 'No changed properties supplied. User remains unchanged.';
};

0 comments on commit 39200b4

Please sign in to comment.