@trainheroic-unofficial/dto 3.7.1 → 4.0.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.
package/README.md CHANGED
@@ -54,8 +54,9 @@ re-exported through `index.ts`. The central pieces:
54
54
  block type, where athletes are ranked on a score).
55
55
  - The read-back types (`ReadResult`, `ReadBlock`, `ReadExercise`) describe a session decoded
56
56
  back out of the API into a readable shape, and `Advisory` carries the unit notes and
57
- warnings the encoder emits (for example, a prescription whose unit does not match the
58
- exercise's parameter type).
57
+ warnings the encoder emits. Workout input requires `primaryUnit` for populated `reps`
58
+ and `secondaryUnit` for populated `weight`; the builder checks those units against the
59
+ exercise library before writing.
59
60
  - The `responses` module holds the tolerant schemas the SDK uses to sanity-check an API
60
61
  response before trusting it; these schemas accept unknown fields.
61
62
 
package/dist/index.d.mts CHANGED
@@ -1286,6 +1286,8 @@ export declare const exerciseSpecSchema: z.ZodObject<{
1286
1286
  reps: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>;
1287
1287
  sets: z.ZodOptional<z.ZodNumber>;
1288
1288
  weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
1289
+ primaryUnit: z.ZodOptional<z.ZodString>;
1290
+ secondaryUnit: z.ZodOptional<z.ZodString>;
1289
1291
  rpe: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
1290
1292
  instr: z.ZodOptional<z.ZodString>;
1291
1293
  param_1_type: z.ZodOptional<z.ZodNumber>;
@@ -1321,6 +1323,8 @@ export declare const blockSpecSchema: z.ZodObject<{
1321
1323
  reps: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>;
1322
1324
  sets: z.ZodOptional<z.ZodNumber>;
1323
1325
  weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
1326
+ primaryUnit: z.ZodOptional<z.ZodString>;
1327
+ secondaryUnit: z.ZodOptional<z.ZodString>;
1324
1328
  rpe: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
1325
1329
  instr: z.ZodOptional<z.ZodString>;
1326
1330
  param_1_type: z.ZodOptional<z.ZodNumber>;
@@ -1346,6 +1350,8 @@ export declare const workoutSpecSchema: z.ZodObject<{
1346
1350
  reps: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>]>>;
1347
1351
  sets: z.ZodOptional<z.ZodNumber>;
1348
1352
  weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
1353
+ primaryUnit: z.ZodOptional<z.ZodString>;
1354
+ secondaryUnit: z.ZodOptional<z.ZodString>;
1349
1355
  rpe: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
1350
1356
  instr: z.ZodOptional<z.ZodString>;
1351
1357
  param_1_type: z.ZodOptional<z.ZodNumber>;
package/dist/index.mjs CHANGED
@@ -763,14 +763,26 @@ const exerciseSpecSchema = z.object({
763
763
  z.number(),
764
764
  z.string(),
765
765
  z.array(z.union([z.number(), z.string()]))
766
- ]).optional(),
766
+ ]).optional().describe("Primary slot values; may be reps, distance, or time. State primaryUnit."),
767
767
  sets: z.number().optional(),
768
- weight: z.union([z.number(), z.array(z.number())]).optional(),
768
+ weight: z.union([z.number(), z.array(z.number())]).optional().describe("Secondary slot values; may be weight or time. State secondaryUnit."),
769
+ primaryUnit: z.string().trim().min(1).optional().describe("Intended primary unit from exercise_resolve, such as reps, m, mi, or sec."),
770
+ secondaryUnit: z.string().trim().min(1).optional().describe("Intended secondary unit from exercise_resolve, such as lb or sec."),
769
771
  rpe: z.union([z.number(), z.string()]).optional(),
770
772
  instr: z.string().optional(),
771
773
  param_1_type: z.number().optional(),
772
774
  param_2_type: z.number().optional()
773
775
  }).superRefine((exercise, ctx) => {
776
+ if (exercise.reps !== void 0 && exercise.primaryUnit === void 0) ctx.addIssue({
777
+ code: "custom",
778
+ message: "primaryUnit is required when reps contains primary slot values.",
779
+ path: ["primaryUnit"]
780
+ });
781
+ if (exercise.weight !== void 0 && exercise.secondaryUnit === void 0) ctx.addIssue({
782
+ code: "custom",
783
+ message: "secondaryUnit is required when weight contains secondary slot values.",
784
+ path: ["secondaryUnit"]
785
+ });
774
786
  if (Array.isArray(exercise.reps) && Array.isArray(exercise.weight) && exercise.reps.length !== exercise.weight.length) ctx.addIssue({
775
787
  code: "custom",
776
788
  message: `Per-set reps and weight arrays must have the same length; received ${exercise.reps.length} reps and ${exercise.weight.length} weights.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/dto",
3
- "version": "3.7.1",
3
+ "version": "4.0.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",