@tmlmobilidade/types 20250917.1116.49 → 20250917.1256.45

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,17 +1,17 @@
1
1
  import { z } from 'zod';
2
- export declare const CommentTypeSchema: z.ZodEnum<["field_changed", "note"]>;
2
+ export declare const CommentTypeSchema: z.ZodEnum<["field_changed", "note", "crud"]>;
3
3
  export type CommentType = z.infer<typeof CommentTypeSchema>;
4
+ export declare const CrudCommentSchemaActionSchema: z.ZodEnum<["create", "update", "delete", "archived", "restored"]>;
5
+ export type CrudCommentSchemaAction = z.infer<typeof CrudCommentSchemaActionSchema>;
4
6
  export declare const NoteCommentSchema: z.ZodObject<{
5
- _id: z.ZodString;
7
+ _id: z.ZodOptional<z.ZodString>;
6
8
  created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
7
9
  created_by: z.ZodOptional<z.ZodString>;
8
10
  updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
9
11
  updated_by: z.ZodOptional<z.ZodString>;
10
- } & {
11
12
  message: z.ZodString;
12
13
  type: z.ZodLiteral<"note">;
13
14
  }, "strip", z.ZodTypeAny, {
14
- _id: string;
15
15
  created_at: number & {
16
16
  __brand: "UnixTimestamp";
17
17
  };
@@ -20,31 +20,30 @@ export declare const NoteCommentSchema: z.ZodObject<{
20
20
  };
21
21
  message: string;
22
22
  type: "note";
23
+ _id?: string | undefined;
23
24
  created_by?: string | undefined;
24
25
  updated_by?: string | undefined;
25
26
  }, {
26
- _id: string;
27
27
  created_at: number;
28
28
  updated_at: number;
29
29
  message: string;
30
30
  type: "note";
31
+ _id?: string | undefined;
31
32
  created_by?: string | undefined;
32
33
  updated_by?: string | undefined;
33
34
  }>;
34
35
  export declare const FieldChangedCommentSchema: z.ZodObject<{
35
- _id: z.ZodString;
36
+ _id: z.ZodOptional<z.ZodString>;
36
37
  created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
37
38
  created_by: z.ZodOptional<z.ZodString>;
38
39
  updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
39
40
  updated_by: z.ZodOptional<z.ZodString>;
40
- } & {
41
+ type: z.ZodLiteral<"field_changed">;
41
42
  curr_value: z.ZodAny;
42
43
  field: z.ZodString;
43
44
  metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
44
45
  prev_value: z.ZodAny;
45
- type: z.ZodLiteral<"field_changed">;
46
46
  }, "strip", z.ZodTypeAny, {
47
- _id: string;
48
47
  created_at: number & {
49
48
  __brand: "UnixTimestamp";
50
49
  };
@@ -53,34 +52,62 @@ export declare const FieldChangedCommentSchema: z.ZodObject<{
53
52
  };
54
53
  type: "field_changed";
55
54
  field: string;
55
+ _id?: string | undefined;
56
56
  created_by?: string | undefined;
57
57
  updated_by?: string | undefined;
58
58
  curr_value?: any;
59
59
  metadata?: Record<string, unknown> | null | undefined;
60
60
  prev_value?: any;
61
61
  }, {
62
- _id: string;
63
62
  created_at: number;
64
63
  updated_at: number;
65
64
  type: "field_changed";
66
65
  field: string;
66
+ _id?: string | undefined;
67
67
  created_by?: string | undefined;
68
68
  updated_by?: string | undefined;
69
69
  curr_value?: any;
70
70
  metadata?: Record<string, unknown> | null | undefined;
71
71
  prev_value?: any;
72
72
  }>;
73
+ export declare const CrudCommentSchema: z.ZodObject<{
74
+ _id: z.ZodOptional<z.ZodString>;
75
+ created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
76
+ created_by: z.ZodOptional<z.ZodString>;
77
+ updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
78
+ updated_by: z.ZodOptional<z.ZodString>;
79
+ type: z.ZodLiteral<"crud">;
80
+ action: z.ZodEnum<["create", "update", "delete", "archived", "restored"]>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ created_at: number & {
83
+ __brand: "UnixTimestamp";
84
+ };
85
+ updated_at: number & {
86
+ __brand: "UnixTimestamp";
87
+ };
88
+ type: "crud";
89
+ action: "create" | "update" | "delete" | "archived" | "restored";
90
+ _id?: string | undefined;
91
+ created_by?: string | undefined;
92
+ updated_by?: string | undefined;
93
+ }, {
94
+ created_at: number;
95
+ updated_at: number;
96
+ type: "crud";
97
+ action: "create" | "update" | "delete" | "archived" | "restored";
98
+ _id?: string | undefined;
99
+ created_by?: string | undefined;
100
+ updated_by?: string | undefined;
101
+ }>;
73
102
  export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
