Skip to content

Commit 696ba4c

Browse files
authored
feat: Add Seam LTS version (#50)
* feat: Add Seam LTS version * Add LTS badge * Update lts-version.ts * Update README.md * Add headers test
1 parent 42f6c9e commit 696ba4c

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Seam HTTP Client
22

33
[![npm](https://img.shields.io/npm/v/@seamapi/http.svg)](https://www.npmjs.com/package/@seamapi/http)
4+
[![Seam LTS Version](https://img.shields.io/badge/Seam_LTS-1.0.0-blue)](https://docs.seam.co/lts)
45
[![GitHub Actions](https://github.com/seamapi/javascript-http/actions/workflows/check.yml/badge.svg)](https://github.com/seamapi/javascript-http/actions/workflows/check.yml)
56

67
JavaScript HTTP client for the Seam API written in TypeScript.

prepack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const injectVersion = async (path: string): Promise<string> => {
2929
const data = buff
3030
.toString()
3131
.replace(
32-
'const seamapiJavascriptHttpVersion = null',
32+
"const seamapiJavascriptHttpVersion = '0.0.0'",
3333
`const seamapiJavascriptHttpVersion = '${version}'`,
3434
)
3535

src/lib/lts-version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const seamApiLtsVersion = '1.0.0'

src/lib/seam/connect/parse-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { seamApiLtsVersion } from 'lib/lts-version.js'
12
import version from 'lib/version.js'
23

34
import { getAuthHeaders } from './auth.js'
@@ -16,6 +17,7 @@ export const defaultEndpoint = 'https://connect.getseam.com'
1617
export const sdkHeaders = {
1718
'seam-sdk-name': 'seamapi/javascript-http',
1819
'seam-sdk-version': version,
20+
'seam-lts-version': seamApiLtsVersion,
1921
}
2022

2123
export type Options =

src/lib/seam/connect/seam-http.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { seamApiLtsVersion } from 'lib/lts-version.js'
2+
13
import {
24
getAuthHeadersForClientSessionToken,
35
warnOnInsecureuserIdentifierKey,
@@ -42,6 +44,8 @@ import {
4244
export class SeamHttp {
4345
client: Client
4446
readonly defaults: Required<SeamHttpRequestOptions>
47+
readonly ltsVersion = seamApiLtsVersion
48+
static ltsVersion = seamApiLtsVersion
4549

4650
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
4751
const options = parseOptions(apiKeyOrOptions)

src/lib/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const seamapiJavascriptHttpVersion = null
1+
const seamapiJavascriptHttpVersion = '0.0.0'
22

33
export default seamapiJavascriptHttpVersion

test/seam/connect/headers.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import test from 'ava'
2+
import { randomUUID } from 'crypto'
3+
import { getTestServer } from 'fixtures/seam/connect/api.js'
4+
import nock from 'nock'
5+
6+
import { SeamHttp } from '@seamapi/http/connect'
7+
8+
import seamapiJavascriptHttpVersion from 'lib/version.js'
9+
10+
test('SeamHttp: sends default headers', async (t) => {
11+
const { seed, endpoint } = await getTestServer(t)
12+
const deviceId = randomUUID()
13+
nock(endpoint, {
14+
reqheaders: {
15+
'seam-sdk-name': 'seamapi/javascript-http',
16+
'seam-lts-version': SeamHttp.ltsVersion,
17+
'seam-sdk-version': seamapiJavascriptHttpVersion,
18+
},
19+
})
20+
.post('/devices/get', { device_id: deviceId })
21+
.reply(200, { device: { device_id: deviceId } })
22+
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
23+
const device = await seam.devices.get({
24+
device_id: deviceId,
25+
})
26+
t.is(SeamHttp.ltsVersion, seam.ltsVersion)
27+
t.is(device.device_id, deviceId)
28+
})

0 commit comments

Comments
 (0)