Skip to content

feat: Add Seam LTS version #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Seam HTTP Client

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

JavaScript HTTP client for the Seam API written in TypeScript.
Expand Down
2 changes: 1 addition & 1 deletion prepack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const injectVersion = async (path: string): Promise<string> => {
const data = buff
.toString()
.replace(
'const seamapiJavascriptHttpVersion = null',
"const seamapiJavascriptHttpVersion = '0.0.0'",
`const seamapiJavascriptHttpVersion = '${version}'`,
)

Expand Down
1 change: 1 addition & 0 deletions src/lib/lts-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const seamApiLtsVersion = '1.0.0'
2 changes: 2 additions & 0 deletions src/lib/seam/connect/parse-options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { seamApiLtsVersion } from 'lib/lts-version.js'
import version from 'lib/version.js'

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

export type Options =
Expand Down
4 changes: 4 additions & 0 deletions src/lib/seam/connect/seam-http.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { seamApiLtsVersion } from 'lib/lts-version.js'

import {
getAuthHeadersForClientSessionToken,
warnOnInsecureuserIdentifierKey,
Expand Down Expand Up @@ -42,6 +44,8 @@ import {
export class SeamHttp {
client: Client
readonly defaults: Required<SeamHttpRequestOptions>
readonly ltsVersion = seamApiLtsVersion
static ltsVersion = seamApiLtsVersion

constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
const options = parseOptions(apiKeyOrOptions)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const seamapiJavascriptHttpVersion = null
const seamapiJavascriptHttpVersion = '0.0.0'

export default seamapiJavascriptHttpVersion
28 changes: 28 additions & 0 deletions test/seam/connect/headers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import test from 'ava'
import { randomUUID } from 'crypto'
import { getTestServer } from 'fixtures/seam/connect/api.js'
import nock from 'nock'

import { SeamHttp } from '@seamapi/http/connect'

import seamapiJavascriptHttpVersion from 'lib/version.js'

test('SeamHttp: sends default headers', async (t) => {
const { seed, endpoint } = await getTestServer(t)
const deviceId = randomUUID()
nock(endpoint, {
reqheaders: {
'seam-sdk-name': 'seamapi/javascript-http',
'seam-lts-version': SeamHttp.ltsVersion,
'seam-sdk-version': seamapiJavascriptHttpVersion,
},
})
.post('/devices/get', { device_id: deviceId })
.reply(200, { device: { device_id: deviceId } })
const seam = new SeamHttp({ apiKey: seed.seam_apikey1_token, endpoint })
const device = await seam.devices.get({
device_id: deviceId,
})
t.is(SeamHttp.ltsVersion, seam.ltsVersion)
t.is(device.device_id, deviceId)
})