@tmlmobilidade/types 20250910.1344.34 → 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,29 +1,250 @@
1
1
  import { type UnixTimestamp } from './unix-timestamp.js';
2
2
  import { z } from 'zod';
3
- export declare const CommentSchema: z.ZodObject<{
4
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
3
+ export declare const CommentTypeSchema: z.ZodEnum<["statusChanged", "note", "system_info"]>;
4
+ export type CommentType = z.infer<typeof CommentTypeSchema>;
5
+ export declare const NoteCommentSchema: z.ZodObject<{
6
+ _id: z.ZodString;
7
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
5
8
  created_by: z.ZodDefault<z.ZodString>;
6
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
9
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
7
10
  updated_by: z.ZodDefault<z.ZodString>;
8
11
  } & {
12
+ message: z.ZodString;
13
+ type: z.ZodLiteral<"note">;
14
+ }, "strip", z.ZodTypeAny, {
15
+ _id: string;
16
+ created_at: number & {
17
+ __brand: "UnixTimestamp";
18
+ };
19
+ created_by: string;
20
+ updated_at: number & {
21
+ __brand: "UnixTimestamp";
22
+ };
23
+ updated_by: string;
24
+ message: string;
25
+ type: "note";
26
+ }, {
27
+ _id: string;
28
+ created_at: number;
29
+ updated_at: number;
30
+ message: string;
31
+ type: "note";
32
+ created_by?: string | undefined;
33
+ updated_by?: string | undefined;
34
+ }>;
35
+ export declare const SystemInfoCommentSchema: z.ZodObject<{
9
36
  _id: z.ZodString;
10
- text: z.ZodString;
11
- }, "strict", z.ZodTypeAny, {
37
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
38
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
39
+ } & {
40
+ created_by: z.ZodLiteral<"system">;
41
+ message: z.ZodString;
42
+ type: z.ZodLiteral<"system_info">;
43
+ updated_by: z.ZodLiteral<"system">;
44
+ }, "strip", z.ZodTypeAny, {
12
45
  _id: string;
13
46
  created_at: number & {
14
47
  __brand: "UnixTimestamp";
15
- } & z.BRAND<"UnixTimestamp">;
48
+ };
49
+ created_by: "system";
50
+ updated_at: number & {
51
+ __brand: "UnixTimestamp";
52
+ };
53
+ updated_by: "system";
54
+ message: string;
55
+ type: "system_info";
56
+ }, {
57
+ _id: string;
58
+ created_at: number;
59
+ created_by: "system";
60
+ updated_at: number;
61
+ updated_by: "system";
62
+ message: string;
63
+ type: "system_info";
64
+ }>;
65
+ export declare const StatusChangedCommentSchema: z.ZodObject<{
66
+ _id: z.ZodString;
67
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
68
+ created_by: z.ZodDefault<z.ZodString>;
69
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
70
+ updated_by: z.ZodDefault<z.ZodString>;
71
+ } & {
72
+ curr_status: z.ZodString;
73
+ prev_status: z.ZodString;
74
+ type: z.ZodLiteral<"statusChanged">;
75
+ }, "strip", z.ZodTypeAny, {
76
+ _id: string;
77
+ created_at: number & {
78
+ __brand: "UnixTimestamp";
79
+ };
16
80
  created_by: string;
17
81
  updated_at: number & {
18
82
  __brand: "UnixTimestamp";
19
- } & z.BRAND<"UnixTimestamp">;
83
+ };
20
84
  updated_by: string;
