hevy-shared 1.0.873 → 1.0.875

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.
@@ -120,6 +120,7 @@ export declare class HevyAPIClient<UserContext = never> {
120
120
  legacyAuthToken: string | null;
121
121
  }): Promise<void>;
122
122
  clearAuthToken(): Promise<void>;
123
+ get isAuthenticated(): boolean;
123
124
  attachErrorHandler(onError: HTTPErrorHandler<{
124
125
  willRetry: boolean;
125
126
  isTokenRefreshedAfterRequest: boolean;
@@ -215,6 +215,15 @@ class HevyAPIClient {
215
215
  this._lastTokenRefresh = undefined;
216
216
  });
217
217
  }
218
+ get isAuthenticated() {
219
+ if (this._authTokenFactory.type === 'value' &&
220
+ this._authTokenFactory.value === null) {
221
+ return false;
222
+ }
223
+ else {
224
+ return true;
225
+ }
226
+ }
218
227
  attachErrorHandler(onError) {
219
228
  this._errorHandlers.push(onError);
220
229
  }
@@ -226,12 +235,11 @@ class HevyAPIClient {
226
235
  const userContext = this._config.getUserContext();
227
236
  yield this.refreshExpiredAuthToken(userContext);
228
237
  const method = 'get';
229
- const headers = this._authHeaders;
230
238
  return this._handleResponse({
231
239
  method,
232
240
  url,
233
- headers,
234
- try: () => this._httpClient[method](url, this._addHeaders(headers, config)),
241
+ headers: this._authHeaders,
242
+ try: () => this._httpClient[method](url, this._addHeaders(this._authHeaders, config)),
235
243
  }, userContext);
236
244
  });
237
245
  }
@@ -240,12 +248,11 @@ class HevyAPIClient {
240
248
  const userContext = this._config.getUserContext();
241
249
  yield this.refreshExpiredAuthToken(userContext);
242
250
  const method = 'delete';
243
- const headers = this._authHeaders;
244
251
  return this._handleResponse({
245
252
  method,
246
253
  url,
247
- headers,
248
- try: () => this._httpClient[method](url, this._addHeaders(headers, config)),
254
+ headers: this._authHeaders,
255
+ try: () => this._httpClient[method](url, this._addHeaders(this._authHeaders, config)),
249
256
  }, userContext);
250
257
  });
251
258
  }
@@ -254,12 +261,11 @@ class HevyAPIClient {
254
261
  const userContext = this._config.getUserContext();
255
262
  yield this.refreshExpiredAuthToken(userContext);
256
263
  const method = 'head';
257
- const headers = this._authHeaders;
258
264
  return this._handleResponse({
259
265
  method,
260
266
  url,
261
- headers,
262
- try: () => this._httpClient[method](url, this._addHeaders(headers, config)),
267
+ headers: this._authHeaders,
268
+ try: () => this._httpClient[method](url, this._addHeaders(this._authHeaders, config)),
263
269
  }, userContext);
264
270
  });
265
271
  }
@@ -268,12 +274,11 @@ class HevyAPIClient {
268
274
  const userContext = this._config.getUserContext();
269
275
  yield this.refreshExpiredAuthToken(userContext);
270
276
  const method = 'options';
271
- const headers = this._authHeaders;
272
277
  return this._handleResponse({
273
278
  method,
274
279
  url,
275
- headers,
276
- try: () => this._httpClient[method](url, this._addHeaders(headers, config)),
280
+ headers: this._authHeaders,
281
+ try: () => this._httpClient[method](url, this._addHeaders(this._authHeaders, config)),
277
282
  }, userContext);
278
283
  });
279
284
  }
@@ -282,12 +287,11 @@ class HevyAPIClient {
282
287
  const userContext = this._config.getUserContext();
283
288
  yield this.refreshExpiredAuthToken(userContext);
284
289
  const method = 'post';
285
- const headers = this._authHeaders;
286
290
  return this._handleResponse({
287
291
  method,
288
292
  url,
289
- headers,
290
- try: () => this._httpClient[method](url, data, this._addHeaders(headers, config)),
293
+ headers: this._authHeaders,
294
+ try: () => this._httpClient[method](url, data, this._addHeaders(this._authHeaders, config)),
291
295
  }, userContext);
292
296
  });
293
297
  }
