New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@donmahallem/flow-api-types

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@donmahallem/flow-api-types - npm Package Compare versions

Comparing version 0.0.3 to 1.0.0

dist/schemas/index.d.ts

6

dist/flow-api-validator.d.ts

@@ -1,6 +0,6 @@

import { DaySummary } from "./model";
import * as jsonschema from "jsonschema";
import { IDaySummary } from "./model";
export declare class FlowApiValidator {
static validateTimelineSummary(data: DaySummary | any): jsonschema.ValidatorResult;
static validateTimelineSummaryPromise(data: DaySummary | any): Promise<jsonschema.ValidatorResult>;
static validateTimelineSummary(data: IDaySummary | any): jsonschema.ValidatorResult;
static validateTimelineSummaryPromise(data: IDaySummary | any): Promise<jsonschema.ValidatorResult>;
}

@@ -8,4 +8,4 @@ "use strict";

const val = new jsonschema.Validator();
val.addSchema(day_summary_1.addressSchema);
return val.validate(data, day_summary_1.addressSchema);
val.addSchema(day_summary_1.ActivityTimelineSchema);
return val.validate(data, day_summary_1.ActivityTimelineSchema);
}

@@ -12,0 +12,0 @@ static validateTimelineSummaryPromise(data) {

export * from "./flow-api-validator";
export * from "./summary-merger";
export * from "./model";
export * from "./schemas";

@@ -8,2 +8,3 @@ "use strict";

__export(require("./summary-merger"));
__export(require("./schemas"));
//# sourceMappingURL=index.js.map

@@ -1,14 +0,14 @@

export interface DaySummary {
[key: string]: DayData;
export interface IDaySummary {
[key: string]: IDayData;
}
export interface MiniGraphData {
export interface IMiniGraphData {
calorieReportUrl: string;
dailyGoalReportUrl: string;
data: {
calories: TimeValuePair;
dailyGoal: TimeValuePair;
calories: ITimeValuePair;
dailyGoal: ITimeValuePair;
date: number;
distance: TimeValuePair;
nightLowHr: TimeValuePair;
sleepAverage: TimeValuePair;
distance: ITimeValuePair;
nightLowHr: ITimeValuePair;
sleepAverage: ITimeValuePair;
sleepPlus: boolean;

@@ -20,17 +20,17 @@ };

}
export interface DayData {
activityGraphData: ActivityGraphData;
miniGraphData: MiniGraphData;
export interface IDayData {
activityGraphData: IActivityGraphData;
miniGraphData: IMiniGraphData;
}
export interface ActivityGraphData {
heartRateTimelineSamples: TimeValuePair[];
heartRateSummary: HeartRateSummary;
export interface IActivityGraphData {
heartRateTimelineSamples: ITimeValuePair[];
heartRateSummary: IHeartRateSummary;
activityZoneLimits: number[];
activityTimelineSamples: TimeValuePair[];
activityTimelineSamples: ITimeValuePair[];
}
export interface TimeValuePair {
export interface ITimeValuePair {
time: number;
value: number;
}
export interface HeartRateSummary {
export interface IHeartRateSummary {
dayMaximum: number;

@@ -43,2 +43,2 @@ dayMaximumDateTime: number;

}
export * from './sleep-item';
export * from "./sleep-item";

@@ -1,2 +0,2 @@

export interface NightSleep {
export interface INightSleep {
id: number;

@@ -11,3 +11,3 @@ night: string;

}
export interface SleepInterval {
export interface ISleepInterval {
sleepWakeState: number;

@@ -17,3 +17,3 @@ offsetFromStart: number;

}
export interface SleepEvaluationData {
export interface ISleepEvaluationData {
asleep: number;

@@ -34,10 +34,10 @@ continuityClass: number;

}
export interface SleepSummary {
export interface ISleepSummary {
date: string;
nightSleep: NightSleep;
sleepEvaluationData: SleepEvaluationData;
nightSleep: INightSleep;
sleepEvaluationData: ISleepEvaluationData;
}
export interface SleepNearby {
nextNight: SleepSummary;
previousNights: SleepSummary[];
export interface ISleepNearby {
nextNight: ISleepSummary;
previousNights: ISleepSummary[];
}
import * as jsonschema from "jsonschema";
export declare const timeValuePair: jsonschema.Schema;
export declare const startEndTimePair: jsonschema.Schema;
export declare const activityTimelineIconsSchema: jsonschema.Schema;
export declare const activityGraphData: jsonschema.Schema;
export declare const addressSchema: jsonschema.Schema;
export declare const TimeValuePairSchema: jsonschema.Schema;
export declare const StartEndTimePairSchema: jsonschema.Schema;
export declare const ActivityTimelineIconsSchema: jsonschema.Schema;
export declare const ActivityGraphDataSchema: jsonschema.Schema;
export declare const ActivityTimelineSchema: jsonschema.Schema;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeValuePair = {
type: "object",
exports.TimeValuePairSchema = {
properties: {
"time": {
time: {
type: "integer",
}, value: {
type: "number"
}
}
},
value: {
type: "number",
},
},
type: "object",
};
exports.startEndTimePair = {
type: "object",
exports.StartEndTimePairSchema = {
properties: {
endTime: {
type: "number",
},
startTime: {
type: "integer",
}, endTime: {
type: "number"
}
}
},
},
type: "object",
};
exports.activityTimelineIconsSchema = {
type: "object",
exports.ActivityTimelineIconsSchema = {
properties: {

@@ -49,27 +50,26 @@ activityTimelineIconType: {

type: "string",
}
}
},
},
type: "object",
};
exports.activityGraphData = {
"id": "/ActivityGraphData",
"type": "object",
"properties": {
exports.ActivityGraphDataSchema = {
id: "/ActivityGraphData",
properties: {
activityTimelineIcons: {
items: exports.ActivityTimelineIconsSchema,
type: "array",
items: exports.activityTimelineIconsSchema
},
activityTimelineSamples: {
items: exports.TimeValuePairSchema,
type: "array",
"items": exports.timeValuePair
},
activityZoneLimits: {
items: {
type: "number",
},
maxItems: 7,
minItems: 1,
type: "array",
"minItems": 1,
"maxItems": 7,
"items": {
"type": "number"
}
},
heartRateSummary: {
type: "object",
properties: {

@@ -81,8 +81,9 @@ dayMaximum: { type: "number" },

nightMinimum: { type: "number" },
nightMinimumDateTime: { type: "number" }
}
nightMinimumDateTime: { type: "number" },
},
type: "object",
},
heartRateTimelineSamples: {
items: exports.TimeValuePairSchema,
type: "array",
items: exports.timeValuePair
},

@@ -92,25 +93,26 @@ highSessionTimelineList: { type: "array" },

trainingTimelineList: {
items: exports.StartEndTimePairSchema,
type: "array",
items: exports.startEndTimePair
}
}
},
},
type: "object",
};
exports.addressSchema = {
"id": "/SimpleAddress",
"type": "object",
"patternProperties": {
exports.ActivityTimelineSchema = {
additionalProperties: false,
id: "/ActivityTimeline",
patternProperties: {
// The property name will be passed to new RegExp(prop), so backslashes
// have to be escaped.
"^[0-9]{4,4}\-[0-9]{1,2}\-[0-9]{1,2}$": {
"type": "object",
"properties": {
"dataPanelData": {
"type": "object"
properties: {
activityGraphData: exports.ActivityGraphDataSchema,
dataPanelData: {
type: "object",
},
"activityGraphData": exports.activityGraphData
}
}
},
type: "object",
},
},
"additionalProperties": false
type: "object",
};
//# sourceMappingURL=day-summary.js.map

@@ -1,5 +0,4 @@

import { DayData, DaySummary } from "./model";
import { IDayData, IDaySummary } from "./model";
export declare class SummaryMerger {
private data;
constructor();
/**

@@ -9,3 +8,3 @@ * generates the day key

*/
generateKey(day: DayData): string;
generateKey(day: IDayData): string;
/**

@@ -16,4 +15,4 @@ * Adds a day

*/
add(day: DayData, force?: boolean, key?: string): void;
addSummary(summary: DaySummary): void;
add(day: IDayData, force?: boolean, key?: string): void;
addSummary(summary: IDaySummary): void;
/**

@@ -24,7 +23,7 @@ * Adds multiple days to the summary

*/
addAll(days: DayData[], force?: boolean): void;
addAll(days: IDayData[], force?: boolean): void;
/**
* Gets the map
*/
get(): DaySummary;
get(): IDaySummary;
}

@@ -29,3 +29,3 @@ "use strict";

addSummary(summary) {
for (let key of Object.keys(summary)) {
for (const key of Object.keys(summary)) {
this.data[key] = summary[key];

@@ -40,3 +40,3 @@ }

addAll(days, force = false) {
for (let day of days) {
for (const day of days) {
this.add(day, force);

@@ -43,0 +43,0 @@ }

{
"name": "@donmahallem/flow-api-types",
"version": "0.0.3",
"version": "1.0.0",
"description": "Api Types and helper for FlowApi",

@@ -15,3 +15,5 @@ "main": "dist/index.js",

"test-ci_old": "nyc ts-mocha -p tsconfig.json -- --opts mocha.opts",
"test-ci": "nyc npm run test"
"test-ci": "nyc npm run test",
"lint": "tslint -c tslint.json -e src/**/*.spec.ts src/**/*.ts",
"lint-fix": "tslint --fix -c tslint.json -e src/**/*.spec.ts src/**/*.ts"
},

@@ -46,2 +48,3 @@ "author": "",

"ts-node": "^8.0.1",
"tslint": "^5.12.1",
"typescript": "^3.2.2"

@@ -48,0 +51,0 @@ },

This is a small library of tools to handle data from flow.polar.com
[![Build Status](https://travis-ci.com/donmahallem/FlowApiTypes.svg?branch=master)](https://travis-ci.com/donmahallem/FlowApiTypes) [![Coverage Status](https://coveralls.io/repos/github/donmahallem/FlowApiTypes/badge.svg?branch=master)](https://coveralls.io/github/donmahallem/FlowApiTypes?branch=master)
[![Build Status](https://travis-ci.com/donmahallem/FlowApiTypes.svg?branch=master)](https://travis-ci.com/donmahallem/FlowApiTypes) [![Coverage Status](https://coveralls.io/repos/github/donmahallem/FlowApiTypes/badge.svg?branch=master)](https://coveralls.io/github/donmahallem/FlowApiTypes?branch=master) [![npm version](https://badge.fury.io/js/%40donmahallem%2Fflow-api-types.svg)](https://badge.fury.io/js/%40donmahallem%2Fflow-api-types) [![Maintainability](https://api.codeclimate.com/v1/badges/f20f120f5f2a5d0104c8/maintainability)](https://codeclimate.com/github/donmahallem/FlowApiTypes/maintainability)

@@ -5,3 +5,3 @@ import * as flowApiValidator from "./flow-api-validator";

import * as jsonschema from "jsonschema";
import { addressSchema } from "./schemas/day-summary";
import { ActivityTimelineSchema } from "./schemas/day-summary";
// if you used the "@types/mocha" method to install mocha type definitions, uncomment the following line

@@ -56,7 +56,7 @@ import "mocha";

expect(stubInstance.addSchema.getCall(0).args.length).to.equal(1);
expect(stubInstance.addSchema.getCall(0).args[0]).to.deep.equal(addressSchema);
expect(stubInstance.addSchema.getCall(0).args[0]).to.deep.equal(ActivityTimelineSchema);
expect(stubInstance.validate.callCount).to.equal(1);
expect(stubInstance.validate.getCall(0).args).to.deep.equal([testObj, addressSchema]);
expect(stubInstance.validate.getCall(0).args).to.deep.equal([testObj, ActivityTimelineSchema]);
});
});
});

@@ -1,13 +0,13 @@

import { DaySummary } from "./model";
import * as jsonschema from "jsonschema";
import { addressSchema } from "./schemas/day-summary";
import { IDaySummary } from "./model";
import { ActivityTimelineSchema } from "./schemas/day-summary";
export class FlowApiValidator {
public static validateTimelineSummary(data: DaySummary | any): jsonschema.ValidatorResult {
public static validateTimelineSummary(data: IDaySummary | any): jsonschema.ValidatorResult {
const val: jsonschema.Validator = new jsonschema.Validator();
val.addSchema(addressSchema);
return val.validate(data, addressSchema);
val.addSchema(ActivityTimelineSchema);
return val.validate(data, ActivityTimelineSchema);
}
public static validateTimelineSummaryPromise(data: DaySummary | any): Promise<jsonschema.ValidatorResult> {
public static validateTimelineSummaryPromise(data: IDaySummary | any): Promise<jsonschema.ValidatorResult> {
return new Promise((resolve, reject) => {

@@ -18,2 +18,2 @@ const result: jsonschema.ValidatorResult = this.validateTimelineSummary(data);

}
}
}
export * from "./flow-api-validator";
export * from "./summary-merger";
export * from "./model";
export * from "./model";
export * from "./schemas";

@@ -1,2 +0,2 @@

import { ActivityGraphData } from './index'
import { IActivityGraphData } from "./index"
import { expect } from "chai";

@@ -3,0 +3,0 @@ import "mocha";

@@ -1,17 +0,17 @@

export interface DaySummary {
export interface IDaySummary {
[key: string]: IDayData;
}
[key: string]: DayData;
}
export interface MiniGraphData {
export interface IMiniGraphData {
calorieReportUrl: string;
dailyGoalReportUrl: string;
data: {
calories: TimeValuePair;
dailyGoal: TimeValuePair;
calories: ITimeValuePair;
dailyGoal: ITimeValuePair;
date: number;
distance: TimeValuePair;
nightLowHr: TimeValuePair;
sleepAverage: TimeValuePair;
distance: ITimeValuePair;
nightLowHr: ITimeValuePair;
sleepAverage: ITimeValuePair;
sleepPlus: boolean;
},
};
distanceReportUrl: string;

@@ -21,14 +21,16 @@ sampleDate: number;

}
export interface DayData {
activityGraphData: ActivityGraphData;
miniGraphData: MiniGraphData;
export interface IDayData {
activityGraphData: IActivityGraphData;
miniGraphData: IMiniGraphData;
}
export interface ActivityGraphData {
heartRateTimelineSamples: TimeValuePair[];
heartRateSummary: HeartRateSummary;
export interface IActivityGraphData {
heartRateTimelineSamples: ITimeValuePair[];
heartRateSummary: IHeartRateSummary;
activityZoneLimits: number[];
activityTimelineSamples: TimeValuePair[];
activityTimelineSamples: ITimeValuePair[];
}
export interface TimeValuePair {
export interface ITimeValuePair {
time: number;

@@ -38,3 +40,3 @@ value: number;

export interface HeartRateSummary {
export interface IHeartRateSummary {
dayMaximum: number;

@@ -48,2 +50,2 @@ dayMaximumDateTime: number;

export * from './sleep-item';
export * from "./sleep-item";

@@ -1,2 +0,2 @@

export interface NightSleep {
export interface INightSleep {
id: number;

@@ -12,3 +12,3 @@ night: string;

export interface SleepInterval {
export interface ISleepInterval {
sleepWakeState: number;

@@ -19,3 +19,3 @@ offsetFromStart: number;

export interface SleepEvaluationData {
export interface ISleepEvaluationData {
asleep: number;

@@ -37,11 +37,11 @@ continuityClass: number;

export interface SleepSummary {
export interface ISleepSummary {
date: string;
nightSleep: NightSleep;
sleepEvaluationData: SleepEvaluationData;
nightSleep: INightSleep;
sleepEvaluationData: ISleepEvaluationData;
}
export interface SleepNearby {
nextNight: SleepSummary;
previousNights: SleepSummary[];
}
export interface ISleepNearby {
nextNight: ISleepSummary;
previousNights: ISleepSummary[];
}
import * as jsonschema from "jsonschema";
export const timeValuePair: jsonschema.Schema = {
type: "object",
export const TimeValuePairSchema: jsonschema.Schema = {
properties: {
"time": {
time: {
type: "integer",
}, value: {
type: "number"
}
}
}
export const startEndTimePair: jsonschema.Schema = {
},
value: {
type: "number",
},
},
type: "object",
};
export const StartEndTimePairSchema: jsonschema.Schema = {
properties: {
endTime: {
type: "number",
},
startTime: {
type: "integer",
}, endTime: {
type: "number"
}
}
}
},
},
type: "object",
};
export const activityTimelineIconsSchema: jsonschema.Schema = {
type: "object",
export const ActivityTimelineIconsSchema: jsonschema.Schema = {
properties: {

@@ -50,28 +52,27 @@ activityTimelineIconType: {

type: "string",
}
}
}
},
},
type: "object",
};
export const activityGraphData: jsonschema.Schema = {
"id": "/ActivityGraphData",
"type": "object",
"properties": {
export const ActivityGraphDataSchema: jsonschema.Schema = {
id: "/ActivityGraphData",
properties: {
activityTimelineIcons: {
items: ActivityTimelineIconsSchema,
type: "array",
items: activityTimelineIconsSchema
},
activityTimelineSamples: {
items: TimeValuePairSchema,
type: "array",
"items": timeValuePair
},
activityZoneLimits: {
items: {
type: "number",
},
maxItems: 7,
minItems: 1,
type: "array",
"minItems": 1,
"maxItems": 7,
"items": {
"type": "number"
}
},
heartRateSummary: {
type: "object",
properties: {

@@ -83,8 +84,9 @@ dayMaximum: { type: "number" },

nightMinimum: { type: "number" },
nightMinimumDateTime: { type: "number" }
}
nightMinimumDateTime: { type: "number" },
},
type: "object",
},
heartRateTimelineSamples: {
items: TimeValuePairSchema,
type: "array",
items: timeValuePair
},

@@ -94,26 +96,26 @@ highSessionTimelineList: { type: "array" },

trainingTimelineList: {
items: StartEndTimePairSchema,
type: "array",
items: startEndTimePair
}
}
}
},
},
type: "object",
};
export const addressSchema: jsonschema.Schema = {
"id": "/SimpleAddress",
"type": "object",
"patternProperties": {
export const ActivityTimelineSchema: jsonschema.Schema = {
additionalProperties: false,
id: "/ActivityTimeline",
patternProperties: {
// The property name will be passed to new RegExp(prop), so backslashes
// have to be escaped.
"^[0-9]{4,4}\-[0-9]{1,2}\-[0-9]{1,2}$": {
"type": "object",
"properties": {
"dataPanelData": {
"type": "object"
properties: {
activityGraphData: ActivityGraphDataSchema,
dataPanelData: {
type: "object",
},
"activityGraphData": activityGraphData
}
}
},
type: "object",
},
},
"additionalProperties": false
};
type: "object",
};

@@ -1,7 +0,5 @@

import { DayData, DaySummary } from "./model";
import { IDayData, IDaySummary } from "./model";
export class SummaryMerger {
private data: DaySummary = {};
constructor() {
}
private data: IDaySummary = {};

@@ -12,3 +10,3 @@ /**

*/
public generateKey(day: DayData): string {
public generateKey(day: IDayData): string {
const timestamp: number = day.miniGraphData.data.date;

@@ -24,3 +22,3 @@ const dateObj: Date = new Date(timestamp);

*/
public add(day: DayData, force: boolean = false, key: string = null): void {
public add(day: IDayData, force: boolean = false, key: string = null): void {
const dayKey: string = key ? key : this.generateKey(day);

@@ -33,4 +31,4 @@ if (this.data[dayKey] && force === false) {

public addSummary(summary: DaySummary): void {
for (let key of Object.keys(summary)) {
public addSummary(summary: IDaySummary): void {
for (const key of Object.keys(summary)) {
this.data[key] = summary[key];

@@ -43,6 +41,6 @@ }

* @param days The days to be added
* @param force
* @param force
*/
public addAll(days: DayData[], force: boolean = false): void {
for (let day of days) {
public addAll(days: IDayData[], force: boolean = false): void {
for (const day of days) {
this.add(day, force);

@@ -55,5 +53,5 @@ }

*/
public get(): DaySummary {
public get(): IDaySummary {
return this.data;
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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