74
- _id: z.ZodString;
103
+ _id: z.ZodOptional<z.ZodString>;
75
104
  created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
76
105
  created_by: z.ZodOptional<z.ZodString>;
77
106
  updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
78
107
  updated_by: z.ZodOptional<z.ZodString>;
79
- } & {
80
108
  message: z.ZodString;
81
109
  type: z.ZodLiteral<"note">;
82
110
  }, "strip", z.ZodTypeAny, {
83
- _id: string;
84
111
  created_at: number & {
85
112
  __brand: "UnixTimestamp";
86
113
  };
@@ -89,30 +116,29 @@ export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type",
89
116
  };
90
117
  message: string;
91
118
  type: "note";
119
+ _id?: string | undefined;
92
120
  created_by?: string | undefined;
93
121
  updated_by?: string | undefined;
94
122
  }, {
95
- _id: string;
96
123
  created_at: number;
97
124
  updated_at: number;
98
125
  message: string;
99
126
  type: "note";
127
+ _id?: string | undefined;
100
128
  created_by?: string | undefined;
101
129
  updated_by?: string | undefined;
102
130
  }>, z.ZodObject<{
103
- _id: z.ZodString;
131
+ _id: z.ZodOptional<z.ZodString>;
104
132
  created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
105
133
  created_by: z.ZodOptional<z.ZodString>;
106
134
  updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
107
135
  updated_by: z.ZodOptional<z.ZodString>;
108
- } & {
136
+ type: z.ZodLiteral<"field_changed">;
109
137
  curr_value: z.ZodAny;
110
138
  field: z.ZodString;
111
139
  metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
112
140
  prev_value: z.ZodAny;
113
- type: z.ZodLiteral<"field_changed">;
114
141
  }, "strip", z.ZodTypeAny, {
115
- _id: string;
116
142
  created_at: number & {
117
143
  __brand: "UnixTimestamp";
118
144
  };
@@ -121,24 +147,52 @@ export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type",
121
147
  };
122
148
  type: "field_changed";
123
149
  field: string;
150
+ _id?: string | undefined;
124
151
  created_by?: string | undefined;
125
152
  updated_by?: string | undefined;
126
153
  curr_value?: any;
127
154
  metadata?: Record<string, unknown> | null | undefined;
128
155
  prev_value?: any;
129
156
  }, {
130
- _id: string;
131
157
  created_at: number;
132
158
  updated_at: number;
133
159
  type: "field_changed";
134
160
  field: string;
161
+ _id?: string | undefined;
135
162
  created_by?: string | undefined;
136
163
  updated_by?: string | undefined;
137
164
  curr_value?: any;
138
165
  metadata?: Record<string, unknown> | null | undefined;
139
166
  prev_value?: any;
167
+ }>, z.ZodObject<{
168
+ _id: z.ZodOptional<z.ZodString>;
169
+ created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
170
+ created_by: z.ZodOptional<z.ZodString>;
171
+ updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>;
172
+ updated_by: z.ZodOptional<z.ZodString>;
173
+ type: z.ZodLiteral<"crud">;
174
+ action: z.ZodEnum<["create", "update", "delete", "archived", "restored"]>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ created_at: number & {
177
+ __brand: "UnixTimestamp";
178
+ };
179
+ updated_at: number & {
180
+ __brand: "UnixTimestamp";
181
+ };
182
+ type: "crud";
183
+ action: "create" | "update" | "delete" | "archived" | "restored";
184
+ _id?: string | undefined;
185
+ created_by?: string | undefined;
186
+ updated_by?: string | undefined;
187
+ }, {
188
+ created_at: number;
189
+ updated_at: number;
190
+ type: "crud";
191
+ action: "create" | "update" | "delete" | "archived" | "restored";
192
+ _id?: string | undefined;
193
+ created_by?: string | undefined;
194
+ updated_by?: string | undefined;
140
195
  }>]>, {
141
- _id: string;
142
196
  created_at: number & {
143
197
  __brand: "UnixTimestamp";
144
198
  };
@@ -147,10 +201,10 @@ export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type",
147
201
  };
