@seamapi/http 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/connect.cjs +314 -141
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +89 -75
- package/lib/seam/connect/client.d.ts +0 -1
- package/lib/seam/connect/client.js +0 -2
- package/lib/seam/connect/client.js.map +1 -1
- package/lib/seam/connect/options.d.ts +7 -3
- package/lib/seam/connect/options.js +2 -1
- package/lib/seam/connect/options.js.map +1 -1
- package/lib/seam/connect/parse-options.d.ts +9 -3
- package/lib/seam/connect/parse-options.js +25 -2
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +2 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.js +7 -3
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +2 -1
- package/lib/seam/connect/routes/access-codes.js +8 -4
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +2 -1
- package/lib/seam/connect/routes/acs-access-groups.js +7 -3
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credentials.js +7 -3
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +2 -1
- package/lib/seam/connect/routes/acs-systems.js +7 -3
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +2 -1
- package/lib/seam/connect/routes/acs-users.js +7 -3
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/acs.d.ts +2 -1
- package/lib/seam/connect/routes/acs.js +11 -7
- package/lib/seam/connect/routes/acs.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +4 -8
- package/lib/seam/connect/routes/action-attempts.js +15 -7
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +2 -1
- package/lib/seam/connect/routes/client-sessions.js +7 -3
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +2 -1
- package/lib/seam/connect/routes/connect-webviews.js +7 -3
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +2 -1
- package/lib/seam/connect/routes/connected-accounts.js +7 -3
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +2 -1
- package/lib/seam/connect/routes/devices-unmanaged.js +7 -3
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +2 -1
- package/lib/seam/connect/routes/devices.js +8 -4
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +2 -1
- package/lib/seam/connect/routes/events.js +7 -3
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +6 -14
- package/lib/seam/connect/routes/locks.js +22 -10
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +2 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +7 -3
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors.d.ts +2 -1
- package/lib/seam/connect/routes/noise-sensors.js +8 -4
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +2 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +7 -3
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +2 -1
- package/lib/seam/connect/routes/thermostats.js +8 -4
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +2 -1
- package/lib/seam/connect/routes/user-identities.js +7 -3
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +2 -1
- package/lib/seam/connect/routes/webhooks.js +7 -3
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +2 -1
- package/lib/seam/connect/routes/workspaces.js +7 -3
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http-multi-workspace.d.ts +2 -1
- package/lib/seam/connect/seam-http-multi-workspace.js +5 -4
- package/lib/seam/connect/seam-http-multi-workspace.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +2 -1
- package/lib/seam/connect/seam-http.js +21 -17
- package/lib/seam/connect/seam-http.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/lib/seam/connect/client.ts +0 -3
- package/src/lib/seam/connect/options.ts +11 -4
- package/src/lib/seam/connect/parse-options.ts +43 -4
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +14 -3
- package/src/lib/seam/connect/routes/access-codes.ts +15 -4
- package/src/lib/seam/connect/routes/acs-access-groups.ts +14 -3
- package/src/lib/seam/connect/routes/acs-credentials.ts +14 -3
- package/src/lib/seam/connect/routes/acs-systems.ts +14 -3
- package/src/lib/seam/connect/routes/acs-users.ts +14 -3
- package/src/lib/seam/connect/routes/acs.ts +18 -7
- package/src/lib/seam/connect/routes/action-attempts.ts +26 -16
- package/src/lib/seam/connect/routes/client-sessions.ts +14 -3
- package/src/lib/seam/connect/routes/connect-webviews.ts +14 -3
- package/src/lib/seam/connect/routes/connected-accounts.ts +14 -3
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +14 -3
- package/src/lib/seam/connect/routes/devices.ts +15 -4
- package/src/lib/seam/connect/routes/events.ts +14 -3
- package/src/lib/seam/connect/routes/locks.ts +38 -26
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +14 -3
- package/src/lib/seam/connect/routes/noise-sensors.ts +18 -4
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +14 -3
- package/src/lib/seam/connect/routes/thermostats.ts +18 -4
- package/src/lib/seam/connect/routes/user-identities.ts +14 -3
- package/src/lib/seam/connect/routes/webhooks.ts +14 -3
- package/src/lib/seam/connect/routes/workspaces.ts +14 -3
- package/src/lib/seam/connect/seam-http-multi-workspace.ts +7 -4
- package/src/lib/seam/connect/seam-http.ts +25 -17
- package/src/lib/version.ts +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Client, ClientOptions } from './client.js'
|
|
2
|
+
import { isSeamHttpRequestOption } from './parse-options.js'
|
|
3
|
+
import type { ResolveActionAttemptOptions } from './resolve-action-attempt.js'
|
|
2
4
|
|
|
3
5
|
export type SeamHttpMultiWorkspaceOptions =
|
|
4
6
|
| SeamHttpMultiWorkspaceOptionsWithClient
|
|
@@ -13,16 +15,21 @@ export type SeamHttpOptions =
|
|
|
13
15
|
| SeamHttpOptionsWithConsoleSessionToken
|
|
14
16
|
| SeamHttpOptionsWithPersonalAccessToken
|
|
15
17
|
|
|
16
|
-
interface SeamHttpCommonOptions extends ClientOptions {
|
|
18
|
+
interface SeamHttpCommonOptions extends ClientOptions, SeamHttpRequestOptions {
|
|
17
19
|
endpoint?: string
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
export interface SeamHttpRequestOptions {
|
|
23
|
+
waitForActionAttempt?: boolean | ResolveActionAttemptOptions
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
export interface SeamHttpFromPublishableKeyOptions
|
|
21
27
|
extends SeamHttpCommonOptions {}
|
|
22
28
|
|
|
23
29
|
export interface SeamHttpOptionsFromEnv extends SeamHttpCommonOptions {}
|
|
24
30
|
|
|
25
|
-
export interface SeamHttpMultiWorkspaceOptionsWithClient
|
|
31
|
+
export interface SeamHttpMultiWorkspaceOptionsWithClient
|
|
32
|
+
extends SeamHttpRequestOptions {
|
|
26
33
|
client: Client
|
|
27
34
|
}
|
|
28
35
|
|
|
@@ -31,7 +38,7 @@ export const isSeamHttpMultiWorkspaceOptionsWithClient = (
|
|
|
31
38
|
): options is SeamHttpMultiWorkspaceOptionsWithClient =>
|
|
32
39
|
isSeamHttpOptionsWithClient(options)
|
|
33
40
|
|
|
34
|
-
export interface SeamHttpOptionsWithClient {
|
|
41
|
+
export interface SeamHttpOptionsWithClient extends SeamHttpRequestOptions {
|
|
35
42
|
client: Client
|
|
36
43
|
}
|
|
37
44
|
|
|
@@ -42,7 +49,7 @@ export const isSeamHttpOptionsWithClient = (
|
|
|
42
49
|
if (options.client == null) return false
|
|
43
50
|
|
|
44
51
|
const keys = Object.keys(options).filter((k) => k !== 'client')
|
|
45
|
-
if (keys.length > 0) {
|
|
52
|
+
if (keys.filter((k) => !isSeamHttpRequestOption(k)).length > 0) {
|
|
46
53
|
throw new SeamHttpInvalidOptionsError(
|
|
47
54
|
`The client option cannot be used with any other option, but received: ${keys.join(
|
|
48
55
|
', ',
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import version from 'lib/version.js'
|
|
2
2
|
|
|
3
3
|
import { getAuthHeaders } from './auth.js'
|
|
4
|
-
import type { ClientOptions } from './client.js'
|
|
4
|
+
import type { Client, ClientOptions } from './client.js'
|
|
5
5
|
import {
|
|
6
6
|
isSeamHttpMultiWorkspaceOptionsWithClient,
|
|
7
7
|
isSeamHttpOptionsWithClient,
|
|
8
8
|
isSeamHttpOptionsWithClientSessionToken,
|
|
9
9
|
type SeamHttpMultiWorkspaceOptions,
|
|
10
10
|
type SeamHttpOptions,
|
|
11
|
+
type SeamHttpRequestOptions,
|
|
11
12
|
} from './options.js'
|
|
12
13
|
|
|
13
14
|
const defaultEndpoint = 'https://connect.getseam.com'
|
|
@@ -21,15 +22,20 @@ export type Options =
|
|
|
21
22
|
| SeamHttpMultiWorkspaceOptions
|
|
22
23
|
| (SeamHttpOptions & { publishableKey?: string })
|
|
23
24
|
|
|
25
|
+
type ParsedOptions = Required<
|
|
26
|
+
(ClientOptions | { client: Client }) & SeamHttpRequestOptions
|
|
27
|
+
>
|
|
28
|
+
|
|
24
29
|
export const parseOptions = (
|
|
25
30
|
apiKeyOrOptions: string | Options,
|
|
26
|
-
):
|
|
31
|
+
): ParsedOptions => {
|
|
27
32
|
const options = getNormalizedOptions(apiKeyOrOptions)
|
|
28
33
|
|
|
29
34
|
if (isSeamHttpOptionsWithClient(options)) return options
|
|
30
35
|
if (isSeamHttpMultiWorkspaceOptionsWithClient(options)) return options
|
|
31
36
|
|
|
32
37
|
return {
|
|
38
|
+
...options,
|
|
33
39
|
axiosOptions: {
|
|
34
40
|
baseURL: options.endpoint ?? getEndpointFromEnv() ?? defaultEndpoint,
|
|
35
41
|
withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
|
|
@@ -48,13 +54,22 @@ export const parseOptions = (
|
|
|
48
54
|
|
|
49
55
|
const getNormalizedOptions = (
|
|
50
56
|
apiKeyOrOptions: string | Options,
|
|
51
|
-
): SeamHttpOptions => {
|
|
57
|
+
): SeamHttpOptions & Required<SeamHttpRequestOptions> => {
|
|
52
58
|
const options =
|
|
53
59
|
typeof apiKeyOrOptions === 'string'
|
|
54
60
|
? { apiKey: apiKeyOrOptions }
|
|
55
61
|
: apiKeyOrOptions
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
const requestOptions = {
|
|
64
|
+
waitForActionAttempt: options.waitForActionAttempt ?? false,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (isSeamHttpOptionsWithClient(options)) {
|
|
68
|
+
return {
|
|
69
|
+
...options,
|
|
70
|
+
...requestOptions,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
|
|
59
74
|
const apiKey =
|
|
60
75
|
'apiKey' in options ? options.apiKey : getApiKeyFromEnv(options)
|
|
@@ -62,6 +77,7 @@ const getNormalizedOptions = (
|
|
|
62
77
|
return {
|
|
63
78
|
...options,
|
|
64
79
|
...(apiKey != null ? { apiKey } : {}),
|
|
80
|
+
...requestOptions,
|
|
65
81
|
}
|
|
66
82
|
}
|
|
67
83
|
|
|
@@ -80,3 +96,26 @@ const getEndpointFromEnv = (): string | null | undefined => {
|
|
|
80
96
|
globalThis.process?.env?.SEAM_API_URL
|
|
81
97
|
)
|
|
82
98
|
}
|
|
99
|
+
|
|
100
|
+
export const limitToSeamHttpRequestOptions = (
|
|
101
|
+
options: Required<SeamHttpRequestOptions>,
|
|
102
|
+
): Required<SeamHttpRequestOptions> => {
|
|
103
|
+
return Object.keys(options)
|
|
104
|
+
.filter(isSeamHttpRequestOption)
|
|
105
|
+
.reduce(
|
|
106
|
+
(obj, key) => ({
|
|
107
|
+
...obj,
|
|
108
|
+
[key]: options[key],
|
|
109
|
+
}),
|
|
110
|
+
{},
|
|
111
|
+
) as Required<SeamHttpRequestOptions>
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const isSeamHttpRequestOption = (
|
|
115
|
+
key: string,
|
|
116
|
+
): key is keyof SeamHttpRequestOptions => {
|
|
117
|
+
const keys: Record<keyof SeamHttpRequestOptions, true> = {
|
|
118
|
+
waitForActionAttempt: true,
|
|
119
|
+
}
|
|
120
|
+
return Object.keys(keys).includes(key)
|
|
121
|
+
}
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpAccessCodesUnmanaged {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpAccessCodesUnmanaged {
|
|
|
78
84
|
): Promise<SeamHttpAccessCodesUnmanaged> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,18 +22,24 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpAccessCodesUnmanaged } from './access-codes-unmanaged.js'
|
|
29
33
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
30
34
|
|
|
31
35
|
export class SeamHttpAccessCodes {
|
|
32
36
|
client: Client
|
|
37
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
33
38
|
|
|
34
39
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
35
|
-
const
|
|
36
|
-
this.client = createClient(
|
|
40
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
41
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
42
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
static fromClient(
|
|
@@ -79,6 +85,11 @@ export class SeamHttpAccessCodes {
|
|
|
79
85
|
): Promise<SeamHttpAccessCodes> {
|
|
80
86
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
81
87
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
88
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
89
|
+
throw new SeamHttpInvalidOptionsError(
|
|
90
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
91
|
+
)
|
|
92
|
+
}
|
|
82
93
|
const client = createClient(clientOptions)
|
|
83
94
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
84
95
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -122,7 +133,7 @@ export class SeamHttpAccessCodes {
|
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
get unmanaged(): SeamHttpAccessCodesUnmanaged {
|
|
125
|
-
return SeamHttpAccessCodesUnmanaged.fromClient(this.client)
|
|
136
|
+
return SeamHttpAccessCodesUnmanaged.fromClient(this.client, this.defaults)
|
|
126
137
|
}
|
|
127
138
|
|
|
128
139
|
async create(
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpAcsAccessGroups {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpAcsAccessGroups {
|
|
|
78
84
|
): Promise<SeamHttpAcsAccessGroups> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpAcsCredentials {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpAcsCredentials {
|
|
|
78
84
|
): Promise<SeamHttpAcsCredentials> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpAcsSystems {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpAcsSystems {
|
|
|
78
84
|
): Promise<SeamHttpAcsSystems> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpAcsUsers {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpAcsUsers {
|
|
|
78
84
|
): Promise<SeamHttpAcsUsers> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -19,8 +19,12 @@ import {
|
|
|
19
19
|
type SeamHttpOptionsWithClientSessionToken,
|
|
20
20
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
21
21
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
22
|
+
type SeamHttpRequestOptions,
|
|
22
23
|
} from 'lib/seam/connect/options.js'
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
limitToSeamHttpRequestOptions,
|
|
26
|
+
parseOptions,
|
|
27
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
24
28
|
|
|
25
29
|
import { SeamHttpAcsAccessGroups } from './acs-access-groups.js'
|
|
26
30
|
import { SeamHttpAcsCredentials } from './acs-credentials.js'
|
|
@@ -30,10 +34,12 @@ import { SeamHttpClientSessions } from './client-sessions.js'
|
|
|
30
34
|
|
|
31
35
|
export class SeamHttpAcs {
|
|
32
36
|
client: Client
|
|
37
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
33
38
|
|
|
34
39
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
35
|
-
const
|
|
36
|
-
this.client = createClient(
|
|
40
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
41
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
42
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
static fromClient(
|
|
@@ -79,6 +85,11 @@ export class SeamHttpAcs {
|
|
|
79
85
|
): Promise<SeamHttpAcs> {
|
|
80
86
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
81
87
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
88
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
89
|
+
throw new SeamHttpInvalidOptionsError(
|
|
90
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
91
|
+
)
|
|
92
|
+
}
|
|
82
93
|
const client = createClient(clientOptions)
|
|
83
94
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
84
95
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -122,18 +133,18 @@ export class SeamHttpAcs {
|
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
get accessGroups(): SeamHttpAcsAccessGroups {
|
|
125
|
-
return SeamHttpAcsAccessGroups.fromClient(this.client)
|
|
136
|
+
return SeamHttpAcsAccessGroups.fromClient(this.client, this.defaults)
|
|
126
137
|
}
|
|
127
138
|
|
|
128
139
|
get credentials(): SeamHttpAcsCredentials {
|
|
129
|
-
return SeamHttpAcsCredentials.fromClient(this.client)
|
|
140
|
+
return SeamHttpAcsCredentials.fromClient(this.client, this.defaults)
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
get systems(): SeamHttpAcsSystems {
|
|
133
|
-
return SeamHttpAcsSystems.fromClient(this.client)
|
|
144
|
+
return SeamHttpAcsSystems.fromClient(this.client, this.defaults)
|
|
134
145
|
}
|
|
135
146
|
|
|
136
147
|
get users(): SeamHttpAcsUsers {
|
|
137
|
-
return SeamHttpAcsUsers.fromClient(this.client)
|
|
148
|
+
return SeamHttpAcsUsers.fromClient(this.client, this.defaults)
|
|
138
149
|
}
|
|
139
150
|
}
|
|
@@ -22,21 +22,24 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from 'lib/seam/connect/
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
|
+
import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js'
|
|
31
32
|
|
|
32
33
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
34
|
|
|
34
35
|
export class SeamHttpActionAttempts {
|
|
35
36
|
client: Client
|
|
37
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
36
38
|
|
|
37
39
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
38
|
-
const
|
|
39
|
-
this.client = createClient(
|
|
40
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
41
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
42
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
static fromClient(
|
|
@@ -82,6 +85,11 @@ export class SeamHttpActionAttempts {
|
|
|
82
85
|
): Promise<SeamHttpActionAttempts> {
|
|
83
86
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
84
87
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
88
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
89
|
+
throw new SeamHttpInvalidOptionsError(
|
|
90
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
91
|
+
)
|
|
92
|
+
}
|
|
85
93
|
const client = createClient(clientOptions)
|
|
86
94
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
87
95
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -126,21 +134,22 @@ export class SeamHttpActionAttempts {
|
|
|
126
134
|
|
|
127
135
|
async get(
|
|
128
136
|
body?: ActionAttemptsGetParams,
|
|
129
|
-
{
|
|
130
|
-
waitForActionAttempt = false,
|
|
131
|
-
}: {
|
|
132
|
-
waitForActionAttempt?: boolean | Partial<ResolveActionAttemptOptions>
|
|
133
|
-
} = {},
|
|
137
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
134
138
|
): Promise<ActionAttemptsGetResponse['action_attempt']> {
|
|
135
139
|
const { data } = await this.client.request<ActionAttemptsGetResponse>({
|
|
136
140
|
url: '/action_attempts/get',
|
|
137
141
|
method: 'post',
|
|
138
142
|
data: body,
|
|
139
143
|
})
|
|
140
|
-
|
|
144
|
+
const waitForActionAttempt =
|
|
145
|
+
options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
|
|
146
|
+
if (waitForActionAttempt !== false) {
|
|
141
147
|
return await resolveActionAttempt(
|
|
142
148
|
data.action_attempt,
|
|
143
|
-
SeamHttpActionAttempts.fromClient(this.client
|
|
149
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
150
|
+
...this.defaults,
|
|
151
|
+
waitForActionAttempt: false,
|
|
152
|
+
}),
|
|
144
153
|
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
145
154
|
)
|
|
146
155
|
}
|
|
@@ -166,9 +175,10 @@ export type ActionAttemptsGetResponse = SetNonNullable<
|
|
|
166
175
|
Required<RouteResponse<'/action_attempts/get'>>
|
|
167
176
|
>
|
|
168
177
|
|
|
169
|
-
export
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
export type ActionAttemptsGetOptions = Pick<
|
|
179
|
+
SeamHttpRequestOptions,
|
|
180
|
+
'waitForActionAttempt'
|
|
181
|
+
>
|
|
172
182
|
|
|
173
183
|
export type ActionAttemptsListParams = RouteRequestBody<'/action_attempts/list'>
|
|
174
184
|
|
|
@@ -22,15 +22,21 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
export class SeamHttpClientSessions {
|
|
29
33
|
client: Client
|
|
34
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
30
35
|
|
|
31
36
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
32
|
-
const
|
|
33
|
-
this.client = createClient(
|
|
37
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
38
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
39
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
static fromClient(
|
|
@@ -76,6 +82,11 @@ export class SeamHttpClientSessions {
|
|
|
76
82
|
): Promise<SeamHttpClientSessions> {
|
|
77
83
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
78
84
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
85
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
86
|
+
throw new SeamHttpInvalidOptionsError(
|
|
87
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
88
|
+
)
|
|
89
|
+
}
|
|
79
90
|
const client = createClient(clientOptions)
|
|
80
91
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
81
92
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -26,17 +26,23 @@ import {
|
|
|
26
26
|
type SeamHttpOptionsWithClientSessionToken,
|
|
27
27
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
28
28
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
29
|
+
type SeamHttpRequestOptions,
|
|
29
30
|
} from 'lib/seam/connect/options.js'
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
limitToSeamHttpRequestOptions,
|
|
33
|
+
parseOptions,
|
|
34
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
35
|
|
|
32
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
37
|
|
|
34
38
|
export class SeamHttpConnectWebviews {
|
|
35
39
|
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
36
41
|
|
|
37
42
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
38
|
-
const
|
|
39
|
-
this.client = createClient(
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
static fromClient(
|
|
@@ -82,6 +88,11 @@ export class SeamHttpConnectWebviews {
|
|
|
82
88
|
): Promise<SeamHttpConnectWebviews> {
|
|
83
89
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
84
90
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
91
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
92
|
+
throw new SeamHttpInvalidOptionsError(
|
|
93
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
94
|
+
)
|
|
95
|
+
}
|
|
85
96
|
const client = createClient(clientOptions)
|
|
86
97
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
87
98
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -26,17 +26,23 @@ import {
|
|
|
26
26
|
type SeamHttpOptionsWithClientSessionToken,
|
|
27
27
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
28
28
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
29
|
+
type SeamHttpRequestOptions,
|
|
29
30
|
} from 'lib/seam/connect/options.js'
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
limitToSeamHttpRequestOptions,
|
|
33
|
+
parseOptions,
|
|
34
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
35
|
|
|
32
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
37
|
|
|
34
38
|
export class SeamHttpConnectedAccounts {
|
|
35
39
|
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
36
41
|
|
|
37
42
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
38
|
-
const
|
|
39
|
-
this.client = createClient(
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
static fromClient(
|
|
@@ -82,6 +88,11 @@ export class SeamHttpConnectedAccounts {
|
|
|
82
88
|
): Promise<SeamHttpConnectedAccounts> {
|
|
83
89
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
84
90
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
91
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
92
|
+
throw new SeamHttpInvalidOptionsError(
|
|
93
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
94
|
+
)
|
|
95
|
+
}
|
|
85
96
|
const client = createClient(clientOptions)
|
|
86
97
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
87
98
|
const { token } = await clientSessions.getOrCreate({
|