@trainheroic-unofficial/dto 2.0.1 → 2.0.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
@@ -701,7 +701,11 @@ declare const leaderboardSpecSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumb
701
701
  instruction: z.ZodOptional<z.ZodString>;
702
702
  }, z.core.$strip>]>;
703
703
  type LeaderboardSpec = z.infer<typeof leaderboardSpecSchema>;
704
- /** A block (group of exercises); two exercises render as a superset. */
704
+ /**
705
+ * A block (group of exercises); two exercises render as a superset.
706
+ * Empty `exercises` is allowed only with a non-empty `instruction` — that is TrainHeroic's
707
+ * free-text Circuit / Conditioning block (type 1): title + instruction blurb, no linked lifts.
708
+ */
705
709
  declare const blockSpecSchema: z.ZodObject<{
706
710
  title: z.ZodString;
707
711
  type: z.ZodOptional<z.ZodNumber>;
@@ -779,6 +783,8 @@ type ReadExercise = {
779
783
  type ReadBlock = {
780
784
  order: number;
781
785
  title: string;
786
+ /** Block-level coach note (free-text Circuit / conditioning blurbs live here). */
787
+ instruction: string;
782
788
  leaderboard: string | null;
783
789
  exercises: ReadExercise[];
784
790
  };
package/dist/index.mjs CHANGED
@@ -340,13 +340,24 @@ const leaderboardSpecSchema = z.union([
340
340
  instruction: z.string().optional()
341
341
  })
342
342
  ]);
343
- /** A block (group of exercises); two exercises render as a superset. */
343
+ /**
344
+ * A block (group of exercises); two exercises render as a superset.
345
+ * Empty `exercises` is allowed only with a non-empty `instruction` — that is TrainHeroic's
346
+ * free-text Circuit / Conditioning block (type 1): title + instruction blurb, no linked lifts.
347
+ */
344
348
  const blockSpecSchema = z.object({
345
349
  title: z.string(),
346
350
  type: z.number().optional(),
347
351
  instruction: z.string().optional(),
348
352
  leaderboard: leaderboardSpecSchema.optional(),
349
353
  exercises: z.array(exerciseSpecSchema)
354
+ }).superRefine((block, ctx) => {
355
+ if (block.exercises.length > 0) return;
356
+ if ((block.instruction?.trim() ?? "") === "") ctx.addIssue({
357
+ code: "custom",
358
+ message: "A block with no exercises needs a non-empty instruction (text-only Circuit / Conditioning block). Otherwise provide at least one exercise.",
359
+ path: ["exercises"]
360
+ });
350
361
  });
351
362
  /** A full session spec: the blocks plus an optional session note (Coach Instructions). */
352
363
  const workoutSpecSchema = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/dto",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",