Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fitbit-sdk-types

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fitbit-sdk-types - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

523

index.d.ts

@@ -15,12 +15,33 @@ type PermissionName =

interface Sensor<Reading> {
readonly activated: boolean;
onactivate(event: Event): void;
onerror(event: SensorErrorEvent): void;
onreading(event: Event): void;
interface StrictEventListener<EventMap> {
addEventListener<EventName extends keyof EventMap>(
type: EventName,
listener: (event: EventMap[EventName]) => void,
): void;
removeEventListener<EventName extends keyof EventMap>(
eventName: EventName,
): void;
}
interface Sensor<BatchReading extends {}, EventMap = {}>
extends StrictEventListener<
EventMap & {
activate: Event;
error: SensorErrorEvent;
reading: Event;
}
> {
onactivate: (event: Event) => void;
onerror: (event: SensorErrorEvent) => void;
onreading: (event: Event) => void;
start(): void;
stop(): void;
readonly readings: BatchedReading<Reading>;
readonly activated: boolean;
readonly readings: BatchedReading<BatchReading>;
}
declare class SensorBase {
constructor(options?: SensorOptions);
}
interface SensorErrorEvent {

@@ -33,17 +54,9 @@ readonly defaultPrevented: boolean;

interface BatchedSensorReading {
readonly timestamp: Float32Array;
}
interface SensorReading {
readonly timestamp: number | null;
}
interface SensorOptions {
readonly frequency?: number | undefined;
readonly batch?: number | undefined;
readonly frequency?: number;
readonly batch?: number;
}
interface BatchedSensorOptions extends SensorOptions {
readonly batch?: number | undefined;
readonly batch?: number;
}

@@ -62,5 +75,3 @@

AccelerometerReading {}
export class Accelerometer {
constructor(options?: SensorOptions);
}
export class Accelerometer extends SensorBase {}
}

@@ -78,5 +89,473 @@

const me: Appbit;
export const me: Appbit;
}
export { me };
declare module 'barometer' {
interface BarometerReading {
readonly pressure: number | null;
readonly timestamp: number | null;
}
interface Barometer extends Sensor<BarometerReading>, BarometerReading {}
export class Barometer extends SensorBase {}
}
declare module 'body-presence' {
interface BodyPresenceReading {
readonly present: boolean;
}
interface BodyPresenceSensor extends Sensor<BodyPresenceReading> {}
export class BodyPresenceSensor extends SensorBase {
readonly present: boolean;
}
}
declare module 'clock' {
type Granularity = 'off' | 'seconds' | 'minutes' | 'hours';
interface TickEvent extends Event {
readonly date: Date;
}
interface Clock {
granularity: Granularity;
ontick: (event: TickEvent) => void;
}
const clock: Clock;
export default clock;
}
declare module 'device' {
interface Device {
readonly firmwareVersion: string;
readonly lastSyncTime: Date;
readonly modelId: string;
readonly modelName: string;
readonly screen: {
readonly width: number;
readonly height: number;
};
readonly type: 'WATCH' | 'TRACKER';
}
export const me: Device;
}
declare module 'display' {
interface EventMap {
change: Event;
patata: string;
}
interface Display extends StrictEventListener<EventMap> {
autoOff: boolean;
brightnessOverride: number | undefined;
on: boolean;
onchange: (event: Event) => void;
poke(): void;
}
export const display: Display;
}
declare module 'document' {
interface EventMap {
activate: Event;
animationend: AnimationEvent;
animationiteration: AnimationEvent;
animationstart: AnimationEvent;
click: MouseEvent;
collapse: Event;
disable: Event;
enable: Event;
expand: Event;
highlight: Event;
keydown: KeyboardEvent;
keypress: KeyboardEvent;
keyup: KeyboardEvent;
listbackward: ListScrollEvent;
listforward: ListScrollEvent;
load: LoadEvent;
mousedown: MouseEvent;
mousemove: MouseEvent;
mouseout: MouseEvent;
mouseover: MouseEvent;
mouseup: MouseEvent;
pagescroll: PageScrollEvent;
reload: LoadEvent;
select: Event;
unhighlight: Event;
unload: Event;
unselect: Event;
}
interface ListScrollEvent extends Event {
readonly first: number;
readonly last: number;
readonly middle: number;
}
interface LoadEvent extends Event {
readonly phase: 1 | 2;
}
interface PageScrollEvent extends Event {
readonly pageSize: number;
readonly position: number;
readonly viewSize: number;
}
interface EventHandler {
(event: Event): boolean;
}
interface GlobalEvents extends StrictEventListener<EventMap> {
onactivate: (event: Event) => void;
onanimationend: (event: AnimationEvent) => void;
onanimationiteration: (event: AnimationEvent) => void;
onanimationstart: (event: AnimationEvent) => void;
onclick: (event: MouseEvent) => void;
oncollapse: (event: Event) => void;
ondisable: (event: Event) => void;
onenable: (event: Event) => void;
onexpand: (event: Event) => void;
onhighlight: (event: Event) => void;
onkeydown: (event: KeyboardEvent) => void;
onkeypress: (event: KeyboardEvent) => void;
onkeyup: (event: KeyboardEvent) => void;
onlistbackward: (event: ListScrollEvent) => void;
onlistforward: (event: ListScrollEvent) => void;
onload: (event: LoadEvent) => void;
onmousedown: (event: MouseEvent) => void;
onmousemove: (event: MouseEvent) => void;
onmouseout: (event: MouseEvent) => void;
onmouseover: (event: MouseEvent) => void;
onmouseup: (event: MouseEvent) => void;
onpagescroll: (event: PageScrollEvent) => void;
onreload: (event: Event) => void;
onselect: (event: Event) => void;
onunhighlight: (event: Event) => void;
onunload: (event: Event) => void;
onunselect: (event: Event) => void;
}
interface DocumentModule extends GlobalEvents {
readonly default: DocumentModule;
readonly root: Element;
getEventHandler(elementType: string): EventHandler | null;
setEventHandler(elementType: string, handler: EventHandler): void;
}
interface Element extends GlobalEvents {
[key: string]: any;
}
interface ElementSearch {
getElementById(id: string): Element;
getElementsByClassName(className: string): Element[];
getElementsByTypeName(typeName: string): Element[];
}
const document: DocumentModule & ElementSearch;
export default document;
}
declare module 'fs' {
export function writeFileSync(
filename: string,
data: ArrayBuffer | ArrayBufferView,
): void;
export function writeFileSync(
filename: string,
data: string,
encoding: 'ascii' | 'utf-8',
): void;
export function writeFileSync(
filename: string,
data: any,
encoding: 'cbor' | 'json',
): void;
export function readFileSync(filename: string): any;
export function readFileSync(
filename: string,
encoding: 'ascii' | 'utf-8',
): string;
export function readFileSync(
filename: string,
encoding: 'cbor' | 'json',
): any;
export function renameSync(oldFilename: string, newFilename: string): void;
export function unlinkSync(filename: string): void;
interface FileStats {
readonly size: number;
readonly mtime: any;
}
export function statSync(filename: string): FileStats;
type FileDescriptor = number;
export function writeSync(
fd: FileDescriptor,
buffer: ArrayBuffer,
offset?: number,
length?: number,
position?: number,
): void;
export function readSync(
fd: FileDescriptor,
buffer: ArrayBuffer,
offset?: number,
length?: number,
position?: number,
): void;
export function closeSync(fd: FileDescriptor): void;
export function openSync(
filename: string,
flags: 'r' | 'r+' | 'w' | 'w+' | 'a' | 'a+',
): FileDescriptor;
export function listDirSync(path: string): Iterator<string>;
}
declare module 'file-transfer' {
interface EventMap {
newfile: Event;
}
type FileName = string;
interface Inbox extends StrictEventListener<EventMap> {
onnewfile: (event: Event) => void;
nextFile(): FileName | undefined;
}
export const inbox: Inbox;
}
declare module 'geolocation' {
type WatchId = number;
interface Geolocation {
clearWatch(watchId: WatchId): void;
getCurrentPosition(
successCallback: PositionCallback,
errorCallback?: PositionErrorCallback,
options?: PositionOptions,
): void;
watchPosition(
successCallback: PositionCallback,
errorCallback?: PositionErrorCallback,
options?: PositionOptions,
): WatchId;
}
interface PositionOptions {
enableHighAccuracy?: boolean;
maximumAge?: number;
timeout?: number;
}
type PositionErrorCode =
| 'PERMISSION_DENIED'
| 'POSITION_UNAVAILABLE'
| 'TIMEOUT';
export const PositionErrorCode: {
readonly PERMISSION_DENIED: 'PERMISSION_DENIED';
readonly POSITION_UNAVAILABLE: 'POSITION_UNAVAILABLE';
readonly TIMEOUT: 'TIMEOUT';
readonly code: PositionErrorCode;
};
export const geolocation: Geolocation;
}
declare module 'gyroscope' {
interface GyroscopeReading {
readonly timestamp: number | null;
readonly x: number | null;
readonly y: number | null;
readonly z: number | null;
}
interface Gyroscope extends Sensor<GyroscopeReading>, GyroscopeReading {}
export class Gyroscope extends SensorBase {}
}
declare module 'haptics' {
type VibrationPatternName =
| 'bump'
| 'nudge'
| 'nudge-max'
| 'ping'
| 'confirmation'
| 'confirmation-max';
interface Vibration {
start(pattern: VibrationPatternName): void;
}
export const vibration: Vibration;
}
declare module 'messaging' {
type CloseCode = 'CONNECTION_LOST' | 'PEER_INITIATED' | 'SOCKET_ERROR';
export class CloseEvent extends Event {
readonly CONNECTION_LOST: 'CONNECTION_LOST';
readonly PEER_INITIATED: 'PEER_INITIATED';
readonly SOCKET_ERROR: 'SOCKET_ERROR';
readonly code: CloseCode;
readonly wasClean: boolean;
}
type ErrorCode = 'BUFFER_FULL';
export class ErrorEvent extends Error {
readonly BUFFER_FULL: 'BUFFER_FULL';
readonly code: ErrorCode;
}
export class MessageEvent extends Event {
readonly data: any;
}
type ReadyState = 'CLOSED' | 'OPEN';
interface EventMap {
bufferedamountdecrease: Event;
close: CloseEvent;
error: ErrorEvent;
message: MessageEvent;
open: Event;
}
interface MessageSocket extends StrictEventListener<EventMap> {}
class MessageSocket {
readonly CLOSED: 'CLOSED';
readonly OPEN: 'OPEN';
readonly MAX_MESSAGE_SIZE: number;
readonly bufferedAmount: number;
onbufferedamountdecrease: (event: Event) => void;
onclose: (event: CloseEvent) => void;
onerror: (event: ErrorEvent) => void;
onmessage: (event: MessageEvent) => void;
onopen: (event: Event) => void;
readonly readyState: ReadyState;
send(data: any): void;
}
export const peerSocket: MessageSocket;
}
declare module 'orientation' {
type Quaternion = [number, number, number, number];
interface BatchReading {
readonly i: number;
readonly j: number;
readonly k: number;
readonly scalar: number;
readonly timestamp: number;
}
interface OrientationSensor extends Sensor<BatchReading> {
readonly quaternion: Quaternion;
readonly timestamp: number;
}
export class OrientationSensor extends SensorBase {}
}
declare module 'power' {
interface BatteryEventMap {
change: Event;
}
interface Battery extends StrictEventListener<BatteryEventMap> {
readonly chargeLevel: number;
readonly charging: boolean;
onchange: (event: Event) => void;
readonly timeUntilFull: number;
}
export const battery: Battery;
interface ChargerEventMap {
change: Event;
}
interface Charger extends StrictEventListener<ChargerEventMap> {
readonly connected: boolean;
onchange: (event: Event) => void;
powerIsGood: boolean | undefined;
}
export const charger: Charger;
}
declare module 'system' {
interface EventPressureMonitorEventMap {
memorypressurechange: Event;
}
interface MemoryPressureMonitor
extends StrictEventListener<EventPressureMonitorEventMap> {
onmemorypressurechange: (event: Event) => void;
readonly pressure: 'normal' | 'high' | 'critical';
}
interface MemoryUsage {
readonly peak: number;
readonly total: number;
readonly used: number;
}
interface Memory {
readonly js: MemoryUsage;
readonly monitor: MemoryPressureMonitor;
readonly native: MemoryUsage;
}
export const memory: Memory;
}
declare module 'user-activity' {
interface GoalsEventMap {
reachgoal: Event;
}
interface Goals {
readonly activeMinutes: number | undefined;
readonly calories: number | undefined;
readonly distance: number | undefined;
readonly elevationGain: number | undefined;
onreachgoal: (event: Event) => void;
readonly steps: number | undefined;
}
export const goals: Goals;
interface Activity {
readonly activeMinutes: number | undefined;
readonly calories: number | undefined;
readonly distance: number | undefined;
readonly elevationGain: number | undefined;
readonly steps: number | undefined;
}
interface Today {
readonly adjusted: Activity;
readonly local: Activity;
}
export const today: Today;
}
declare module 'user-profile' {
type DefaultZone = 'out-of-range' | 'fat-burn' | 'cardio' | 'peak';
type UserDefinedZone = 'below-custom' | 'custom' | 'above-custom';
interface UserProfile {
readonly age: number | undefined;
readonly bmr: number | undefined;
readonly gender: 'male' | 'female' | undefined;
readonly height: number | undefined;
readonly restingHeartRate: number | undefined;
readonly stride: {
readonly walk: number | undefined;
readonly run: number | undefined;
};
readonly weight: number | undefined;
heartRateZone(heartRate: number): DefaultZone | UserDefinedZone;
}
export const user: UserProfile;
}
declare module 'user-settings' {
interface Preferences {
readonly clockDisplay: '12h' | '24h';
readonly firstDayOfWeek: 0 | 1;
}
export const preferences: Preferences;
interface ExerciseSettings {
readonly poolLength: number;
}
export const exercise: ExerciseSettings;
interface DeviceSettings {
readonly airplaneModeEnabled: boolean;
readonly vibrationEnabled: boolean;
}
export const device: DeviceSettings;
interface LocaleSettings {
readonly language: string;
}
export const locale: LocaleSettings;
interface UnitsSettings {
readonly bodyWeight: 'metric' | 'us' | 'stone';
readonly distance: 'metric' | 'us';
readonly height: 'metric' | 'us';
readonly speed: 'metric' | 'us';
readonly temperature: 'C' | 'F';
readonly volume: 'metric' | 'us';
readonly weight: 'metric' | 'us';
}
export const units: UnitsSettings;
}
{
"name": "fitbit-sdk-types",
"version": "0.0.2",
"version": "0.0.3",
"description": "Work in progress. Types for Fitbit SDK.",

@@ -14,3 +14,7 @@ "scripts": {

"author": "Sergio Morchón Poveda",
"repository": {
"type": "git",
"url": "https://github.com/SergioMorchon/fitbit-sdk-types"
},
"license": "ISC"
}
# Fitbit SDK Types
This is a work in progress project to add static typing for the FITBIT SDK modules.
Add types to your Fitbit project to use safely the SDK.
_This is a work in progress project to add static typing for the FITBIT SDK modules._
## How to use in your app project
1. Add this project as to your `devDependencies`with `npm install --save-dev fitbit-sdk-types`.
1. Add a _reference type_ to any of your files, or to a `global.d.ts` one with `/// <reference types="fitbit-sdk-types" />`.
1. Profit!
**app/index.ts**
```typescript
/// <reference types="fitbit-sdk-types" />
import { Accelerometer } from "accelerometer";
const acc = new Accelerometer();
console.log(acc.activated);
console.log(acc.potato); // error
```
## Examples
You can see a ton of official examples working as tests right here, under the `./test` path.
## Contributing
Make a PR submitting _at least_ the desired test examples to work under the `.test` path, ideally with some link to any of the Fitbit official sources to get more info.
## Remainig
* All the *Companion* APIs.
* Some *App*'s `document` module types (mostly `WhateverElement`).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc