@plus45/types 1.1.47 → 1.2.0

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/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@plus45/types",
3
- "version": "1.1.47",
4
- "main": "index.js",
5
- "types": "index.d.ts",
3
+ "version": "1.2.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "scripts": {
7
10
  "build": "tsc",
8
11
  "pb": "tsc && npm publish"
package/index.ts DELETED
@@ -1,55 +0,0 @@
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 {
5
- DistanceUnits,
6
- ExerciseUnit,
7
- TimeUnits,
8
- WeightUnits
9
- } from "./types/exercise/exercise_units";
10
- import { Workout } from "./types/workout/workout";
11
- import { AssignedSchedule, Schedule } from "./types/schedule/schedule";
12
- import { ScheduleDay } from "./types/schedule/schedule_days";
13
- import { ScheduleRecurrence } from "./types/schedule/schedule_recurrence";
14
- import { UserSessionInfo } from "./types/user/session_info";
15
- import {
16
- CompletedExercise,
17
- WorkoutExecution
18
- } from "./types/workout/workout_execution";
19
- import { WeekLayout } from "./types/generics/week_layout";
20
- import { AuthType } from "./types/authorization/authorization";
21
- import Exercise from "./types/exercise/exercise";
22
-
23
- export {
24
- // User Type Structures
25
- type User,
26
- type UserSessionInfo,
27
- type AccessToken,
28
-
29
- // Exercise Type Structures
30
- type Exercise,
31
- type CompletedExercise,
32
-
33
- // Workout Type Structures
34
- type Workout,
35
- type WorkoutExecution,
36
-
37
- // Schedule Type Structures
38
- type Schedule,
39
- type AssignedSchedule,
40
-
41
- // Generics
42
- WeekLayout,
43
-
44
- // Enums
45
- ExerciseType,
46
- ExerciseUnit,
47
- ScheduleDay,
48
- ScheduleRecurrence,
49
- AuthType,
50
-
51
- // Collections
52
- WeightUnits,
53
- DistanceUnits,
54
- TimeUnits
55
- };
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
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,4 +0,0 @@
1
- export const AuthType = {
2
- PASSWORD_CHANGE: "PASSWORD_CHANGE"
3
- } as const;
4
- export type AuthType = (typeof AuthType)[keyof typeof AuthType];
@@ -1,18 +0,0 @@
1
- import { ExerciseType } from "./exercise_types";
2
- import { ExerciseUnit } from "./exercise_units";
3
-
4
- type Exercise = {
5
- id: string;
6
- name: string;
7
- created_by: string;
8
- type: ExerciseType;
9
- description?: string;
10
- sets?: number;
11
- reps?: number;
12
- value?: number;
13
- value_unit?: ExerciseUnit;
14
- created_at: Date;
15
- deleted?: boolean;
16
- };
17
-
18
- export default Exercise;
@@ -1,26 +0,0 @@
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
- /**
11
- * Time based exercise (e.g. 3x30s)
12
- */
13
- TIME: "TIME",
14
-
15
- /**
16
- * Distance based exercise (e.g. 3x400m)
17
- */
18
- DISTANCE: "DISTANCE",
19
-
20
- /**
21
- * Custom exercise (uses string as data)
22
- */
23
- CUSTOM: "CUSTOM"
24
- } as const;
25
-
26
- export type ExerciseType = (typeof ExerciseType)[keyof typeof ExerciseType];
@@ -1,27 +0,0 @@
1
- export const ExerciseUnit = {
2
- // Time
3
- seconds: "SECONDS",
4
- minutes: "MINUTES",
5
-
6
- // Weight
7
- pounds: "POUNDS",
8
- kilograms: "KILOGRAMS",
9
-
10
- // Distance
11
- miles: "MILES",
12
- kilometers: "KILOMETERS",
13
- yards: "YARDS",
14
- feet: "FEET",
15
- meters: "METERS"
16
- } as const;
17
- export type ExerciseUnit = (typeof ExerciseUnit)[keyof typeof ExerciseUnit];
18
-
19
- export const WeightUnits = [ExerciseUnit.pounds, ExerciseUnit.kilograms];
20
- export const TimeUnits = [ExerciseUnit.seconds, ExerciseUnit.minutes];
21
- export const DistanceUnits = [
22
- ExerciseUnit.miles,
23
- ExerciseUnit.kilometers,
24
- ExerciseUnit.yards,
25
- ExerciseUnit.feet,
26
- ExerciseUnit.meters
27
- ];
@@ -1,65 +0,0 @@
1
- export 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
-
10
- constructor(
11
- Sunday?: Array<T>,
12
- Monday?: Array<T>,
13
- Tuesday?: Array<T>,
14
- Wednesday?: Array<T>,
15
- Thursday?: Array<T>,
16
- Friday?: Array<T>,
17
- Saturday?: Array<T>
18
- ) {
19
- this.Sunday = Sunday ?? [];
20
- this.Monday = Monday ?? [];
21
- this.Tuesday = Tuesday ?? [];
22
- this.Wednesday = Wednesday ?? [];
23
- this.Thursday = Thursday ?? [];
24
- this.Friday = Friday ?? [];
25
- this.Saturday = Saturday ?? [];
26
- }
27
-
28
- private getDayFromIndex = [
29
- "Sunday",
30
- "Monday",
31
- "Tuesday",
32
- "Wednesday",
33
- "Thursday",
34
- "Friday",
35
- "Saturday"
36
- ];
37
-
38
- /**
39
- * 0 = Sunday, 6 = Saturday
40
- */
41
- public setDay(index: number, value: T[]) {
42
- const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- (this as any)[day] = value;
45
- }
46
-
47
- /**
48
- * 0 = Sunday, 6 = Saturday
49
- */
50
- public addToDay(index: number, value: T) {
51
- const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
- const toAddTo = (this as any)[day] as T[];
54
- toAddTo.push(value);
55
- }
56
-
57
- /**
58
- * 0 = Sunday, 6 = Saturday
59
- */
60
- public getDay(index: number) {
61
- return (this as any)[
62
- this.getDayFromIndex[index] as keyof WeekLayout<T>
63
- ] as T[];
64
- }
65
- }
@@ -1,20 +0,0 @@
1
- import { Workout } from "../workout/workout";
2
-
3
- export type Schedule = {
4
- id: string;
5
- user_id: string;
6
- workout_id: string;
7
- workout?: Workout;
8
- days_of_week: number[];
9
- created_at: string;
10
- start_time: string;
11
- };
12
-
13
- export type AssignedSchedule = {
14
- schedule_id: string;
15
- schedule: Schedule;
16
- user_id: string;
17
- start_week: number;
18
- start_year: number;
19
- recurrence: number;
20
- };
@@ -1,10 +0,0 @@
1
- export const ScheduleDay = {
2
- SUNDAY: 0,
3
- MONDAY: 1,
4
- TUESDAY: 2,
5
- WEDNESDAY: 3,
6
- THURSDAY: 4,
7
- FRIDAY: 5,
8
- SATURDAY: 6
9
- } as const;
10
- export type ScheduleDay = (typeof ScheduleDay)[keyof typeof ScheduleDay];
@@ -1,6 +0,0 @@
1
- export const ScheduleRecurrence = {
2
- WEEKLY: "WEEKLY",
3
- BIWEEKLY: "BIWEEKLY"
4
- } as const;
5
- export type ScheduleRecurrence =
6
- (typeof ScheduleRecurrence)[keyof typeof ScheduleRecurrence];
@@ -1,12 +0,0 @@
1
- export type AccessToken = {
2
- id: string;
3
- user_id: string;
4
- hashed_token: string;
5
- expires_at: Date;
6
- user_agent: string;
7
- ip_address: string;
8
- platform?: string;
9
- language?: string;
10
- location?: string;
11
- created_at: Date;
12
- };
@@ -1,6 +0,0 @@
1
- export type UserSessionInfo = {
2
- userAgent: string;
3
- platform: string;
4
- language: string;
5
- ipAddress?: string;
6
- };
@@ -1,11 +0,0 @@
1
- export type User = {
2
- id: string;
3
- first_name: string;
4
- last_name: string;
5
- username: string;
6
- email: string;
7
- lang: string;
8
- created_at: string;
9
- theme_mode: string;
10
- theme_color: "light" | "dark";
11
- };
@@ -1,9 +0,0 @@
1
- import Exercise from "../exercise/exercise";
2
-
3
- export type Workout = {
4
- id: string;
5
- name: string;
6
- created_by: string;
7
- exercises: Exercise[];
8
- created_at: Date;
9
- };
@@ -1,20 +0,0 @@
1
- import { ExerciseUnit } from "../exercise/exercise_units";
2
- import { Workout } from "./workout";
3
-
4
- export type WorkoutExecution = {
5
- assigned_to_user: string;
6
- workout_id: string;
7
- current_index: number;
8
-
9
- /**
10
- * Completions are a record that point the exercise id (as the key) to the completion containing the value entered as well as the unit.
11
- */
12
- completions: Record<number, CompletedExercise>;
13
- completed?: boolean;
14
- } & Workout;
15
-
16
- export type CompletedExercise = {
17
- id: string;
18
- value?: number;
19
- unit?: ExerciseUnit;
20
- };