@updraft-solutions/mcrit-sdk 0.3.1 → 0.4.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.
@@ -265,11 +265,19 @@ export const userQualificationSchema = z.object({
265
265
  });
266
266
 
267
267
  export const airportSchema = z.object({
268
- type: z.literal("airport"),
268
+ // Aligned with what AirportResource actually serializes: `type` and
269
+ // `country` are absent on minified payloads (e.g. booking waypoint
270
+ // airports); coordinates + municipality/iso_country ride along on the
271
+ // full shape.
272
+ type: z.literal("airport").optional(),
269
273
  id: z.number(),
270
274
  ident: z.string(),
271
275
  name: z.string(),
272
- country: z.string(),
276
+ country: z.string().optional(),
277
+ municipality: z.string().nullable().optional(),
278
+ iso_country: z.string().nullable().optional(),
279
+ latitude_deg: z.number().nullable().optional(),
280
+ longitude_deg: z.number().nullable().optional(),
273
281
  });
274
282
 
275
283
  export const recurringFlightSchema = z.object({
@@ -387,6 +395,26 @@ export const availSchema = z.object({
387
395
  .optional(),
388
396
  });
389
397
 
398
+ // Ordered via-airport on a booking's route (BookingResource `waypoints`).
399
+ // Airports arrive minified (no `type` literal), hence the dedicated shape.
400
+ // Distinct from the nav-fix `waypointSchema` further down — do not merge.
401
+ export const bookingWaypointSchema = z.object({
402
+ sequence: z.number(),
403
+ airport_id: z.number(),
404
+ airport: z
405
+ .object({
406
+ id: z.number(),
407
+ ident: z.string(),
408
+ name: z.string(),
409
+ municipality: z.string().nullable().optional(),
410
+ iso_country: z.string().nullable().optional(),
411
+ latitude_deg: z.number().nullable().optional(),
412
+ longitude_deg: z.number().nullable().optional(),
413
+ })
414
+ .nullable()
415
+ .optional(),
416
+ });
417
+
390
418
  export const bookingSchema = BaseModel.extend({
391
419
  type: z.literal("booking"),
392
420
  ifr: z.boolean().default(false),
@@ -403,6 +431,15 @@ export const bookingSchema = BaseModel.extend({
403
431
  destination_airport_id: z.number().optional(),
404
432
  departure_airport: airportSchema.optional(),
405
433
  destination_airport: airportSchema.optional(),
434
+ waypoints: z.array(bookingWaypointSchema).optional(),
435
+ // Flat, always-present home timezone on BookingResource.
436
+ company_timezone: z.string().nullable().optional(),
437
+ // Slim per-booking training-record status, present when the backend
438
+ // eager-loaded `trainingRecord` (enrollment bookings surfaces).
439
+ training_record_status: z
440
+ .enum(["draft", "awaiting_signatures", "signed"])
441
+ .nullable()
442
+ .optional(),
406
443
  next_booking_id: z.number().nullable().optional(),
407
444
  previous_booking_id: z.number().nullable().optional(),
408
445
  maintenance: z.number().optional(),
@@ -797,6 +834,24 @@ export const expenseSchema = z.object({
797
834
  .optional(),
798
835
  });
799
836
 
837
+ // Company-scoped tag (shared pool across taggable models — see
838
+ // m-crit-api docs/features/tags.md).
839
+ export const tagSchema = z.object({
840
+ type: z.literal("tag").optional(),
841
+ id: z.number(),
842
+ name: z.string(),
843
+ color: z.string().nullable().optional(),
844
+ });
845
+
846
+ // Slim attached progress-check sheet (course_check_syllabi pivot),
847
+ // serialized on course show/update payloads.
848
+ export const courseCheckSyllabusSchema = z.object({
849
+ id: z.number(),
850
+ name: z.string(),
851
+ version: z.number(),
852
+ kind: z.enum(["regular", "progress_check"]).default("regular"),
853
+ });
854
+
800
855
  export const courseSchema = z.object({
801
856
  type: z.literal("course"),
802
857
  id: z.number(),
@@ -813,15 +868,25 @@ export const courseSchema = z.object({
813
868
  aircraft_required: z.boolean().default(false),
814
869
  qualification_id: z.number().nullable().optional(),
815
870
  qualification: qualificationSchema.optional(),
871
+ is_archived: z.boolean().optional(),
872
+ archived_at: z.string().nullable().optional(),
873
+ category: z.string().nullable().optional(),
874
+ title: z.string().nullable().optional(),
875
+ subtitle: z.string().nullable().optional(),
876
+ content: z.string().nullable().optional(),
877
+ footer: z.string().nullable().optional(),
878
+ // Syllabus assignment pointers: `syllabus_id` drives the Übersicht,
879
+ // `booking_form_syllabus_id` the per-flight Ausbildungsnachweis.
880
+ syllabus_id: z.number().nullable().optional(),
881
+ booking_form_syllabus_id: z.number().nullable().optional(),
882
+ // Present only when the backend eager-loaded `checkSyllabi`.
883
+ check_syllabi: z.array(courseCheckSyllabusSchema).optional(),
884
+ tags: z.array(tagSchema).optional(),
816
885
  created_at: z.string(),
817
886
  updated_at: z.string(),
818
- can: z
819
- .object({
820
- update: zNullableBool,
821
- delete: zNullableBool,
822
- enroll: zNullableBool,
823
- })
824
- .optional(),
887
+ // Loose record on purpose: gates are policy-reflected server-side and
888
+ // grow over time (useAssistant, …) — same convention as companySchema.
889
+ can: z.record(z.string(), zNullableBool).optional(),
825
890
  });
826
891
 
827
892
  /**
@@ -854,20 +919,19 @@ export const courseEnrollmentSchema = z.object({
854
919
  comments: z.string().nullable().optional(),
855
920
  initial_payment_generated: z.boolean().optional(),
856
921
  initial_payment_removable: z.boolean().optional(),
922
+ // Element-driven training progress (see m-crit-api
923
+ // docs/features/training-tracking.md).
924
+ tracked_training_elements_count: z.number().optional(),
925
+ progress_source: z.enum(["training_elements", "milestones"]).optional(),
857
926
  metrics: courseEnrollmentMetricsSchema.optional(),
858
927
  created_at: z.string(),
859
928
  updated_at: z.string(),
860
929
  course: courseSchema.optional(),
861
930
  membership: membershipSchema.optional(),
862
931
  mentor: userSchema.optional(),
863
- can: z
864
- .object({
865
- view: zNullableBool,
866
- update: zNullableBool,
867
- delete: zNullableBool,
868
- complete: zNullableBool,
869
- })
870
- .optional(),
932
+ // Loose record on purpose: gates are policy-reflected server-side and
933
+ // grow over time (updateTraining, manageInitialPayment, …).
934
+ can: z.record(z.string(), zNullableBool).optional(),
871
935
  });
872
936
 
873
937
  export const eventSchema = z.object({
@@ -42,6 +42,10 @@ export type RecurringFlight = z.infer<
42
42
  // Fee types
43
43
  export type Fee = z.infer<typeof ModelSchemas.feeSchema>;
44
44
  export type CourseFee = z.infer<typeof ModelSchemas.courseFeeSchema>;
45
+ export type Tag = z.infer<typeof ModelSchemas.tagSchema>;
46
+ export type CourseCheckSyllabus = z.infer<
47
+ typeof ModelSchemas.courseCheckSyllabusSchema
48
+ >;
45
49
  export type Price = z.infer<typeof ModelSchemas.priceSchema>;
46
50
 
47
51
  // Maintenance types