@seamapi/http 1.100.0 → 1.101.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 (34) hide show
  1. package/dist/connect.cjs +193 -0
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +49 -2
  4. package/dist/index.cjs +197 -0
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +1 -1
  7. package/lib/seam/connect/routes/seam/index.d.ts +1 -0
  8. package/lib/seam/connect/routes/seam/index.js +1 -0
  9. package/lib/seam/connect/routes/seam/index.js.map +1 -1
  10. package/lib/seam/connect/routes/seam/v1/customers/customers.d.ts +34 -0
  11. package/lib/seam/connect/routes/seam/v1/customers/customers.js +98 -0
  12. package/lib/seam/connect/routes/seam/v1/customers/customers.js.map +1 -0
  13. package/lib/seam/connect/routes/seam/v1/customers/index.d.ts +1 -0
  14. package/lib/seam/connect/routes/seam/v1/customers/index.js +6 -0
  15. package/lib/seam/connect/routes/seam/v1/customers/index.js.map +1 -0
  16. package/lib/seam/connect/routes/seam/v1/index.d.ts +2 -0
  17. package/lib/seam/connect/routes/seam/v1/index.js +7 -0
  18. package/lib/seam/connect/routes/seam/v1/index.js.map +1 -0
  19. package/lib/seam/connect/routes/seam/v1/v1.d.ts +21 -0
  20. package/lib/seam/connect/routes/seam/v1/v1.js +92 -0
  21. package/lib/seam/connect/routes/seam/v1/v1.js.map +1 -0
  22. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +3 -1
  23. package/lib/seam/connect/routes/seam-http-endpoints.js +8 -0
  24. package/lib/seam/connect/routes/seam-http-endpoints.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/seam/connect/routes/seam/index.ts +1 -0
  29. package/src/lib/seam/connect/routes/seam/v1/customers/customers.ts +197 -0
  30. package/src/lib/seam/connect/routes/seam/v1/customers/index.ts +6 -0
  31. package/src/lib/seam/connect/routes/seam/v1/index.ts +7 -0
  32. package/src/lib/seam/connect/routes/seam/v1/v1.ts +168 -0
  33. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +20 -0
  34. package/src/lib/version.ts +1 -1
@@ -0,0 +1,197 @@
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 SeamHttpSeamV1Customers {
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
+ ): SeamHttpSeamV1Customers {
55
+ const constructorOptions = { ...options, client }
56
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
57
+ throw new SeamHttpInvalidOptionsError('Missing client')
58
+ }
59
+ return new SeamHttpSeamV1Customers(constructorOptions)
60
+ }
61
+
62
+ static fromApiKey(
63
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
64
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
65
+ ): SeamHttpSeamV1Customers {
66
+ const constructorOptions = { ...options, apiKey }
67
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
68
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
69
+ }
70
+ return new SeamHttpSeamV1Customers(constructorOptions)
71
+ }
72
+
73
+ static fromClientSessionToken(
74
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
75
+ options: Omit<
76
+ SeamHttpOptionsWithClientSessionToken,
77
+ 'clientSessionToken'
78
+ > = {},
79
+ ): SeamHttpSeamV1Customers {
80
+ const constructorOptions = { ...options, clientSessionToken }
81
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
82
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
83
+ }
84
+ return new SeamHttpSeamV1Customers(constructorOptions)
85
+ }
86
+
87
+ static async fromPublishableKey(
88
+ publishableKey: string,
89
+ userIdentifierKey: string,
90
+ options: SeamHttpFromPublishableKeyOptions = {},
91
+ ): Promise<SeamHttpSeamV1Customers> {
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 SeamHttpSeamV1Customers.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 SeamHttpSeamV1Customers.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
+ ): SeamHttpSeamV1Customers {
115
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
116
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
117
+ throw new SeamHttpInvalidOptionsError(
118
+ 'Missing consoleSessionToken or workspaceId',
119
+ )
120
+ }
121
+ return new SeamHttpSeamV1Customers(constructorOptions)
122
+ }
123
+
124
+ static fromPersonalAccessToken(
125
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
126
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
127
+ options: Omit<
128
+ SeamHttpOptionsWithPersonalAccessToken,
129
+ 'personalAccessToken' | 'workspaceId'
130
+ > = {},
131
+ ): SeamHttpSeamV1Customers {
132
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
133
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ 'Missing personalAccessToken or workspaceId',
136
+ )
137
+ }
138
+ return new SeamHttpSeamV1Customers(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
+ pushData(
167
+ parameters?: SeamV1CustomersPushDataParameters,
168
+ options: SeamV1CustomersPushDataOptions = {},
169
+ ): SeamV1CustomersPushDataRequest {
170
+ return new SeamHttpRequest(this, {
171
+ pathname: '/seam/v1/customers/push_data',
172
+ method: 'POST',
173
+ body: parameters,
174
+ responseKey: undefined,
175
+ options,
176
+ })
177
+ }
178
+ }
179
+
180
+ export type SeamV1CustomersPushDataParameters =
181
+ RouteRequestBody<'/seam/v1/customers/push_data'>
182
+
183
+ /**
184
+ * @deprecated Use SeamV1CustomersPushDataParameters instead.
185
+ */
186
+ export type SeamV1CustomersPushDataBody = SeamV1CustomersPushDataParameters
187
+
188
+ /**
189
+ * @deprecated Use SeamV1CustomersPushDataRequest instead.
190
+ */
191
+ export type SeamV1CustomersPushDataResponse = SetNonNullable<
192
+ Required<RouteResponse<'/seam/v1/customers/push_data'>>
193
+ >
194
+
195
+ export type SeamV1CustomersPushDataRequest = SeamHttpRequest<void, undefined>
196
+
197
+ export interface SeamV1CustomersPushDataOptions {}
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ export * from './customers.js'
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ export * from './customers/index.js'
7
+ export * from './v1.js'
@@ -0,0 +1,168 @@
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 { seamApiLtsVersion } from 'lib/lts-version.js'
7
+ import {
8
+ getAuthHeadersForClientSessionToken,
9
+ warnOnInsecureuserIdentifierKey,
10
+ } from 'lib/seam/connect/auth.js'
11
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
12
+ import {
13
+ isSeamHttpOptionsWithApiKey,
14
+ isSeamHttpOptionsWithClient,
15
+ isSeamHttpOptionsWithClientSessionToken,
16
+ isSeamHttpOptionsWithConsoleSessionToken,
17
+ isSeamHttpOptionsWithPersonalAccessToken,
18
+ type SeamHttpFromPublishableKeyOptions,
19
+ SeamHttpInvalidOptionsError,
20
+ type SeamHttpOptions,
21
+ type SeamHttpOptionsWithApiKey,
22
+ type SeamHttpOptionsWithClient,
23
+ type SeamHttpOptionsWithClientSessionToken,
24
+ type SeamHttpOptionsWithConsoleSessionToken,
25
+ type SeamHttpOptionsWithPersonalAccessToken,
26
+ type SeamHttpRequestOptions,
27
+ } from 'lib/seam/connect/options.js'
28
+ import {
29
+ limitToSeamHttpRequestOptions,
30
+ parseOptions,
31
+ } from 'lib/seam/connect/parse-options.js'
32
+ import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
33
+ import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
+ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
35
+
36
+ import { SeamHttpSeamV1Customers } from './customers/index.js'
37
+
38
+ export class SeamHttpSeamV1 {
39
+ client: Client
40
+ readonly defaults: Required<SeamHttpRequestOptions>
41
+ readonly ltsVersion = seamApiLtsVersion
42
+ static ltsVersion = seamApiLtsVersion
43
+
44
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
45
+ const options = parseOptions(apiKeyOrOptions)
46
+ this.client = 'client' in options ? options.client : createClient(options)
47
+ this.defaults = limitToSeamHttpRequestOptions(options)
48
+ }
49
+
50
+ static fromClient(
51
+ client: SeamHttpOptionsWithClient['client'],
52
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
53
+ ): SeamHttpSeamV1 {
54
+ const constructorOptions = { ...options, client }
55
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
56
+ throw new SeamHttpInvalidOptionsError('Missing client')
57
+ }
58
+ return new SeamHttpSeamV1(constructorOptions)
59
+ }
60
+
61
+ static fromApiKey(
62
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
63
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
64
+ ): SeamHttpSeamV1 {
65
+ const constructorOptions = { ...options, apiKey }
66
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
67
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
68
+ }
69
+ return new SeamHttpSeamV1(constructorOptions)
70
+ }
71
+
72
+ static fromClientSessionToken(
73
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
74
+ options: Omit<
75
+ SeamHttpOptionsWithClientSessionToken,
76
+ 'clientSessionToken'
77
+ > = {},
78
+ ): SeamHttpSeamV1 {
79
+ const constructorOptions = { ...options, clientSessionToken }
80
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
81
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
82
+ }
83
+ return new SeamHttpSeamV1(constructorOptions)
84
+ }
85
+
86
+ static async fromPublishableKey(
87
+ publishableKey: string,
88
+ userIdentifierKey: string,
89
+ options: SeamHttpFromPublishableKeyOptions = {},
90
+ ): Promise<SeamHttpSeamV1> {
91
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
92
+ const clientOptions = parseOptions({ ...options, publishableKey })
93
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
94
+ throw new SeamHttpInvalidOptionsError(
95
+ 'The client option cannot be used with SeamHttpSeamV1.fromPublishableKey',
96
+ )
97
+ }
98
+ const client = createClient(clientOptions)
99
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
100
+ const { token } = await clientSessions.getOrCreate({
101
+ user_identifier_key: userIdentifierKey,
102
+ })
103
+ return SeamHttpSeamV1.fromClientSessionToken(token, options)
104
+ }
105
+
106
+ static fromConsoleSessionToken(
107
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
108
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
109
+ options: Omit<
110
+ SeamHttpOptionsWithConsoleSessionToken,
111
+ 'consoleSessionToken' | 'workspaceId'
112
+ > = {},
113
+ ): SeamHttpSeamV1 {
114
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
115
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
116
+ throw new SeamHttpInvalidOptionsError(
117
+ 'Missing consoleSessionToken or workspaceId',
118
+ )
119
+ }
120
+ return new SeamHttpSeamV1(constructorOptions)
121
+ }
122
+
123
+ static fromPersonalAccessToken(
124
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
125
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
126
+ options: Omit<
127
+ SeamHttpOptionsWithPersonalAccessToken,
128
+ 'personalAccessToken' | 'workspaceId'
129
+ > = {},
130
+ ): SeamHttpSeamV1 {
131
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
132
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
133
+ throw new SeamHttpInvalidOptionsError(
134
+ 'Missing personalAccessToken or workspaceId',
135
+ )
136
+ }
137
+ return new SeamHttpSeamV1(constructorOptions)
138
+ }
139
+
140
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
141
+ request: SeamHttpRequest<TResponse, TResponseKey>,
142
+ ): SeamPaginator<TResponse, TResponseKey> {
143
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
144
+ }
145
+
146
+ async updateClientSessionToken(
147
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
148
+ ): Promise<void> {
149
+ const { headers } = this.client.defaults
150
+ const authHeaders = getAuthHeadersForClientSessionToken({
151
+ clientSessionToken,
152
+ })
153
+ for (const key of Object.keys(authHeaders)) {
154
+ if (headers[key] == null) {
155
+ throw new Error(
156
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
157
+ )
158
+ }
159
+ }
160
+ this.client.defaults.headers = { ...headers, ...authHeaders }
161
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
162
+ await clientSessions.get()
163
+ }
164
+
165
+ get customers(): SeamHttpSeamV1Customers {
166
+ return SeamHttpSeamV1Customers.fromClient(this.client, this.defaults)
167
+ }
168
+ }
@@ -707,6 +707,12 @@ import {
707
707
  type SeamPartnerV1BuildingBlocksSpacesAutoMapParameters,
708
708
  type SeamPartnerV1BuildingBlocksSpacesAutoMapRequest,
709
709
  } from './seam/partner/v1/building-blocks/spaces/index.js'
710
+ import {
711
+ SeamHttpSeamV1Customers,
712
+ type SeamV1CustomersPushDataOptions,
713
+ type SeamV1CustomersPushDataParameters,
714
+ type SeamV1CustomersPushDataRequest,
715
+ } from './seam/v1/customers/index.js'
710
716
  import {
711
717
  SeamHttpSpaces,
712
718
  type SpacesAddAcsEntrancesOptions,
@@ -3616,6 +3622,19 @@ export class SeamHttpEndpoints {
3616
3622
  }
3617
3623
  }
3618
3624
 
3625
+ get '/seam/v1/customers/push_data'(): (
3626
+ parameters?: SeamV1CustomersPushDataParameters,
3627
+ options?: SeamV1CustomersPushDataOptions,
3628
+ ) => SeamV1CustomersPushDataRequest {
3629
+ const { client, defaults } = this
3630
+ return function seamV1CustomersPushData(
3631
+ ...args: Parameters<SeamHttpSeamV1Customers['pushData']>
3632
+ ): ReturnType<SeamHttpSeamV1Customers['pushData']> {
3633
+ const seam = SeamHttpSeamV1Customers.fromClient(client, defaults)
3634
+ return seam.pushData(...args)
3635
+ }
3636
+ }
3637
+
3619
3638
  get '/spaces/add_acs_entrances'(): (
3620
3639
  parameters?: SpacesAddAcsEntrancesParameters,
3621
3640
  options?: SpacesAddAcsEntrancesOptions,
@@ -4937,6 +4956,7 @@ export type SeamHttpEndpointMutationPaths =
4937
4956
  | '/seam/customer/v1/customers/open_portal'
4938
4957
  | '/seam/customer/v1/settings/update'
4939
4958
  | '/seam/customer/v1/spaces/create'
4959
+ | '/seam/v1/customers/push_data'
4940
4960
  | '/spaces/add_acs_entrances'
4941
4961
  | '/spaces/add_devices'
4942
4962
  | '/spaces/create'
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '1.100.0'
1
+ const seamapiJavascriptHttpVersion = '1.101.0'
2
2
 
3
3
  export default seamapiJavascriptHttpVersion