@awarevue/api-types 1.0.17 → 1.0.19

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.
@@ -3,5 +3,4 @@ export * from './credential';
3
3
  export * from './schedule';
4
4
  export * from './person';
5
5
  export * from './zone';
6
- export * from './sync';
7
6
  export * from './person-presence';
@@ -19,5 +19,4 @@ __exportStar(require("./credential"), exports);
19
19
  __exportStar(require("./schedule"), exports);
20
20
  __exportStar(require("./person"), exports);
21
21
  __exportStar(require("./zone"), exports);
22
- __exportStar(require("./sync"), exports);
23
22
  __exportStar(require("./person-presence"), exports);
@@ -59,5 +59,7 @@ export declare const sAddZoneDeviceRequest: z.ZodObject<{
59
59
  }, {
60
60
  deviceId: string;
61
61
  }>;
62
- export type AddZoneDeviceRequest = z.infer<typeof sAddZoneDeviceRequest>;
62
+ export type AddZoneDeviceRequest = {
63
+ zoneId: string;
64
+ } & z.infer<typeof sAddZoneDeviceRequest>;
63
65
  export type RemoveZoneDeviceRequest = AddZoneDeviceRequest;
package/dist/error.d.ts CHANGED
@@ -1,391 +1,5 @@
1
- import { z } from 'zod';
2
- export declare const sErrorNotFound: z.ZodObject<{
3
- objectId: z.ZodString;
4
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
5
- }, "strip", z.ZodTypeAny, {
6
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
7
- objectId: string;
8
- }, {
9
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
10
- objectId: string;
11
- }>;
12
- export declare const sErrorInvalid: z.ZodObject<{
13
- objectId: z.ZodString;
14
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
15
- }, "strip", z.ZodTypeAny, {
16
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
17
- objectId: string;
18
- }, {
19
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
20
- objectId: string;
21
- }>;
22
- export declare const sErrorNotSupported: z.ZodObject<{
23
- objectId: z.ZodString;
24
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
25
- }, "strip", z.ZodTypeAny, {
26
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
27
- objectId: string;
28
- }, {
29
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
30
- objectId: string;
31
- }>;
32
- export declare const sErrorNotUnique: z.ZodObject<{
33
- objectId: z.ZodString;
34
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
35
- conflictingObjectId: z.ZodOptional<z.ZodString>;
36
- }, "strip", z.ZodTypeAny, {
37
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
38
- objectId: string;
39
- conflictingObjectId?: string | undefined;
40
- }, {
41
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
42
- objectId: string;
43
- conflictingObjectId?: string | undefined;
44
- }>;
45
- export declare const sErrorInvalidFormat: z.ZodObject<{
46
- value: z.ZodString;
47
- path: z.ZodString;
48
- }, "strip", z.ZodTypeAny, {
49
- value: string;
50
- path: string;
51
- }, {
52
- value: string;
53
- path: string;
54
- }>;
55
- export declare const sErrorMissingField: z.ZodObject<{
56
- path: z.ZodString;
57
- }, "strip", z.ZodTypeAny, {
58
- path: string;
59
- }, {
60
- path: string;
61
- }>;
62
- export declare const sErrorNotUniqueValue: z.ZodObject<{
63
- value: z.ZodString;
64
- path: z.ZodString;
65
- }, "strip", z.ZodTypeAny, {
66
- value: string;
67
- path: string;
68
- }, {
69
- value: string;
70
- path: string;
71
- }>;
72
- export declare const sErrorList: z.ZodObject<{
73
- errors: z.ZodArray<z.ZodUnion<[z.ZodObject<{
74
- objectId: z.ZodString;
75
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
76
- }, "strip", z.ZodTypeAny, {
77
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
78
- objectId: string;
79
- }, {
80
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
81
- objectId: string;
82
- }>, z.ZodObject<{
83
- objectId: z.ZodString;
84
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
85
- }, "strip", z.ZodTypeAny, {
86
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
87
- objectId: string;
88
- }, {
89
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
90
- objectId: string;
91
- }>, z.ZodObject<{
92
- objectId: z.ZodString;
93
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
94
- }, "strip", z.ZodTypeAny, {
95
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
96
- objectId: string;
97
- }, {
98
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
99
- objectId: string;
100
- }>, z.ZodObject<{
101
- objectId: z.ZodString;
102
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
103
- conflictingObjectId: z.ZodOptional<z.ZodString>;
104
- }, "strip", z.ZodTypeAny, {
105
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
106
- objectId: string;
107
- conflictingObjectId?: string | undefined;
108
- }, {
109
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
110
- objectId: string;
111
- conflictingObjectId?: string | undefined;
112
- }>, z.ZodObject<{
113
- value: z.ZodString;
114
- path: z.ZodString;
115
- }, "strip", z.ZodTypeAny, {
116
- value: string;
117
- path: string;
118
- }, {
119
- value: string;
120
- path: string;
121
- }>, z.ZodObject<{
122
- path: z.ZodString;
123
- }, "strip", z.ZodTypeAny, {
124
- path: string;
125
- }, {
126
- path: string;
127
- }>, z.ZodObject<{
128
- value: z.ZodString;
129
- path: z.ZodString;
130
- }, "strip", z.ZodTypeAny, {
131
- value: string;
132
- path: string;
133
- }, {
134
- value: string;
135
- path: string;
136
- }>]>, "many">;
137
- }, "strip", z.ZodTypeAny, {
138
- errors: ({
139
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
140
- objectId: string;
141
- } | {
142
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
143
- objectId: string;
144
- } | {
145
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
146
- objectId: string;
147
- } | {
148
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
149
- objectId: string;
150
- conflictingObjectId?: string | undefined;
151
- } | {
152
- value: string;
153
- path: string;
154
- } | {
155
- path: string;
156
- } | {
157
- value: string;
158
- path: string;
159
- })[];
160
- }, {
161
- errors: ({
162
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
163
- objectId: string;
164
- } | {
165
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
166
- objectId: string;
167
- } | {
168
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
169
- objectId: string;
170
- } | {
171
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
172
- objectId: string;
173
- conflictingObjectId?: string | undefined;
174
- } | {
175
- value: string;
176
- path: string;
177
- } | {
178
- path: string;
179
- } | {
180
- value: string;
181
- path: string;
182
- })[];
183
- }>;
184
- export type ErrorNotFound = z.infer<typeof sErrorNotFound>;
185
- export type ErrorInvalid = z.infer<typeof sErrorInvalid>;
186
- export type ErrorNotSupported = z.infer<typeof sErrorNotSupported>;
187
- export type ErrorNotUnique = z.infer<typeof sErrorNotUnique>;
188
- export type ErrorInvalidFormat = z.infer<typeof sErrorInvalidFormat>;
189
- export type ErrorMissingField = z.infer<typeof sErrorMissingField>;
190
- export type ErrorNotUniqueValue = z.infer<typeof sErrorNotUniqueValue>;
191
- export type ErrorList = z.infer<typeof sErrorList>;
192
- export declare const errorDetailsMap: {
193
- readonly 'not-found': z.ZodObject<{
194
- objectId: z.ZodString;
195
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
196
- }, "strip", z.ZodTypeAny, {
197
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
198
- objectId: string;
199
- }, {
200
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
201
- objectId: string;
202
- }>;
203
- readonly invalid: z.ZodObject<{
204
- objectId: z.ZodString;
205
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
206
- }, "strip", z.ZodTypeAny, {
207
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
208
- objectId: string;
209
- }, {
210
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
211
- objectId: string;
212
- }>;
213
- readonly 'not-supported': z.ZodObject<{
214
- objectId: z.ZodString;
215
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
216
- }, "strip", z.ZodTypeAny, {
217
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
218
- objectId: string;
219
- }, {
220
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
221
- objectId: string;
222
- }>;
223
- readonly 'not-unique': z.ZodObject<{
224
- objectId: z.ZodString;
225
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
226
- conflictingObjectId: z.ZodOptional<z.ZodString>;
227
- }, "strip", z.ZodTypeAny, {
228
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
229
- objectId: string;
230
- conflictingObjectId?: string | undefined;
231
- }, {
232
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
233
- objectId: string;
234
- conflictingObjectId?: string | undefined;
235
- }>;
236
- readonly 'invalid-format': z.ZodObject<{
237
- value: z.ZodString;
238
- path: z.ZodString;
239
- }, "strip", z.ZodTypeAny, {
240
- value: string;
241
- path: string;
242
- }, {
243
- value: string;
244
- path: string;
245
- }>;
246
- readonly 'missing-field': z.ZodObject<{
247
- path: z.ZodString;
248
- }, "strip", z.ZodTypeAny, {
249
- path: string;
250
- }, {
251
- path: string;
252
- }>;
253
- readonly 'not-unique-value': z.ZodObject<{
254
- value: z.ZodString;
255
- path: z.ZodString;
256
- }, "strip", z.ZodTypeAny, {
257
- value: string;
258
- path: string;
259
- }, {
260
- value: string;
261
- path: string;
262
- }>;
263
- readonly list: z.ZodObject<{
264
- errors: z.ZodArray<z.ZodUnion<[z.ZodObject<{
265
- objectId: z.ZodString;
266
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
267
- }, "strip", z.ZodTypeAny, {
268
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
269
- objectId: string;
270
- }, {
271
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
272
- objectId: string;
273
- }>, z.ZodObject<{
274
- objectId: z.ZodString;
275
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
276
- }, "strip", z.ZodTypeAny, {
277
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
278
- objectId: string;
279
- }, {
280
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
281
- objectId: string;
282
- }>, z.ZodObject<{
283
- objectId: z.ZodString;
284
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
285
- }, "strip", z.ZodTypeAny, {
286
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
287
- objectId: string;
288
- }, {
289
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
290
- objectId: string;
291
- }>, z.ZodObject<{
292
- objectId: z.ZodString;
293
- objectKind: z.ZodEnum<["accessRule", "schedule", "person", "device", "zone", "personPresence", "deviceGroup", "view", "layout", "automationRule", "macro", "role", "user"]>;
294
- conflictingObjectId: z.ZodOptional<z.ZodString>;
295
- }, "strip", z.ZodTypeAny, {
296
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
297
- objectId: string;
298
- conflictingObjectId?: string | undefined;
299
- }, {
300
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
301
- objectId: string;
302
- conflictingObjectId?: string | undefined;
303
- }>, z.ZodObject<{
304
- value: z.ZodString;
305
- path: z.ZodString;
306
- }, "strip", z.ZodTypeAny, {
307
- value: string;
308
- path: string;
309
- }, {
310
- value: string;
311
- path: string;
312
- }>, z.ZodObject<{
313
- path: z.ZodString;
314
- }, "strip", z.ZodTypeAny, {
315
- path: string;
316
- }, {
317
- path: string;
318
- }>, z.ZodObject<{
319
- value: z.ZodString;
320
- path: z.ZodString;
321
- }, "strip", z.ZodTypeAny, {
322
- value: string;
323
- path: string;
324
- }, {
325
- value: string;
326
- path: string;
327
- }>]>, "many">;
328
- }, "strip", z.ZodTypeAny, {
329
- errors: ({
330
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
331
- objectId: string;
332
- } | {
333
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
334
- objectId: string;
335
- } | {
336
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
337
- objectId: string;
338
- } | {
339
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
340
- objectId: string;
341
- conflictingObjectId?: string | undefined;
342
- } | {
343
- value: string;
344
- path: string;
345
- } | {
346
- path: string;
347
- } | {
348
- value: string;
349
- path: string;
350
- })[];
351
- }, {
352
- errors: ({
353
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
354
- objectId: string;
355
- } | {
356
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
357
- objectId: string;
358
- } | {
359
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
360
- objectId: string;
361
- } | {
362
- objectKind: "view" | "role" | "user" | "person" | "zone" | "layout" | "device" | "schedule" | "macro" | "accessRule" | "personPresence" | "deviceGroup" | "automationRule";
363
- objectId: string;
364
- conflictingObjectId?: string | undefined;
365
- } | {
366
- value: string;
367
- path: string;
368
- } | {
369
- path: string;
370
- } | {
371
- value: string;
372
- path: string;
373
- })[];
374
- }>;
375
- };
376
- export type ErrorDetailsMap = {
377
- [K in keyof typeof errorDetailsMap]: z.infer<(typeof errorDetailsMap)[K]>;
378
- };
379
- export type ErrorCode = keyof typeof errorDetailsMap;
380
- export type ErrorDetails = z.infer<(typeof errorDetailsMap)[keyof typeof errorDetailsMap]>;
381
- export type ErrorResponse = {
382
- [K in keyof typeof errorDetailsMap]: {
383
- code: K;
384
- message: string;
385
- details: z.infer<(typeof errorDetailsMap)[K]>;
386
- };
387
- }[keyof typeof errorDetailsMap];
1
+ export interface ErrorResponse {
2
+ code: string;
3
+ message: string;
4
+ }
388
5
  export declare const isErrorResponse: (obj: unknown) => obj is ErrorResponse;
