@trainheroic-unofficial/dto 3.5.0 → 3.5.2

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.d.mts CHANGED
@@ -1349,7 +1349,9 @@ type WorkoutDate = readonly [number, number, number];
1349
1349
  /**
1350
1350
  * Parse a `YYYY-M-D` string into the `WorkoutDate` tuple. The single home for this
1351
1351
  * conversion, shared by the MCP tools and the CLI so they cannot drift on what counts
1352
- * as a valid date. Each part must be an integer.
1352
+ * as a valid date. Each part must be a run of digits (`Number("")` is 0, so a blank part such as
1353
+ * the trailing one in "2026-9-" must be rejected explicitly), and month/day must be in range so
1354
+ * a typo cannot land a session on a date the calendar does not have.
1353
1355
  */
1354
1356
  declare function parseWorkoutDate(s: string): WorkoutDate;
1355
1357
  /** Unit advisories surfaced when building: informational notes and override warnings. */
package/dist/index.mjs CHANGED
@@ -744,6 +744,12 @@ const exerciseSpecSchema = z.object({
744
744
  instr: z.string().optional(),
745
745
  param_1_type: z.number().optional(),
746
746
  param_2_type: z.number().optional()
747
+ }).superRefine((exercise, ctx) => {
748
+ if (Array.isArray(exercise.reps) && Array.isArray(exercise.weight) && exercise.reps.length !== exercise.weight.length) ctx.addIssue({
749
+ code: "custom",
750
+ message: `Per-set reps and weight arrays must have the same length; received ${exercise.reps.length} reps and ${exercise.weight.length} weights.`,
751
+ path: ["weight"]
752
+ });
747
753
  });
748
754
  /** A block's Red-Zone leaderboard: a unit string/number, or an object with options. */
749
755
  const leaderboardSpecSchema = z.union([
@@ -783,15 +789,19 @@ const workoutSpecSchema = z.object({
783
789
  /**
784
790
  * Parse a `YYYY-M-D` string into the `WorkoutDate` tuple. The single home for this
785
791
  * conversion, shared by the MCP tools and the CLI so they cannot drift on what counts
786
- * as a valid date. Each part must be an integer.
792
+ * as a valid date. Each part must be a run of digits (`Number("")` is 0, so a blank part such as
793
+ * the trailing one in "2026-9-" must be rejected explicitly), and month/day must be in range so
794
+ * a typo cannot land a session on a date the calendar does not have.
787
795
  */
788
796
  function parseWorkoutDate(s) {
789
- const parts = s.split("-").map((p) => Number(p));
790
- if (parts.length !== 3 || parts.some((n) => !Number.isInteger(n))) throw new Error(`date must be YYYY-M-D, got "${s}".`);
797
+ const parts = s.split("-");
798
+ if (parts.length !== 3 || parts.some((p) => !/^\d+$/u.test(p))) throw new Error(`date must be YYYY-M-D, got "${s}".`);
799
+ const [year, month, day] = parts.map(Number);
800
+ if (month < 1 || month > 12 || day < 1 || day > 31) throw new Error(`date must be YYYY-M-D with a real month and day, got "${s}".`);
791
801
  return [
792
- parts[0],
793
- parts[1],
794
- parts[2]
802
+ year,
803
+ month,
804
+ day
795
805
  ];
796
806
  }
797
807
  /** Body for `POST /v5/sessions/template` (library create, not save-from-session). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/dto",
3
- "version": "3.5.0",
3
+ "version": "3.5.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",