@seamapi/http 2.24.1 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +37 -0
  2. package/lib/error-interceptor.js +2 -2
  3. package/lib/error-interceptor.js.map +1 -1
  4. package/lib/resources/access-grant.d.ts +1 -1
  5. package/lib/resources/event.d.ts +9 -4
  6. package/lib/routes/access-codes/access-codes.js +1 -1
  7. package/lib/routes/access-codes/access-codes.js.map +1 -1
  8. package/lib/routes/access-grants/access-grants.d.ts +25 -25
  9. package/lib/routes/access-methods/access-methods.d.ts +5 -5
  10. package/lib/routes/access-methods/access-methods.js +1 -1
  11. package/lib/routes/access-methods/access-methods.js.map +1 -1
  12. package/lib/routes/acs/encoders/simulate/simulate.d.ts +5 -5
  13. package/lib/routes/customers/customers.d.ts +185 -185
  14. package/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.js +1 -1
  15. package/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.js.map +1 -1
  16. package/lib/routes/thermostats/simulate/simulate.d.ts +8 -8
  17. package/lib/routes/thermostats/thermostats.d.ts +5 -5
  18. package/lib/routes/user-identities/user-identities.d.ts +5 -5
  19. package/lib/routes/user-identities/user-identities.js +1 -1
  20. package/lib/routes/user-identities/user-identities.js.map +1 -1
  21. package/lib/routes/workspaces/workspaces.d.ts +1 -1
  22. package/lib/seam-http-error.d.ts +16 -3
  23. package/lib/seam-http-error.js +18 -6
  24. package/lib/seam-http-error.js.map +1 -1
  25. package/lib/version.d.ts +1 -1
  26. package/lib/version.js +1 -1
  27. package/package.json +3 -3
  28. package/src/lib/error-interceptor.ts +6 -2
  29. package/src/lib/resources/access-grant.ts +1 -1
  30. package/src/lib/resources/event.ts +10 -5
  31. package/src/lib/routes/access-codes/access-codes.ts +1 -1
  32. package/src/lib/routes/access-grants/access-grants.ts +27 -27
  33. package/src/lib/routes/access-methods/access-methods.ts +6 -6
  34. package/src/lib/routes/acs/encoders/simulate/simulate.ts +5 -6
  35. package/src/lib/routes/customers/customers.ts +235 -236
  36. package/src/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.ts +1 -1
  37. package/src/lib/routes/thermostats/simulate/simulate.ts +9 -10
  38. package/src/lib/routes/thermostats/thermostats.ts +7 -7
  39. package/src/lib/routes/user-identities/user-identities.ts +6 -6
  40. package/src/lib/routes/workspaces/workspaces.ts +1 -1
  41. package/src/lib/seam-http-error.ts +43 -6
  42. package/src/lib/version.ts +1 -1
@@ -224,242 +224,6 @@ export class SeamHttpCustomers {
224
224
  }
225
225
 