21
- text: string;
85
+ type: "statusChanged";
86
+ curr_status: string;
87
+ prev_status: string;
22
88
  }, {
23
89
  _id: string;
24
90
  created_at: number;
25
91
  updated_at: number;
26
- text: string;
92
+ type: "statusChanged";
93
+ curr_status: string;
94
+ prev_status: string;
95
+ created_by?: string | undefined;
96
+ updated_by?: string | undefined;
97
+ }>;
98
+ export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
99
+ _id: z.ZodString;
100
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
101
+ created_by: z.ZodDefault<z.ZodString>;
102
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
103
+ updated_by: z.ZodDefault<z.ZodString>;
104
+ } & {
105
+ message: z.ZodString;
106
+ type: z.ZodLiteral<"note">;
107
+ }, "strip", z.ZodTypeAny, {
108
+ _id: string;
109
+ created_at: number & {
110
+ __brand: "UnixTimestamp";
111
+ };
112
+ created_by: string;
113
+ updated_at: number & {
114
+ __brand: "UnixTimestamp";
115
+ };
116
+ updated_by: string;
117
+ message: string;
118
+ type: "note";
119
+ }, {
120
+ _id: string;
121
+ created_at: number;
122
+ updated_at: number;
123
+ message: string;
124
+ type: "note";
125
+ created_by?: string | undefined;
126
+ updated_by?: string | undefined;
127
+ }>, z.ZodObject<{
128
+ _id: z.ZodString;
129
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
130
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
131
+ } & {
132
+ created_by: z.ZodLiteral<"system">;
133
+ message: z.ZodString;
134
+ type: z.ZodLiteral<"system_info">;
135
+ updated_by: z.ZodLiteral<"system">;
136
+ }, "strip", z.ZodTypeAny, {
137
+ _id: string;
138
+ created_at: number & {
139
+ __brand: "UnixTimestamp";
140
+ };
141
+ created_by: "system";
142
+ updated_at: number & {
143
+ __brand: "UnixTimestamp";
144
+ };
145
+ updated_by: "system";
146
+ message: string;
147
+ type: "system_info";
148
+ }, {
149
+ _id: string;
150
+ created_at: number;
151
+ created_by: "system";
152
+ updated_at: number;
153
+ updated_by: "system";
154
+ message: string;
155
+ type: "system_info";
156
+ }>, z.ZodObject<{
157
+ _id: z.ZodString;
158
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
159
+ created_by: z.ZodDefault<z.ZodString>;
160
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
161
+ updated_by: z.ZodDefault<z.ZodString>;
162
+ } & {
163
+ curr_status: z.ZodString;
164
+ prev_status: z.ZodString;
165
+ type: z.ZodLiteral<"statusChanged">;
166
+ }, "strip", z.ZodTypeAny, {
167
+ _id: string;
168
+ created_at: number & {
169
+ __brand: "UnixTimestamp";
170
+ };
171
+ created_by: string;
172
+ updated_at: number & {
173
+ __brand: "UnixTimestamp";
174
+ };
175
+ updated_by: string;
176
+ type: "statusChanged";
177
+ curr_status: string;
178
+ prev_status: string;
179
+ }, {
180
+ _id: string;
181
+ created_at: number;
182
+ updated_at: number;
183
+ type: "statusChanged";
184
+ curr_status: string;
185
+ prev_status: string;
186
+ created_by?: string | undefined;
187
+ updated_by?: string | undefined;
188
+ }>]>, {
189
+ _id: string;
190
+ created_at: number & {
191
+ __brand: "UnixTimestamp";
192
+ };
193
+ created_by: string;
194
+ updated_at: number & {
195
+ __brand: "UnixTimestamp";
196
+ };
197
+ updated_by: string;
198
+ message: string;
199
+ type: "note";
200
+ } | {
201
+ _id: string;
202
+ created_at: number & {
203
+ __brand: "UnixTimestamp";
204
+ };
205
+ created_by: "system";
206
+ updated_at: number & {
207
+ __brand: "UnixTimestamp";
208
+ };
209
+ updated_by: "system";
210
+ message: string;
211
+ type: "system_info";
212
+ } | {
213
+ _id: string;
214
+ created_at: number & {
215
+ __brand: "UnixTimestamp";
216
+ };
217
+ created_by: string;
218
+ updated_at: number & {
219
+ __brand: "UnixTimestamp";
220
+ };
221
+ updated_by: string;
222
+ type: "statusChanged";
223
+ curr_status: string;
224
+ prev_status: string;
225
+ }, {
226
+ _id: string;
227
+ created_at: number;
228
+ updated_at: number;
229
+ message: string;
230
+ type: "note";
231
+ created_by?: string | undefined;
232
+ updated_by?: string | undefined;
233
+ } | {
234
+ _id: string;
235
+ created_at: number;
236
+ created_by: "system";
237
+ updated_at: number;
238
+ updated_by: "system";
239
+ message: string;
240
+ type: "system_info";
241
+ } | {
242
+ _id: string;
243
+ created_at: number;
244
+ updated_at: number;
245
+ type: "statusChanged";
246
+ curr_status: string;
247
+ prev_status: string;
27
248
  created_by?: string | undefined;
28
249
  updated_by?: string | undefined;
29
250
  }>;
