@abella-bilhalba-engenharia/api-client 0.0.35 → 0.0.37

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.
package/dist/index.js CHANGED
@@ -36,28 +36,90 @@ var commonResponses = {
36
36
  500: commonResponsesBodySchema.internalServerError
37
37
  };
38
38
 
39
- // src/contracts/auth.contract.ts
39
+ // src/contracts/integrations/index.ts
40
40
  import { initContract } from "@ts-rest/core";
41
41
  import z2 from "zod";
42
42
  var c = initContract();
43
- var authContract = c.router({
43
+ var integrationsContract = {
44
+ growatt: c.router({
45
+ listPlants: {
46
+ method: "GET",
47
+ path: "/integrations/growatt/list-plants",
48
+ headers: z2.object({
49
+ authorization: authorizationHeader
50
+ }),
51
+ query: z2.object({
52
+ page: z2.number().positive().optional(),
53
+ perPage: z2.number().positive().optional()
54
+ }),
55
+ responses: {
56
+ 200: z2.object({
57
+ data: z2.array(
58
+ z2.object({
59
+ name: z2.string(),
60
+ id: z2.int()
61
+ })
62
+ )
63
+ })
64
+ },
65
+ summary: "List all growatt plants"
66
+ },
67
+ store: {
68
+ method: "POST",
69
+ path: "/integrations/growatt",
70
+ headers: z2.object({
71
+ authorization: authorizationHeader
72
+ }),
73
+ body: z2.object({
74
+ installationId: z2.uuidv4(),
75
+ growattPlantId: z2.int()
76
+ }),
77
+ responses: {
78
+ 201: z2.object({
79
+ data: z2.object({
80
+ growattPlant: z2.object({
81
+ name: z2.string(),
82
+ id: z2.int()
83
+ }),
84
+ installation: z2.object({
85
+ name: z2.string(),
86
+ id: z2.uuidv4(),
87
+ installationCode: z2.int().min(1).max(9999999999)
88
+ }),
89
+ client: z2.object({
90
+ name: z2.string(),
91
+ id: z2.uuidv4()
92
+ })
93
+ })
94
+ })
95
+ },
96
+ summary: "Create a new growatt integration"
97
+ }
98
+ })
99
+ };
100
+
101
+ // src/contracts/auth.contract.ts
102
+ import { initContract as initContract2 } from "@ts-rest/core";
103
+ import z3 from "zod";
104
+ var c2 = initContract2();
105
+ var authContract = c2.router({
44
106
  login: {
45
107
  method: "POST",
46
108
  path: "/auth/login",
47
- body: z2.object({
48
- email: z2.email(),
49
- password: z2.string().min(8).max(128)
109
+ body: z3.object({
110
+ email: z3.email(),
111
+ password: z3.string().min(8).max(128)
50
112
  }),
51
113
  responses: {
52
- 200: z2.object({
53
- data: z2.object({
54
- token: z2.jwt()
114
+ 200: z3.object({
115
+ data: z3.object({
116
+ token: z3.jwt()
55
117
  })
56
118
  }),
57
- 401: z2.object({
119
+ 401: z3.object({
58
120
  error: {
59
- type: z2.literal("INVALID_CREDENTIALS"),
60
- message: z2.string().default("").optional()
121
+ type: z3.literal("INVALID_CREDENTIALS"),
122
+ message: z3.string().default("").optional()
61
123
  }
62
124
  })
63
125
  },
@@ -66,27 +128,27 @@ var authContract = c.router({
66
128
  });
67
129
 
68
130
  // src/contracts/admin.contract.ts
69
- import { initContract as initContract2 } from "@ts-rest/core";
70
- import z3 from "zod";
71
- var c2 = initContract2();
131
+ import { initContract as initContract3 } from "@ts-rest/core";
132
+ import z4 from "zod";
133
+ var c3 = initContract3();
72
134
  var adminContract = {
73
- clients: c2.router({
135
+ clients: c3.router({
74
136
  list: {
75
137
  method: "GET",
76
138
  path: "/clients",
77
- headers: z3.object({
139
+ headers: z4.object({
78
140
  authorization: authorizationHeader
79
141
  }),
80
- query: z3.object({
81
- page: z3.number().positive().optional(),
82
- perPage: z3.number().positive().optional()
142
+ query: z4.object({
143
+ page: z4.number().positive().optional(),
144
+ perPage: z4.number().positive().optional()
83
145
  }),
84
146
  responses: {
85
- 200: z3.object({
86
- data: z3.array(
87
- z3.object({
88
- name: z3.string(),
89
- id: z3.uuidv4()
147
+ 200: z4.object({
148
+ data: z4.array(
149
+ z4.object({
150
+ name: z4.string(),
151
+ id: z4.uuidv4()
90
152
  })
91
153
  )
92
154
  })
@@ -96,47 +158,47 @@ var adminContract = {
96
158
  store: {
97
159
  method: "POST",
98
160
  path: "/clients",
99
- headers: z3.object({
161
+ headers: z4.object({
100
162
  authorization: authorizationHeader
101
163
  }),
102
- body: z3.object({
103
- name: z3.string()
164
+ body: z4.object({
165
+ name: z4.string()
104
166
  // email: z.email(),
105
167
  // password: z.string().min(8).max(128),
106
168
  }),
107
169
  responses: {
108
- 201: z3.object({
109
- data: z3.object({
110
- name: z3.string(),
170
+ 201: z4.object({
171
+ data: z4.object({
172
+ name: z4.string(),
111
173
  // email: z.email(),
112
- id: z3.uuidv4()
174
+ id: z4.uuidv4()
113
175
  })
114
176
  })
115
177
  },
116
178
  summary: "Create a new client"
117
179
  }
118
180
  }),
119
- plants: c2.router({
181
+ plants: c3.router({
120
182
  list: {
121
183
  method: "GET",
122
184
  path: "/plants",
123
- headers: z3.object({
185
+ headers: z4.object({
124
186
  authorization: authorizationHeader
125
187
  }),
126
- query: z3.object({
127
- page: z3.number().positive().optional(),
128
- perPage: z3.number().positive().optional()
188
+ query: z4.object({
189
+ page: z4.number().positive().optional(),
190
+ perPage: z4.number().positive().optional()
129
191
  }),
130
192
  responses: {
131
- 200: z3.object({
132
- data: z3.array(
133
- z3.object({
134
- name: z3.string(),
135
- id: z3.uuidv4(),
136
- installationCode: z3.int().min(1).max(9999999999),
137
- client: z3.object({
138
- name: z3.string(),
139
- id: z3.uuidv4()
193
+ 200: z4.object({
194
+ data: z4.array(
195
+ z4.object({
196
+ name: z4.string(),
197
+ id: z4.uuidv4(),
198
+ installationCode: z4.int().min(1).max(9999999999),
199
+ client: z4.object({
200
+ name: z4.string(),
201
+ id: z4.uuidv4()
140
202
  })
141
203
  })
142
204
  )
@@ -147,23 +209,23 @@ var adminContract = {
147
209
  store: {
148
210
  method: "POST",
149
211
  path: "/plants",
150
- headers: z3.object({
212
+ headers: z4.object({
151
213
  authorization: authorizationHeader
152
214
  }),
153
- body: z3.object({
154
- name: z3.string(),
155
- clientId: z3.uuidv4(),
156
- installationCode: z3.int().min(1).max(9999999999)
215
+ body: z4.object({
216
+ name: z4.string(),
217
+ clientId: z4.uuidv4(),
218
+ installationCode: z4.int().min(1).max(9999999999)
157
219
  }),
158
220
  responses: {
159
- 201: z3.object({
160
- data: z3.object({
161
- name: z3.string(),
162
- id: z3.uuidv4(),
163
- installationCode: z3.int().min(1).max(9999999999),
164
- client: z3.object({
165
- name: z3.string(),
166
- id: z3.uuidv4()
221
+ 201: z4.object({
222
+ data: z4.object({
223
+ name: z4.string(),
224
+ id: z4.uuidv4(),
225
+ installationCode: z4.int().min(1).max(9999999999),
226
+ client: z4.object({
227
+ name: z4.string(),
228
+ id: z4.uuidv4()
167
229
  })
168
230
  })
169
231
  })
@@ -173,49 +235,49 @@ var adminContract = {
173
235
  listInvoices: {
174
236
  method: "GET",
175
237
  path: "/plants/:id/invoices",
176
- headers: z3.object({
238
+ headers: z4.object({
177
239
  authorization: authorizationHeader
178
240
  }),
179
- pathParams: z3.object({
180
- id: z3.uuidv4()
241
+ pathParams: z4.object({
242
+ id: z4.uuidv4()
181
243
  }),
182
- query: z3.object({
183
- page: z3.number().positive().optional(),
184
- perPage: z3.number().positive().optional()
244
+ query: z4.object({
245
+ page: z4.number().positive().optional(),
246
+ perPage: z4.number().positive().optional()
185
247
  }),
186
248
  responses: {
187
- 200: z3.object({
188
- data: z3.object({
189
- installation: z3.object({
190
- name: z3.string(),
191
- id: z3.uuidv4(),
192
- installationCode: z3.int().min(1).max(9999999999)
249
+ 200: z4.object({
250
+ data: z4.object({
251
+ installation: z4.object({
252
+ name: z4.string(),
253
+ id: z4.uuidv4(),
254
+ installationCode: z4.int().min(1).max(9999999999)
193
255
  }),
194
- client: z3.object({
195
- name: z3.string(),
196
- id: z3.uuidv4()
256
+ client: z4.object({
257
+ name: z4.string(),
258
+ id: z4.uuidv4()
197
259
  }),
198
- invoices: z3.array(
199
- z3.object({
200
- id: z3.uuidv4(),
201
- date: z3.iso.date(),
202
- readingDates: z3.object({
203
- previous: z3.iso.date(),
204
- actual: z3.iso.date(),
205
- next: z3.iso.date()
260
+ invoices: z4.array(
261
+ z4.object({
262
+ id: z4.uuidv4(),
263
+ date: z4.iso.date(),
264
+ readingDates: z4.object({
265
+ previous: z4.iso.date(),
266
+ actual: z4.iso.date(),
267
+ next: z4.iso.date()
206
268
  }),
207
- tariff: z3.object({
208
- tusd: z3.number().nonnegative(),
209
- te: z3.number().nonnegative(),
210
- increases: z3.number().nonnegative(),
211
- decreases: z3.number().nonnegative(),
212
- utilityTotal: z3.number().nonnegative()
269
+ tariff: z4.object({
270
+ tusd: z4.number().nonnegative(),
271
+ te: z4.number().nonnegative(),
272
+ increases: z4.number().nonnegative(),
273
+ decreases: z4.number().nonnegative(),
274
+ utilityTotal: z4.number().nonnegative()
213
275
  }),
214
- energy: z3.object({
215
- minimumCharge: z3.number().nonnegative(),
216
- balance: z3.number().nonnegative(),
217
- active: z3.number().nonnegative(),
218
- injected: z3.number().nonnegative()
276
+ energy: z4.object({
277
+ minimumCharge: z4.number().nonnegative(),
278
+ balance: z4.number().nonnegative(),
279
+ active: z4.number().nonnegative(),
280
+ injected: z4.number().nonnegative()
219
281
  })
220
282
  })
221
283
  )
@@ -225,34 +287,34 @@ var adminContract = {
225
287
  summary: "List all invoices for a installation"
226
288
  }
227
289
  }),
228
- units: c2.router({
290
+ units: c3.router({
229
291
  list: {
230
292
  method: "GET",
231
293
  path: "/units",
232
- headers: z3.object({
294
+ headers: z4.object({
233
295
  authorization: authorizationHeader
234
296
  }),
235
- query: z3.object({
236
- page: z3.number().positive().optional(),
237
- perPage: z3.number().positive().optional()
297
+ query: z4.object({
298
+ page: z4.number().positive().optional(),
299
+ perPage: z4.number().positive().optional()
238
300
  }),
239
301
  responses: {
240
- 200: z3.object({
241
- data: z3.array(
242
- z3.object({
243
- id: z3.uuidv4(),
244
- commissioningDate: z3.iso.date(),
245
- installation: z3.object({
246
- name: z3.string(),
247
- id: z3.uuidv4(),
248
- installationCode: z3.int().min(1).max(9999999999)
302
+ 200: z4.object({
303
+ data: z4.array(
304
+ z4.object({
305
+ id: z4.uuidv4(),
306
+ commissioningDate: z4.iso.date(),
307
+ installation: z4.object({
308
+ name: z4.string(),
309
+ id: z4.uuidv4(),
310
+ installationCode: z4.int().min(1).max(9999999999)
249
311
  }),
250
- client: z3.object({
251
- name: z3.string(),
252
- id: z3.uuidv4()
312
+ client: z4.object({
313
+ name: z4.string(),
314
+ id: z4.uuidv4()
253
315
  }),
254
- equipments: z3.object({
255
- inverter: z3.string()
316
+ equipments: z4.object({
317
+ inverter: z4.string()
256
318
  })
257
319
  })
258
320
  )
@@ -263,42 +325,42 @@ var adminContract = {
263
325
  store: {
264
326
  method: "POST",
265
327
  path: "/units",
266
- headers: z3.object({
328
+ headers: z4.object({
267
329
  authorization: authorizationHeader
268
330
  }),
269
- body: z3.object({
270
- installationId: z3.uuidv4(),
271
- commissioningDate: z3.iso.date(),
272
- equipments: z3.object({
273
- inverter: z3.string(),
274
- panels: z3.array(
275
- z3.object({
276
- model: z3.string(),
277
- quantity: z3.int().positive()
331
+ body: z4.object({
332
+ installationId: z4.uuidv4(),
333
+ commissioningDate: z4.iso.date(),
334
+ equipments: z4.object({
335
+ inverter: z4.string(),
336
+ panels: z4.array(
337
+ z4.object({
338
+ model: z4.string(),
339
+ quantity: z4.int().positive()
278
340
  })
279
341
  )
280
342
  })
281
343
  }),
282
344
  responses: {
283
- 201: z3.object({
284
- data: z3.object({
285
- id: z3.uuidv4(),
286
- commissioningDate: z3.iso.date(),
287
- installation: z3.object({
288
- name: z3.string(),
289
- id: z3.uuidv4(),
290
- installationCode: z3.int().min(1).max(9999999999)
345
+ 201: z4.object({
346
+ data: z4.object({
347
+ id: z4.uuidv4(),
348
+ commissioningDate: z4.iso.date(),
349
+ installation: z4.object({
350
+ name: z4.string(),
351
+ id: z4.uuidv4(),
352
+ installationCode: z4.int().min(1).max(9999999999)
291
353
  }),
292
- client: z3.object({
293
- name: z3.string(),
294
- id: z3.uuidv4()
354
+ client: z4.object({
355
+ name: z4.string(),
356
+ id: z4.uuidv4()
295
357
  }),
296
- equipments: z3.object({
297
- inverter: z3.string(),
298
- panels: z3.array(
299
- z3.object({
300
- model: z3.string(),
301
- quantity: z3.int().positive()
358
+ equipments: z4.object({
359
+ inverter: z4.string(),
360
+ panels: z4.array(
361
+ z4.object({
362
+ model: z4.string(),
363
+ quantity: z4.int().positive()
302
364
  })
303
365
  )
304
366
  })
@@ -308,67 +370,70 @@ var adminContract = {
308
370
  summary: "Create a new unit"
309
371
  }
310
372
  }),
311
- invoices: c2.router({
373
+ invoices: c3.router({
312
374
  store: {
313
375
  method: "POST",
314
376
  path: "/invoices",
315
- headers: z3.object({
377
+ headers: z4.object({
316
378
  authorization: authorizationHeader
317
379
  }),
318
- body: z3.object({
319
- installationId: z3.uuidv4(),
320
- date: z3.iso.date(),
321
- readingDates: z3.object({
322
- previous: z3.iso.date(),
323
- actual: z3.iso.date(),
324
- next: z3.iso.date()
380
+ body: z4.object({
381
+ installationId: z4.uuidv4(),
382
+ date: z4.object({
383
+ month: z4.coerce.number().int().min(1).max(12),
384
+ year: z4.coerce.number().int().min(1).max(2050)
325
385
  }),
326
- tariff: z3.object({
327
- tusd: z3.number().nonnegative(),
328
- te: z3.number().nonnegative(),
329
- increases: z3.number().nonnegative(),
330
- decreases: z3.number().nonnegative(),
331
- utilityTotal: z3.number().nonnegative()
386
+ readingDates: z4.object({
387
+ previous: z4.iso.date(),
388
+ actual: z4.iso.date(),
389
+ next: z4.iso.date()
332
390
  }),
333
- energy: z3.object({
334
- minimumCharge: z3.number().nonnegative(),
335
- balance: z3.number().nonnegative(),
336
- active: z3.number().nonnegative(),
337
- injected: z3.number().nonnegative()
391
+ tariff: z4.object({
392
+ tusd: z4.number().nonnegative(),
393
+ te: z4.number().nonnegative(),
394
+ increases: z4.number().nonnegative(),
395
+ decreases: z4.number().nonnegative(),
396
+ utilityTotal: z4.number().nonnegative()
397
+ }),
398
+ energy: z4.object({
399
+ minimumCharge: z4.number().nonnegative(),
400
+ balance: z4.number().nonnegative(),
401
+ active: z4.number().nonnegative(),
402
+ injected: z4.number().nonnegative()
338
403
  })
339
404
  }),
340
405
  responses: {
341
- 201: z3.object({
342
- data: z3.array(
343
- z3.object({
344
- id: z3.uuidv4(),
345
- date: z3.iso.date(),
346
- installation: z3.object({
347
- name: z3.string(),
348
- id: z3.uuidv4(),
349
- installationCode: z3.int().min(1).max(9999999999)
406
+ 201: z4.object({
407
+ data: z4.array(
408
+ z4.object({
409
+ id: z4.uuidv4(),
410
+ date: z4.iso.date(),
411
+ installation: z4.object({
412
+ name: z4.string(),
413
+ id: z4.uuidv4(),
414
+ installationCode: z4.int().min(1).max(9999999999)
350
415
  }),
351
- readingDates: z3.object({
352
- previous: z3.iso.date(),
353
- actual: z3.iso.date(),
354
- next: z3.iso.date()
416
+ readingDates: z4.object({
417
+ previous: z4.iso.date(),
418
+ actual: z4.iso.date(),
419
+ next: z4.iso.date()
355
420
  }),
356
- tariff: z3.object({
357
- tusd: z3.number().nonnegative(),
358
- te: z3.number().nonnegative(),
359
- increases: z3.number().nonnegative(),
360
- decreases: z3.number().nonnegative(),
361
- utilityTotal: z3.number().nonnegative()
421
+ tariff: z4.object({
422
+ tusd: z4.number().nonnegative(),
423
+ te: z4.number().nonnegative(),
424
+ increases: z4.number().nonnegative(),
425
+ decreases: z4.number().nonnegative(),
426
+ utilityTotal: z4.number().nonnegative()
362
427
  }),
363
- energy: z3.object({
364
- minimumCharge: z3.number().nonnegative(),
365
- balance: z3.number().nonnegative(),
366
- active: z3.number().nonnegative(),
367
- injected: z3.number().nonnegative()
428
+ energy: z4.object({
429
+ minimumCharge: z4.number().nonnegative(),
430
+ balance: z4.number().nonnegative(),
431
+ active: z4.number().nonnegative(),
432
+ injected: z4.number().nonnegative()
368
433
  }),
369
- client: z3.object({
370
- name: z3.string(),
371
- id: z3.uuidv4()
434
+ client: z4.object({
435
+ name: z4.string(),
436
+ id: z4.uuidv4()
372
437
  })
373
438
  })
374
439
  )
@@ -376,13 +441,14 @@ var adminContract = {
376
441
  },
377
442
  summary: "Create a new invoice"
378
443
  }
379
- })
444
+ }),
445
+ integrations: integrationsContract
380
446
  };
381
447
 
382
448
  // src/contract.ts
383
- import { initContract as initContract3 } from "@ts-rest/core";
384
- var c3 = initContract3();
385
- var contract = c3.router(
449
+ import { initContract as initContract4 } from "@ts-rest/core";
450
+ var c4 = initContract4();
451
+ var contract = c4.router(
386
452
  { auth: authContract, admin: adminContract },
387
453
  {
388
454
  strictStatusCodes: true,
@@ -395,5 +461,6 @@ export {
395
461
  authorizationHeader,
396
462
  commonResponses,
397
463
  commonResponsesBodySchema,
398
- contract
464
+ contract,
465
+ integrationsContract
399
466
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@abella-bilhalba-engenharia/api-client",
3
3
  "description": "Type-safe Client for Abella Bilhalba Engenharia API.",
4
4
  "author": "TheDevick",
5
- "version": "0.0.35",
5
+ "version": "0.0.37",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "types": "./dist/index.d.ts",