@trainheroic-unofficial/dto 4.1.1 → 4.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.
package/README.md CHANGED
@@ -55,8 +55,8 @@ re-exported through `index.ts`. The central pieces:
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
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.
58
+ and `secondaryUnit` for populated `weight`; the builder maps each unit to a TrainHeroic param
59
+ type, using the exercise's library default when it already has that unit.
60
60
  - The `responses` module holds the tolerant schemas the SDK uses to sanity-check an API
61
61
  response before trusting it; these schemas accept unknown fields.
62
62
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- //#region src/athlete.d.ts
3
2
  /** `/user/simple` — the identity + tenant key (numeric `id`) for any logged-in account. */
4
3
  export declare const userSimpleSchema: z.ZodObject<{
5
4
  id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
@@ -827,8 +826,6 @@ export type WorkoutHistoryExport = {
827
826
  personal: boolean;
828
827
  blocks: ExportBlock[];
829
828
  };
830
- //#endregion
831
- //#region src/common.d.ts
832
829
  /** An entity id as it arrives over the wire — a number or a numeric string. */
833
830
  export declare const idSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
834
831
  export type Id = z.infer<typeof idSchema>;
@@ -838,8 +835,6 @@ export type Id = z.infer<typeof idSchema>;
838
835
  * a bad argument fails validation instead of becoming NaN in a URL or a query.
839
836
  */
840
837
  export declare const idArgSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
841
- //#endregion
842
- //#region src/exercise.d.ts
843
838
  /** A library exercise row as the index stores it. */
844
839
  export type ExerciseRow = {
845
840
  id: number;
@@ -914,8 +909,6 @@ export declare const exerciseUpdateSchema: z.ZodObject<{
914
909
  points_of_performance: z.ZodOptional<z.ZodString>;
915
910
  }, z.core.$loose>;
916
911
  export type ExerciseUpdate = z.infer<typeof exerciseUpdateSchema>;
917
- //#endregion
918
- //#region src/messaging.d.ts
919
912
  /** A chat comment to draft or send: target stream, body text, optional threaded reply. */
920
913
  export declare const commentDraftSchema: z.ZodObject<{
921
914
  streamId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
@@ -923,8 +916,6 @@ export declare const commentDraftSchema: z.ZodObject<{
923
916
  replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
924
917
  }, z.core.$strip>;
925
918
  export type CommentDraft = z.infer<typeof commentDraftSchema>;
926
- //#endregion
927
- //#region src/responses.d.ts
928
919
  /** An exercise as the library + create endpoints return it (only the fields we read). */
929
920
  export declare const exerciseResponseSchema: z.ZodObject<{
930
921
  id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
@@ -968,8 +959,6 @@ export declare const programCreateResponseSchema: z.ZodObject<{
968
959
  program_type: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
969
960
  }, z.core.$loose>>;
970
961
  }, z.core.$loose>;
971
- //#endregion
972
- //#region src/team.d.ts
973
962
  /** Fields merged onto the program object for `POST /1.0/coach/team/updatePublishSettings`. */
974
963
  export declare const teamPublishPatchObject: z.ZodObject<{
975
964
  pub_enabled: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean]>>;
@@ -984,8 +973,6 @@ export declare const teamPublishPatchSchema: z.ZodObject<{
984
973
  pub_timezone: z.ZodOptional<z.ZodString>;
985
974
  }, z.core.$strip>;
986
975
  export type TeamPublishPatch = z.infer<typeof teamPublishPatchSchema>;
987
- //#endregion
988
- //#region src/tool-output.d.ts
989
976
  export declare const truncationMarkerSchema: z.ZodObject<{
990
977
  field: z.ZodOptional<z.ZodString>;
991
978
  returned: z.ZodOptional<z.ZodNumber>;
@@ -1142,6 +1129,7 @@ export declare const athleteExerciseNoteOutputSchema: z.ZodObject<{
1142
1129
  export type AthleteExerciseNoteOutput = z.infer<typeof athleteExerciseNoteOutputSchema>;
1143
1130
  export declare const workoutReadOutputSchema: z.ZodObject<{
1144
1131
  pwId: z.ZodNumber;
1132
+ workoutId: z.ZodNullable<z.ZodNumber>;
1145
1133
  date: z.ZodString;
1146
1134
  published: z.ZodOptional<z.ZodJSONSchema>;
1147
1135
  instruction: z.ZodString;
@@ -1172,6 +1160,7 @@ export declare const workoutBuildOutputSchema: z.ZodObject<{
1172
1160
  }, z.core.$strip>;
1173
1161
  readback: z.ZodNullable<z.ZodObject<{
1174
1162
  pwId: z.ZodNumber;
1163
+ workoutId: z.ZodNullable<z.ZodNumber>;
1175
1164
  date: z.ZodString;
1176
1165
  published: z.ZodOptional<z.ZodJSONSchema>;
1177
1166
  instruction: z.ZodString;
@@ -1197,6 +1186,7 @@ export declare const workoutPublishOutputSchema: z.ZodObject<{
1197
1186
  published: z.ZodNumber;
1198
1187
  readback: z.ZodObject<{
1199
1188
  pwId: z.ZodNumber;
1189
+ workoutId: z.ZodNullable<z.ZodNumber>;
1200
1190
  date: z.ZodString;
1201
1191
  published: z.ZodOptional<z.ZodJSONSchema>;
1202
1192
  instruction: z.ZodString;
@@ -1277,8 +1267,6 @@ export declare const programDeletedOutputSchema: z.ZodObject<{
1277
1267
  programId: z.ZodNumber;
1278
1268
  containerId: z.ZodNullable<z.ZodNumber>;
1279
1269
  }, z.core.$strip>;
1280
- //#endregion
1281
- //#region src/workout.d.ts
1282
1270
  /** A single exercise prescription inside a block. */
1283
1271
  export declare const exerciseSpecSchema: z.ZodObject<{
1284
1272
  id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
@@ -1398,6 +1386,8 @@ export type ReadBlock = {
1398
1386
  /** A whole session read back from the calendar. */
1399
1387
  export type ReadResult = {
1400
1388
  pwId: number;
1389
+ /** The session's underlying workout id, or null when the read-back omits it. */
1390
+ workoutId: number | null;
1401
1391
  date: string;
1402
1392
  published: unknown;
1403
1393
  instruction: string;
@@ -1409,4 +1399,10 @@ export declare const sessionTemplateCreateSchema: z.ZodObject<{
1409
1399
  instruction: z.ZodOptional<z.ZodString>;
1410
1400
  }, z.core.$strip>;
1411
1401
  export type SessionTemplateCreate = z.infer<typeof sessionTemplateCreateSchema>;
1412
- //#endregion
1402
+ /** Input for copying an existing calendar session into the session library. */
1403
+ export declare const sessionSaveAsTemplateSchema: z.ZodObject<{
1404
+ workoutId: z.ZodNumber;
1405
+ pwId: z.ZodNumber;
1406
+ title: z.ZodString;
1407
+ }, z.core.$strip>;
1408
+ export type SessionSaveAsTemplate = z.infer<typeof sessionSaveAsTemplateSchema>;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- //#region src/common.ts
2
+ // src/common.ts
3
3
  /** An entity id as it arrives over the wire — a number or a numeric string. */
4
4
  const idSchema = z.union([z.string(), z.number()]);
5
5
  /**
@@ -8,8 +8,7 @@ const idSchema = z.union([z.string(), z.number()]);
8
8
  * a bad argument fails validation instead of becoming NaN in a URL or a query.
9
9
  */
10
10
  const idArgSchema = z.union([z.number().int(), z.string().regex(/^\d+$/u)]);
11
- //#endregion
12
- //#region src/athlete.ts
11
+ // src/athlete.ts
13
12
  const intLike$1 = z.union([z.number(), z.string()]);
14
13
  const intLikeOrNull$1 = z.union([
15
14
  z.number(),
@@ -425,8 +424,7 @@ const presentedExerciseHistorySchema = z.object({
425
424
  });
426
425
  /** Presented history first so the loose raw detail schema cannot swallow it. */
427
426
  const exerciseHistoryOutputSchema = z.union([presentedExerciseHistorySchema, exerciseHistoryDetailSchema]);
428
- //#endregion
429
- //#region src/exercise.ts
427
+ // src/exercise.ts
430
428
  /**
431
429
  * A row presented for display. The raw param-type codes are dropped and the fixed
432
430
  * measurement units are surfaced positionally in `units`, ordered by entry slot
@@ -488,16 +486,14 @@ const exerciseUpdateSchema = z.looseObject({
488
486
  ...exerciseWriteShape,
489
487
  points_of_performance: z.string().optional()
490
488
  });
491
- //#endregion
492
- //#region src/messaging.ts
489
+ // src/messaging.ts
493
490
  /** A chat comment to draft or send: target stream, body text, optional threaded reply. */
494
491
  const commentDraftSchema = z.object({
495
492
  streamId: idSchema,
496
493
  text: z.string().min(1),
497
494
  replyTo: idSchema.optional()
498
495
  });
499
- //#endregion
500
- //#region src/responses.ts
496
+ // src/responses.ts
501
497
  const intLike = z.union([z.number(), z.string()]);
502
498
  const intLikeOrNull = z.union([
503
499
  z.number(),
@@ -537,8 +533,7 @@ const programCreateResponseSchema = z.looseObject({
537
533
  program_type: intLike
538
534
  }).optional()
539
535
  });
540
- //#endregion
541
- //#region src/team.ts
536
+ // src/team.ts
542
537
  /** Fields merged onto the program object for `POST /1.0/coach/team/updatePublishSettings`. */
543
538
  const teamPublishPatchObject = z.object({
544
539
  pub_enabled: z.union([z.number(), z.boolean()]).optional(),
@@ -547,8 +542,7 @@ const teamPublishPatchObject = z.object({
547
542
  pub_timezone: z.string().optional()
548
543
  });
549
544
  const teamPublishPatchSchema = teamPublishPatchObject.refine((v) => v.pub_enabled !== void 0 || v.pub_days !== void 0 || v.pub_time !== void 0 || v.pub_timezone !== void 0, { message: "Provide at least one pub_* field" });
550
- //#endregion
551
- //#region src/tool-output.ts
545
+ // src/tool-output.ts
552
546
  const nullableNumber = z.number().nullable();
553
547
  const nullableString = z.string().nullable();
554
548
  const truncationMarkerSchema = z.looseObject({
@@ -685,6 +679,7 @@ const workoutReadBlockOutputSchema = z.object({
685
679
  });
686
680
  const workoutReadOutputSchema = z.object({
687
681
  pwId: z.number(),
682
+ workoutId: z.number().nullable(),
688
683
  date: z.string(),
689
684
  published: z.json().optional(),
690
685
  instruction: z.string(),
@@ -753,8 +748,7 @@ const programDeletedOutputSchema = z.object({
753
748
  programId: z.number(),
754
749
  containerId: nullableNumber
755
750
  });
756
- //#endregion
757
- //#region src/workout.ts
751
+ // src/workout.ts
758
752
  /** A single exercise prescription inside a block. */
759
753
  const exerciseSpecSchema = z.object({
760
754
  id: z.union([z.number(), z.string()]),
@@ -766,8 +760,8 @@ const exerciseSpecSchema = z.object({
766
760
  ]).optional().describe("Primary slot values; may be reps, distance, or time. State primaryUnit."),
767
761
  sets: z.number().optional(),
768
762
  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."),
763
+ primaryUnit: z.string().trim().min(1).optional().describe("Unit of the primary values, such as reps, m, mi, or sec. A unit other than the exercise's default from exercise_resolve is set on this session."),
764
+ secondaryUnit: z.string().trim().min(1).optional().describe("Unit of the secondary values, such as lb, %max, RPE, or sec. A unit other than the exercise's default from exercise_resolve is set on this session."),
771
765
  rpe: z.union([z.number(), z.string()]).optional(),
772
766
  instr: z.string().optional(),
773
767
  param_1_type: z.number().optional(),
@@ -847,5 +841,10 @@ const sessionTemplateCreateSchema = z.object({
847
841
  title: z.string().min(1),
848
842
  instruction: z.string().optional()
849
843
  });
850
- //#endregion
851
- export { athleteExerciseCatalogOutputSchema, athleteExerciseNoteArgsSchema, athleteExerciseNoteOutputSchema, athleteInviteOutputSchema, athleteMainLiftPrsOutputSchema, athletePrefsSchema, athletePrescribeSetArgsSchema, athleteProfileOutputSchema, athleteProfileSummarySchema, athleteSessionRemoveArgsSchema, athleteSessionRemovedOutputSchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutBlockSchema, athleteWorkoutExerciseSchema, athleteWorkoutNoteArgsSchema, athleteWorkoutNoteObject, athleteWorkoutNoteOutputSchema, athleteWorkoutRangeArgsSchema, athleteWorkoutSummarySchema, athleteWorkoutViewSchema, athleteWorkoutsOutputSchema, blockSpecSchema, coachAthleteExerciseSchema, coachAthleteSessionSchema, coachAthleteTrainingOutputSchema, coachAthleteTrainingSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, coachPrescribeSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseCreatedOutputSchema, exerciseDeletedOutputSchema, exerciseForgottenOutputSchema, exerciseGetOutputSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseHistoryOutputSchema, exerciseLibraryResponseSchema, exerciseParamTypeSchema, exerciseResolveOutputSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, exerciseSwapOutputSchema, exerciseUpdateSchema, exerciseViewSchema, feedbackOutputSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSessionArgsSchema, logSetArgsSchema, logTargetsOutputSchema, loggedSetSchema, loggedSetWithSlotSchema, messageDeletedOutputSchema, messageDraftOutputSchema, messageSentOutputSchema, opaqueJsonOutputSchema, opaqueOutputSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, personalWorkoutCreatedOutputSchema, presentedExerciseHistorySchema, presentedExerciseSessionSchema, programCreateResponseSchema, programCreatedOutputSchema, programDeletedOutputSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, removedSessionOutputSchema, repMaxSchema, rosterActivityOutputSchema, rosterActivityRowSchema, sessionCreateResponseSchema, sessionLogOutputSchema, sessionTemplateCreateSchema, sessionTemplateCreatedOutputSchema, setLogOutputSchema, setPrescriptionOutputSchema, swapAthleteExerciseArgsSchema, teamPublishPatchObject, teamPublishPatchSchema, teamVolumeAthleteSchema, teamVolumeOutputSchema, teamVolumeReportSchema, toolOutputSchema, truncatedOutputSchema, truncationMarkerSchema, userSimpleSchema, workoutBuildOutputSchema, workoutPublishOutputSchema, workoutReadOutputSchema, workoutSpecSchema };
844
+ /** Input for copying an existing calendar session into the session library. */
845
+ const sessionSaveAsTemplateSchema = z.object({
846
+ workoutId: z.number().int().describe("The session's workout_id (workout_build returns it as workoutId)."),
847
+ pwId: z.number().int().describe("The session's programWorkout id (workout_build returns it as pwId)."),
848
+ title: z.string().trim().min(1).describe("Title of the new library template.")
849
+ });
850
+ export { athleteExerciseCatalogOutputSchema, athleteExerciseNoteArgsSchema, athleteExerciseNoteOutputSchema, athleteInviteOutputSchema, athleteMainLiftPrsOutputSchema, athletePrefsSchema, athletePrescribeSetArgsSchema, athleteProfileOutputSchema, athleteProfileSummarySchema, athleteSessionRemoveArgsSchema, athleteSessionRemovedOutputSchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutBlockSchema, athleteWorkoutExerciseSchema, athleteWorkoutNoteArgsSchema, athleteWorkoutNoteObject, athleteWorkoutNoteOutputSchema, athleteWorkoutRangeArgsSchema, athleteWorkoutSummarySchema, athleteWorkoutViewSchema, athleteWorkoutsOutputSchema, blockSpecSchema, coachAthleteExerciseSchema, coachAthleteSessionSchema, coachAthleteTrainingOutputSchema, coachAthleteTrainingSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, coachPrescribeSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseCreatedOutputSchema, exerciseDeletedOutputSchema, exerciseForgottenOutputSchema, exerciseGetOutputSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseHistoryOutputSchema, exerciseLibraryResponseSchema, exerciseParamTypeSchema, exerciseResolveOutputSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, exerciseSwapOutputSchema, exerciseUpdateSchema, exerciseViewSchema, feedbackOutputSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSessionArgsSchema, logSetArgsSchema, logTargetsOutputSchema, loggedSetSchema, loggedSetWithSlotSchema, messageDeletedOutputSchema, messageDraftOutputSchema, messageSentOutputSchema, opaqueJsonOutputSchema, opaqueOutputSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, personalWorkoutCreatedOutputSchema, presentedExerciseHistorySchema, presentedExerciseSessionSchema, programCreateResponseSchema, programCreatedOutputSchema, programDeletedOutputSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, removedSessionOutputSchema, repMaxSchema, rosterActivityOutputSchema, rosterActivityRowSchema, sessionCreateResponseSchema, sessionLogOutputSchema, sessionSaveAsTemplateSchema, sessionTemplateCreateSchema, sessionTemplateCreatedOutputSchema, setLogOutputSchema, setPrescriptionOutputSchema, swapAthleteExerciseArgsSchema, teamPublishPatchObject, teamPublishPatchSchema, teamVolumeAthleteSchema, teamVolumeOutputSchema, teamVolumeReportSchema, toolOutputSchema, truncatedOutputSchema, truncationMarkerSchema, userSimpleSchema, workoutBuildOutputSchema, workoutPublishOutputSchema, workoutReadOutputSchema, workoutSpecSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/dto",
3
- "version": "4.1.1",
3
+ "version": "4.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,11 +22,11 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "zod": "^4.6.5"
25
+ "zod": "^4.6.7"
26
26
  },
27
27
  "devDependencies": {
28
- "tsdown": "^0.23.0",
29
- "vitest": "^5.0.3"
28
+ "tsdown": "^0.23.7",
29
+ "vitest": "^5.1.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsdown",