@seamapi/http 1.50.0 → 1.51.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 (35) hide show
  1. package/dist/connect.cjs +111 -6
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +54 -23
  4. package/dist/index.cjs +113 -6
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +1 -1
  7. package/lib/seam/connect/resolve-action-attempt.d.ts +16 -16
  8. package/lib/seam/connect/routes/index.d.ts +1 -0
  9. package/lib/seam/connect/routes/index.js +1 -0
  10. package/lib/seam/connect/routes/index.js.map +1 -1
  11. package/lib/seam/connect/routes/instant-keys/index.d.ts +1 -0
  12. package/lib/seam/connect/routes/instant-keys/index.js +6 -0
  13. package/lib/seam/connect/routes/instant-keys/index.js.map +1 -0
  14. package/lib/seam/connect/routes/instant-keys/instant-keys.d.ts +34 -0
  15. package/lib/seam/connect/routes/instant-keys/instant-keys.js +96 -0
  16. package/lib/seam/connect/routes/instant-keys/instant-keys.js.map +1 -0
  17. package/lib/seam/connect/routes/seam/console/v1/v1.d.ts +8 -8
  18. package/lib/seam/connect/routes/seam/console/v1/v1.js +3 -3
  19. package/lib/seam/connect/routes/seam/console/v1/v1.js.map +1 -1
  20. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +5 -3
  21. package/lib/seam/connect/routes/seam-http-endpoints.js +11 -3
  22. package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
  23. package/lib/seam/connect/routes/seam-http.d.ts +2 -0
  24. package/lib/seam/connect/routes/seam-http.js +4 -0
  25. package/lib/seam/connect/routes/seam-http.js.map +1 -1
  26. package/lib/version.d.ts +1 -1
  27. package/lib/version.js +1 -1
  28. package/package.json +3 -3
  29. package/src/lib/seam/connect/routes/index.ts +1 -0
  30. package/src/lib/seam/connect/routes/instant-keys/index.ts +6 -0
  31. package/src/lib/seam/connect/routes/instant-keys/instant-keys.ts +200 -0
  32. package/src/lib/seam/connect/routes/seam/console/v1/v1.ts +18 -18
  33. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +32 -12
  34. package/src/lib/seam/connect/routes/seam-http.ts +5 -0
  35. package/src/lib/version.ts +1 -1
@@ -0,0 +1,200 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+
8
+ import { seamApiLtsVersion } from 'lib/lts-version.js'
9
+ import {
10
+ getAuthHeadersForClientSessionToken,
11
+ warnOnInsecureuserIdentifierKey,
12
+ } from 'lib/seam/connect/auth.js'
13
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
14
+ import {
15
+ isSeamHttpOptionsWithApiKey,
16
+ isSeamHttpOptionsWithClient,
17
+ isSeamHttpOptionsWithClientSessionToken,
18
+ isSeamHttpOptionsWithConsoleSessionToken,
19
+ isSeamHttpOptionsWithPersonalAccessToken,
20
+ type SeamHttpFromPublishableKeyOptions,
21
+ SeamHttpInvalidOptionsError,
22
+ type SeamHttpOptions,
23
+ type SeamHttpOptionsWithApiKey,
24
+ type SeamHttpOptionsWithClient,
25
+ type SeamHttpOptionsWithClientSessionToken,
26
+ type SeamHttpOptionsWithConsoleSessionToken,
27
+ type SeamHttpOptionsWithPersonalAccessToken,
28
+ type SeamHttpRequestOptions,
29
+ } from 'lib/seam/connect/options.js'
30
+ import {
31
+ limitToSeamHttpRequestOptions,
32
+ parseOptions,
33
+ } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
35
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
36
+ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
37
+ import type { SetNonNullable } from 'lib/types.js'
38
+
39
+ export class SeamHttpInstantKeys {
40
+ client: Client
41
+ readonly defaults: Required<SeamHttpRequestOptions>
42
+ readonly ltsVersion = seamApiLtsVersion
43
+ static ltsVersion = seamApiLtsVersion
44
+
45
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
46
+ const options = parseOptions(apiKeyOrOptions)
47
+ this.client = 'client' in options ? options.client : createClient(options)
48
+ this.defaults = limitToSeamHttpRequestOptions(options)
49
+ }
50
+
51
+ static fromClient(
52
+ client: SeamHttpOptionsWithClient['client'],
53
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
54
+ ): SeamHttpInstantKeys {
55
+ const constructorOptions = { ...options, client }
56
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
57
+ throw new SeamHttpInvalidOptionsError('Missing client')
58
+ }
59
+ return new SeamHttpInstantKeys(constructorOptions)
60
+ }
61
+
62
+ static fromApiKey(
63
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
64
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
65
+ ): SeamHttpInstantKeys {
66
+ const constructorOptions = { ...options, apiKey }
67
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
68
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
69
+ }
70
+ return new SeamHttpInstantKeys(constructorOptions)
71
+ }
72
+
73
+ static fromClientSessionToken(
74
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
75
+ options: Omit<
76
+ SeamHttpOptionsWithClientSessionToken,
77
+ 'clientSessionToken'
78
+ > = {},
79
+ ): SeamHttpInstantKeys {
80
+ const constructorOptions = { ...options, clientSessionToken }
81
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
82
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
83
+ }
84
+ return new SeamHttpInstantKeys(constructorOptions)
85
+ }
86
+
87
+ static async fromPublishableKey(
88
+ publishableKey: string,
89
+ userIdentifierKey: string,
90
+ options: SeamHttpFromPublishableKeyOptions = {},
91
+ ): Promise<SeamHttpInstantKeys> {
92
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
93
+ const clientOptions = parseOptions({ ...options, publishableKey })
94
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
95
+ throw new SeamHttpInvalidOptionsError(
96
+ 'The client option cannot be used with SeamHttpInstantKeys.fromPublishableKey',
97
+ )
98
+ }
99
+ const client = createClient(clientOptions)
100
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
101
+ const { token } = await clientSessions.getOrCreate({
102
+ user_identifier_key: userIdentifierKey,
103
+ })
104
+ return SeamHttpInstantKeys.fromClientSessionToken(token, options)
105
+ }
106
+
107
+ static fromConsoleSessionToken(
108
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
109
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
110
+ options: Omit<
111
+ SeamHttpOptionsWithConsoleSessionToken,
112
+ 'consoleSessionToken' | 'workspaceId'
113
+ > = {},
114
+ ): SeamHttpInstantKeys {
115
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
116
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
117
+ throw new SeamHttpInvalidOptionsError(
118
+ 'Missing consoleSessionToken or workspaceId',
119
+ )
120
+ }
121
+ return new SeamHttpInstantKeys(constructorOptions)
122
+ }
123
+
124
+ static fromPersonalAccessToken(
125
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
126
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
127
+ options: Omit<
128
+ SeamHttpOptionsWithPersonalAccessToken,
129
+ 'personalAccessToken' | 'workspaceId'
130
+ > = {},
131
+ ): SeamHttpInstantKeys {
132
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
133
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ 'Missing personalAccessToken or workspaceId',
136
+ )
137
+ }
138
+ return new SeamHttpInstantKeys(constructorOptions)
139
+ }
140
+
141
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
+ request: SeamHttpRequest<TResponse, TResponseKey>,
143
+ ): SeamPaginator<TResponse, TResponseKey> {
144
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ }
146
+
147
+ async updateClientSessionToken(
148
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
149
+ ): Promise<void> {
150
+ const { headers } = this.client.defaults
151
+ const authHeaders = getAuthHeadersForClientSessionToken({
152
+ clientSessionToken,
153
+ })
154
+ for (const key of Object.keys(authHeaders)) {
155
+ if (headers[key] == null) {
156
+ throw new Error(
157
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
158
+ )
159
+ }
160
+ }
161
+ this.client.defaults.headers = { ...headers, ...authHeaders }
162
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
163
+ await clientSessions.get()
164
+ }
165
+
166
+ list(
167
+ parameters?: InstantKeysListParameters,
168
+ options: InstantKeysListOptions = {},
169
+ ): InstantKeysListRequest {
170
+ return new SeamHttpRequest(this, {
171
+ pathname: '/instant_keys/list',
172
+ method: 'POST',
173
+ body: parameters,
174
+ responseKey: 'instant_keys',
175
+ options,
176
+ })
177
+ }
178
+ }
179
+
180
+ export type InstantKeysListParameters = RouteRequestBody<'/instant_keys/list'>
181
+
182
+ /**
183
+ * @deprecated Use InstantKeysListParameters instead.
184
+ */
185
+ export type InstantKeysListParams = InstantKeysListParameters
186
+
187
+ /**
188
+ * @deprecated Use InstantKeysListRequest instead.
189
+ */
190
+ export type InstantKeysListResponse = SetNonNullable<
191
+ Required<RouteResponse<'/instant_keys/list'>>
192
+ >
193
+
194
+ export type InstantKeysListRequest = SeamHttpRequest<
195
+ InstantKeysListResponse,
196
+ 'instant_keys'
197
+ >
198
+
199
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
200
+ export interface InstantKeysListOptions {}
@@ -168,45 +168,45 @@ export class SeamHttpSeamConsoleV1 {
168
168
  await clientSessions.get()
169
169
  }
170
170
 
171
- getResourceType(
172
- parameters?: SeamConsoleV1GetResourceTypeParameters,
173
- options: SeamConsoleV1GetResourceTypeOptions = {},
174
- ): SeamConsoleV1GetResourceTypeRequest {
171
+ getResourceLocator(
172
+ parameters?: SeamConsoleV1GetResourceLocatorParameters,
173
+ options: SeamConsoleV1GetResourceLocatorOptions = {},
174
+ ): SeamConsoleV1GetResourceLocatorRequest {
175
175
  if (!this.defaults.isUndocumentedApiEnabled) {
176
176
  throw new Error(
177
177
  'Cannot use undocumented API without isUndocumentedApiEnabled',
178
178
  )
179
179
  }
180
180
  return new SeamHttpRequest(this, {
181
- pathname: '/seam/console/v1/get_resource_type',
181
+ pathname: '/seam/console/v1/get_resource_locator',
182
182
  method: 'GET',
183
183
  params: parameters,
184
- responseKey: 'resource_type',
184
+ responseKey: 'resource_locator',
185
185
  options,
186
186
  })
187
187
  }
188
188
  }
189
189
 
190
- export type SeamConsoleV1GetResourceTypeParameters =
191
- RouteRequestParams<'/seam/console/v1/get_resource_type'>
190
+ export type SeamConsoleV1GetResourceLocatorParameters =
191
+ RouteRequestParams<'/seam/console/v1/get_resource_locator'>
192
192
 
193
193
  /**
194
- * @deprecated Use SeamConsoleV1GetResourceTypeParameters instead.
194
+ * @deprecated Use SeamConsoleV1GetResourceLocatorParameters instead.
195
195
  */
196
- export type SeamConsoleV1GetResourceTypeParams =
197
- SeamConsoleV1GetResourceTypeParameters
196
+ export type SeamConsoleV1GetResourceLocatorParams =
197
+ SeamConsoleV1GetResourceLocatorParameters
198
198
 
199
199
  /**
200
- * @deprecated Use SeamConsoleV1GetResourceTypeRequest instead.
200
+ * @deprecated Use SeamConsoleV1GetResourceLocatorRequest instead.
201
201
  */
202
- export type SeamConsoleV1GetResourceTypeResponse = SetNonNullable<
203
- Required<RouteResponse<'/seam/console/v1/get_resource_type'>>
202
+ export type SeamConsoleV1GetResourceLocatorResponse = SetNonNullable<
203
+ Required<RouteResponse<'/seam/console/v1/get_resource_locator'>>
204
204
  >
205
205
 
206
- export type SeamConsoleV1GetResourceTypeRequest = SeamHttpRequest<
207
- SeamConsoleV1GetResourceTypeResponse,
208
- 'resource_type'
206
+ export type SeamConsoleV1GetResourceLocatorRequest = SeamHttpRequest<
207
+ SeamConsoleV1GetResourceLocatorResponse,
208
+ 'resource_locator'
209
209
  >
210
210
 
211
211
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
212
- export interface SeamConsoleV1GetResourceTypeOptions {}
212
+ export interface SeamConsoleV1GetResourceLocatorOptions {}
@@ -452,6 +452,12 @@ import {
452
452
  type EventsListRequest,
453
453
  SeamHttpEvents,
454
454
  } from './events/index.js'
