@softruck/api-contracts 0.1.1-beta.3

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.
Files changed (250) hide show
  1. package/README.md +0 -0
  2. package/dist/alerts/api.d.ts +9 -0
  3. package/dist/alerts/api.js +8 -0
  4. package/dist/alerts/index.d.ts +3 -0
  5. package/dist/alerts/index.js +3 -0
  6. package/dist/alerts/schemas.d.ts +65 -0
  7. package/dist/alerts/schemas.js +29 -0
  8. package/dist/alerts/types.d.ts +36 -0
  9. package/dist/alerts/types.js +1 -0
  10. package/dist/auth/api.d.ts +26 -0
  11. package/dist/auth/api.js +39 -0
  12. package/dist/auth/index.d.ts +3 -0
  13. package/dist/auth/index.js +3 -0
  14. package/dist/auth/schemas/access-codes.d.ts +16 -0
  15. package/dist/auth/schemas/access-codes.js +13 -0
  16. package/dist/auth/schemas/login.d.ts +13 -0
  17. package/dist/auth/schemas/login.js +9 -0
  18. package/dist/auth/schemas/passwords.d.ts +81 -0
  19. package/dist/auth/schemas/passwords.js +28 -0
  20. package/dist/auth/schemas/sessions.d.ts +3 -0
  21. package/dist/auth/schemas/sessions.js +2 -0
  22. package/dist/auth/schemas/tokens.d.ts +11 -0
  23. package/dist/auth/schemas/tokens.js +9 -0
  24. package/dist/auth/schemas.d.ts +5 -0
  25. package/dist/auth/schemas.js +5 -0
  26. package/dist/auth/types.d.ts +1 -0
  27. package/dist/auth/types.js +1 -0
  28. package/dist/checklist/api.d.ts +30 -0
  29. package/dist/checklist/api.js +15 -0
  30. package/dist/checklist/index.d.ts +3 -0
  31. package/dist/checklist/index.js +3 -0
  32. package/dist/checklist/schemas.d.ts +62 -0
  33. package/dist/checklist/schemas.js +46 -0
  34. package/dist/checklist/types.d.ts +76 -0
  35. package/dist/checklist/types.js +1 -0
  36. package/dist/chips/api.d.ts +17 -0
  37. package/dist/chips/api.js +8 -0
  38. package/dist/chips/connections/api.d.ts +13 -0
  39. package/dist/chips/connections/api.js +4 -0
  40. package/dist/chips/connections/index.d.ts +3 -0
  41. package/dist/chips/connections/index.js +3 -0
  42. package/dist/chips/connections/schemas.d.ts +31 -0
  43. package/dist/chips/connections/schemas.js +31 -0
  44. package/dist/chips/connections/types.d.ts +26 -0
  45. package/dist/chips/connections/types.js +1 -0
  46. package/dist/chips/index.d.ts +5 -0
  47. package/dist/chips/index.js +5 -0
  48. package/dist/chips/requirements/api.d.ts +13 -0
  49. package/dist/chips/requirements/api.js +4 -0
  50. package/dist/chips/requirements/index.d.ts +3 -0
  51. package/dist/chips/requirements/index.js +3 -0
  52. package/dist/chips/requirements/schemas.d.ts +21 -0
  53. package/dist/chips/requirements/schemas.js +21 -0
  54. package/dist/chips/requirements/types.d.ts +16 -0
  55. package/dist/chips/requirements/types.js +1 -0
  56. package/dist/chips/schemas.d.ts +78 -0
  57. package/dist/chips/schemas.js +72 -0
  58. package/dist/chips/types.d.ts +76 -0
  59. package/dist/chips/types.js +1 -0
  60. package/dist/core/client.d.ts +45 -0
  61. package/dist/core/client.js +42 -0
  62. package/dist/core/index.d.ts +4 -0
  63. package/dist/core/index.js +4 -0
  64. package/dist/core/query-builder.d.ts +34 -0
  65. package/dist/core/query-builder.js +86 -0
  66. package/dist/core/schemas.d.ts +80 -0
  67. package/dist/core/schemas.js +31 -0
  68. package/dist/core/types.d.ts +119 -0
  69. package/dist/core/types.js +2 -0
  70. package/dist/devices/activations/api.d.ts +20 -0
  71. package/dist/devices/activations/api.js +9 -0
  72. package/dist/devices/activations/index.d.ts +3 -0
  73. package/dist/devices/activations/index.js +3 -0
  74. package/dist/devices/activations/schemas.d.ts +42 -0
  75. package/dist/devices/activations/schemas.js +42 -0
  76. package/dist/devices/activations/types.d.ts +75 -0
  77. package/dist/devices/activations/types.js +1 -0
  78. package/dist/devices/api.d.ts +28 -0
  79. package/dist/devices/api.js +11 -0
  80. package/dist/devices/commands/api.d.ts +17 -0
  81. package/dist/devices/commands/api.js +8 -0
  82. package/dist/devices/commands/index.d.ts +3 -0
  83. package/dist/devices/commands/index.js +3 -0
  84. package/dist/devices/commands/schemas.d.ts +39 -0
  85. package/dist/devices/commands/schemas.js +33 -0
  86. package/dist/devices/commands/types.d.ts +58 -0
  87. package/dist/devices/commands/types.js +1 -0
  88. package/dist/devices/index.d.ts +5 -0
  89. package/dist/devices/index.js +5 -0
  90. package/dist/devices/schemas.d.ts +115 -0
  91. package/dist/devices/schemas.js +96 -0
  92. package/dist/devices/types.d.ts +142 -0
  93. package/dist/devices/types.js +1 -0
  94. package/dist/enterprises/api.d.ts +27 -0
  95. package/dist/enterprises/api.js +15 -0
  96. package/dist/enterprises/index.d.ts +3 -0
  97. package/dist/enterprises/index.js +3 -0
  98. package/dist/enterprises/schemas.d.ts +59 -0
  99. package/dist/enterprises/schemas.js +53 -0
  100. package/dist/enterprises/types.d.ts +160 -0
  101. package/dist/enterprises/types.js +1 -0
  102. package/dist/events/api.d.ts +18 -0
  103. package/dist/events/api.js +13 -0
  104. package/dist/events/index.d.ts +3 -0
  105. package/dist/events/index.js +3 -0
  106. package/dist/events/schemas.d.ts +262 -0
  107. package/dist/events/schemas.js +54 -0
  108. package/dist/events/types.d.ts +130 -0
  109. package/dist/events/types.js +1 -0
  110. package/dist/exports/api.d.ts +18 -0
  111. package/dist/exports/api.js +9 -0
  112. package/dist/exports/index.d.ts +3 -0
  113. package/dist/exports/index.js +3 -0
  114. package/dist/exports/schemas.d.ts +27 -0
  115. package/dist/exports/schemas.js +22 -0
  116. package/dist/exports/types.d.ts +47 -0
  117. package/dist/exports/types.js +1 -0
  118. package/dist/fuelings/api.d.ts +22 -0
  119. package/dist/fuelings/api.js +9 -0
  120. package/dist/fuelings/index.d.ts +3 -0
  121. package/dist/fuelings/index.js +3 -0
  122. package/dist/fuelings/schemas.d.ts +84 -0
  123. package/dist/fuelings/schemas.js +52 -0
  124. package/dist/fuelings/types.d.ts +80 -0
  125. package/dist/fuelings/types.js +1 -0
  126. package/dist/index.d.ts +22 -0
  127. package/dist/index.js +22 -0
  128. package/dist/maintenances/api.d.ts +31 -0
  129. package/dist/maintenances/api.js +12 -0
  130. package/dist/maintenances/index.d.ts +3 -0
  131. package/dist/maintenances/index.js +3 -0
  132. package/dist/maintenances/schemas.d.ts +74 -0
  133. package/dist/maintenances/schemas.js +44 -0
  134. package/dist/maintenances/types.d.ts +69 -0
  135. package/dist/maintenances/types.js +1 -0
  136. package/dist/operation-logs/api.d.ts +13 -0
  137. package/dist/operation-logs/api.js +10 -0
  138. package/dist/operation-logs/index.d.ts +3 -0
  139. package/dist/operation-logs/index.js +3 -0
  140. package/dist/operation-logs/schemas.d.ts +34 -0
  141. package/dist/operation-logs/schemas.js +22 -0
  142. package/dist/operation-logs/types.d.ts +32 -0
  143. package/dist/operation-logs/types.js +1 -0
  144. package/dist/protocols/api.d.ts +34 -0
  145. package/dist/protocols/api.js +13 -0
  146. package/dist/protocols/index.d.ts +3 -0
  147. package/dist/protocols/index.js +3 -0
  148. package/dist/protocols/schemas.d.ts +66 -0
  149. package/dist/protocols/schemas.js +36 -0
  150. package/dist/protocols/types.d.ts +99 -0
  151. package/dist/protocols/types.js +1 -0
  152. package/dist/service-orders/api.d.ts +38 -0
  153. package/dist/service-orders/api.js +14 -0
  154. package/dist/service-orders/index.d.ts +3 -0
  155. package/dist/service-orders/index.js +3 -0
  156. package/dist/service-orders/schemas.d.ts +82 -0
  157. package/dist/service-orders/schemas.js +47 -0
  158. package/dist/service-orders/types.d.ts +84 -0
  159. package/dist/service-orders/types.js +1 -0
  160. package/dist/sharings/api.d.ts +17 -0
  161. package/dist/sharings/api.js +8 -0
  162. package/dist/sharings/index.d.ts +3 -0
  163. package/dist/sharings/index.js +3 -0
  164. package/dist/sharings/schemas.d.ts +47 -0
  165. package/dist/sharings/schemas.js +36 -0
  166. package/dist/sharings/types.d.ts +54 -0
  167. package/dist/sharings/types.js +1 -0
  168. package/dist/surveys/api.d.ts +2 -0
  169. package/dist/surveys/api.js +3 -0
  170. package/dist/surveys/index.d.ts +3 -0
  171. package/dist/surveys/index.js +3 -0
  172. package/dist/surveys/schemas.d.ts +33 -0
  173. package/dist/surveys/schemas.js +23 -0
  174. package/dist/surveys/types.d.ts +27 -0
  175. package/dist/surveys/types.js +1 -0
  176. package/dist/tags/api.d.ts +24 -0
  177. package/dist/tags/api.js +28 -0
  178. package/dist/tags/index.d.ts +3 -0
  179. package/dist/tags/index.js +3 -0
  180. package/dist/tags/schemas.d.ts +26 -0
  181. package/dist/tags/schemas.js +19 -0
  182. package/dist/tags/types.d.ts +16 -0
  183. package/dist/tags/types.js +1 -0
  184. package/dist/tracking/api.d.ts +2 -0
  185. package/dist/tracking/api.js +3 -0
  186. package/dist/tracking/index.d.ts +3 -0
  187. package/dist/tracking/index.js +3 -0
  188. package/dist/tracking/schemas.d.ts +12 -0
  189. package/dist/tracking/schemas.js +12 -0
  190. package/dist/tracking/types.d.ts +11 -0
  191. package/dist/tracking/types.js +1 -0
  192. package/dist/trajectories/api.d.ts +27 -0
  193. package/dist/trajectories/api.js +13 -0
  194. package/dist/trajectories/index.d.ts +3 -0
  195. package/dist/trajectories/index.js +3 -0
  196. package/dist/trajectories/schemas.d.ts +39 -0
  197. package/dist/trajectories/schemas.js +30 -0
  198. package/dist/trajectories/types.d.ts +58 -0
  199. package/dist/trajectories/types.js +1 -0
  200. package/dist/trips/api.d.ts +30 -0
  201. package/dist/trips/api.js +12 -0
  202. package/dist/trips/index.d.ts +3 -0
  203. package/dist/trips/index.js +3 -0
  204. package/dist/trips/schemas.d.ts +62 -0
  205. package/dist/trips/schemas.js +36 -0
  206. package/dist/trips/types.d.ts +65 -0
  207. package/dist/trips/types.js +1 -0
  208. package/dist/users/api.d.ts +533 -0
  209. package/dist/users/api.js +102 -0
  210. package/dist/users/configuration/api.d.ts +21 -0
  211. package/dist/users/configuration/api.js +16 -0
  212. package/dist/users/configuration/index.d.ts +3 -0
  213. package/dist/users/configuration/index.js +3 -0
  214. package/dist/users/configuration/schemas.d.ts +91 -0
  215. package/dist/users/configuration/schemas.js +42 -0
  216. package/dist/users/configuration/types.d.ts +36 -0
  217. package/dist/users/configuration/types.js +1 -0
  218. package/dist/users/index.d.ts +4 -0
  219. package/dist/users/index.js +4 -0
  220. package/dist/users/schemas/addresses.d.ts +136 -0
  221. package/dist/users/schemas/addresses.js +94 -0
  222. package/dist/users/schemas/authenticated-user.d.ts +30 -0
  223. package/dist/users/schemas/authenticated-user.js +21 -0
  224. package/dist/users/schemas/common.d.ts +28 -0
  225. package/dist/users/schemas/common.js +26 -0
  226. package/dist/users/schemas/documents.d.ts +40 -0
  227. package/dist/users/schemas/documents.js +53 -0
  228. package/dist/users/schemas/passwords.d.ts +10 -0
  229. package/dist/users/schemas/passwords.js +15 -0
  230. package/dist/users/schemas/roles.d.ts +60 -0
  231. package/dist/users/schemas/roles.js +9 -0
  232. package/dist/users/schemas/sessions.d.ts +84 -0
  233. package/dist/users/schemas/sessions.js +55 -0
  234. package/dist/users/schemas/usernames.d.ts +14 -0
  235. package/dist/users/schemas/usernames.js +12 -0
  236. package/dist/users/schemas/users.d.ts +648 -0
  237. package/dist/users/schemas/users.js +243 -0
  238. package/dist/users/schemas.d.ts +8 -0
  239. package/dist/users/schemas.js +8 -0
  240. package/dist/users/types.d.ts +1 -0
  241. package/dist/users/types.js +1 -0
  242. package/dist/vehicles/api.d.ts +28 -0
  243. package/dist/vehicles/api.js +13 -0
  244. package/dist/vehicles/index.d.ts +3 -0
  245. package/dist/vehicles/index.js +3 -0
  246. package/dist/vehicles/schemas.d.ts +88 -0
  247. package/dist/vehicles/schemas.js +71 -0
  248. package/dist/vehicles/types.d.ts +142 -0
  249. package/dist/vehicles/types.js +1 -0
  250. package/package.json +59 -0
