curated2: !30
This commit is contained in:
commit
e0241b804e
23 files changed
+2157
-6
No files matched your search
@@ -0,0 +1,579 @@
|
||||
// AUTO-GENERATED by scripts/build-hevy-id-map.mjs — do not edit by hand.
|
||||
// Hevy exercise_template id → openGym catalogue id, plus English title → id for CSV exports
|
||||
// (Hevy CSV has titles, not template ids). Regenerated from the Hevy templates API +
|
||||
// verified title aliases.
|
||||
// 283 mapped · 168 left unmatched (import as custom).
|
||||
// Source templates: 451 (built-in only).
|
||||
|
||||
export const HEVY_ID_MAP = {
|
||||
"018ADC12": "3017",
|
||||
"01A35BF9": "2404",
|
||||
"023943F1": "0572",
|
||||
"026FD047": "0407",
|
||||
"0393F233": "0218",
|
||||
"040BA2E3": "2612",
|
||||
"046E25A2": "0673",
|
||||
"0482DA98": "0826",
|
||||
"05293BCA": "3142",
|
||||
"059E835D": "0603",
|
||||
"062AB91A": "0594",
|
||||
"06745E58": "1372",
|
||||
"073032BB": "1457",
|
||||
"07B38369": "0314",
|
||||
"084A67CA": "0128",
|
||||
"08590920": "0472",
|
||||
"08A2974E": "0606",
|
||||
"091737FA": "0573",
|
||||
"09C9F635": "0865",
|
||||
"0B4C1902": "0294",
|
||||
"0B841777": "0095",
|
||||
"0B9B92BA": "0085",
|
||||
"0EB695C9": "2611",
|
||||
"0F24286A": "0099",
|
||||
"0FBF7195": "0748",
|
||||
"1006DF48": "0401",
|
||||
"10313AFD": "0550",
|
||||
"10347BAC": "0591",
|
||||
"10D76E8F": "1273",
|
||||
"112FC6B7": "0080",
|
||||
"11A123F3": "0586",
|
||||
"12017185": "0308",
|
||||
"123EE239": "0439",
|
||||
"1283BBA6": "0043",
|
||||
"150E076B": "3655",
|
||||
"18487FA7": "0301",
|
||||
"19372ABC": "0662",
|
||||
"19A38071": "0604",
|
||||
"1B2B1E7C": "0652",
|
||||
"1B89CA1B": "0521",
|
||||
"1D4B3D6B": "0313",
|
||||
"1DF4A847": "1350",
|
||||
"1E42FD5F": "0743",
|
||||
"1E9A6B8E": "0592",
|
||||
"20870ED5": "0752",
|
||||
"20C1A3CB": "0809",
|
||||
"21310F5F": "0607",
|
||||
"218DA87C": "0803",
|
||||
"22578A94": "0168",
|
||||
"234897AB": "0165",
|
||||
"23A48484": "0175",
|
||||
"23E92538": "0292",
|
||||
"243710DE": "3666",
|
||||
"286C1D0B": "0246",
|
||||
"28BB4A95": "0591",
|
||||
"29083183": "1326",
|
||||
"29472BE1": "0251",
|
||||
"2982AA23": "0687",
|
||||
"2A48E443": "0116",
|
||||
"2B4B7310": "0085",
|
||||
"2C37EC5E": "0017",
|
||||
"2CFED196": "0069",
|
||||
"2F8D3067": "0607",
|
||||
"2FA77B28": "0459",
|
||||
"3092FADD": "0607",
|
||||
"32B0B590": "0507",
|
||||
"32C4D4A2": "0298",
|
||||
"32HKJ34K": "1460",
|
||||
"3303376C": "2141",
|
||||
"33EDD7DB": "1460",
|
||||
"35B51B87": "0030",
|
||||
"3601968B": "0289",
|
||||
"36E8F14E": "0165",
|
||||
"3765684D": "0607",
|
||||
"37FCC2BB": "0294",
|
||||
"392887AA": "0662",
|
||||
"39C99849": "0493",
|
||||
"3A6FA3D1": "0757",
|
||||
"3D0C7C75": "1760",
|
||||
"3F5F8D40": "3142",
|
||||
"3FF6A22E": "0544",
|
||||
"40C6A9FC": "0127",
|
||||
"4180C405": "0044",
|
||||
"422B08F1": "0334",
|
||||
"425805F4": "0499",
|
||||
"43573BB8": "0003",
|
||||
"4377A52B": "2311",
|
||||
"4377A52C": "2311",
|
||||
"473CF5B8": "0673",
|
||||
"47B036EF": "0978",
|
||||
"49C922A1": "1409",
|
||||
"4B4BF8C2": "0019",
|
||||
"4E5257DE": "2616",
|
||||
"4F5866F8": "0573",
|
||||
"4F942934": "0070",
|
||||
"5046D0A9": "0042",
|
||||
"50C613D0": "2133",
|
||||
"50DFDFAB": "0047",
|
||||
"5122E7D9": "1451",
|
||||
"51A0EDAA": "0677",
|
||||
"542F3CD5": "1700",
|
||||
"55E6546F": "0027",
|
||||
"56808FD2": "0970",
|
||||
"582ADA23": "1636",
|
||||
"5E10D0E6": "3142",
|
||||
"5E1A7777": "0054",
|
||||
"5F4E6DD3": "0300",
|
||||
"5F8903BF": "0551",
|
||||
"6120CAAB": "0795",
|
||||
"6182EE83": "0607",
|
||||
"651F844C": "1269",
|
||||
"6575F52D": "0283",
|
||||
"6622E5A0": "3142",
|
||||
"67280085": "0375",
|
||||
"68B83EE0": "3193",
|
||||
"68F8A292": "0060",
|
||||
"6A6C31A5": "2330",
|
||||
"6AC96645": "0405",
|
||||
"6DA40660": "0417",
|
||||
"6E6EE645": "0054",
|
||||
"6FCD7755": "0251",
|
||||
"70D4EBBF": "0514",
|
||||
"72297E8C": "5201",
|
||||
"724CDE60": "0297",
|
||||
"729237D1": "0652",
|
||||
"72CFFAD5": "1459",
|
||||
"74103F24": "0052",
|
||||
"742E5BD5": "0767",
|
||||
"75A4F6C4": "0585",
|
||||
"78683336": "0596",
|
||||
"7952B5CD": "0872",
|
||||
"796E8E2C": "0834",
|
||||
"797F0782": "0437",
|
||||
"79D0BB3A": "0025",
|
||||
"7AB9A362": "0120",
|
||||
"7B8D84E8": "0091",
|
||||
"7C0028C3": "0593",
|
||||
"7C50F118": "1429",
|
||||
"7E3BC8B6": "0312",
|
||||
"7EB3F7C3": "0577",
|
||||
"818BA121": "0078",
|
||||
"8293E554": "0310",
|
||||
"875F585F": "0060",
|
||||
"878CD1D0": "0405",
|
||||
"89304423": "0529",
|
||||
"8A2E6481": "0180",
|
||||
"8BAB2735": "0318",
|
||||
"8BEBFED6": "0598",
|
||||
"8C331CD8": "0196",
|
||||
"8C9D2928": "1494",
|
||||
"90427D4A": "1675",
|
||||
"90B04F96": "0471",
|
||||
"90E506D5": "3305",
|
||||
"91237BDD": "2289",
|
||||
"914F3A96": "0327",
|
||||
"91AF29E0": "0091",
|
||||
"9237BAD1": "0603",
|
||||
"923874CA": "0562",
|
||||
"9273BA17": "0237",
|
||||
"9283BABA": "0858",
|
||||
"92D858EA": "0243",
|
||||
"9372FFAA": "0396",
|
||||
"93A552C6": "0241",
|
||||
"947DAC23": "0259",
|
||||
"95F2E076": "1426",
|
||||
"9694DA61": "3543",
|
||||
"98237BA2": "0826",
|
||||
"991833C2": "3220",
|
||||
"9930DF71": "0091",
|
||||
"99507114": "0032",
|
||||
"99B49684": "3663",
|
||||
"99C1F2AD": "0151",
|
||||
"99D5F10E": "0857",
|
||||
"9B13BA4B": "0548",
|
||||
"9DCE2D64": "0596",
|
||||
"9F48F858": "0206",
|
||||
"9F9C164B": "0631",
|
||||
"A01BE509": "0443",
|
||||
"A05C064D": "0573",
|
||||
"A0D8FA1B": "2271",
|
||||
"A127DA73": "0534",
|
||||
"A2D838BD": "0243",
|
||||
"A41C7261": "0972",
|
||||
"A57D38D5": "0815",
|
||||
"A5AC6449": "0031",
|
||||
"A69FF221": "2137",
|
||||
"A733CC5B": "1460",
|
||||
"A8814C06": "1003",
|
||||
"AA1EB7D8": "0571",
|
||||
"AA52E8D2": "0773",
|
||||
"ABB00838": "0028",
|
||||
"ABEC557F": "0406",
|
||||
"AC5A4C58": "0046",
|
||||
"ADA8623C": "0868",
|
||||
"AF328E3D": "0575",
|
||||
"B05C2C29": "0605",
|
||||
"B09A1304": "0766",
|
||||
"B123DD01": "2285",
|
||||
"B2398CD1": "0277",
|
||||
"B3B1D947": "3360",
|
||||
"B537D09F": "0336",
|
||||
"B582299E": "0383",
|
||||
"B5D3A742": "0410",
|
||||
"B5EFBF9C": "0194",
|
||||
"B74A95BB": "3211",
|
||||
"B8127AD1": "0586",
|
||||
"B82D6418": "0043",
|
||||
"B923B230": "0811",
|
||||
"BB792A36": "1160",
|
||||
"BB83BDDE": "0687",
|
||||
"BC10A922": "0277",
|
||||
"BD4E7E53": "0535",
|
||||
"BD86EFD5": "0041",
|
||||
"BE289E45": "0178",
|
||||
"BE640BA0": "0203",
|
||||
"BF6ECE89": "0431",
|
||||
"C315DC2A": "0602",
|
||||
"C43825EA": "0279",
|
||||
"C469EA70": "0597",
|
||||
"C6272009": "0032",
|
||||
"C628D768": "0648",
|
||||
"C6C9B8A0": "2135",
|
||||
"C7973E0E": "0739",
|
||||
"C7AE420A": "0688",
|
||||
"C8706C80": "0624",
|
||||
"CC35A01F": "0043",
|
||||
"CC55119B": "0979",
|
||||
"CD6DC8E5": "0830",
|
||||
"D04AC939": "0043",
|
||||
"D20D7BBE": "0117",
|
||||
"D23C609B": "0572",
|
||||
"D2FE7B2E": "2330",
|
||||
"D3095577": "0028",
|
||||
"D3E2AB55": "0319",
|
||||
"D4A2FE7E": "2143",
|
||||
"D53F2886": "0065",
|
||||
"D5D0354D": "0584",
|
||||
"D8281C62": "0602",
|
||||
"D82EA543": "0983",
|
||||
"D8460FA6": "0385",
|
||||
"D8911FC4": "0276",
|
||||
"D8F7F851": "2331",
|
||||
"D928C232": "0832",
|
||||
"D950429E": "0038",
|
||||
"DA0F0470": "0033",
|
||||
"DBB91A3C": "0162",
|
||||
"DBE341AA": "1495",
|
||||
"DBF9273A": "0310",
|
||||
"DCF3B31B": "0832",
|
||||
"DCFF3E9F": "0413",
|
||||
"DDCC3821": "0770",
|
||||
"DE68C825": "0192",
|
||||
"DF200976": "0977",
|
||||
"E05C2C38": "0605",
|
||||
"E3EDA509": "1775",
|
||||
"E53CCBE5": "1372",
|
||||
"E5988A0A": "0383",
|
||||
"E644F828": "1258",
|
||||
"E9E4089F": "0009",
|
||||
"EA820646": "0027",
|
||||
"EAC7D9C5": "3124",
|
||||
"EB43ADD4": "1452",
|
||||
"EB813C91": "1359",
|
||||
"F1258206": "1004",
|
||||
"F1D60854": "0218",
|
||||
"F1E57334": "0292",
|
||||
"F2A37357": "1410",
|
||||
"F30A4F01": "1460",
|
||||
"F3717B0E": "3888",
|
||||
"F49E31D6": "0630",
|
||||
"F4B4C6EE": "0597",
|
||||
"F5DEF1EB": "1489",
|
||||
"F8356514": "0472",
|
||||
"F8A0FCCA": "0549",
|
||||
"F99C211D": "0535",
|
||||
"FAB6EB2F": "0372",
|
||||
"FAF31231": "0033",
|
||||
"FB09C938": "0067",
|
||||
"FBF92739": "1299",
|
||||
"FE389074": "0074",
|
||||
"FFABC123": "0220",
|
||||
"FFC106CB": "0753",
|
||||
"FFDA283B": "0381",
|
||||
}
|
||||
|
||||
/** Lowercased Hevy English title → catalogue id (CSV / name path). */
|
||||
export const HEVY_TITLE_MAP = {
|
||||
"ab wheel": "0857",
|
||||
"air bike": "0003",
|
||||
"arnold press (dumbbell)": "2137",
|
||||
"around the world": "2143",
|
||||
"back extension (hyperextension)": "0573",
|
||||
"back extension (machine)": "0573",
|
||||
"back extension (weighted hyperextension)": "0573",
|
||||
"battle ropes": "0128",
|
||||
"bear crawl": "3360",
|
||||
"bench dip": "0830",
|
||||
"bench press (barbell)": "0025",
|
||||
"bench press (cable)": "0151",
|
||||
"bench press (dumbbell)": "0289",
|
||||
"bench press (smith machine)": "0748",
|
||||
"bench press - close grip (barbell)": "0030",
|
||||
"bench press - wide grip (barbell)": "1258",
|
||||
"bent over row (band)": "0027",
|
||||
"bent over row (barbell)": "0027",
|
||||
"bent over row (dumbbell)": "0292",
|
||||
"bent over row (smith machine)": "1359",
|
||||
"bicep curl (barbell)": "0031",
|
||||
"bicep curl (cable)": "0868",
|
||||
"bicep curl (dumbbell)": "0294",
|
||||
"bicep curl (machine)": "0575",
|
||||
"bicep curl (suspension)": "0294",
|
||||
"bicycle crunch": "0972",
|
||||
"boxing": "2271",
|
||||
"bulgarian split squat (barbell)": "0099",
|
||||
"bulgarian split squat (dumbbell)": "0410",
|
||||
"burpee": "1160",
|
||||
"butterfly (pec deck)": "0596",
|
||||
"cable core pallof press": "0979",
|
||||
"cable crunch": "0175",
|
||||
"cable fly crossovers": "1269",
|
||||
"cable pull through": "0196",
|
||||
"cable twist (down to up)": "0243",
|
||||
"cable twist (up to down)": "0243",
|
||||
"calf press (machine)": "2289",
|
||||
"chest dip": "0251",
|
||||
"chest dip (assisted)": "0009",
|
||||
"chest dip (weighted)": "0251",
|
||||
"chest fly (dumbbell)": "0308",
|
||||
"chest fly (machine)": "0596",
|
||||
"chest press (band)": "3124",
|
||||
"chest press (machine)": "0577",
|
||||
"chest supported incline row (dumbbell)": "0327",
|
||||
"chest supported reverse fly (dumbbell)": "0383",
|
||||
"chin up": "1326",
|
||||
"chin up (assisted)": "0572",
|
||||
"chin up (weighted)": "0572",
|
||||
"clap push ups": "1273",
|
||||
"clean": "0028",
|
||||
"clean and press": "0028",
|
||||
"concentration curl": "0297",
|
||||
"cross body hammer curl": "0298",
|
||||
"crunch": "0832",
|
||||
"crunch (machine)": "1452",
|
||||
"crunch (weighted)": "0832",
|
||||
"cycling": "2331",
|
||||
"dead bug": "0276",
|
||||
"deadlift (band)": "0032",
|
||||
"deadlift (barbell)": "0032",
|
||||
"deadlift (dumbbell)": "0300",
|
||||
"deadlift (smith machine)": "0752",
|
||||
"deadlift (trap bar)": "0811",
|
||||
"decline bench press (barbell)": "0033",
|
||||
"decline bench press (dumbbell)": "0301",
|
||||
"decline bench press (machine)": "0033",
|
||||
"decline bench press (smith machine)": "0753",
|
||||
"decline crunch": "0277",
|
||||
"decline crunch (weighted)": "0277",
|
||||
"decline push up": "0279",
|
||||
"diamond push up": "0283",
|
||||
"drag curl": "0038",
|
||||
"dumbbell row": "0292",
|
||||
"dumbbell snatch": "3888",
|
||||
"dumbbell step up": "0431",
|
||||
"elbow to knee": "0443",
|
||||
"elliptical trainer": "2141",
|
||||
"ez bar biceps curl": "2404",
|
||||
"face pull": "0203",
|
||||
"farmers walk": "2133",
|
||||
"floor press (barbell)": "0065",
|
||||
"floor triceps dip": "0815",
|
||||
"flutter kicks": "0459",
|
||||
"front raise (band)": "0978",
|
||||
"front raise (barbell)": "0041",
|
||||
"front raise (cable)": "0162",
|
||||
"front raise (dumbbell)": "0310",
|
||||
"front raise (suspension)": "0834",
|
||||
"front squat": "0042",
|
||||
"full squat": "0043",
|
||||
"glute bridge (barbell)": "1409",
|
||||
"glute ham raise": "3193",
|
||||
"goblet squat": "1760",
|
||||
"good morning (barbell)": "0044",
|
||||
"hack squat": "0046",
|
||||
"hack squat (machine)": "0743",
|
||||
"hammer curl (band)": "0313",
|
||||
"hammer curl (cable)": "0165",
|
||||
"hammer curl (dumbbell)": "0312",
|
||||
"handstand push up": "0471",
|
||||
"hang clean": "0535",
|
||||
"hanging knee raise": "0472",
|
||||
"hanging leg raise": "0472",
|
||||
"high knees": "3655",
|
||||
"hip abduction (cable)": "0597",
|
||||
"hip abduction (machine)": "0597",
|
||||
"hip adduction (cable)": "0168",
|
||||
"hip adduction (machine)": "0598",
|
||||
"incline bench press (barbell)": "0047",
|
||||
"incline bench press (dumbbell)": "0314",
|
||||
"incline bench press (smith machine)": "0757",
|
||||
"incline chest fly (dumbbell)": "0319",
|
||||
"incline chest press (machine)": "1299",
|
||||
"incline push ups": "0493",
|
||||
"inverted row": "0499",
|
||||
"iso-lateral row (machine)": "0571",
|
||||
"jackknife sit up": "0507",
|
||||
"jm press (barbell)": "0052",
|
||||
"jump rope": "2612",
|
||||
"jump squat": "0514",
|
||||
"jumping jack": "3220",
|
||||
"kettlebell clean": "0535",
|
||||
"kettlebell goblet squat": "0534",
|
||||
"kettlebell high pull": "0548",
|
||||
"kettlebell snatch": "0529",
|
||||
"kettlebell swing": "0549",
|
||||
"kettlebell turkish get up": "0551",
|
||||
"knee raise parallel bars": "0826",
|
||||
"kneeling pulldown (band)": "0983",
|
||||
"kneeling push up": "3211",
|
||||
"landmine 180": "0562",
|
||||
"lat pulldown (band)": "2330",
|
||||
"lat pulldown (cable)": "2330",
|
||||
"lat pulldown (machine)": "0673",
|
||||
"lat pulldown - close grip (cable)": "2616",
|
||||
"lateral lunge": "1410",
|
||||
"lateral raise (band)": "0977",
|
||||
"lateral raise (cable)": "0178",
|
||||
"lateral raise (dumbbell)": "0334",
|
||||
"lateral raise (machine)": "0584",
|
||||
"leg extension (machine)": "0585",
|
||||
"leg press (machine)": "0739",
|
||||
"leg press horizontal (machine)": "2611",
|
||||
"leg raise parallel bars": "0826",
|
||||
"low row (suspension)": "0180",
|
||||
"lunge": "0054",
|
||||
"lunge (barbell)": "0054",
|
||||
"lunge (dumbbell)": "0336",
|
||||
"lying leg curl (machine)": "0586",
|
||||
"lying leg raise": "0865",
|
||||
"mountain climber": "0630",
|
||||
"muscle up": "0631",
|
||||
"oblique crunch": "1495",
|
||||
"overhead curl (cable)": "1636",
|
||||
"overhead press (barbell)": "0091",
|
||||
"overhead press (dumbbell)": "0405",
|
||||
"overhead press (smith machine)": "0766",
|
||||
"overhead squat": "0069",
|
||||
"overhead triceps extension (cable)": "0194",
|
||||
"pendlay row (barbell)": "3017",
|
||||
"pistol squat": "0544",
|
||||
"plank": "2135",
|
||||
"plate front raise": "0310",
|
||||
"power clean": "0648",
|
||||
"preacher curl (barbell)": "0070",
|
||||
"preacher curl (dumbbell)": "0372",
|
||||
"preacher curl (machine)": "0592",
|
||||
"pull up": "0652",
|
||||
"pull up (assisted)": "0017",
|
||||
"pull up (band)": "0970",
|
||||
"pull up (weighted)": "0652",
|
||||
"pullover (dumbbell)": "0375",
|
||||
"pullover (machine)": "2285",
|
||||
"push press": "1700",
|
||||
"push up": "0662",
|
||||
"push up (weighted)": "0662",
|
||||
"push up - close grip": "0259",
|
||||
"rack pull": "0074",
|
||||
"rear delt reverse fly (cable)": "0602",
|
||||
"rear delt reverse fly (dumbbell)": "0383",
|
||||
"rear delt reverse fly (machine)": "0602",
|
||||
"renegade row (dumbbell)": "0521",
|
||||
"reverse crunch": "0872",
|
||||
"reverse curl (barbell)": "0080",
|
||||
"reverse curl (cable)": "0206",
|
||||
"reverse grip lat pulldown (cable)": "0673",
|
||||
"reverse hyperextension": "0593",
|
||||
"reverse lunge (barbell)": "0078",
|
||||
"reverse lunge (dumbbell)": "0381",
|
||||
"reverse plank": "3663",
|
||||
"reverse wrist curl (dumbbell)": "0385",
|
||||
"ring dips": "0677",
|
||||
"romanian deadlift (barbell)": "0085",
|
||||
"romanian deadlift (dumbbell)": "1459",
|
||||
"romanian deadlift (smith machine)": "0085",
|
||||
"rope cable curl": "0165",
|
||||
"rope straight arm pulldown": "0237",
|
||||
"russian twist (bodyweight)": "0687",
|
||||
"russian twist (weighted)": "0687",
|
||||
"scapular pull ups": "0688",
|
||||
"seated cable row - bar grip": "0218",
|
||||
"seated cable row - v grip (cable)": "0218",
|
||||
"seated calf raise": "0594",
|
||||
"seated dip machine": "1451",
|
||||
"seated incline curl (dumbbell)": "0318",
|
||||
"seated lateral raise (dumbbell)": "0396",
|
||||
"seated leg curl (machine)": "0586",
|
||||
"seated overhead press (barbell)": "0091",
|
||||
"seated overhead press (dumbbell)": "0091",
|
||||
"seated palms up wrist curl": "0401",
|
||||
"seated row (machine)": "1350",
|
||||
"seated shoulder press (machine)": "0603",
|
||||
"seated wrist curl (barbell)": "1426",
|
||||
"shoulder press (dumbbell)": "0405",
|
||||
"shoulder press (machine plates)": "0603",
|
||||
"shrug (barbell)": "0095",
|
||||
"shrug (cable)": "0220",
|
||||
"shrug (dumbbell)": "0406",
|
||||
"shrug (machine)": "0604",
|
||||
"shrug (smith machine)": "0767",
|
||||
"side bend (dumbbell)": "0407",
|
||||
"side plank": "1775",
|
||||
"single arm lateral raise (cable)": "0192",
|
||||
"single leg standing calf raise (machine)": "0605",
|
||||
"sissy squat (weighted)": "1489",
|
||||
"skullcrusher (barbell)": "0060",
|
||||
"skullcrusher (dumbbell)": "0060",
|
||||
"snatch": "0067",
|
||||
"spider curl (dumbbell)": "1675",
|
||||
"split squat (dumbbell)": "0809",
|
||||
"sprints": "0858",
|
||||
"squat (band)": "1004",
|
||||
"squat (barbell)": "0043",
|
||||
"squat (bodyweight)": "3543",
|
||||
"squat (dumbbell)": "0413",
|
||||
"squat (machine)": "0043",
|
||||
"squat (smith machine)": "0770",
|
||||
"squat (suspension)": "0043",
|
||||
"squat row": "1003",
|
||||
"stair machine (floors)": "2311",
|
||||
"stair machine (steps)": "2311",
|
||||
"standing calf raise": "1372",
|
||||
"standing calf raise (barbell)": "1372",
|
||||
"standing calf raise (dumbbell)": "0417",
|
||||
"standing calf raise (machine)": "0605",
|
||||
"standing calf raise (smith)": "0773",
|
||||
"standing leg curls": "0795",
|
||||
"standing military press (barbell)": "1457",
|
||||
"straight leg deadlift": "0116",
|
||||
"sumo deadlift": "0117",
|
||||
"sumo squat": "3142",
|
||||
"sumo squat (barbell)": "3142",
|
||||
"sumo squat (dumbbell)": "3142",
|
||||
"sumo squat (kettlebell)": "3142",
|
||||
"superman": "0803",
|
||||
"t bar row": "0606",
|
||||
"thruster (barbell)": "3305",
|
||||
"thruster (kettlebell)": "0550",
|
||||
"treadmill": "3666",
|
||||
"triceps dip": "0591",
|
||||
"triceps dip (assisted)": "0019",
|
||||
"triceps dip (weighted)": "0591",
|
||||
"triceps extension (barbell)": "0607",
|
||||
"triceps extension (cable)": "0607",
|
||||
"triceps extension (dumbbell)": "0607",
|
||||
"triceps extension (machine)": "0607",
|
||||
"triceps extension (suspension)": "0607",
|
||||
"triceps pushdown": "0241",
|
||||
"upright row (barbell)": "0120",
|
||||
"upright row (cable)": "0246",
|
||||
"upright row (dumbbell)": "0437",
|
||||
"waiter curl (dumbbell)": "5201",
|
||||
"walking": "1460",
|
||||
"walking lunge": "1460",
|
||||
"walking lunge (dumbbell)": "1460",
|
||||
"walking lunge (sandbag)": "1460",
|
||||
"wall sit": "0624",
|
||||
"wide pull up": "1429",
|
||||
"yoga": "1494",
|
||||
"zercher squat": "0127",
|
||||
"zottman curl (dumbbell)": "0439",
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
import { EXDB, EXIDX } from './exercises.js'
|
||||
import { uid } from './format.js'
|
||||
import { isWarmupRow } from './workout-model.js'
|
||||
import { HEVY_TITLE_MAP } from './hevy-id-map.js'
|
||||
|
||||
/* ----------------------------------------------------------------- CSV ---- */
|
||||
|
||||
@@ -251,6 +252,16 @@ export function matchExercise(name) {
|
||||
return ties === 1 ? best : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Exact Hevy English title → catalogue id (from the generated title map).
|
||||
* Used when a CSV is detected as Hevy: same deterministic table as the API import,
|
||||
* keyed by title because Hevy's CSV has no template id column.
|
||||
*/
|
||||
export function matchHevyTitle(name) {
|
||||
const id = HEVY_TITLE_MAP[String(name || '').trim().toLowerCase()]
|
||||
return id && EXIDX[id] ? id : null
|
||||
}
|
||||
|
||||
// Hevy exports no category column, so every invented exercise fell through to the
|
||||
// 'upper legs' default and a third of an imported history was attributed to the legs in
|
||||
// the muscle map. When there is no category, read the body part off the name instead.
|
||||
@@ -389,7 +400,12 @@ export function parseWorkoutCSV(text, { unit = 'kg' } = {}) {
|
||||
|
||||
const key = keyOf(name)
|
||||
let id = resolved.get(key)
|
||||
if (id === undefined) { id = matchExercise(name); resolved.set(key, id) }
|
||||
if (id === undefined) {
|
||||
// Hevy CSV: prefer the generated English-title map (same table as the API import).
|
||||
// Localized titles still fall through to the word-bag matcher.
|
||||
id = (source === 'Hevy' ? matchHevyTitle(name) : null) || matchExercise(name)
|
||||
resolved.set(key, id)
|
||||
}
|
||||
if (id) matched++
|
||||
else {
|
||||
let c = created.get(key)
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
// Import a Hevy account through the public API (https://api.hevyapp.com/docs/).
|
||||
//
|
||||
// Exercise identity is Hevy's `exercise_template_id`, looked up in the generated
|
||||
// `hevy-id-map.js` table — never the localized title on a set. Regenerate the map
|
||||
// with `node scripts/build-hevy-id-map.mjs`. The API key never leaves this module's
|
||||
// callers: nothing here stores it.
|
||||
|
||||
import { EXIDX } from './exercises.js'
|
||||
import { uid } from './format.js'
|
||||
import { isWarmupRow } from './workout-model.js'
|
||||
import { HEVY_ID_MAP, HEVY_TITLE_MAP } from './hevy-id-map.js'
|
||||
|
||||
export { HEVY_ID_MAP, HEVY_TITLE_MAP }
|
||||
export const HEVY_API = 'https://api.hevyapp.com'
|
||||
export const HEVY_DEV_SETTINGS = 'https://hevy.com/settings?developer'
|
||||
|
||||
const LB_TO_KG = 0.45359237
|
||||
|
||||
/* --------------------------------------------------------------- auth/fetch -- */
|
||||
|
||||
class HevyApiError extends Error {
|
||||
constructor(status, message) {
|
||||
super(message || `Hevy API error ${status}`)
|
||||
this.name = 'HevyApiError'
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
async function hevyGet(path, apiKey, params = {}) {
|
||||
const url = new URL(path, HEVY_API)
|
||||
for (const [k, v] of Object.entries(params)) {
|
||||
if (v != null && v !== '') url.searchParams.set(k, String(v))
|
||||
}
|
||||
const res = await fetch(url, { headers: { 'api-key': apiKey } })
|
||||
if (res.status === 401 || res.status === 403) {
|
||||
throw new HevyApiError(res.status, 'auth')
|
||||
}
|
||||
if (!res.ok) throw new HevyApiError(res.status, `http ${res.status}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
/** Page through a Hevy list endpoint. `pageSize` caps differ per resource. */
|
||||
export async function fetchHevyPages(path, apiKey, {
|
||||
resultKey,
|
||||
pageSize = 10,
|
||||
onProgress,
|
||||
} = {}) {
|
||||
const items = []
|
||||
let page = 1
|
||||
let pageCount = 1
|
||||
while (page <= pageCount) {
|
||||
const data = await hevyGet(path, apiKey, { page, pageSize })
|
||||
pageCount = Math.max(1, data.page_count || 1)
|
||||
const batch = data[resultKey] || []
|
||||
items.push(...batch)
|
||||
onProgress && onProgress({ page, pageCount, loaded: items.length, resultKey })
|
||||
if (!batch.length) break
|
||||
page++
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
export async function fetchHevyAccount(apiKey, { onProgress } = {}) {
|
||||
const key = String(apiKey || '').trim()
|
||||
if (!key) throw new HevyApiError(0, 'empty')
|
||||
|
||||
const templates = await fetchHevyPages('/v1/exercise_templates', key, {
|
||||
resultKey: 'exercise_templates', pageSize: 100,
|
||||
onProgress: p => onProgress && onProgress({ stage: 'templates', ...p }),
|
||||
})
|
||||
const workouts = await fetchHevyPages('/v1/workouts', key, {
|
||||
resultKey: 'workouts', pageSize: 10,
|
||||
onProgress: p => onProgress && onProgress({ stage: 'workouts', ...p }),
|
||||
})
|
||||
const routines = await fetchHevyPages('/v1/routines', key, {
|
||||
resultKey: 'routines', pageSize: 10,
|
||||
onProgress: p => onProgress && onProgress({ stage: 'routines', ...p }),
|
||||
})
|
||||
let bodyMeasurements = []
|
||||
try {
|
||||
bodyMeasurements = await fetchHevyPages('/v1/body_measurements', key, {
|
||||
resultKey: 'body_measurements', pageSize: 10,
|
||||
onProgress: p => onProgress && onProgress({ stage: 'body', ...p }),
|
||||
})
|
||||
} catch (e) {
|
||||
// Older keys / accounts may lack measurements — workouts still import.
|
||||
if (!(e instanceof HevyApiError) || e.message === 'auth') throw e
|
||||
}
|
||||
return { templates, workouts, routines, bodyMeasurements }
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- template → id -- */
|
||||
|
||||
// Hevy primary_muscle_group → openGym body-part for exercises we invent.
|
||||
const HEVY_BP = {
|
||||
biceps: 'upper arms', triceps: 'upper arms', forearms: 'lower arms',
|
||||
chest: 'chest', lats: 'back', upper_back: 'back', lower_back: 'back',
|
||||
traps: 'back', shoulders: 'shoulders',
|
||||
abdominals: 'waist', abs: 'waist', obliques: 'waist',
|
||||
quadriceps: 'upper legs', hamstrings: 'upper legs', glutes: 'upper legs',
|
||||
abductors: 'upper legs', adductors: 'upper legs', calves: 'lower legs',
|
||||
cardio: 'cardio', full_body: 'upper legs', other: 'upper legs', neck: 'neck',
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a Hevy exercise template to a catalogue id.
|
||||
*
|
||||
* Deterministic: only `HEVY_ID_MAP` (generated by scripts/build-hevy-id-map.mjs).
|
||||
* No runtime name guessing — unmatched templates become custom exercises.
|
||||
*/
|
||||
export function matchHevyTemplate(template) {
|
||||
if (!template?.id) return null
|
||||
const id = HEVY_ID_MAP[template.id]
|
||||
return id && EXIDX[id] ? id : null
|
||||
}
|
||||
|
||||
/** Build templateId → catalogue id (or null) from a templates list. */
|
||||
export function buildHevyExerciseMap(templates) {
|
||||
const map = new Map()
|
||||
for (const t of templates || []) {
|
||||
if (!t?.id) continue
|
||||
map.set(t.id, matchHevyTemplate(t))
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- parse ---- */
|
||||
|
||||
const p2 = n => String(n).padStart(2, '0')
|
||||
|
||||
/** Hevy ISO timestamps → local calendar date + ms-since-midnight (matches CSV import). */
|
||||
export function localWhen(iso) {
|
||||
const d = new Date(iso)
|
||||
if (isNaN(d.getTime())) return null
|
||||
const day = `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())}`
|
||||
const t = d.getHours() * 3600000 + d.getMinutes() * 60000 + d.getSeconds() * 1000
|
||||
return { d: day, t }
|
||||
}
|
||||
|
||||
function bpOfTemplate(t) {
|
||||
const g = String(t?.primary_muscle_group || '').toLowerCase()
|
||||
return HEVY_BP[g] || 'upper legs'
|
||||
}
|
||||
|
||||
/** Shared resolver: HEVY_ID_MAP hit, else one custom exercise per Hevy template id. */
|
||||
function makeResolver(templates) {
|
||||
const byId = new Map((templates || []).map(t => [t.id, t]))
|
||||
const created = new Map()
|
||||
const unmatched = new Set()
|
||||
const matchedIds = new Set()
|
||||
|
||||
const resolve = (templateId, fallbackTitle) => {
|
||||
const pinned = templateId && HEVY_ID_MAP[templateId]
|
||||
if (pinned && EXIDX[pinned]) {
|
||||
matchedIds.add(pinned)
|
||||
return pinned
|
||||
}
|
||||
const key = templateId || String(fallbackTitle || '').toLowerCase()
|
||||
if (!key) return null
|
||||
let c = created.get(key)
|
||||
if (!c) {
|
||||
const t = templateId ? byId.get(templateId) : null
|
||||
const name = (t?.title || fallbackTitle || 'exercise').toLowerCase()
|
||||
c = {
|
||||
id: 'im' + uid(), n: name, custom: true, eq: 'custom', tg: '', desc: '',
|
||||
bp: bpOfTemplate(t) || (t?.type === 'distance_duration' || t?.type === 'duration' ? 'cardio' : null)
|
||||
|| 'upper legs',
|
||||
}
|
||||
created.set(key, c)
|
||||
unmatched.add(t?.title || fallbackTitle || name)
|
||||
}
|
||||
return c.id
|
||||
}
|
||||
|
||||
return {
|
||||
resolve,
|
||||
byId,
|
||||
customEx: () => [...created.values()],
|
||||
unmatchedNames: () => [...unmatched].sort(),
|
||||
matchedCount: () => matchedIds.size,
|
||||
createdCount: () => created.size,
|
||||
}
|
||||
}
|
||||
|
||||
const toProfileWeight = (wKg, unit) => {
|
||||
if (wKg == null || !isFinite(wKg)) return 0
|
||||
if (unit === 'lb') return Math.round(wKg / LB_TO_KG * 10) / 10
|
||||
return Math.round(wKg * 10) / 10
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn Hevy API workouts into the same shape `mergeImport` already understands.
|
||||
* Mapping is by `exercise_template_id` through `HEVY_ID_MAP` only — localized
|
||||
* titles on each set are never used to pick a catalogue entry.
|
||||
*/
|
||||
export function parseHevyWorkouts(workouts, templates, { unit = 'kg' } = {}) {
|
||||
const R = makeResolver(templates)
|
||||
const byDate = new Map()
|
||||
let sets = 0, skipped = 0, matched = 0, warmups = 0, rpeSets = 0
|
||||
|
||||
for (const w of workouts || []) {
|
||||
const start = localWhen(w.start_time)
|
||||
const end = localWhen(w.end_time)
|
||||
if (!start) { skipped++; continue }
|
||||
|
||||
let day = byDate.get(start.d)
|
||||
if (!day) {
|
||||
day = { ex: new Map(), name: w.title || '', start: start.t, end: end?.t ?? null }
|
||||
byDate.set(start.d, day)
|
||||
} else if (!day.name && w.title) day.name = w.title
|
||||
if (end?.t != null) day.end = end.t
|
||||
|
||||
for (const ex of w.exercises || []) {
|
||||
const id = R.resolve(ex.exercise_template_id, ex.title)
|
||||
if (!id) { skipped++; continue }
|
||||
if (EXIDX[id] && !String(id).startsWith('im')) matched++
|
||||
|
||||
if (!day.ex.has(id)) day.ex.set(id, [])
|
||||
const list = day.ex.get(id)
|
||||
|
||||
for (const s of ex.sets || []) {
|
||||
const warmup = /warm/i.test(String(s.type || ''))
|
||||
if (warmup) warmups++
|
||||
const reps = s.reps != null ? Math.round(s.reps) : 0
|
||||
const wgt = toProfileWeight(s.weight_kg, unit)
|
||||
const secs = s.duration_seconds != null ? Number(s.duration_seconds) : 0
|
||||
const km = s.distance_meters != null ? Number(s.distance_meters) / 1000 : 0
|
||||
if (!wgt && !reps && !secs && !km) { skipped++; continue }
|
||||
|
||||
const isCardio = (km > 0 || secs > 0) && !reps
|
||||
const mins = secs > 0 ? Math.round(secs / 60 * 10) / 10 : 0
|
||||
const set = isCardio
|
||||
? { min: mins, speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }
|
||||
: { w: wgt, r: reps || 0, done: true, ...(warmup ? { phase: 'warmup' } : {}) }
|
||||
|
||||
if (!isCardio && s.rpe != null && isFinite(Number(s.rpe)) && Number(s.rpe) > 0) {
|
||||
set.rpe = Math.min(10, Math.round(Number(s.rpe) * 100) / 100)
|
||||
rpeSets++
|
||||
}
|
||||
list.push(set)
|
||||
sets++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const dates = [...byDate.keys()].sort()
|
||||
const outWorkouts = dates.map(d => {
|
||||
const day = byDate.get(d)
|
||||
const entries = [...day.ex.entries()].map(([id, ss]) => {
|
||||
const mx = Math.max(0, ...ss.filter(s => !isWarmupRow(s)).map(s => s.w || 0))
|
||||
return { id, sets: ss, topW: mx || null }
|
||||
})
|
||||
const base = new Date(d + 'T00:00:00').getTime()
|
||||
const startMs = base + (day.start ?? 18 * 3600000)
|
||||
const endMs = day.end != null ? base + day.end : startMs
|
||||
const workout = {
|
||||
id: 'iw' + uid(), d, start: startMs, end: endMs > startMs ? endMs : startMs,
|
||||
routineId: null, name: day.name || 'Imported', entries, prs: [],
|
||||
}
|
||||
workout.vol = entries.reduce((a, e) => a + e.sets.reduce((b, s) => b + (s.w || 0) * (s.r || 0), 0), 0)
|
||||
return workout
|
||||
})
|
||||
|
||||
return {
|
||||
kind: 'workouts',
|
||||
source: 'Hevy',
|
||||
workouts: outWorkouts,
|
||||
customEx: R.customEx(),
|
||||
matched: R.matchedCount(),
|
||||
matchedSets: matched,
|
||||
created: R.createdCount(),
|
||||
unmatchedNames: R.unmatchedNames(),
|
||||
sets, skipped, warmups,
|
||||
fileUnit: 'kg',
|
||||
mixedUnits: false,
|
||||
converted: unit === 'lb',
|
||||
rpeSets, rirSets: 0,
|
||||
from: dates[0] || null,
|
||||
to: dates[dates.length - 1] || null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hevy routine → openGym routine config.
|
||||
* Work sets become `sets`×`reps`/`weight`; warm-ups become `warmupSets`;
|
||||
* supersets keep adjacency via `sg`. Always imported as *new* routines.
|
||||
*/
|
||||
export function parseHevyRoutines(routines, templates, { unit = 'kg' } = {}) {
|
||||
const R = makeResolver(templates)
|
||||
const out = []
|
||||
|
||||
for (const r of routines || []) {
|
||||
const ex = []
|
||||
const sgMap = new Map() // Hevy superset_id → openGym sg token
|
||||
|
||||
for (const he of r.exercises || []) {
|
||||
const id = R.resolve(he.exercise_template_id, he.title)
|
||||
if (!id) continue
|
||||
|
||||
const allSets = he.sets || []
|
||||
const warm = allSets.filter(s => /warm/i.test(String(s.type || ''))).length
|
||||
const work = allSets.filter(s => !/warm/i.test(String(s.type || '')))
|
||||
if (!work.length && !warm) continue
|
||||
|
||||
const sample = work[0] || allSets[0]
|
||||
const reps = sample?.reps != null ? Math.round(sample.reps) : 0
|
||||
const secs = sample?.duration_seconds != null ? Number(sample.duration_seconds) : 0
|
||||
const km = sample?.distance_meters != null ? Number(sample.distance_meters) / 1000 : 0
|
||||
const wgt = toProfileWeight(sample?.weight_kg, unit)
|
||||
const nWork = Math.max(1, work.length)
|
||||
|
||||
let cfg
|
||||
if (km > 0 && !reps) {
|
||||
const mins = secs > 0 ? Math.round(secs / 60 * 10) / 10 : 20
|
||||
cfg = {
|
||||
id, sets: nWork, min: mins || 20,
|
||||
speed: mins > 0 ? Math.round(km / (mins / 60) * 10) / 10 : 0,
|
||||
}
|
||||
} else if (secs > 0 && !reps && !wgt) {
|
||||
cfg = { id, sets: nWork, sec: Math.round(secs), weight: 0, mode: 'time' }
|
||||
} else {
|
||||
cfg = { id, sets: nWork, reps: reps || 10, weight: wgt || 0, mode: 'reps' }
|
||||
}
|
||||
if (warm > 0) cfg.warmupSets = Math.min(5, warm)
|
||||
if (he.notes) cfg.note = String(he.notes).slice(0, 280)
|
||||
|
||||
if (he.superset_id != null && he.superset_id !== '') {
|
||||
const key = String(he.superset_id)
|
||||
if (!sgMap.has(key)) sgMap.set(key, 'hs' + uid())
|
||||
cfg.sg = sgMap.get(key)
|
||||
}
|
||||
ex.push(cfg)
|
||||
}
|
||||
|
||||
if (!ex.length) continue
|
||||
// Drop singleton supersets (partner missing after drops).
|
||||
ex.forEach((e, i) => {
|
||||
if (e.sg && !(ex[i - 1]?.sg === e.sg || ex[i + 1]?.sg === e.sg)) delete e.sg
|
||||
})
|
||||
|
||||
out.push({
|
||||
id: 'hr' + uid(),
|
||||
name: (r.title || 'Imported').trim() || 'Imported',
|
||||
emoji: 'figureStrength',
|
||||
hevyId: r.id || null,
|
||||
ex,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'routines',
|
||||
source: 'Hevy',
|
||||
routines: out,
|
||||
customEx: R.customEx(),
|
||||
matched: R.matchedCount(),
|
||||
created: R.createdCount(),
|
||||
unmatchedNames: R.unmatchedNames(),
|
||||
exerciseCount: out.reduce((n, r) => n + r.ex.length, 0),
|
||||
converted: unit === 'lb',
|
||||
}
|
||||
}
|
||||
|
||||
/** Merge Hevy routines into state — always added as new routines (fresh ids). */
|
||||
export function mergeHevyRoutines(S, parsed) {
|
||||
S.customEx = S.customEx || []
|
||||
S.routines = S.routines || []
|
||||
const exIdMap = {}
|
||||
;(parsed.customEx || []).forEach(c => {
|
||||
const same = S.customEx.find(x => (x.n || '').toLowerCase() === (c.n || '').toLowerCase() && x.bp === c.bp)
|
||||
if (same) { exIdMap[c.id] = same.id; return }
|
||||
// Keep the pre-assigned id from parse so routine configs already point at it.
|
||||
if (!S.customEx.some(x => x.id === c.id)) S.customEx.push(c)
|
||||
})
|
||||
let added = 0
|
||||
for (const r of parsed.routines || []) {
|
||||
S.routines.push({
|
||||
id: uid(),
|
||||
name: r.name,
|
||||
emoji: r.emoji || 'figureStrength',
|
||||
ex: (r.ex || []).map(e => ({ ...e, id: exIdMap[e.id] || e.id })),
|
||||
})
|
||||
added++
|
||||
}
|
||||
return { added }
|
||||
}
|
||||
|
||||
/** Body measurements from the Hevy API → `mergeImport` bodyweight shape. */
|
||||
export function parseHevyBodyweight(measurements, { unit = 'kg' } = {}) {
|
||||
const out = new Map()
|
||||
for (const m of measurements || []) {
|
||||
const d = String(m.date || '').slice(0, 10)
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(d)) continue
|
||||
let w = Number(m.weight_kg)
|
||||
if (!isFinite(w) || w <= 0) continue
|
||||
if (unit === 'lb') w = Math.round(w / LB_TO_KG * 10) / 10
|
||||
else w = Math.round(w * 10) / 10
|
||||
const t = m.created_at ? new Date(m.created_at).getTime() : new Date(d + 'T12:00:00').getTime()
|
||||
out.set(d, { d, w, t: isFinite(t) ? t : new Date(d + 'T12:00:00').getTime() })
|
||||
}
|
||||
const dates = [...out.keys()].sort()
|
||||
return {
|
||||
kind: 'bodyweight',
|
||||
source: 'Hevy',
|
||||
bodyweight: dates.map(d => out.get(d)),
|
||||
fileUnit: 'kg',
|
||||
converted: unit === 'lb',
|
||||
from: dates[0] || null,
|
||||
to: dates[dates.length - 1] || null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch + parse. Returns `{ workouts, routines, bodyweight }` ready to merge,
|
||||
* or throws `HevyApiError`. The apiKey is only read here — never written.
|
||||
*/
|
||||
export async function importHevyData(apiKey, { unit = 'kg', onProgress } = {}) {
|
||||
const { templates, workouts, routines, bodyMeasurements } = await fetchHevyAccount(apiKey, { onProgress })
|
||||
onProgress && onProgress({ stage: 'parse' })
|
||||
return {
|
||||
workouts: parseHevyWorkouts(workouts, templates, { unit }),
|
||||
routines: parseHevyRoutines(routines, templates, { unit }),
|
||||
bodyweight: parseHevyBodyweight(bodyMeasurements, { unit }),
|
||||
templateCount: templates.length,
|
||||
}
|
||||
}
|
||||
|
||||
export { HevyApiError }
|
||||
@@ -0,0 +1,291 @@
|
||||
import { describe, expect, it, vi, afterEach } from 'vitest'
|
||||
import {
|
||||
matchHevyTemplate, buildHevyExerciseMap, parseHevyWorkouts, parseHevyBodyweight,
|
||||
parseHevyRoutines, mergeHevyRoutines, localWhen, importHevyData, HevyApiError, HEVY_ID_MAP,
|
||||
} from './import-hevy.js'
|
||||
import { EXIDX } from './exercises.js'
|
||||
import { mergeImport } from './import-csv.js'
|
||||
|
||||
const TEMPLATES = [
|
||||
{
|
||||
id: '3303376C', title: 'Elliptical Trainer', type: 'distance_duration',
|
||||
primary_muscle_group: 'cardio', secondary_muscle_groups: [], equipment: 'machine', is_custom: false,
|
||||
},
|
||||
{
|
||||
id: '4E5257DE', title: 'Lat Pulldown - Close Grip (Cable)', type: 'weight_reps',
|
||||
primary_muscle_group: 'lats', secondary_muscle_groups: [], equipment: 'machine', is_custom: false,
|
||||
},
|
||||
{
|
||||
id: 'DEADBEEF', title: 'My Invented Landmine Twist', type: 'weight_reps',
|
||||
primary_muscle_group: 'abdominals', secondary_muscle_groups: [], equipment: 'other', is_custom: true,
|
||||
},
|
||||
{
|
||||
id: '99D5F10E', title: 'Ab Wheel', type: 'reps_only',
|
||||
primary_muscle_group: 'abdominals', secondary_muscle_groups: [], equipment: 'other', is_custom: false,
|
||||
},
|
||||
]
|
||||
|
||||
const WORKOUT = {
|
||||
id: 'w1',
|
||||
title: 'Oberkörper 2',
|
||||
start_time: '2026-08-25T10:10:24+00:00',
|
||||
end_time: '2026-08-25T11:10:08+00:00',
|
||||
exercises: [
|
||||
{
|
||||
index: 0,
|
||||
title: 'Crosstrainer', // localized — must NOT drive the match
|
||||
exercise_template_id: '3303376C',
|
||||
sets: [{
|
||||
index: 0, type: 'normal', weight_kg: null, reps: null,
|
||||
distance_meters: 480, duration_seconds: 180, rpe: null,
|
||||
}],
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
title: 'Latzug - Enger Griff (Kabel)',
|
||||
exercise_template_id: '4E5257DE',
|
||||
sets: [
|
||||
{ index: 0, type: 'warmup', weight_kg: 25, reps: 15, distance_meters: null, duration_seconds: null, rpe: null },
|
||||
{ index: 1, type: 'normal', weight_kg: 52, reps: 15, distance_meters: null, duration_seconds: null, rpe: 8 },
|
||||
{ index: 2, type: 'normal', weight_kg: 52, reps: 10, distance_meters: null, duration_seconds: null, rpe: null },
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
title: 'Meine Eigenkreation',
|
||||
exercise_template_id: 'DEADBEEF',
|
||||
sets: [
|
||||
{ index: 0, type: 'normal', weight_kg: 20, reps: 12, distance_meters: null, duration_seconds: null, rpe: null },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
describe('HEVY_ID_MAP', () => {
|
||||
it('only points at real catalogue ids', () => {
|
||||
for (const id of Object.values(HEVY_ID_MAP)) {
|
||||
expect(EXIDX[id], `catalogue missing ${id}`).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
// Real import leftovers: same lifts under Hevy's naming. Map lookup is the
|
||||
// only resolution path — titles are never guessed at runtime.
|
||||
const PINNED = {
|
||||
B5D3A742: '0410', // Bulgarian Split Squat (Dumbbell)
|
||||
'914F3A96': '0327', // Chest Supported Incline Row (Dumbbell)
|
||||
'98237BA2': '0826', // Knee Raise Parallel Bars
|
||||
'4E5257DE': '2616', // Lat Pulldown - Close Grip (Cable)
|
||||
C315DC2A: '0602', // Rear Delt Reverse Fly (Cable)
|
||||
FFDA283B: '0381', // Reverse Lunge (Dumbbell)
|
||||
'8BAB2735': '0318', // Seated Incline Curl (Dumbbell)
|
||||
'9237BAD1': '0603', // Seated Shoulder Press (Machine)
|
||||
B05C2C29: '0605', // Single Leg Standing Calf Raise (Machine)
|
||||
'3303376C': '2141', // Elliptical Trainer
|
||||
'99D5F10E': '0857', // Ab Wheel
|
||||
}
|
||||
for (const [hid, want] of Object.entries(PINNED)) {
|
||||
it(`maps ${hid} → ${want} (${EXIDX[want]?.n})`, () => {
|
||||
expect(HEVY_ID_MAP[hid]).toBe(want)
|
||||
expect(matchHevyTemplate({ id: hid, title: 'ignored localized name' })).toBe(want)
|
||||
})
|
||||
}
|
||||
|
||||
it('leaves catalogue gaps unmapped (import as custom)', () => {
|
||||
for (const id of ['68CE0B9B', '0222DB42', 'D1CD146F']) {
|
||||
expect(HEVY_ID_MAP[id]).toBeUndefined()
|
||||
expect(matchHevyTemplate({ id, title: 'whatever' })).toBeNull()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('matchHevyTemplate', () => {
|
||||
it('is map-only — title never overrides the id', () => {
|
||||
expect(matchHevyTemplate({ id: '3303376C', title: 'Totally Wrong Name' })).toBe('2141')
|
||||
expect(matchHevyTemplate({ id: 'DEADBEEF', title: 'Bench Press' })).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseHevyWorkouts', () => {
|
||||
it('maps by template id, not the localized workout title', () => {
|
||||
const parsed = parseHevyWorkouts([WORKOUT], TEMPLATES, { unit: 'kg' })
|
||||
expect(parsed.error).toBeUndefined()
|
||||
expect(parsed.source).toBe('Hevy')
|
||||
expect(parsed.workouts).toHaveLength(1)
|
||||
|
||||
const entries = parsed.workouts[0].entries
|
||||
const elliptical = entries.find(e => e.id === '2141')
|
||||
expect(elliptical).toBeTruthy()
|
||||
expect(elliptical.sets[0]).toMatchObject({ min: 3, done: true })
|
||||
|
||||
const pulldown = entries.find(e => e.id === '2616')
|
||||
expect(pulldown).toBeTruthy()
|
||||
expect(pulldown.sets[0]).toMatchObject({ w: 25, r: 15, phase: 'warmup' })
|
||||
expect(pulldown.sets[1]).toMatchObject({ w: 52, r: 15, rpe: 8 })
|
||||
expect(pulldown.topW).toBe(52)
|
||||
expect(parsed.warmups).toBe(1)
|
||||
expect(parsed.rpeSets).toBe(1)
|
||||
|
||||
const custom = entries.find(e => String(e.id).startsWith('im'))
|
||||
expect(custom).toBeTruthy()
|
||||
expect(parsed.customEx.some(c => c.id === custom.id && c.n === 'my invented landmine twist')).toBe(true)
|
||||
expect(parsed.customEx.find(c => c.id === custom.id).bp).toBe('waist')
|
||||
expect(parsed.unmatchedNames).toContain('My Invented Landmine Twist')
|
||||
})
|
||||
|
||||
it('converts kg weights into a lb profile', () => {
|
||||
const parsed = parseHevyWorkouts([WORKOUT], TEMPLATES, { unit: 'lb' })
|
||||
const pulldown = parsed.workouts[0].entries.find(e => e.id === '2616')
|
||||
expect(pulldown.sets.find(s => s.r === 15 && !s.phase).w).toBeCloseTo(114.6, 0)
|
||||
expect(parsed.converted).toBe(true)
|
||||
})
|
||||
|
||||
it('merges two Hevy sessions on the same local day', () => {
|
||||
const a = { ...WORKOUT, id: 'a', title: 'AM', exercises: [WORKOUT.exercises[0]] }
|
||||
const b = {
|
||||
...WORKOUT, id: 'b', title: 'PM',
|
||||
start_time: '2026-08-25T18:00:00+00:00',
|
||||
end_time: '2026-08-25T19:00:00+00:00',
|
||||
exercises: [WORKOUT.exercises[1]],
|
||||
}
|
||||
const parsed = parseHevyWorkouts([a, b], TEMPLATES, { unit: 'kg' })
|
||||
expect(parsed.workouts).toHaveLength(1)
|
||||
expect(parsed.workouts[0].entries.length).toBeGreaterThanOrEqual(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseHevyBodyweight', () => {
|
||||
it('reads weigh-ins in the profile unit', () => {
|
||||
const parsed = parseHevyBodyweight([
|
||||
{ id: 1, date: '2026-08-23', weight_kg: 83.2, created_at: '2026-08-23T18:22:48.070Z' },
|
||||
], { unit: 'kg' })
|
||||
expect(parsed.bodyweight).toEqual([{ d: '2026-08-23', w: 83.2, t: expect.any(Number) }])
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeImport with Hevy payloads', () => {
|
||||
it('adds workouts and skips days that already exist', () => {
|
||||
const parsed = parseHevyWorkouts([WORKOUT], TEMPLATES, { unit: 'kg' })
|
||||
const S = { workouts: [], customEx: [], exWeights: {}, bodyweight: [] }
|
||||
const first = mergeImport(S, parsed)
|
||||
expect(first.added).toBe(1)
|
||||
expect(S.customEx.length).toBe(1)
|
||||
const second = mergeImport(S, parsed)
|
||||
expect(second.added).toBe(0)
|
||||
expect(S.workouts).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('localWhen', () => {
|
||||
it('parses an ISO timestamp into a local calendar day', () => {
|
||||
const w = localWhen('2026-08-25T10:10:24+00:00')
|
||||
expect(w.d).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
||||
expect(w.t).toBeGreaterThanOrEqual(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('importHevyData', () => {
|
||||
afterEach(() => { vi.unstubAllGlobals(); vi.restoreAllMocks() })
|
||||
|
||||
it('pages templates and workouts, never persists the key', async () => {
|
||||
const calls = []
|
||||
vi.stubGlobal('fetch', vi.fn(async (url, opts) => {
|
||||
calls.push({ url: String(url), key: opts.headers['api-key'] })
|
||||
const u = String(url)
|
||||
if (u.includes('/exercise_templates')) {
|
||||
return { ok: true, status: 200, json: async () => ({ page: 1, page_count: 1, exercise_templates: TEMPLATES }) }
|
||||
}
|
||||
if (u.includes('/workouts')) {
|
||||
return { ok: true, status: 200, json: async () => ({ page: 1, page_count: 1, workouts: [WORKOUT] }) }
|
||||
}
|
||||
if (u.includes('/routines')) {
|
||||
return { ok: true, status: 200, json: async () => ({ page: 1, page_count: 1, routines: [] }) }
|
||||
}
|
||||
if (u.includes('/body_measurements')) {
|
||||
return { ok: true, status: 200, json: async () => ({ page: 1, page_count: 1, body_measurements: [] }) }
|
||||
}
|
||||
return { ok: false, status: 404, json: async () => ({}) }
|
||||
}))
|
||||
|
||||
const result = await importHevyData('test-key-not-stored', { unit: 'kg' })
|
||||
expect(result.workouts.workouts).toHaveLength(1)
|
||||
expect(result.routines.routines).toHaveLength(0)
|
||||
expect(result.bodyweight.bodyweight).toHaveLength(0)
|
||||
expect(calls.every(c => c.key === 'test-key-not-stored')).toBe(true)
|
||||
})
|
||||
|
||||
it('surfaces a refused key as HevyApiError auth', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: false, status: 401, json: async () => ({}) })))
|
||||
await expect(importHevyData('bad')).rejects.toMatchObject({ name: 'HevyApiError', message: 'auth' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseHevyRoutines', () => {
|
||||
const ROUTINE = {
|
||||
id: 'r1',
|
||||
title: 'Oberkörper 2',
|
||||
exercises: [
|
||||
{
|
||||
title: 'Crosstrainer',
|
||||
exercise_template_id: '3303376C',
|
||||
superset_id: null,
|
||||
sets: [{ type: 'normal', weight_kg: null, reps: null, distance_meters: 480, duration_seconds: 180 }],
|
||||
},
|
||||
{
|
||||
title: 'Latzug',
|
||||
exercise_template_id: '4E5257DE',
|
||||
superset_id: 1,
|
||||
sets: [
|
||||
{ type: 'warmup', weight_kg: 25, reps: 15 },
|
||||
{ type: 'normal', weight_kg: 52, reps: 15 },
|
||||
{ type: 'normal', weight_kg: 52, reps: 12 },
|
||||
{ type: 'normal', weight_kg: 52, reps: 10 },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Row partner',
|
||||
exercise_template_id: '914F3A96', // chest supported incline row → 0327
|
||||
superset_id: 1,
|
||||
sets: [
|
||||
{ type: 'normal', weight_kg: 20, reps: 12 },
|
||||
{ type: 'normal', weight_kg: 20, reps: 12 },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
it('builds openGym routine configs from Hevy sets', () => {
|
||||
const parsed = parseHevyRoutines([ROUTINE], TEMPLATES, { unit: 'kg' })
|
||||
expect(parsed.routines).toHaveLength(1)
|
||||
expect(parsed.routines[0].name).toBe('Oberkörper 2')
|
||||
expect(parsed.exerciseCount).toBe(3)
|
||||
|
||||
const [cardio, pull, row] = parsed.routines[0].ex
|
||||
expect(cardio.id).toBe('2141')
|
||||
expect(cardio).toMatchObject({ sets: 1, min: 3 })
|
||||
expect(pull.id).toBe('2616')
|
||||
expect(pull).toMatchObject({ sets: 3, reps: 15, weight: 52, warmupSets: 1 })
|
||||
expect(row.id).toBe('0327')
|
||||
expect(pull.sg).toBeTruthy()
|
||||
expect(pull.sg).toBe(row.sg)
|
||||
})
|
||||
|
||||
it('mergeHevyRoutines always adds new routines', () => {
|
||||
const parsed = parseHevyRoutines([ROUTINE], TEMPLATES, { unit: 'kg' })
|
||||
const S = { routines: [], customEx: [] }
|
||||
expect(mergeHevyRoutines(S, parsed).added).toBe(1)
|
||||
expect(S.routines).toHaveLength(1)
|
||||
expect(mergeHevyRoutines(S, parsed).added).toBe(1)
|
||||
expect(S.routines).toHaveLength(2)
|
||||
expect(S.routines[0].id).not.toBe(S.routines[1].id)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildHevyExerciseMap', () => {
|
||||
it('indexes every template id from the static map', () => {
|
||||
const map = buildHevyExerciseMap(TEMPLATES)
|
||||
expect(map.get('3303376C')).toBe('2141')
|
||||
expect(map.get('4E5257DE')).toBe('2616')
|
||||
expect(map.get('DEADBEEF')).toBeNull()
|
||||
expect(map.size).toBe(TEMPLATES.length)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { matchExercise, parseWorkoutCSV } from './import-csv.js'
|
||||
import { matchExercise, matchHevyTitle, parseWorkoutCSV, detectSource } from './import-csv.js'
|
||||
import { EXIDX } from './exercises.js'
|
||||
|
||||
// The names other apps actually export, and the catalogue entry each has to land on.
|
||||
@@ -109,3 +109,36 @@ describe('invented exercises get a body part from their name', () => {
|
||||
expect(r.customEx[0].bp).toBe('shoulders')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Hevy CSV uses the generated title map', () => {
|
||||
const HEVY_CSV = [
|
||||
'title,start_time,end_time,description,exercise_title,superset_id,exercise_notes,set_index,set_type,weight_kg,reps,distance_km,duration_seconds,rpe',
|
||||
'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Bulgarian Split Squat (Dumbbell),,,0,normal,40,10,0,,',
|
||||
'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Lat Pulldown - Close Grip (Cable),,,0,warmup,25,15,0,,',
|
||||
'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Lat Pulldown - Close Grip (Cable),,,1,normal,52,12,0,,8',
|
||||
'Push,2026-08-01 10:00:00,2026-08-01 11:00:00,,Reverse Lunge (Dumbbell),,,0,normal,20,10,0,,',
|
||||
].join('\n')
|
||||
|
||||
it('detects the Hevy export dialect', () => {
|
||||
expect(detectSource(HEVY_CSV.split('\n')[0].split(','))).toBe('Hevy')
|
||||
})
|
||||
|
||||
it('resolves English Hevy titles through HEVY_TITLE_MAP before the word-bag', () => {
|
||||
expect(matchHevyTitle('Bulgarian Split Squat (Dumbbell)')).toBe('0410')
|
||||
expect(matchHevyTitle('Lat Pulldown - Close Grip (Cable)')).toBe('2616')
|
||||
expect(matchHevyTitle('Reverse Lunge (Dumbbell)')).toBe('0381')
|
||||
// Word-bag alone still misses these — the title map is what makes CSV work.
|
||||
expect(matchExercise('Bulgarian Split Squat (Dumbbell)')).toBeNull()
|
||||
})
|
||||
|
||||
it('imports a Hevy CSV onto catalogue ids, not customs', () => {
|
||||
const parsed = parseWorkoutCSV(HEVY_CSV, { unit: 'kg' })
|
||||
expect(parsed.source).toBe('Hevy')
|
||||
expect(parsed.created).toBe(0)
|
||||
const ids = parsed.workouts[0].entries.map(e => e.id).sort()
|
||||
expect(ids).toEqual(['0410', '0381', '2616'].sort())
|
||||
const pull = parsed.workouts[0].entries.find(e => e.id === '2616')
|
||||
expect(pull.sets[0]).toMatchObject({ w: 25, r: 15, phase: 'warmup' })
|
||||
expect(pull.sets[1]).toMatchObject({ w: 52, r: 12, rpe: 8 })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user