@awarevue/api-types 1.0.19 → 1.0.21

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/error.d.ts CHANGED
@@ -1,5 +1,629 @@
1
- export interface ErrorResponse {
2
- code: string;
3
- message: string;
1
+ import { z } from 'zod';
2
+ export declare const sDuplicateMeta: z.ZodObject<{
3
+ subject: z.ZodString;
4
+ field: z.ZodString;
5
+ value: z.ZodOptional<z.ZodString>;
6
+ existingId: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ field: string;
9
+ subject: string;
10
+ value?: string | undefined;
11
+ existingId?: string | undefined;
12
+ }, {
13
+ field: string;
14
+ subject: string;
15
+ value?: string | undefined;
16
+ existingId?: string | undefined;
17
+ }>;
18
+ export declare const sNotFoundMeta: z.ZodObject<{
19
+ subject: z.ZodString;
20
+ field: z.ZodString;
21
+ value: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ value: string;
24
+ field: string;
25
+ subject: string;
26
+ }, {
27
+ value: string;
28
+ field: string;
29
+ subject: string;
30
+ }>;
31
+ export declare const sInvalidMeta: z.ZodObject<{
32
+ subject: z.ZodString;
33
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ subject: string;
36
+ fieldErrors: Record<string, string>;
37
+ }, {
38
+ subject: string;
39
+ fieldErrors: Record<string, string>;
40
+ }>;
41
+ export declare const sConflictMeta: z.ZodObject<{
42
+ subject: z.ZodString;
43
+ blockingSubject: z.ZodOptional<z.ZodString>;
44
+ blockingId: z.ZodOptional<z.ZodString>;
45
+ value: z.ZodOptional<z.ZodString>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ subject: string;
48
+ value?: string | undefined;
49
+ blockingSubject?: string | undefined;
50
+ blockingId?: string | undefined;
51
+ }, {
52
+ subject: string;
53
+ value?: string | undefined;
54
+ blockingSubject?: string | undefined;
55
+ blockingId?: string | undefined;
56
+ }>;
57
+ export declare const sVoidMeta: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
58
+ export type VoidMeta = z.infer<typeof sVoidMeta>;
59
+ export type DuplicateMeta = z.infer<typeof sDuplicateMeta>;
60
+ export type NotFoundMeta = z.infer<typeof sNotFoundMeta>;
61
+ export type InvalidMeta = z.infer<typeof sInvalidMeta>;
62
+ export type ConflictMeta = z.infer<typeof sConflictMeta>;
63
+ export declare enum AppErrorCode {
64
+ RESOURCE_ALREADY_EXISTS = "RESOURCE_ALREADY_EXISTS",
65
+ RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
66
+ RESOURCE_INVALID = "RESOURCE_INVALID",
67
+ RESOURCE_IN_USE = "RESOURCE_IN_USE",
68
+ RESOURCE_NOT_SUPPORTED = "RESOURCE_NOT_SUPPORTED",
69
+ BAD_REFERENCE = "BAD_REFERENCE",
70
+ UNKNOWN = "UNKNOWN",
71
+ ACCESS_RULE_NOT_FOUND = "ACCESS_RULE_NOT_FOUND",
72
+ ACCESS_RULE_PERMISSION_CONFLICT = "ACCESS_RULE_PERMISSION_CONFLICT",
73
+ ALARM_NOT_FOUND = "ALARM_NOT_FOUND",
74
+ AUTH_INVALID_CREDENTIALS = "AUTH_INVALID_CREDENTIALS",
75
+ USER_NOT_FOUND = "USER_NOT_FOUND",
76
+ USERNAME_ALREADY_EXISTS = "USERNAME_ALREADY_EXISTS",
77
+ EMAIL_ALREADY_EXISTS = "EMAIL_ALREADY_EXISTS",
78
+ CANNOT_DELETE_ROOT_USER = "CANNOT_DELETE_ROOT_USER",
79
+ PERSON_NOT_FOUND = "PERSON_NOT_FOUND",
80
+ PERSON_INVALID_ID = "PERSON_INVALID_ID",
81
+ TOKEN_NOT_SUPPORTED = "TOKEN_NOT_SUPPORTED",
82
+ TOKEN_INVALID_FORMAT = "TOKEN_INVALID_FORMAT",
83
+ TOKEN_LIMIT_EXCEEDED = "TOKEN_LIMIT_EXCEEDED",
84
+ TOKEN_IN_USE = "TOKEN_IN_USE",
85
+ DEVICE_NOT_FOUND = "DEVICE_NOT_FOUND",
86
+ DEVICE_ALREADY_EXISTS = "DEVICE_ALREADY_EXISTS",
87
+ DEVICE_INVALID_ID = "DEVICE_INVALID_ID",
88
+ DEVICE_INVALID_TYPE = "DEVICE_INVALID_TYPE",
89
+ DEVICE_INVALID_RELATION_TYPE = "DEVICE_INVALID_RELATION_TYPE",
90
+ DEVICE_INVALID_TEMPLATE = "DEVICE_INVALID_TEMPLATE",
91
+ DEVICE_INVALID_PROVIDER_METADATA = "DEVICE_INVALID_PROVIDER_METADATA",
92
+ DEVICE_PRESET_ALREADY_EXISTS = "DEVICE_PRESET_ALREADY_EXISTS",
93
+ DEVICE_NOT_SUPPORTED = "DEVICE_NOT_SUPPORTED",
94
+ GROUP_NOT_FOUND = "GROUP_NOT_FOUND",
95
+ GROUP_ALREADY_EXISTS = "GROUP_ALREADY_EXISTS",
96
+ ZONE_NOT_FOUND = "ZONE_NOT_FOUND",
97
+ ZONE_ALREADY_EXISTS = "ZONE_ALREADY_EXISTS",
98
+ ZONE_IN_USE = "ZONE_IN_USE",
99
+ SCHEDULE_NOT_FOUND = "SCHEDULE_NOT_FOUND",
100
+ SCHEDULE_ALREADY_EXISTS = "SCHEDULE_ALREADY_EXISTS",
101
+ SCHEDULE_IN_USE = "SCHEDULE_IN_USE",
102
+ PERMISSION_ALREADY_EXISTS = "PERMISSION_ALREADY_EXISTS",
103
+ ROLE_ALREADY_EXISTS = "ROLE_ALREADY_EXISTS",
104
+ ADMIN_ROLE_CANNOT_UPDATE = "ADMIN_ROLE_CANNOT_UPDATE",
105
+ ADMIN_ROLE_CANNOT_DELETE = "ADMIN_ROLE_CANNOT_DELETE",
106
+ RULE_ALREADY_EXISTS = "RULE_ALREADY_EXISTS",
107
+ RULE_INVALID_BODY = "RULE_INVALID_BODY",
108
+ RULE_MISSING_CODE = "RULE_MISSING_CODE",
109
+ LAYOUT_ALREADY_EXISTS = "LAYOUT_ALREADY_EXISTS",
110
+ VIEW_ALREADY_EXISTS = "VIEW_ALREADY_EXISTS",
111
+ CONFIG_INVALID = "CONFIG_INVALID"
4
112
  }
5
- export declare const isErrorResponse: (obj: unknown) => obj is ErrorResponse;
113
+ export declare const errorMetadataSchemas: {
114
+ readonly RESOURCE_ALREADY_EXISTS: z.ZodObject<{
115
+ subject: z.ZodString;
116
+ field: z.ZodString;
117
+ value: z.ZodOptional<z.ZodString>;
118
+ existingId: z.ZodOptional<z.ZodString>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ field: string;
121
+ subject: string;
122
+ value?: string | undefined;
123
+ existingId?: string | undefined;
124
+ }, {
125
+ field: string;
126
+ subject: string;
127
+ value?: string | undefined;
128
+ existingId?: string | undefined;
129
+ }>;
130
+ readonly RESOURCE_NOT_FOUND: z.ZodObject<{
131
+ subject: z.ZodString;
132
+ field: z.ZodString;
133
+ value: z.ZodString;
134
+ }, "strip", z.ZodTypeAny, {
135
+ value: string;
136
+ field: string;
137
+ subject: string;
138
+ }, {
139
+ value: string;
140
+ field: string;
141
+ subject: string;
142
+ }>;
143
+ readonly RESOURCE_INVALID: z.ZodObject<{
144
+ subject: z.ZodString;
145
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
146
+ }, "strip", z.ZodTypeAny, {
147
+ subject: string;
148
+ fieldErrors: Record<string, string>;
149
+ }, {
150
+ subject: string;
151
+ fieldErrors: Record<string, string>;
152
+ }>;
153
+ readonly RESOURCE_IN_USE: z.ZodObject<{
154
+ subject: z.ZodString;
155
+ blockingSubject: z.ZodOptional<z.ZodString>;
156
+ blockingId: z.ZodOptional<z.ZodString>;
157
+ value: z.ZodOptional<z.ZodString>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ subject: string;
160
+ value?: string | undefined;
161
+ blockingSubject?: string | undefined;
162
+ blockingId?: string | undefined;
163
+ }, {
164
+ subject: string;
165
+ value?: string | undefined;
166
+ blockingSubject?: string | undefined;
167
+ blockingId?: string | undefined;
168
+ }>;
169
+ readonly RESOURCE_NOT_SUPPORTED: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
170
+ readonly BAD_REFERENCE: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
171
+ readonly ACCESS_RULE_NOT_FOUND: z.ZodObject<{
172
+ subject: z.ZodString;
173
+ field: z.ZodString;
174
+ value: z.ZodString;
175
+ }, "strip", z.ZodTypeAny, {
176
+ value: string;
177
+ field: string;
178
+ subject: string;
179
+ }, {
180
+ value: string;
181
+ field: string;
182
+ subject: string;
183
+ }>;
184
+ readonly ACCESS_RULE_PERMISSION_CONFLICT: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
185
+ readonly ALARM_NOT_FOUND: z.ZodObject<{
186
+ subject: z.ZodString;
187
+ field: z.ZodString;
188
+ value: z.ZodString;
189
+ }, "strip", z.ZodTypeAny, {
190
+ value: string;
191
+ field: string;
192
+ subject: string;
193
+ }, {
194
+ value: string;
195
+ field: string;
196
+ subject: string;
197
+ }>;
198
+ readonly AUTH_INVALID_CREDENTIALS: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
199
+ readonly USER_NOT_FOUND: z.ZodObject<{
200
+ subject: z.ZodString;
201
+ field: z.ZodString;
202
+ value: z.ZodString;
203
+ }, "strip", z.ZodTypeAny, {
204
+ value: string;
205
+ field: string;
206
+ subject: string;
207
+ }, {
208
+ value: string;
209
+ field: string;
210
+ subject: string;
211
+ }>;
212
+ readonly USERNAME_ALREADY_EXISTS: z.ZodObject<{
213
+ subject: z.ZodString;
214
+ field: z.ZodString;
215
+ value: z.ZodOptional<z.ZodString>;
216
+ existingId: z.ZodOptional<z.ZodString>;
217
+ }, "strip", z.ZodTypeAny, {
218
+ field: string;
219
+ subject: string;
220
+ value?: string | undefined;
221
+ existingId?: string | undefined;
222
+ }, {
223
+ field: string;
224
+ subject: string;
225
+ value?: string | undefined;
226
+ existingId?: string | undefined;
227
+ }>;
228
+ readonly EMAIL_ALREADY_EXISTS: z.ZodObject<{
229
+ subject: z.ZodString;
230
+ field: z.ZodString;
231
+ value: z.ZodOptional<z.ZodString>;
232
+ existingId: z.ZodOptional<z.ZodString>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ field: string;
235
+ subject: string;
236
+ value?: string | undefined;
237
+ existingId?: string | undefined;
238
+ }, {
239
+ field: string;
240
+ subject: string;
241
+ value?: string | undefined;
242
+ existingId?: string | undefined;
243
+ }>;
244
+ readonly CANNOT_DELETE_ROOT_USER: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
245
+ readonly PERSON_NOT_FOUND: z.ZodObject<{
246
+ subject: z.ZodString;
247
+ field: z.ZodString;
248
+ value: z.ZodString;
249
+ }, "strip", z.ZodTypeAny, {
250
+ value: string;
251
+ field: string;
252
+ subject: string;
253
+ }, {
254
+ value: string;
255
+ field: string;
256
+ subject: string;
257
+ }>;
258
+ readonly PERSON_INVALID_ID: z.ZodObject<{
259
+ subject: z.ZodString;
260
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
261
+ }, "strip", z.ZodTypeAny, {
262
+ subject: string;
263
+ fieldErrors: Record<string, string>;
264
+ }, {
265
+ subject: string;
266
+ fieldErrors: Record<string, string>;
267
+ }>;
268
+ readonly TOKEN_NOT_SUPPORTED: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
269
+ readonly TOKEN_INVALID_FORMAT: z.ZodObject<{
270
+ subject: z.ZodString;
271
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
272
+ }, "strip", z.ZodTypeAny, {
273
+ subject: string;
274
+ fieldErrors: Record<string, string>;
275
+ }, {
276
+ subject: string;
277
+ fieldErrors: Record<string, string>;
278
+ }>;
279
+ readonly TOKEN_LIMIT_EXCEEDED: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
280
+ readonly TOKEN_IN_USE: z.ZodObject<{
281
+ subject: z.ZodString;
282
+ blockingSubject: z.ZodOptional<z.ZodString>;
283
+ blockingId: z.ZodOptional<z.ZodString>;
284
+ value: z.ZodOptional<z.ZodString>;
285
+ }, "strip", z.ZodTypeAny, {
286
+ subject: string;
287
+ value?: string | undefined;
288
+ blockingSubject?: string | undefined;
289
+ blockingId?: string | undefined;
290
+ }, {
291
+ subject: string;
292
+ value?: string | undefined;
293
+ blockingSubject?: string | undefined;
294
+ blockingId?: string | undefined;
295
+ }>;
296
+ readonly DEVICE_NOT_FOUND: z.ZodObject<{
297
+ subject: z.ZodString;
298
+ field: z.ZodString;
299
+ value: z.ZodString;
300
+ }, "strip", z.ZodTypeAny, {
301
+ value: string;
302
+ field: string;
303
+ subject: string;
304
+ }, {
305
+ value: string;
306
+ field: string;
307
+ subject: string;
308
+ }>;
309
+ readonly DEVICE_ALREADY_EXISTS: z.ZodObject<{
310
+ subject: z.ZodString;
311
+ field: z.ZodString;
312
+ value: z.ZodOptional<z.ZodString>;
313
+ existingId: z.ZodOptional<z.ZodString>;
314
+ }, "strip", z.ZodTypeAny, {
315
+ field: string;
316
+ subject: string;
317
+ value?: string | undefined;
318
+ existingId?: string | undefined;
319
+ }, {
320
+ field: string;
321
+ subject: string;
322
+ value?: string | undefined;
323
+ existingId?: string | undefined;
324
+ }>;
325
+ readonly DEVICE_INVALID_ID: z.ZodObject<{
326
+ subject: z.ZodString;
327
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
328
+ }, "strip", z.ZodTypeAny, {
329
+ subject: string;
330
+ fieldErrors: Record<string, string>;
331
+ }, {
332
+ subject: string;
333
+ fieldErrors: Record<string, string>;
334
+ }>;
335
+ readonly DEVICE_INVALID_TYPE: z.ZodObject<{
336
+ subject: z.ZodString;
337
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
338
+ }, "strip", z.ZodTypeAny, {
339
+ subject: string;
340
+ fieldErrors: Record<string, string>;
341
+ }, {
342
+ subject: string;
343
+ fieldErrors: Record<string, string>;
344
+ }>;
345
+ readonly DEVICE_INVALID_RELATION_TYPE: z.ZodObject<{
346
+ subject: z.ZodString;
347
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
348
+ }, "strip", z.ZodTypeAny, {
349
+ subject: string;
350
+ fieldErrors: Record<string, string>;
351
+ }, {
352
+ subject: string;
353
+ fieldErrors: Record<string, string>;
354
+ }>;
355
+ readonly DEVICE_INVALID_TEMPLATE: z.ZodObject<{
356
+ subject: z.ZodString;
357
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
358
+ }, "strip", z.ZodTypeAny, {
359
+ subject: string;
360
+ fieldErrors: Record<string, string>;
361
+ }, {
362
+ subject: string;
363
+ fieldErrors: Record<string, string>;
364
+ }>;
365
+ readonly DEVICE_INVALID_PROVIDER_METADATA: z.ZodObject<{
366
+ subject: z.ZodString;
367
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
368
+ }, "strip", z.ZodTypeAny, {
369
+ subject: string;
370
+ fieldErrors: Record<string, string>;
371
+ }, {
372
+ subject: string;
373
+ fieldErrors: Record<string, string>;
374
+ }>;
375
+ readonly DEVICE_PRESET_ALREADY_EXISTS: z.ZodObject<{
376
+ subject: z.ZodString;
377
+ field: z.ZodString;
378
+ value: z.ZodOptional<z.ZodString>;
379
+ existingId: z.ZodOptional<z.ZodString>;
380
+ }, "strip", z.ZodTypeAny, {
381
+ field: string;
382
+ subject: string;
383
+ value?: string | undefined;
384
+ existingId?: string | undefined;
385
+ }, {
386
+ field: string;
387
+ subject: string;
388
+ value?: string | undefined;
389
+ existingId?: string | undefined;
390
+ }>;
391
+ readonly DEVICE_NOT_SUPPORTED: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
392
+ readonly GROUP_NOT_FOUND: z.ZodObject<{
393
+ subject: z.ZodString;
394
+ field: z.ZodString;
395
+ value: z.ZodString;
396
+ }, "strip", z.ZodTypeAny, {
397
+ value: string;
398
+ field: string;
399
+ subject: string;
400
+ }, {
401
+ value: string;
402
+ field: string;
403
+ subject: string;
404
+ }>;
405
+ readonly GROUP_ALREADY_EXISTS: z.ZodObject<{
406
+ subject: z.ZodString;
407
+ field: z.ZodString;
408
+ value: z.ZodOptional<z.ZodString>;
409
+ existingId: z.ZodOptional<z.ZodString>;
410
+ }, "strip", z.ZodTypeAny, {
411
+ field: string;
412
+ subject: string;
413
+ value?: string | undefined;
414
+ existingId?: string | undefined;
415
+ }, {
416
+ field: string;
417
+ subject: string;
418
+ value?: string | undefined;
419
+ existingId?: string | undefined;
420
+ }>;
421
+ readonly ZONE_NOT_FOUND: z.ZodObject<{
422
+ subject: z.ZodString;
423
+ field: z.ZodString;
424
+ value: z.ZodString;
425
+ }, "strip", z.ZodTypeAny, {
426
+ value: string;
427
+ field: string;
428
+ subject: string;
429
+ }, {
430
+ value: string;
431
+ field: string;
432
+ subject: string;
433
+ }>;
434
+ readonly ZONE_ALREADY_EXISTS: z.ZodObject<{
435
+ subject: z.ZodString;
436
+ field: z.ZodString;
437
+ value: z.ZodOptional<z.ZodString>;
438
+ existingId: z.ZodOptional<z.ZodString>;
439
+ }, "strip", z.ZodTypeAny, {
440
+ field: string;
441
+ subject: string;
442
+ value?: string | undefined;
443
+ existingId?: string | undefined;
444
+ }, {
445
+ field: string;
446
+ subject: string;
447
+ value?: string | undefined;
448
+ existingId?: string | undefined;
449
+ }>;
450
+ readonly ZONE_IN_USE: z.ZodObject<{
451
+ subject: z.ZodString;
452
+ blockingSubject: z.ZodOptional<z.ZodString>;
453
+ blockingId: z.ZodOptional<z.ZodString>;
454
+ value: z.ZodOptional<z.ZodString>;
455
+ }, "strip", z.ZodTypeAny, {
456
+ subject: string;
457
+ value?: string | undefined;
458
+ blockingSubject?: string | undefined;
459
+ blockingId?: string | undefined;
460
+ }, {
461
+ subject: string;
462
+ value?: string | undefined;
463
+ blockingSubject?: string | undefined;
464
+ blockingId?: string | undefined;
465
+ }>;
466
+ readonly SCHEDULE_NOT_FOUND: z.ZodObject<{
467
+ subject: z.ZodString;
468
+ field: z.ZodString;
469
+ value: z.ZodString;
470
+ }, "strip", z.ZodTypeAny, {
471
+ value: string;
472
+ field: string;
473
+ subject: string;
474
+ }, {
475
+ value: string;
476
+ field: string;
477
+ subject: string;
478
+ }>;
479
+ readonly SCHEDULE_ALREADY_EXISTS: z.ZodObject<{
480
+ subject: z.ZodString;
481
+ field: z.ZodString;
482
+ value: z.ZodOptional<z.ZodString>;
483
+ existingId: z.ZodOptional<z.ZodString>;
484
+ }, "strip", z.ZodTypeAny, {
485
+ field: string;
486
+ subject: string;
487
+ value?: string | undefined;
488
+ existingId?: string | undefined;
489
+ }, {
490
+ field: string;
491
+ subject: string;
492
+ value?: string | undefined;
493
+ existingId?: string | undefined;
494
+ }>;
495
+ readonly SCHEDULE_IN_USE: z.ZodObject<{
496
+ subject: z.ZodString;
497
+ blockingSubject: z.ZodOptional<z.ZodString>;
498
+ blockingId: z.ZodOptional<z.ZodString>;
499
+ value: z.ZodOptional<z.ZodString>;
500
+ }, "strip", z.ZodTypeAny, {
501
+ subject: string;
502
+ value?: string | undefined;
503
+ blockingSubject?: string | undefined;
504
+ blockingId?: string | undefined;
505
+ }, {
506
+ subject: string;
507
+ value?: string | undefined;
508
+ blockingSubject?: string | undefined;
509
+ blockingId?: string | undefined;
510
+ }>;
511
+ readonly PERMISSION_ALREADY_EXISTS: z.ZodObject<{
512
+ subject: z.ZodString;
513
+ field: z.ZodString;
514
+ value: z.ZodOptional<z.ZodString>;
515
+ existingId: z.ZodOptional<z.ZodString>;
516
+ }, "strip", z.ZodTypeAny, {
517
+ field: string;
518
+ subject: string;
519
+ value?: string | undefined;
520
+ existingId?: string | undefined;
521
+ }, {
522
+ field: string;
523
+ subject: string;
524
+ value?: string | undefined;
525
+ existingId?: string | undefined;
526
+ }>;
527
+ readonly ROLE_ALREADY_EXISTS: z.ZodObject<{
528
+ subject: z.ZodString;
529
+ field: z.ZodString;
530
+ value: z.ZodOptional<z.ZodString>;
531
+ existingId: z.ZodOptional<z.ZodString>;
532
+ }, "strip", z.ZodTypeAny, {
533
+ field: string;
534
+ subject: string;
535
+ value?: string | undefined;
536
+ existingId?: string | undefined;
537
+ }, {
538
+ field: string;
539
+ subject: string;
540
+ value?: string | undefined;
541
+ existingId?: string | undefined;
542
+ }>;
543
+ readonly ADMIN_ROLE_CANNOT_UPDATE: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
544
+ readonly ADMIN_ROLE_CANNOT_DELETE: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
545
+ readonly RULE_ALREADY_EXISTS: z.ZodObject<{
546
+ subject: z.ZodString;
547
+ field: z.ZodString;
548
+ value: z.ZodOptional<z.ZodString>;
549
+ existingId: z.ZodOptional<z.ZodString>;
550
+ }, "strip", z.ZodTypeAny, {
551
+ field: string;
552
+ subject: string;
553
+ value?: string | undefined;
554
+ existingId?: string | undefined;
555
+ }, {
556
+ field: string;
557
+ subject: string;
558
+ value?: string | undefined;
559
+ existingId?: string | undefined;
560
+ }>;
561
+ readonly RULE_INVALID_BODY: z.ZodObject<{
562
+ subject: z.ZodString;
563
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
564
+ }, "strip", z.ZodTypeAny, {
565
+ subject: string;
566
+ fieldErrors: Record<string, string>;
567
+ }, {
568
+ subject: string;
569
+ fieldErrors: Record<string, string>;
570
+ }>;
571
+ readonly RULE_MISSING_CODE: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
572
+ readonly LAYOUT_ALREADY_EXISTS: z.ZodObject<{
573
+ subject: z.ZodString;
574
+ field: z.ZodString;
575
+ value: z.ZodOptional<z.ZodString>;
576
+ existingId: z.ZodOptional<z.ZodString>;
577
+ }, "strip", z.ZodTypeAny, {
578
+ field: string;
579
+ subject: string;
580
+ value?: string | undefined;
581
+ existingId?: string | undefined;
582
+ }, {
583
+ field: string;
584
+ subject: string;
585
+ value?: string | undefined;
586
+ existingId?: string | undefined;
587
+ }>;
588
+ readonly VIEW_ALREADY_EXISTS: z.ZodObject<{
589
+ subject: z.ZodString;
590
+ field: z.ZodString;
591
+ value: z.ZodOptional<z.ZodString>;
592
+ existingId: z.ZodOptional<z.ZodString>;
593
+ }, "strip", z.ZodTypeAny, {
594
+ field: string;
595
+ subject: string;
596
+ value?: string | undefined;
597
+ existingId?: string | undefined;
598
+ }, {
599
+ field: string;
600
+ subject: string;
601
+ value?: string | undefined;
602
+ existingId?: string | undefined;
603
+ }>;
604
+ readonly CONFIG_INVALID: z.ZodObject<{
605
+ subject: z.ZodString;
606
+ fieldErrors: z.ZodRecord<z.ZodString, z.ZodString>;
607
+ }, "strip", z.ZodTypeAny, {
608
+ subject: string;
609
+ fieldErrors: Record<string, string>;
610
+ }, {
611
+ subject: string;
612
+ fieldErrors: Record<string, string>;
613
+ }>;
614
+ readonly UNKNOWN: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
615
+ };
616
+ type AppErrorMetadataSchemaMap = typeof errorMetadataSchemas;
617
+ export type AppErrorMetadataMap = {
618
+ [K in keyof AppErrorMetadataSchemaMap]: z.infer<AppErrorMetadataSchemaMap[K]>;
619
+ };
620
+ export type ErrorResponse<C extends AppErrorCode = AppErrorCode> = {
621
+ code: C;
622
+ message: string;
623
+ metadata: AppErrorMetadataMap[C];
624
+ };
625
+ export type AnyErrorResponse = {
626
+ [K in AppErrorCode]: ErrorResponse<K>;
627
+ }[AppErrorCode];
628
+ export declare function isErrorResponse(err: unknown): err is AnyErrorResponse;
629
+ export {};
package/dist/error.js CHANGED
@@ -1,7 +1,157 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isErrorResponse = void 0;
4
- const isErrorResponse = (obj) => {
5
- return (typeof obj === 'object' && obj !== null && 'code' in obj && 'message' in obj);
6
- };
3
+ exports.errorMetadataSchemas = exports.AppErrorCode = exports.sVoidMeta = exports.sConflictMeta = exports.sInvalidMeta = exports.sNotFoundMeta = exports.sDuplicateMeta = void 0;
7
4
  exports.isErrorResponse = isErrorResponse;
5
+ const zod_1 = require("zod");
6
+ // METADATA
7
+ exports.sDuplicateMeta = zod_1.z.object({
8
+ subject: zod_1.z.string(),
9
+ field: zod_1.z.string(),
10
+ value: zod_1.z.string().optional(),
11
+ existingId: zod_1.z.string().optional(), // UUID or whatever
12
+ });
13
+ exports.sNotFoundMeta = zod_1.z.object({
14
+ subject: zod_1.z.string(),
15
+ field: zod_1.z.string(),
16
+ value: zod_1.z.string(),
17
+ });
18
+ exports.sInvalidMeta = zod_1.z.object({
19
+ subject: zod_1.z.string(),
20
+ fieldErrors: zod_1.z.record(zod_1.z.string()), // key → human msg
21
+ });
22
+ exports.sConflictMeta = zod_1.z.object({
23
+ subject: zod_1.z.string(),
24
+ blockingSubject: zod_1.z.string().optional(),
25
+ blockingId: zod_1.z.string().optional(),
26
+ value: zod_1.z.string().optional(),
27
+ });
28
+ exports.sVoidMeta = zod_1.z.object({}).strict();
29
+ // ERROR CODES
30
+ var AppErrorCode;
31
+ (function (AppErrorCode) {
32
+ // generic
33
+ AppErrorCode["RESOURCE_ALREADY_EXISTS"] = "RESOURCE_ALREADY_EXISTS";
34
+ AppErrorCode["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
35
+ AppErrorCode["RESOURCE_INVALID"] = "RESOURCE_INVALID";
36
+ AppErrorCode["RESOURCE_IN_USE"] = "RESOURCE_IN_USE";
37
+ AppErrorCode["RESOURCE_NOT_SUPPORTED"] = "RESOURCE_NOT_SUPPORTED";
38
+ AppErrorCode["BAD_REFERENCE"] = "BAD_REFERENCE";
39
+ AppErrorCode["UNKNOWN"] = "UNKNOWN";
40
+ // access
41
+ AppErrorCode["ACCESS_RULE_NOT_FOUND"] = "ACCESS_RULE_NOT_FOUND";
42
+ AppErrorCode["ACCESS_RULE_PERMISSION_CONFLICT"] = "ACCESS_RULE_PERMISSION_CONFLICT";
43
+ // alarm
44
+ AppErrorCode["ALARM_NOT_FOUND"] = "ALARM_NOT_FOUND";
45
+ // auth / user
46
+ AppErrorCode["AUTH_INVALID_CREDENTIALS"] = "AUTH_INVALID_CREDENTIALS";
47
+ AppErrorCode["USER_NOT_FOUND"] = "USER_NOT_FOUND";
48
+ AppErrorCode["USERNAME_ALREADY_EXISTS"] = "USERNAME_ALREADY_EXISTS";
49
+ AppErrorCode["EMAIL_ALREADY_EXISTS"] = "EMAIL_ALREADY_EXISTS";
50
+ AppErrorCode["CANNOT_DELETE_ROOT_USER"] = "CANNOT_DELETE_ROOT_USER";
51
+ // person / token
52
+ AppErrorCode["PERSON_NOT_FOUND"] = "PERSON_NOT_FOUND";
53
+ AppErrorCode["PERSON_INVALID_ID"] = "PERSON_INVALID_ID";
54
+ AppErrorCode["TOKEN_NOT_SUPPORTED"] = "TOKEN_NOT_SUPPORTED";
55
+ AppErrorCode["TOKEN_INVALID_FORMAT"] = "TOKEN_INVALID_FORMAT";
56
+ AppErrorCode["TOKEN_LIMIT_EXCEEDED"] = "TOKEN_LIMIT_EXCEEDED";
57
+ AppErrorCode["TOKEN_IN_USE"] = "TOKEN_IN_USE";
58
+ // device
59
+ AppErrorCode["DEVICE_NOT_FOUND"] = "DEVICE_NOT_FOUND";
60
+ AppErrorCode["DEVICE_ALREADY_EXISTS"] = "DEVICE_ALREADY_EXISTS";
61
+ AppErrorCode["DEVICE_INVALID_ID"] = "DEVICE_INVALID_ID";
62
+ AppErrorCode["DEVICE_INVALID_TYPE"] = "DEVICE_INVALID_TYPE";
63
+ AppErrorCode["DEVICE_INVALID_RELATION_TYPE"] = "DEVICE_INVALID_RELATION_TYPE";
64
+ AppErrorCode["DEVICE_INVALID_TEMPLATE"] = "DEVICE_INVALID_TEMPLATE";
65
+ AppErrorCode["DEVICE_INVALID_PROVIDER_METADATA"] = "DEVICE_INVALID_PROVIDER_METADATA";
66
+ AppErrorCode["DEVICE_PRESET_ALREADY_EXISTS"] = "DEVICE_PRESET_ALREADY_EXISTS";
67
+ AppErrorCode["DEVICE_NOT_SUPPORTED"] = "DEVICE_NOT_SUPPORTED";
68
+ // group / zone / schedule
69
+ AppErrorCode["GROUP_NOT_FOUND"] = "GROUP_NOT_FOUND";
70
+ AppErrorCode["GROUP_ALREADY_EXISTS"] = "GROUP_ALREADY_EXISTS";
71
+ AppErrorCode["ZONE_NOT_FOUND"] = "ZONE_NOT_FOUND";
72
+ AppErrorCode["ZONE_ALREADY_EXISTS"] = "ZONE_ALREADY_EXISTS";
73
+ AppErrorCode["ZONE_IN_USE"] = "ZONE_IN_USE";
74
+ AppErrorCode["SCHEDULE_NOT_FOUND"] = "SCHEDULE_NOT_FOUND";
75
+ AppErrorCode["SCHEDULE_ALREADY_EXISTS"] = "SCHEDULE_ALREADY_EXISTS";
76
+ AppErrorCode["SCHEDULE_IN_USE"] = "SCHEDULE_IN_USE";
77
+ // permission / role
78
+ AppErrorCode["PERMISSION_ALREADY_EXISTS"] = "PERMISSION_ALREADY_EXISTS";
79
+ AppErrorCode["ROLE_ALREADY_EXISTS"] = "ROLE_ALREADY_EXISTS";
80
+ AppErrorCode["ADMIN_ROLE_CANNOT_UPDATE"] = "ADMIN_ROLE_CANNOT_UPDATE";
81
+ AppErrorCode["ADMIN_ROLE_CANNOT_DELETE"] = "ADMIN_ROLE_CANNOT_DELETE";
82
+ // automation / rules
83
+ AppErrorCode["RULE_ALREADY_EXISTS"] = "RULE_ALREADY_EXISTS";
84
+ AppErrorCode["RULE_INVALID_BODY"] = "RULE_INVALID_BODY";
85
+ AppErrorCode["RULE_MISSING_CODE"] = "RULE_MISSING_CODE";
86
+ // layout / view
87
+ AppErrorCode["LAYOUT_ALREADY_EXISTS"] = "LAYOUT_ALREADY_EXISTS";
88
+ AppErrorCode["VIEW_ALREADY_EXISTS"] = "VIEW_ALREADY_EXISTS";
89
+ // config
90
+ AppErrorCode["CONFIG_INVALID"] = "CONFIG_INVALID";
91
+ })(AppErrorCode || (exports.AppErrorCode = AppErrorCode = {}));
92
+ exports.errorMetadataSchemas = {
93
+ [AppErrorCode.RESOURCE_ALREADY_EXISTS]: exports.sDuplicateMeta,
94
+ [AppErrorCode.RESOURCE_NOT_FOUND]: exports.sNotFoundMeta,
95
+ [AppErrorCode.RESOURCE_INVALID]: exports.sInvalidMeta,
96
+ [AppErrorCode.RESOURCE_IN_USE]: exports.sConflictMeta,
97
+ [AppErrorCode.RESOURCE_NOT_SUPPORTED]: exports.sVoidMeta,
98
+ [AppErrorCode.BAD_REFERENCE]: exports.sVoidMeta,
99
+ // access
100
+ [AppErrorCode.ACCESS_RULE_NOT_FOUND]: exports.sNotFoundMeta,
101
+ [AppErrorCode.ACCESS_RULE_PERMISSION_CONFLICT]: exports.sVoidMeta,
102
+ // alarm
103
+ [AppErrorCode.ALARM_NOT_FOUND]: exports.sNotFoundMeta,
104
+ // auth / user
105
+ [AppErrorCode.AUTH_INVALID_CREDENTIALS]: exports.sVoidMeta,
106
+ [AppErrorCode.USER_NOT_FOUND]: exports.sNotFoundMeta,
107
+ [AppErrorCode.USERNAME_ALREADY_EXISTS]: exports.sDuplicateMeta,
108
+ [AppErrorCode.EMAIL_ALREADY_EXISTS]: exports.sDuplicateMeta,
109
+ [AppErrorCode.CANNOT_DELETE_ROOT_USER]: exports.sVoidMeta,
110
+ // person / token
111
+ [AppErrorCode.PERSON_NOT_FOUND]: exports.sNotFoundMeta,
112
+ [AppErrorCode.PERSON_INVALID_ID]: exports.sInvalidMeta,
113
+ [AppErrorCode.TOKEN_NOT_SUPPORTED]: exports.sVoidMeta,
114
+ [AppErrorCode.TOKEN_INVALID_FORMAT]: exports.sInvalidMeta,
115
+ [AppErrorCode.TOKEN_LIMIT_EXCEEDED]: exports.sVoidMeta,
116
+ [AppErrorCode.TOKEN_IN_USE]: exports.sConflictMeta,
117
+ // device
118
+ [AppErrorCode.DEVICE_NOT_FOUND]: exports.sNotFoundMeta,
119
+ [AppErrorCode.DEVICE_ALREADY_EXISTS]: exports.sDuplicateMeta,
120
+ [AppErrorCode.DEVICE_INVALID_ID]: exports.sInvalidMeta,
121
+ [AppErrorCode.DEVICE_INVALID_TYPE]: exports.sInvalidMeta,
122
+ [AppErrorCode.DEVICE_INVALID_RELATION_TYPE]: exports.sInvalidMeta,
123
+ [AppErrorCode.DEVICE_INVALID_TEMPLATE]: exports.sInvalidMeta,
124
+ [AppErrorCode.DEVICE_INVALID_PROVIDER_METADATA]: exports.sInvalidMeta,
125
+ [AppErrorCode.DEVICE_PRESET_ALREADY_EXISTS]: exports.sDuplicateMeta,
126
+ [AppErrorCode.DEVICE_NOT_SUPPORTED]: exports.sVoidMeta,
127
+ // group / zone / schedule
128
+ [AppErrorCode.GROUP_NOT_FOUND]: exports.sNotFoundMeta,
129
+ [AppErrorCode.GROUP_ALREADY_EXISTS]: exports.sDuplicateMeta,
130
+ [AppErrorCode.ZONE_NOT_FOUND]: exports.sNotFoundMeta,
131
+ [AppErrorCode.ZONE_ALREADY_EXISTS]: exports.sDuplicateMeta,
132
+ [AppErrorCode.ZONE_IN_USE]: exports.sConflictMeta,
133
+ [AppErrorCode.SCHEDULE_NOT_FOUND]: exports.sNotFoundMeta,
134
+ [AppErrorCode.SCHEDULE_ALREADY_EXISTS]: exports.sDuplicateMeta,
135
+ [AppErrorCode.SCHEDULE_IN_USE]: exports.sConflictMeta,
136
+ // permission / role
137
+ [AppErrorCode.PERMISSION_ALREADY_EXISTS]: exports.sDuplicateMeta,
138
+ [AppErrorCode.ROLE_ALREADY_EXISTS]: exports.sDuplicateMeta,
139
+ [AppErrorCode.ADMIN_ROLE_CANNOT_UPDATE]: exports.sVoidMeta,
140
+ [AppErrorCode.ADMIN_ROLE_CANNOT_DELETE]: exports.sVoidMeta,
141
+ // automation / rules
142
+ [AppErrorCode.RULE_ALREADY_EXISTS]: exports.sDuplicateMeta,
143
+ [AppErrorCode.RULE_INVALID_BODY]: exports.sInvalidMeta,
144
+ [AppErrorCode.RULE_MISSING_CODE]: exports.sVoidMeta,
145
+ // layout / view
146
+ [AppErrorCode.LAYOUT_ALREADY_EXISTS]: exports.sDuplicateMeta,
147
+ [AppErrorCode.VIEW_ALREADY_EXISTS]: exports.sDuplicateMeta,
148
+ // config
149
+ [AppErrorCode.CONFIG_INVALID]: exports.sInvalidMeta,
150
+ [AppErrorCode.UNKNOWN]: exports.sVoidMeta,
151
+ };
152
+ function isErrorResponse(err) {
153
+ return (!!err &&
154
+ typeof err === 'object' &&
155
+ 'code' in err &&
156
+ Object.values(AppErrorCode).includes(err.code));
157
+ }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarevue/api-types",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Common types between backend, agent(s) and frontend(s)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarevue/api-types",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Common types between backend, agent(s) and frontend(s)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",