389
- export declare const isErrorOfCode: <T extends ErrorCode>(error: unknown, code: T) => error is ErrorResponse & {
390
- code: T;
391
- };
package/dist/error.js CHANGED
@@ -1,125 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isErrorOfCode = exports.isErrorResponse = exports.errorDetailsMap = exports.sErrorList = exports.sErrorNotUniqueValue = exports.sErrorMissingField = exports.sErrorInvalidFormat = exports.sErrorNotUnique = exports.sErrorNotSupported = exports.sErrorInvalid = exports.sErrorNotFound = void 0;
4
- const zod_1 = require("zod");
5
- const device_1 = require("./device");
6
- exports.sErrorNotFound = zod_1.z.object({
7
- objectId: zod_1.z.string(),
8
- objectKind: device_1.sObjectKind,
9
- });
10
- exports.sErrorInvalid = zod_1.z.object({
11
- objectId: zod_1.z.string(),
12
- objectKind: device_1.sObjectKind,
13
- });
14
- exports.sErrorNotSupported = zod_1.z.object({
15
- objectId: zod_1.z.string(),
16
- objectKind: device_1.sObjectKind,
17
- });
18
- exports.sErrorNotUnique = zod_1.z.object({
19
- objectId: zod_1.z.string(),
20
- objectKind: device_1.sObjectKind,
21
- conflictingObjectId: zod_1.z.string().optional(),
22
- });
23
- exports.sErrorInvalidFormat = zod_1.z.object({
24
- value: zod_1.z.string(),
25
- path: zod_1.z.string(),
26
- });
27
- exports.sErrorMissingField = zod_1.z.object({
28
- path: zod_1.z.string(),
29
- });
30
- exports.sErrorNotUniqueValue = zod_1.z.object({
31
- value: zod_1.z.string(),
32
- path: zod_1.z.string(),
33
- });
34
- exports.sErrorList = zod_1.z.object({
35
- errors: zod_1.z.array(zod_1.z.union([
36
- exports.sErrorNotFound,
37
- exports.sErrorInvalid,
38
- exports.sErrorNotSupported,
39
- exports.sErrorNotUnique,
40
- exports.sErrorInvalidFormat,
41
- exports.sErrorMissingField,
42
- exports.sErrorNotUniqueValue,
43
- ])),
44
- });
45
- exports.errorDetailsMap = {
46
- 'not-found': exports.sErrorNotFound,
47
- invalid: exports.sErrorInvalid,
48
- 'not-supported': exports.sErrorNotSupported,
49
- 'not-unique': exports.sErrorNotUnique,
50
- 'invalid-format': exports.sErrorInvalidFormat,
51
- 'missing-field': exports.sErrorMissingField,
52
- 'not-unique-value': exports.sErrorNotUniqueValue,
53
- list: exports.sErrorList,
54
- // Add more error types here as needed
55
- };
3
+ exports.isErrorResponse = void 0;
56
4
  const isErrorResponse = (obj) => {
57
- if (typeof obj !== 'object' || obj === null) {
58
- return false;
59
- }
60
- if (!('code' in obj)) {
61
- return false;
62
- }
63
- const code = obj.code;
64
- if (typeof obj.code !== 'string') {
65
- return false;
66
- }
67
- if (!('message' in obj)) {
68
- return false;
69
- }
70
- if (typeof obj.message !== 'string') {
71
- return false;
72
- }
73
- if (!('details' in obj)) {
74
- return false;
75
- }
76
- const details = obj.details;
77
- if (typeof details !== 'object' || details === null) {
78
- return false;
79
- }
80
- if (!exports.errorDetailsMap[code]) {
81
- return false;
82
- }
83
- const schema = exports.errorDetailsMap[code];
84
- if (!schema.safeParse(details).success) {
85
- return false;
86
- }
87
- return true;
5
+ return (typeof obj === 'object' && obj !== null && 'code' in obj && 'message' in obj);
88
6
  };
