@seamapi/http 1.39.0 → 1.40.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 (132) hide show
  1. package/README.md +8 -8
  2. package/dist/connect.cjs +86 -1153
  3. package/dist/connect.cjs.map +1 -1
  4. package/dist/connect.d.cts +43 -298
  5. package/dist/index.cjs.map +1 -1
  6. package/lib/seam/connect/auth.js +3 -3
  7. package/lib/seam/connect/auth.js.map +1 -1
  8. package/lib/seam/connect/index.d.ts +0 -1
  9. package/lib/seam/connect/index.js +0 -1
  10. package/lib/seam/connect/index.js.map +1 -1
  11. package/lib/seam/connect/options.d.ts +9 -9
  12. package/lib/seam/connect/options.js +7 -7
  13. package/lib/seam/connect/options.js.map +1 -1
  14. package/lib/seam/connect/parse-options.d.ts +2 -2
  15. package/lib/seam/connect/parse-options.js +2 -2
  16. package/lib/seam/connect/parse-options.js.map +1 -1
  17. package/lib/seam/connect/routes/index.d.ts +2 -0
  18. package/lib/seam/connect/routes/index.js +2 -0
  19. package/lib/seam/connect/routes/index.js.map +1 -1
  20. package/lib/seam/connect/routes/seam/index.d.ts +0 -3
  21. package/lib/seam/connect/routes/seam/index.js +0 -3
  22. package/lib/seam/connect/routes/seam/index.js.map +1 -1
  23. package/lib/seam/connect/routes/seam-http-endpoints-without-workspace.d.ts +17 -0
  24. package/lib/seam/connect/routes/seam-http-endpoints-without-workspace.js +54 -0
  25. package/lib/seam/connect/routes/seam-http-endpoints-without-workspace.js.map +1 -0
  26. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +2 -16
  27. package/lib/seam/connect/routes/seam-http-endpoints.js +0 -95
  28. package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
  29. package/lib/seam/connect/routes/seam-http-without-workspace.d.ts +18 -0
  30. package/lib/seam/connect/routes/seam-http-without-workspace.js +47 -0
  31. package/lib/seam/connect/routes/seam-http-without-workspace.js.map +1 -0
  32. package/lib/version.d.ts +1 -1
  33. package/lib/version.js +1 -1
  34. package/package.json +3 -3
  35. package/src/lib/seam/connect/auth.ts +8 -8
  36. package/src/lib/seam/connect/index.ts +0 -1
  37. package/src/lib/seam/connect/options.ts +19 -19
  38. package/src/lib/seam/connect/parse-options.ts +4 -4
  39. package/src/lib/seam/connect/routes/index.ts +2 -0
  40. package/src/lib/seam/connect/routes/seam/index.ts +0 -3
  41. package/src/lib/seam/connect/routes/seam-http-endpoints-without-workspace.ts +126 -0
  42. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +0 -252
  43. package/src/lib/seam/connect/routes/seam-http-without-workspace.ts +96 -0
  44. package/src/lib/version.ts +1 -1
  45. package/lib/seam/connect/routes/seam/bridge/index.d.ts +0 -1
  46. package/lib/seam/connect/routes/seam/bridge/index.js +0 -6
  47. package/lib/seam/connect/routes/seam/bridge/index.js.map +0 -1
  48. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.d.ts +0 -86
  49. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.js +0 -150
  50. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.js.map +0 -1
  51. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.d.ts +0 -1
  52. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.js +0 -6
  53. package/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.js.map +0 -1
  54. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.d.ts +0 -34
  55. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.js +0 -102
  56. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.js.map +0 -1
  57. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.d.ts +0 -1
  58. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.js +0 -6
  59. package/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.js.map +0 -1
  60. package/lib/seam/connect/routes/seam/bridge/v1/index.d.ts +0 -3
  61. package/lib/seam/connect/routes/seam/bridge/v1/index.js +0 -8
  62. package/lib/seam/connect/routes/seam/bridge/v1/index.js.map +0 -1
  63. package/lib/seam/connect/routes/seam/bridge/v1/v1.d.ts +0 -23
  64. package/lib/seam/connect/routes/seam/bridge/v1/v1.js +0 -97
  65. package/lib/seam/connect/routes/seam/bridge/v1/v1.js.map +0 -1
  66. package/lib/seam/connect/routes/seam/instant-key/index.d.ts +0 -1
  67. package/lib/seam/connect/routes/seam/instant-key/index.js +0 -6
  68. package/lib/seam/connect/routes/seam/instant-key/index.js.map +0 -1
  69. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.d.ts +0 -34
  70. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.js +0 -102
  71. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.js.map +0 -1
  72. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.d.ts +0 -1
  73. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.js +0 -6
  74. package/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.js.map +0 -1
  75. package/lib/seam/connect/routes/seam/instant-key/v1/index.d.ts +0 -2
  76. package/lib/seam/connect/routes/seam/instant-key/v1/index.js +0 -7
  77. package/lib/seam/connect/routes/seam/instant-key/v1/index.js.map +0 -1
  78. package/lib/seam/connect/routes/seam/instant-key/v1/v1.d.ts +0 -21
  79. package/lib/seam/connect/routes/seam/instant-key/v1/v1.js +0 -93
  80. package/lib/seam/connect/routes/seam/instant-key/v1/v1.js.map +0 -1
  81. package/lib/seam/connect/routes/seam/mobile-sdk/index.d.ts +0 -1
  82. package/lib/seam/connect/routes/seam/mobile-sdk/index.js +0 -6
  83. package/lib/seam/connect/routes/seam/mobile-sdk/index.js.map +0 -1
  84. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.d.ts +0 -21
  85. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.js +0 -93
  86. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.js.map +0 -1
  87. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.d.ts +0 -34
  88. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.js +0 -102
  89. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.js.map +0 -1
  90. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.d.ts +0 -1
  91. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.js +0 -6
  92. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.js.map +0 -1
  93. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.d.ts +0 -2
  94. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.js +0 -7
  95. package/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.js.map +0 -1
  96. package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.d.ts +0 -3
  97. package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.js +0 -8
  98. package/lib/seam/connect/routes/seam/mobile-sdk/v1/index.js.map +0 -1
  99. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.d.ts +0 -1
  100. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.js +0 -6
  101. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.js.map +0 -1
  102. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.d.ts +0 -34
  103. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.js +0 -102
  104. package/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.js.map +0 -1
  105. package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.d.ts +0 -23
  106. package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.js +0 -97
  107. package/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.js.map +0 -1
  108. package/lib/seam/connect/seam-http-multi-workspace.d.ts +0 -12
  109. package/lib/seam/connect/seam-http-multi-workspace.js +0 -36
  110. package/lib/seam/connect/seam-http-multi-workspace.js.map +0 -1
  111. package/src/lib/seam/connect/routes/seam/bridge/index.ts +0 -6
  112. package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/bridge-client-sessions.ts +0 -398
  113. package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-client-sessions/index.ts +0 -6
  114. package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/bridge-connected-systems.ts +0 -215
  115. package/src/lib/seam/connect/routes/seam/bridge/v1/bridge-connected-systems/index.ts +0 -6
  116. package/src/lib/seam/connect/routes/seam/bridge/v1/index.ts +0 -8
  117. package/src/lib/seam/connect/routes/seam/bridge/v1/v1.ts +0 -184
  118. package/src/lib/seam/connect/routes/seam/instant-key/index.ts +0 -6
  119. package/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/client-sessions.ts +0 -219
  120. package/src/lib/seam/connect/routes/seam/instant-key/v1/client-sessions/index.ts +0 -6
  121. package/src/lib/seam/connect/routes/seam/instant-key/v1/index.ts +0 -7
  122. package/src/lib/seam/connect/routes/seam/instant-key/v1/v1.ts +0 -176
  123. package/src/lib/seam/connect/routes/seam/mobile-sdk/index.ts +0 -6
  124. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/acs.ts +0 -176
  125. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/credentials.ts +0 -215
  126. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/credentials/index.ts +0 -6
  127. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/acs/index.ts +0 -7
  128. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/index.ts +0 -8
  129. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/index.ts +0 -6
  130. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/phone-sessions/phone-sessions.ts +0 -215
  131. package/src/lib/seam/connect/routes/seam/mobile-sdk/v1/v1.ts +0 -181
  132. package/src/lib/seam/connect/seam-http-multi-workspace.ts +0 -80