455
+ import {
456
+ type InstantKeysListOptions,
457
+ type InstantKeysListParameters,
458
+ type InstantKeysListRequest,
459
+ SeamHttpInstantKeys,
460
+ } from './instant-keys/index.js'
455
461
  import {
456
462
  type LocksGetOptions,
457
463
  type LocksGetParameters,
@@ -525,9 +531,9 @@ import {
525
531
  SeamHttpPhonesSimulate,
526
532
  } from './phones/simulate/index.js'
527
533
  import {
528
- type SeamConsoleV1GetResourceTypeOptions,
529
- type SeamConsoleV1GetResourceTypeParameters,
530
- type SeamConsoleV1GetResourceTypeRequest,
534
+ type SeamConsoleV1GetResourceLocatorOptions,
535
+ type SeamConsoleV1GetResourceLocatorParameters,
536
+ type SeamConsoleV1GetResourceLocatorRequest,
531
537
  SeamHttpSeamConsoleV1,
532
538
  } from './seam/console/v1/index.js'
533
539
  import {
@@ -2534,6 +2540,19 @@ export class SeamHttpEndpoints {
2534
2540
  }
2535
2541
  }
2536
2542
 
2543
+ get ['/instant_keys/list'](): (
2544
+ parameters?: InstantKeysListParameters,
2545
+ options?: InstantKeysListOptions,
2546
+ ) => InstantKeysListRequest {
2547
+ const { client, defaults } = this
2548
+ return function instantKeysList(
2549
+ ...args: Parameters<SeamHttpInstantKeys['list']>
2550
+ ): ReturnType<SeamHttpInstantKeys['list']> {
2551
+ const seam = SeamHttpInstantKeys.fromClient(client, defaults)
2552
+ return seam.list(...args)
2553
+ }
2554
+ }
2555
+
2537
2556
  get ['/locks/get'](): (
2538
2557
  parameters?: LocksGetParameters,
2539
2558
  options?: LocksGetOptions,
@@ -2770,21 +2789,21 @@ export class SeamHttpEndpoints {
2770
2789
  }
2771
2790
  }
2772
2791
 
2773
- get ['/seam/console/v1/get_resource_type'](): (
2774
- parameters?: SeamConsoleV1GetResourceTypeParameters,
2775
- options?: SeamConsoleV1GetResourceTypeOptions,
2776
- ) => SeamConsoleV1GetResourceTypeRequest {
2792
+ get ['/seam/console/v1/get_resource_locator'](): (
2793
+ parameters?: SeamConsoleV1GetResourceLocatorParameters,
2794
+ options?: SeamConsoleV1GetResourceLocatorOptions,
2795
+ ) => SeamConsoleV1GetResourceLocatorRequest {
2777
2796
  const { client, defaults } = this
2778
2797
  if (!this.defaults.isUndocumentedApiEnabled) {
2779
2798
  throw new Error(
2780
2799
  'Cannot use undocumented API without isUndocumentedApiEnabled',
2781
2800
  )
2782
2801
  }
2783
- return function seamConsoleV1GetResourceType(
2784
- ...args: Parameters<SeamHttpSeamConsoleV1['getResourceType']>
2785
- ): ReturnType<SeamHttpSeamConsoleV1['getResourceType']> {
2802
+ return function seamConsoleV1GetResourceLocator(
2803
+ ...args: Parameters<SeamHttpSeamConsoleV1['getResourceLocator']>
2804
+ ): ReturnType<SeamHttpSeamConsoleV1['getResourceLocator']> {
2786
2805
  const seam = SeamHttpSeamConsoleV1.fromClient(client, defaults)
2787
- return seam.getResourceType(...args)
2806
+ return seam.getResourceLocator(...args)
2788
2807
  }
2789
2808
  }
2790
2809
 
@@ -4205,6 +4224,7 @@ export type SeamHttpEndpointQueryPaths =
4205
4224
  | '/devices/unmanaged/list'
4206
4225
  | '/events/get'
4207
4226
  | '/events/list'
4227
+ | '/instant_keys/list'
4208
4228
  | '/locks/get'
4209
4229
  | '/locks/list'
4210
4230
  | '/noise_sensors/list'
@@ -4212,7 +4232,7 @@ export type SeamHttpEndpointQueryPaths =
4212
4232
  | '/noise_sensors/noise_thresholds/list'
4213
4233
  | '/phones/get'
4214
4234
  | '/phones/list'
4215
- | '/seam/console/v1/get_resource_type'
4235
+ | '/seam/console/v1/get_resource_locator'
4216
4236
  | '/seam/customer/v1/automation_runs/list'
4217
4237
  | '/seam/customer/v1/automations/get'
4218
4238
  | '/seam/customer/v1/portals/get'
@@ -44,6 +44,7 @@ import { SeamHttpConnectedAccounts } from './connected-accounts/index.js'
44
44
  import { SeamHttpCustomers } from './customers/index.js'
45
45
  import { SeamHttpDevices } from './devices/index.js'
46
46
  import { SeamHttpEvents } from './events/index.js'
47
+ import { SeamHttpInstantKeys } from './instant-keys/index.js'
47
48
  import { SeamHttpLocks } from './locks/index.js'
48
49
  import { SeamHttpNoiseSensors } from './noise-sensors/index.js'
49
50
  import { SeamHttpPhones } from './phones/index.js'
@@ -232,6 +233,10 @@ export class SeamHttp {
232
233
  return SeamHttpEvents.fromClient(this.client, this.defaults)
233
234
  }
234
235
 
236
+ get instantKeys(): SeamHttpInstantKeys {
237
+ return SeamHttpInstantKeys.fromClient(this.client, this.defaults)
238
+ }
239
+
235
240
  get locks(): SeamHttpLocks {
236
241
  return SeamHttpLocks.fromClient(this.client, this.defaults)
237
242
  }
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '1.50.0'
1
+ const seamapiJavascriptHttpVersion = '1.51.0'
2
2
 
3
3
  export default seamapiJavascriptHttpVersion