148
202
  message: string;
149
203
  type: "note";
204
+ _id?: string | undefined;
150
205
  created_by?: string | undefined;
151
206
  updated_by?: string | undefined;
152
207
  } | {
153
- _id: string;
154
208
  created_at: number & {
155
209
  __brand: "UnixTimestamp";
156
210
  };
@@ -159,33 +213,55 @@ export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type",
159
213
  };
160
214
  type: "field_changed";
161
215
  field: string;
216
+ _id?: string | undefined;
162
217
  created_by?: string | undefined;
163
218
  updated_by?: string | undefined;
164
219
  curr_value?: any;
165
220
  metadata?: Record<string, unknown> | null | undefined;
166
221
  prev_value?: any;
222
+ } | {
223
+ created_at: number & {
224
+ __brand: "UnixTimestamp";
225
+ };
226
+ updated_at: number & {
227
+ __brand: "UnixTimestamp";
228
+ };
229
+ type: "crud";
230
+ action: "create" | "update" | "delete" | "archived" | "restored";
231
+ _id?: string | undefined;
232
+ created_by?: string | undefined;
233
+ updated_by?: string | undefined;
167
234
  }, {
168
- _id: string;
169
235
  created_at: number;
170
236
  updated_at: number;
171
237
  message: string;
172
238
  type: "note";
239
+ _id?: string | undefined;
173
240
  created_by?: string | undefined;
174
241
  updated_by?: string | undefined;
175
242
  } | {
176
- _id: string;
177
243
  created_at: number;
178
244
  updated_at: number;
179
245
  type: "field_changed";
180
246
  field: string;
247
+ _id?: string | undefined;
181
248
  created_by?: string | undefined;
182
249
  updated_by?: string | undefined;
183
250
  curr_value?: any;
184
251
  metadata?: Record<string, unknown> | null | undefined;
185
252
  prev_value?: any;
253
+ } | {
254
+ created_at: number;
255
+ updated_at: number;
256
+ type: "crud";
257
+ action: "create" | "update" | "delete" | "archived" | "restored";
258
+ _id?: string | undefined;
259
+ created_by?: string | undefined;
260
+ updated_by?: string | undefined;
186
261
  }>;
187
262
  export type Comment = z.infer<typeof CommentSchema>;
188
263
  export type NoteComment = z.infer<typeof NoteCommentSchema>;
264
+ export type CrudComment = z.infer<typeof CrudCommentSchema>;
189
265
  export interface FieldChangedComment<T, K extends keyof T> extends Omit<z.infer<typeof FieldChangedCommentSchema>, 'curr_value' | 'field' | 'prev_value'> {
190
266
  curr_value: T[K];
191
267
  field: K;
@@ -2,20 +2,26 @@
2
2
  import { DocumentSchema } from './document.js';
3
3
  import { z } from 'zod';
4
4
  /* * */
5
- const COMMENT_TYPE_OPTIONS = ['field_changed', 'note'];
5
+ const COMMENT_TYPE_OPTIONS = ['field_changed', 'note', 'crud'];
6
6
  export const CommentTypeSchema = z.enum(COMMENT_TYPE_OPTIONS);
7
+ const CRUD_COMMENT_ACTION_OPTIONS = ['create', 'update', 'delete', 'archived', 'restored'];
8
+ export const CrudCommentSchemaActionSchema = z.enum(CRUD_COMMENT_ACTION_OPTIONS);
7
9
  /* * */
8
10
  export const NoteCommentSchema = DocumentSchema.extend({
9
11
  message: z.string(),
10
12
  type: z.literal(CommentTypeSchema.enum.note),
11
- });
13
+ }).partial({ _id: true });
12
14
  export const FieldChangedCommentSchema = DocumentSchema.extend({
13
15
  curr_value: z.any(),
14
16
  field: z.string(),
15
17
  metadata: z.record(z.unknown()).nullish(),
16
18
  prev_value: z.any(),
17
19
  type: z.literal(CommentTypeSchema.enum.field_changed),
18
- });
20
+ }).partial({ _id: true });
21
+ export const CrudCommentSchema = DocumentSchema.extend({
22
+ action: CrudCommentSchemaActionSchema,
23
+ type: z.literal(CommentTypeSchema.enum.crud),
24
+ }).partial({ _id: true });
19
25
  /* * */
