-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from kuzzleio/2-dev
- Loading branch information
Showing
40 changed files
with
1,366 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
features/fixtures/application/decoders/DummyAccelerometer3d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { JSONObject } from 'kuzzle'; | ||
|
||
import { | ||
DecodedPayload, Decoder | ||
} from '../../../../index'; | ||
import { Acceleration3dMeasurement } from '../measures/Acceleration3dMeasure'; | ||
|
||
export class DummyAccelerometer3dDecoder extends Decoder { | ||
public measures = [ | ||
{ name: 'acceleration3d', type: 'acceleration3d' }, | ||
] as const; | ||
|
||
constructor () { | ||
super(); | ||
|
||
this.payloadsMappings = { | ||
deviceEUI: { type: 'keyword' } | ||
}; | ||
} | ||
|
||
async validate (payload: JSONObject) { | ||
return payload.x && payload.y && payload.z && payload.id; | ||
} | ||
|
||
async decode (payload: JSONObject): Promise<DecodedPayload<Decoder>> { | ||
const decodedPayload = new DecodedPayload<DummyAccelerometer3dDecoder>(this); | ||
|
||
const measurement: Acceleration3dMeasurement = { | ||
measuredAt: Date.now(), | ||
type: 'acceleration3d', | ||
values: { | ||
x: payload.x, | ||
y: payload.y, | ||
z: payload.z, | ||
} | ||
} | ||
|
||
decodedPayload.addMeasurement(payload.id, 'acceleration3d', measurement); | ||
|
||
return decodedPayload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.