@@ -0,0 +1,243 @@
1
+ import { z } from 'zod';
2
+ import { EnterpriseRelAttrSchema, FilterValueSchema } from '../../core/schemas.js';
3
+ import { NullableTimestampsAttributesSchema, NullableUserContactAttributesSchema, NullableUserDocumentAttributesSchema, OptionalUserContactAttributesSchema, OptionalUserDocumentAttributesSchema, RoleAttributesSchema, } from './common.js';
4
+ const UserAttributeKeySchema = z.enum([
5
+ 'id',
6
+ 'uuid',
7
+ 'enterprise_id',
8
+ 'username',
9
+ 'email',
10
+ 'name',
11
+ 'phone1',
12
+ 'phone2',
13
+ 'last_login_at',
14
+ 'emergency_contact',
15
+ 'emergency_phone',
16
+ 'document_number',
17
+ 'cpf',
18
+ 'birthdate',
19
+ 'created_at',
20
+ 'updated_at',
21
+ 'deleted_at',
22
+ 'deleted',
23
+ 'deactivated_at',
24
+ 'locale',
25
+ 'user_type',
26
+ 'last_integration_source',
27
+ 'last_integration_time',
28
+ 'invalid_email_address',
29
+ 'otp',
30
+ 'reachable_email_address',
31
+ ]);
32
+ const UserIncludeKeySchema = z.enum([
33
+ 'enterprise',
34
+ 'document',
35
+ 'times',
36
+ 'identification_users',
37
+ 'roles',
38
+ 'addresses',
39
+ 'vehicles',
40
+ 'tags',
41
+ ]);
42
+ const UserFilterKeySchema = z.enum([
43
+ ...UserAttributeKeySchema.options,
44
+ 'users.id',
45
+ 'users.uuid',
46
+ 'users.enterprise_id',
47
+ 'users.username',
48
+ 'users.email',
49
+ 'users.name',
50
+ 'users.phone1',
51
+ 'users.phone2',
52
+ 'users.last_login_at',
53
+ 'users.emergency_contact',
54
+ 'users.emergency_phone',
55
+ 'users.document_number',
56
+ 'users.cpf',
57
+ 'users.birthdate',
58
+ 'users.created_at',
59
+ 'users.updated_at',
60
+ 'users.deleted_at',
61
+ 'users.deleted',
62
+ 'users.deactivated_at',
63
+ 'users.locale',
64
+ 'users.user_type',
65
+ 'users.last_integration_source',
66
+ 'users.last_integration_time',
67
+ 'users.invalid_email_address',
68
+ 'users.otp',
69
+ 'users.reachable_email_address',
70
+ 'enterprise.id',
71
+ 'enterprise.name',
72
+ 'roles.name',
73
+ 'roles.internal',
74
+ 'tags.id',
75
+ 'tags.name',
76
+ ]);
77
+ const UserGroupByFieldSchema = z.enum(['users.locale', 'users.created_at', 'users.deactivated_at', 'roles.name']);
78
+ const UserFieldSelectionSchema = z.union([z.string(), z.literal('*')]);
79
+ const UserAttributeSelectionSchema = z.union([UserAttributeKeySchema, z.literal('*')]);
80
+ const UserGroupByValueSchema = z.string().refine(value => value
81
+ .split(',')
82
+ .every(field => UserGroupByFieldSchema.safeParse(field.split(':')[0]).success), 'Invalid user groupBy field');
83
+ const UserQueryParamsShape = {
84
+ count: z.union([z.boolean(), z.literal('only')]).optional(),
85
+ page: z.number().optional(),
86
+ limit: z.number().optional(),
87
+ search: z.string().optional(),
88
+ attributes: z.array(UserAttributeSelectionSchema).optional(),
89
+ includes: z.partialRecord(UserIncludeKeySchema, z.array(UserFieldSelectionSchema)).optional(),
90
+ filters: z.partialRecord(UserFilterKeySchema, z.union([FilterValueSchema, z.array(FilterValueSchema)])).optional(),
91
+ sort: z.object({ prop: UserFilterKeySchema, order: z.enum(['ASC', 'DESC']) }).strict().optional(),
92
+ };
93
+ export const UserQueryParamsSchema = z.object(UserQueryParamsShape).strict();
94
+ export const UserPanelQueryParamsSchema = z
95
+ .object({
96
+ ...UserQueryParamsShape,
97
+ any: z
98
+ .object({
99
+ groupBy: z.object({ value: UserGroupByValueSchema }).strict(),
100
+ })
101
+ .strict(),
102
+ })
103
+ .strict();
104
+ export const CreateUserPayloadSchema = z.object({
105
+ attributes: z
106
+ .object({
107
+ username: z.string().min(1),
108
+ password: z.string().min(1).optional(),
109
+ name: z.string().min(1),
110
+ locale: z.enum(['pt_BR', 'es_UY', 'en_US']),
111
+ email: z.email().optional(),
112
+ birthdate: z.string().optional(),
113
+ })
114
+ .extend(OptionalUserContactAttributesSchema.shape)
115
+ .extend(OptionalUserDocumentAttributesSchema.shape)
116
+ .strict(),
117
+ relationships: z.object({
118
+ enterprise: z.object({ type: z.literal('enterprise'), id: z.string() }).strict(),
119
+ roles: z.object({ type: z.literal('roles'), id: z.string() }).strict().optional(),
120
+ }).strict(),
121
+ }).strict();
122
+ export const CreateUsersPayloadSchema = z
123
+ .object({
124
+ data: z.array(CreateUserPayloadSchema).min(1),
125
+ })
126
+ .strict();
127
+ export const CreatedUserSchema = z.object({
128
+ id: z.string(),
129
+ type: z.string().optional(),
130
+ attributes: z.record(z.string(), z.unknown()).optional(),
131
+ relationships: z.record(z.string(), z.unknown()).optional(),
132
+ });
133
+ export const CreateUsersResponseSchema = z
134
+ .object({
135
+ data: z.array(CreatedUserSchema),
136
+ })
137
+ .strict();
138
+ export const UpdateUserPayloadSchema = z.object({
139
+ attributes: z
140
+ .object({
141
+ username: z.string().optional(),
142
+ name: z.string().optional(),
143
+ email: z.email().optional(),
144
+ birthdate: z.string().nullable().optional(),
145
+ cpf: z.string().optional(),
146
+ document_number: z.string().nullable().optional(),
147
+ emergency_contact: z.string().nullable().optional(),
148
+ locale: z.string().optional(),
149
+ phone1: z.string().nullable().optional(),
150
+ phone2: z.string().nullable().optional(),
151
+ emergency_phone: z.string().nullable().optional(),
152
+ })
153
+ .strict()
154
+ .optional(),
155
+ relationships: z
156
+ .object({
157
+ enterprise: z.object({ type: z.literal('enterprise'), id: z.string() }).strict().optional(),
158
+ roles: z.object({ type: z.literal('roles'), id: z.string() }).strict().nullable().optional(),
159
+ })
160
+ .strict()
161
+ .optional(),
162
+ }).strict();
163
+ export const DeleteUsersPayloadSchema = z
164
+ .object({
165
+ data: z.array(z.object({ type: z.literal('users'), id: z.string().min(1) }).strict()).min(1).max(1000),
166
+ })
167
+ .strict();
168
+ export const UserAttributesSchema = z
169
+ .object({
170
+ name: z.string(),
171
+ username: z.string(),
172
+ email: z.string().nullable(),
173
+ birthdate: z.string().nullable(),
174
+ locale: z.string().nullable(),
175
+ last_login_at: z.string().nullable(),
176
+ last_integration_source: z.string().nullable(),
177
+ last_integration_time: z.string().nullable(),
178
+ deactivated_at: z.string().nullable(),
179
+ })
180
+ .extend(NullableUserContactAttributesSchema.shape)
181
+ .extend(NullableUserDocumentAttributesSchema.shape)
182
+ .extend(NullableTimestampsAttributesSchema.shape);
183
+ export const UserPanelRowSchema = z.object({
184
+ type: z.string(),
185
+ attributes: z.object({
186
+ created_at: z.object({ day: z.string() }),
187
+ deactivated_at: z.string().nullable(),
188
+ locale: z.string(),
189
+ count: z.string(),
190
+ roles: z.object({ name: z.string().nullable() }),
191
+ }),
192
+ relationships: z.record(z.string(), z.unknown()),
193
+ });
194
+ export const UserSchema = z.object({
195
+ id: z.string(),
196
+ attributes: UserAttributesSchema,
197
+ relationships: z.object({
198
+ enterprise: z
199
+ .object({
200
+ id: z.string(),
201
+ attributes: EnterpriseRelAttrSchema,
202
+ })
203
+ .nullable()
204
+ .optional(),
205
+ roles: z.array(z.object({ attributes: RoleAttributesSchema })).optional(),
206
+ tags: z.array(z.object({
207
+ id: z.string(),
208
+ attributes: z.object({ name: z.string(), color: z.string().nullable() }),
209
+ })).optional(),
210
+ document: z
211
+ .object({ attributes: z.object({ folder: z.string() }) })
212
+ .nullable()
213
+ .optional(),
214
+ }),
215
+ });
216
+ export const SerializedUserSchema = z.object({
217
+ type: z.literal('users'),
218
+ id: z.union([z.string(), z.number()]),
219
+ uuid: z.string().optional(),
220
+ attributes: z.object({
221
+ username: z.string(),
222
+ email: z.string().nullable().optional(),
223
+ name: z.string().nullable().optional(),
224
+ phone1: z.string().nullable().optional(),
225
+ phone2: z.string().nullable().optional(),
226
+ emergency_contact: z.string().nullable().optional(),
227
+ emergency_phone: z.string().nullable().optional(),
228
+ document_number: z.string().nullable().optional(),
229
+ cpf: z.string().nullable().optional(),
230
+ birthdate: z.string().nullable().optional(),
231
+ last_login_at: z.string().nullable().optional(),
232
+ deactivated_at: z.string().nullable().optional(),
233
+ locale: z.string(),
234
+ user_type: z.string().nullable().optional(),
235
+ last_integration_source: z.string().nullable().optional(),
236
+ last_integration_time: z.string().nullable().optional(),
237
+ created_at: z.string(),
238
+ updated_at: z.string(),
239
+ deleted: z.boolean().optional(),
240
+ otp: z.boolean().optional(),
241
+ }).strict(),
242
+ relationships: z.record(z.string(), z.unknown()),
243
+ }).strict();
@@ -0,0 +1,8 @@
1
+ export * from './schemas/addresses';
2
+ export * from './schemas/authenticated-user';
3
+ export * from './schemas/documents';
4
+ export * from './schemas/passwords';
5
+ export * from './schemas/roles';
6
+ export * from './schemas/sessions';
7
+ export * from './schemas/usernames';
8
+ export * from './schemas/users';
@@ -0,0 +1,8 @@
1
+ export * from './schemas/addresses.js';
2
+ export * from './schemas/authenticated-user.js';
3
+ export * from './schemas/documents.js';
4
+ export * from './schemas/passwords.js';
5
+ export * from './schemas/roles.js';
6
+ export * from './schemas/sessions.js';
7
+ export * from './schemas/usernames.js';
8
+ export * from './schemas/users.js';
@@ -0,0 +1 @@
1
+ export type { AddressQueryParams, AuthenticatedUserData, CheckUsernamePayload, CheckUsernameResponse, ConfirmUserDocumentUploadPayload, CreateAddressPayload, CreatedUser, CreateUserPayload, CreateUsersPayload, CreateUsersResponse, DeleteUsersPayload, Role, RoleQueryParams, SerializedUser, SessionQueryParams, UpdateAddressPayload, UpdatePasswordPayload, UpdateUserPayload, User, UserAddress, UserAttributes, UserDocument, UserDocumentSignedLinkPayload, UserDocumentSignedLinkResponse, UserPanelQueryParams, UserPanelRow, UserQueryParams, UserSession, } from './schemas';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { ApiClientLike } from '../core/client';
2
+ import type { QueryParams } from '../core/query-builder';
3
+ import type { AssociateDevicesPayload, AssociateUsersPayload, DeleteVehicleDeviceAssociationsPayload, Vehicle, VehicleDevice, VehiclePanelRow, VehicleUser } from './types';
4
+ export declare function createVehiclesApi(client: ApiClientLike): {
5
+ listDevices: (vehicleId: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
6
+ data: VehicleDevice[];
7
+ count: number;
8
+ }>;
9
+ listUsers: (vehicleId: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
10
+ data: VehicleUser[];
11
+ count: number;
12
+ }>;
13
+ associateDevices: (payload: AssociateDevicesPayload) => Promise<undefined>;
14
+ disassociateDevices: (payload: DeleteVehicleDeviceAssociationsPayload) => Promise<undefined>;
15
+ associateUsers: (payload: AssociateUsersPayload) => Promise<undefined>;
16
+ panel: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
17
+ data: VehiclePanelRow[];
18
+ }>;
19
+ endpoint: string;
20
+ list: <R = Vehicle>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<import("..").ListResponse<R>>;
21
+ get: <R = Vehicle>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
22
+ data: R;
23
+ }>;
24
+ create: (payload: unknown) => Promise<undefined>;
25
+ update: (id: string, payload: unknown) => Promise<undefined>;
26
+ remove: (id: string) => Promise<undefined>;
27
+ removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
28
+ };
@@ -0,0 +1,13 @@
1
+ import { createResourceApi } from '../core/client.js';
2
+ import { withQuery } from '../core/query-builder.js';
3
+ export function createVehiclesApi(client) {
4
+ return {
5
+ ...createResourceApi(client, '/v5/vehicles'),
6
+ listDevices: (vehicleId, params = {}, signal) => client.get(withQuery(`/v5/vehicles/${vehicleId}/associations/devices`, params), { signal }).then(r => r.data),
7
+ listUsers: (vehicleId, params = {}, signal) => client.get(withQuery(`/v5/vehicles/${vehicleId}/associations/users`, params), { signal }).then(r => r.data),
8
+ associateDevices: (payload) => client.post('/v5/vehicles/associations/devices', payload).then(() => undefined),
9
+ disassociateDevices: (payload) => client.delete('/v5/vehicles/associations/devices', { data: payload }).then(() => undefined),
10
+ associateUsers: (payload) => client.post('/v5/vehicles/associations/users', payload).then(() => undefined),
11
+ panel: (params = {}, signal) => client.get(withQuery('/v5/vehicles', params), { signal }).then(r => r.data),
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ export * from './api';
2
+ export * from './schemas';
3
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ export * from './api.js';
2
+ export * from './schemas.js';
3
+ export * from './types.js';
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ export declare const VehicleSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ attributes: z.ZodObject<{
5
+ plate: z.ZodNullable<z.ZodString>;
6
+ vin: z.ZodNullable<z.ZodString>;
7
+ code: z.ZodNullable<z.ZodString>;
8
+ brand_name: z.ZodNullable<z.ZodString>;
9
+ model_name: z.ZodNullable<z.ZodString>;
10
+ trim_name: z.ZodNullable<z.ZodString>;
11
+ type_name: z.ZodNullable<z.ZodString>;
12
+ color: z.ZodNullable<z.ZodString>;
13
+ year: z.ZodNullable<z.ZodNumber>;
14
+ document: z.ZodNullable<z.ZodString>;
15
+ created_at: z.ZodNullable<z.ZodString>;
16
+ updated_at: z.ZodNullable<z.ZodString>;
17
+ deactivated_at: z.ZodNullable<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ relationships: z.ZodObject<{
20
+ enterprise: z.ZodNullable<z.ZodObject<{
21
+ attributes: z.ZodObject<{
22
+ name: z.ZodNullable<z.ZodString>;
23
+ cnpj: z.ZodNullable<z.ZodString>;
24
+ email: z.ZodNullable<z.ZodString>;
25
+ }, z.core.$strip>;
26
+ }, z.core.$strip>>;
27
+ last_gps: z.ZodNullable<z.ZodObject<{
28
+ attributes: z.ZodObject<{
29
+ last_gps_time: z.ZodNullable<z.ZodString>;
30
+ last_connection_time: z.ZodNullable<z.ZodString>;
31
+ lat: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ lng: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ }, z.core.$strip>;
34
+ }, z.core.$strip>>;
35
+ devices: z.ZodArray<z.ZodObject<{
36
+ id: z.ZodString;
37
+ attributes: z.ZodObject<{
38
+ name: z.ZodString;
39
+ imei: z.ZodString;
40
+ }, z.core.$strip>;
41
+ }, z.core.$strip>>;
42
+ tags: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ attributes: z.ZodObject<{
45
+ name: z.ZodString;
46
+ color: z.ZodNullable<z.ZodString>;
47
+ }, z.core.$strip>;
48
+ }, z.core.$strip>>;
49
+ type: z.ZodNullable<z.ZodObject<{
50
+ attributes: z.ZodObject<{
51
+ name: z.ZodString;
52
+ }, z.core.$strip>;
53
+ }, z.core.$strip>>;
54
+ document: z.ZodNullable<z.ZodObject<{
55
+ attributes: z.ZodObject<{
56
+ name: z.ZodNullable<z.ZodString>;
57
+ mime: z.ZodNullable<z.ZodString>;
58
+ folder: z.ZodNullable<z.ZodString>;
59
+ }, z.core.$strip>;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>;
62
+ }, z.core.$strip>;
63
+ export declare const CreateVehiclePayloadSchema: z.ZodObject<{
64
+ attributes: z.ZodObject<{
65
+ type: z.ZodString;
66
+ plate: z.ZodOptional<z.ZodString>;
67
+ vin: z.ZodOptional<z.ZodString>;
68
+ year: z.ZodOptional<z.ZodString>;
69
+ code: z.ZodOptional<z.ZodString>;
70
+ description: z.ZodOptional<z.ZodString>;
71
+ registration_number: z.ZodOptional<z.ZodString>;
72
+ color: z.ZodOptional<z.ZodString>;
73
+ batch: z.ZodOptional<z.ZodString>;
74
+ brand: z.ZodOptional<z.ZodString>;
75
+ model: z.ZodOptional<z.ZodString>;
76
+ trim: z.ZodOptional<z.ZodString>;
77
+ valuation_method: z.ZodOptional<z.ZodString>;
78
+ reference_code: z.ZodOptional<z.ZodString>;
79
+ current_value: z.ZodOptional<z.ZodNumber>;
80
+ currency: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>;
82
+ relationships: z.ZodObject<{
83
+ enterprise: z.ZodObject<{
84
+ type: z.ZodLiteral<"enterprise">;
85
+ id: z.ZodString;
86
+ }, z.core.$strip>;
87
+ }, z.core.$strip>;
88
+ }, z.core.$strip>;
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+ export const VehicleSchema = z.object({
3
+ id: z.string(),
4
+ attributes: z.object({
5
+ plate: z.string().nullable(),
6
+ vin: z.string().nullable(),
7
+ code: z.string().nullable(),
8
+ brand_name: z.string().nullable(),
9
+ model_name: z.string().nullable(),
10
+ trim_name: z.string().nullable(),
11
+ type_name: z.string().nullable(),
12
+ color: z.string().nullable(),
13
+ year: z.number().nullable(),
14
+ document: z.string().nullable(),
15
+ created_at: z.string().nullable(),
16
+ updated_at: z.string().nullable(),
17
+ deactivated_at: z.string().nullable(),
18
+ }),
19
+ relationships: z.object({
20
+ enterprise: z.object({
21
+ attributes: z.object({ name: z.string().nullable(), cnpj: z.string().nullable(), email: z.string().nullable() }),
22
+ }).nullable(),
23
+ last_gps: z.object({
24
+ attributes: z.object({
25
+ last_gps_time: z.string().nullable(),
26
+ last_connection_time: z.string().nullable(),
27
+ lat: z.string().nullable().optional(),
28
+ lng: z.string().nullable().optional(),
29
+ }),
30
+ }).nullable(),
31
+ devices: z.array(z.object({
32
+ id: z.string(),
33
+ attributes: z.object({ name: z.string(), imei: z.string() }),
34
+ })),
35
+ tags: z.array(z.object({
36
+ id: z.string(),
37
+ attributes: z.object({ name: z.string(), color: z.string().nullable() }),
38
+ })),
39
+ type: z.object({ attributes: z.object({ name: z.string() }) }).nullable(),
40
+ document: z.object({
41
+ attributes: z.object({
42
+ name: z.string().nullable(),
43
+ mime: z.string().nullable(),
44
+ folder: z.string().nullable(),
45
+ }),
46
+ }).nullable(),
47
+ }),
48
+ });
49
+ export const CreateVehiclePayloadSchema = z.object({
50
+ attributes: z.object({
51
+ type: z.string().min(1),
52
+ plate: z.string().optional(),
53
+ vin: z.string().optional(),
54
+ year: z.string().optional(),
55
+ code: z.string().optional(),
56
+ description: z.string().optional(),
57
+ registration_number: z.string().optional(),
58
+ color: z.string().optional(),
59
+ batch: z.string().optional(),
60
+ brand: z.string().optional(),
61
+ model: z.string().optional(),
62
+ trim: z.string().optional(),
63
+ valuation_method: z.string().optional(),
64
+ reference_code: z.string().optional(),
65
+ current_value: z.number().optional(),
66
+ currency: z.string().optional(),
67
+ }),
68
+ relationships: z.object({
69
+ enterprise: z.object({ type: z.literal('enterprise'), id: z.string() }),
70
+ }),
71
+ });
@@ -0,0 +1,142 @@
1
+ import type { Deactivatable, EnterpriseRelAttr, LastGpsAttr, Tag, UserRelAttr } from '../core/types';
2
+ export interface VehicleAttributes extends Deactivatable {
3
+ plate: string | null;
4
+ vin: string | null;
5
+ code: string | null;
6
+ brand_name: string | null;
7
+ model_name: string | null;
8
+ trim_name: string | null;
9
+ type_name: string | null;
10
+ color: string | null;
11
+ year: number | null;
12
+ document: string | null;
13
+ }
14
+ export interface Vehicle {
15
+ id: string;
16
+ attributes: VehicleAttributes;
17
+ relationships: {
18
+ enterprise: {
19
+ id: string;
20
+ attributes: EnterpriseRelAttr;
21
+ } | null;
22
+ last_gps: {
23
+ attributes: LastGpsAttr;
24
+ } | null;
25
+ devices: Array<{
26
+ id: string;
27
+ attributes: {
28
+ name: string;
29
+ imei: string;
30
+ };
31
+ }>;
32
+ tags: Tag[];
33
+ type: {
34
+ attributes: {
35
+ name: string;
36
+ };
37
+ } | null;
38
+ document: {
39
+ attributes: {
40
+ name: string | null;
41
+ mime: string | null;
42
+ folder: string | null;
43
+ };
44
+ } | null;
45
+ };
46
+ }
47
+ export interface VehicleDevice {
48
+ id: string;
49
+ relationships: {
50
+ device: {
51
+ attributes: {
52
+ name: string;
53
+ imei: string;
54
+ deleted_at: string | null;
55
+ };
56
+ } | null;
57
+ enterprise: {
58
+ attributes: Pick<EnterpriseRelAttr, 'name' | 'cnpj'>;
59
+ } | null;
60
+ };
61
+ }
62
+ export interface VehicleUser {
63
+ id: string;
64
+ relationships: {
65
+ user: {
66
+ attributes: Pick<UserRelAttr, 'name' | 'username' | 'email' | 'phone1' | 'deleted_at'>;
67
+ } | null;
68
+ };
69
+ }
70
+ export interface CreateVehiclePayload {
71
+ attributes: {
72
+ type: string;
73
+ plate?: string;
74
+ vin?: string;
75
+ year?: string;
76
+ code?: string;
77
+ description?: string;
78
+ registration_number?: string;
79
+ color?: string;
80
+ batch?: string;
81
+ brand?: string;
82
+ model?: string;
83
+ trim?: string;
84
+ valuation_method?: string;
85
+ reference_code?: string;
86
+ current_value?: number;
87
+ currency?: string;
88
+ };
89
+ relationships: {
90
+ enterprise: {
91
+ type: 'enterprise';
92
+ id: string;
93
+ };
94
+ };
95
+ }
96
+ export interface AssociateDevicesPayload {
97
+ data: Array<{
98
+ device_id: string;
99
+ asset_id: string;
100
+ is_main_device?: boolean;
101
+ shadow?: boolean;
102
+ }>;
103
+ }
104
+ export type VehicleUserCommand = 'general_location' | 'out_enable-1' | 'out_disable-1';
105
+ export interface AssociateUsersPayload {
106
+ data: Array<{
107
+ asset_id: string;
108
+ user_id: string;
109
+ meta?: {
110
+ permissions: {
111
+ commands?: VehicleUserCommand[];
112
+ sharings?: boolean;
113
+ };
114
+ } | null;
115
+ }>;
116
+ }
117
+ export interface DeleteVehicleDeviceAssociationsPayload {
118
+ data: Array<{
119
+ type: 'device_association';
120
+ id: string;
121
+ }>;
122
+ }
123
+ export interface VehiclePanelRow {
124
+ type: string;
125
+ attributes: {
126
+ created_at: {
127
+ day: string;
128
+ };
129
+ brand_name: string | null;
130
+ type_name: string | null;
131
+ year: string | null;
132
+ color: string | null;
133
+ currency: string | null;
134
+ count: string;
135
+ sum: {
136
+ asset_vehicles: {
137
+ current_value: string | null;
138
+ };
139
+ } | null;
140
+ };
141
+ relationships: Record<string, unknown>;
142
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@softruck/api-contracts",
3
+ "version": "0.1.1-beta.3",
4
+ "description": "Shared API contracts, schemas, and client factories for Softruck front-end applications.",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+ssh://git@bitbucket.org/softrucktechteam/api-contracts.git"
9
+ },
10
+ "license": "MIT",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./core": {
20
+ "types": "./dist/core/index.d.ts",
21
+ "default": "./dist/core/index.js"
22
+ },
23
+ "./*": {
24
+ "types": "./dist/*/index.d.ts",
25
+ "default": "./dist/*/index.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "zod": "^4.4.3"
30
+ },
31
+ "devDependencies": {
32
+ "@eslint/js": "^10.0.1",
33
+ "@semantic-release/changelog": "^6.0.3",
34
+ "@semantic-release/commit-analyzer": "^13.0.1",
35
+ "@semantic-release/git": "^10.0.1",
36
+ "@semantic-release/npm": "^13.1.5",
37
+ "@semantic-release/release-notes-generator": "^14.1.0",
38
+ "eslint": "^10.4.1",
39
+ "eslint-plugin-simple-import-sort": "^13.0.0",
40
+ "husky": "^9.1.7",
41
+ "knip": "^6.23.0",
42
+ "semantic-release": "^25.0.3",
43
+ "typescript": "~6.0.2",
44
+ "typescript-eslint": "^8.60.1",
45
+ "vitest": "^4.1.7"
46
+ },
47
+ "scripts": {
48
+ "build": "pnpm clean && tsc && node scripts/fix-esm-imports.mjs",
49
+ "clean": "rm -rf dist",
50
+ "knip": "knip",
51
+ "knip:production": "knip --production",
52
+ "lint": "eslint .",
53
+ "lint:fix": "eslint . --fix",
54
+ "release": "HUSKY=0 semantic-release",
55
+ "release:dry-run": "HUSKY=0 semantic-release --dry-run",
56
+ "test": "vitest run",
57
+ "typecheck": "tsc --noEmit"
58
+ }
59
+ }