@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,76 @@
1
+ export interface ChecklistItemAttributes {
2
+ name: string | null;
3
+ field_format: string | null;
4
+ required: boolean | null;
5
+ active: boolean | null;
6
+ created_at: string | null;
7
+ }
8
+ export interface ChecklistItem {
9
+ id: string;
10
+ attributes: ChecklistItemAttributes;
11
+ relationships: {
12
+ enterprise: {
13
+ attributes: {
14
+ name: string;
15
+ cnpj: string | null;
16
+ };
17
+ } | null;
18
+ address: {
19
+ attributes: {
20
+ formatted_address: string | null;
21
+ };
22
+ } | null;
23
+ tags: Array<{
24
+ id: string;
25
+ attributes: {
26
+ name: string;
27
+ };
28
+ }>;
29
+ templates: Array<{
30
+ id: string;
31
+ attributes: {
32
+ name: string | null;
33
+ category: string | null;
34
+ };
35
+ }>;
36
+ };
37
+ }
38
+ export interface TemplateAttributes {
39
+ name: string | null;
40
+ category: string | null;
41
+ active: boolean | null;
42
+ created_at: string | null;
43
+ }
44
+ export interface ChecklistTemplate {
45
+ id: string;
46
+ attributes: TemplateAttributes;
47
+ relationships: {
48
+ enterprise: {
49
+ attributes: {
50
+ name: string | null;
51
+ cnpj: string | null;
52
+ fantasy_name: string | null;
53
+ };
54
+ } | null;
55
+ items: Array<{
56
+ id: string;
57
+ attributes: {
58
+ name: string | null;
59
+ field_format: string | null;
60
+ };
61
+ }>;
62
+ };
63
+ }
64
+ export interface CreateTemplatePayload {
65
+ attributes: {
66
+ name: string;
67
+ category: string;
68
+ type: string;
69
+ };
70
+ relationships: {
71
+ enterprise: {
72
+ type: string;
73
+ id: string;
74
+ };
75
+ };
76
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { ApiClientLike } from '../core/client';
2
+ import type { QueryParams } from '../core/query-builder';
3
+ import type { Chip, ChipPanelRow } from './types';
4
+ export declare function createChipsApi(client: ApiClientLike): {
5
+ panel: (params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
6
+ data: ChipPanelRow[];
7
+ }>;
8
+ endpoint: string;
9
+ list: <R = Chip>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<import("..").ListResponse<R>>;
10
+ get: <R = Chip>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
11
+ data: R;
12
+ }>;
13
+ create: (payload: unknown) => Promise<undefined>;
14
+ update: (id: string, payload: unknown) => Promise<undefined>;
15
+ remove: (id: string) => Promise<undefined>;
16
+ removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
17
+ };
@@ -0,0 +1,8 @@
1
+ import { createResourceApi } from '../core/client.js';
2
+ import { withQuery } from '../core/query-builder.js';
3
+ export function createChipsApi(client) {
4
+ return {
5
+ ...createResourceApi(client, '/v5/chips'),
6
+ panel: (params = {}, signal) => client.get(withQuery('/v5/chips', params), { signal }).then(r => r.data),
7
+ };
8
+ }
@@ -0,0 +1,13 @@
1
+ import type { ApiClientLike } from '../../core/client';
2
+ import type { Connection } from './types';
3
+ export declare function createConnectionsApi(client: ApiClientLike): {
4
+ endpoint: string;
5
+ list: <R = Connection>(params?: Partial<import("../..").QueryParams>, signal?: AbortSignal) => Promise<import("../..").ListResponse<R>>;
6
+ get: <R = Connection>(id: string, params?: Partial<import("../..").QueryParams>, signal?: AbortSignal) => Promise<{
7
+ data: R;
8
+ }>;
9
+ create: (payload: unknown) => Promise<undefined>;
10
+ update: (id: string, payload: unknown) => Promise<undefined>;
11
+ remove: (id: string) => Promise<undefined>;
12
+ removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
13
+ };
@@ -0,0 +1,4 @@
1
+ import { createResourceApi } from '../../core/client.js';
2
+ export function createConnectionsApi(client) {
3
+ return createResourceApi(client, '/v5/chips/commands-history');
4
+ }
@@ -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,31 @@
1
+ import { z } from 'zod';
2
+ export declare const ConnectionSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ attributes: z.ZodObject<{
5
+ connection_time: z.ZodNullable<z.ZodString>;
6
+ disconnection_time: z.ZodNullable<z.ZodString>;
7
+ type: z.ZodNullable<z.ZodString>;
8
+ status: z.ZodNullable<z.ZodString>;
9
+ message: z.ZodNullable<z.ZodString>;
10
+ created_at: z.ZodNullable<z.ZodString>;
11
+ }, z.core.$strip>;
12
+ relationships: z.ZodObject<{
13
+ chip: z.ZodNullable<z.ZodObject<{
14
+ attributes: z.ZodObject<{
15
+ serial: z.ZodNullable<z.ZodString>;
16
+ number: z.ZodNullable<z.ZodString>;
17
+ imsi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ service_provider: z.ZodNullable<z.ZodString>;
19
+ carrier: z.ZodNullable<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ }, z.core.$strip>>;
22
+ user: z.ZodNullable<z.ZodObject<{
23
+ attributes: z.ZodObject<{
24
+ name: z.ZodString;
25
+ username: z.ZodNullable<z.ZodString>;
26
+ email: z.ZodNullable<z.ZodString>;
27
+ phone1: z.ZodNullable<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$strip>;
31
+ }, z.core.$strip>;
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ export const ConnectionSchema = z.object({
3
+ id: z.string(),
4
+ attributes: z.object({
5
+ connection_time: z.string().nullable(),
6
+ disconnection_time: z.string().nullable(),
7
+ type: z.string().nullable(),
8
+ status: z.string().nullable(),
9
+ message: z.string().nullable(),
10
+ created_at: z.string().nullable(),
11
+ }),
12
+ relationships: z.object({
13
+ chip: z.object({
14
+ attributes: z.object({
15
+ serial: z.string().nullable(),
16
+ number: z.string().nullable(),
17
+ imsi: z.string().nullable().optional(),
18
+ service_provider: z.string().nullable(),
19
+ carrier: z.string().nullable(),
20
+ }),
21
+ }).nullable(),
22
+ user: z.object({
23
+ attributes: z.object({
24
+ name: z.string(),
25
+ username: z.string().nullable(),
26
+ email: z.string().nullable(),
27
+ phone1: z.string().nullable(),
28
+ }),
29
+ }).nullable(),
30
+ }),
31
+ });
@@ -0,0 +1,26 @@
1
+ import type { ChipRelAttr } from '../../core/types';
2
+ export interface ConnectionAttributes {
3
+ connection_time: string | null;
4
+ disconnection_time: string | null;
5
+ type: string | null;
6
+ status: string | null;
7
+ message: string | null;
8
+ created_at: string | null;
9
+ }
10
+ export interface Connection {
11
+ id: string;
12
+ attributes: ConnectionAttributes;
13
+ relationships: {
14
+ chip: {
15
+ attributes: ChipRelAttr;
16
+ } | null;
17
+ user: {
18
+ attributes: {
19
+ name: string;
20
+ username: string | null;
21
+ email: string | null;
22
+ phone1: string | null;
23
+ };
24
+ } | null;
25
+ };
26
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './api';
2
+ export * from './connections';
3
+ export * from './requirements';
4
+ export * from './schemas';
5
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ export * from './api.js';
2
+ export * from './connections/index.js';
3
+ export * from './requirements/index.js';
4
+ export * from './schemas.js';
5
+ export * from './types.js';
@@ -0,0 +1,13 @@
1
+ import type { ApiClientLike } from '../../core/client';
2
+ import type { Requirement } from './types';
3
+ export declare function createRequirementsApi(client: ApiClientLike): {
4
+ endpoint: string;
5
+ list: <R = Requirement>(params?: Partial<import("../..").QueryParams>, signal?: AbortSignal) => Promise<import("../..").ListResponse<R>>;
6
+ get: <R = Requirement>(id: string, params?: Partial<import("../..").QueryParams>, signal?: AbortSignal) => Promise<{
7
+ data: R;
8
+ }>;
9
+ create: (payload: unknown) => Promise<undefined>;
10
+ update: (id: string, payload: unknown) => Promise<undefined>;
11
+ remove: (id: string) => Promise<undefined>;
12
+ removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
13
+ };
@@ -0,0 +1,4 @@
1
+ import { createResourceApi } from '../../core/client.js';
2
+ export function createRequirementsApi(client) {
3
+ return createResourceApi(client, '/v5/chips/requirements');
4
+ }
@@ -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,21 @@
1
+ import { z } from 'zod';
2
+ export declare const RequirementSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ attributes: z.ZodObject<{
5
+ status: z.ZodNullable<z.ZodString>;
6
+ quantity: z.ZodNullable<z.ZodNumber>;
7
+ created_at: z.ZodNullable<z.ZodString>;
8
+ updated_at: z.ZodNullable<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ relationships: z.ZodObject<{
11
+ chip: z.ZodNullable<z.ZodObject<{
12
+ attributes: z.ZodObject<{
13
+ serial: z.ZodNullable<z.ZodString>;
14
+ number: z.ZodNullable<z.ZodString>;
15
+ imsi: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ service_provider: z.ZodNullable<z.ZodString>;
17
+ carrier: z.ZodNullable<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ }, z.core.$strip>>;
20
+ }, z.core.$strip>;
21
+ }, z.core.$strip>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export const RequirementSchema = z.object({
3
+ id: z.string(),
4
+ attributes: z.object({
5
+ status: z.string().nullable(),
6
+ quantity: z.number().nullable(),
7
+ created_at: z.string().nullable(),
8
+ updated_at: z.string().nullable(),
9
+ }),
10
+ relationships: z.object({
11
+ chip: z.object({
12
+ attributes: z.object({
13
+ serial: z.string().nullable(),
14
+ number: z.string().nullable(),
15
+ imsi: z.string().nullable().optional(),
16
+ service_provider: z.string().nullable(),
17
+ carrier: z.string().nullable(),
18
+ }),
19
+ }).nullable(),
20
+ }),
21
+ });
@@ -0,0 +1,16 @@
1
+ import type { ChipRelAttr } from '../../core/types';
2
+ export interface RequirementAttributes {
3
+ status: string | null;
4
+ quantity: number | null;
5
+ created_at: string | null;
6
+ updated_at: string | null;
7
+ }
8
+ export interface Requirement {
9
+ id: string;
10
+ attributes: RequirementAttributes;
11
+ relationships: {
12
+ chip: {
13
+ attributes: ChipRelAttr;
14
+ } | null;
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
1
+ import { z } from 'zod';
2
+ export declare const ChipSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ attributes: z.ZodObject<{
5
+ serial: z.ZodNullable<z.ZodString>;
6
+ number: z.ZodNullable<z.ZodString>;
7
+ carrier: z.ZodNullable<z.ZodString>;
8
+ service_provider: z.ZodNullable<z.ZodString>;
9
+ from_softruck: z.ZodNullable<z.ZodBoolean>;
10
+ batch: z.ZodNullable<z.ZodString>;
11
+ apn: z.ZodNullable<z.ZodString>;
12
+ apn_user: z.ZodNullable<z.ZodString>;
13
+ apn_username: z.ZodNullable<z.ZodString>;
14
+ apn_password: z.ZodNullable<z.ZodString>;
15
+ apn_pin: z.ZodNullable<z.ZodString>;
16
+ apn_puk: z.ZodNullable<z.ZodString>;
17
+ status: z.ZodNullable<z.ZodString>;
18
+ last_integration_source: z.ZodNullable<z.ZodString>;
19
+ last_integration_time: z.ZodNullable<z.ZodString>;
20
+ created_at: z.ZodNullable<z.ZodString>;
21
+ updated_at: z.ZodNullable<z.ZodString>;
22
+ deactivated_at: z.ZodNullable<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ relationships: z.ZodObject<{
25
+ enterprise: z.ZodNullable<z.ZodObject<{
26
+ attributes: z.ZodObject<{
27
+ name: z.ZodNullable<z.ZodString>;
28
+ cnpj: z.ZodNullable<z.ZodString>;
29
+ email: z.ZodNullable<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ }, z.core.$strip>>;
32
+ device: z.ZodNullable<z.ZodObject<{
33
+ id: z.ZodString;
34
+ attributes: z.ZodObject<{
35
+ name: z.ZodNullable<z.ZodString>;
36
+ imei: z.ZodNullable<z.ZodString>;
37
+ code: z.ZodNullable<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ }, z.core.$strip>>;
40
+ events: z.ZodNullable<z.ZodObject<{
41
+ attributes: z.ZodObject<{
42
+ consumption_montly_data: z.ZodNullable<z.ZodNumber>;
43
+ lat: z.ZodNullable<z.ZodString>;
44
+ lng: z.ZodNullable<z.ZodString>;
45
+ location_updated_at: z.ZodNullable<z.ZodString>;
46
+ }, z.core.$strip>;
47
+ }, z.core.$strip>>;
48
+ tags: z.ZodArray<z.ZodObject<{
49
+ id: z.ZodString;
50
+ attributes: z.ZodObject<{
51
+ name: z.ZodString;
52
+ color: z.ZodNullable<z.ZodString>;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>;
56
+ }, z.core.$strip>;
57
+ export declare const CreateChipPayloadSchema: z.ZodObject<{
58
+ attributes: z.ZodObject<{
59
+ serial: z.ZodString;
60
+ batch: z.ZodOptional<z.ZodString>;
61
+ number: z.ZodOptional<z.ZodString>;
62
+ carrier: z.ZodOptional<z.ZodString>;
63
+ service_provider: z.ZodOptional<z.ZodString>;
64
+ apn: z.ZodOptional<z.ZodString>;
65
+ apn_username: z.ZodOptional<z.ZodString>;
66
+ apn_password: z.ZodOptional<z.ZodString>;
67
+ pin: z.ZodOptional<z.ZodString>;
68
+ puk: z.ZodOptional<z.ZodString>;
69
+ plan_size: z.ZodOptional<z.ZodString>;
70
+ status: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>;
72
+ relationships: z.ZodObject<{
73
+ enterprise: z.ZodObject<{
74
+ type: z.ZodLiteral<"enterprise">;
75
+ id: z.ZodString;
76
+ }, z.core.$strip>;
77
+ }, z.core.$strip>;
78
+ }, z.core.$strip>;
@@ -0,0 +1,72 @@
1
+ import { z } from 'zod';
2
+ export const ChipSchema = z.object({
3
+ id: z.string(),
4
+ attributes: z.object({
5
+ serial: z.string().nullable(),
6
+ number: z.string().nullable(),
7
+ carrier: z.string().nullable(),
8
+ service_provider: z.string().nullable(),
9
+ from_softruck: z.boolean().nullable(),
10
+ batch: z.string().nullable(),
11
+ apn: z.string().nullable(),
12
+ apn_user: z.string().nullable(),
13
+ apn_username: z.string().nullable(),
14
+ apn_password: z.string().nullable(),
15
+ apn_pin: z.string().nullable(),
16
+ apn_puk: z.string().nullable(),
17
+ status: z.string().nullable(),
18
+ last_integration_source: z.string().nullable(),
19
+ last_integration_time: z.string().nullable(),
20
+ created_at: z.string().nullable(),
21
+ updated_at: z.string().nullable(),
22
+ deactivated_at: z.string().nullable(),
23
+ }),
24
+ relationships: z.object({
25
+ enterprise: z.object({
26
+ attributes: z.object({
27
+ name: z.string().nullable(),
28
+ cnpj: z.string().nullable(),
29
+ email: z.string().nullable(),
30
+ }),
31
+ }).nullable(),
32
+ device: z.object({
33
+ id: z.string(),
34
+ attributes: z.object({
35
+ name: z.string().nullable(),
36
+ imei: z.string().nullable(),
37
+ code: z.string().nullable(),
38
+ }),
39
+ }).nullable(),
40
+ events: z.object({
41
+ attributes: z.object({
42
+ consumption_montly_data: z.number().nullable(),
43
+ lat: z.string().nullable(),
44
+ lng: z.string().nullable(),
45
+ location_updated_at: z.string().nullable(),
46
+ }),
47
+ }).nullable(),
48
+ tags: z.array(z.object({
49
+ id: z.string(),
50
+ attributes: z.object({ name: z.string(), color: z.string().nullable() }),
51
+ })),
52
+ }),
53
+ });
54
+ export const CreateChipPayloadSchema = z.object({
55
+ attributes: z.object({
56
+ serial: z.string().min(1),
57
+ batch: z.string().optional(),
58
+ number: z.string().optional(),
59
+ carrier: z.string().optional(),
60
+ service_provider: z.string().optional(),
61
+ apn: z.string().optional(),
62
+ apn_username: z.string().optional(),
63
+ apn_password: z.string().optional(),
64
+ pin: z.string().optional(),
65
+ puk: z.string().optional(),
66
+ plan_size: z.string().optional(),
67
+ status: z.string().optional(),
68
+ }),
69
+ relationships: z.object({
70
+ enterprise: z.object({ type: z.literal('enterprise'), id: z.string() }),
71
+ }),
72
+ });
@@ -0,0 +1,76 @@
1
+ import type { Deactivatable, DeviceRelAttr, EnterpriseRelAttr, Tag } from '../core/types';
2
+ export interface ChipAttributes extends Deactivatable {
3
+ serial: string | null;
4
+ number: string | null;
5
+ carrier: string | null;
6
+ service_provider: string | null;
7
+ from_softruck: boolean | null;
8
+ batch: string | null;
9
+ apn: string | null;
10
+ apn_user: string | null;
11
+ apn_username: string | null;
12
+ apn_password: string | null;
13
+ apn_pin: string | null;
14
+ apn_puk: string | null;
15
+ status: string | null;
16
+ last_integration_source: string | null;
17
+ last_integration_time: string | null;
18
+ }
19
+ export interface ChipEventsAttr {
20
+ consumption_montly_data: number | null;
21
+ lat: string | null;
22
+ lng: string | null;
23
+ location_updated_at: string | null;
24
+ }
25
+ export interface Chip {
26
+ id: string;
27
+ attributes: ChipAttributes;
28
+ relationships: {
29
+ enterprise: {
30
+ id: string;
31
+ attributes: EnterpriseRelAttr;
32
+ } | null;
33
+ device: {
34
+ id: string;
35
+ attributes: DeviceRelAttr;
36
+ } | null;
37
+ events: {
38
+ attributes: ChipEventsAttr;
39
+ } | null;
40
+ tags: Tag[];
41
+ };
42
+ }
43
+ export interface CreateChipPayload {
44
+ attributes: {
45
+ serial: string;
46
+ batch?: string;
47
+ number?: string;
48
+ carrier?: string;
49
+ service_provider?: string;
50
+ apn?: string;
51
+ apn_username?: string;
52
+ apn_password?: string;
53
+ pin?: string;
54
+ puk?: string;
55
+ plan_size?: string;
56
+ status?: string;
57
+ };
58
+ relationships: {
59
+ enterprise: {
60
+ type: 'enterprise';
61
+ id: string;
62
+ };
63
+ };
64
+ }
65
+ export interface ChipPanelRow {
66
+ type: string;
67
+ attributes: {
68
+ created_at: {
69
+ day: string;
70
+ };
71
+ service_provider: string | null;
72
+ carrier: string | null;
73
+ count: string;
74
+ };
75
+ relationships: Record<string, unknown>;
76
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { z } from 'zod';
2
+ import type { QueryParams } from './query-builder';
3
+ import type { ListResponse } from './types';
4
+ export interface ApiClientLike {
5
+ get<T = unknown>(url: string, config?: {
6
+ signal?: AbortSignal;
7
+ }): Promise<{
8
+ data: T;
9
+ }>;
10
+ post<T = unknown>(url: string, data?: unknown, config?: {
11
+ signal?: AbortSignal;
12
+ }): Promise<{
13
+ data: T;
14
+ }>;
15
+ patch<T = unknown>(url: string, data?: unknown, config?: {
16
+ signal?: AbortSignal;
17
+ }): Promise<{
18
+ data: T;
19
+ }>;
20
+ delete<T = unknown>(url: string, config?: {
21
+ data?: unknown;
22
+ signal?: AbortSignal;
23
+ }): Promise<{
24
+ data: T;
25
+ }>;
26
+ }
27
+ export declare function countResource(client: ApiClientLike, endpoint: string, params?: Partial<QueryParams>, signal?: AbortSignal): Promise<number>;
28
+ export interface ResourceSchemas<T> {
29
+ item?: z.ZodType<T>;
30
+ createPayload?: z.ZodType<unknown>;
31
+ updatePayload?: z.ZodType<unknown>;
32
+ bulkDeletePayload?: z.ZodType<unknown>;
33
+ }
34
+ export declare function parseOrLog<T>(schema: z.ZodType<T>, data: unknown, context: string): T;
35
+ export declare function createResourceApi<T>(client: ApiClientLike, endpoint: string, schemas?: ResourceSchemas<T>): {
36
+ endpoint: string;
37
+ list: <R = T>(params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<ListResponse<R>>;
38
+ get: <R = T>(id: string, params?: Partial<QueryParams>, signal?: AbortSignal) => Promise<{
39
+ data: R;
40
+ }>;
41
+ create: (payload: unknown) => Promise<undefined>;
42
+ update: (id: string, payload: unknown) => Promise<undefined>;
43
+ remove: (id: string) => Promise<undefined>;
44
+ removeMany: (payload: unknown, signal?: AbortSignal) => Promise<undefined>;
45
+ };
@@ -0,0 +1,42 @@
1
+ import { withQuery } from './query-builder.js';
2
+ export function countResource(client, endpoint, params = {}, signal) {
3
+ return client
4
+ .get(withQuery(endpoint, { ...params, count: 'only' }), { signal })
5
+ .then(r => r.data.count);
6
+ }
7
+ // Validates `data` against `schema`, logging the Zod issues to the console before
8
+ // throwing so a failure is visible even when the caller has no onError handler.
9
+ export function parseOrLog(schema, data, context) {
10
+ const result = schema.safeParse(data);
11
+ if (!result.success) {
12
+ console.error(`[api-types] Validation failed: ${context}`, result.error.issues);
13
+ throw result.error;
14
+ }
15
+ return result.data;
16
+ }
17
+ // Standard CRUD operations. Each project's hook decides what QueryParams to pass.
18
+ export function createResourceApi(client, endpoint, schemas = {}) {
19
+ return {
20
+ endpoint,
21
+ list: (params = {}, signal) => client.get(withQuery(endpoint, params), { signal }).then((r) => {
22
+ const itemSchema = schemas.item;
23
+ return itemSchema
24
+ ? { ...r.data, data: r.data.data.map(item => parseOrLog(itemSchema, item, `GET ${endpoint} (item)`)) }
25
+ : r.data;
26
+ }),
27
+ get: (id, params = {}, signal) => client.get(withQuery(`${endpoint}/${id}`, params), { signal }).then(r => schemas.item ? { data: parseOrLog(schemas.item, r.data.data, `GET ${endpoint}/${id} (item)`) } : r.data),
28
+ create: (payload) => Promise.resolve(payload)
29
+ .then(p => schemas.createPayload ? parseOrLog(schemas.createPayload, p, `POST ${endpoint} (payload)`) : p)
30
+ .then(data => client.post(endpoint, { data }))
31
+ .then(() => undefined),
32
+ update: (id, payload) => Promise.resolve(payload)
33
+ .then(p => schemas.updatePayload ? parseOrLog(schemas.updatePayload, p, `PATCH ${endpoint}/${id} (payload)`) : p)
34
+ .then(data => client.patch(`${endpoint}/${id}`, { data }))
35
+ .then(() => undefined),
36
+ remove: (id) => client.delete(`${endpoint}/${id}`).then(() => undefined),
37
+ removeMany: (payload, signal) => Promise.resolve(payload)
38
+ .then(p => schemas.bulkDeletePayload ? parseOrLog(schemas.bulkDeletePayload, p, `DELETE ${endpoint} (payload)`) : p)
39
+ .then(data => client.delete(endpoint, { data, signal }))
40
+ .then(() => undefined),
41
+ };
42
+ }
@@ -0,0 +1,4 @@
1
+ export * from './client';
2
+ export * from './query-builder';
3
+ export * from './schemas';
4
+ export * from './types';