@@ -31,3 +252,5 @@ export interface Comment extends Omit<z.infer<typeof CommentSchema>, 'created_at
31
252
  created_at: UnixTimestamp;
32
253
  updated_at: UnixTimestamp;
33
254
  }
255
+ export type CreateCommentDto = Omit<z.infer<typeof CommentSchema>, 'created_at' | 'updated_at'>;
256
+ export type UpdateCommentDto = Partial<Omit<CreateCommentDto, 'created_by'>>;
@@ -2,7 +2,39 @@
2
2
  import { DocumentSchema } from './document.js';
3
3
  import { z } from 'zod';
4
4
  /* * */
5
- export const CommentSchema = DocumentSchema.extend({
6
- _id: z.string(),
7
- text: z.string(),
8
- }).strict();
5
+ const COMMENT_TYPE_OPTIONS = ['statusChanged', 'note', 'system_info'];
6
+ export const CommentTypeSchema = z.enum(COMMENT_TYPE_OPTIONS);
7
+ /* * */
8
+ export const NoteCommentSchema = DocumentSchema.extend({
9
+ message: z.string(),
10
+ type: z.literal(CommentTypeSchema.enum.note),
11
+ });
12
+ export const SystemInfoCommentSchema = DocumentSchema.extend({
13
+ created_by: z.literal('system'),
14
+ message: z.string(),
15
+ type: z.literal(CommentTypeSchema.enum.system_info),
16
+ updated_by: z.literal('system'),
17
+ });
18
+ export const StatusChangedCommentSchema = DocumentSchema.extend({
19
+ curr_status: z.string(),
20
+ prev_status: z.string(),
21
+ type: z.literal(CommentTypeSchema.enum.statusChanged),
22
+ });
23
+ export const CommentSchema = z
24
+ .discriminatedUnion('type', [
25
+ NoteCommentSchema,
26
+ SystemInfoCommentSchema,
27
+ StatusChangedCommentSchema,
28
+ ])
29
+ .superRefine((data, ctx) => {
30
+ if (data.type === CommentTypeSchema.enum.statusChanged) {
31
+ const d = data;
32
+ if (d.curr_status === d.prev_status) {
33
+ ctx.addIssue({
34
+ code: z.ZodIssueCode.custom,
35
+ message: 'curr_status and prev_status must differ',
36
+ path: ['curr_status'],
37
+ });
38
+ }
39
+ }
40
+ });
@@ -1,19 +1,19 @@
1
1
  import { z } from 'zod';
2
2
  export declare const DocumentSchema: z.ZodObject<{
3
3
  _id: z.ZodString;
4
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>, "UnixTimestamp">;
4
+ created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
5
5
  created_by: z.ZodDefault<z.ZodString>;
6
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>, "UnixTimestamp">;
6
+ updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
7
7
  updated_by: z.ZodDefault<z.ZodString>;
8
8
  }, "strip", z.ZodTypeAny, {
9
9
  _id: string;
10
10
  created_at: number & {
11
11
  __brand: "UnixTimestamp";
12
- } & z.BRAND<"UnixTimestamp">;
12
+ };
13
13
  created_by: string;
14
14
  updated_at: number & {
15
15
  __brand: "UnixTimestamp";
16
- } & z.BRAND<"UnixTimestamp">;
16
+ };
17
17
  updated_by: string;
