Skip to content

Commit 8fee01c

Browse files
committed
Always use seam over client
1 parent 9bb0829 commit 8fee01c

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

examples/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export type Handler<Options = EmptyOptions> = DefaultHandler<Options, Context>
1919
type Context = DefaultContext & ClientContext
2020

2121
interface ClientContext {
22-
client: SeamHttp
22+
seam: SeamHttp
2323
}
2424

2525
const commands = [workspace]
2626

2727
const createAppContext: MiddlewareFunction = async (argv) => {
2828
const apiKey = argv['api-key']
2929
if (typeof apiKey !== 'string') throw new Error('Missing Seam API key')
30-
const client = SeamHttp.fromApiKey(apiKey)
31-
argv['client'] = client
30+
const seam = SeamHttp.fromApiKey(apiKey)
31+
argv['seam'] = seam
3232
}
3333

3434
const middleware = [...defaultMiddleware, createAppContext]

examples/workspace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const describe: Describe = 'Get workspace'
1111

1212
export const builder: Builder = {}
1313

14-
export const handler: Handler<Options> = async ({ client, logger }) => {
15-
const workspace = await client.workspaces.get()
14+
export const handler: Handler<Options> = async ({ seam, logger }) => {
15+
const workspace = await seam.workspaces.get()
1616
logger.info({ workspace }, 'workspace')
1717
}

test/seam/connect/api-key.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { SeamHttpInvalidTokenError } from 'lib/seam/connect/auth.js'
77

88
test('SeamHttp: fromApiKey returns instance authorized with apiKey', async (t) => {
99
const { seed, endpoint } = await getTestServer(t)
10-
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
11-
const device = await client.devices.get({
10+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
11+
const device = await seam.devices.get({
1212
device_id: seed.august_device_1,
1313
})
1414
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -17,17 +17,17 @@ test('SeamHttp: fromApiKey returns instance authorized with apiKey', async (t) =
1717

1818
test('SeamHttp: constructor returns instance authorized with apiKey', async (t) => {
1919
const { seed, endpoint } = await getTestServer(t)
20-
const client = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
21-
const device = await client.devices.get({
20+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
21+
const device = await seam.devices.get({
2222
device_id: seed.august_device_1,
2323
})
2424
t.is(device.workspace_id, seed.seed_workspace_1)
2525
t.is(device.device_id, seed.august_device_1)
2626
})
2727

2828
test('SeamHttp: constructor interprets single string argument as apiKey', (t) => {
29-
const client = new SeamHttp('seam_apikey_token')
30-
t.truthy(client)
29+
const seam = new SeamHttp('seam_apikey_token')
30+
t.truthy(seam)
3131
t.throws(() => new SeamHttp('some-invalid-key-format'), {
3232
instanceOf: SeamHttpInvalidTokenError,
3333
message: /apiKey/,

test/seam/connect/client-session-token.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { SeamHttpInvalidTokenError } from 'lib/seam/connect/auth.js'
77

88
test('SeamHttp: fromClientSessionToken returns instance authorized with clientSessionToken', async (t) => {
99
const { seed, endpoint } = await getTestServer(t)
10-
const client = SeamHttp.fromClientSessionToken(seed.seam_cst1_token, {
10+
const seam = SeamHttp.fromClientSessionToken(seed.seam_cst1_token, {
1111
endpoint,
1212
})
13-
const device = await client.devices.get({
13+
const device = await seam.devices.get({
1414
device_id: seed.august_device_1,
1515
})
1616
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -19,11 +19,11 @@ test('SeamHttp: fromClientSessionToken returns instance authorized with clientSe
1919

2020
test('SeamHttp: constructor returns instance authorized with clientSessionToken', async (t) => {
2121
const { seed, endpoint } = await getTestServer(t)
22-
const client = new SeamHttp({
22+
const seam = new SeamHttp({
2323
clientSessionToken: seed.seam_cst1_token,
2424
endpoint,
2525
})
26-
const device = await client.devices.get({
26+
const device = await seam.devices.get({
2727
device_id: seed.august_device_1,
2828
})
2929
t.is(device.workspace_id, seed.seed_workspace_1)

test/seam/connect/client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { SeamHttp } from '@seamapi/http/connect'
55

66
test('SeamHttp: fromClient returns instance that uses client', async (t) => {
77
const { seed, endpoint } = await getTestServer(t)
8-
const client = SeamHttp.fromClient(
8+
const seam = SeamHttp.fromClient(
99
SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client,
1010
)
11-
const device = await client.devices.get({
11+
const device = await seam.devices.get({
1212
device_id: seed.august_device_1,
1313
})
1414
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -17,10 +17,10 @@ test('SeamHttp: fromClient returns instance that uses client', async (t) => {
1717

1818
test('SeamHttp: constructor returns instance that uses client', async (t) => {
1919
const { seed, endpoint } = await getTestServer(t)
20-
const client = new SeamHttp({
20+
const seam = new SeamHttp({
2121
client: SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client,
2222
})
23-
const device = await client.devices.get({
23+
const device = await seam.devices.get({
2424
device_id: seed.august_device_1,
2525
})
2626
t.is(device.workspace_id, seed.seed_workspace_1)

test/seam/connect/env.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ test.serial(
2121
async (t) => {
2222
const { seed, endpoint } = await getTestServer(t)
2323
env.SEAM_API_KEY = seed.seam_apikey1_token
24-
const client = new SeamHttp({ endpoint })
25-
const device = await client.devices.get({
24+
const seam = new SeamHttp({ endpoint })
25+
const device = await seam.devices.get({
2626
device_id: seed.august_device_1,
2727
})
2828
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -35,8 +35,8 @@ test.serial(
3535
async (t) => {
3636
const { seed, endpoint } = await getTestServer(t)
3737
env.SEAM_API_KEY = 'some-invalid-api-key'
38-
const client = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
39-
const device = await client.devices.get({
38+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
39+
const device = await seam.devices.get({
4040
device_id: seed.august_device_1,
4141
})
4242
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -48,17 +48,17 @@ test.serial(
4848
'SeamHttp: apiKey option as first argument overrides environment variables',
4949
(t) => {
5050
env.SEAM_API_KEY = 'some-invalid-api-key'
51-
const client = new SeamHttp('seam_apikey_token')
52-
t.truthy(client)
51+
const seam = new SeamHttp('seam_apikey_token')
52+
t.truthy(seam)
5353
},
5454
)
5555

5656
test.serial(
5757
'SeamHttp: constructor uses SEAM_API_KEY environment variable when passed no argument',
5858
(t) => {
5959
env.SEAM_API_KEY = 'seam_apikey_token'
60-
const client = new SeamHttp()
61-
t.truthy(client)
60+
const seam = new SeamHttp()
61+
t.truthy(seam)
6262
},
6363
)
6464

@@ -89,8 +89,8 @@ test.serial(
8989
const { seed, endpoint } = await getTestServer(t)
9090
env.SEAM_API_URL = 'https://example.com'
9191
env.SEAM_ENDPOINT = endpoint
92-
const client = new SeamHttp({ apiKey: seed.seam_apikey1_token })
93-
const device = await client.devices.get({
92+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token })
93+
const device = await seam.devices.get({
9494
device_id: seed.august_device_1,
9595
})
9696
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -103,8 +103,8 @@ test.serial(
103103
async (t) => {
104104
const { seed, endpoint } = await getTestServer(t)
105105
env.SEAM_API_URL = endpoint
106-
const client = new SeamHttp({ apiKey: seed.seam_apikey1_token })
107-
const device = await client.devices.get({
106+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token })
107+
const device = await seam.devices.get({
108108
device_id: seed.august_device_1,
109109
})
110110
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -118,8 +118,8 @@ test.serial(
118118
const { seed, endpoint } = await getTestServer(t)
119119
env.SEAM_API_URL = 'https://example.com'
120120
env.SEAM_ENDPOINT = 'https://example.com'
121-
const client = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
122-
const device = await client.devices.get({
121+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
122+
const device = await seam.devices.get({
123123
device_id: seed.august_device_1,
124124
})
125125
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -133,8 +133,8 @@ test.serial(
133133
const { seed, endpoint } = await getTestServer(t)
134134
env.SEAM_API_URL = 'https://example.com'
135135
env.SEAM_ENDPOINT = endpoint
136-
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token)
137-
const device = await client.devices.get({
136+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token)
137+
const device = await seam.devices.get({
138138
device_id: seed.august_device_1,
139139
})
140140
t.is(device.workspace_id, seed.seed_workspace_1)
@@ -148,8 +148,8 @@ test.serial(
148148
const { seed, endpoint } = await getTestServer(t)
149149
env.SEAM_API_URL = 'https://example.com'
150150
env.SEAM_ENDPOINT = endpoint
151-
const client = SeamHttp.fromClientSessionToken(seed.seam_cst1_token)
152-
const device = await client.devices.get({
151+
const seam = SeamHttp.fromClientSessionToken(seed.seam_cst1_token)
152+
const device = await seam.devices.get({
153153
device_id: seed.august_device_1,
154154
})
155155
t.is(device.workspace_id, seed.seed_workspace_1)

test/seam/connect/serialization.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ import { SeamHttp } from '@seamapi/http/connect'
55

66
test('serializes array params when undefined', async (t) => {
77
const { seed, endpoint } = await getTestServer(t)
8-
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
9-
const devices = await client.devices.list({
8+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
9+
const devices = await seam.devices.list({
1010
device_ids: undefined,
1111
})
1212
t.is(devices.length, 4)
1313
})
1414

1515
test('serializes array params when empty', async (t) => {
1616
const { seed, endpoint } = await getTestServer(t)
17-
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
18-
const devices = await client.devices.list({
17+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
18+
const devices = await seam.devices.list({
1919
device_ids: [],
2020
})
2121
t.is(devices.length, 0)
2222
})
2323

2424
test('serializes array params when non-empty', async (t) => {
2525
const { seed, endpoint } = await getTestServer(t)
26-
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
27-
const devices = await client.devices.list({
26+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
27+
const devices = await seam.devices.list({
2828
device_ids: [seed.august_device_1, seed.ecobee_device_1],
2929
})
3030
t.is(devices.length, 2)

0 commit comments

Comments
 (0)