@trainheroic-unofficial/cli 0.2.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +24 -8
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -270,12 +270,31 @@ function unitLabel(paramType) {
270
270
  if (t === null) return null;
271
271
  return PARAM_UNIT[t] ?? null;
272
272
  }
273
- /** Annotate a row with human-readable units for display. */
273
+ /**
274
+ * Fixed measurement units for an exercise, ordered by entry slot (param 1, then param 2).
275
+ * Positional, not semantic: some exercises reverse the slots, so the array is not labelled
276
+ * by role. A null entry is an unset slot.
277
+ */
278
+ function exerciseUnits(param1, param2) {
279
+ return [unitLabel(param1), unitLabel(param2)];
280
+ }
281
+ /** Present a row for display: drop the raw param-type codes, surface units positionally. */
274
282
  function withUnits(row) {
283
+ const { param_1_type, param_2_type, ...rest } = row;
284
+ return {
285
+ ...rest,
286
+ units: exerciseUnits(param_1_type, param_2_type)
287
+ };
288
+ }
289
+ /**
290
+ * Present a full raw exercise object for display: drop the raw param-type codes and add the
291
+ * positional `units` array. Keeps every other field of the raw object intact.
292
+ */
293
+ function presentExercise(raw) {
294
+ const { param_1_type, param_2_type, ...rest } = raw;
275
295
  return {
276
- ...row,
277
- param_1_unit: unitLabel(row.param_1_type),
278
- param_2_unit: unitLabel(row.param_2_type)
296
+ ...rest,
297
+ units: exerciseUnits(param_1_type, param_2_type)
279
298
  };
280
299
  }
281
300
  function buildSearchText(title) {
@@ -831,10 +850,7 @@ var ExerciseLibrary = class {
831
850
  await this.ensureFresh();
832
851
  const s = this.#byId.get(id);
833
852
  if (!s) return null;
834
- const full = { ...s.raw };
835
- full.param_1_unit = unitLabel(full.param_1_type);
836
- full.param_2_unit = unitLabel(full.param_2_type);
837
- return full;
853
+ return presentExercise(s.raw);
838
854
  }
839
855
  async defaults(id) {
840
856
  const s = this.#byId.get(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/dto": "0.2.0",
25
- "@trainheroic-unofficial/js": "0.2.0"
24
+ "@trainheroic-unofficial/dto": "0.3.0",
25
+ "@trainheroic-unofficial/js": "0.3.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.0.0",