18
18
  }, {
19
19
  _id: string;
@@ -1,11 +1,11 @@
1
1
  /* * */
2
- import { validateUnixTimestamp } from './unix-timestamp.js';
2
+ import { unixTimeStampSchema } from './unix-timestamp.js';
3
3
  import { z } from 'zod';
4
4
  /* * */
5
5
  export const DocumentSchema = z.object({
6
6
  _id: z.string(),
7
- created_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
7
+ created_at: unixTimeStampSchema,
8
8
  created_by: z.string().default('system'),
9
- updated_at: z.number().transform(validateUnixTimestamp).brand('UnixTimestamp'),
9
+ updated_at: unixTimeStampSchema,
10
10
  updated_by: z.string().default('system'),
11
11
  });
@@ -4,9 +4,9 @@ export declare const scopeSchema: z.ZodEnum<["stop", "lines"]>;
4
4
  export declare const statusSchema: z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>;
5
5
  export declare const ProposedChangeSchema: z.ZodObject<{
6
6
  _id: z.ZodString;
7
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
7
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
8
8
  created_by: z.ZodDefault<z.ZodString>;
9
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
9
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
10
10
  updated_by: z.ZodDefault<z.ZodString>;
11
11
  } & {
12
12
  field_path: z.ZodString;
@@ -19,13 +19,13 @@ export declare const ProposedChangeSchema: z.ZodObject<{
19
19
  _id: string;
20
20
  created_at: number & {
21
21
  __brand: "UnixTimestamp";
22
- } & z.BRAND<"UnixTimestamp">;
23
- status: "pending" | "accepted" | "declined";
22
+ };
24
23
  created_by: string;
25
24
  updated_at: number & {
26
25
  __brand: "UnixTimestamp";
27
- } & z.BRAND<"UnixTimestamp">;
26
+ };
28
27
  updated_by: string;
28
+ status: "pending" | "accepted" | "declined";
29
29
  field_path: string;
30
30
  scope: "stop" | "lines";
31
31
  target_id: string;
@@ -39,16 +39,16 @@ export declare const ProposedChangeSchema: z.ZodObject<{
39
39
  scope: "stop" | "lines";
40
40
  target_id: string;
41
41
  user_id: string;
42
- status?: "pending" | "accepted" | "declined" | undefined;
43
42
  created_by?: string | undefined;
44
43
  updated_by?: string | undefined;
44
+ status?: "pending" | "accepted" | "declined" | undefined;
45
45
  field_value?: any;
46
46
  }>;
47
47
  export declare const CreateProposedChangeSchema: z.ZodObject<Omit<{
48
48
  _id: z.ZodString;
49
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
49
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
50
50
  created_by: z.ZodDefault<z.ZodString>;
51
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
51
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
52
52
  updated_by: z.ZodDefault<z.ZodString>;
53
53
  } & {
54
54
  field_path: z.ZodString;
@@ -58,9 +58,9 @@ export declare const CreateProposedChangeSchema: z.ZodObject<Omit<{
58
58
  target_id: z.ZodString;
59
59
  user_id: z.ZodString;
60
60
  }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
61
- status: "pending" | "accepted" | "declined";
62
61
  created_by: string;
63
62
  updated_by: string;
63
+ status: "pending" | "accepted" | "declined";
64
64
  field_path: string;
65
65
  scope: "stop" | "lines";
66
66
  target_id: string;
@@ -71,33 +71,33 @@ export declare const CreateProposedChangeSchema: z.ZodObject<Omit<{
71
71
  scope: "stop" | "lines";
72
72
  target_id: string;
73
73
  user_id: string;
74
- status?: "pending" | "accepted" | "declined" | undefined;
75
74
  created_by?: string | undefined;
76
75
  updated_by?: string | undefined;
76
+ status?: "pending" | "accepted" | "declined" | undefined;
77
77
  field_value?: any;
78
78
  }>;
79
79
  export declare const UpdateProposedChangeSchema: z.ZodObject<{
80
- status: z.ZodOptional<z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>>;
81
80
  created_by: z.ZodOptional<z.ZodDefault<z.ZodString>>;
82
81
  updated_by: z.ZodOptional<z.ZodDefault<z.ZodString>>;
82
+ status: z.ZodOptional<z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>>;
83
83
  field_path: z.ZodOptional<z.ZodString>;
84
84
  field_value: z.ZodOptional<z.ZodAny>;
85
85
  scope: z.ZodOptional<z.ZodEnum<["stop", "lines"]>>;
86
86
  target_id: z.ZodOptional<z.ZodString>;
87
87
  user_id: z.ZodOptional<z.ZodString>;
88
88
  }, "strict", z.ZodTypeAny, {
89
- status?: "pending" | "accepted" | "declined" | undefined;
90
89
  created_by?: string | undefined;
91
90
  updated_by?: string | undefined;
91
+ status?: "pending" | "accepted" | "declined" | undefined;
92
92
  field_path?: string | undefined;
93
93
  field_value?: any;
94
94
  scope?: "stop" | "lines" | undefined;
95
95
  target_id?: string | undefined;
96
96
  user_id?: string | undefined;
97
97
  }, {
98
- status?: "pending" | "accepted" | "declined" | undefined;
99
98
  created_by?: string | undefined;
100
99
  updated_by?: string | undefined;
100
+ status?: "pending" | "accepted" | "declined" | undefined;
101
101
  field_path?: string | undefined;
102
102
  field_value?: any;
103
103
  scope?: "stop" | "lines" | undefined;
@@ -6,7 +6,7 @@ import { z } from 'zod';
6
6
  export type UnixTimestamp = number & {
7
7
  __brand: 'UnixTimestamp';
8
8
  };
9
- export declare const unixTimeStampSchema: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
9
+ export declare const unixTimeStampSchema: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
10
10
  /**
11
11
  * This function validates if a number is a valid Unix Timestamp, in milliseconds.
12
12
  * It is assumed the number will always be greater than 10^10 (1e10) to ensure it is in milliseconds.
@@ -3,8 +3,7 @@ import { DateTime } from 'luxon';
3
3
  import { z } from 'zod';
4
4
  export const unixTimeStampSchema = z
5
5
  .number()
6
- .transform(validateUnixTimestamp)
7
- .brand('UnixTimestamp');
6
+ .transform(validateUnixTimestamp);
8
7
  /**
9
8
  * This function validates if a number is a valid Unix Timestamp, in milliseconds.
10
9
  * It is assumed the number will always be greater than 10^10 (1e10) to ensure it is in milliseconds.
@@ -3,9 +3,9 @@ import { type UnixTimestamp } from './_common/unix-timestamp.js';
3
3
  import { z } from 'zod';
4
4
  export declare const AgencySchema: z.ZodObject<{
5
5
  _id: z.ZodString;
6
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
6
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
7
7
  created_by: z.ZodDefault<z.ZodString>;
8
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
8
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
9
9
  updated_by: z.ZodDefault<z.ZodString>;
10
10
  } & {
11
11
  contact_emails_pta: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
@@ -32,11 +32,11 @@ export declare const AgencySchema: z.ZodObject<{
32
32
  _id: string;
33
33
  created_at: number & {
34
34
  __brand: "UnixTimestamp";
35
- } & z.BRAND<"UnixTimestamp">;
35
+ };
36
36
  created_by: string;
37
37
  updated_at: number & {
38
38
  __brand: "UnixTimestamp";
39
- } & z.BRAND<"UnixTimestamp">;
39
+ };
40
40
  updated_by: string;
41
41
  contact_emails_pta: string[];
42
42
  contact_emails_pto: string[];
@@ -77,9 +77,9 @@ export declare const AgencySchema: z.ZodObject<{
77
77
  }>;
78
78
  export declare const CreateAgencySchema: z.ZodObject<Omit<{
79
79
  _id: z.ZodString;
80
- created_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
80
+ created_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
81
81
  created_by: z.ZodDefault<z.ZodString>;
82
- updated_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
82
+ updated_at: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
83
83
  updated_by: z.ZodDefault<z.ZodString>;
84
84
  } & {
85
85
  contact_emails_pta: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;