Skip to content

Commit f9dc262

Browse files
razor-xseambot
andauthored
Replace SeamWebookEvent with SeamEvent (#6)
* Replace SeamWebhookEvent with SeamEvent * Sync peerDependencies for types version * ci: Generate code * Use TIP and IMPORTANT in README * Fix event types --------- Co-authored-by: Seam Bot <devops@getseam.com>
1 parent 9c60bc3 commit f9dc262

File tree

5 files changed

+46
-56
lines changed

5 files changed

+46
-56
lines changed

.github/workflows/generate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
uses: ./.github/actions/setup
3232
with:
3333
install_dependencies: 'false'
34+
- name: Sync @seamapi/types version in peerDependencies
35+
run: |
36+
sudo apt-get install -y jq moreutils
37+
jq '.peerDependencies."@seamapi/types" = .devDependencies."@seamapi/types"' package.json | sponge package.json
3438
- name: Normalize package-lock.json
3539
run: npm install
3640
- name: Commit

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ in your application.
2727

2828
## Installation
2929

30-
_This is a low-level package meant for applications and libraries with particular dependency requirements.
31-
Before using this package, ensure you understand the installation and updating instructions.
32-
This SDK is entirely contained in the [seam package]. Seam recommends using that package instead
33-
for simpler dependency management._
30+
> [!IMPORTANT]
31+
> This is a low-level package meant for applications and libraries with particular dependency requirements.
32+
> Before using this package, ensure you understand the installation and updating instructions.
33+
> This SDK is entirely contained in the [seam package].
34+
> Seam recommends using that package instead for simpler dependency management.
3435
3536
Add this as a dependency to your project using [npm] with
3637

@@ -55,30 +56,29 @@ Refer to the next section for keeping the types updated.
5556

5657
#### Keeping up with the latest types
5758

58-
This package depends on [seamapi-types] for the latest TypeScript types.
59+
This package depends on [@seamapi/types] for the latest TypeScript types.
5960
New versions of this SDK are generally not released when new types are published.
6061
Unless your project frequently runs a blanket `npm update`,
6162
the types will become outdated with the Seam API over time.
6263
Thus, users of this package should explicitly install the types with
6364

6465
```
65-
$ npm install -D seamapi-types
66+
$ npm install -D @seamapi/types
6667
```
6768

6869
and update them when consuming new API features with
6970

7071
```
71-
$ npm install -D seamapi-types
72+
$ npm install -D @seamapi/types@latest
7273
```
7374

74-
[seamapi-types]: https://github.com/seamapi/seamapi-types/
75-
7675
## Usage
7776

7877
First, create a webhook using the Seam API or Seam Console
7978
and obtain a Seam webhook secret.
8079

81-
_This example is for [Express], see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how)._
80+
> [!TIP]
81+
> This example is for [Express], see the [Svix docs for more examples in specific frameworks](https://docs.svix.com/receiving/verifying-payloads/how).
8282
8383
```js
8484
import { SeamWebhook } from '@seamapi/webhook'

package-lock.json

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,18 @@
6666
"npm": ">= 9.0.0"
6767
},
6868
"peerDependencies": {
69-
"seamapi-types": "^1.42.0",
70-
"type-fest": "^4.0.0"
69+
"@seamapi/types": "^1.166.0"
7170
},
7271
"peerDependenciesMeta": {
73-
"seamapi-types": {
74-
"optional": true
75-
},
76-
"type-fest": {
72+
"@seamapi/types": {
7773
"optional": true
7874
}
7975
},
8076
"dependencies": {
8177
"svix": "^1.15.0"
8278
},
8379
"devDependencies": {
80+
"@seamapi/types": "^1.166.0",
8481
"@types/node": "^20.8.10",
8582
"ava": "^6.0.1",
8683
"c8": "^9.0.0",
@@ -92,11 +89,9 @@
9289
"eslint-plugin-simple-import-sort": "^12.0.0",
9390
"eslint-plugin-unused-imports": "^3.0.0",
9491
"prettier": "^3.0.0",
95-
"seamapi-types": "^1.42.0",
9692
"tsc-alias": "^1.8.2",
9793
"tsup": "^8.0.1",
9894
"tsx": "^4.6.2",
99-
"type-fest": "^4.14.0",
10095
"typescript": "^5.1.0"
10196
}
10297
}

src/lib/seam-webhook.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
import type { SeamEvent } from 'seamapi-types'
1+
import type { SeamEvent } from '@seamapi/types/connect'
22
import { Webhook } from 'svix'
33

4-
// UPSTREAM: This type should come from @seamapi/types.
5-
export type SeamWebhookEvent = Distribute<SeamEvent['event_type']>
6-
74
export class SeamWebhook {
85
readonly #webhook: Webhook
96

107
constructor(secret: string) {
118
this.#webhook = new Webhook(secret)
129
}
1310

14-
verify(payload: string, headers: Record<string, string>): SeamWebhookEvent {
15-
return this.#webhook.verify(payload, headers) as SeamWebhookEvent
11+
verify(payload: string, headers: Record<string, string>): SeamEvent {
12+
return this.#webhook.verify(payload, headers) as SeamEvent
1613
}
1714
}
18-
19-
type Distribute<EventType> = EventType extends SeamEvent['event_type']
20-
? {
21-
event_type: EventType
22-
} & Extract<SeamEvent, { event_type: EventType }>['payload']
23-
: never

0 commit comments

Comments
 (0)