@seamapi/http 1.40.1 → 1.42.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 (106) hide show
  1. package/dist/connect.cjs +638 -213
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +256 -224
  4. package/lib/seam/connect/resolve-action-attempt.d.ts +32 -168
  5. package/lib/seam/connect/routes/access-methods/access-methods.d.ts +12 -0
  6. package/lib/seam/connect/routes/access-methods/access-methods.js +9 -0
  7. package/lib/seam/connect/routes/access-methods/access-methods.js.map +1 -1
  8. package/lib/seam/connect/routes/acs/encoders/encoders.d.ts +0 -12
  9. package/lib/seam/connect/routes/acs/encoders/encoders.js +0 -9
  10. package/lib/seam/connect/routes/acs/encoders/encoders.js.map +1 -1
  11. package/lib/seam/connect/routes/customers/customers.d.ts +47 -0
  12. package/lib/seam/connect/routes/customers/customers.js +105 -0
  13. package/lib/seam/connect/routes/customers/customers.js.map +1 -0
  14. package/lib/seam/connect/routes/customers/index.d.ts +1 -0
  15. package/lib/seam/connect/routes/{unstable-partner/resources → customers}/index.js +1 -1
  16. package/lib/seam/connect/routes/customers/index.js.map +1 -0
  17. package/lib/seam/connect/routes/devices/simulate/simulate.d.ts +1 -1
  18. package/lib/seam/connect/routes/index.d.ts +1 -0
  19. package/lib/seam/connect/routes/index.js +1 -0
  20. package/lib/seam/connect/routes/index.js.map +1 -1
  21. package/lib/seam/connect/routes/phones/simulate/simulate.d.ts +1 -1
  22. package/lib/seam/connect/routes/seam/customer/index.d.ts +1 -0
  23. package/lib/seam/connect/routes/seam/{partner/v1/resources → customer}/index.js +1 -1
  24. package/lib/seam/connect/routes/seam/customer/index.js.map +1 -0
  25. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.d.ts +34 -0
  26. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.js +102 -0
  27. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.js.map +1 -0
  28. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.d.ts +1 -0
  29. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.js +6 -0
  30. package/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.js.map +1 -0
  31. package/lib/seam/connect/routes/seam/customer/v1/automations/automations.d.ts +60 -0
  32. package/lib/seam/connect/routes/seam/customer/v1/automations/automations.js +126 -0
  33. package/lib/seam/connect/routes/seam/customer/v1/automations/automations.js.map +1 -0
  34. package/lib/seam/connect/routes/seam/customer/v1/automations/index.d.ts +1 -0
  35. package/lib/seam/connect/routes/seam/customer/v1/automations/index.js +6 -0
  36. package/lib/seam/connect/routes/seam/customer/v1/automations/index.js.map +1 -0
  37. package/lib/seam/connect/routes/seam/customer/v1/index.d.ts +5 -0
  38. package/lib/seam/connect/routes/seam/customer/v1/index.js +10 -0
  39. package/lib/seam/connect/routes/seam/customer/v1/index.js.map +1 -0
  40. package/lib/seam/connect/routes/seam/customer/v1/portals/index.d.ts +1 -0
  41. package/lib/seam/connect/routes/seam/customer/v1/portals/index.js +6 -0
  42. package/lib/seam/connect/routes/seam/customer/v1/portals/index.js.map +1 -0
  43. package/lib/seam/connect/routes/{unstable-partner/resources/resources.d.ts → seam/customer/v1/portals/portals.d.ts} +20 -20
  44. package/lib/seam/connect/routes/{unstable-partner/resources/resources.js → seam/customer/v1/portals/portals.js} +21 -21
  45. package/lib/seam/connect/routes/{unstable-partner/resources/resources.js.map → seam/customer/v1/portals/portals.js.map} +1 -1
  46. package/lib/seam/connect/routes/seam/customer/v1/settings/index.d.ts +1 -0
  47. package/lib/seam/connect/routes/seam/customer/v1/settings/index.js +6 -0
  48. package/lib/seam/connect/routes/seam/customer/v1/settings/index.js.map +1 -0
  49. package/lib/seam/connect/routes/seam/{partner/v1/resources/resources.d.ts → customer/v1/settings/settings.d.ts} +15 -15
  50. package/lib/seam/connect/routes/seam/{partner/v1/resources/resources.js → customer/v1/settings/settings.js} +14 -14
  51. package/lib/seam/connect/routes/seam/customer/v1/settings/settings.js.map +1 -0
  52. package/lib/seam/connect/routes/seam/{partner → customer}/v1/v1.d.ts +15 -11
  53. package/lib/seam/connect/routes/seam/{partner → customer}/v1/v1.js +23 -15
  54. package/lib/seam/connect/routes/seam/customer/v1/v1.js.map +1 -0
  55. package/lib/seam/connect/routes/seam/index.d.ts +1 -0
  56. package/lib/seam/connect/routes/seam/index.js +1 -0
  57. package/lib/seam/connect/routes/seam/index.js.map +1 -1
  58. package/lib/seam/connect/routes/seam/partner/v1/index.d.ts +0 -2
  59. package/lib/seam/connect/routes/seam/partner/v1/index.js +0 -2
  60. package/lib/seam/connect/routes/seam/partner/v1/index.js.map +1 -1
  61. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +19 -10
  62. package/lib/seam/connect/routes/seam-http-endpoints.js +84 -27
  63. package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
  64. package/lib/seam/connect/routes/seam-http.d.ts +2 -0
  65. package/lib/seam/connect/routes/seam-http.js +4 -0
  66. package/lib/seam/connect/routes/seam-http.js.map +1 -1
  67. package/lib/seam/connect/routes/unstable-partner/index.d.ts +0 -1
  68. package/lib/seam/connect/routes/unstable-partner/index.js +0 -1
  69. package/lib/seam/connect/routes/unstable-partner/index.js.map +1 -1
  70. package/lib/seam/connect/routes/unstable-partner/unstable-partner.d.ts +0 -2
  71. package/lib/seam/connect/routes/unstable-partner/unstable-partner.js +0 -4
  72. package/lib/seam/connect/routes/unstable-partner/unstable-partner.js.map +1 -1
  73. package/lib/version.d.ts +1 -1
  74. package/lib/version.js +1 -1
  75. package/package.json +3 -3
  76. package/src/lib/seam/connect/routes/access-methods/access-methods.ts +38 -0
  77. package/src/lib/seam/connect/routes/acs/encoders/encoders.ts +0 -39
  78. package/src/lib/seam/connect/routes/customers/customers.ts +234 -0
  79. package/src/lib/seam/connect/routes/{seam/partner/v1/resources → customers}/index.ts +1 -1
  80. package/src/lib/seam/connect/routes/devices/simulate/simulate.ts +1 -1
  81. package/src/lib/seam/connect/routes/index.ts +1 -0
  82. package/src/lib/seam/connect/routes/phones/simulate/simulate.ts +1 -1
  83. package/src/lib/seam/connect/routes/{unstable-partner/resources → seam/customer}/index.ts +1 -1
  84. package/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/automation-runs.ts +215 -0
  85. package/src/lib/seam/connect/routes/seam/customer/v1/automation-runs/index.ts +6 -0
  86. package/src/lib/seam/connect/routes/seam/customer/v1/automations/automations.ts +303 -0
  87. package/src/lib/seam/connect/routes/seam/customer/v1/automations/index.ts +6 -0
  88. package/src/lib/seam/connect/routes/seam/customer/v1/index.ts +10 -0
  89. package/src/lib/seam/connect/routes/seam/customer/v1/portals/index.ts +6 -0
  90. package/src/lib/seam/connect/routes/seam/{partner/v1/resources/resources.ts → customer/v1/portals/portals.ts} +31 -32
  91. package/src/lib/seam/connect/routes/seam/customer/v1/settings/index.ts +6 -0
  92. package/src/lib/seam/connect/routes/{unstable-partner/resources/resources.ts → seam/customer/v1/settings/settings.ts} +30 -33
  93. package/src/lib/seam/connect/routes/seam/{partner → customer}/v1/v1.ts +33 -20
  94. package/src/lib/seam/connect/routes/seam/index.ts +1 -0
  95. package/src/lib/seam/connect/routes/seam/partner/v1/index.ts +0 -2
  96. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +216 -72
  97. package/src/lib/seam/connect/routes/seam-http.ts +5 -0
  98. package/src/lib/seam/connect/routes/unstable-partner/index.ts +0 -1
  99. package/src/lib/seam/connect/routes/unstable-partner/unstable-partner.ts +0 -8
  100. package/src/lib/version.ts +1 -1
  101. package/lib/seam/connect/routes/seam/partner/v1/resources/index.d.ts +0 -1
  102. package/lib/seam/connect/routes/seam/partner/v1/resources/index.js.map +0 -1
  103. package/lib/seam/connect/routes/seam/partner/v1/resources/resources.js.map +0 -1
  104. package/lib/seam/connect/routes/seam/partner/v1/v1.js.map +0 -1
  105. package/lib/seam/connect/routes/unstable-partner/resources/index.d.ts +0 -1
  106. package/lib/seam/connect/routes/unstable-partner/resources/index.js.map +0 -1
@@ -0,0 +1,234 @@
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 SeamHttpCustomers {
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
+ ): SeamHttpCustomers {
55
+ const constructorOptions = { ...options, client }
56
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
57
+ throw new SeamHttpInvalidOptionsError('Missing client')
58
+ }
59
+ return new SeamHttpCustomers(constructorOptions)
60
+ }
61
+
62
+ static fromApiKey(
63
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
64
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
65
+ ): SeamHttpCustomers {
66
+ const constructorOptions = { ...options, apiKey }
67
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
68
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
69
+ }
70
+ return new SeamHttpCustomers(constructorOptions)
71
+ }
72
+
73
+ static fromClientSessionToken(
74
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
75
+ options: Omit<
76
+ SeamHttpOptionsWithClientSessionToken,
77
+ 'clientSessionToken'
78
+ > = {},
79
+ ): SeamHttpCustomers {
80
+ const constructorOptions = { ...options, clientSessionToken }
81
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
82
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
83
+ }
84
+ return new SeamHttpCustomers(constructorOptions)
85
+ }
86
+
87
+ static async fromPublishableKey(
88
+ publishableKey: string,
89
+ userIdentifierKey: string,
90
+ options: SeamHttpFromPublishableKeyOptions = {},
91
+ ): Promise<SeamHttpCustomers> {
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 SeamHttpCustomers.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 SeamHttpCustomers.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
+ ): SeamHttpCustomers {
115
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
116
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
117
+ throw new SeamHttpInvalidOptionsError(
118
+ 'Missing consoleSessionToken or workspaceId',
119
+ )
120
+ }
121
+ return new SeamHttpCustomers(constructorOptions)
122
+ }
123
+
124
+ static fromPersonalAccessToken(
125
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
126
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
127
+ options: Omit<
128
+ SeamHttpOptionsWithPersonalAccessToken,
129
+ 'personalAccessToken' | 'workspaceId'
130
+ > = {},
131
+ ): SeamHttpCustomers {
132
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
133
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ 'Missing personalAccessToken or workspaceId',
136
+ )
137
+ }
138
+ return new SeamHttpCustomers(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
+ createPortal(
167
+ parameters?: CustomersCreatePortalParameters,
168
+ options: CustomersCreatePortalOptions = {},
169
+ ): CustomersCreatePortalRequest {
170
+ return new SeamHttpRequest(this, {
171
+ pathname: '/customers/create_portal',
172
+ method: 'POST',
173
+ body: parameters,
174
+ responseKey: 'magic_link',
175
+ options,
176
+ })
177
+ }
178
+
179
+ pushData(
180
+ parameters?: CustomersPushDataParameters,
181
+ options: CustomersPushDataOptions = {},
182
+ ): CustomersPushDataRequest {
183
+ return new SeamHttpRequest(this, {
184
+ pathname: '/customers/push_data',
185
+ method: 'POST',
186
+ body: parameters,
187
+ responseKey: undefined,
188
+ options,
189
+ })
190
+ }
191
+ }
192
+
193
+ export type CustomersCreatePortalParameters =
194
+ RouteRequestBody<'/customers/create_portal'>
195
+
196
+ /**
197
+ * @deprecated Use CustomersCreatePortalParameters instead.
198
+ */
199
+ export type CustomersCreatePortalBody = CustomersCreatePortalParameters
200
+
201
+ /**
202
+ * @deprecated Use CustomersCreatePortalRequest instead.
203
+ */
204
+ export type CustomersCreatePortalResponse = SetNonNullable<
205
+ Required<RouteResponse<'/customers/create_portal'>>
206
+ >
207
+
208
+ export type CustomersCreatePortalRequest = SeamHttpRequest<
209
+ CustomersCreatePortalResponse,
210
+ 'magic_link'
211
+ >
212
+
213
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
214
+ export interface CustomersCreatePortalOptions {}
215
+
216
+ export type CustomersPushDataParameters =
217
+ RouteRequestBody<'/customers/push_data'>
218
+
219
+ /**
220
+ * @deprecated Use CustomersPushDataParameters instead.
221
+ */
222
+ export type CustomersPushDataBody = CustomersPushDataParameters
223
+
224
+ /**
225
+ * @deprecated Use CustomersPushDataRequest instead.
226
+ */
227
+ export type CustomersPushDataResponse = SetNonNullable<
228
+ Required<RouteResponse<'/customers/push_data'>>
229
+ >
230
+
231
+ export type CustomersPushDataRequest = SeamHttpRequest<void, undefined>
232
+
233
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
234
+ export interface CustomersPushDataOptions {}
@@ -3,4 +3,4 @@
3
3
  * Do not edit this file or add other files to this directory.
