@plus45/types 1.1.46 → 1.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -0
- package/dist/index.js +13 -0
- package/dist/types/authorization/authorization.d.ts +4 -0
- package/dist/types/authorization/authorization.js +3 -0
- package/dist/types/exercise/exercise.d.ts +16 -0
- package/dist/types/exercise/exercise.js +1 -0
- package/dist/types/exercise/exercise_types.d.ts +22 -0
- package/dist/types/exercise/exercise_types.js +21 -0
- package/dist/types/exercise/exercise_units.d.ts +15 -0
- package/dist/types/exercise/exercise_units.js +23 -0
- package/dist/types/generics/week_layout.d.ts +23 -0
- package/dist/types/generics/week_layout.js +50 -0
- package/dist/types/schedule/schedule.d.ts +18 -0
- package/dist/types/schedule/schedule.js +1 -0
- package/dist/types/schedule/schedule_days.d.ts +10 -0
- package/dist/types/schedule/schedule_days.js +9 -0
- package/dist/types/schedule/schedule_recurrence.d.ts +5 -0
- package/dist/types/schedule/schedule_recurrence.js +4 -0
- package/dist/types/user/access_token.d.ts +12 -0
- package/dist/types/user/access_token.js +1 -0
- package/dist/types/user/session_info.d.ts +6 -0
- package/dist/types/user/session_info.js +1 -0
- package/dist/types/user/user.d.ts +11 -0
- package/dist/types/user/user.js +1 -0
- package/dist/types/workout/workout.d.ts +8 -0
- package/dist/types/workout/workout.js +1 -0
- package/dist/types/workout/workout_execution.d.ts +17 -0
- package/dist/types/workout/workout_execution.js +1 -0
- package/index.ts +1 -1
- package/package.json +7 -3
- package/tsconfig.json +13 -0
- package/types/authorization/authorization.ts +2 -2
- package/types/exercise/exercise.ts +4 -2
- package/types/exercise/exercise_types.ts +1 -2
- package/types/workout/workout.ts +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExerciseType } from "./types/exercise/exercise_types";
|
|
2
|
+
import { AccessToken } from "./types/user/access_token";
|
|
3
|
+
import { User } from "./types/user/user";
|
|
4
|
+
import { DistanceUnits, ExerciseUnit, TimeUnits, WeightUnits } from "./types/exercise/exercise_units";
|
|
5
|
+
import { Workout } from "./types/workout/workout";
|
|
6
|
+
import { AssignedSchedule, Schedule } from "./types/schedule/schedule";
|
|
7
|
+
import { ScheduleDay } from "./types/schedule/schedule_days";
|
|
8
|
+
import { ScheduleRecurrence } from "./types/schedule/schedule_recurrence";
|
|
9
|
+
import { UserSessionInfo } from "./types/user/session_info";
|
|
10
|
+
import { CompletedExercise, WorkoutExecution } from "./types/workout/workout_execution";
|
|
11
|
+
import { WeekLayout } from "./types/generics/week_layout";
|
|
12
|
+
import { AuthType } from "./types/authorization/authorization";
|
|
13
|
+
import Exercise from "./types/exercise/exercise";
|
|
14
|
+
export { type User, type UserSessionInfo, type AccessToken, type Exercise, type CompletedExercise, type Workout, type WorkoutExecution, type Schedule, type AssignedSchedule, WeekLayout, ExerciseType, ExerciseUnit, ScheduleDay, ScheduleRecurrence, AuthType, WeightUnits, DistanceUnits, TimeUnits };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExerciseType } from "./types/exercise/exercise_types";
|
|
2
|
+
import { DistanceUnits, ExerciseUnit, TimeUnits, WeightUnits } from "./types/exercise/exercise_units";
|
|
3
|
+
import { ScheduleDay } from "./types/schedule/schedule_days";
|
|
4
|
+
import { ScheduleRecurrence } from "./types/schedule/schedule_recurrence";
|
|
5
|
+
import { WeekLayout } from "./types/generics/week_layout";
|
|
6
|
+
import { AuthType } from "./types/authorization/authorization";
|
|
7
|
+
export {
|
|
8
|
+
// Generics
|
|
9
|
+
WeekLayout,
|
|
10
|
+
// Enums
|
|
11
|
+
ExerciseType, ExerciseUnit, ScheduleDay, ScheduleRecurrence, AuthType,
|
|
12
|
+
// Collections
|
|
13
|
+
WeightUnits, DistanceUnits, TimeUnits };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExerciseType } from "./exercise_types";
|
|
2
|
+
import { ExerciseUnit } from "./exercise_units";
|
|
3
|
+
type Exercise = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
created_by: string;
|
|
7
|
+
type: ExerciseType;
|
|
8
|
+
description?: string;
|
|
9
|
+
sets?: number;
|
|
10
|
+
reps?: number;
|
|
11
|
+
value?: number;
|
|
12
|
+
value_unit?: ExerciseUnit;
|
|
13
|
+
created_at: Date;
|
|
14
|
+
deleted?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export default Exercise;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object for different types of exercises.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ExerciseType: {
|
|
5
|
+
/**
|
|
6
|
+
* Sets-Reps based exercise (e.g. 3x10)
|
|
7
|
+
*/
|
|
8
|
+
readonly STRENGTH: "STRENGTH";
|
|
9
|
+
/**
|
|
10
|
+
* Time based exercise (e.g. 3x30s)
|
|
11
|
+
*/
|
|
12
|
+
readonly TIME: "TIME";
|
|
13
|
+
/**
|
|
14
|
+
* Distance based exercise (e.g. 3x400m)
|
|
15
|
+
*/
|
|
16
|
+
readonly DISTANCE: "DISTANCE";
|
|
17
|
+
/**
|
|
18
|
+
* Custom exercise (uses string as data)
|
|
19
|
+
*/
|
|
20
|
+
readonly CUSTOM: "CUSTOM";
|
|
21
|
+
};
|
|
22
|
+
export type ExerciseType = (typeof ExerciseType)[keyof typeof ExerciseType];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object for different types of exercises.
|
|
3
|
+
*/
|
|
4
|
+
export const ExerciseType = {
|
|
5
|
+
/**
|
|
6
|
+
* Sets-Reps based exercise (e.g. 3x10)
|
|
7
|
+
*/
|
|
8
|
+
STRENGTH: "STRENGTH",
|
|
9
|
+
/**
|
|
10
|
+
* Time based exercise (e.g. 3x30s)
|
|
11
|
+
*/
|
|
12
|
+
TIME: "TIME",
|
|
13
|
+
/**
|
|
14
|
+
* Distance based exercise (e.g. 3x400m)
|
|
15
|
+
*/
|
|
16
|
+
DISTANCE: "DISTANCE",
|
|
17
|
+
/**
|
|
18
|
+
* Custom exercise (uses string as data)
|
|
19
|
+
*/
|
|
20
|
+
CUSTOM: "CUSTOM"
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const ExerciseUnit: {
|
|
2
|
+
readonly seconds: "SECONDS";
|
|
3
|
+
readonly minutes: "MINUTES";
|
|
4
|
+
readonly pounds: "POUNDS";
|
|
5
|
+
readonly kilograms: "KILOGRAMS";
|
|
6
|
+
readonly miles: "MILES";
|
|
7
|
+
readonly kilometers: "KILOMETERS";
|
|
8
|
+
readonly yards: "YARDS";
|
|
9
|
+
readonly feet: "FEET";
|
|
10
|
+
readonly meters: "METERS";
|
|
11
|
+
};
|
|
12
|
+
export type ExerciseUnit = (typeof ExerciseUnit)[keyof typeof ExerciseUnit];
|
|
13
|
+
export declare const WeightUnits: ("POUNDS" | "KILOGRAMS")[];
|
|
14
|
+
export declare const TimeUnits: ("SECONDS" | "MINUTES")[];
|
|
15
|
+
export declare const DistanceUnits: ("MILES" | "KILOMETERS" | "YARDS" | "FEET" | "METERS")[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const ExerciseUnit = {
|
|
2
|
+
// Time
|
|
3
|
+
seconds: "SECONDS",
|
|
4
|
+
minutes: "MINUTES",
|
|
5
|
+
// Weight
|
|
6
|
+
pounds: "POUNDS",
|
|
7
|
+
kilograms: "KILOGRAMS",
|
|
8
|
+
// Distance
|
|
9
|
+
miles: "MILES",
|
|
10
|
+
kilometers: "KILOMETERS",
|
|
11
|
+
yards: "YARDS",
|
|
12
|
+
feet: "FEET",
|
|
13
|
+
meters: "METERS"
|
|
14
|
+
};
|
|
15
|
+
export const WeightUnits = [ExerciseUnit.pounds, ExerciseUnit.kilograms];
|
|
16
|
+
export const TimeUnits = [ExerciseUnit.seconds, ExerciseUnit.minutes];
|
|
17
|
+
export const DistanceUnits = [
|
|
18
|
+
ExerciseUnit.miles,
|
|
19
|
+
ExerciseUnit.kilometers,
|
|
20
|
+
ExerciseUnit.yards,
|
|
21
|
+
ExerciseUnit.feet,
|
|
22
|
+
ExerciseUnit.meters
|
|
23
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class WeekLayout<T> {
|
|
2
|
+
Sunday: Array<T>;
|
|
3
|
+
Monday: Array<T>;
|
|
4
|
+
Tuesday: Array<T>;
|
|
5
|
+
Wednesday: Array<T>;
|
|
6
|
+
Thursday: Array<T>;
|
|
7
|
+
Friday: Array<T>;
|
|
8
|
+
Saturday: Array<T>;
|
|
9
|
+
constructor(Sunday?: Array<T>, Monday?: Array<T>, Tuesday?: Array<T>, Wednesday?: Array<T>, Thursday?: Array<T>, Friday?: Array<T>, Saturday?: Array<T>);
|
|
10
|
+
private getDayFromIndex;
|
|
11
|
+
/**
|
|
12
|
+
* 0 = Sunday, 6 = Saturday
|
|
13
|
+
*/
|
|
14
|
+
setDay(index: number, value: T[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* 0 = Sunday, 6 = Saturday
|
|
17
|
+
*/
|
|
18
|
+
addToDay(index: number, value: T): void;
|
|
19
|
+
/**
|
|
20
|
+
* 0 = Sunday, 6 = Saturday
|
|
21
|
+
*/
|
|
22
|
+
getDay(index: number): T[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class WeekLayout {
|
|
2
|
+
Sunday;
|
|
3
|
+
Monday;
|
|
4
|
+
Tuesday;
|
|
5
|
+
Wednesday;
|
|
6
|
+
Thursday;
|
|
7
|
+
Friday;
|
|
8
|
+
Saturday;
|
|
9
|
+
constructor(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) {
|
|
10
|
+
this.Sunday = Sunday ?? [];
|
|
11
|
+
this.Monday = Monday ?? [];
|
|
12
|
+
this.Tuesday = Tuesday ?? [];
|
|
13
|
+
this.Wednesday = Wednesday ?? [];
|
|
14
|
+
this.Thursday = Thursday ?? [];
|
|
15
|
+
this.Friday = Friday ?? [];
|
|
16
|
+
this.Saturday = Saturday ?? [];
|
|
17
|
+
}
|
|
18
|
+
getDayFromIndex = [
|
|
19
|
+
"Sunday",
|
|
20
|
+
"Monday",
|
|
21
|
+
"Tuesday",
|
|
22
|
+
"Wednesday",
|
|
23
|
+
"Thursday",
|
|
24
|
+
"Friday",
|
|
25
|
+
"Saturday"
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* 0 = Sunday, 6 = Saturday
|
|
29
|
+
*/
|
|
30
|
+
setDay(index, value) {
|
|
31
|
+
const day = this.getDayFromIndex[index];
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
this[day] = value;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 0 = Sunday, 6 = Saturday
|
|
37
|
+
*/
|
|
38
|
+
addToDay(index, value) {
|
|
39
|
+
const day = this.getDayFromIndex[index];
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
const toAddTo = this[day];
|
|
42
|
+
toAddTo.push(value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 0 = Sunday, 6 = Saturday
|
|
46
|
+
*/
|
|
47
|
+
getDay(index) {
|
|
48
|
+
return this[this.getDayFromIndex[index]];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Workout } from "../workout/workout";
|
|
2
|
+
export type Schedule = {
|
|
3
|
+
id: string;
|
|
4
|
+
user_id: string;
|
|
5
|
+
workout_id: string;
|
|
6
|
+
workout?: Workout;
|
|
7
|
+
days_of_week: number[];
|
|
8
|
+
created_at: string;
|
|
9
|
+
start_time: string;
|
|
10
|
+
};
|
|
11
|
+
export type AssignedSchedule = {
|
|
12
|
+
schedule_id: string;
|
|
13
|
+
schedule: Schedule;
|
|
14
|
+
user_id: string;
|
|
15
|
+
start_week: number;
|
|
16
|
+
start_year: number;
|
|
17
|
+
recurrence: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const ScheduleDay: {
|
|
2
|
+
readonly SUNDAY: 0;
|
|
3
|
+
readonly MONDAY: 1;
|
|
4
|
+
readonly TUESDAY: 2;
|
|
5
|
+
readonly WEDNESDAY: 3;
|
|
6
|
+
readonly THURSDAY: 4;
|
|
7
|
+
readonly FRIDAY: 5;
|
|
8
|
+
readonly SATURDAY: 6;
|
|
9
|
+
};
|
|
10
|
+
export type ScheduleDay = (typeof ScheduleDay)[keyof typeof ScheduleDay];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExerciseUnit } from "../exercise/exercise_units";
|
|
2
|
+
import { Workout } from "./workout";
|
|
3
|
+
export type WorkoutExecution = {
|
|
4
|
+
assigned_to_user: string;
|
|
5
|
+
workout_id: string;
|
|
6
|
+
current_index: number;
|
|
7
|
+
/**
|
|
8
|
+
* Completions are a record that point the exercise id (as the key) to the completion containing the value entered as well as the unit.
|
|
9
|
+
*/
|
|
10
|
+
completions: Record<number, CompletedExercise>;
|
|
11
|
+
completed?: boolean;
|
|
12
|
+
} & Workout;
|
|
13
|
+
export type CompletedExercise = {
|
|
14
|
+
id: string;
|
|
15
|
+
value?: number;
|
|
16
|
+
unit?: ExerciseUnit;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Exercise } from "./types/exercise/exercise";
|
|
2
1
|
import { ExerciseType } from "./types/exercise/exercise_types";
|
|
3
2
|
import { AccessToken } from "./types/user/access_token";
|
|
4
3
|
import { User } from "./types/user/user";
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
} from "./types/workout/workout_execution";
|
|
20
19
|
import { WeekLayout } from "./types/generics/week_layout";
|
|
21
20
|
import { AuthType } from "./types/authorization/authorization";
|
|
21
|
+
import Exercise from "./types/exercise/exercise";
|
|
22
22
|
|
|
23
23
|
export {
|
|
24
24
|
// User Type Structures
|
package/package.json
CHANGED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"emitDeclarationOnly": false,
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"target": "ESNext",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["index.ts", "types/**/*.ts"]
|
|
13
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import ExerciseType from "./exercise_types";
|
|
1
|
+
import { ExerciseType } from "./exercise_types";
|
|
2
2
|
import { ExerciseUnit } from "./exercise_units";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Exercise = {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
7
|
created_by: string;
|
|
@@ -14,3 +14,5 @@ export type Exercise = {
|
|
|
14
14
|
created_at: Date;
|
|
15
15
|
deleted?: boolean;
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
export default Exercise;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* Object for different types of exercises.
|
|
4
3
|
*/
|
|
@@ -24,4 +23,4 @@ export const ExerciseType = {
|
|
|
24
23
|
CUSTOM: "CUSTOM"
|
|
25
24
|
} as const;
|
|
26
25
|
|
|
27
|
-
export type ExerciseType = typeof ExerciseType[keyof typeof ExerciseType];
|
|
26
|
+
export type ExerciseType = (typeof ExerciseType)[keyof typeof ExerciseType];
|
package/types/workout/workout.ts
CHANGED