89
7
  exports.isErrorResponse = isErrorResponse;
90
- const isErrorOfCode = (error, code) => {
91
- if (typeof error !== 'object' || error === null) {
92
- return false;
93
- }
94
- if (!('code' in error)) {
95
- return false;
96
- }
97
- if (typeof error.code !== 'string') {
98
- return false;
99
- }
100
- if (error.code !== code) {
101
- return false;
102
- }
103
- if (!('details' in error)) {
104
- return false;
105
- }
106
- const details = error.details;
107
- if (typeof details !== 'object' || details === null) {
108
- return false;
109
- }
110
- if (!exports.errorDetailsMap[code].safeParse(details).success) {
111
- return false;
112
- }
113
- return true;
114
- };
115
- exports.isErrorOfCode = isErrorOfCode;
116
- // export type ErrorDetailsMap = {
117
- // 'not-found': ErrorNotFound;
118
- // invalid: ErrorInvalid;
119
- // 'not-supported': ErrorNotSupported;
120
- // 'not-unique': ErrorNotUnique;
121
- // };
122
- // export const sErrorResponse = z.object({});
123
- // export type ErrorResponse = z.infer<typeof sErrorResponse>;
124
- // export const isErrorResponse = (obj: unknown): obj is ErrorResponse =>
125
- // sErrorResponse.safeParse(obj).success;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarevue/api-types",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
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.17",
3
+ "version": "1.0.19",
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",
@@ -1,3 +0,0 @@
1
- export type ResponseWithProgressKey<T = object> = {
2
- syncProgressKey: string;
3
- } & T;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });