@sunsteel/contracts 0.34.0 → 0.36.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/dist/index.cjs CHANGED
@@ -34,6 +34,8 @@ __export(index_exports, {
34
34
  MUSCLE_GROUPS: () => MUSCLE_GROUPS,
35
35
  PLATEAU_MIN_DAYS_SINCE_BEST: () => PLATEAU_MIN_DAYS_SINCE_BEST,
36
36
  PLATEAU_MIN_SESSIONS: () => PLATEAU_MIN_SESSIONS,
37
+ PLATEAU_MIN_SESSIONS_MAX: () => PLATEAU_MIN_SESSIONS_MAX,
38
+ PLATEAU_MIN_SESSIONS_MIN: () => PLATEAU_MIN_SESSIONS_MIN,
37
39
  PLATEAU_RECENT_DAYS: () => PLATEAU_RECENT_DAYS,
38
40
  PLATEAU_WINDOW_DAYS: () => PLATEAU_WINDOW_DAYS,
39
41
  PREFERRED_TRAINING_STYLE_VALUES: () => PREFERRED_TRAINING_STYLE_VALUES,
@@ -51,6 +53,9 @@ __export(index_exports, {
51
53
  RENAISSANCE_RANK_DEFINITIONS: () => RENAISSANCE_RANK_DEFINITIONS,
52
54
  REP_TYPES: () => REP_TYPES,
53
55
  RESERVED_USERNAMES: () => RESERVED_USERNAMES,
56
+ ROUTINE_DAYS_MAX: () => ROUTINE_DAYS_MAX,
57
+ ROUTINE_DAY_NAME_MAX: () => ROUTINE_DAY_NAME_MAX,
58
+ ROUTINE_SCHEDULE_MODES: () => ROUTINE_SCHEDULE_MODES,
54
59
  SESSION_SHARE_DEFAULT_FIELDS: () => SESSION_SHARE_DEFAULT_FIELDS,
55
60
  SESSION_SHARE_FIELDS: () => SESSION_SHARE_FIELDS,
56
61
  SESSION_SHARE_MAX_ACTIVE_LINKS: () => SESSION_SHARE_MAX_ACTIVE_LINKS,
@@ -64,7 +69,8 @@ __export(index_exports, {
64
69
  USERNAME_MIN_LENGTH: () => USERNAME_MIN_LENGTH,
65
70
  USERNAME_PATTERN_SOURCE: () => USERNAME_PATTERN_SOURCE,
66
71
  WEIGHT_UNITS: () => WEIGHT_UNITS,
67
- WORKOUT_SESSION_STATUSES: () => WORKOUT_SESSION_STATUSES
72
+ WORKOUT_SESSION_STATUSES: () => WORKOUT_SESSION_STATUSES,
73
+ routineDayLabel: () => routineDayLabel
68
74
  });
69
75
  module.exports = __toCommonJS(index_exports);
70
76
 
@@ -346,6 +352,31 @@ var RENAISSANCE_RANK_DEFINITIONS = [
346
352
  }
347
353
  ];
348
354
 
355
+ // src/routine.ts
356
+ var ROUTINE_SCHEDULE_MODES = ["WEEKLY", "ROTATION"];
357
+ var ROUTINE_DAYS_MAX = 7;
358
+ var ROUTINE_DAY_NAME_MAX = 40;
359
+ var WEEKDAY_NAMES = [
360
+ "Sunday",
361
+ "Monday",
362
+ "Tuesday",
363
+ "Wednesday",
364
+ "Thursday",
365
+ "Friday",
366
+ "Saturday"
367
+ ];
368
+ function routineDayLabel(day) {
369
+ const name = day.name?.trim();
370
+ if (name) return name;
371
+ if (typeof day.dayOfWeek === "number") {
372
+ return WEEKDAY_NAMES[day.dayOfWeek] ?? "";
373
+ }
374
+ if (typeof day.order === "number" && day.order >= 0 && day.order < 26) {
375
+ return `Day ${String.fromCharCode(65 + day.order)}`;
376
+ }
377
+ return "";
378
+ }
379
+
349
380
  // src/workout.ts
350
381
  var SESSION_SHARE_FIELDS = [
351
382
  "duration",
@@ -379,6 +410,8 @@ var PLATEAU_WINDOW_DAYS = 56;
379
410
  var PLATEAU_MIN_SESSIONS = 4;
380
411
  var PLATEAU_MIN_DAYS_SINCE_BEST = 21;
381
412
  var PLATEAU_RECENT_DAYS = 21;
413
+ var PLATEAU_MIN_SESSIONS_MIN = 3;
414
+ var PLATEAU_MIN_SESSIONS_MAX = 8;
382
415
  // Annotate the CommonJS export names for ESM import in node:
383
416
  0 && (module.exports = {
384
417
  ACHIEVEMENT_CATEGORIES,
@@ -395,6 +428,8 @@ var PLATEAU_RECENT_DAYS = 21;
395
428
  MUSCLE_GROUPS,
396
429
  PLATEAU_MIN_DAYS_SINCE_BEST,
397
430
  PLATEAU_MIN_SESSIONS,
431
+ PLATEAU_MIN_SESSIONS_MAX,
432
+ PLATEAU_MIN_SESSIONS_MIN,
398
433
  PLATEAU_RECENT_DAYS,
399
434
  PLATEAU_WINDOW_DAYS,
400
435
  PREFERRED_TRAINING_STYLE_VALUES,
@@ -412,6 +447,9 @@ var PLATEAU_RECENT_DAYS = 21;
412
447
  RENAISSANCE_RANK_DEFINITIONS,
413
448
  REP_TYPES,
414
449
  RESERVED_USERNAMES,
450
+ ROUTINE_DAYS_MAX,
451
+ ROUTINE_DAY_NAME_MAX,
452
+ ROUTINE_SCHEDULE_MODES,
415
453
  SESSION_SHARE_DEFAULT_FIELDS,
416
454
  SESSION_SHARE_FIELDS,
417
455
  SESSION_SHARE_MAX_ACTIVE_LINKS,
@@ -425,5 +463,6 @@ var PLATEAU_RECENT_DAYS = 21;
425
463
  USERNAME_MIN_LENGTH,
426
464
  USERNAME_PATTERN_SOURCE,
427
465
  WEIGHT_UNITS,
428
- WORKOUT_SESSION_STATUSES
466
+ WORKOUT_SESSION_STATUSES,
467
+ routineDayLabel
429
468
  });
package/dist/index.d.cts CHANGED
@@ -66,7 +66,8 @@ interface WorkoutSession {
66
66
  id: string;
67
67
  name?: string | null;
68
68
  order?: number;
69
- dayOfWeek?: number;
69
+ /** Null on a ROTATION routine day (ROUT-11). */
70
+ dayOfWeek?: number | null;
70
71
  exercises: Array<{
71
72
  id: string;
72
73
  order: number;
@@ -616,9 +617,10 @@ interface WorkoutAnalyticsStatus {
616
617
  }
617
618
  /**
618
619
  * Thresholds behind every plateau. A lift is flagged only when all hold: at
619
- * least `PLATEAU_MIN_SESSIONS` terminal sessions with completed loaded sets
620
- * of it since its current best (the session that set the best excluded, and
621
- * counting only inside the look-back window), the best is at least
620
+ * least the account's minimum sessions (`PLATEAU_MIN_SESSIONS` by default)
621
+ * of terminal sessions with completed loaded sets of it since its current
622
+ * best (the session that set the best excluded, and counting only inside the
623
+ * look-back window), the best is at least
622
624
  * `PLATEAU_MIN_DAYS_SINCE_BEST` days old, and the lift was trained within the
623
625
  * last `PLATEAU_RECENT_DAYS` days. They describe numbers, never a cause.
624
626
  */
@@ -626,6 +628,16 @@ declare const PLATEAU_WINDOW_DAYS = 56;
626
628
  declare const PLATEAU_MIN_SESSIONS = 4;
627
629
  declare const PLATEAU_MIN_DAYS_SINCE_BEST = 21;
628
630
  declare const PLATEAU_RECENT_DAYS = 21;
631
+ /**
632
+ * PREF-05: each account chooses its minimum sessions within these bounds;
633
+ * `PLATEAU_MIN_SESSIONS` is the default. The other thresholds stay fixed.
634
+ */
635
+ declare const PLATEAU_MIN_SESSIONS_MIN = 3;
636
+ declare const PLATEAU_MIN_SESSIONS_MAX = 8;
637
+ /** Body and response of PUT /users/preferences/plateaus. */
638
+ interface PlateauPreferences {
639
+ minSessions: number;
640
+ }
629
641
  interface PlateauSet {
630
642
  weightKg: number;
631
643
  reps: number;
@@ -654,6 +666,7 @@ interface PlateausResponse {
654
666
  asOf: IsoDateString;
655
667
  thresholds: {
656
668
  windowDays: number;
669
+ /** The account's PREF-05 choice, within the bounds above. */
657
670
  minSessions: number;
658
671
  minDaysSinceBest: number;
659
672
  recentDays: number;
@@ -1094,6 +1107,26 @@ interface AchievementsResponse {
1094
1107
  milestoneProgress: AchievementCategoryProgress[];
1095
1108
  }
1096
1109
 
1110
+ /**
1111
+ * ROUT-11: a WEEKLY routine ties each day to a weekday; a ROTATION routine
1112
+ * runs its days in `order`, each after the last completed one, whatever the
1113
+ * weekday.
1114
+ */
1115
+ declare const ROUTINE_SCHEDULE_MODES: readonly ["WEEKLY", "ROTATION"];
1116
+ type RoutineScheduleMode = (typeof ROUTINE_SCHEDULE_MODES)[number];
1117
+ /** At most seven days in either mode. */
1118
+ declare const ROUTINE_DAYS_MAX = 7;
1119
+ declare const ROUTINE_DAY_NAME_MAX = 40;
1120
+ /**
1121
+ * How a routine day is named everywhere, including history snapshots taken
1122
+ * before ROUT-11: its own name, else its weekday, else its rotation letter
1123
+ * ("Day A" for order 0).
1124
+ */
1125
+ declare function routineDayLabel(day: {
1126
+ name?: string | null;
1127
+ dayOfWeek?: number | null;
1128
+ order?: number | null;
1129
+ }): string;
1097
1130
  interface RoutineSet {
1098
1131
  setNumber: number;
1099
1132
  repType: RepType;
@@ -1129,12 +1162,18 @@ interface CreateRoutineExerciseInput {
1129
1162
  }
1130
1163
  interface RoutineDay {
1131
1164
  id: string;
1132
- dayOfWeek: number;
1165
+ /** 0=Sun..6=Sat on a WEEKLY routine; null on a ROTATION routine. */
1166
+ dayOfWeek: number | null;
1167
+ /** Optional label such as "Push" or "Upper A" (see `routineDayLabel`). */
1168
+ name: string | null;
1169
+ /** Rotation sequence, 0-based; also the display order. */
1133
1170
  order: number;
1134
1171
  exercises: RoutineExercise[];
1135
1172
  }
1136
1173
  interface CreateRoutineDayInput {
1137
- dayOfWeek: number;
1174
+ /** Required and unique on a WEEKLY routine; omitted or null on a ROTATION. */
1175
+ dayOfWeek?: number | null;
1176
+ name?: string | null;
1138
1177
  order?: number;
1139
1178
  exercises: CreateRoutineExerciseInput[];
1140
1179
  }
@@ -1146,6 +1185,12 @@ interface Routine {
1146
1185
  isPeriodized: boolean;
1147
1186
  isFavorite: boolean;
1148
1187
  isCompleted: boolean;
1188
+ scheduleMode: RoutineScheduleMode;
1189
+ /**
1190
+ * ROTATION only: the day after the one of the last completed session (an
1191
+ * aborted session does not advance it), or the first day before any.
1192
+ */
1193
+ nextRotationDayId: string | null;
1149
1194
  days: RoutineDay[];
1150
1195
  createdAt: IsoDateString;
1151
1196
  updatedAt: IsoDateString;
@@ -1154,8 +1199,10 @@ interface CreateRoutineRequest {
1154
1199
  name: string;
1155
1200
  description?: string;
1156
1201
  isPeriodized: boolean;
1202
+ /** Defaults to WEEKLY. Changing it on update requires `days`. */
1203
+ scheduleMode?: RoutineScheduleMode;
1157
1204
  days: CreateRoutineDayInput[];
1158
1205
  }
1159
1206
  type UpdateRoutineRequest = Partial<CreateRoutineRequest>;
1160
1207
 
1161
- export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementUnlockedEventPayload, type AchievementsResponse, type Brand, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateSessionShareRequest, EXERCISE_EQUIPMENT, EXERCISE_MECHANICS, type EarnedAchievement, type EarnedPersonalRecord, type Exercise, type ExerciseEquipment, type ExerciseId, type ExerciseMechanic, type ExercisePerformanceHistoryQuery, type ExercisePerformanceHistoryResponse, type ExercisePerformancePrescription, type ExercisePerformancePrescriptionSet, type ExercisePerformanceSession, type ExercisePerformanceSet, type ExercisePerformanceSummary, type ExercisePlateau, type ExerciseStrengthSummary, type ExerciseStrengthTrendPoint, type ExerciseStrengthTrendQuery, type ExerciseStrengthTrendResponse, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FinishStatus, type FinishWorkoutRequest, type FinishWorkoutResponse, type FollowSuggestion, type FollowSuggestionReason, type FollowSuggestionsResponse, type IsoDateString, type ListSessionsParams, MEASURABLE_GOALS_MAX, MEASURABLE_GOAL_DIRECTIONS, MEASURABLE_GOAL_TYPES, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, PLATEAU_MIN_DAYS_SINCE_BEST, PLATEAU_MIN_SESSIONS, PLATEAU_RECENT_DAYS, PLATEAU_WINDOW_DAYS, PREFERRED_TRAINING_STYLE_VALUES, PROFILE_BIO_MAX_LENGTH, PROFILE_FAVORITE_EXERCISES_MAX, PROFILE_LOCATION_MAX_LENGTH, PROFILE_TRAINING_DISCIPLINES_MAX, PROFILE_TRAINING_GOALS_MAX, PROFILE_VISIBILITY_VALUES, PROGRESSION_SCHEMES, PROGRESS_TIMELINE_EVENT_TYPES, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlatePairInventory, type PlateauSet, type PlateausResponse, type PreferredTrainingStyle, type PreviousPerformanceResponse, type PreviousSessionRecap, type PreviousSetPerformance, type ProfileDiscoverySettings, type ProfileFavoriteExercise, type ProfilePrivacySettings, type ProfileViewerAccess, type ProfileVisibility, type ProgressTimelineEventType, type ProgressTimelineItem, type ProgressTimelinePersonalRecordItem, type ProgressTimelineProgressionItem, type ProgressTimelineQuery, type ProgressTimelineRecordPerformance, type ProgressTimelineRecordReason, type ProgressTimelineResponse, type ProgressTimelineSessionContext, type ProgressionChange, type ProgressionRule, type ProgressionScheme, type ProgressionSetChange, type PublicBodyMetrics, type PublicTrainingSummary, type PublicUserProfile, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, type RecentActivityEntry, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineSet, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type StarredExercise, type StarredExercisesResponse, type StartWorkoutRequest, type StartWorkoutResponse, type StreakMilestoneEventPayload, type SubstituteSessionExerciseRequest, type SubstituteSessionExerciseResponse, type SupabaseAuthResponse, type SupabaseAuthUser, type SupabaseMigrationResponse, TRAINING_DISCIPLINE_VALUES, TRAINING_EVENT_TYPES, TRAINING_EXPERIENCE_LEVEL_VALUES, TRAINING_GOAL_VALUES, type TrainingDiscipline, type TrainingEventType, type TrainingExperienceLevel, type TrainingGoal, type TrainingIdentity, type TrainingLocationPreference, type TrainingLocationPreferenceInput, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateProfileDiscoveryRequest, type UpdateProfilePrivacyRequest, type UpdateProfileRequest, type UpdateRoutineRequest, type UpsertSetLogRequest, type UpsertSetLogResponse, type UserId, type UserProfile, type UserSearchResponse, type VolumeTrendPoint, type VolumeTrendQuery, type VolumeTrendResponse, type VolumeTrendSeries, WEIGHT_UNITS, WORKOUT_SESSION_STATUSES, type WeightUnit, type WorkoutAnalyticsStatus, type WorkoutProgressQuery, type WorkoutProgressResponse, type WorkoutSession, type WorkoutSessionId, type WorkoutSessionListResponse, type WorkoutSessionRecap, type WorkoutSessionSnapshotV1, type WorkoutSessionStatus, type WorkoutSessionSummary, type WorkoutStatsQuery, type WorkoutStatsResponse };
1208
+ export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementUnlockedEventPayload, type AchievementsResponse, type Brand, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateSessionShareRequest, EXERCISE_EQUIPMENT, EXERCISE_MECHANICS, type EarnedAchievement, type EarnedPersonalRecord, type Exercise, type ExerciseEquipment, type ExerciseId, type ExerciseMechanic, type ExercisePerformanceHistoryQuery, type ExercisePerformanceHistoryResponse, type ExercisePerformancePrescription, type ExercisePerformancePrescriptionSet, type ExercisePerformanceSession, type ExercisePerformanceSet, type ExercisePerformanceSummary, type ExercisePlateau, type ExerciseStrengthSummary, type ExerciseStrengthTrendPoint, type ExerciseStrengthTrendQuery, type ExerciseStrengthTrendResponse, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FinishStatus, type FinishWorkoutRequest, type FinishWorkoutResponse, type FollowSuggestion, type FollowSuggestionReason, type FollowSuggestionsResponse, type IsoDateString, type ListSessionsParams, MEASURABLE_GOALS_MAX, MEASURABLE_GOAL_DIRECTIONS, MEASURABLE_GOAL_TYPES, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, PLATEAU_MIN_DAYS_SINCE_BEST, PLATEAU_MIN_SESSIONS, PLATEAU_MIN_SESSIONS_MAX, PLATEAU_MIN_SESSIONS_MIN, PLATEAU_RECENT_DAYS, PLATEAU_WINDOW_DAYS, PREFERRED_TRAINING_STYLE_VALUES, PROFILE_BIO_MAX_LENGTH, PROFILE_FAVORITE_EXERCISES_MAX, PROFILE_LOCATION_MAX_LENGTH, PROFILE_TRAINING_DISCIPLINES_MAX, PROFILE_TRAINING_GOALS_MAX, PROFILE_VISIBILITY_VALUES, PROGRESSION_SCHEMES, PROGRESS_TIMELINE_EVENT_TYPES, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlatePairInventory, type PlateauPreferences, type PlateauSet, type PlateausResponse, type PreferredTrainingStyle, type PreviousPerformanceResponse, type PreviousSessionRecap, type PreviousSetPerformance, type ProfileDiscoverySettings, type ProfileFavoriteExercise, type ProfilePrivacySettings, type ProfileViewerAccess, type ProfileVisibility, type ProgressTimelineEventType, type ProgressTimelineItem, type ProgressTimelinePersonalRecordItem, type ProgressTimelineProgressionItem, type ProgressTimelineQuery, type ProgressTimelineRecordPerformance, type ProgressTimelineRecordReason, type ProgressTimelineResponse, type ProgressTimelineSessionContext, type ProgressionChange, type ProgressionRule, type ProgressionScheme, type ProgressionSetChange, type PublicBodyMetrics, type PublicTrainingSummary, type PublicUserProfile, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, type RecentActivityEntry, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type StarredExercise, type StarredExercisesResponse, type StartWorkoutRequest, type StartWorkoutResponse, type StreakMilestoneEventPayload, type SubstituteSessionExerciseRequest, type SubstituteSessionExerciseResponse, type SupabaseAuthResponse, type SupabaseAuthUser, type SupabaseMigrationResponse, TRAINING_DISCIPLINE_VALUES, TRAINING_EVENT_TYPES, TRAINING_EXPERIENCE_LEVEL_VALUES, TRAINING_GOAL_VALUES, type TrainingDiscipline, type TrainingEventType, type TrainingExperienceLevel, type TrainingGoal, type TrainingIdentity, type TrainingLocationPreference, type TrainingLocationPreferenceInput, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateProfileDiscoveryRequest, type UpdateProfilePrivacyRequest, type UpdateProfileRequest, type UpdateRoutineRequest, type UpsertSetLogRequest, type UpsertSetLogResponse, type UserId, type UserProfile, type UserSearchResponse, type VolumeTrendPoint, type VolumeTrendQuery, type VolumeTrendResponse, type VolumeTrendSeries, WEIGHT_UNITS, WORKOUT_SESSION_STATUSES, type WeightUnit, type WorkoutAnalyticsStatus, type WorkoutProgressQuery, type WorkoutProgressResponse, type WorkoutSession, type WorkoutSessionId, type WorkoutSessionListResponse, type WorkoutSessionRecap, type WorkoutSessionSnapshotV1, type WorkoutSessionStatus, type WorkoutSessionSummary, type WorkoutStatsQuery, type WorkoutStatsResponse, routineDayLabel };
package/dist/index.d.ts CHANGED
@@ -66,7 +66,8 @@ interface WorkoutSession {
66
66
  id: string;
67
67
  name?: string | null;
68
68
  order?: number;
69
- dayOfWeek?: number;
69
+ /** Null on a ROTATION routine day (ROUT-11). */
70
+ dayOfWeek?: number | null;
70
71
  exercises: Array<{
71
72
  id: string;
72
73
  order: number;
@@ -616,9 +617,10 @@ interface WorkoutAnalyticsStatus {
616
617
  }
617
618
  /**
618
619
  * Thresholds behind every plateau. A lift is flagged only when all hold: at
619
- * least `PLATEAU_MIN_SESSIONS` terminal sessions with completed loaded sets
620
- * of it since its current best (the session that set the best excluded, and
621
- * counting only inside the look-back window), the best is at least
620
+ * least the account's minimum sessions (`PLATEAU_MIN_SESSIONS` by default)
621
+ * of terminal sessions with completed loaded sets of it since its current
622
+ * best (the session that set the best excluded, and counting only inside the
623
+ * look-back window), the best is at least
622
624
  * `PLATEAU_MIN_DAYS_SINCE_BEST` days old, and the lift was trained within the
623
625
  * last `PLATEAU_RECENT_DAYS` days. They describe numbers, never a cause.
624
626
  */
@@ -626,6 +628,16 @@ declare const PLATEAU_WINDOW_DAYS = 56;
626
628
  declare const PLATEAU_MIN_SESSIONS = 4;
627
629
  declare const PLATEAU_MIN_DAYS_SINCE_BEST = 21;
628
630
  declare const PLATEAU_RECENT_DAYS = 21;
631
+ /**
632
+ * PREF-05: each account chooses its minimum sessions within these bounds;
633
+ * `PLATEAU_MIN_SESSIONS` is the default. The other thresholds stay fixed.
634
+ */
635
+ declare const PLATEAU_MIN_SESSIONS_MIN = 3;
636
+ declare const PLATEAU_MIN_SESSIONS_MAX = 8;
637
+ /** Body and response of PUT /users/preferences/plateaus. */
638
+ interface PlateauPreferences {
639
+ minSessions: number;
640
+ }
629
641
  interface PlateauSet {
630
642
  weightKg: number;
631
643
  reps: number;
@@ -654,6 +666,7 @@ interface PlateausResponse {
654
666
  asOf: IsoDateString;
655
667
  thresholds: {
656
668
  windowDays: number;
669
+ /** The account's PREF-05 choice, within the bounds above. */
657
670
  minSessions: number;
658
671
  minDaysSinceBest: number;
659
672
  recentDays: number;
@@ -1094,6 +1107,26 @@ interface AchievementsResponse {
1094
1107
  milestoneProgress: AchievementCategoryProgress[];
1095
1108
  }
1096
1109
 
1110
+ /**
1111
+ * ROUT-11: a WEEKLY routine ties each day to a weekday; a ROTATION routine
1112
+ * runs its days in `order`, each after the last completed one, whatever the
1113
+ * weekday.
1114
+ */
1115
+ declare const ROUTINE_SCHEDULE_MODES: readonly ["WEEKLY", "ROTATION"];
1116
+ type RoutineScheduleMode = (typeof ROUTINE_SCHEDULE_MODES)[number];
1117
+ /** At most seven days in either mode. */
1118
+ declare const ROUTINE_DAYS_MAX = 7;
1119
+ declare const ROUTINE_DAY_NAME_MAX = 40;
1120
+ /**
1121
+ * How a routine day is named everywhere, including history snapshots taken
1122
+ * before ROUT-11: its own name, else its weekday, else its rotation letter
1123
+ * ("Day A" for order 0).
1124
+ */
1125
+ declare function routineDayLabel(day: {
1126
+ name?: string | null;
1127
+ dayOfWeek?: number | null;
1128
+ order?: number | null;
1129
+ }): string;
1097
1130
  interface RoutineSet {
1098
1131
  setNumber: number;
1099
1132
  repType: RepType;
@@ -1129,12 +1162,18 @@ interface CreateRoutineExerciseInput {
1129
1162
  }
1130
1163
  interface RoutineDay {
1131
1164
  id: string;
1132
- dayOfWeek: number;
1165
+ /** 0=Sun..6=Sat on a WEEKLY routine; null on a ROTATION routine. */
1166
+ dayOfWeek: number | null;
1167
+ /** Optional label such as "Push" or "Upper A" (see `routineDayLabel`). */
1168
+ name: string | null;
1169
+ /** Rotation sequence, 0-based; also the display order. */
1133
1170
  order: number;
1134
1171
  exercises: RoutineExercise[];
1135
1172
  }
1136
1173
  interface CreateRoutineDayInput {
1137
- dayOfWeek: number;
1174
+ /** Required and unique on a WEEKLY routine; omitted or null on a ROTATION. */
1175
+ dayOfWeek?: number | null;
1176
+ name?: string | null;
1138
1177
  order?: number;
1139
1178
  exercises: CreateRoutineExerciseInput[];
1140
1179
  }
@@ -1146,6 +1185,12 @@ interface Routine {
1146
1185
  isPeriodized: boolean;
1147
1186
  isFavorite: boolean;
1148
1187
  isCompleted: boolean;
1188
+ scheduleMode: RoutineScheduleMode;
1189
+ /**
1190
+ * ROTATION only: the day after the one of the last completed session (an
1191
+ * aborted session does not advance it), or the first day before any.
1192
+ */
1193
+ nextRotationDayId: string | null;
1149
1194
  days: RoutineDay[];
1150
1195
  createdAt: IsoDateString;
1151
1196
  updatedAt: IsoDateString;
@@ -1154,8 +1199,10 @@ interface CreateRoutineRequest {
1154
1199
  name: string;
1155
1200
  description?: string;
1156
1201
  isPeriodized: boolean;
1202
+ /** Defaults to WEEKLY. Changing it on update requires `days`. */
1203
+ scheduleMode?: RoutineScheduleMode;
1157
1204
  days: CreateRoutineDayInput[];
1158
1205
  }
1159
1206
  type UpdateRoutineRequest = Partial<CreateRoutineRequest>;
1160
1207
 
1161
- export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementUnlockedEventPayload, type AchievementsResponse, type Brand, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateSessionShareRequest, EXERCISE_EQUIPMENT, EXERCISE_MECHANICS, type EarnedAchievement, type EarnedPersonalRecord, type Exercise, type ExerciseEquipment, type ExerciseId, type ExerciseMechanic, type ExercisePerformanceHistoryQuery, type ExercisePerformanceHistoryResponse, type ExercisePerformancePrescription, type ExercisePerformancePrescriptionSet, type ExercisePerformanceSession, type ExercisePerformanceSet, type ExercisePerformanceSummary, type ExercisePlateau, type ExerciseStrengthSummary, type ExerciseStrengthTrendPoint, type ExerciseStrengthTrendQuery, type ExerciseStrengthTrendResponse, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FinishStatus, type FinishWorkoutRequest, type FinishWorkoutResponse, type FollowSuggestion, type FollowSuggestionReason, type FollowSuggestionsResponse, type IsoDateString, type ListSessionsParams, MEASURABLE_GOALS_MAX, MEASURABLE_GOAL_DIRECTIONS, MEASURABLE_GOAL_TYPES, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, PLATEAU_MIN_DAYS_SINCE_BEST, PLATEAU_MIN_SESSIONS, PLATEAU_RECENT_DAYS, PLATEAU_WINDOW_DAYS, PREFERRED_TRAINING_STYLE_VALUES, PROFILE_BIO_MAX_LENGTH, PROFILE_FAVORITE_EXERCISES_MAX, PROFILE_LOCATION_MAX_LENGTH, PROFILE_TRAINING_DISCIPLINES_MAX, PROFILE_TRAINING_GOALS_MAX, PROFILE_VISIBILITY_VALUES, PROGRESSION_SCHEMES, PROGRESS_TIMELINE_EVENT_TYPES, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlatePairInventory, type PlateauSet, type PlateausResponse, type PreferredTrainingStyle, type PreviousPerformanceResponse, type PreviousSessionRecap, type PreviousSetPerformance, type ProfileDiscoverySettings, type ProfileFavoriteExercise, type ProfilePrivacySettings, type ProfileViewerAccess, type ProfileVisibility, type ProgressTimelineEventType, type ProgressTimelineItem, type ProgressTimelinePersonalRecordItem, type ProgressTimelineProgressionItem, type ProgressTimelineQuery, type ProgressTimelineRecordPerformance, type ProgressTimelineRecordReason, type ProgressTimelineResponse, type ProgressTimelineSessionContext, type ProgressionChange, type ProgressionRule, type ProgressionScheme, type ProgressionSetChange, type PublicBodyMetrics, type PublicTrainingSummary, type PublicUserProfile, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, type RecentActivityEntry, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineSet, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type StarredExercise, type StarredExercisesResponse, type StartWorkoutRequest, type StartWorkoutResponse, type StreakMilestoneEventPayload, type SubstituteSessionExerciseRequest, type SubstituteSessionExerciseResponse, type SupabaseAuthResponse, type SupabaseAuthUser, type SupabaseMigrationResponse, TRAINING_DISCIPLINE_VALUES, TRAINING_EVENT_TYPES, TRAINING_EXPERIENCE_LEVEL_VALUES, TRAINING_GOAL_VALUES, type TrainingDiscipline, type TrainingEventType, type TrainingExperienceLevel, type TrainingGoal, type TrainingIdentity, type TrainingLocationPreference, type TrainingLocationPreferenceInput, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateProfileDiscoveryRequest, type UpdateProfilePrivacyRequest, type UpdateProfileRequest, type UpdateRoutineRequest, type UpsertSetLogRequest, type UpsertSetLogResponse, type UserId, type UserProfile, type UserSearchResponse, type VolumeTrendPoint, type VolumeTrendQuery, type VolumeTrendResponse, type VolumeTrendSeries, WEIGHT_UNITS, WORKOUT_SESSION_STATUSES, type WeightUnit, type WorkoutAnalyticsStatus, type WorkoutProgressQuery, type WorkoutProgressResponse, type WorkoutSession, type WorkoutSessionId, type WorkoutSessionListResponse, type WorkoutSessionRecap, type WorkoutSessionSnapshotV1, type WorkoutSessionStatus, type WorkoutSessionSummary, type WorkoutStatsQuery, type WorkoutStatsResponse };
1208
+ export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementUnlockedEventPayload, type AchievementsResponse, type Brand, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateSessionShareRequest, EXERCISE_EQUIPMENT, EXERCISE_MECHANICS, type EarnedAchievement, type EarnedPersonalRecord, type Exercise, type ExerciseEquipment, type ExerciseId, type ExerciseMechanic, type ExercisePerformanceHistoryQuery, type ExercisePerformanceHistoryResponse, type ExercisePerformancePrescription, type ExercisePerformancePrescriptionSet, type ExercisePerformanceSession, type ExercisePerformanceSet, type ExercisePerformanceSummary, type ExercisePlateau, type ExerciseStrengthSummary, type ExerciseStrengthTrendPoint, type ExerciseStrengthTrendQuery, type ExerciseStrengthTrendResponse, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FinishStatus, type FinishWorkoutRequest, type FinishWorkoutResponse, type FollowSuggestion, type FollowSuggestionReason, type FollowSuggestionsResponse, type IsoDateString, type ListSessionsParams, MEASURABLE_GOALS_MAX, MEASURABLE_GOAL_DIRECTIONS, MEASURABLE_GOAL_TYPES, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, PLATEAU_MIN_DAYS_SINCE_BEST, PLATEAU_MIN_SESSIONS, PLATEAU_MIN_SESSIONS_MAX, PLATEAU_MIN_SESSIONS_MIN, PLATEAU_RECENT_DAYS, PLATEAU_WINDOW_DAYS, PREFERRED_TRAINING_STYLE_VALUES, PROFILE_BIO_MAX_LENGTH, PROFILE_FAVORITE_EXERCISES_MAX, PROFILE_LOCATION_MAX_LENGTH, PROFILE_TRAINING_DISCIPLINES_MAX, PROFILE_TRAINING_GOALS_MAX, PROFILE_VISIBILITY_VALUES, PROGRESSION_SCHEMES, PROGRESS_TIMELINE_EVENT_TYPES, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlatePairInventory, type PlateauPreferences, type PlateauSet, type PlateausResponse, type PreferredTrainingStyle, type PreviousPerformanceResponse, type PreviousSessionRecap, type PreviousSetPerformance, type ProfileDiscoverySettings, type ProfileFavoriteExercise, type ProfilePrivacySettings, type ProfileViewerAccess, type ProfileVisibility, type ProgressTimelineEventType, type ProgressTimelineItem, type ProgressTimelinePersonalRecordItem, type ProgressTimelineProgressionItem, type ProgressTimelineQuery, type ProgressTimelineRecordPerformance, type ProgressTimelineRecordReason, type ProgressTimelineResponse, type ProgressTimelineSessionContext, type ProgressionChange, type ProgressionRule, type ProgressionScheme, type ProgressionSetChange, type PublicBodyMetrics, type PublicTrainingSummary, type PublicUserProfile, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, type RecentActivityEntry, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type StarredExercise, type StarredExercisesResponse, type StartWorkoutRequest, type StartWorkoutResponse, type StreakMilestoneEventPayload, type SubstituteSessionExerciseRequest, type SubstituteSessionExerciseResponse, type SupabaseAuthResponse, type SupabaseAuthUser, type SupabaseMigrationResponse, TRAINING_DISCIPLINE_VALUES, TRAINING_EVENT_TYPES, TRAINING_EXPERIENCE_LEVEL_VALUES, TRAINING_GOAL_VALUES, type TrainingDiscipline, type TrainingEventType, type TrainingExperienceLevel, type TrainingGoal, type TrainingIdentity, type TrainingLocationPreference, type TrainingLocationPreferenceInput, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateProfileDiscoveryRequest, type UpdateProfilePrivacyRequest, type UpdateProfileRequest, type UpdateRoutineRequest, type UpsertSetLogRequest, type UpsertSetLogResponse, type UserId, type UserProfile, type UserSearchResponse, type VolumeTrendPoint, type VolumeTrendQuery, type VolumeTrendResponse, type VolumeTrendSeries, WEIGHT_UNITS, WORKOUT_SESSION_STATUSES, type WeightUnit, type WorkoutAnalyticsStatus, type WorkoutProgressQuery, type WorkoutProgressResponse, type WorkoutSession, type WorkoutSessionId, type WorkoutSessionListResponse, type WorkoutSessionRecap, type WorkoutSessionSnapshotV1, type WorkoutSessionStatus, type WorkoutSessionSummary, type WorkoutStatsQuery, type WorkoutStatsResponse, routineDayLabel };
package/dist/index.js CHANGED
@@ -276,6 +276,31 @@ var RENAISSANCE_RANK_DEFINITIONS = [
276
276
  }
277
277
  ];
278
278
 
279
+ // src/routine.ts
280
+ var ROUTINE_SCHEDULE_MODES = ["WEEKLY", "ROTATION"];
281
+ var ROUTINE_DAYS_MAX = 7;
282
+ var ROUTINE_DAY_NAME_MAX = 40;
283
+ var WEEKDAY_NAMES = [
284
+ "Sunday",
285
+ "Monday",
286
+ "Tuesday",
287
+ "Wednesday",
288
+ "Thursday",
289
+ "Friday",
290
+ "Saturday"
291
+ ];
292
+ function routineDayLabel(day) {
293
+ const name = day.name?.trim();
294
+ if (name) return name;
295
+ if (typeof day.dayOfWeek === "number") {
296
+ return WEEKDAY_NAMES[day.dayOfWeek] ?? "";
297
+ }
298
+ if (typeof day.order === "number" && day.order >= 0 && day.order < 26) {
299
+ return `Day ${String.fromCharCode(65 + day.order)}`;
300
+ }
301
+ return "";
302
+ }
303
+
279
304
  // src/workout.ts
280
305
  var SESSION_SHARE_FIELDS = [
281
306
  "duration",
@@ -309,6 +334,8 @@ var PLATEAU_WINDOW_DAYS = 56;
309
334
  var PLATEAU_MIN_SESSIONS = 4;
310
335
  var PLATEAU_MIN_DAYS_SINCE_BEST = 21;
311
336
  var PLATEAU_RECENT_DAYS = 21;
337
+ var PLATEAU_MIN_SESSIONS_MIN = 3;
338
+ var PLATEAU_MIN_SESSIONS_MAX = 8;
312
339
  export {
313
340
  ACHIEVEMENT_CATEGORIES,
314
341
  ACHIEVEMENT_DEFINITIONS,
@@ -324,6 +351,8 @@ export {
324
351
  MUSCLE_GROUPS,
325
352
  PLATEAU_MIN_DAYS_SINCE_BEST,
326
353
  PLATEAU_MIN_SESSIONS,
354
+ PLATEAU_MIN_SESSIONS_MAX,
355
+ PLATEAU_MIN_SESSIONS_MIN,
327
356
  PLATEAU_RECENT_DAYS,
328
357
  PLATEAU_WINDOW_DAYS,
329
358
  PREFERRED_TRAINING_STYLE_VALUES,
@@ -341,6 +370,9 @@ export {
341
370
  RENAISSANCE_RANK_DEFINITIONS,
342
371
  REP_TYPES,
343
372
  RESERVED_USERNAMES,
373
+ ROUTINE_DAYS_MAX,
374
+ ROUTINE_DAY_NAME_MAX,
375
+ ROUTINE_SCHEDULE_MODES,
344
376
  SESSION_SHARE_DEFAULT_FIELDS,
345
377
  SESSION_SHARE_FIELDS,
346
378
  SESSION_SHARE_MAX_ACTIVE_LINKS,
@@ -354,5 +386,6 @@ export {
354
386
  USERNAME_MIN_LENGTH,
355
387
  USERNAME_PATTERN_SOURCE,
356
388
  WEIGHT_UNITS,
357
- WORKOUT_SESSION_STATUSES
389
+ WORKOUT_SESSION_STATUSES,
390
+ routineDayLabel
358
391
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunsteel/contracts",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ezee969/sunsteel-contracts.git"