@tmlmobilidade/types 20250910.1526.7 → 20250910.1538.31

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.
@@ -1,11 +1,13 @@
1
1
  /* * */
2
- import { CommentSchema } from '../_common/comment.js';
3
2
  import { DocumentSchema } from '../_common/document.js';
3
+ import { RideAnalysisSchema } from './ride-analysis.js';
4
+ import { RideJustificationSchema } from './ride-justification.js';
4
5
  import { z } from 'zod';
5
6
  /* * */
6
7
  export const RideAuditSchema = DocumentSchema.extend({
7
- comments: z.array(CommentSchema).default([]),
8
+ analysis: RideAnalysisSchema,
8
9
  is_locked: z.boolean().default(false),
10
+ justification: RideJustificationSchema,
9
11
  ride_id: z.string(),
10
12
  }).strict();
11
13
  export const CreateRideAuditSchema = RideAuditSchema.partial({ _id: true }).omit({ created_at: true, updated_at: true });
@@ -1,65 +1,20 @@
1
- import { type UnixTimestamp } from '../_common/unix-timestamp.js';
2
1
  import { z } from 'zod';
3
2
  export declare const RIDE_ACCEPTANCE_STATUS_OPTIONS: readonly ["justification_required", "under_review", "accepted", "rejected"];
4
3
  export declare const RideAcceptanceStatusSchema: z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>;
5
4
  export type RideAcceptanceStatus = z.infer<typeof RideAcceptanceStatusSchema>;
