@sunsteel/contracts 0.46.0 → 0.47.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
@@ -38,11 +38,13 @@ __export(index_exports, {
38
38
  MEASURABLE_GOALS_MAX: () => MEASURABLE_GOALS_MAX,
39
39
  MEASURABLE_GOAL_DIRECTIONS: () => MEASURABLE_GOAL_DIRECTIONS,
40
40
  MEASURABLE_GOAL_TYPES: () => MEASURABLE_GOAL_TYPES,
41
+ MINUTES_IN_DAY: () => MINUTES_IN_DAY,
41
42
  MOVEMENT_PATTERNS: () => MOVEMENT_PATTERNS,
42
43
  MUSCLE_GROUPS: () => MUSCLE_GROUPS,
43
44
  NOTIFICATIONS_LIST_LIMIT: () => NOTIFICATIONS_LIST_LIMIT,
44
45
  NOTIFICATIONS_LOOKBACK_DAYS: () => NOTIFICATIONS_LOOKBACK_DAYS,
45
46
  NOTIFICATIONS_RETENTION_DAYS: () => NOTIFICATIONS_RETENTION_DAYS,
47
+ NOTIFICATION_CATEGORIES: () => NOTIFICATION_CATEGORIES,
46
48
  NOTIFICATION_KINDS: () => NOTIFICATION_KINDS,
47
49
  PLATEAU_MIN_DAYS_SINCE_BEST: () => PLATEAU_MIN_DAYS_SINCE_BEST,
48
50
  PLATEAU_MIN_SESSIONS: () => PLATEAU_MIN_SESSIONS,
@@ -94,6 +96,7 @@ __export(index_exports, {
94
96
  USERNAME_PATTERN_SOURCE: () => USERNAME_PATTERN_SOURCE,
95
97
  WEIGHT_UNITS: () => WEIGHT_UNITS,
96
98
  WORKOUT_SESSION_STATUSES: () => WORKOUT_SESSION_STATUSES,
99
+ isWithinQuietHours: () => isWithinQuietHours,
97
100
  routineDayLabel: () => routineDayLabel
98
101
  });
99
102
  module.exports = __toCommonJS(index_exports);
@@ -470,7 +473,7 @@ var NOTIFICATIONS_LIST_LIMIT = 50;
470
473
 
471
474
  // src/push.ts
472
475
  var PUSH_SUBSCRIPTIONS_MAX = 10;
473
- var PUSH_PAYLOAD_KINDS = ["REST_ALERT"];
476
+ var PUSH_PAYLOAD_KINDS = ["REST_ALERT", "TRAINING_REMINDER"];
474
477
  var REST_ALERT_MAX_LEAD_SECONDS = 3600;
475
478
  var REST_ALERT_MIN_LEAD_SECONDS = 5;
476
479
  var REST_ALERT_REFUSALS = [
@@ -479,8 +482,25 @@ var REST_ALERT_REFUSALS = [
479
482
  /** The server holds no VAPID key pair. */
480
483
  "PUSH_UNAVAILABLE",
481
484
  /** Rest ends too soon for a push to beat it. */
482
- "TOO_SOON"
485
+ "TOO_SOON",
486
+ /** NOTIF-05: the owner switched rest alerts off. */
487
+ "CATEGORY_OFF",
488
+ /** NOTIF-05: rest would end inside the owner's quiet hours. */
489
+ "QUIET_HOURS"
483
490
  ];
491
+
492
+ // src/notification-preferences.ts
493
+ var NOTIFICATION_CATEGORIES = [
494
+ "REST_ALERT",
495
+ "TRAINING_REMINDER"
496
+ ];
497
+ var MINUTES_IN_DAY = 1440;
498
+ function isWithinQuietHours(minuteOfDay, quietHours) {
499
+ if (!quietHours) return false;
500
+ const { startMinute, endMinute } = quietHours;
501
+ if (startMinute === endMinute) return false;
502
+ return startMinute < endMinute ? minuteOfDay >= startMinute && minuteOfDay < endMinute : minuteOfDay >= startMinute || minuteOfDay < endMinute;
503
+ }
484
504
  // Annotate the CommonJS export names for ESM import in node:
485
505
  0 && (module.exports = {
486
506
  ACHIEVEMENT_CATEGORIES,
@@ -501,11 +521,13 @@ var REST_ALERT_REFUSALS = [
501
521
  MEASURABLE_GOALS_MAX,
502
522
  MEASURABLE_GOAL_DIRECTIONS,
503
523
  MEASURABLE_GOAL_TYPES,
524
+ MINUTES_IN_DAY,
504
525
  MOVEMENT_PATTERNS,
505
526
  MUSCLE_GROUPS,
506
527
  NOTIFICATIONS_LIST_LIMIT,
507
528
  NOTIFICATIONS_LOOKBACK_DAYS,
508
529
  NOTIFICATIONS_RETENTION_DAYS,
530
+ NOTIFICATION_CATEGORIES,
509
531
  NOTIFICATION_KINDS,
510
532
  PLATEAU_MIN_DAYS_SINCE_BEST,
511
533
  PLATEAU_MIN_SESSIONS,
@@ -557,5 +579,6 @@ var REST_ALERT_REFUSALS = [
557
579
  USERNAME_PATTERN_SOURCE,
558
580
  WEIGHT_UNITS,
559
581
  WORKOUT_SESSION_STATUSES,
582
+ isWithinQuietHours,
560
583
  routineDayLabel
561
584
  });
package/dist/index.d.cts CHANGED
@@ -1539,7 +1539,7 @@ interface DeletePushSubscriptionRequest {
1539
1539
  * What a delivered push asks the service worker to show. `kind` exists so the
1540
1540
  * worker can branch without guessing from the copy.
1541
1541
  */
1542
- declare const PUSH_PAYLOAD_KINDS: readonly ["REST_ALERT"];
1542
+ declare const PUSH_PAYLOAD_KINDS: readonly ["REST_ALERT", "TRAINING_REMINDER"];
1543
1543
  type PushPayloadKind = (typeof PUSH_PAYLOAD_KINDS)[number];
1544
1544
  interface RestAlertPushPayload {
1545
1545
  kind: 'REST_ALERT';
@@ -1555,7 +1555,15 @@ interface RestAlertPushPayload {
1555
1555
  /** Collapses an older alert for the same session instead of stacking. */
1556
1556
  tag: string;
1557
1557
  }
1558
- type PushPayload = RestAlertPushPayload;
1558
+ /** NOTIF-04. Planned for a local date, so it names days, never an hour. */
1559
+ interface TrainingReminderPushPayload {
1560
+ kind: 'TRAINING_REMINDER';
1561
+ title: string;
1562
+ body: string;
1563
+ url: string;
1564
+ tag: string;
1565
+ }
1566
+ type PushPayload = RestAlertPushPayload | TrainingReminderPushPayload;
1559
1567
  /** A rest alert is refused beyond this far ahead. */
1560
1568
  declare const REST_ALERT_MAX_LEAD_SECONDS = 3600;
1561
1569
  /**
@@ -1580,7 +1588,84 @@ interface ScheduleRestAlertResponse {
1580
1588
  scheduledFor: IsoDateString | null;
1581
1589
  reason: RestAlertRefusal | null;
1582
1590
  }
1583
- declare const REST_ALERT_REFUSALS: readonly ["NO_SUBSCRIPTION", "PUSH_UNAVAILABLE", "TOO_SOON"];
1591
+ declare const REST_ALERT_REFUSALS: readonly ["NO_SUBSCRIPTION", "PUSH_UNAVAILABLE", "TOO_SOON", "CATEGORY_OFF", "QUIET_HOURS"];
1584
1592
  type RestAlertRefusal = (typeof REST_ALERT_REFUSALS)[number];
1585
1593
 
1586
- export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementNotification, type AchievementUnlockedEventPayload, type AchievementsResponse, type AppNotification, type Brand, COMEBACK_MIN_INACTIVE_DAYS, COMEBACK_RECOGNITION_LIMIT, COMEBACK_REQUIRED_ACTIVE_DAYS, COMEBACK_SESSION_LOOKBACK, COMEBACK_WINDOW_DAYS, type CalendarDate, type ComebackRecognition, type ComebackRecognitionSummary, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateRoutineVersionRequest, type CreateSessionShareRequest, type DeletePushSubscriptionRequest, 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, FEATURED_PROFILE_ITEMS_MAX, FEATURED_PROFILE_ITEM_KINDS, FEATURED_PROFILE_REFERENCE_MAX_LENGTH, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FeaturedProfileAchievementItem, type FeaturedProfileItem, type FeaturedProfileItemKind, type FeaturedProfileRankItem, type FeaturedProfileRecordItem, type FeaturedProfileSelection, type FeaturedProfileSelectionInput, type FeaturedProfileSelectionsResponse, 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 MarkNotificationsReadRequest, type MarkNotificationsReadResponse, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MoveOccurrenceRequest, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, NOTIFICATIONS_LIST_LIMIT, NOTIFICATIONS_LOOKBACK_DAYS, NOTIFICATIONS_RETENTION_DAYS, NOTIFICATION_KINDS, type NewFollowerNotification, type NotificationKind, type NotificationsResponse, 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, PUSH_PAYLOAD_KINDS, PUSH_SUBSCRIPTIONS_MAX, 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 PublicProfileAchievements, type PublicTrainingSummary, type PublicUserProfile, type PushPayload, type PushPayloadKind, type PushSubscriptionKeys, type PushSubscriptionSummary, type PushSubscriptionsResponse, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, REST_ALERT_MAX_LEAD_SECONDS, REST_ALERT_MIN_LEAD_SECONDS, REST_ALERT_REFUSALS, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, ROUTINE_VERSIONS_MAX, ROUTINE_VERSION_KINDS, ROUTINE_VERSION_NAME_MAX, type RecentActivityEntry, type RegisterPushSubscriptionRequest, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceFeaturedProfileItemsRequest, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type RestAlertPushPayload, type RestAlertRefusal, type RestoreRoutineVersionResponse, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, type RoutineVersion, type RoutineVersionDay, type RoutineVersionExercise, type RoutineVersionKind, type RoutineVersionSetup, type RoutineVersionsResponse, SCHEDULE_MOVE_MAX_DAYS, SCHEDULE_OVERRIDES_MAX_RANGE_DAYS, SCHEDULE_OVERRIDE_KINDS, SCHEDULE_SKIP_PAST_DAYS, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type ScheduleOverride, type ScheduleOverrideKind, type ScheduleOverridesQuery, type ScheduleOverridesResponse, type ScheduleRestAlertRequest, type ScheduleRestAlertResponse, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionProgressNotification, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type SkipOccurrenceRequest, 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 };
1594
+ /**
1595
+ * What a notification can be about. Every delivered payload names one, and an
1596
+ * owner can switch each off independently.
1597
+ *
1598
+ * There is deliberately no "channel" axis beside this. Web Push is the only
1599
+ * delivery channel that exists, so a channel switch would be the same switch
1600
+ * twice; the NOTIF-01 centre is gathered on read rather than delivered, and is
1601
+ * not something to turn off.
1602
+ */
1603
+ declare const NOTIFICATION_CATEGORIES: readonly ["REST_ALERT", "TRAINING_REMINDER"];
1604
+ type NotificationCategory = (typeof NOTIFICATION_CATEGORIES)[number];
1605
+ /**
1606
+ * A local-clock window in which nothing is delivered, as minutes from
1607
+ * midnight. It may wrap past midnight (22:00 to 07:00 is `1320` to `420`),
1608
+ * which is the normal case, so a plain `start <= x < end` test is wrong.
1609
+ */
1610
+ interface QuietHours {
1611
+ startMinute: number;
1612
+ endMinute: number;
1613
+ }
1614
+ declare const MINUTES_IN_DAY = 1440;
1615
+ /** True when a local minute-of-day falls inside the window, wrap included. */
1616
+ declare function isWithinQuietHours(minuteOfDay: number, quietHours: QuietHours | null): boolean;
1617
+ /**
1618
+ * NOTIF-04's reminder time, as minutes from local midnight.
1619
+ *
1620
+ * It is a time of day, not a lead time before a session, because the product
1621
+ * does not know what hour anyone trains: a routine day carries a weekday and
1622
+ * nothing stores an intended start. Counting back from a session would mean
1623
+ * inventing the session's hour.
1624
+ */
1625
+ interface TrainingReminderPreference {
1626
+ /** Null switches reminders off without discarding the chosen time. */
1627
+ minuteOfDay: number | null;
1628
+ }
1629
+ interface NotificationPreferences {
1630
+ /** Every category, so a client never has to assume a default. */
1631
+ categories: Record<NotificationCategory, boolean>;
1632
+ quietHours: QuietHours | null;
1633
+ reminder: TrainingReminderPreference;
1634
+ /**
1635
+ * The zone every local rule above is evaluated in. Read-only here; it is
1636
+ * owned by `PUT /users/time-zone` and registered by the device.
1637
+ */
1638
+ timeZone: string | null;
1639
+ }
1640
+ /** PUT /notifications/preferences. Every field is optional and partial. */
1641
+ interface UpdateNotificationPreferencesRequest {
1642
+ categories?: Partial<Record<NotificationCategory, boolean>>;
1643
+ /** Null clears the window; omitting it leaves the stored one alone. */
1644
+ quietHours?: QuietHours | null;
1645
+ reminder?: TrainingReminderPreference;
1646
+ }
1647
+ /**
1648
+ * GET /notifications/preferences
1649
+ *
1650
+ * Carries the delivery state beside the preferences so one read answers both
1651
+ * "what did I choose" and "can any of it actually reach me" — a category left
1652
+ * on while no device is subscribed would otherwise read as working.
1653
+ */
1654
+ interface NotificationPreferencesResponse {
1655
+ preferences: NotificationPreferences;
1656
+ /** False when the account has no subscribed device. */
1657
+ hasSubscribedDevice: boolean;
1658
+ /** False when the server holds no VAPID key pair. */
1659
+ pushAvailable: boolean;
1660
+ }
1661
+ /**
1662
+ * A reminder is planned for a whole local date, not a session: the schedule
1663
+ * knows which days an account trains, never at what hour.
1664
+ */
1665
+ interface PlannedReminder {
1666
+ date: CalendarDate;
1667
+ /** The routines planned that day, named in the notification. */
1668
+ routineNames: string[];
1669
+ }
1670
+
1671
+ export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementNotification, type AchievementUnlockedEventPayload, type AchievementsResponse, type AppNotification, type Brand, COMEBACK_MIN_INACTIVE_DAYS, COMEBACK_RECOGNITION_LIMIT, COMEBACK_REQUIRED_ACTIVE_DAYS, COMEBACK_SESSION_LOOKBACK, COMEBACK_WINDOW_DAYS, type CalendarDate, type ComebackRecognition, type ComebackRecognitionSummary, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateRoutineVersionRequest, type CreateSessionShareRequest, type DeletePushSubscriptionRequest, 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, FEATURED_PROFILE_ITEMS_MAX, FEATURED_PROFILE_ITEM_KINDS, FEATURED_PROFILE_REFERENCE_MAX_LENGTH, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FeaturedProfileAchievementItem, type FeaturedProfileItem, type FeaturedProfileItemKind, type FeaturedProfileRankItem, type FeaturedProfileRecordItem, type FeaturedProfileSelection, type FeaturedProfileSelectionInput, type FeaturedProfileSelectionsResponse, 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, MINUTES_IN_DAY, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MarkNotificationsReadRequest, type MarkNotificationsReadResponse, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MoveOccurrenceRequest, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, NOTIFICATIONS_LIST_LIMIT, NOTIFICATIONS_LOOKBACK_DAYS, NOTIFICATIONS_RETENTION_DAYS, NOTIFICATION_CATEGORIES, NOTIFICATION_KINDS, type NewFollowerNotification, type NotificationCategory, type NotificationKind, type NotificationPreferences, type NotificationPreferencesResponse, type NotificationsResponse, 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, PUSH_PAYLOAD_KINDS, PUSH_SUBSCRIPTIONS_MAX, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlannedReminder, 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 PublicProfileAchievements, type PublicTrainingSummary, type PublicUserProfile, type PushPayload, type PushPayloadKind, type PushSubscriptionKeys, type PushSubscriptionSummary, type PushSubscriptionsResponse, type QuietHours, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, REST_ALERT_MAX_LEAD_SECONDS, REST_ALERT_MIN_LEAD_SECONDS, REST_ALERT_REFUSALS, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, ROUTINE_VERSIONS_MAX, ROUTINE_VERSION_KINDS, ROUTINE_VERSION_NAME_MAX, type RecentActivityEntry, type RegisterPushSubscriptionRequest, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceFeaturedProfileItemsRequest, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type RestAlertPushPayload, type RestAlertRefusal, type RestoreRoutineVersionResponse, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, type RoutineVersion, type RoutineVersionDay, type RoutineVersionExercise, type RoutineVersionKind, type RoutineVersionSetup, type RoutineVersionsResponse, SCHEDULE_MOVE_MAX_DAYS, SCHEDULE_OVERRIDES_MAX_RANGE_DAYS, SCHEDULE_OVERRIDE_KINDS, SCHEDULE_SKIP_PAST_DAYS, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type ScheduleOverride, type ScheduleOverrideKind, type ScheduleOverridesQuery, type ScheduleOverridesResponse, type ScheduleRestAlertRequest, type ScheduleRestAlertResponse, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionProgressNotification, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type SkipOccurrenceRequest, 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, type TrainingReminderPreference, type TrainingReminderPushPayload, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateNotificationPreferencesRequest, 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, isWithinQuietHours, routineDayLabel };
package/dist/index.d.ts CHANGED
@@ -1539,7 +1539,7 @@ interface DeletePushSubscriptionRequest {
1539
1539
  * What a delivered push asks the service worker to show. `kind` exists so the
1540
1540
  * worker can branch without guessing from the copy.
1541
1541
  */
1542
- declare const PUSH_PAYLOAD_KINDS: readonly ["REST_ALERT"];
1542
+ declare const PUSH_PAYLOAD_KINDS: readonly ["REST_ALERT", "TRAINING_REMINDER"];
1543
1543
  type PushPayloadKind = (typeof PUSH_PAYLOAD_KINDS)[number];
1544
1544
  interface RestAlertPushPayload {
1545
1545
  kind: 'REST_ALERT';
@@ -1555,7 +1555,15 @@ interface RestAlertPushPayload {
1555
1555
  /** Collapses an older alert for the same session instead of stacking. */
1556
1556
  tag: string;
1557
1557
  }
1558
- type PushPayload = RestAlertPushPayload;
1558
+ /** NOTIF-04. Planned for a local date, so it names days, never an hour. */
1559
+ interface TrainingReminderPushPayload {
1560
+ kind: 'TRAINING_REMINDER';
1561
+ title: string;
1562
+ body: string;
1563
+ url: string;
1564
+ tag: string;
1565
+ }
1566
+ type PushPayload = RestAlertPushPayload | TrainingReminderPushPayload;
1559
1567
  /** A rest alert is refused beyond this far ahead. */
1560
1568
  declare const REST_ALERT_MAX_LEAD_SECONDS = 3600;
1561
1569
  /**
@@ -1580,7 +1588,84 @@ interface ScheduleRestAlertResponse {
1580
1588
  scheduledFor: IsoDateString | null;
1581
1589
  reason: RestAlertRefusal | null;
1582
1590
  }
1583
- declare const REST_ALERT_REFUSALS: readonly ["NO_SUBSCRIPTION", "PUSH_UNAVAILABLE", "TOO_SOON"];
1591
+ declare const REST_ALERT_REFUSALS: readonly ["NO_SUBSCRIPTION", "PUSH_UNAVAILABLE", "TOO_SOON", "CATEGORY_OFF", "QUIET_HOURS"];
1584
1592
  type RestAlertRefusal = (typeof REST_ALERT_REFUSALS)[number];
1585
1593
 
1586
- export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementNotification, type AchievementUnlockedEventPayload, type AchievementsResponse, type AppNotification, type Brand, COMEBACK_MIN_INACTIVE_DAYS, COMEBACK_RECOGNITION_LIMIT, COMEBACK_REQUIRED_ACTIVE_DAYS, COMEBACK_SESSION_LOOKBACK, COMEBACK_WINDOW_DAYS, type CalendarDate, type ComebackRecognition, type ComebackRecognitionSummary, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateRoutineVersionRequest, type CreateSessionShareRequest, type DeletePushSubscriptionRequest, 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, FEATURED_PROFILE_ITEMS_MAX, FEATURED_PROFILE_ITEM_KINDS, FEATURED_PROFILE_REFERENCE_MAX_LENGTH, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FeaturedProfileAchievementItem, type FeaturedProfileItem, type FeaturedProfileItemKind, type FeaturedProfileRankItem, type FeaturedProfileRecordItem, type FeaturedProfileSelection, type FeaturedProfileSelectionInput, type FeaturedProfileSelectionsResponse, 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 MarkNotificationsReadRequest, type MarkNotificationsReadResponse, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MoveOccurrenceRequest, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, NOTIFICATIONS_LIST_LIMIT, NOTIFICATIONS_LOOKBACK_DAYS, NOTIFICATIONS_RETENTION_DAYS, NOTIFICATION_KINDS, type NewFollowerNotification, type NotificationKind, type NotificationsResponse, 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, PUSH_PAYLOAD_KINDS, PUSH_SUBSCRIPTIONS_MAX, 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 PublicProfileAchievements, type PublicTrainingSummary, type PublicUserProfile, type PushPayload, type PushPayloadKind, type PushSubscriptionKeys, type PushSubscriptionSummary, type PushSubscriptionsResponse, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, REST_ALERT_MAX_LEAD_SECONDS, REST_ALERT_MIN_LEAD_SECONDS, REST_ALERT_REFUSALS, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, ROUTINE_VERSIONS_MAX, ROUTINE_VERSION_KINDS, ROUTINE_VERSION_NAME_MAX, type RecentActivityEntry, type RegisterPushSubscriptionRequest, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceFeaturedProfileItemsRequest, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type RestAlertPushPayload, type RestAlertRefusal, type RestoreRoutineVersionResponse, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, type RoutineVersion, type RoutineVersionDay, type RoutineVersionExercise, type RoutineVersionKind, type RoutineVersionSetup, type RoutineVersionsResponse, SCHEDULE_MOVE_MAX_DAYS, SCHEDULE_OVERRIDES_MAX_RANGE_DAYS, SCHEDULE_OVERRIDE_KINDS, SCHEDULE_SKIP_PAST_DAYS, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type ScheduleOverride, type ScheduleOverrideKind, type ScheduleOverridesQuery, type ScheduleOverridesResponse, type ScheduleRestAlertRequest, type ScheduleRestAlertResponse, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionProgressNotification, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type SkipOccurrenceRequest, 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 };
1594
+ /**
1595
+ * What a notification can be about. Every delivered payload names one, and an
1596
+ * owner can switch each off independently.
1597
+ *
1598
+ * There is deliberately no "channel" axis beside this. Web Push is the only
1599
+ * delivery channel that exists, so a channel switch would be the same switch
1600
+ * twice; the NOTIF-01 centre is gathered on read rather than delivered, and is
1601
+ * not something to turn off.
1602
+ */
1603
+ declare const NOTIFICATION_CATEGORIES: readonly ["REST_ALERT", "TRAINING_REMINDER"];
1604
+ type NotificationCategory = (typeof NOTIFICATION_CATEGORIES)[number];
1605
+ /**
1606
+ * A local-clock window in which nothing is delivered, as minutes from
1607
+ * midnight. It may wrap past midnight (22:00 to 07:00 is `1320` to `420`),
1608
+ * which is the normal case, so a plain `start <= x < end` test is wrong.
1609
+ */
1610
+ interface QuietHours {
1611
+ startMinute: number;
1612
+ endMinute: number;
1613
+ }
1614
+ declare const MINUTES_IN_DAY = 1440;
1615
+ /** True when a local minute-of-day falls inside the window, wrap included. */
1616
+ declare function isWithinQuietHours(minuteOfDay: number, quietHours: QuietHours | null): boolean;
1617
+ /**
1618
+ * NOTIF-04's reminder time, as minutes from local midnight.
1619
+ *
1620
+ * It is a time of day, not a lead time before a session, because the product
1621
+ * does not know what hour anyone trains: a routine day carries a weekday and
1622
+ * nothing stores an intended start. Counting back from a session would mean
1623
+ * inventing the session's hour.
1624
+ */
1625
+ interface TrainingReminderPreference {
1626
+ /** Null switches reminders off without discarding the chosen time. */
1627
+ minuteOfDay: number | null;
1628
+ }
1629
+ interface NotificationPreferences {
1630
+ /** Every category, so a client never has to assume a default. */
1631
+ categories: Record<NotificationCategory, boolean>;
1632
+ quietHours: QuietHours | null;
1633
+ reminder: TrainingReminderPreference;
1634
+ /**
1635
+ * The zone every local rule above is evaluated in. Read-only here; it is
1636
+ * owned by `PUT /users/time-zone` and registered by the device.
1637
+ */
1638
+ timeZone: string | null;
1639
+ }
1640
+ /** PUT /notifications/preferences. Every field is optional and partial. */
1641
+ interface UpdateNotificationPreferencesRequest {
1642
+ categories?: Partial<Record<NotificationCategory, boolean>>;
1643
+ /** Null clears the window; omitting it leaves the stored one alone. */
1644
+ quietHours?: QuietHours | null;
1645
+ reminder?: TrainingReminderPreference;
1646
+ }
1647
+ /**
1648
+ * GET /notifications/preferences
1649
+ *
1650
+ * Carries the delivery state beside the preferences so one read answers both
1651
+ * "what did I choose" and "can any of it actually reach me" — a category left
1652
+ * on while no device is subscribed would otherwise read as working.
1653
+ */
1654
+ interface NotificationPreferencesResponse {
1655
+ preferences: NotificationPreferences;
1656
+ /** False when the account has no subscribed device. */
1657
+ hasSubscribedDevice: boolean;
1658
+ /** False when the server holds no VAPID key pair. */
1659
+ pushAvailable: boolean;
1660
+ }
1661
+ /**
1662
+ * A reminder is planned for a whole local date, not a session: the schedule
1663
+ * knows which days an account trains, never at what hour.
1664
+ */
1665
+ interface PlannedReminder {
1666
+ date: CalendarDate;
1667
+ /** The routines planned that day, named in the notification. */
1668
+ routineNames: string[];
1669
+ }
1670
+
1671
+ export { ACHIEVEMENT_CATEGORIES, ACHIEVEMENT_DEFINITIONS, type AchievementCategory, type AchievementCategoryProgress, type AchievementDefinition, type AchievementNotification, type AchievementUnlockedEventPayload, type AchievementsResponse, type AppNotification, type Brand, COMEBACK_MIN_INACTIVE_DAYS, COMEBACK_RECOGNITION_LIMIT, COMEBACK_REQUIRED_ACTIVE_DAYS, COMEBACK_SESSION_LOOKBACK, COMEBACK_WINDOW_DAYS, type CalendarDate, type ComebackRecognition, type ComebackRecognitionSummary, type CreateRoutineDayInput, type CreateRoutineExerciseInput, type CreateRoutineRequest, type CreateRoutineVersionRequest, type CreateSessionShareRequest, type DeletePushSubscriptionRequest, 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, FEATURED_PROFILE_ITEMS_MAX, FEATURED_PROFILE_ITEM_KINDS, FEATURED_PROFILE_REFERENCE_MAX_LENGTH, FOLLOW_SUGGESTIONS_DEFAULT_LIMIT, FOLLOW_SUGGESTIONS_MAX_LIMIT, FOLLOW_SUGGESTION_REASONS, type FeaturedProfileAchievementItem, type FeaturedProfileItem, type FeaturedProfileItemKind, type FeaturedProfileRankItem, type FeaturedProfileRecordItem, type FeaturedProfileSelection, type FeaturedProfileSelectionInput, type FeaturedProfileSelectionsResponse, 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, MINUTES_IN_DAY, MOVEMENT_PATTERNS, MUSCLE_GROUPS, type MarkNotificationsReadRequest, type MarkNotificationsReadResponse, type MeasurableGoal, type MeasurableGoalDirection, type MeasurableGoalExercise, type MeasurableGoalInput, type MeasurableGoalType, type MoveOccurrenceRequest, type MovementPattern, type MuscleGroup, type MuscleGroupHeatmapQuery, type MuscleGroupHeatmapResponse, type MuscleGroupHeatmapValue, type MuscleGroupHeatmapWeek, type MuscleVolumeTrendSeries, NOTIFICATIONS_LIST_LIMIT, NOTIFICATIONS_LOOKBACK_DAYS, NOTIFICATIONS_RETENTION_DAYS, NOTIFICATION_CATEGORIES, NOTIFICATION_KINDS, type NewFollowerNotification, type NotificationCategory, type NotificationKind, type NotificationPreferences, type NotificationPreferencesResponse, type NotificationsResponse, 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, PUSH_PAYLOAD_KINDS, PUSH_SUBSCRIPTIONS_MAX, type PaginatedResponse, type PersonalGoalProgress, type PersonalGoalsResponse, type PersonalRecordEntry, type PersonalRecordKind, type PlannedReminder, 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 PublicProfileAchievements, type PublicTrainingSummary, type PublicUserProfile, type PushPayload, type PushPayloadKind, type PushSubscriptionKeys, type PushSubscriptionSummary, type PushSubscriptionsResponse, type QuietHours, RELATIONSHIP_LIST_DEFAULT_LIMIT, RELATIONSHIP_LIST_KINDS, RELATIONSHIP_LIST_MAX_LIMIT, RENAISSANCE_RANK_DEFINITIONS, REP_TYPES, RESERVED_USERNAMES, REST_ALERT_MAX_LEAD_SECONDS, REST_ALERT_MIN_LEAD_SECONDS, REST_ALERT_REFUSALS, ROUTINE_DAYS_MAX, ROUTINE_DAY_NAME_MAX, ROUTINE_SCHEDULE_MODES, ROUTINE_VERSIONS_MAX, ROUTINE_VERSION_KINDS, ROUTINE_VERSION_NAME_MAX, type RecentActivityEntry, type RegisterPushSubscriptionRequest, type RelationshipListKind, type RelationshipListQuery, type RelationshipListResponse, type RelationshipMember, type RenaissanceRankDefinition, type RenaissanceRankProgress, type RepType, type ReplaceFeaturedProfileItemsRequest, type ReplaceMeasurableGoalsRequest, type ReplaceTrainingLocationsRequest, type RestAlertPushPayload, type RestAlertRefusal, type RestoreRoutineVersionResponse, type Routine, type RoutineDay, type RoutineDayId, type RoutineExercise, type RoutineId, type RoutineScheduleMode, type RoutineSet, type RoutineVersion, type RoutineVersionDay, type RoutineVersionExercise, type RoutineVersionKind, type RoutineVersionSetup, type RoutineVersionsResponse, SCHEDULE_MOVE_MAX_DAYS, SCHEDULE_OVERRIDES_MAX_RANGE_DAYS, SCHEDULE_OVERRIDE_KINDS, SCHEDULE_SKIP_PAST_DAYS, SESSION_SHARE_DEFAULT_FIELDS, SESSION_SHARE_FIELDS, SESSION_SHARE_MAX_ACTIVE_LINKS, SEXES, STARRED_EXERCISES_MAX, type ScheduleOverride, type ScheduleOverrideKind, type ScheduleOverridesQuery, type ScheduleOverridesResponse, type ScheduleRestAlertRequest, type ScheduleRestAlertResponse, type SessionComparisonExercise, type SessionComparisonQuery, type SessionComparisonResponse, type SessionComparisonRoutineDay, type SessionComparisonSession, type SessionComparisonSet, type SessionExerciseSubstitution, type SessionProgressNotification, type SessionRecapRecord, type SessionShare, type SessionShareField, type SessionShareListResponse, type SetAccountTimeZoneRequest, type SetLog, type Sex, type SharedSessionOwner, type SharedSessionRecap, type SkipOccurrenceRequest, 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, type TrainingReminderPreference, type TrainingReminderPushPayload, USERNAME_MAX_LENGTH, USERNAME_MIN_LENGTH, USERNAME_PATTERN_SOURCE, type UpdateNotificationPreferencesRequest, 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, isWithinQuietHours, routineDayLabel };
package/dist/index.js CHANGED
@@ -370,7 +370,7 @@ var NOTIFICATIONS_LIST_LIMIT = 50;
370
370
 
371
371
  // src/push.ts
372
372
  var PUSH_SUBSCRIPTIONS_MAX = 10;
373
- var PUSH_PAYLOAD_KINDS = ["REST_ALERT"];
373
+ var PUSH_PAYLOAD_KINDS = ["REST_ALERT", "TRAINING_REMINDER"];
374
374
  var REST_ALERT_MAX_LEAD_SECONDS = 3600;
375
375
  var REST_ALERT_MIN_LEAD_SECONDS = 5;
376
376
  var REST_ALERT_REFUSALS = [
@@ -379,8 +379,25 @@ var REST_ALERT_REFUSALS = [
379
379
  /** The server holds no VAPID key pair. */
380
380
  "PUSH_UNAVAILABLE",
381
381
  /** Rest ends too soon for a push to beat it. */
382
- "TOO_SOON"
382
+ "TOO_SOON",
383
+ /** NOTIF-05: the owner switched rest alerts off. */
384
+ "CATEGORY_OFF",
385
+ /** NOTIF-05: rest would end inside the owner's quiet hours. */
386
+ "QUIET_HOURS"
383
387
  ];
388
+
389
+ // src/notification-preferences.ts
390
+ var NOTIFICATION_CATEGORIES = [
391
+ "REST_ALERT",
392
+ "TRAINING_REMINDER"
393
+ ];
394
+ var MINUTES_IN_DAY = 1440;
395
+ function isWithinQuietHours(minuteOfDay, quietHours) {
396
+ if (!quietHours) return false;
397
+ const { startMinute, endMinute } = quietHours;
398
+ if (startMinute === endMinute) return false;
399
+ return startMinute < endMinute ? minuteOfDay >= startMinute && minuteOfDay < endMinute : minuteOfDay >= startMinute || minuteOfDay < endMinute;
400
+ }
384
401
  export {
385
402
  ACHIEVEMENT_CATEGORIES,
386
403
  ACHIEVEMENT_DEFINITIONS,
@@ -400,11 +417,13 @@ export {
400
417
  MEASURABLE_GOALS_MAX,
401
418
  MEASURABLE_GOAL_DIRECTIONS,
402
419
  MEASURABLE_GOAL_TYPES,
420
+ MINUTES_IN_DAY,
403
421
  MOVEMENT_PATTERNS,
404
422
  MUSCLE_GROUPS,
405
423
  NOTIFICATIONS_LIST_LIMIT,
406
424
  NOTIFICATIONS_LOOKBACK_DAYS,
407
425
  NOTIFICATIONS_RETENTION_DAYS,
426
+ NOTIFICATION_CATEGORIES,
408
427
  NOTIFICATION_KINDS,
409
428
  PLATEAU_MIN_DAYS_SINCE_BEST,
410
429
  PLATEAU_MIN_SESSIONS,
@@ -456,5 +475,6 @@ export {
456
475
  USERNAME_PATTERN_SOURCE,
457
476
  WEIGHT_UNITS,
458
477
  WORKOUT_SESSION_STATUSES,
478
+ isWithinQuietHours,
459
479
  routineDayLabel
460
480
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunsteel/contracts",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ezee969/sunsteel-contracts.git"