4
4
  */
5
5
 
6
- export * from './resources.js'
6
+ export * from './customers.js'
@@ -249,7 +249,7 @@ export type DevicesSimulateRemoveParameters =
249
249
  /**
250
250
  * @deprecated Use DevicesSimulateRemoveParameters instead.
251
251
  */
252
- export type DevicesSimulateRemoveParams = DevicesSimulateRemoveParameters
252
+ export type DevicesSimulateRemoveBody = DevicesSimulateRemoveParameters
253
253
 
254
254
  /**
255
255
  * @deprecated Use DevicesSimulateRemoveRequest instead.
@@ -12,6 +12,7 @@ export * from './bridges/index.js'
12
12
  export * from './client-sessions/index.js'
13
13
  export * from './connect-webviews/index.js'
14
14
  export * from './connected-accounts/index.js'
15
+ export * from './customers/index.js'
15
16
  export * from './devices/index.js'
16
17
  export * from './events/index.js'
17
18
  export * from './locks/index.js'
@@ -183,7 +183,7 @@ export type PhonesSimulateCreateSandboxPhoneParameters =
183
183
  /**
184
184
  * @deprecated Use PhonesSimulateCreateSandboxPhoneParameters instead.
185
185
  */
186
- export type PhonesSimulateCreateSandboxPhoneParams =
186
+ export type PhonesSimulateCreateSandboxPhoneBody =
187
187
  PhonesSimulateCreateSandboxPhoneParameters
