Skip to content

Commit 60fa7ef

Browse files
feat(api): manual updates
1 parent da3410b commit 60fa7ef

34 files changed

Lines changed: 218 additions & 58 deletions

.github/workflows/publish-npm.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow is triggered when a GitHub release is created.
2+
# It can also be run manually to re-publish to NPM in case it failed for some reason.
3+
# You can run this workflow by navigating to https://www.github.com/sentdm/sent-dm-typescript/actions/workflows/publish-npm.yml
4+
name: Publish NPM
5+
on:
6+
workflow_dispatch:
7+
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
publish:
13+
name: publish
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
id-token: write
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
22+
- name: Set up Node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: '20'
26+
27+
- name: Set up pnpm
28+
uses: pnpm/action-setup@v4
29+
30+
- name: Install dependencies
31+
run: |
32+
pnpm install
33+
34+
- name: Publish to NPM
35+
run: |
36+
bash ./bin/publish-npm
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Doctor
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
release_doctor:
10+
name: release doctor
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'sentdm/sent-dm-typescript' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
13+
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- name: Check release environment
18+
run: |
19+
bash ./bin/check-release-environment
20+

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.7.2"
3+
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 44
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sent%2Fsent-dm-433bfd8c688a6b6d2d4f964bb59121d692798f4e2bb6cb47f6110c4f0e1f638d.yml
33
openapi_spec_hash: 5378295d401c8c1152c1946cc7dbd69f
4-
config_hash: 64ada5a5574e037e7ada612d3df30ae8
4+
config_hash: 338e3f4d5c4c5320b6c1cd97b26baa6a

CONTRIBUTING.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ If you’d like to use the repository from source, you can either install from g
4242
To install via git:
4343

4444
```sh
45-
$ npm install git+ssh://git@github.com:stainless-sdks/sent-dm-typescript.git
45+
$ npm install git+ssh://git@github.com:sentdm/sent-dm-typescript.git
4646
```
4747

4848
Alternatively, to link a local copy of the repo:
4949

5050
```sh
5151
# Clone
52-
$ git clone https://www.github.com/stainless-sdks/sent-dm-typescript
52+
$ git clone https://www.github.com/sentdm/sent-dm-typescript
5353
$ cd sent-dm-typescript
5454

5555
# With yarn
5656
$ yarn link
5757
$ cd ../my-package
58-
$ yarn link sent-dm
58+
$ yarn link @sentdm/sentdm
5959

6060
# With pnpm
6161
$ pnpm link --global
6262
$ cd ../my-package
63-
$ pnpm link -—global sent-dm
63+
$ pnpm link -—global @sentdm/sentdm
6464
```
6565

6666
## Running tests
@@ -91,3 +91,17 @@ To format and fix all lint issues automatically:
9191
```sh
9292
$ pnpm fix
9393
```
94+
95+
## Publishing and releases
96+
97+
Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
98+
the changes aren't made through the automated pipeline, you may want to make releases manually.
99+
100+
### Publish with a GitHub workflow
101+
102+
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/sentdm/sent-dm-typescript/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.
103+
104+
### Publish manually
105+
106+
If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
107+
the environment.

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sent Dm TypeScript API Library
22