6
- export declare const RideJustificationChangelogSchema: z.ZodObject<{
7
- acceptance_status: z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>;
8
- analysis_result: z.ZodObject<{
9
- error_message: z.ZodOptional<z.ZodString>;
10
- grade: z.ZodEnum<["pass", "fail", "skip", "error"]>;
11
- reason: z.ZodString;
12
- }, "strict", z.ZodTypeAny, {
13
- grade: "error" | "pass" | "fail" | "skip";
14
- reason: string;
15
- error_message?: string | undefined;
16
- }, {
17
- grade: "error" | "pass" | "fail" | "skip";
18
- reason: string;
19
- error_message?: string | undefined;
20
- }>;
21
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
22
- created_by: z.ZodString;
23
- }, "strict", z.ZodTypeAny, {
24
- created_at: number & {
25
- __brand: "UnixTimestamp";
26
- } & z.BRAND<"UnixTimestamp">;
27
- created_by: string;
28
- acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
29
- analysis_result: {
30
- grade: "error" | "pass" | "fail" | "skip";
31
- reason: string;
32
- error_message?: string | undefined;
33
- };
34
- }, {
35
- created_at: number;
36
- created_by: string;
37
- acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
38
- analysis_result: {
39
- grade: "error" | "pass" | "fail" | "skip";
40
- reason: string;
41
- error_message?: string | undefined;
42
- };
43
- }>;
44
- export interface RideJustificationChangelog extends Omit<z.infer<typeof RideJustificationChangelogSchema>, 'created_at'> {
45
- created_at: UnixTimestamp;
46
- }
47
- export declare const RIDE_JUSTIFICATION_TYPE_OPTIONS: readonly ["traffic_accident", "traffic_delay", "accepted", "rejected"];
48
- export declare const RideJustificationTypeSchema: z.ZodEnum<["traffic_accident", "traffic_delay", "accepted", "rejected"]>;
49
- export type RideJustificationType = z.infer<typeof RideJustificationTypeSchema>;
50
5
  export declare const RideJustificationSchema: z.ZodObject<{
51
6
  _id: z.ZodString;
52
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
7
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
53
8
  created_by: z.ZodDefault<z.ZodString>;
54
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
9
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
55
10
  updated_by: z.ZodDefault<z.ZodString>;
56
11
  } & {
57
12
  acceptance_status: z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>;
58
13
  comments: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
59
14
  _id: z.ZodString;
60
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
15
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
61
16
  created_by: z.ZodDefault<z.ZodString>;
62
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
17
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
63
18
  updated_by: z.ZodDefault<z.ZodString>;
64
19
  } & {
65
20
  message: z.ZodString;
@@ -86,8 +41,8 @@ export declare const RideJustificationSchema: z.ZodObject<{
86
41
  updated_by?: string | undefined;
87
42
  }>, z.ZodObject<{
88
43
  _id: z.ZodString;
89
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
90
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
44
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
45
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
91
46
  } & {
92
47
  created_by: z.ZodLiteral<"system">;
93
48
  message: z.ZodString;
@@ -115,9 +70,9 @@ export declare const RideJustificationSchema: z.ZodObject<{
115
70
  type: "system_info";
116
71
  }>, z.ZodObject<{
117
72
  _id: z.ZodString;
118
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
73
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
119
74
  created_by: z.ZodDefault<z.ZodString>;
120
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
75
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
121
76
  updated_by: z.ZodDefault<z.ZodString>;
122
77
  } & {
123
78
  curr_status: z.ZodString;
@@ -281,6 +236,7 @@ export declare const RideJustificationSchema: z.ZodObject<{
281
236
  __brand: "UnixTimestamp";
282
237
  };
283
238
  updated_by: string;
239
+ acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
284
240
  comments: ({
285
241
  _id: string;
286
242
  created_at: number & {
@@ -319,7 +275,6 @@ export declare const RideJustificationSchema: z.ZodObject<{
319
275
  curr_status: string;
320
276
  prev_status: string;
321
277
  })[];
322
- acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
323
278
  pto_message: string;
324
279
  }, {
325
280
  _id: string;
@@ -358,15 +313,16 @@ export declare const RideJustificationSchema: z.ZodObject<{
358
313
  }>;
359
314
  export declare const CreateRideJustificationSchema: z.ZodObject<Omit<{
360
315
  _id: z.ZodOptional<z.ZodString>;
361
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
316
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
362
317
  created_by: z.ZodDefault<z.ZodString>;
363
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
318
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
364
319
  updated_by: z.ZodDefault<z.ZodString>;
320
+ acceptance_status: z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>;
365
321
  comments: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
366
322
  _id: z.ZodString;
367
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
323
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
368
324
  created_by: z.ZodDefault<z.ZodString>;
369
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
325
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
370
326
  updated_by: z.ZodDefault<z.ZodString>;
371
327
  } & {
372
328
  message: z.ZodString;
@@ -393,8 +349,8 @@ export declare const CreateRideJustificationSchema: z.ZodObject<Omit<{
393
349
  updated_by?: string | undefined;
394
350
  }>, z.ZodObject<{
395
351
  _id: z.ZodString;
396
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
397
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
352
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
353
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
398
354
  } & {
399
355
  created_by: z.ZodLiteral<"system">;
400
356
  message: z.ZodString;
@@ -422,9 +378,9 @@ export declare const CreateRideJustificationSchema: z.ZodObject<Omit<{
422
378
  type: "system_info";
423
379
  }>, z.ZodObject<{
424
380
  _id: z.ZodString;
425
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
381
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
426
382
  created_by: z.ZodDefault<z.ZodString>;
427
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
383
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
428
384
  updated_by: z.ZodDefault<z.ZodString>;
429
385
  } & {
430
386
  curr_status: z.ZodString;
@@ -577,11 +533,11 @@ export declare const CreateRideJustificationSchema: z.ZodObject<Omit<{
577
533
  created_by?: string | undefined;
578
534
  updated_by?: string | undefined;
579
535
  }>, "many">>;
580
- acceptance_status: z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>;
581
536
  pto_message: z.ZodDefault<z.ZodString>;
582
537
  }, "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
583
538
  created_by: string;
584
539
  updated_by: string;
540
+ acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
585
541
  comments: ({
586
542
  _id: string;
587
543
  created_at: number & {
@@ -620,7 +576,6 @@ export declare const CreateRideJustificationSchema: z.ZodObject<Omit<{
620
576
  curr_status: string;
621
577
  prev_status: string;
622
578
  })[];
623
- acceptance_status: "accepted" | "justification_required" | "under_review" | "rejected";
624
579
  pto_message: string;
625
580
  _id?: string | undefined;
626
581
  }, {
@@ -660,11 +615,12 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
660
615
  _id: z.ZodOptional<z.ZodOptional<z.ZodString>>;
661
616
  created_by: z.ZodOptional<z.ZodDefault<z.ZodString>>;
662
617
  updated_by: z.ZodOptional<z.ZodDefault<z.ZodString>>;
618
+ acceptance_status: z.ZodOptional<z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>>;
663
619
  comments: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
664
620
  _id: z.ZodString;
665
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
621
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
666
622
  created_by: z.ZodDefault<z.ZodString>;
667
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
623
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
668
624
  updated_by: z.ZodDefault<z.ZodString>;
669
625
  } & {
670
626
  message: z.ZodString;
@@ -691,8 +647,8 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
691
647
  updated_by?: string | undefined;
692
648
  }>, z.ZodObject<{
693
649
  _id: z.ZodString;
694
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
695
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
650
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
651
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
696
652
  } & {
697
653
  created_by: z.ZodLiteral<"system">;
698
654
  message: z.ZodString;
@@ -720,9 +676,9 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
720
676
  type: "system_info";
721
677
  }>, z.ZodObject<{
722
678
  _id: z.ZodString;
723
- created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
679
+ created_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
724
680
  created_by: z.ZodDefault<z.ZodString>;
725
- updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
681
+ updated_at: z.ZodEffects<z.ZodNumber, import("../_common/unix-timestamp.js").UnixTimestamp, number>;
726
682
  updated_by: z.ZodDefault<z.ZodString>;
727
683
  } & {
728
684
  curr_status: z.ZodString;
@@ -875,12 +831,12 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
875
831
  created_by?: string | undefined;
876
832
  updated_by?: string | undefined;
877
833
  }>, "many">>>;
878
- acceptance_status: z.ZodOptional<z.ZodEnum<["justification_required", "under_review", "accepted", "rejected"]>>;
879
834
  pto_message: z.ZodOptional<z.ZodDefault<z.ZodString>>;
880
835
  }, "strict", z.ZodTypeAny, {
881
836
  _id?: string | undefined;
882
837
  created_by?: string | undefined;
883
838
  updated_by?: string | undefined;
839
+ acceptance_status?: "accepted" | "justification_required" | "under_review" | "rejected" | undefined;
884
840
  comments?: ({
885
841
  _id: string;
886
842
  created_at: number & {
@@ -919,12 +875,12 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
919
875
  curr_status: string;
920
876
  prev_status: string;
921
877
  })[] | undefined;
922
- acceptance_status?: "accepted" | "justification_required" | "under_review" | "rejected" | undefined;
923
878
  pto_message?: string | undefined;
924
879
  }, {
925
880
  _id?: string | undefined;
926
881
  created_by?: string | undefined;
927
882
  updated_by?: string | undefined;
883
+ acceptance_status?: "accepted" | "justification_required" | "under_review" | "rejected" | undefined;
928
884
  comments?: ({
929
885
  _id: string;
930
886
  created_at: number;
@@ -951,9 +907,8 @@ export declare const UpdateRideJustificationSchema: z.ZodObject<{
951
907
  created_by?: string | undefined;
952
908
  updated_by?: string | undefined;
953
909
  })[] | undefined;
954
- acceptance_status?: "accepted" | "justification_required" | "under_review" | "rejected" | undefined;
955
910
  pto_message?: string | undefined;
956
911
  }>;
957
912
  export type RideJustification = z.infer<typeof RideJustificationSchema>;
958
913
  export type CreateRideJustificationDto = z.infer<typeof CreateRideJustificationSchema>;
959
- export type UpdateRideJustificationDto = Partial<CreateRideJustificationDto>;
914
+ export type UpdateRideJustificationDto = z.infer<typeof UpdateRideJustificationSchema>;
@@ -1,22 +1,11 @@
1
1
  /* * */
2
2
  import { CommentSchema, CommentTypeSchema } from '../_common/comment.js';
3
3
  import { DocumentSchema } from '../_common/document.js';
4
- import { validateUnixTimestamp } from '../_common/unix-timestamp.js';
5
- import { RideAnalysisSchema } from './ride-analysis.js';
6
4
  import { z } from 'zod';
7
5
  /* * */
8
6
  export const RIDE_ACCEPTANCE_STATUS_OPTIONS = ['justification_required', 'under_review', 'accepted', 'rejected'];
9
7
  export const RideAcceptanceStatusSchema = z.enum(RIDE_ACCEPTANCE_STATUS_OPTIONS);
10
8
  /* * */
11
- export const RideJustificationChangelogSchema = z.object({
12
- acceptance_status: RideAcceptanceStatusSchema,
13
- analysis_result: RideAnalysisSchema,
14
- created_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
15
- created_by: z.string().min(2).max(100),
16
- }).strict();
17
- /* * */
18
- export const RIDE_JUSTIFICATION_TYPE_OPTIONS = ['traffic_accident', 'traffic_delay', 'accepted', 'rejected'];
19
- export const RideJustificationTypeSchema = z.enum(RIDE_JUSTIFICATION_TYPE_OPTIONS);
20
9
  const CommentSchemaWithRideJustificationStatus = CommentSchema.superRefine((data, ctx) => {
21
10
  if (data.type === CommentTypeSchema.enum.statusChanged) {
22
11
  const d = data;
@@ -44,21 +33,3 @@ export const RideJustificationSchema = DocumentSchema.extend({
44
33
  }).strict();
45
34
  export const CreateRideJustificationSchema = RideJustificationSchema.partial({ _id: true }).omit({ created_at: true, updated_at: true });
46
35
  export const UpdateRideJustificationSchema = CreateRideJustificationSchema.partial();
47
- const example = {
48
- _id: '64b64f4f8f1d2c001f6e4b8a',
49
- acceptance_status: 'rejected',
50
- comments: [
51
- {
52
- _id: '64b64f4f8f1d2c001f6e4b8a',
53
- created_at: 1690400000,
54
- created_by: 'system',
55
- message: 'Ride justification created',
56
- type: 'system_info',
57
- updated_at: 1690400000,
58
- updated_by: 'system',
59
- },
60
- ],
61
- created_by: 'joao',
62
- pto_message: '',
63
- updated_by: '',
64
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/types",
3
- "version": "20250910.1526.7",
3
+ "version": "20250910.1538.31",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",