@seamapi/http 2.24.0 → 2.24.1

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 (144) hide show
  1. package/lib/routes/access-codes/access-codes.js +1 -1
  2. package/lib/routes/access-codes/access-codes.js.map +1 -1
  3. package/lib/routes/access-codes/simulate/simulate.js +1 -1
  4. package/lib/routes/access-codes/simulate/simulate.js.map +1 -1
  5. package/lib/routes/access-codes/unmanaged/unmanaged.js +1 -1
  6. package/lib/routes/access-codes/unmanaged/unmanaged.js.map +1 -1
  7. package/lib/routes/access-grants/access-grants.js +1 -1
  8. package/lib/routes/access-grants/access-grants.js.map +1 -1
  9. package/lib/routes/access-grants/unmanaged/unmanaged.js +1 -1
  10. package/lib/routes/access-grants/unmanaged/unmanaged.js.map +1 -1
  11. package/lib/routes/access-methods/access-methods.js +1 -1
  12. package/lib/routes/access-methods/access-methods.js.map +1 -1
  13. package/lib/routes/access-methods/unmanaged/unmanaged.js +1 -1
  14. package/lib/routes/access-methods/unmanaged/unmanaged.js.map +1 -1
  15. package/lib/routes/acs/access-groups/access-groups.js +1 -1
  16. package/lib/routes/acs/access-groups/access-groups.js.map +1 -1
  17. package/lib/routes/acs/acs.js +1 -1
  18. package/lib/routes/acs/acs.js.map +1 -1
  19. package/lib/routes/acs/credentials/credentials.js +1 -1
  20. package/lib/routes/acs/credentials/credentials.js.map +1 -1
  21. package/lib/routes/acs/encoders/encoders.js +1 -1
  22. package/lib/routes/acs/encoders/encoders.js.map +1 -1
  23. package/lib/routes/acs/encoders/simulate/simulate.js +1 -1
  24. package/lib/routes/acs/encoders/simulate/simulate.js.map +1 -1
  25. package/lib/routes/acs/entrances/entrances.js +1 -1
  26. package/lib/routes/acs/entrances/entrances.js.map +1 -1
  27. package/lib/routes/acs/systems/systems.js +1 -1
  28. package/lib/routes/acs/systems/systems.js.map +1 -1
  29. package/lib/routes/acs/users/users.js +1 -1
  30. package/lib/routes/acs/users/users.js.map +1 -1
  31. package/lib/routes/action-attempts/action-attempts.js +1 -1
  32. package/lib/routes/action-attempts/action-attempts.js.map +1 -1
  33. package/lib/routes/client-sessions/client-sessions.js +1 -1
  34. package/lib/routes/client-sessions/client-sessions.js.map +1 -1
  35. package/lib/routes/connect-webviews/connect-webviews.js +1 -1
  36. package/lib/routes/connect-webviews/connect-webviews.js.map +1 -1
  37. package/lib/routes/connected-accounts/connected-accounts.js +1 -1
  38. package/lib/routes/connected-accounts/connected-accounts.js.map +1 -1
  39. package/lib/routes/connected-accounts/simulate/simulate.js +1 -1
  40. package/lib/routes/connected-accounts/simulate/simulate.js.map +1 -1
  41. package/lib/routes/customers/customers.js +1 -1
  42. package/lib/routes/customers/customers.js.map +1 -1
  43. package/lib/routes/devices/devices.js +1 -1
  44. package/lib/routes/devices/devices.js.map +1 -1
  45. package/lib/routes/devices/simulate/simulate.js +1 -1
  46. package/lib/routes/devices/simulate/simulate.js.map +1 -1
  47. package/lib/routes/devices/unmanaged/unmanaged.js +1 -1
  48. package/lib/routes/devices/unmanaged/unmanaged.js.map +1 -1
  49. package/lib/routes/events/events.js +1 -1
  50. package/lib/routes/events/events.js.map +1 -1
  51. package/lib/routes/instant-keys/instant-keys.js +1 -1
  52. package/lib/routes/instant-keys/instant-keys.js.map +1 -1
  53. package/lib/routes/locks/locks.js +1 -1
  54. package/lib/routes/locks/locks.js.map +1 -1
  55. package/lib/routes/locks/simulate/simulate.js +1 -1
  56. package/lib/routes/locks/simulate/simulate.js.map +1 -1
  57. package/lib/routes/noise-sensors/noise-sensors.js +1 -1
  58. package/lib/routes/noise-sensors/noise-sensors.js.map +1 -1
  59. package/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.js +1 -1
  60. package/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.js.map +1 -1
  61. package/lib/routes/noise-sensors/simulate/simulate.js +1 -1
  62. package/lib/routes/noise-sensors/simulate/simulate.js.map +1 -1
  63. package/lib/routes/phones/phones.js +1 -1
  64. package/lib/routes/phones/phones.js.map +1 -1
  65. package/lib/routes/phones/simulate/simulate.js +1 -1
  66. package/lib/routes/phones/simulate/simulate.js.map +1 -1
  67. package/lib/routes/seam-http-endpoints.js +1 -1
  68. package/lib/routes/seam-http-endpoints.js.map +1 -1
  69. package/lib/routes/seam-http.js +1 -1
  70. package/lib/routes/seam-http.js.map +1 -1
  71. package/lib/routes/spaces/spaces.js +1 -1
  72. package/lib/routes/spaces/spaces.js.map +1 -1
  73. package/lib/routes/thermostats/daily-programs/daily-programs.js +1 -1
  74. package/lib/routes/thermostats/daily-programs/daily-programs.js.map +1 -1
  75. package/lib/routes/thermostats/schedules/schedules.js +1 -1
  76. package/lib/routes/thermostats/schedules/schedules.js.map +1 -1
  77. package/lib/routes/thermostats/simulate/simulate.js +1 -1
  78. package/lib/routes/thermostats/simulate/simulate.js.map +1 -1
  79. package/lib/routes/thermostats/thermostats.js +1 -1
  80. package/lib/routes/thermostats/thermostats.js.map +1 -1
  81. package/lib/routes/user-identities/unmanaged/unmanaged.js +1 -1
  82. package/lib/routes/user-identities/unmanaged/unmanaged.js.map +1 -1
  83. package/lib/routes/user-identities/user-identities.js +1 -1
  84. package/lib/routes/user-identities/user-identities.js.map +1 -1
  85. package/lib/routes/webhooks/webhooks.js +1 -1
  86. package/lib/routes/webhooks/webhooks.js.map +1 -1
  87. package/lib/routes/workspaces/workspaces.js +1 -1
  88. package/lib/routes/workspaces/workspaces.js.map +1 -1
  89. package/lib/seam-http-request.d.ts +4 -0
  90. package/lib/seam-http-request.js +18 -0
  91. package/lib/seam-http-request.js.map +1 -1
  92. package/lib/seam-paginator.d.ts +1 -7
  93. package/lib/seam-paginator.js +3 -19
  94. package/lib/seam-paginator.js.map +1 -1
  95. package/lib/version.d.ts +1 -1
  96. package/lib/version.js +1 -1
  97. package/package.json +1 -1
  98. package/src/lib/routes/access-codes/access-codes.ts +1 -1
  99. package/src/lib/routes/access-codes/simulate/simulate.ts +1 -1
  100. package/src/lib/routes/access-codes/unmanaged/unmanaged.ts +1 -1
  101. package/src/lib/routes/access-grants/access-grants.ts +1 -1
  102. package/src/lib/routes/access-grants/unmanaged/unmanaged.ts +1 -1
  103. package/src/lib/routes/access-methods/access-methods.ts +1 -1
  104. package/src/lib/routes/access-methods/unmanaged/unmanaged.ts +1 -1
  105. package/src/lib/routes/acs/access-groups/access-groups.ts +1 -1
  106. package/src/lib/routes/acs/acs.ts +1 -1
  107. package/src/lib/routes/acs/credentials/credentials.ts +1 -1
  108. package/src/lib/routes/acs/encoders/encoders.ts +1 -1
  109. package/src/lib/routes/acs/encoders/simulate/simulate.ts +1 -1
  110. package/src/lib/routes/acs/entrances/entrances.ts +1 -1
  111. package/src/lib/routes/acs/systems/systems.ts +1 -1
  112. package/src/lib/routes/acs/users/users.ts +1 -1
  113. package/src/lib/routes/action-attempts/action-attempts.ts +1 -1
  114. package/src/lib/routes/client-sessions/client-sessions.ts +1 -1
  115. package/src/lib/routes/connect-webviews/connect-webviews.ts +1 -1
  116. package/src/lib/routes/connected-accounts/connected-accounts.ts +1 -1
  117. package/src/lib/routes/connected-accounts/simulate/simulate.ts +1 -1
  118. package/src/lib/routes/customers/customers.ts +1 -1
  119. package/src/lib/routes/devices/devices.ts +1 -1
  120. package/src/lib/routes/devices/simulate/simulate.ts +1 -1
  121. package/src/lib/routes/devices/unmanaged/unmanaged.ts +1 -1
  122. package/src/lib/routes/events/events.ts +1 -1
  123. package/src/lib/routes/instant-keys/instant-keys.ts +1 -1
  124. package/src/lib/routes/locks/locks.ts +1 -1
  125. package/src/lib/routes/locks/simulate/simulate.ts +1 -1
  126. package/src/lib/routes/noise-sensors/noise-sensors.ts +1 -1
  127. package/src/lib/routes/noise-sensors/noise-thresholds/noise-thresholds.ts +1 -1
  128. package/src/lib/routes/noise-sensors/simulate/simulate.ts +1 -1
  129. package/src/lib/routes/phones/phones.ts +1 -1
  130. package/src/lib/routes/phones/simulate/simulate.ts +1 -1
  131. package/src/lib/routes/seam-http-endpoints.ts +1 -1
  132. package/src/lib/routes/seam-http.ts +1 -1
  133. package/src/lib/routes/spaces/spaces.ts +1 -1
  134. package/src/lib/routes/thermostats/daily-programs/daily-programs.ts +1 -1
  135. package/src/lib/routes/thermostats/schedules/schedules.ts +1 -1
  136. package/src/lib/routes/thermostats/simulate/simulate.ts +1 -1
  137. package/src/lib/routes/thermostats/thermostats.ts +1 -1
  138. package/src/lib/routes/user-identities/unmanaged/unmanaged.ts +1 -1
  139. package/src/lib/routes/user-identities/user-identities.ts +1 -1
  140. package/src/lib/routes/webhooks/webhooks.ts +1 -1
  141. package/src/lib/routes/workspaces/workspaces.ts +1 -1
  142. package/src/lib/seam-http-request.ts +23 -0
  143. package/src/lib/seam-paginator.ts +2 -33
  144. package/src/lib/version.ts +1 -1