@@ -1,184 +0,0 @@
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 { SeamHttpSeamBridgeV1BridgeClientSessions } from './bridge-client-sessions/index.js'
37
- import { SeamHttpSeamBridgeV1BridgeConnectedSystems } from './bridge-connected-systems/index.js'
38
-
39
- export class SeamHttpSeamBridgeV1 {
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
- ): SeamHttpSeamBridgeV1 {
60
- const constructorOptions = { ...options, client }
61
- if (!isSeamHttpOptionsWithClient(constructorOptions)) {
62
- throw new SeamHttpInvalidOptionsError('Missing client')
63
- }
64
- return new SeamHttpSeamBridgeV1(constructorOptions)
65
- }
66
-
67
- static fromApiKey(
68
- apiKey: SeamHttpOptionsWithApiKey['apiKey'],
69
- options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
70
- ): SeamHttpSeamBridgeV1 {
71
- const constructorOptions = { ...options, apiKey }
72
- if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
73
- throw new SeamHttpInvalidOptionsError('Missing apiKey')
74
- }
75
- return new SeamHttpSeamBridgeV1(constructorOptions)
76
- }
77
-
78
- static fromClientSessionToken(
79
- clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
80
- options: Omit<
81
- SeamHttpOptionsWithClientSessionToken,
82
- 'clientSessionToken'
83
- > = {},
84
- ): SeamHttpSeamBridgeV1 {
85
- const constructorOptions = { ...options, clientSessionToken }
86
- if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
87
- throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
88
- }
89
- return new SeamHttpSeamBridgeV1(constructorOptions)
90
- }
91
-
92
- static async fromPublishableKey(
93
- publishableKey: string,
94
- userIdentifierKey: string,
95
- options: SeamHttpFromPublishableKeyOptions = {},
96
- ): Promise<SeamHttpSeamBridgeV1> {
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 SeamHttpSeamBridgeV1.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 SeamHttpSeamBridgeV1.fromClientSessionToken(token, options)
110
- }
111
-
112
- static fromConsoleSessionToken(
113
- consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
114
- workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
115
- options: Omit<
116
- SeamHttpOptionsWithConsoleSessionToken,
117
- 'consoleSessionToken' | 'workspaceId'
118
- > = {},
119
- ): SeamHttpSeamBridgeV1 {
120
- const constructorOptions = { ...options, consoleSessionToken, workspaceId }
121
- if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
122
- throw new SeamHttpInvalidOptionsError(
123
- 'Missing consoleSessionToken or workspaceId',
124
- )
125
- }
126
- return new SeamHttpSeamBridgeV1(constructorOptions)
127
- }
128
-
129
- static fromPersonalAccessToken(
130
- personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
131
- workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
132
- options: Omit<
133
- SeamHttpOptionsWithPersonalAccessToken,
134
- 'personalAccessToken' | 'workspaceId'
135
- > = {},
136
- ): SeamHttpSeamBridgeV1 {
137
- const constructorOptions = { ...options, personalAccessToken, workspaceId }
138
- if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
139
- throw new SeamHttpInvalidOptionsError(
140
- 'Missing personalAccessToken or workspaceId',
141
- )
142
- }
143
- return new SeamHttpSeamBridgeV1(constructorOptions)
144
- }
145
-
146
- createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
147
- request: SeamHttpRequest<TResponse, TResponseKey>,
148
- ): SeamPaginator<TResponse, TResponseKey> {
149
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
150
- }
151
-
152
- async updateClientSessionToken(
153
- clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
154
- ): Promise<void> {
155
- const { headers } = this.client.defaults
156
- const authHeaders = getAuthHeadersForClientSessionToken({
157
- clientSessionToken,
158
- })
159
- for (const key of Object.keys(authHeaders)) {
160
- if (headers[key] == null) {
161
- throw new Error(
162
- 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
163
- )
164
- }
165
- }
166
- this.client.defaults.headers = { ...headers, ...authHeaders }
167
- const clientSessions = SeamHttpClientSessions.fromClient(this.client)
168
- await clientSessions.get()
169
- }
170
-
171
- get bridgeClientSessions(): SeamHttpSeamBridgeV1BridgeClientSessions {
172
- return SeamHttpSeamBridgeV1BridgeClientSessions.fromClient(
173
- this.client,
174
- this.defaults,
175
- )
176
- }
177
-
178
- get bridgeConnectedSystems(): SeamHttpSeamBridgeV1BridgeConnectedSystems {
179
- return SeamHttpSeamBridgeV1BridgeConnectedSystems.fromClient(
180
- this.client,
181
- this.defaults,
182
- )
183
- }
184
- }
@@ -1,6 +0,0 @@
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 './v1/index.js'
@@ -1,219 +0,0 @@
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 SeamHttpSeamInstantKeyV1ClientSessions {
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
- ): SeamHttpSeamInstantKeyV1ClientSessions {
60
- const constructorOptions = { ...options, client }
61
- if (!isSeamHttpOptionsWithClient(constructorOptions)) {
62
- throw new SeamHttpInvalidOptionsError('Missing client')
63
- }
64
- return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions)
65
- }
66
-
67
- static fromApiKey(
68
- apiKey: SeamHttpOptionsWithApiKey['apiKey'],
69
- options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
70
- ): SeamHttpSeamInstantKeyV1ClientSessions {
71
- const constructorOptions = { ...options, apiKey }
72
- if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
73
- throw new SeamHttpInvalidOptionsError('Missing apiKey')
74
- }
75
- return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions)
76
- }
77
-
78
- static fromClientSessionToken(
79
- clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
80
- options: Omit<
81
- SeamHttpOptionsWithClientSessionToken,
82
- 'clientSessionToken'
83
- > = {},
84
- ): SeamHttpSeamInstantKeyV1ClientSessions {
85
- const constructorOptions = { ...options, clientSessionToken }
86
- if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
87
- throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
88
- }
89
- return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions)
90
- }
91
-
92
- static async fromPublishableKey(
93
- publishableKey: string,
94
- userIdentifierKey: string,
95
- options: SeamHttpFromPublishableKeyOptions = {},
96
- ): Promise<SeamHttpSeamInstantKeyV1ClientSessions> {
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 SeamHttpSeamInstantKeyV1ClientSessions.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 SeamHttpSeamInstantKeyV1ClientSessions.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
- ): SeamHttpSeamInstantKeyV1ClientSessions {
123
- const constructorOptions = { ...options, consoleSessionToken, workspaceId }
124
- if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
125
- throw new SeamHttpInvalidOptionsError(
126
- 'Missing consoleSessionToken or workspaceId',
127
- )
128
- }
129
- return new SeamHttpSeamInstantKeyV1ClientSessions(constructorOptions)
130
- }
131
-
132
- static fromPersonalAccessToken(
133
- personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
134
- workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
135
- options: Omit<
136
- SeamHttpOptionsWithPersonalAccessToken,
137
- 'personalAccessToken' | 'workspaceId'
138
- > = {},
139
- ): SeamHttpSeamInstantKeyV1ClientSessions {
140
- const constructorOptions = { ...options, personalAccessToken, workspaceId }
141
- if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
142
- throw new SeamHttpInvalidOptionsError(
143
- 'Missing personalAccessToken or workspaceId',
144
- )
145
- }
146
- return new SeamHttpSeamInstantKeyV1ClientSessions(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
- exchangeShortCode(
175
- parameters?: SeamInstantKeyV1ClientSessionsExchangeShortCodeParameters,
176
- options: SeamInstantKeyV1ClientSessionsExchangeShortCodeOptions = {},
177
- ): SeamInstantKeyV1ClientSessionsExchangeShortCodeRequest {
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/instant_key/v1/client_sessions/exchange_short_code',
185
- method: 'POST',
186
- body: parameters,
187
- responseKey: 'client_session',
188
- options,
189
- })
190
- }
191
- }
192
-
193
- export type SeamInstantKeyV1ClientSessionsExchangeShortCodeParameters =
194
- RouteRequestBody<'/seam/instant_key/v1/client_sessions/exchange_short_code'>
195
-
196
- /**
197
- * @deprecated Use SeamInstantKeyV1ClientSessionsExchangeShortCodeParameters instead.
198
- */
199
- export type SeamInstantKeyV1ClientSessionsExchangeShortCodeBody =
200
- SeamInstantKeyV1ClientSessionsExchangeShortCodeParameters
201
-
202
- /**
203
- * @deprecated Use SeamInstantKeyV1ClientSessionsExchangeShortCodeRequest instead.
204
- */
205
- export type SeamInstantKeyV1ClientSessionsExchangeShortCodeResponse =
206
- SetNonNullable<
207
- Required<
208
- RouteResponse<'/seam/instant_key/v1/client_sessions/exchange_short_code'>
209
- >
210
- >
211
-
212
- export type SeamInstantKeyV1ClientSessionsExchangeShortCodeRequest =
213
- SeamHttpRequest<
214
- SeamInstantKeyV1ClientSessionsExchangeShortCodeResponse,
215
- 'client_session'
216
- >
217
-
218
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
219
- export interface SeamInstantKeyV1ClientSessionsExchangeShortCodeOptions {}
@@ -1,6 +0,0 @@
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 './client-sessions.js'
@@ -1,7 +0,0 @@
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 './client-sessions/index.js'
7
- export * from './v1.js'
@@ -1,176 +0,0 @@
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 { SeamHttpSeamInstantKeyV1ClientSessions } from './client-sessions/index.js'
37
-
38
- export class SeamHttpSeamInstantKeyV1 {
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
- if (!options.isUndocumentedApiEnabled) {
47
- throw new Error(
48
- 'Cannot use undocumented API without isUndocumentedApiEnabled',
49
- )
50
- }
51
- this.client = 'client' in options ? options.client : createClient(options)
52
- this.defaults = limitToSeamHttpRequestOptions(options)
53
- }
54
-
55
- static fromClient(
56
- client: SeamHttpOptionsWithClient['client'],
57
- options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
58
- ): SeamHttpSeamInstantKeyV1 {
59
- const constructorOptions = { ...options, client }
60
- if (!isSeamHttpOptionsWithClient(constructorOptions)) {
61
- throw new SeamHttpInvalidOptionsError('Missing client')
62
- }
63
- return new SeamHttpSeamInstantKeyV1(constructorOptions)
64
- }
65
-
66
- static fromApiKey(
67
- apiKey: SeamHttpOptionsWithApiKey['apiKey'],
68
- options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
69
- ): SeamHttpSeamInstantKeyV1 {
70
- const constructorOptions = { ...options, apiKey }
71
- if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
72
- throw new SeamHttpInvalidOptionsError('Missing apiKey')
73
- }
74
- return new SeamHttpSeamInstantKeyV1(constructorOptions)
75
- }
76
-
77
- static fromClientSessionToken(
78
- clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
79
- options: Omit<
80
- SeamHttpOptionsWithClientSessionToken,
81
- 'clientSessionToken'
82
- > = {},
83
- ): SeamHttpSeamInstantKeyV1 {
84
- const constructorOptions = { ...options, clientSessionToken }
85
- if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
86
- throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
87
- }
88
- return new SeamHttpSeamInstantKeyV1(constructorOptions)
89
- }
90
-
91
- static async fromPublishableKey(
92
- publishableKey: string,
93
- userIdentifierKey: string,
94
- options: SeamHttpFromPublishableKeyOptions = {},
95
- ): Promise<SeamHttpSeamInstantKeyV1> {
96
- warnOnInsecureuserIdentifierKey(userIdentifierKey)
97
- const clientOptions = parseOptions({ ...options, publishableKey })
98
- if (isSeamHttpOptionsWithClient(clientOptions)) {
99
- throw new SeamHttpInvalidOptionsError(
100
- 'The client option cannot be used with SeamHttpSeamInstantKeyV1.fromPublishableKey',
101
- )
102
- }
103
- const client = createClient(clientOptions)
104
- const clientSessions = SeamHttpClientSessions.fromClient(client)
105
- const { token } = await clientSessions.getOrCreate({
106
- user_identifier_key: userIdentifierKey,
107
- })
108
- return SeamHttpSeamInstantKeyV1.fromClientSessionToken(token, options)
109
- }
110
-
111
- static fromConsoleSessionToken(
112
- consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
113
- workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
114
- options: Omit<
115
- SeamHttpOptionsWithConsoleSessionToken,
116
- 'consoleSessionToken' | 'workspaceId'
117
- > = {},
118
- ): SeamHttpSeamInstantKeyV1 {
119
- const constructorOptions = { ...options, consoleSessionToken, workspaceId }
120
- if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
121
- throw new SeamHttpInvalidOptionsError(
122
- 'Missing consoleSessionToken or workspaceId',
123
- )
124
- }
125
- return new SeamHttpSeamInstantKeyV1(constructorOptions)
126
- }
127
-
128
- static fromPersonalAccessToken(
129
- personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
130
- workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
131
- options: Omit<
132
- SeamHttpOptionsWithPersonalAccessToken,
133
- 'personalAccessToken' | 'workspaceId'
134
- > = {},
135
- ): SeamHttpSeamInstantKeyV1 {
136
- const constructorOptions = { ...options, personalAccessToken, workspaceId }
137
- if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
138
- throw new SeamHttpInvalidOptionsError(
139
- 'Missing personalAccessToken or workspaceId',
140
- )
141
- }
142
- return new SeamHttpSeamInstantKeyV1(constructorOptions)
143
- }
144
-
145
- createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
146
- request: SeamHttpRequest<TResponse, TResponseKey>,
147
- ): SeamPaginator<TResponse, TResponseKey> {
148
- return new SeamPaginator<TResponse, TResponseKey>(this, request)
149
- }
150
-
151
- async updateClientSessionToken(
152
- clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
153
- ): Promise<void> {
154
- const { headers } = this.client.defaults
155
- const authHeaders = getAuthHeadersForClientSessionToken({
156
- clientSessionToken,
157
- })
158
- for (const key of Object.keys(authHeaders)) {
159
- if (headers[key] == null) {
160
- throw new Error(
161
- 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
162
- )
163
- }
164
- }
165
- this.client.defaults.headers = { ...headers, ...authHeaders }
166
- const clientSessions = SeamHttpClientSessions.fromClient(this.client)
167
- await clientSessions.get()
168
- }
169
-
170
- get clientSessions(): SeamHttpSeamInstantKeyV1ClientSessions {
171
- return SeamHttpSeamInstantKeyV1ClientSessions.fromClient(
172
- this.client,
173
- this.defaults,
174
- )
175
- }
176
- }
@@ -1,6 +0,0 @@
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 './v1/index.js'