@awarevue/api-types 1.0.19 → 1.0.20

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