hevy-shared 1.0.902 → 1.0.904
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/built/API/APIClient.d.ts +4 -1
- package/built/API/APIClient.js +9 -0
- package/built/API/types.d.ts +2 -0
- package/built/index.d.ts +1 -6
- package/built/index.js +2 -37
- package/package.json +1 -1
package/built/API/APIClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientAuthToken, DeepReadonly } from '..';
|
|
2
|
-
import { RequestConfig, HTTPResponse, HTTPClient, HTTPErrorHandler } from './types';
|
|
2
|
+
import { RequestConfig, HTTPResponse, HTTPClient, HTTPResponseHandler, HTTPErrorHandler } from './types';
|
|
3
3
|
interface HevyAPIClientConfig<UserContext> {
|
|
4
4
|
/**
|
|
5
5
|
* How long before predicted token expiry to request a new token. We request
|
|
@@ -90,6 +90,7 @@ export declare class HevyAPIClient<UserContext = never> {
|
|
|
90
90
|
private static readonly DEFAULT_TOKEN_REFRESH_THROTTLE_MS;
|
|
91
91
|
private static readonly DEFAULT_REFRESH_AUTH_TOKEN_API_ENDPOINT;
|
|
92
92
|
private readonly _config;
|
|
93
|
+
private _responseHandlers;
|
|
93
94
|
private _errorHandlers;
|
|
94
95
|
private _authTokenFactory;
|
|
95
96
|
private _legacyAuthToken;
|
|
@@ -123,6 +124,8 @@ export declare class HevyAPIClient<UserContext = never> {
|
|
|
123
124
|
clearAuthToken(): Promise<void>;
|
|
124
125
|
get isAuthenticated(): boolean;
|
|
125
126
|
markSessionDeleted(): void;
|
|
127
|
+
attachResponseHandler(onResponse: HTTPResponseHandler): void;
|
|
128
|
+
removeResponseHandlers(): void;
|
|
126
129
|
attachErrorHandler(onError: HTTPErrorHandler<{
|
|
127
130
|
willRetry: boolean;
|
|
128
131
|
isTokenRefreshedAfterRequest: boolean;
|
package/built/API/APIClient.js
CHANGED
|
@@ -20,6 +20,7 @@ const __1 = require("..");
|
|
|
20
20
|
const types_1 = require("./types");
|
|
21
21
|
class HevyAPIClient {
|
|
22
22
|
constructor(httpClient, config) {
|
|
23
|
+
this._responseHandlers = [];
|
|
23
24
|
this._errorHandlers = [];
|
|
24
25
|
this._authTokenFactory = {
|
|
25
26
|
type: 'value',
|
|
@@ -145,9 +146,11 @@ class HevyAPIClient {
|
|
|
145
146
|
response,
|
|
146
147
|
});
|
|
147
148
|
}
|
|
149
|
+
this._responseHandlers.forEach((cb) => cb({ isSuccess: true, value: response }, request));
|
|
148
150
|
return response;
|
|
149
151
|
}
|
|
150
152
|
catch (e) {
|
|
153
|
+
this._responseHandlers.forEach((cb) => cb({ isSuccess: false, error: e }, request));
|
|
151
154
|
if (!(0, types_1.isHTTPError)(e))
|
|
152
155
|
throw e;
|
|
153
156
|
const { response } = e;
|
|
@@ -238,6 +241,12 @@ class HevyAPIClient {
|
|
|
238
241
|
markSessionDeleted() {
|
|
239
242
|
this._lastSessionDelete = new Date();
|
|
240
243
|
}
|
|
244
|
+
attachResponseHandler(onResponse) {
|
|
245
|
+
this._responseHandlers.push(onResponse);
|
|
246
|
+
}
|
|
247
|
+
removeResponseHandlers() {
|
|
248
|
+
this._responseHandlers.length = 0;
|
|
249
|
+
}
|
|
241
250
|
attachErrorHandler(onError) {
|
|
242
251
|
this._errorHandlers.push(onError);
|
|
243
252
|
}
|
package/built/API/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Result } from '..';
|
|
1
2
|
export interface HTTPClient {
|
|
2
3
|
get<T>(url: string, config?: RequestConfig): Promise<HTTPResponse<T>>;
|
|
3
4
|
delete<T>(url: string, config?: RequestConfig): Promise<HTTPResponse<T>>;
|
|
@@ -22,6 +23,7 @@ export interface HTTPRequestFactory<T = unknown> {
|
|
|
22
23
|
headers: Record<string, string>;
|
|
23
24
|
try(): Promise<HTTPResponse<T>>;
|
|
24
25
|
}
|
|
26
|
+
export type HTTPResponseHandler<T = unknown, R = unknown> = (response: Result<HTTPResponse<T>>, request: HTTPRequestFactory<R>) => void;
|
|
25
27
|
export type HTTPErrorHandler<E, T = unknown, R = unknown> = (response: HTTPResponse<T>, request: HTTPRequestFactory<R>, extraData: E) => void;
|
|
26
28
|
export interface HTTPResponse<T = unknown> {
|
|
27
29
|
status: number;
|
package/built/index.d.ts
CHANGED
|
@@ -246,8 +246,7 @@ export interface UsernameAvailabilityResponse {
|
|
|
246
246
|
isAvailable: boolean;
|
|
247
247
|
suggestions: string[];
|
|
248
248
|
}
|
|
249
|
-
export interface CoachLoginResult {
|
|
250
|
-
auth_token: string;
|
|
249
|
+
export interface CoachLoginResult extends ClientAuthTokenResponse {
|
|
251
250
|
is_first_login_to_coach_platform: boolean;
|
|
252
251
|
}
|
|
253
252
|
export interface CoachSocialLoginResult extends SocialLoginResult {
|
|
@@ -647,9 +646,6 @@ export type TrainingLevel = Lookup<typeof trainingLevels>;
|
|
|
647
646
|
export type ExerciseCategory = Lookup<typeof exerciseCategories>;
|
|
648
647
|
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
649
648
|
export declare const hevyTrainerProgramEquipments: readonly ["barbell", "dumbbell", "machine"];
|
|
650
|
-
declare const granularEquipments: readonly ["barbell", "dumbbell", "kettlebell", "plate", "medicine_ball", "ez_bar", "landmine", "trap_bar", "pullup_bar", "dip_bar", "squat_rack", "flat_bench", "adjustable_bench", "dual_cable_machine", "single_cable_machine", "lat_pulldown_cable", "leg_press_machine", "smith_machine", "t_bar", "plate_machines", "stack_machines", "treadmill", "elliptical_trainer", "rowing_machine", "spinning", "stair_machine", "air_bike", "suspension_band", "battle_rope", "rings", "rope"];
|
|
651
|
-
export type GranularEquipment = Lookup<typeof granularEquipments>;
|
|
652
|
-
export declare const isGranularEquipment: (x: string) => x is GranularEquipment;
|
|
653
649
|
export declare const weeklyTrainingFrequencies: readonly [1, 2, 3, 4, 5, 6];
|
|
654
650
|
export type WeeklyTrainingFrequency = Lookup<typeof weeklyTrainingFrequencies>;
|
|
655
651
|
/**
|
|
@@ -701,7 +697,6 @@ export interface LibraryExercise extends BaseExerciseTemplate {
|
|
|
701
697
|
goal: TrainingGoal[] | undefined;
|
|
702
698
|
level: TrainingLevel[] | undefined;
|
|
703
699
|
category: ExerciseCategory | undefined;
|
|
704
|
-
granular_equipments: GranularEquipment[] | undefined;
|
|
705
700
|
url_female?: string;
|
|
706
701
|
thumbnail_url_female?: string;
|
|
707
702
|
}
|
package/built/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isWorkoutBiometrics = exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.
|
|
18
|
-
exports.isOAuthScope = exports.supportedScopes = exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList =
|
|
17
|
+
exports.isHevyTrainerRoutine = exports.isWorkoutBiometrics = exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.hevyTrainerProgramEquipments = exports.exerciseCategories = exports.trainingLevels = exports.trainingGoals = exports.isCustomExerciseType = exports.customExericseTypes = exports.isExerciseType = exports.exerciseTypes = exports.isExerciseRepType = exports.exerciseRepTypes = exports.isEquipmentFilter = exports.equipmentFilters = exports.isEquipment = exports.equipments = exports.simplifiedMuscleGroupToMuscleGroups = exports.isMuscleGroupFilter = exports.muscleGroupFilters = exports.isMuscleGroup = exports.muscleGroups = exports.isSimplifiedMuscleGroup = exports.simplifiedMuscleGroups = exports.miscellaneousMuscles = exports.chestMuscles = exports.backMuscles = exports.legMuscles = exports.armMuscles = exports.shoulderMuscles = exports.coreMuscles = exports.DefaultClientConfiguration = exports.parseClientAuthTokenResponse = exports.isCoachRole = exports.isErrorResponse = exports.isLivePRVolumeOption = exports.isTimerVolumeOption = exports.isWeekday = exports.orderedWeekdays = exports.isBodyMeasurementUnit = exports.isDistanceUnitShort = exports.isDistanceUnit = exports.isWeightUnit = void 0;
|
|
18
|
+
exports.isOAuthScope = exports.supportedScopes = exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = void 0;
|
|
19
19
|
const typeUtils_1 = require("./typeUtils");
|
|
20
20
|
__exportStar(require("./constants"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
@@ -232,41 +232,6 @@ exports.hevyTrainerProgramEquipments = [
|
|
|
232
232
|
'dumbbell',
|
|
233
233
|
'machine',
|
|
234
234
|
];
|
|
235
|
-
const granularEquipments = [
|
|
236
|
-
'barbell',
|
|
237
|
-
'dumbbell',
|
|
238
|
-
'kettlebell',
|
|
239
|
-
'plate',
|
|
240
|
-
'medicine_ball',
|
|
241
|
-
'ez_bar',
|
|
242
|
-
'landmine',
|
|
243
|
-
'trap_bar',
|
|
244
|
-
'pullup_bar',
|
|
245
|
-
'dip_bar',
|
|
246
|
-
'squat_rack',
|
|
247
|
-
'flat_bench',
|
|
248
|
-
'adjustable_bench',
|
|
249
|
-
'dual_cable_machine',
|
|
250
|
-
'single_cable_machine',
|
|
251
|
-
'lat_pulldown_cable',
|
|
252
|
-
'leg_press_machine',
|
|
253
|
-
'smith_machine',
|
|
254
|
-
't_bar',
|
|
255
|
-
'plate_machines',
|
|
256
|
-
'stack_machines',
|
|
257
|
-
'treadmill',
|
|
258
|
-
'elliptical_trainer',
|
|
259
|
-
'rowing_machine',
|
|
260
|
-
'spinning',
|
|
261
|
-
'stair_machine',
|
|
262
|
-
'air_bike',
|
|
263
|
-
'suspension_band',
|
|
264
|
-
'battle_rope',
|
|
265
|
-
'rings',
|
|
266
|
-
'rope',
|
|
267
|
-
];
|
|
268
|
-
const isGranularEquipment = (x) => (0, typeUtils_1.isInArray)(x, granularEquipments);
|
|
269
|
-
exports.isGranularEquipment = isGranularEquipment;
|
|
270
235
|
exports.weeklyTrainingFrequencies = [1, 2, 3, 4, 5, 6];
|
|
271
236
|
exports.supportedInstructionsLanguages = [
|
|
272
237
|
'en',
|