@seamapi/http 0.0.2 → 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 +1807 -96
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +472 -15
- 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 +4 -3
- package/lib/seam/connect/auth.js +59 -8
- package/lib/seam/connect/auth.js.map +1 -1
- package/lib/seam/connect/client.d.ts +10 -10
- package/lib/seam/connect/client.js +16 -49
- 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/options.d.ts +23 -0
- package/lib/seam/connect/options.js +39 -0
- 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 +35 -10
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +27 -0
- package/lib/seam/connect/routes/access-codes-unmanaged.js +84 -0
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -0
- package/lib/seam/connect/routes/access-codes.d.ts +38 -0
- package/lib/seam/connect/routes/access-codes.js +113 -0
- package/lib/seam/connect/routes/access-codes.js.map +1 -0
- package/lib/seam/connect/routes/acs-access-groups.d.ts +36 -0
- package/lib/seam/connect/routes/acs-access-groups.js +107 -0
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -0
- package/lib/seam/connect/routes/acs-credentials.d.ts +24 -0
- package/lib/seam/connect/routes/acs-credentials.js +78 -0
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -0
- package/lib/seam/connect/routes/acs-systems.d.ts +18 -0
- package/lib/seam/connect/routes/acs-systems.js +63 -0
- package/lib/seam/connect/routes/acs-systems.js.map +1 -0
- package/lib/seam/connect/routes/acs-users.d.ts +39 -0
- package/lib/seam/connect/routes/acs-users.js +113 -0
- package/lib/seam/connect/routes/acs-users.js.map +1 -0
- package/lib/seam/connect/routes/acs.d.ts +18 -0
- package/lib/seam/connect/routes/acs.js +63 -0
- package/lib/seam/connect/routes/acs.js.map +1 -0
- package/lib/seam/connect/routes/action-attempts.d.ts +18 -0
- package/lib/seam/connect/routes/action-attempts.js +63 -0
- package/lib/seam/connect/routes/action-attempts.js.map +1 -0
- package/lib/seam/connect/routes/client-sessions.d.ts +30 -0
- package/lib/seam/connect/routes/client-sessions.js +93 -0
- package/lib/seam/connect/routes/client-sessions.js.map +1 -0
- package/lib/seam/connect/routes/connect-webviews.d.ts +27 -0
- package/lib/seam/connect/routes/connect-webviews.js +85 -0
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -0
- package/lib/seam/connect/routes/connected-accounts.d.ts +21 -0
- package/lib/seam/connect/routes/connected-accounts.js +70 -0
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -0
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +21 -0
- package/lib/seam/connect/routes/devices-unmanaged.js +70 -0
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -0
- package/lib/seam/connect/routes/devices.d.ts +29 -0
- package/lib/seam/connect/routes/devices.js +89 -0
- package/lib/seam/connect/routes/devices.js.map +1 -0
- package/lib/seam/connect/routes/events.d.ts +18 -0
- package/lib/seam/connect/routes/events.js +63 -0
- package/lib/seam/connect/routes/events.js.map +1 -0
- package/lib/seam/connect/routes/index.d.ts +21 -0
- package/lib/seam/connect/routes/index.js +22 -0
- package/lib/seam/connect/routes/index.js.map +1 -0
- package/lib/seam/connect/routes/locks.d.ts +24 -0
- package/lib/seam/connect/routes/locks.js +79 -0
- package/lib/seam/connect/routes/locks.js.map +1 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +27 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +84 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -0
- package/lib/seam/connect/routes/noise-sensors.d.ts +12 -0
- package/lib/seam/connect/routes/noise-sensors.js +51 -0
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +27 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +85 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -0
- package/lib/seam/connect/routes/thermostats.d.ts +38 -0
- package/lib/seam/connect/routes/thermostats.js +109 -0
- package/lib/seam/connect/routes/thermostats.js.map +1 -0
- package/lib/seam/connect/routes/webhooks.d.ts +24 -0
- package/lib/seam/connect/routes/webhooks.js +78 -0
- package/lib/seam/connect/routes/webhooks.js.map +1 -0
- package/lib/seam/connect/routes/workspaces.d.ts +17 -7
- package/lib/seam/connect/routes/workspaces.js +61 -11
- 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 +9 -3
- package/src/lib/params-serializer.ts +55 -0
- package/src/lib/seam/connect/auth.ts +101 -13
- package/src/lib/seam/connect/client.ts +30 -62
- 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} +37 -15
- package/src/lib/seam/connect/parse-options.ts +55 -14
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +170 -0
- package/src/lib/seam/connect/routes/access-codes.ts +226 -0
- package/src/lib/seam/connect/routes/acs-access-groups.ts +216 -0
- package/src/lib/seam/connect/routes/acs-credentials.ts +151 -0
- package/src/lib/seam/connect/routes/acs-systems.ts +118 -0
- package/src/lib/seam/connect/routes/acs-users.ts +221 -0
- package/src/lib/seam/connect/routes/acs.ts +101 -0
- package/src/lib/seam/connect/routes/action-attempts.ts +118 -0
- package/src/lib/seam/connect/routes/client-sessions.ts +187 -0
- package/src/lib/seam/connect/routes/connect-webviews.ts +170 -0
- package/src/lib/seam/connect/routes/connected-accounts.ts +139 -0
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +134 -0
- package/src/lib/seam/connect/routes/devices.ts +166 -0
- package/src/lib/seam/connect/routes/events.ts +114 -0
- package/src/lib/seam/connect/routes/index.ts +21 -0
- package/src/lib/seam/connect/routes/locks.ts +148 -0
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +170 -0
- package/src/lib/seam/connect/routes/noise-sensors.ts +86 -0
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +192 -0
- package/src/lib/seam/connect/routes/thermostats.ts +208 -0
- package/src/lib/seam/connect/routes/webhooks.ts +151 -0
- package/src/lib/seam/connect/routes/workspaces.ts +118 -22
- 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 -17
- package/lib/seam/connect/axios.js.map +0 -1
- package/lib/seam/connect/client-options.d.ts +0 -19
- package/lib/seam/connect/client-options.js +0 -29
- package/lib/seam/connect/client-options.js.map +0 -1
- package/lib/seam/connect/legacy/workspaces.d.ts +0 -8
- package/lib/seam/connect/legacy/workspaces.js +0 -10
- package/lib/seam/connect/legacy/workspaces.js.map +0 -1
- package/src/lib/seam/connect/axios.ts +0 -23
- package/src/lib/seam/connect/legacy/workspaces.ts +0 -26
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by generate-routes.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
|
+
import type { SetNonNullable } from 'type-fest'
|
|
8
|
+
|
|
9
|
+
import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
|
|
26
|
+
export class SeamHttpAccessCodesUnmanaged {
|
|
27
|
+
client: Client
|
|
28
|
+
|
|
29
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
30
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
31
|
+
this.client = createClient(clientOptions)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromClient(
|
|
35
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
36
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
37
|
+
): SeamHttpAccessCodesUnmanaged {
|
|
38
|
+
const constructorOptions = { ...options, client }
|
|
39
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
40
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
41
|
+
}
|
|
42
|
+
return new SeamHttpAccessCodesUnmanaged(constructorOptions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromApiKey(
|
|
46
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
47
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
48
|
+
): SeamHttpAccessCodesUnmanaged {
|
|
49
|
+
const constructorOptions = { ...options, apiKey }
|
|
50
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
51
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
52
|
+
}
|
|
53
|
+
return new SeamHttpAccessCodesUnmanaged(constructorOptions)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromClientSessionToken(
|
|
57
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
58
|
+
options: Omit<
|
|
59
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
60
|
+
'clientSessionToken'
|
|
61
|
+
> = {},
|
|
62
|
+
): SeamHttpAccessCodesUnmanaged {
|
|
63
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
64
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpAccessCodesUnmanaged(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async fromPublishableKey(
|
|
71
|
+
publishableKey: string,
|
|
72
|
+
userIdentifierKey: string,
|
|
73
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
74
|
+
): Promise<SeamHttpAccessCodesUnmanaged> {
|
|
75
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
76
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
77
|
+
const client = createClient(clientOptions)
|
|
78
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
79
|
+
const { token } = await clientSessions.getOrCreate({
|
|
80
|
+
user_identifier_key: userIdentifierKey,
|
|
81
|
+
})
|
|
82
|
+
return SeamHttpAccessCodesUnmanaged.fromClientSessionToken(token, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async convertToManaged(
|
|
86
|
+
body: AccessCodesUnmanagedConvertToManagedBody,
|
|
87
|
+
): Promise<void> {
|
|
88
|
+
await this.client.request<AccessCodesUnmanagedConvertToManagedResponse>({
|
|
89
|
+
url: '/access_codes/unmanaged/convert_to_managed',
|
|
90
|
+
method: 'post',
|
|
91
|
+
data: body,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async delete(body: AccessCodesUnmanagedDeleteBody): Promise<void> {
|
|
96
|
+
await this.client.request<AccessCodesUnmanagedDeleteResponse>({
|
|
97
|
+
url: '/access_codes/unmanaged/delete',
|
|
98
|
+
method: 'post',
|
|
99
|
+
data: body,
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async get(
|
|
104
|
+
body: AccessCodesUnmanagedGetBody,
|
|
105
|
+
): Promise<AccessCodesUnmanagedGetResponse['access_code']> {
|
|
106
|
+
const { data } = await this.client.request<AccessCodesUnmanagedGetResponse>(
|
|
107
|
+
{
|
|
108
|
+
url: '/access_codes/unmanaged/get',
|
|
109
|
+
method: 'post',
|
|
110
|
+
data: body,
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
return data.access_code
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async list(
|
|
117
|
+
body: AccessCodesUnmanagedListBody,
|
|
118
|
+
): Promise<AccessCodesUnmanagedListResponse['access_codes']> {
|
|
119
|
+
const { data } =
|
|
120
|
+
await this.client.request<AccessCodesUnmanagedListResponse>({
|
|
121
|
+
url: '/access_codes/unmanaged/list',
|
|
122
|
+
method: 'post',
|
|
123
|
+
data: body,
|
|
124
|
+
})
|
|
125
|
+
return data.access_codes
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async update(body: AccessCodesUnmanagedUpdateBody): Promise<void> {
|
|
129
|
+
await this.client.request<AccessCodesUnmanagedUpdateResponse>({
|
|
130
|
+
url: '/access_codes/unmanaged/update',
|
|
131
|
+
method: 'post',
|
|
132
|
+
data: body,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type AccessCodesUnmanagedConvertToManagedBody =
|
|
138
|
+
RouteRequestBody<'/access_codes/unmanaged/convert_to_managed'>
|
|
139
|
+
|
|
140
|
+
export type AccessCodesUnmanagedConvertToManagedResponse = SetNonNullable<
|
|
141
|
+
Required<RouteResponse<'/access_codes/unmanaged/convert_to_managed'>>
|
|
142
|
+
>
|
|
143
|
+
|
|
144
|
+
export type AccessCodesUnmanagedDeleteBody =
|
|
145
|
+
RouteRequestBody<'/access_codes/unmanaged/delete'>
|
|
146
|
+
|
|
147
|
+
export type AccessCodesUnmanagedDeleteResponse = SetNonNullable<
|
|
148
|
+
Required<RouteResponse<'/access_codes/unmanaged/delete'>>
|
|
149
|
+
>
|
|
150
|
+
|
|
151
|
+
export type AccessCodesUnmanagedGetBody =
|
|
152
|
+
RouteRequestBody<'/access_codes/unmanaged/get'>
|
|
153
|
+
|
|
154
|
+
export type AccessCodesUnmanagedGetResponse = SetNonNullable<
|
|
155
|
+
Required<RouteResponse<'/access_codes/unmanaged/get'>>
|
|
156
|
+
>
|
|
157
|
+
|
|
158
|
+
export type AccessCodesUnmanagedListBody =
|
|
159
|
+
RouteRequestBody<'/access_codes/unmanaged/list'>
|
|
160
|
+
|
|
161
|
+
export type AccessCodesUnmanagedListResponse = SetNonNullable<
|
|
162
|
+
Required<RouteResponse<'/access_codes/unmanaged/list'>>
|
|
163
|
+
>
|
|
164
|
+
|
|
165
|
+
export type AccessCodesUnmanagedUpdateBody =
|
|
166
|
+
RouteRequestBody<'/access_codes/unmanaged/update'>
|
|
167
|
+
|
|
168
|
+
export type AccessCodesUnmanagedUpdateResponse = SetNonNullable<
|
|
169
|
+
Required<RouteResponse<'/access_codes/unmanaged/update'>>
|
|
170
|
+
>
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by generate-routes.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
|
+
import type { SetNonNullable } from 'type-fest'
|
|
8
|
+
|
|
9
|
+
import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpAccessCodesUnmanaged } from './access-codes-unmanaged.js'
|
|
25
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
26
|
+
|
|
27
|
+
export class SeamHttpAccessCodes {
|
|
28
|
+
client: Client
|
|
29
|
+
|
|
30
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
31
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
32
|
+
this.client = createClient(clientOptions)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static fromClient(
|
|
36
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
37
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
38
|
+
): SeamHttpAccessCodes {
|
|
39
|
+
const constructorOptions = { ...options, client }
|
|
40
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
41
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
42
|
+
}
|
|
43
|
+
return new SeamHttpAccessCodes(constructorOptions)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromApiKey(
|
|
47
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
48
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
49
|
+
): SeamHttpAccessCodes {
|
|
50
|
+
const constructorOptions = { ...options, apiKey }
|
|
51
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
52
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
53
|
+
}
|
|
54
|
+
return new SeamHttpAccessCodes(constructorOptions)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static fromClientSessionToken(
|
|
58
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
59
|
+
options: Omit<
|
|
60
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
61
|
+
'clientSessionToken'
|
|
62
|
+
> = {},
|
|
63
|
+
): SeamHttpAccessCodes {
|
|
64
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
65
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
66
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
67
|
+
}
|
|
68
|
+
return new SeamHttpAccessCodes(constructorOptions)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static async fromPublishableKey(
|
|
72
|
+
publishableKey: string,
|
|
73
|
+
userIdentifierKey: string,
|
|
74
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
75
|
+
): Promise<SeamHttpAccessCodes> {
|
|
76
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
77
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
78
|
+
const client = createClient(clientOptions)
|
|
79
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
80
|
+
const { token } = await clientSessions.getOrCreate({
|
|
81
|
+
user_identifier_key: userIdentifierKey,
|
|
82
|
+
})
|
|
83
|
+
return SeamHttpAccessCodes.fromClientSessionToken(token, options)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get unmanaged(): SeamHttpAccessCodesUnmanaged {
|
|
87
|
+
return SeamHttpAccessCodesUnmanaged.fromClient(this.client)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async create(
|
|
91
|
+
body: AccessCodesCreateBody,
|
|
92
|
+
): Promise<AccessCodesCreateResponse['access_code']> {
|
|
93
|
+
const { data } = await this.client.request<AccessCodesCreateResponse>({
|
|
94
|
+
url: '/access_codes/create',
|
|
95
|
+
method: 'post',
|
|
96
|
+
data: body,
|
|
97
|
+
})
|
|
98
|
+
return data.access_code
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async createMultiple(
|
|
102
|
+
body: AccessCodesCreateMultipleBody,
|
|
103
|
+
): Promise<AccessCodesCreateMultipleResponse['access_codes']> {
|
|
104
|
+
const { data } =
|
|
105
|
+
await this.client.request<AccessCodesCreateMultipleResponse>({
|
|
106
|
+
url: '/access_codes/create_multiple',
|
|
107
|
+
method: 'post',
|
|
108
|
+
data: body,
|
|
109
|
+
})
|
|
110
|
+
return data.access_codes
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async delete(body: AccessCodesDeleteBody): Promise<void> {
|
|
114
|
+
await this.client.request<AccessCodesDeleteResponse>({
|
|
115
|
+
url: '/access_codes/delete',
|
|
116
|
+
method: 'post',
|
|
117
|
+
data: body,
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async generateCode(
|
|
122
|
+
body: AccessCodesGenerateCodeBody,
|
|
123
|
+
): Promise<AccessCodesGenerateCodeResponse['generated_code']> {
|
|
124
|
+
const { data } = await this.client.request<AccessCodesGenerateCodeResponse>(
|
|
125
|
+
{
|
|
126
|
+
url: '/access_codes/generate_code',
|
|
127
|
+
method: 'post',
|
|
128
|
+
data: body,
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
return data.generated_code
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async get(
|
|
135
|
+
body: AccessCodesGetBody,
|
|
136
|
+
): Promise<AccessCodesGetResponse['access_code']> {
|
|
137
|
+
const { data } = await this.client.request<AccessCodesGetResponse>({
|
|
138
|
+
url: '/access_codes/get',
|
|
139
|
+
method: 'post',
|
|
140
|
+
data: body,
|
|
141
|
+
})
|
|
142
|
+
return data.access_code
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async list(
|
|
146
|
+
body: AccessCodesListBody,
|
|
147
|
+
): Promise<AccessCodesListResponse['access_codes']> {
|
|
148
|
+
const { data } = await this.client.request<AccessCodesListResponse>({
|
|
149
|
+
url: '/access_codes/list',
|
|
150
|
+
method: 'post',
|
|
151
|
+
data: body,
|
|
152
|
+
})
|
|
153
|
+
return data.access_codes
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async pullBackupAccessCode(
|
|
157
|
+
body: AccessCodesPullBackupAccessCodeBody,
|
|
158
|
+
): Promise<AccessCodesPullBackupAccessCodeResponse['backup_access_code']> {
|
|
159
|
+
const { data } =
|
|
160
|
+
await this.client.request<AccessCodesPullBackupAccessCodeResponse>({
|
|
161
|
+
url: '/access_codes/pull_backup_access_code',
|
|
162
|
+
method: 'post',
|
|
163
|
+
data: body,
|
|
164
|
+
})
|
|
165
|
+
return data.backup_access_code
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async update(body: AccessCodesUpdateBody): Promise<void> {
|
|
169
|
+
await this.client.request<AccessCodesUpdateResponse>({
|
|
170
|
+
url: '/access_codes/update',
|
|
171
|
+
method: 'post',
|
|
172
|
+
data: body,
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export type AccessCodesCreateBody = RouteRequestBody<'/access_codes/create'>
|
|
178
|
+
|
|
179
|
+
export type AccessCodesCreateResponse = SetNonNullable<
|
|
180
|
+
Required<RouteResponse<'/access_codes/create'>>
|
|
181
|
+
>
|
|
182
|
+
|
|
183
|
+
export type AccessCodesCreateMultipleBody =
|
|
184
|
+
RouteRequestBody<'/access_codes/create_multiple'>
|
|
185
|
+
|
|
186
|
+
export type AccessCodesCreateMultipleResponse = SetNonNullable<
|
|
187
|
+
Required<RouteResponse<'/access_codes/create_multiple'>>
|
|
188
|
+
>
|
|
189
|
+
|
|
190
|
+
export type AccessCodesDeleteBody = RouteRequestBody<'/access_codes/delete'>
|
|
191
|
+
|
|
192
|
+
export type AccessCodesDeleteResponse = SetNonNullable<
|
|
193
|
+
Required<RouteResponse<'/access_codes/delete'>>
|
|
194
|
+
>
|
|
195
|
+
|
|
196
|
+
export type AccessCodesGenerateCodeBody =
|
|
197
|
+
RouteRequestBody<'/access_codes/generate_code'>
|
|
198
|
+
|
|
199
|
+
export type AccessCodesGenerateCodeResponse = SetNonNullable<
|
|
200
|
+
Required<RouteResponse<'/access_codes/generate_code'>>
|
|
201
|
+
>
|
|
202
|
+
|
|
203
|
+
export type AccessCodesGetBody = RouteRequestBody<'/access_codes/get'>
|
|
204
|
+
|
|
205
|
+
export type AccessCodesGetResponse = SetNonNullable<
|
|
206
|
+
Required<RouteResponse<'/access_codes/get'>>
|
|
207
|
+
>
|
|
208
|
+
|
|
209
|
+
export type AccessCodesListBody = RouteRequestBody<'/access_codes/list'>
|
|
210
|
+
|
|
211
|
+
export type AccessCodesListResponse = SetNonNullable<
|
|
212
|
+
Required<RouteResponse<'/access_codes/list'>>
|
|
213
|
+
>
|
|
214
|
+
|
|
215
|
+
export type AccessCodesPullBackupAccessCodeBody =
|
|
216
|
+
RouteRequestBody<'/access_codes/pull_backup_access_code'>
|
|
217
|
+
|
|
218
|
+
export type AccessCodesPullBackupAccessCodeResponse = SetNonNullable<
|
|
219
|
+
Required<RouteResponse<'/access_codes/pull_backup_access_code'>>
|
|
220
|
+
>
|
|
221
|
+
|
|
222
|
+
export type AccessCodesUpdateBody = RouteRequestBody<'/access_codes/update'>
|
|
223
|
+
|
|
224
|
+
export type AccessCodesUpdateResponse = SetNonNullable<
|
|
225
|
+
Required<RouteResponse<'/access_codes/update'>>
|
|
226
|
+
>
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by generate-routes.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
|
+
import type { SetNonNullable } from 'type-fest'
|
|
8
|
+
|
|
9
|
+
import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
|
|
26
|
+
export class SeamHttpAcsAccessGroups {
|
|
27
|
+
client: Client
|
|
28
|
+
|
|
29
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
30
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
31
|
+
this.client = createClient(clientOptions)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromClient(
|
|
35
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
36
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
37
|
+
): SeamHttpAcsAccessGroups {
|
|
38
|
+
const constructorOptions = { ...options, client }
|
|
39
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
40
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
41
|
+
}
|
|
42
|
+
return new SeamHttpAcsAccessGroups(constructorOptions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromApiKey(
|
|
46
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
47
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
48
|
+
): SeamHttpAcsAccessGroups {
|
|
49
|
+
const constructorOptions = { ...options, apiKey }
|
|
50
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
51
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
52
|
+
}
|
|
53
|
+
return new SeamHttpAcsAccessGroups(constructorOptions)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromClientSessionToken(
|
|
57
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
58
|
+
options: Omit<
|
|
59
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
60
|
+
'clientSessionToken'
|
|
61
|
+
> = {},
|
|
62
|
+
): SeamHttpAcsAccessGroups {
|
|
63
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
64
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpAcsAccessGroups(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async fromPublishableKey(
|
|
71
|
+
publishableKey: string,
|
|
72
|
+
userIdentifierKey: string,
|
|
73
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
74
|
+
): Promise<SeamHttpAcsAccessGroups> {
|
|
75
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
76
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
77
|
+
const client = createClient(clientOptions)
|
|
78
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
79
|
+
const { token } = await clientSessions.getOrCreate({
|
|
80
|
+
user_identifier_key: userIdentifierKey,
|
|
81
|
+
})
|
|
82
|
+
return SeamHttpAcsAccessGroups.fromClientSessionToken(token, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async addUser(body: AcsAccessGroupsAddUserBody): Promise<void> {
|
|
86
|
+
await this.client.request<AcsAccessGroupsAddUserResponse>({
|
|
87
|
+
url: '/acs/access_groups/add_user',
|
|
88
|
+
method: 'post',
|
|
89
|
+
data: body,
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async create(
|
|
94
|
+
body: AcsAccessGroupsCreateBody,
|
|
95
|
+
): Promise<AcsAccessGroupsCreateResponse['acs_access_group']> {
|
|
96
|
+
const { data } = await this.client.request<AcsAccessGroupsCreateResponse>({
|
|
97
|
+
url: '/acs/access_groups/create',
|
|
98
|
+
method: 'post',
|
|
99
|
+
data: body,
|
|
100
|
+
})
|
|
101
|
+
return data.acs_access_group
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async delete(body: AcsAccessGroupsDeleteBody): Promise<void> {
|
|
105
|
+
await this.client.request<AcsAccessGroupsDeleteResponse>({
|
|
106
|
+
url: '/acs/access_groups/delete',
|
|
107
|
+
method: 'post',
|
|
108
|
+
data: body,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async get(
|
|
113
|
+
body: AcsAccessGroupsGetBody,
|
|
114
|
+
): Promise<AcsAccessGroupsGetResponse['acs_access_group']> {
|
|
115
|
+
const { data } = await this.client.request<AcsAccessGroupsGetResponse>({
|
|
116
|
+
url: '/acs/access_groups/get',
|
|
117
|
+
method: 'post',
|
|
118
|
+
data: body,
|
|
119
|
+
})
|
|
120
|
+
return data.acs_access_group
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async list(
|
|
124
|
+
body: AcsAccessGroupsListBody,
|
|
125
|
+
): Promise<AcsAccessGroupsListResponse['acs_access_groups']> {
|
|
126
|
+
const { data } = await this.client.request<AcsAccessGroupsListResponse>({
|
|
127
|
+
url: '/acs/access_groups/list',
|
|
128
|
+
method: 'post',
|
|
129
|
+
data: body,
|
|
130
|
+
})
|
|
131
|
+
return data.acs_access_groups
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async listUsers(
|
|
135
|
+
body: AcsAccessGroupsListUsersBody,
|
|
136
|
+
): Promise<AcsAccessGroupsListUsersResponse['acs_users']> {
|
|
137
|
+
const { data } =
|
|
138
|
+
await this.client.request<AcsAccessGroupsListUsersResponse>({
|
|
139
|
+
url: '/acs/access_groups/list_users',
|
|
140
|
+
method: 'post',
|
|
141
|
+
data: body,
|
|
142
|
+
})
|
|
143
|
+
return data.acs_users
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async removeUser(body: AcsAccessGroupsRemoveUserBody): Promise<void> {
|
|
147
|
+
await this.client.request<AcsAccessGroupsRemoveUserResponse>({
|
|
148
|
+
url: '/acs/access_groups/remove_user',
|
|
149
|
+
method: 'post',
|
|
150
|
+
data: body,
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async update(body: AcsAccessGroupsUpdateBody): Promise<void> {
|
|
155
|
+
await this.client.request<AcsAccessGroupsUpdateResponse>({
|
|
156
|
+
url: '/acs/access_groups/update',
|
|
157
|
+
method: 'post',
|
|
158
|
+
data: body,
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type AcsAccessGroupsAddUserBody =
|
|
164
|
+
RouteRequestBody<'/acs/access_groups/add_user'>
|
|
165
|
+
|
|
166
|
+
export type AcsAccessGroupsAddUserResponse = SetNonNullable<
|
|
167
|
+
Required<RouteResponse<'/acs/access_groups/add_user'>>
|
|
168
|
+
>
|
|
169
|
+
|
|
170
|
+
export type AcsAccessGroupsCreateBody =
|
|
171
|
+
RouteRequestBody<'/acs/access_groups/create'>
|
|
172
|
+
|
|
173
|
+
export type AcsAccessGroupsCreateResponse = SetNonNullable<
|
|
174
|
+
Required<RouteResponse<'/acs/access_groups/create'>>
|
|
175
|
+
>
|
|
176
|
+
|
|
177
|
+
export type AcsAccessGroupsDeleteBody =
|
|
178
|
+
RouteRequestBody<'/acs/access_groups/delete'>
|
|
179
|
+
|
|
180
|
+
export type AcsAccessGroupsDeleteResponse = SetNonNullable<
|
|
181
|
+
Required<RouteResponse<'/acs/access_groups/delete'>>
|
|
182
|
+
>
|
|
183
|
+
|
|
184
|
+
export type AcsAccessGroupsGetBody = RouteRequestBody<'/acs/access_groups/get'>
|
|
185
|
+
|
|
186
|
+
export type AcsAccessGroupsGetResponse = SetNonNullable<
|
|
187
|
+
Required<RouteResponse<'/acs/access_groups/get'>>
|
|
188
|
+
>
|
|
189
|
+
|
|
190
|
+
export type AcsAccessGroupsListBody =
|
|
191
|
+
RouteRequestBody<'/acs/access_groups/list'>
|
|
192
|
+
|
|
193
|
+
export type AcsAccessGroupsListResponse = SetNonNullable<
|
|
194
|
+
Required<RouteResponse<'/acs/access_groups/list'>>
|
|
195
|
+
>
|
|
196
|
+
|
|
197
|
+
export type AcsAccessGroupsListUsersBody =
|
|
198
|
+
RouteRequestBody<'/acs/access_groups/list_users'>
|
|
199
|
+
|
|
200
|
+
export type AcsAccessGroupsListUsersResponse = SetNonNullable<
|
|
201
|
+
Required<RouteResponse<'/acs/access_groups/list_users'>>
|
|
202
|
+
>
|
|
203
|
+
|
|
204
|
+
export type AcsAccessGroupsRemoveUserBody =
|
|
205
|
+
RouteRequestBody<'/acs/access_groups/remove_user'>
|
|
206
|
+
|
|
207
|
+
export type AcsAccessGroupsRemoveUserResponse = SetNonNullable<
|
|
208
|
+
Required<RouteResponse<'/acs/access_groups/remove_user'>>
|
|
209
|
+
>
|
|
210
|
+
|
|
211
|
+
export type AcsAccessGroupsUpdateBody =
|
|
212
|
+
RouteRequestBody<'/acs/access_groups/update'>
|
|
213
|
+
|
|
214
|
+
export type AcsAccessGroupsUpdateResponse = SetNonNullable<
|
|
215
|
+
Required<RouteResponse<'/acs/access_groups/update'>>
|
|
216
|
+
>
|