3-
[![NPM version](<https://img.shields.io/npm/v/sent-dm.svg?label=npm%20(stable)>)](https://npmjs.org/package/sent-dm) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/sent-dm)
3+
[![NPM version](<https://img.shields.io/npm/v/@sentdm/sentdm.svg?label=npm%20(stable)>)](https://npmjs.org/package/@sentdm/sentdm) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@sentdm/sentdm)
44

55
This library provides convenient access to the Sent Dm REST API from server-side TypeScript or JavaScript.
66

@@ -11,19 +11,16 @@ It is generated with [Stainless](https://www.stainless.com/).
1111
## Installation
1212

1313
```sh
14-
npm install git+ssh://git@github.com:stainless-sdks/sent-dm-typescript.git
14+
npm install @sentdm/sentdm
1515
```
1616

17-
> [!NOTE]
18-
> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npm install sent-dm`
19-
2017
## Usage
2118

2219
The full API of this library can be found in [api.md](api.md).
2320

2421
<!-- prettier-ignore -->
2522
```js
26-
import SentDm from 'sent-dm';
23+
import SentDm from '@sentdm/sentdm';
2724

2825
const client = new SentDm({
2926
apiKey: process.env['SENT_DM_API_KEY'], // This is the default and can be omitted
@@ -48,7 +45,7 @@ This library includes TypeScript definitions for all request params and response
4845

4946
<!-- prettier-ignore -->
5047
```ts
51-
import SentDm from 'sent-dm';
48+
import SentDm from '@sentdm/sentdm';
5249

5350
const client = new SentDm({
5451
apiKey: process.env['SENT_DM_API_KEY'], // This is the default and can be omitted
@@ -225,7 +222,7 @@ The log level can be configured in two ways:
225222
2. Using the `logLevel` client option (overrides the environment variable if set)
226223

227224
```ts
228-
import SentDm from 'sent-dm';
225+
import SentDm from '@sentdm/sentdm';
229226

230227
const client = new SentDm({
231228
logLevel: 'debug', // Show all log messages
@@ -253,7 +250,7 @@ When providing a custom logger, the `logLevel` option still controls which messa
253250
below the configured level will not be sent to your logger.
254251

255252
```ts
256-
import SentDm from 'sent-dm';
253+
import SentDm from '@sentdm/sentdm';
257254
import pino from 'pino';
258255

259256
const logger = pino();
@@ -322,7 +319,7 @@ globalThis.fetch = fetch;
322319
Or pass it to the client:
323320

324321
```ts
325-
import SentDm from 'sent-dm';
322+
import SentDm from '@sentdm/sentdm';
326323
import fetch from 'my-fetch';
327324

328325
const client = new SentDm({ fetch });
@@ -333,7 +330,7 @@ const client = new SentDm({ fetch });
333330
If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
334331

335332
```ts
336-
import SentDm from 'sent-dm';
333+
import SentDm from '@sentdm/sentdm';
337334

338335
const client = new SentDm({
339336
fetchOptions: {
@@ -350,7 +347,7 @@ options to requests:
350347
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/node.svg" align="top" width="18" height="21"> **Node** <sup>[[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]</sup>
351348

352349
```ts
353-
import SentDm from 'sent-dm';
350+
import SentDm from '@sentdm/sentdm';
354351
import * as undici from 'undici';
355352

356353
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
@@ -364,7 +361,7 @@ const client = new SentDm({
364361
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/bun.svg" align="top" width="18" height="21"> **Bun** <sup>[[docs](https://bun.sh/guides/http/proxy)]</sup>
365362

366363
```ts
367-
import SentDm from 'sent-dm';
364+
import SentDm from '@sentdm/sentdm';
368365

369366
const client = new SentDm({
370367
fetchOptions: {
@@ -376,7 +373,7 @@ const client = new SentDm({
376373
<img src="https://raw.githubusercontent.com/stainless-api/sdk-assets/refs/heads/main/deno.svg" align="top" width="18" height="21"> **Deno** <sup>[[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]</sup>
377374

378375
```ts
379-
import SentDm from 'npm:sent-dm';
376+
import SentDm from 'npm:@sentdm/sentdm';
380377

381378
const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
382379
const client = new SentDm({
@@ -398,7 +395,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
398395

399396
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
400397

401-
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/sent-dm-typescript/issues) with questions, bugs, or suggestions.
398+
We are keen for your feedback; please open an [issue](https://www.github.com/sentdm/sent-dm-typescript/issues) with questions, bugs, or suggestions.
402399

403400
## Requirements
404401

bin/check-release-environment

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
errors=()
4+
5+
lenErrors=${#errors[@]}
6+
7+
if [[ lenErrors -gt 0 ]]; then
8+
echo -e "Found the following errors in the release environment:\n"
9+
10+
for error in "${errors[@]}"; do
11+
echo -e "- $error\n"
12+
done
13+
14+
exit 1
15+
fi
16+
17+
echo "The environment is ready to push releases!"
18+

bin/publish-npm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
set -eux
44

5-
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
5+
if [[ ${NPM_TOKEN:-} ]]; then
6+
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
7+
elif [[ ! ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-} ]]; then
8+
echo "ERROR: NPM_TOKEN must be set if not running in a Github Action with id-token permission"
9+
exit 1
10+
fi
611

712
pnpm build
813
cd dist
@@ -57,5 +62,8 @@ else
5762
TAG="latest"
5863
fi
5964

65+
# Install OIDC compatible npm version
66+
npm install --prefix ../oidc/ npm@11.6.2
67+
6068
# Publish with the appropriate tag
61-
pnpm publish --no-git-checks --tag "$TAG"
69+
pnpm publish --npm-path "$(cd ../ && pwd)/oidc/node_modules/.bin/npm" --no-git-checks --tag "$TAG"

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default tseslint.config(
2525
{
2626
patterns: [
2727
{
28-
regex: '^sent-dm(/.*)?',
28+
regex: '^@sentdm/sentdm(/.*)?',
2929
message: 'Use a relative import, not a package import.',
3030
},
3131
],

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = {
77
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
88
},
99
moduleNameMapper: {
10-
'^sent-dm$': '<rootDir>/src/index.ts',
11-
'^sent-dm/(.*)$': '<rootDir>/src/$1',
10+
'^@sentdm/sentdm$': '<rootDir>/src/index.ts',
11+
'^@sentdm/sentdm/(.*)$': '<rootDir>/src/$1',
1212
},
1313
modulePathIgnorePatterns: [
1414
'<rootDir>/ecosystem-tests/',

0 commit comments

Comments
 (0)