226
226
  export type CustomersCreatePortalParameters = {
227
- /**
228
- * Filter configuration for resources based on their custom_metadata. Each filter specifies a field, operation, and value to match against resource custom_metadata.
229
- */
230
- customer_resources_filters?:
231
- | Array<{
232
- /**
233
- * The custom_metadata field name to filter on.
234
- */
235
- field?: string | undefined
236
- /**
237
- * The comparison operation. Currently only '=' is supported.
238
- */
239
- operation?: '=' | undefined
240
- /**
241
- * The value to compare against.
242
- */
243
- value?: string | undefined
244
- }>
245
- | undefined
246
- /**
247
- * The ID of the customization profile to use for the portal.
248
- */
249
- customization_profile_id?: string | undefined
250
- /**
251
- * Deep link target resource for initial redirect. When set, the portal will navigate directly to the specified resource.
252
- */
253
- deep_link?:
254
- | {
255
- resource_key?: string | undefined
256
-
257
- resource_type?: 'reservation' | 'space' | 'device' | undefined
258
-
259
- resource_id?: string | undefined
260
- }
261
- | undefined
262
- /**
263
- * Whether to exclude the option to select a locale within the portal UI.
264
- */
265
- exclude_locale_picker?: boolean | undefined
266
-
267
- features?:
268
- | {
269
- /**
270
- * Configuration for the configure feature.
271
- */
272
- configure?:
273
- | {
274
- /**
275
- * Indicates whether the customer can customize the access automation rules for their properties.
276
- */
277
- allow_access_automation_rule_customization?: boolean | undefined
278
- /**
279
- * Indicates whether the customer can customize the climate automation rules for their properties.
280
- */
281
- allow_climate_automation_rule_customization?: boolean | undefined
282
- /**
283
- * Indicates whether the customer can customize the Instant Key profile for their properties.
284
- */
285
- allow_instant_key_customization?: boolean | undefined
286
- /**
287
- * Whether to exclude this feature from the portal.
288
- */
289
- exclude?: boolean | undefined
290
- }
291
- | undefined
292
- /**
293
- * Configuration for the connect accounts feature.
294
- */
295
- connect?:
296
- | {
297
- /**
298
- * List of provider keys to allow for the connect feature. These providers will be shown when the customer tries to connect an account.
299
- */
300
- accepted_providers?: Array<string> | undefined
301
- /**
302
- * Whether to exclude this feature from the portal.
303
- */
304
- exclude?: boolean | undefined
305
- /**
306
- * List of provider keys to exclude from the connect feature. These providers will not be shown when the customer tries to connect an account.
307
- */
308
- excluded_providers?: Array<string> | undefined
309
- }
310
- | undefined
311
- /**
312
- * Configuration for the manage feature.
313
- */
314
- manage?:
315
- | {
316
- /**
317
- * Custom copy for the confirmation modal shown before unmanaged devices are added to a space and begin being managed (and billed). Only takes effect when the MANAGE_DEVICES_CONFIRMATION_MODAL feature flag is enabled for the workspace. Any omitted string falls back to a localized default.
318
- */
319
- device_management_confirmation?:
320
- | {
321
- /**
322
- * Custom body text for the confirmation modal. May include the {count} token, which is replaced with the number of devices that will begin being managed.
323
- */
324
- body?: string | undefined
325
- /**
326
- * Custom label for the cancel button.
327
- */
328
- cancel_button_label?: string | undefined
329
- /**
330
- * Custom label for the confirm button.
331
- */
332
- confirm_button_label?: string | undefined
333
- /**
334
- * Custom title for the confirmation modal.
335
- */
336
- title?: string | undefined
337
- }
338
- | undefined
339
- /**
340
- * Configuration for event type filtering in the manage feature.
341
- */
342
- events?:
343
- | {
344
- /**
345
- * List of event types to show in the events filter. When set, only these event types will be available. Leave empty to show all events.
346
- */
347
- allowed_events?: Array<string> | undefined
348
- /**
349
- * List of event types that are pre-selected in the events filter when the user first loads the events tab.
350
- */
351
- default_events?: Array<string> | undefined
352
- }
353
- | undefined
354
- /**
355
- * Whether to exclude this feature from the portal.
356
- */
357
- exclude?: boolean | undefined
358
- /**
359
- * Indicates whether the customer can manage reservations for their properties.
360
- */
361
- exclude_reservation_management?: boolean | undefined
362
- /**
363
- * Indicates whether to exclude technical details from reservation views.
364
- */
365
- exclude_reservation_technical_details?: boolean | undefined
366
- /**
367
- * Indicates whether the customer can manage staff for their properties.
368
- */
369
- exclude_staff_management?: boolean | undefined
370
- }
371
- | undefined
372
- /**
373
- * Configuration for the manage devices feature.
374
- * ---
375
- * deprecated: Use `manage` instead.
376
- * ---
377
- */
378
- manage_devices?:
379
- | {
380
- /**
381
- * Whether to exclude this feature from the portal.
382
- */
383
- exclude?: boolean | undefined
384
- }
385
- | undefined
386
- /**
387
- * Configuration for the organize feature.
388
- */
389
- organize?:
390
- | {
391
- /**
392
- * Whether to exclude this feature from the portal.
393
- */
394
- exclude?: boolean | undefined
395
- }
396
- | undefined
397
- }
398
- | undefined
399
- /**
400
- * Whether the portal is embedded in another application.
401
- */
402
- is_embedded?: boolean | undefined
403
- /**
404
- * Configuration for the landing page when the portal loads.
405
- */
406
- landing_page?:
407
- | {
408
- manage?:
409
- | {
410
- space_key?: string | undefined
411
-
412
- property_key?: string | undefined
413
-
414
- room_key?: string | undefined
415
-
416
- common_area_key?: string | undefined
417
-
418
- unit_key?: string | undefined
419
-
420
- facility_key?: string | undefined
421
-
422
- building_key?: string | undefined
423
-
424
- listing_key?: string | undefined
425
-
426
- property_listing_key?: string | undefined
427
-
428
- site_key?: string | undefined
429
-
430
- reservation_key?: string | undefined
431
-
432
- booking_key?: string | undefined
433
-
434
- access_grant_key?: string | undefined
435
- }
436
- | undefined
437
- }
438
- | undefined
439
- /**
440
- * The locale to use for the portal.
441
- */
442
- locale?:
443
- | 'en-US'
444
- | 'pt-PT'
445
- | 'fr-FR'
446
- | 'it-IT'
447
- | 'es-ES'
448
- | 'de-DE'
449
- | 'nl-NL'
450
- | 'el-GR'
451
- | 'pl-PL'
452
- | 'ru-RU'
453
- | undefined
454
- /**
455
- * Navigation mode for the portal. 'restricted' tells frontend to hide navigation UI, typically used for embedded deep links.
456
- */
457
- navigation_mode?: 'full' | 'restricted' | undefined
458
- /**
459
- * Whether the portal is read-only. When true, the customer can browse the portal but cannot perform any mutating action; write requests made with the portal's client session are rejected.
460
- */
461
- read_only?: boolean | undefined
462
-
463
227
  customer_data?:
464
228
  | {
465
229
  /**
@@ -1099,6 +863,241 @@ export type CustomersCreatePortalParameters = {
1099
863
  | undefined
1100
864
  }
1101
865
  | undefined
866
+ /**
867
+ * Filter configuration for resources based on their custom_metadata. Each filter specifies a field, operation, and value to match against resource custom_metadata.
868
+ */
869
+ customer_resources_filters?:
870
+ | Array<{
871
+ /**
872
+ * The custom_metadata field name to filter on.
873
+ */
874
+ field?: string | undefined
875
+ /**
876
+ * The comparison operation. Currently only '=' is supported.
877
+ */
878
+ operation?: '=' | undefined
879
+ /**
880
+ * The value to compare against.
881
+ */
882
+ value?: string | undefined
883
+ }>
884
+ | undefined
885
+ /**
886
+ * The ID of the customization profile to use for the portal.
887
+ */
888
+ customization_profile_id?: string | undefined
889
+ /**
890
+ * Deep link target resource for initial redirect. When set, the portal will navigate directly to the specified resource.
891
+ */
892
+ deep_link?:
893
+ | {
894
+ resource_id?: string | undefined
895
+
896
+ resource_key?: string | undefined
897
+
898
+ resource_type?: 'reservation' | 'space' | 'device' | undefined
899
+ }
900
+ | undefined
901
+ /**
902
+ * Whether to exclude the option to select a locale within the portal UI.
903
+ */
904
+ exclude_locale_picker?: boolean | undefined
905
+
906
+ features?:
907
+ | {
908
+ /**
909
+ * Configuration for the configure feature.
910
+ */
911
+ configure?:
912
+ | {
913
+ /**
914
+ * Indicates whether the customer can customize the access automation rules for their properties.
915
+ */
916
+ allow_access_automation_rule_customization?: boolean | undefined
917
+ /**
918
+ * Indicates whether the customer can customize the climate automation rules for their properties.
919
+ */
920
+ allow_climate_automation_rule_customization?: boolean | undefined
921
+ /**
922
+ * Indicates whether the customer can customize the Instant Key profile for their properties.
923
+ */
924
+ allow_instant_key_customization?: boolean | undefined
925
+ /**
926
+ * Whether to exclude this feature from the portal.
927
+ */
928
+ exclude?: boolean | undefined
929
+ }
930
+ | undefined
931
+ /**
932
+ * Configuration for the connect accounts feature.
933
+ */
934
+ connect?:
935
+ | {
936
+ /**
937
+ * List of provider keys to allow for the connect feature. These providers will be shown when the customer tries to connect an account.
938
+ */
939
+ accepted_providers?: Array<string> | undefined
940
+ /**
941
+ * Whether to exclude this feature from the portal.
942
+ */
943
+ exclude?: boolean | undefined
944
+ /**
945
+ * List of provider keys to exclude from the connect feature. These providers will not be shown when the customer tries to connect an account.
946
+ */
947
+ excluded_providers?: Array<string> | undefined
948
+ }
949
+ | undefined
950
+ /**
951
+ * Configuration for the manage feature.
952
+ */
953
+ manage?:
954
+ | {
955
+ /**
956
+ * Custom copy for the confirmation modal shown before unmanaged devices are added to a space and begin being managed (and billed). Only takes effect when the MANAGE_DEVICES_CONFIRMATION_MODAL feature flag is enabled for the workspace. Any omitted string falls back to a localized default.
957
+ */
958
+ device_management_confirmation?:
959
+ | {
960
+ /**
961
+ * Custom body text for the confirmation modal. May include the {count} token, which is replaced with the number of devices that will begin being managed.
962
+ */
963
+ body?: string | undefined
964
+ /**
965
+ * Custom label for the cancel button.
966
+ */
967
+ cancel_button_label?: string | undefined
968
+ /**
969
+ * Custom label for the confirm button.
970
+ */
971
+ confirm_button_label?: string | undefined
972
+ /**
973
+ * Custom title for the confirmation modal.
974
+ */
975
+ title?: string | undefined
976
+ }
977
+ | undefined
978
+ /**
979
+ * Configuration for event type filtering in the manage feature.
980
+ */
981
+ events?:
982
+ | {
983
+ /**
984
+ * List of event types to show in the events filter. When set, only these event types will be available. Leave empty to show all events.
985
+ */
986
+ allowed_events?: Array<string> | undefined
987
+ /**
988
+ * List of event types that are pre-selected in the events filter when the user first loads the events tab.
989
+ */
990
+ default_events?: Array<string> | undefined
991
+ }
992
+ | undefined
993
+ /**
994
+ * Whether to exclude this feature from the portal.
995
+ */
996
+ exclude?: boolean | undefined
997
+ /**
998
+ * Indicates whether the customer can manage reservations for their properties.
999
+ */
1000
+ exclude_reservation_management?: boolean | undefined
1001
+ /**
1002
+ * Indicates whether to exclude technical details from reservation views.
1003
+ */
1004
+ exclude_reservation_technical_details?: boolean | undefined
1005
+ /**
1006
+ * Indicates whether the customer can manage staff for their properties.
1007
+ */
1008
+ exclude_staff_management?: boolean | undefined
1009
+ }
1010
+ | undefined
1011
+ /**
1012
+ * Configuration for the manage devices feature.
1013
+ * ---
1014
+ * deprecated: Use `manage` instead.
1015
+ * ---
1016
+ */
1017
+ manage_devices?:
1018
+ | {
1019
+ /**
1020
+ * Whether to exclude this feature from the portal.
1021
+ */
1022
+ exclude?: boolean | undefined
1023
+ }
1024
+ | undefined
1025
+ /**
1026
+ * Configuration for the organize feature.
1027
+ */
1028
+ organize?:
1029
+ | {
1030
+ /**
1031
+ * Whether to exclude this feature from the portal.
1032
+ */
1033
+ exclude?: boolean | undefined
1034
+ }
1035
+ | undefined
1036
+ }
1037
+ | undefined
1038
+ /**
1039
+ * Whether the portal is embedded in another application.
1040
+ */
1041
+ is_embedded?: boolean | undefined
1042
+ /**
1043
+ * Configuration for the landing page when the portal loads.
1044
+ */
1045
+ landing_page?:
1046
+ | {
1047
+ manage?:
1048
+ | {
1049
+ access_grant_key?: string | undefined
1050
+
1051
+ booking_key?: string | undefined
1052
+
1053
+ building_key?: string | undefined
1054
+
1055
+ common_area_key?: string | undefined
1056
+
1057
+ facility_key?: string | undefined
1058
+
1059
+ listing_key?: string | undefined
1060
+
1061
+ property_key?: string | undefined
1062
+
1063
+ property_listing_key?: string | undefined
1064
+
1065
+ reservation_key?: string | undefined
1066
+
1067
+ room_key?: string | undefined
1068
+
1069
+ site_key?: string | undefined
1070
+
1071
+ space_key?: string | undefined
1072
+
1073
+ unit_key?: string | undefined
1074
+ }
1075
+ | undefined
1076
+ }
1077
+ | undefined
1078
+ /**
1079
+ * The locale to use for the portal.
1080
+ */
1081
+ locale?:
1082
+ | 'en-US'
1083
+ | 'pt-PT'
1084
+ | 'fr-FR'
1085
+ | 'it-IT'
1086
+ | 'es-ES'
1087
+ | 'de-DE'
1088
+ | 'nl-NL'
1089
+ | 'el-GR'
1090
+ | 'pl-PL'
1091
+ | 'ru-RU'
1092
+ | undefined
1093
+ /**
1094
+ * Navigation mode for the portal. 'restricted' tells frontend to hide navigation UI, typically used for embedded deep links.
1095
+ */
1096
+ navigation_mode?: 'full' | 'restricted' | undefined
1097
+ /**
1098
+ * Whether the portal is read-only. When true, the customer can browse the portal but cannot perform any mutating action; write requests made with the portal's client session are rejected.
1099
+ */
1100
+ read_only?: boolean | undefined
1102
1101
  }
1103
1102
 
1104
1103
  /**
@@ -253,7 +253,7 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
253
253
  ): NoiseSensorsNoiseThresholdsUpdateRequest {
254
254
  return new SeamHttpRequest(this, {
255
255
  pathname: '/noise_sensors/noise_thresholds/update',
256
- method: 'PUT',
256
+ method: 'PATCH',
257
257
  body: parameters,
258
258
  parameters,
259
259
  hasRequiredParameters: true,
@@ -202,16 +202,6 @@ export class SeamHttpThermostatsSimulate {
202
202
  }
203
203
 
204
204
  export type ThermostatsSimulateHvacModeAdjustedParameters = {
205
- /**
206
- * ID of the thermostat device for which you want to simulate having adjusted the HVAC mode.
207
- */
208
- device_id: string
209
-
210
- /**
211
- * HVAC mode that you want to simulate.
212
- */
213
- hvac_mode: 'off' | 'cool' | 'heat' | 'heat_cool'
214
-
215
205
  /**
216
206
  * Cooling [set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °C that you want to simulate. You must set `cooling_set_point_celsius` or `cooling_set_point_fahrenheit`.
217
207
  */
@@ -220,6 +210,11 @@ export type ThermostatsSimulateHvacModeAdjustedParameters = {
220
210
  * Cooling [set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °F that you want to simulate. You must set `cooling_set_point_fahrenheit` or `cooling_set_point_celsius`.
221
211
  */
222
212
  cooling_set_point_fahrenheit?: number | undefined
213
+ /**
214
+ * ID of the thermostat device for which you want to simulate having adjusted the HVAC mode.
215
+ */
216
+ device_id: string
217
+
223
218
  /**
224
219
  * Heating [set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °C that you want to simulate. You must set `heating_set_point_celsius` or `heating_set_point_fahrenheit`.
225
220
  */
@@ -228,6 +223,10 @@ export type ThermostatsSimulateHvacModeAdjustedParameters = {
228
223
  * Heating [set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °F that you want to simulate. You must set `heating_set_point_fahrenheit` or `heating_set_point_celsius`.
229
224
  */
230
225
  heating_set_point_fahrenheit?: number | undefined
226
+ /**
227
+ * HVAC mode that you want to simulate.
228
+ */
229
+ hvac_mode: 'off' | 'cool' | 'heat' | 'heat_cool'
231
230
  }
232
231
 
233
232
  /**
@@ -879,13 +879,6 @@ export type ThermostatsSetFanModeOptions = Pick<
879
879
  >
880
880
 
881
881
  export type ThermostatsSetHvacModeParameters = {
882
- /**
883
- * ID of the thermostat device for which you want to set the HVAC mode.
884
- */
885
- device_id: string
886
-
887
- hvac_mode_setting: 'off' | 'cool' | 'heat' | 'heat_cool' | 'eco'
888
-
889
882
  /**
890
883
  * [Cooling set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °C that you want to set for the thermostat. You must set one of the `cooling_set_point` parameters.
891
884
  */
@@ -894,6 +887,11 @@ export type ThermostatsSetHvacModeParameters = {
894
887
  * [Cooling set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °F that you want to set for the thermostat. You must set one of the `cooling_set_point` parameters.
895
888
  */
896
889
  cooling_set_point_fahrenheit?: number | undefined
890
+ /**
891
+ * ID of the thermostat device for which you want to set the HVAC mode.
892
+ */
893
+ device_id: string
894
+
897
895
  /**
898
896
  * [Heating set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °C that you want to set for the thermostat. You must set one of the `heating_set_point` parameters.
899
897
  */
@@ -902,6 +900,8 @@ export type ThermostatsSetHvacModeParameters = {
902
900
  * [Heating set point](https://docs.seam.co/capability-guides/thermostats/understanding-thermostat-concepts/set-points) in °F that you want to set for the thermostat. You must set one of the `heating_set_point` parameters.
903
901
  */
904
902
  heating_set_point_fahrenheit?: number | undefined
903
+
904
+ hvac_mode_setting: 'off' | 'cool' | 'heat' | 'heat_cool' | 'eco'
905
905
  }
906
906
 
907
907
  /**
@@ -423,8 +423,8 @@ export class SeamHttpUserIdentities {
423
423
  requiredParameterNames: [],
424
424
  atLeastOneParameterNames: [
425
425
  'merged_user_identity_ids',
426
- 'user_identity_id',
427
426
  'merged_user_identity_keys',
427
+ 'user_identity_id',
428
428
  'user_identity_key',
429
429
  ],
430
430
  responseKey: undefined,
@@ -772,22 +772,22 @@ export type UserIdentitiesMergeParameters = RequireAtLeastOne<
772
772
  * IDs of the user identities to merge into the primary user identity. These user identities are deleted.
773
773
  */
774
774
  merged_user_identity_ids?: Array<string> | undefined
775
- /**
776
- * ID of the primary user identity to keep.
777
- */
778
- user_identity_id?: string | undefined
779
775
  /**
780
776
  * Keys of the user identities to merge into the primary user identity. These user identities are deleted.
781
777
  */
782
778
  merged_user_identity_keys?: Array<string> | undefined
779
+ /**
780
+ * ID of the primary user identity to keep.
781
+ */
782
+ user_identity_id?: string | undefined
783
783
  /**
784
784
  * Key of the primary user identity to keep.
785
785
  */
786
786
  user_identity_key?: string | undefined
787
787
  },
788
788
  | 'merged_user_identity_ids'
789
- | 'user_identity_id'
790
789
  | 'merged_user_identity_keys'
790
+ | 'user_identity_id'
791
791
  | 'user_identity_key'
792
792
  >
793
793
 
@@ -312,7 +312,7 @@ export type WorkspacesCreateParameters = {
312
312
  name: string
313
313
 
314
314
  /**
315
- * ID of the organization to associate with the new workspace.
315
+ * ID of the organization to associate with the new workspace. If omitted, the new workspace is associated with the organization that you administer, if you administer exactly one.
316
316
  */
317
317
  organization_id?: string | undefined
318
318
  /**
@@ -22,9 +22,14 @@ export class SeamHttpApiError extends Error {
22
22
  */
23
23
  data?: unknown
24
24
 
25
- constructor(error: ApiError, statusCode: number, requestId: string) {
25
+ constructor(
26
+ error: ApiError,
27
+ statusCode: number,
28
+ requestId: string,
29
+ options: ErrorOptions = {},
30
+ ) {
26
31
  const { type, message, data } = error
27
- super(message)
32
+ super(message, options)
28
33
  this.name = this.constructor.name
29
34
  this.code = type
30
35
  this.statusCode = statusCode
@@ -49,10 +54,15 @@ export class SeamHttpUnauthorizedError extends SeamHttpApiError {
49
54
  override code: 'unauthorized'
50
55
  override statusCode: 401
51
56
 
52
- constructor(requestId: string) {
57
+ constructor(requestId: string, error?: ApiError, options: ErrorOptions = {}) {
53
58
  const type = 'unauthorized'
54
59
  const status = 401
55
- super({ type, message: 'Unauthorized' }, status, requestId)
60
+ super(
61
+ error ?? { type, message: 'Unauthorized' },
62
+ status,
63
+ requestId,
64
+ options,
65
+ )
56
66
  this.name = this.constructor.name
57
67
  this.code = type
58
68
  this.statusCode = status
@@ -69,6 +79,15 @@ export const isSeamHttpUnauthorizedError = (
69
79
  return error instanceof SeamHttpUnauthorizedError
70
80
  }
71
81
 
82
+ /**
83
+ * A request parameter that failed validation,
84
+ * along with the messages explaining why.
85
+ */
86
+ export interface SeamValidationError {
87
+ parameterName: string
88
+ errorMessages: string[]
89
+ }
90
+
72
91
  /**
73
92
  * Error thrown when the Seam API returns an `invalid_input` error response.
74
93
  */
@@ -77,13 +96,31 @@ export class SeamHttpInvalidInputError extends SeamHttpApiError {
77
96
 
78
97
  readonly #validationErrors: NonNullable<ApiError['validation_errors']>
79
98
 
80
- constructor(error: ApiError, statusCode: number, requestId: string) {
81
- super(error, statusCode, requestId)
99
+ constructor(
100
+ error: ApiError,
101
+ statusCode: number,
102
+ requestId: string,
103
+ options: ErrorOptions = {},
104
+ ) {
105
+ super(error, statusCode, requestId, options)
82
106
  this.name = this.constructor.name
83
107
  this.code = 'invalid_input'
84
108
  this.#validationErrors = error.validation_errors ?? {}
85
109
  }
86
110
 
111
+ /**
112
+ * Validation errors returned by the Seam API,
113
+ * one entry per request parameter that failed validation.
114
+ */
115
+ get validationErrors(): SeamValidationError[] {
116
+ return Object.entries(this.#validationErrors)
117
+ .filter(([parameterName]) => parameterName !== '_errors')
118
+ .map(([parameterName, { _errors }]) => ({
119
+ parameterName,
120
+ errorMessages: _errors,
121
+ }))
122
+ }
123
+
87
124
  /**
88
125
  * Returns the validation error messages for the request parameter,
89
126
  * or an empty array if the parameter had no validation errors.