20
26
  function validateFieldChanged(data, ctx) {
21
27
  if (data.curr_value === data.prev_value) {
@@ -31,6 +37,7 @@ export const CommentSchema = z
31
37
  .discriminatedUnion('type', [
32
38
  NoteCommentSchema,
33
39
  FieldChangedCommentSchema,
40
+ CrudCommentSchema,
34
41
  ])
35
42
  .superRefine((data, ctx) => {
36
43
  if (data.type === CommentTypeSchema.enum.field_changed) {
@@ -4,12 +4,12 @@ export declare const PermissionSchema: z.ZodObject<{
4
4
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
5
5
  scope: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- scope: string;
8
7
  action: string;
8
+ scope: string;
9
9
  resource?: Record<string, any> | null | undefined;
10
10
  }, {
11
- scope: string;
12
11
  action: string;
12
+ scope: string;
13
13
  resource?: Record<string, any> | null | undefined;
14
14
  }>;
15
15
  export interface Permission<T> {
@@ -12,12 +12,12 @@ export declare const RoleSchema: z.ZodObject<{
12
12
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
13
13
  scope: z.ZodString;
14
14
  }, "strip", z.ZodTypeAny, {
15
- scope: string;
16
15
  action: string;
16
+ scope: string;
17
17
  resource?: Record<string, any> | null | undefined;
18
18
  }, {
19
- scope: string;
20
19
  action: string;
20
+ scope: string;
21
21
  resource?: Record<string, any> | null | undefined;
22
22
  }>, "many">;
23
23
  }, "strict", z.ZodTypeAny, {
@@ -30,8 +30,8 @@ export declare const RoleSchema: z.ZodObject<{
30
30
  };
31
31
  name: string;
32
32
  permissions: {
33
- scope: string;
34
33
  action: string;
34
+ scope: string;
35
35
  resource?: Record<string, any> | null | undefined;
36
36
  }[];
37
37
  created_by?: string | undefined;
@@ -42,8 +42,8 @@ export declare const RoleSchema: z.ZodObject<{
42
42
  updated_at: number;
43
43
  name: string;
44
44
  permissions: {
45
- scope: string;
46
45
  action: string;
46
+ scope: string;
47
47
  resource?: Record<string, any> | null | undefined;
48
48
  }[];
49
49
  created_by?: string | undefined;
@@ -62,19 +62,19 @@ export declare const CreateRoleSchema: z.ZodObject<Omit<{
62
62
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
63
63
  scope: z.ZodString;
64
64
  }, "strip", z.ZodTypeAny, {
65
- scope: string;
66
65
  action: string;
66
+ scope: string;
67
67
  resource?: Record<string, any> | null | undefined;
68
68
  }, {
69
- scope: string;
70
69
  action: string;
70
+ scope: string;
71
71
  resource?: Record<string, any> | null | undefined;
72
72
  }>, "many">;
73
73
  }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
74
74
  name: string;
75
75
  permissions: {
76
- scope: string;
77
76
  action: string;
77
+ scope: string;
78
78
  resource?: Record<string, any> | null | undefined;
79
79
  }[];
80
80
  created_by?: string | undefined;
@@ -82,8 +82,8 @@ export declare const CreateRoleSchema: z.ZodObject<Omit<{
82
82
  }, {
83
83
  name: string;
84
84
  permissions: {
85
- scope: string;
86
85
  action: string;
86
+ scope: string;
87
87
  resource?: Record<string, any> | null | undefined;
88
88
  }[];
89
89
  created_by?: string | undefined;
@@ -97,28 +97,28 @@ export declare const UpdateRoleSchema: z.ZodObject<{
97
97
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
98
98
  scope: z.ZodString;
99
99
  }, "strip", z.ZodTypeAny, {
100
- scope: string;
101
100
  action: string;
101
+ scope: string;
102
102
  resource?: Record<string, any> | null | undefined;
103
103
  }, {
104
- scope: string;
105
104
  action: string;
105
+ scope: string;
106
106
  resource?: Record<string, any> | null | undefined;
107
107
  }>, "many">>;
108
108
  }, "strict", z.ZodTypeAny, {
109
109
  updated_by?: string | undefined;
110
110
  name?: string | undefined;
111
111
  permissions?: {
112
- scope: string;
113
112
  action: string;
113
+ scope: string;
114
114
  resource?: Record<string, any> | null | undefined;
115
115
  }[] | undefined;
116
116
  }, {
117
117
  updated_by?: string | undefined;
118
118
  name?: string | undefined;
119
119
  permissions?: {
120
- scope: string;
121
120
  action: string;
121
+ scope: string;
122
122
  resource?: Record<string, any> | null | undefined;
123
123
  }[] | undefined;
124
124
  }>;
@@ -22,12 +22,12 @@ export declare const UserSchema: z.ZodObject<{
22
22
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
23
23
  scope: z.ZodString;
24
24
  }, "strip", z.ZodTypeAny, {
25
- scope: string;
26
25
  action: string;
26
+ scope: string;
27
27
  resource?: Record<string, any> | null | undefined;
28
28
  }, {
29
- scope: string;
30
29
  action: string;
30
+ scope: string;
31
31
  resource?: Record<string, any> | null | undefined;
32
32
  }>, "many">;
33
33
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -46,8 +46,8 @@ export declare const UserSchema: z.ZodObject<{
46
46
  };
47
47
  email: string;
48
48
  permissions: {
49
- scope: string;
50
49
  action: string;
50
+ scope: string;
51
51
  resource?: Record<string, any> | null | undefined;
52
52
  }[];
53
53
  first_name: string;
@@ -71,8 +71,8 @@ export declare const UserSchema: z.ZodObject<{
71
71
  updated_at: number;
72
72
  email: string;
73
73
  permissions: {
74
- scope: string;
75
74
  action: string;
75
+ scope: string;
76
76
  resource?: Record<string, any> | null | undefined;
77
77
  }[];
78
78
  first_name: string;
@@ -111,12 +111,12 @@ export declare const CreateUserSchema: z.ZodObject<Omit<{
111
111
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
112
112
  scope: z.ZodString;
113
113
  }, "strip", z.ZodTypeAny, {
114
- scope: string;
115
114
  action: string;
115
+ scope: string;
116
116
  resource?: Record<string, any> | null | undefined;
117
117
  }, {
118
- scope: string;
119
118
  action: string;
119
+ scope: string;
120
120
  resource?: Record<string, any> | null | undefined;
121
121
  }>, "many">;
122
122
  phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -128,8 +128,8 @@ export declare const CreateUserSchema: z.ZodObject<Omit<{
128
128
  }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
129
129
  email: string;
130
130
  permissions: {
131
- scope: string;
132
131
  action: string;
132
+ scope: string;
133
133
  resource?: Record<string, any> | null | undefined;
134
134
  }[];
135
135
  first_name: string;
@@ -150,8 +150,8 @@ export declare const CreateUserSchema: z.ZodObject<Omit<{
150
150
  }, {
151
151
  email: string;
152
152
  permissions: {
153
- scope: string;
154
153
  action: string;
154
+ scope: string;
155
155
  resource?: Record<string, any> | null | undefined;
156
156
  }[];
157
157
  first_name: string;
@@ -179,12 +179,12 @@ export declare const UpdateUserSchema: z.ZodObject<{
179
179
  resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
180
180
  scope: z.ZodString;
181
181
  }, "strip", z.ZodTypeAny, {
182
- scope: string;
183
182
  action: string;
183
+ scope: string;
184
184
  resource?: Record<string, any> | null | undefined;
185
185
  }, {
186
- scope: string;
187
186
  action: string;
187
+ scope: string;
188
188
  resource?: Record<string, any> | null | undefined;
189
189
  }>, "many">>;
190
190
  avatar: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
@@ -204,8 +204,8 @@ export declare const UpdateUserSchema: z.ZodObject<{
204
204
  phone?: string | null | undefined;
205
205
  email?: string | undefined;
206
206
  permissions?: {
207
- scope: string;
208
207
  action: string;
208
+ scope: string;
209
209
  resource?: Record<string, any> | null | undefined;
210
210
  }[] | undefined;
211
211
  avatar?: string | null | undefined;
@@ -225,8 +225,8 @@ export declare const UpdateUserSchema: z.ZodObject<{
225
225
  phone?: string | null | undefined;
226
226
  email?: string | undefined;
227
227
  permissions?: {
228
- scope: string;
229
228
  action: string;
229
+ scope: string;
230
230
  resource?: Record<string, any> | null | undefined;
231
231
  }[] | undefined;
232
232
  avatar?: string | null | undefined;