188
188
 
189
189
  /**
@@ -3,4 +3,4 @@
3
3
  * Do not edit this file or add other files to this directory.
4
4
  */
5
5
 
6
- export * from './resources.js'
6
+ export * from './v1/index.js'
@@ -0,0 +1,215 @@
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 SeamHttpSeamCustomerV1AutomationRuns {
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
+ if (!options.isUndocumentedApiEnabled) {
48
+ throw new Error(
49
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
50
+ )
51
+ }
52
+ this.client = 'client' in options ? options.client : createClient(options)
53
+ this.defaults = limitToSeamHttpRequestOptions(options)
54
+ }
55
+
56
+ static fromClient(
57
+ client: SeamHttpOptionsWithClient['client'],
58
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
59
+ ): SeamHttpSeamCustomerV1AutomationRuns {
60
+ const constructorOptions = { ...options, client }
61
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing client')
63
+ }
64
+ return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions)
65
+ }
66
+
67
+ static fromApiKey(
68
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
69
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
70
+ ): SeamHttpSeamCustomerV1AutomationRuns {
71
+ const constructorOptions = { ...options, apiKey }
72
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
73
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
74
+ }
75
+ return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions)
76
+ }
77
+
78
+ static fromClientSessionToken(
79
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
80
+ options: Omit<
81
+ SeamHttpOptionsWithClientSessionToken,
82
+ 'clientSessionToken'
83
+ > = {},
84
+ ): SeamHttpSeamCustomerV1AutomationRuns {
85
+ const constructorOptions = { ...options, clientSessionToken }
86
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
87
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
88
+ }
89
+ return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions)
90
+ }
91
+
92
+ static async fromPublishableKey(
93
+ publishableKey: string,
94
+ userIdentifierKey: string,
95
+ options: SeamHttpFromPublishableKeyOptions = {},
96
+ ): Promise<SeamHttpSeamCustomerV1AutomationRuns> {
97
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
98
+ const clientOptions = parseOptions({ ...options, publishableKey })
99
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
100
+ throw new SeamHttpInvalidOptionsError(
101
+ 'The client option cannot be used with SeamHttpSeamCustomerV1AutomationRuns.fromPublishableKey',
102
+ )
103
+ }
104
+ const client = createClient(clientOptions)
105
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
106
+ const { token } = await clientSessions.getOrCreate({
107
+ user_identifier_key: userIdentifierKey,
108
+ })
109
+ return SeamHttpSeamCustomerV1AutomationRuns.fromClientSessionToken(
110
+ token,
111
+ options,
112
+ )
113
+ }
114
+
115
+ static fromConsoleSessionToken(
116
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
117
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
118
+ options: Omit<
119
+ SeamHttpOptionsWithConsoleSessionToken,
120
+ 'consoleSessionToken' | 'workspaceId'
121
+ > = {},
122
+ ): SeamHttpSeamCustomerV1AutomationRuns {
123
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
124
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
125
+ throw new SeamHttpInvalidOptionsError(
126
+ 'Missing consoleSessionToken or workspaceId',
127
+ )
128
+ }
129
+ return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions)
130
+ }
131
+
132
+ static fromPersonalAccessToken(
133
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
134
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
135
+ options: Omit<
136
+ SeamHttpOptionsWithPersonalAccessToken,
137
+ 'personalAccessToken' | 'workspaceId'
138
+ > = {},
139
+ ): SeamHttpSeamCustomerV1AutomationRuns {
140
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
141
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
142
+ throw new SeamHttpInvalidOptionsError(
143
+ 'Missing personalAccessToken or workspaceId',
144
+ )
145
+ }
146
+ return new SeamHttpSeamCustomerV1AutomationRuns(constructorOptions)
147
+ }
148
+
149
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
150
+ request: SeamHttpRequest<TResponse, TResponseKey>,
151
+ ): SeamPaginator<TResponse, TResponseKey> {
152
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
153
+ }
154
+
155
+ async updateClientSessionToken(
156
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
157
+ ): Promise<void> {
158
+ const { headers } = this.client.defaults
159
+ const authHeaders = getAuthHeadersForClientSessionToken({
160
+ clientSessionToken,
161
+ })
162
+ for (const key of Object.keys(authHeaders)) {
163
+ if (headers[key] == null) {
164
+ throw new Error(
165
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
166
+ )
167
+ }
168
+ }
169
+ this.client.defaults.headers = { ...headers, ...authHeaders }
170
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
171
+ await clientSessions.get()
172
+ }
173
+
174
+ list(
175
+ parameters?: SeamCustomerV1AutomationRunsListParameters,
176
+ options: SeamCustomerV1AutomationRunsListOptions = {},
177
+ ): SeamCustomerV1AutomationRunsListRequest {
178
+ if (!this.defaults.isUndocumentedApiEnabled) {
179
+ throw new Error(
180
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
181
+ )
182
+ }
183
+ return new SeamHttpRequest(this, {
184
+ pathname: '/seam/customer/v1/automation_runs/list',
185
+ method: 'POST',
186
+ body: parameters,
187
+ responseKey: 'automation_runs',
188
+ options,
189
+ })
190
+ }
191
+ }
192
+
193
+ export type SeamCustomerV1AutomationRunsListParameters =
194
+ RouteRequestBody<'/seam/customer/v1/automation_runs/list'>
195
+
196
+ /**
197
+ * @deprecated Use SeamCustomerV1AutomationRunsListParameters instead.
198
+ */
199
+ export type SeamCustomerV1AutomationRunsListParams =
200
+ SeamCustomerV1AutomationRunsListParameters
201
+
202
+ /**
203
+ * @deprecated Use SeamCustomerV1AutomationRunsListRequest instead.
204
+ */
205
+ export type SeamCustomerV1AutomationRunsListResponse = SetNonNullable<
206
+ Required<RouteResponse<'/seam/customer/v1/automation_runs/list'>>
207
+ >
208
+
209
+ export type SeamCustomerV1AutomationRunsListRequest = SeamHttpRequest<
210
+ SeamCustomerV1AutomationRunsListResponse,
211
+ 'automation_runs'
212
+ >
213
+
214
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
215
+ export interface SeamCustomerV1AutomationRunsListOptions {}
@@ -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 './automation-runs.js'