@seamapi/http 0.1.0 → 0.2.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.
- package/dist/connect.cjs +752 -366
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +186 -142
- package/lib/params-serializer.d.ts +5 -0
- package/lib/params-serializer.js +42 -0
- package/lib/params-serializer.js.map +1 -0
- package/lib/seam/connect/auth.d.ts +3 -2
- package/lib/seam/connect/auth.js +55 -4
- package/lib/seam/connect/auth.js.map +1 -1
- package/lib/seam/connect/client.d.ts +10 -22
- package/lib/seam/connect/client.js +17 -77
- package/lib/seam/connect/client.js.map +1 -1
- package/lib/seam/connect/index.d.ts +2 -1
- package/lib/seam/connect/index.js +2 -1
- package/lib/seam/connect/index.js.map +1 -1
- package/lib/seam/connect/{client-options.d.ts → options.d.ts} +7 -7
- package/lib/seam/connect/{client-options.js → options.js} +5 -10
- package/lib/seam/connect/options.js.map +1 -0
- package/lib/seam/connect/parse-options.d.ts +6 -2
- package/lib/seam/connect/parse-options.js +34 -16
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +10 -9
- package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -14
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +15 -14
- package/lib/seam/connect/routes/access-codes.js +29 -17
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +13 -12
- package/lib/seam/connect/routes/acs-access-groups.js +26 -14
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +9 -8
- package/lib/seam/connect/routes/acs-credentials.js +26 -14
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +9 -8
- package/lib/seam/connect/routes/acs-systems.js +29 -17
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +18 -11
- package/lib/seam/connect/routes/acs-users.js +40 -14
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/acs.d.ts +5 -4
- package/lib/seam/connect/routes/acs.js +26 -14
- package/lib/seam/connect/routes/acs.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +7 -6
- package/lib/seam/connect/routes/action-attempts.js +26 -14
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +13 -9
- package/lib/seam/connect/routes/client-sessions.js +33 -14
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +11 -10
- package/lib/seam/connect/routes/connect-webviews.js +29 -17
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +8 -7
- package/lib/seam/connect/routes/connected-accounts.js +26 -14
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +8 -7
- package/lib/seam/connect/routes/devices-unmanaged.js +26 -14
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +10 -9
- package/lib/seam/connect/routes/devices.js +26 -14
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +7 -6
- package/lib/seam/connect/routes/events.js +26 -14
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +9 -8
- package/lib/seam/connect/routes/locks.js +26 -14
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +10 -9
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -14
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors.d.ts +5 -4
- package/lib/seam/connect/routes/noise-sensors.js +26 -14
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +10 -9
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -14
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +13 -12
- package/lib/seam/connect/routes/thermostats.js +26 -14
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +9 -8
- package/lib/seam/connect/routes/webhooks.js +26 -14
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +8 -7
- package/lib/seam/connect/routes/workspaces.js +26 -14
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +24 -0
- package/lib/seam/connect/seam-http.js +82 -0
- package/lib/seam/connect/seam-http.js.map +1 -0
- package/package.json +7 -4
- package/src/lib/params-serializer.ts +55 -0
- package/src/lib/seam/connect/auth.ts +94 -6
- package/src/lib/seam/connect/client.ts +22 -127
- package/src/lib/seam/connect/env.d.ts +11 -0
- package/src/lib/seam/connect/index.ts +2 -1
- package/src/lib/seam/connect/{client-options.ts → options.ts} +13 -19
- package/src/lib/seam/connect/parse-options.ts +50 -23
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +44 -31
- package/src/lib/seam/connect/routes/access-codes.ts +48 -48
- package/src/lib/seam/connect/routes/acs-access-groups.ts +49 -40
- package/src/lib/seam/connect/routes/acs-credentials.ts +40 -28
- package/src/lib/seam/connect/routes/acs-systems.ts +40 -30
- package/src/lib/seam/connect/routes/acs-users.ts +70 -36
- package/src/lib/seam/connect/routes/acs.ts +33 -17
- package/src/lib/seam/connect/routes/action-attempts.ts +36 -22
- package/src/lib/seam/connect/routes/client-sessions.ts +58 -30
- package/src/lib/seam/connect/routes/connect-webviews.ts +45 -34
- package/src/lib/seam/connect/routes/connected-accounts.ts +40 -25
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +39 -25
- package/src/lib/seam/connect/routes/devices.ts +39 -31
- package/src/lib/seam/connect/routes/events.ts +36 -22
- package/src/lib/seam/connect/routes/locks.ts +38 -28
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +47 -31
- package/src/lib/seam/connect/routes/noise-sensors.ts +33 -17
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -31
- package/src/lib/seam/connect/routes/thermostats.ts +42 -40
- package/src/lib/seam/connect/routes/webhooks.ts +38 -28
- package/src/lib/seam/connect/routes/workspaces.ts +38 -25
- package/src/lib/seam/connect/seam-http.ts +141 -0
- package/lib/seam/connect/axios.d.ts +0 -3
- package/lib/seam/connect/axios.js +0 -19
- package/lib/seam/connect/axios.js.map +0 -1
- package/lib/seam/connect/client-options.js.map +0 -1
- package/src/lib/seam/connect/axios.ts +0 -25
|
@@ -8,50 +8,53 @@ import type {
|
|
|
8
8
|
RouteRequestParams,
|
|
9
9
|
RouteResponse,
|
|
10
10
|
} from '@seamapi/types/connect'
|
|
11
|
-
import type { Axios } from 'axios'
|
|
12
11
|
import type { SetNonNullable } from 'type-fest'
|
|
13
12
|
|
|
14
|
-
import {
|
|
13
|
+
import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
14
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
15
15
|
import {
|
|
16
16
|
isSeamHttpOptionsWithApiKey,
|
|
17
17
|
isSeamHttpOptionsWithClient,
|
|
18
18
|
isSeamHttpOptionsWithClientSessionToken,
|
|
19
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
19
20
|
SeamHttpInvalidOptionsError,
|
|
20
21
|
type SeamHttpOptions,
|
|
21
22
|
type SeamHttpOptionsWithApiKey,
|
|
22
23
|
type SeamHttpOptionsWithClient,
|
|
23
24
|
type SeamHttpOptionsWithClientSessionToken,
|
|
24
|
-
} from 'lib/seam/connect/
|
|
25
|
+
} from 'lib/seam/connect/options.js'
|
|
25
26
|
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
26
27
|
|
|
28
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
|
+
|
|
27
30
|
export class SeamHttpWorkspaces {
|
|
28
|
-
client:
|
|
31
|
+
client: Client
|
|
29
32
|
|
|
30
|
-
constructor(apiKeyOrOptions: string | SeamHttpOptions) {
|
|
31
|
-
const
|
|
32
|
-
this.client =
|
|
33
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
35
|
+
this.client = createClient(clientOptions)
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
static fromClient(
|
|
36
39
|
client: SeamHttpOptionsWithClient['client'],
|
|
37
40
|
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
38
41
|
): SeamHttpWorkspaces {
|
|
39
|
-
const
|
|
40
|
-
if (!isSeamHttpOptionsWithClient(
|
|
42
|
+
const constructorOptions = { ...options, client }
|
|
43
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
41
44
|
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
42
45
|
}
|
|
43
|
-
return new SeamHttpWorkspaces(
|
|
46
|
+
return new SeamHttpWorkspaces(constructorOptions)
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
static fromApiKey(
|
|
47
50
|
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
48
51
|
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
49
52
|
): SeamHttpWorkspaces {
|
|
50
|
-
const
|
|
51
|
-
if (!isSeamHttpOptionsWithApiKey(
|
|
53
|
+
const constructorOptions = { ...options, apiKey }
|
|
54
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
52
55
|
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
53
56
|
}
|
|
54
|
-
return new SeamHttpWorkspaces(
|
|
57
|
+
return new SeamHttpWorkspaces(constructorOptions)
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
static fromClientSessionToken(
|
|
@@ -61,11 +64,26 @@ export class SeamHttpWorkspaces {
|
|
|
61
64
|
'clientSessionToken'
|
|
62
65
|
> = {},
|
|
63
66
|
): SeamHttpWorkspaces {
|
|
64
|
-
const
|
|
65
|
-
if (!isSeamHttpOptionsWithClientSessionToken(
|
|
67
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
68
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
66
69
|
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
67
70
|
}
|
|
68
|
-
return new SeamHttpWorkspaces(
|
|
71
|
+
return new SeamHttpWorkspaces(constructorOptions)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static async fromPublishableKey(
|
|
75
|
+
publishableKey: string,
|
|
76
|
+
userIdentifierKey: string,
|
|
77
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
78
|
+
): Promise<SeamHttpWorkspaces> {
|
|
79
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
81
|
+
const client = createClient(clientOptions)
|
|
82
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
|
+
const { token } = await clientSessions.getOrCreate({
|
|
84
|
+
user_identifier_key: userIdentifierKey,
|
|
85
|
+
})
|
|
86
|
+
return SeamHttpWorkspaces.fromClientSessionToken(token, options)
|
|
69
87
|
}
|
|
70
88
|
|
|
71
89
|
async get(
|
|
@@ -99,25 +117,20 @@ export class SeamHttpWorkspaces {
|
|
|
99
117
|
}
|
|
100
118
|
}
|
|
101
119
|
|
|
102
|
-
export type WorkspacesGetParams =
|
|
103
|
-
Required<RouteRequestParams<'/workspaces/get'>>
|
|
104
|
-
>
|
|
120
|
+
export type WorkspacesGetParams = RouteRequestParams<'/workspaces/get'>
|
|
105
121
|
|
|
106
122
|
export type WorkspacesGetResponse = SetNonNullable<
|
|
107
123
|
Required<RouteResponse<'/workspaces/get'>>
|
|
108
124
|
>
|
|
109
125
|
|
|
110
|
-
export type WorkspacesListParams =
|
|
111
|
-
Required<RouteRequestParams<'/workspaces/list'>>
|
|
112
|
-
>
|
|
126
|
+
export type WorkspacesListParams = RouteRequestParams<'/workspaces/list'>
|
|
113
127
|
|
|
114
128
|
export type WorkspacesListResponse = SetNonNullable<
|
|
115
129
|
Required<RouteResponse<'/workspaces/list'>>
|
|
116
130
|
>
|
|
117
131
|
|
|
118
|
-
export type WorkspacesResetSandboxBody =
|
|
119
|
-
|
|
120
|
-
>
|
|
132
|
+
export type WorkspacesResetSandboxBody =
|
|
133
|
+
RouteRequestBody<'/workspaces/reset_sandbox'>
|
|
121
134
|
|
|
122
135
|
export type WorkspacesResetSandboxResponse = SetNonNullable<
|
|
123
136
|
Required<RouteResponse<'/workspaces/reset_sandbox'>>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { warnOnInsecureuserIdentifierKey } from './auth.js'
|
|
2
|
+
import { type Client, createClient } from './client.js'
|
|
3
|
+
import {
|
|
4
|
+
isSeamHttpOptionsWithApiKey,
|
|
5
|
+
isSeamHttpOptionsWithClient,
|
|
6
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
7
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
8
|
+
SeamHttpInvalidOptionsError,
|
|
9
|
+
type SeamHttpOptions,
|
|
10
|
+
type SeamHttpOptionsWithApiKey,
|
|
11
|
+
type SeamHttpOptionsWithClient,
|
|
12
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
13
|
+
} from './options.js'
|
|
14
|
+
import { parseOptions } from './parse-options.js'
|
|
15
|
+
import {
|
|
16
|
+
SeamHttpAccessCodes,
|
|
17
|
+
SeamHttpAcs,
|
|
18
|
+
SeamHttpActionAttempts,
|
|
19
|
+
SeamHttpClientSessions,
|
|
20
|
+
SeamHttpConnectedAccounts,
|
|
21
|
+
SeamHttpConnectWebviews,
|
|
22
|
+
SeamHttpDevices,
|
|
23
|
+
SeamHttpEvents,
|
|
24
|
+
SeamHttpLocks,
|
|
25
|
+
SeamHttpNoiseSensors,
|
|
26
|
+
SeamHttpThermostats,
|
|
27
|
+
SeamHttpWebhooks,
|
|
28
|
+
SeamHttpWorkspaces,
|
|
29
|
+
} from './routes/index.js'
|
|
30
|
+
|
|
31
|
+
export class SeamHttp {
|
|
32
|
+
client: Client
|
|
33
|
+
|
|
34
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
35
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
36
|
+
this.client = createClient(clientOptions)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static fromClient(
|
|
40
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
41
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
42
|
+
): SeamHttp {
|
|
43
|
+
const constructorOptions = { ...options, client }
|
|
44
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
45
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
46
|
+
}
|
|
47
|
+
return new SeamHttp(constructorOptions)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static fromApiKey(
|
|
51
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
52
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
53
|
+
): SeamHttp {
|
|
54
|
+
const constructorOptions = { ...options, apiKey }
|
|
55
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
56
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
57
|
+
}
|
|
58
|
+
return new SeamHttp(constructorOptions)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static fromClientSessionToken(
|
|
62
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
63
|
+
options: Omit<
|
|
64
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
65
|
+
'clientSessionToken'
|
|
66
|
+
> = {},
|
|
67
|
+
): SeamHttp {
|
|
68
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
69
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
70
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
71
|
+
}
|
|
72
|
+
return new SeamHttp(constructorOptions)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static async fromPublishableKey(
|
|
76
|
+
publishableKey: string,
|
|
77
|
+
userIdentifierKey: string,
|
|
78
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
79
|
+
): Promise<SeamHttp> {
|
|
80
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
81
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
82
|
+
const client = createClient(clientOptions)
|
|
83
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
84
|
+
const { token } = await clientSessions.getOrCreate({
|
|
85
|
+
user_identifier_key: userIdentifierKey,
|
|
86
|
+
})
|
|
87
|
+
return SeamHttp.fromClientSessionToken(token, options)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get accessCodes(): SeamHttpAccessCodes {
|
|
91
|
+
return SeamHttpAccessCodes.fromClient(this.client)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get acs(): SeamHttpAcs {
|
|
95
|
+
return SeamHttpAcs.fromClient(this.client)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get actionAttempts(): SeamHttpActionAttempts {
|
|
99
|
+
return SeamHttpActionAttempts.fromClient(this.client)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get clientSessions(): SeamHttpClientSessions {
|
|
103
|
+
return SeamHttpClientSessions.fromClient(this.client)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get connectedAccounts(): SeamHttpConnectedAccounts {
|
|
107
|
+
return SeamHttpConnectedAccounts.fromClient(this.client)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get connectWebviews(): SeamHttpConnectWebviews {
|
|
111
|
+
return SeamHttpConnectWebviews.fromClient(this.client)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get devices(): SeamHttpDevices {
|
|
115
|
+
return SeamHttpDevices.fromClient(this.client)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get events(): SeamHttpEvents {
|
|
119
|
+
return SeamHttpEvents.fromClient(this.client)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get locks(): SeamHttpLocks {
|
|
123
|
+
return SeamHttpLocks.fromClient(this.client)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get noiseSensors(): SeamHttpNoiseSensors {
|
|
127
|
+
return SeamHttpNoiseSensors.fromClient(this.client)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get thermostats(): SeamHttpThermostats {
|
|
131
|
+
return SeamHttpThermostats.fromClient(this.client)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get webhooks(): SeamHttpWebhooks {
|
|
135
|
+
return SeamHttpWebhooks.fromClient(this.client)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get workspaces(): SeamHttpWorkspaces {
|
|
139
|
+
return SeamHttpWorkspaces.fromClient(this.client)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import axios, {} from 'axios';
|
|
2
|
-
import { getAuthHeaders } from './auth.js';
|
|
3
|
-
import { isSeamHttpOptionsWithClient, isSeamHttpOptionsWithClientSessionToken, } from './client-options.js';
|
|
4
|
-
export const createAxiosClient = (options) => {
|
|
5
|
-
if (isSeamHttpOptionsWithClient(options))
|
|
6
|
-
return options.client;
|
|
7
|
-
// TODO: axiosRetry? Allow options to configure this if so
|
|
8
|
-
return axios.create({
|
|
9
|
-
baseURL: options.endpoint,
|
|
10
|
-
withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
|
|
11
|
-
...options.axiosOptions,
|
|
12
|
-
headers: {
|
|
13
|
-
...getAuthHeaders(options),
|
|
14
|
-
...options.axiosOptions.headers,
|
|
15
|
-
// TODO: User-Agent
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=axios.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/lib/seam/connect/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EACL,2BAA2B,EAC3B,uCAAuC,GAExC,MAAM,qBAAqB,CAAA;AAE5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAkC,EAC3B,EAAE;IACT,IAAI,2BAA2B,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,MAAM,CAAA;IAC/D,0DAA0D;IAC1D,OAAO,KAAK,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC,QAAQ;QACzB,eAAe,EAAE,uCAAuC,CAAC,OAAO,CAAC;QACjE,GAAG,OAAO,CAAC,YAAY;QACvB,OAAO,EAAE;YACP,GAAG,cAAc,CAAC,OAAO,CAAC;YAC1B,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO;YAC/B,mBAAmB;SACpB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-options.js","sourceRoot":"","sources":["../../../src/lib/seam/connect/client-options.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAAwB,EACc,EAAE;IACxC,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAExC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC7D,CAAA;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAI,2BAA2B,CACnC,2GAA2G,IAAI,CAAC,IAAI,CAClH,IAAI,CACL,EAAE,CACJ,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAMD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,OAAwB,EACc,EAAE;IACxC,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACxC,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAExC,IAAI,oBAAoB,IAAI,OAAO,IAAI,OAAO,CAAC,kBAAkB,IAAI,IAAI,EAAE;QACzE,MAAM,IAAI,2BAA2B,CACnC,sEAAsE,CACvE,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAOD,MAAM,CAAC,MAAM,uCAAuC,GAAG,CACrD,OAAwB,EAC0B,EAAE;IACpD,IAAI,CAAC,CAAC,oBAAoB,IAAI,OAAO,CAAC;QAAE,OAAO,KAAK,CAAA;IACpD,IAAI,OAAO,CAAC,kBAAkB,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAEpD,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE;QACjD,MAAM,IAAI,2BAA2B,CACnC,sEAAsE,CACvE,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACjD,CAAC;CACF;AAED,kFAAkF;AAClF,mFAAmF;AACnF,wBAAwB;AACxB,mBAAmB;AACnB,IAAI"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import axios, { type Axios } from 'axios'
|
|
2
|
-
|
|
3
|
-
import { getAuthHeaders } from './auth.js'
|
|
4
|
-
import {
|
|
5
|
-
isSeamHttpOptionsWithClient,
|
|
6
|
-
isSeamHttpOptionsWithClientSessionToken,
|
|
7
|
-
type SeamHttpOptions,
|
|
8
|
-
} from './client-options.js'
|
|
9
|
-
|
|
10
|
-
export const createAxiosClient = (
|
|
11
|
-
options: Required<SeamHttpOptions>,
|
|
12
|
-
): Axios => {
|
|
13
|
-
if (isSeamHttpOptionsWithClient(options)) return options.client
|
|
14
|
-
// TODO: axiosRetry? Allow options to configure this if so
|
|
15
|
-
return axios.create({
|
|
16
|
-
baseURL: options.endpoint,
|
|
17
|
-
withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
|
|
18
|
-
...options.axiosOptions,
|
|
19
|
-
headers: {
|
|
20
|
-
...getAuthHeaders(options),
|
|
21
|
-
...options.axiosOptions.headers,
|
|
22
|
-
// TODO: User-Agent
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
}
|