@@ -296,12 +300,11 @@ class HevyAPIClient {
296
300
  const userContext = this._config.getUserContext();
297
301
  yield this.refreshExpiredAuthToken(userContext);
298
302
  const method = 'put';
299
- const headers = this._authHeaders;
300
303
  return this._handleResponse({
301
304
  method,
302
305
  url,
303
- headers,
304
- try: () => this._httpClient[method](url, data, this._addHeaders(headers, config)),
306
+ headers: this._authHeaders,
307
+ try: () => this._httpClient[method](url, data, this._addHeaders(this._authHeaders, config)),
305
308
  }, userContext);
306
309
  });
307
310
  }
@@ -310,12 +313,11 @@ class HevyAPIClient {
310
313
  const userContext = this._config.getUserContext();
311
314
  yield this.refreshExpiredAuthToken(userContext);
312
315
  const method = 'patch';
313
- const headers = this._authHeaders;
314
316
  return this._handleResponse({
315
317
  method,
316
318
  url,
317
- headers,
318
- try: () => this._httpClient[method](url, data, this._addHeaders(headers, config)),
319
+ headers: this._authHeaders,
320
+ try: () => this._httpClient[method](url, data, this._addHeaders(this._authHeaders, config)),
319
321
  }, userContext);
320
322
  });
321
323
  }
package/built/index.d.ts CHANGED
@@ -1887,3 +1887,26 @@ export interface FolderLinkPreviewMetadataResponse extends LinkPreviewMetadataRe
1887
1887
  username: string;
1888
1888
  routine_count: number;
1889
1889
  }
1890
+ export interface ExerciseHistorySet {
1891
+ weight_kg: number | null;
1892
+ reps: number | null;
1893
+ indicator: SetType;
1894
+ duration_seconds: number | null;
1895
+ distance_meters: number | null;
1896
+ rpe: number | null;
1897
+ custom_metric: number | null;
1898
+ set_index: number;
1899
+ prs: SetPersonalRecordType[];
1900
+ }
1901
+ export interface ExerciseInstructionsStep {
1902
+ index?: number;
1903
+ description: string;
1904
+ }
1905
+ export interface ExerciseHistoryWorkout {
1906
+ id: string;
1907
+ name: string;
1908
+ start_time: number;
1909
+ exercises: {
1910
+ sets: ExerciseHistorySet[];
1911
+ }[];
1912
+ }
@@ -141,7 +141,7 @@ export type NotificationMobilePushDataType = NotificationType | 'chat-update' |
141
141
  * For iOS/Apple see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app
142
142
  * For Android see https://firebase.google.com/docs/cloud-messaging/concept-options#data_messages
143
143
  */