@@ -142,7 +142,7 @@ export class SeamHttpNoiseSensors {
142
142
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
143
143
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
144
144
  ): SeamPaginator<TResponse, TResponseKey> {
145
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ return new SeamPaginator<TResponse, TResponseKey>(request)
146
146
  }
147
147
 
148
148
  async updateClientSessionToken(
@@ -142,7 +142,7 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
142
142
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
143
143
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
144
144
  ): SeamPaginator<TResponse, TResponseKey> {
145
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ return new SeamPaginator<TResponse, TResponseKey>(request)
146
146
  }
147
147
 
148
148
  async updateClientSessionToken(
@@ -138,7 +138,7 @@ export class SeamHttpNoiseSensorsSimulate {
138
138
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
139
139
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
140
140
  ): SeamPaginator<TResponse, TResponseKey> {
141
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
141
+ return new SeamPaginator<TResponse, TResponseKey>(request)
142
142
  }
143
143
 
144
144
  async updateClientSessionToken(
@@ -141,7 +141,7 @@ export class SeamHttpPhones {
141
141
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
142
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
143
143
  ): SeamPaginator<TResponse, TResponseKey> {
144
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
144
+ return new SeamPaginator<TResponse, TResponseKey>(request)
145
145
  }
146
146
 
147
147
  async updateClientSessionToken(
@@ -139,7 +139,7 @@ export class SeamHttpPhonesSimulate {
139
139
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
140
140
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
141
141
  ): SeamPaginator<TResponse, TResponseKey> {
142
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
142
+ return new SeamPaginator<TResponse, TResponseKey>(request)
143
143
  }
144
144
 
145
145
  async updateClientSessionToken(
@@ -864,7 +864,7 @@ export class SeamHttpEndpoints {
864
864
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
865
865
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
866
866
  ): SeamPaginator<TResponse, TResponseKey> {
867
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
867
+ return new SeamPaginator<TResponse, TResponseKey>(request)
868
868
  }
869
869
 
870
870
  async updateClientSessionToken(
@@ -155,7 +155,7 @@ export class SeamHttp {
155
155
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
156
156
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
157
157
  ): SeamPaginator<TResponse, TResponseKey> {
158
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
158
+ return new SeamPaginator<TResponse, TResponseKey>(request)
159
159
  }
160
160
 
161
161
  async updateClientSessionToken(
@@ -141,7 +141,7 @@ export class SeamHttpSpaces {
141
141
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
142
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
143
143
  ): SeamPaginator<TResponse, TResponseKey> {
144
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
144
+ return new SeamPaginator<TResponse, TResponseKey>(request)
145
145
  }
146
146
 
147
147
  async updateClientSessionToken(
@@ -144,7 +144,7 @@ export class SeamHttpThermostatsDailyPrograms {
144
144
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
145
145
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
146
146
  ): SeamPaginator<TResponse, TResponseKey> {
147
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
147
+ return new SeamPaginator<TResponse, TResponseKey>(request)
148
148
  }
149
149
 
150
150
  async updateClientSessionToken(
@@ -139,7 +139,7 @@ export class SeamHttpThermostatsSchedules {
139
139
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
140
140
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
141
141
  ): SeamPaginator<TResponse, TResponseKey> {
142
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
142
+ return new SeamPaginator<TResponse, TResponseKey>(request)
143
143
  }
144
144
 
145
145
  async updateClientSessionToken(
@@ -138,7 +138,7 @@ export class SeamHttpThermostatsSimulate {
138
138
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
139
139
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
140
140
  ): SeamPaginator<TResponse, TResponseKey> {
141
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
141
+ return new SeamPaginator<TResponse, TResponseKey>(request)
142
142
  }
143
143
 
144
144
  async updateClientSessionToken(
@@ -145,7 +145,7 @@ export class SeamHttpThermostats {
145
145
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
146
146
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
147
147
  ): SeamPaginator<TResponse, TResponseKey> {
148
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
148
+ return new SeamPaginator<TResponse, TResponseKey>(request)
149
149
  }
150
150
 
151
151
  async updateClientSessionToken(
@@ -142,7 +142,7 @@ export class SeamHttpUserIdentitiesUnmanaged {
142
142
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
143
143
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
144
144
  ): SeamPaginator<TResponse, TResponseKey> {
145
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ return new SeamPaginator<TResponse, TResponseKey>(request)
146
146
  }
147
147
 
148
148
  async updateClientSessionToken(
@@ -147,7 +147,7 @@ export class SeamHttpUserIdentities {
147
147
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
148
148
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
149
149
  ): SeamPaginator<TResponse, TResponseKey> {
150
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
150
+ return new SeamPaginator<TResponse, TResponseKey>(request)
151
151
  }
152
152
 
153
153
  async updateClientSessionToken(
@@ -139,7 +139,7 @@ export class SeamHttpWebhooks {
139
139
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
140
140
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
141
141
  ): SeamPaginator<TResponse, TResponseKey> {
142
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
142
+ return new SeamPaginator<TResponse, TResponseKey>(request)
143
143
  }
144
144
 
145
145
  async updateClientSessionToken(
@@ -141,7 +141,7 @@ export class SeamHttpWorkspaces {
141
141
  createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
142
  request: SeamPaginatedRequest<TResponse, TResponseKey>,
143
143
  ): SeamPaginator<TResponse, TResponseKey> {
144
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
144
+ return new SeamPaginator<TResponse, TResponseKey>(request)
145
145
  }
146
146
 
147
147
  async updateClientSessionToken(
@@ -124,6 +124,29 @@ export class SeamHttpRequest<
124
124
  return this.#config.body
125
125
  }
126
126
 
127
+ /**
128
+ * Returns a copy of this request with the page cursor set.
129
+ */
130
+ withPageCursor(
131
+ pageCursor?: string,
132
+ ): SeamHttpRequest<TResponse, TResponseKey> {
133
+ const usesParams = ['GET', 'DELETE'].includes(this.method.toUpperCase())
134
+
135
+ const requestData = {
136
+ ...(usesParams
137
+ ? (this.#config.params ?? {})
138
+ : ((this.#config.body as Record<string, unknown> | null) ?? {})),
139
+ page_cursor: pageCursor,
140
+ }
141
+
142
+ return new SeamHttpRequest(this.#parent, {
143
+ ...this.#config,
144
+ parameters: requestData,
145
+ params: usesParams ? requestData : undefined,
146
+ body: usesParams ? undefined : requestData,
147
+ })
148
+ }
149
+
127
150
  /**
128
151
  * Sends the request and returns the response data.
129
152
  * If the response contains an action attempt,
@@ -1,17 +1,9 @@
1
- import type { Client } from './client.js'
2
- import type { SeamHttpRequestOptions } from './options.js'
3
1
  import { SeamHttpInvalidResponseError } from './seam-http-error.js'
4
2
  import {
5
3
  readResponseData,
6
- SeamHttpRequest,
7
4
  type SeamPaginatedRequest,
8
5
  } from './seam-http-request.js'
9
6
 
10
- interface SeamPaginatorParent {
11
- readonly client: Client
12
- readonly defaults: Required<SeamHttpRequestOptions>
13
- }
14
-
15
7
  declare const $brand: unique symbol
16
8
 
17
9
  /**
@@ -39,18 +31,13 @@ export class SeamPaginator<
39
31
  const TResponseKey extends keyof TResponse,
40
32
  > implements AsyncIterable<EnsureReadonlyArray<TResponse[TResponseKey]>> {
41
33
  readonly #request: SeamPaginatedRequest<TResponse, TResponseKey>
42
- readonly #parent: SeamPaginatorParent
43
34
 
44
- constructor(
45
- parent: SeamPaginatorParent,
46
- request: SeamPaginatedRequest<TResponse, TResponseKey>,
47
- ) {
35
+ constructor(request: SeamPaginatedRequest<TResponse, TResponseKey>) {
48
36
  if (!request.hasPagination) {
49
37
  throw new Error(
50
38
  `The ${request.pathname} endpoint does not support pagination`,
51
39
  )
52
40
  }
53
- this.#parent = parent
54
41
  this.#request = request
55
42
  }
56
43
 
@@ -86,22 +73,7 @@ export class SeamPaginator<
86
73
  throw new Error('Cannot paginate a response without a responseKey')
87
74
  }
88
75
 
89
- const method = this.#request.method
90
-
91
- const requestData = {
92
- ...(usesParams(method)
93
- ? (this.#request.params ?? {})
94
- : ((this.#request.body as Record<string, unknown> | null) ?? {})),
95
- page_cursor: nextPageCursor,
96
- }
97
-
98
- const request = new SeamHttpRequest<TResponse, TResponseKey>(this.#parent, {
99
- pathname: this.#request.pathname,
100
- method,
101
- responseKey,
102
- params: usesParams(method) ? requestData : undefined,
103
- body: usesParams(method) ? undefined : requestData,
104
- })
76
+ const request = this.#request.withPageCursor(nextPageCursor ?? undefined)
105
77
 
106
78
  const response = await request.fetchResponse()
107
79
  const data = readResponseData(response, responseKey, request.pathname)
@@ -193,9 +165,6 @@ export class SeamPaginator<
193
165
  }
194
166
  }
195
167
 
196
- const usesParams = (method: string): boolean =>
197
- ['GET', 'DELETE'].includes(method.toUpperCase())
198
-
199
168
  type EnsureReadonlyArray<T> = T extends readonly any[] ? T : never
200
169
  type EnsureMutableArray<T> = T extends any[] ? T : never
201
170
  type ElementOfArray<T> =
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '2.24.0'
1
+ const seamapiJavascriptHttpVersion = '2.24.1'
2
2
 
3
3
  export default seamapiJavascriptHttpVersion