144
- export type DataOnlyMobilePushDataType = 'coach-data-changed' | 'coach-program-changed' | 'sync-workouts' | 'sync-routines' | 'sync-routine-folders' | 'sync-exercise-templates-and-customizations' | 'sync-account' | 'hevy-pro-status-changed' | 'hevy-pro-subscription-renewed' | 'new-notification' | never;
144
+ export type DataOnlyMobilePushDataType = 'coach-data-changed' | 'coach-program-changed' | 'sync-workouts' | 'sync-routines' | 'sync-routine-folders' | 'sync-exercise-templates-and-customizations' | 'sync-account' | 'hevy-pro-status-changed' | 'hevy-pro-subscription-renewed' | never;
145
145
  export interface CoachDataChangedMobilePushData extends BaseMobilePushData {
146
146
  type: 'coach-data-changed';
147
147
  additionalHevyData: ClientsCoachData;
@@ -206,10 +206,4 @@ export interface GracePeriodResolveMobilePushData extends BaseMobilePushData {
206
206
  type: 'grace-period-resolve';
207
207
  deeplink: string;
208
208
  }
209
- export interface NewNotificationMobilePushData extends BaseMobilePushData {
210
- type: 'new-notification';
211
- additionalHevyData: {
212
- notificationDateISO: string;
213
- };
214
- }
215
- export type MobilePushData = ChatUpdateMobilePushData | SyncCustomExercisesAndCoachCustomizationsMobilePushData | SyncWorkoutsMobilePushData | SyncRoutineFoldersMobilePushData | SyncRoutinesMobilePushData | SyncAccountMobilePushData | ProStatusChangedPushMobilePushData | HevyProSubscriptionRenewedMobilePushData | CoachProgramChangedMobilePushData | CoachDataChangedMobilePushData | ContactOnHevyMobilePushData | CoachClientInviteMobilePushData | AcceptFollowRequestMobilePushData | FollowRequestMobilePushData | FollowMobilePushData | WorkoutLikeMobilePushData | WorkoutCommentLikeMobilePushData | WorkoutCommentMentionMobilePushData | WorkoutCommentDiscussionMobilePushData | WorkoutCommentReplyMobilePushData | WorkoutCommentMobilePushData | WorkoutMentionMobilePushData | WorkoutCompleteMobilePushData | CoachProgramFinishesNextWeekMobilePushData | CoachProgramStartsTodayMobilePushData | CoachLoggedYourWorkoutMobilePushData | CoachLoggedYourMeasurementsMobilePushData | MonthlyReportMobilePushData | GracePeriodEnterMobilePushData | GracePeriodResolveMobilePushData | NewNotificationMobilePushData;
209
+ export type MobilePushData = ChatUpdateMobilePushData | SyncCustomExercisesAndCoachCustomizationsMobilePushData | SyncWorkoutsMobilePushData | SyncRoutineFoldersMobilePushData | SyncRoutinesMobilePushData | SyncAccountMobilePushData | ProStatusChangedPushMobilePushData | HevyProSubscriptionRenewedMobilePushData | CoachProgramChangedMobilePushData | CoachDataChangedMobilePushData | ContactOnHevyMobilePushData | CoachClientInviteMobilePushData | AcceptFollowRequestMobilePushData | FollowRequestMobilePushData | FollowMobilePushData | WorkoutLikeMobilePushData | WorkoutCommentLikeMobilePushData | WorkoutCommentMentionMobilePushData | WorkoutCommentDiscussionMobilePushData | WorkoutCommentReplyMobilePushData | WorkoutCommentMobilePushData | WorkoutMentionMobilePushData | WorkoutCompleteMobilePushData | CoachProgramFinishesNextWeekMobilePushData | CoachProgramStartsTodayMobilePushData | CoachLoggedYourWorkoutMobilePushData | CoachLoggedYourMeasurementsMobilePushData | MonthlyReportMobilePushData | GracePeriodEnterMobilePushData | GracePeriodResolveMobilePushData;
package/built/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Dayjs } from 'dayjs';
2
- import { BaseExerciseTemplate, ExerciseType, FormatAtText, Result, SetType, StrengthLevel, UserExerciseSet, UserFacingSetIndicator, Weekday } from '.';
2
+ import { BaseExerciseTemplate, ExerciseInstructionsStep, ExerciseType, FormatAtText, Result, SetType, StrengthLevel, UserExerciseSet, UserFacingSetIndicator, Weekday } from '.';
3
3
  /**
4
4
  * Doesn't matter what you throw in the function it'll
5
5
  * always return a number. Non number values will return
@@ -249,4 +249,5 @@ export declare const startOfWeek: (d: Dayjs, firstDayOfWeek: Weekday) => Dayjs;
249
249
  export declare const weekdayNumberMap: {
250
250
  [key in Weekday]: number;
251
251
  };
252
+ export declare const rawInstructionsToIndexedSteps: (rawInstructions: string) => ExerciseInstructionsStep[];
252
253
  export {};
package/built/utils.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startOfWeek = exports.calculateCurrentWeekStreak = exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.getEstimatedExercisesDurationSeconds = exports.ESTIMATED_REST_TIMER_DURATION = exports.ESTIMATED_SET_DURATION = exports.UserFacingIndicatorToSetIndicator = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.secondsToClockParts = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
7
- exports.weekdayNumberMap = void 0;
7
+ exports.rawInstructionsToIndexedSteps = exports.weekdayNumberMap = void 0;
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  /**
10
10
  * Doesn't matter what you throw in the function it'll
@@ -775,3 +775,22 @@ exports.weekdayNumberMap = {
775
775
  friday: 5,
776
776
  saturday: 6,
777
777
  };
778
+ const rawInstructionsToIndexedSteps = (rawInstructions) => {
779
+ const instructionsByLine = rawInstructions
780
+ .split('\n')
781
+ .map((l) => l.trim())
782
+ .filter((l) => l.length > 0);
783
+ const instructionsByStep = instructionsByLine.map((s) => {
784
+ var _a, _b;
785
+ const parsedStep = s.match(/^([0-9]*)\\?\.(.*)$/);
786
+ if (!parsedStep) {
787
+ // this line doesn't contain a number, so just return it unchanged
788
+ return { description: s };
789
+ }
790
+ const index = Number(parsedStep[1]) || undefined; // if it's NaN or 0, convert it to undefined
791
+ const description = (_b = (_a = parsedStep[2]) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : s;
792
+ return { index, description };
793
+ });
794
+ return instructionsByStep;
795
+ };
796
+ exports.rawInstructionsToIndexedSteps = rawInstructionsToIndexedSteps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.873",
3
+ "version": "1.0.875",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",