Skip to content

Commit 637e824

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore: update SDK settings (#3)
1 parent 9e7d1ac commit 637e824

30 files changed

+82
-83
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ $ cd sent-node
5555
# With yarn
5656
$ yarn link
5757
$ cd ../my-package
58-
$ yarn link sent
58+
$ yarn link @sent/node
5959

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

6666
## Running tests

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sent Node API Library
22

3-
[![NPM version](https://img.shields.io/npm/v/sent.svg)](https://npmjs.org/package/sent) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/sent)
3+
[![NPM version](https://img.shields.io/npm/v/@sent/node.svg)](https://npmjs.org/package/@sent/node) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@sent/node)
44

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

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

1313
```sh
14-
npm install git+ssh://[email protected]:sentdm/sent-node.git
14+
npm install @sent/node
1515
```
1616

17-
> [!NOTE]
18-
> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install sent`
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 Sent from 'sent';
23+
import Sent from '@sent/node';
2724

2825
const client = new Sent();
2926

@@ -40,7 +37,7 @@ This library includes TypeScript definitions for all request params and response
4037

4138
<!-- prettier-ignore -->
4239
```ts
43-
import Sent from 'sent';
40+
import Sent from '@sent/node';
4441

4542
const client = new Sent();
4643

@@ -207,11 +204,11 @@ add the following import before your first import `from "Sent"`:
207204
```ts
208205
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
209206
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
210-
import 'sent/shims/web';
211-
import Sent from 'sent';
207+
import '@sent/node/shims/web';
208+
import Sent from '@sent/node';
212209
```
213210

214-
To do the inverse, add `import "sent/shims/node"` (which does import polyfills).
211+
To do the inverse, add `import "@sent/node/shims/node"` (which does import polyfills).
215212
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/sentdm/sent-node/tree/main/src/_shims#readme)).
216213

217214
### Logging and middleware
@@ -221,7 +218,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
221218

222219
```ts
223220
import { fetch } from 'undici'; // as one example
224-
import Sent from 'sent';
221+
import Sent from '@sent/node';
225222

226223
const client = new Sent({
227224
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {

jest.config.ts

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "sent",
2+
"name": "@sent/node",
33
"version": "0.0.1-alpha.0",
44
"description": "The official TypeScript library for the Sent API",
55
"author": "Sent <[email protected]>",
@@ -60,8 +60,8 @@
6060
"./shims/web.mjs"
6161
],
6262
"imports": {
63-
"sent": ".",
64-
"sent/*": "./src/*"
63+
"@sent/node": ".",
64+
"@sent/node/*": "./src/*"
6565
},
6666
"exports": {
6767
"./_shims/auto/*": {

scripts/build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs
88

99
# Build into dist and will publish the package from there,
1010
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
11-
# This way importing from `"sent/resources/foo"` works
11+
# This way importing from `"@sent/node/resources/foo"` works
1212
# even with `"moduleResolution": "node"`
1313

1414
rm -rf dist; mkdir dist
@@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs
4747

4848
# make sure that nothing crashes when we require the output CJS or
4949
# import the output ESM
50-
(cd dist && node -e 'require("sent")')
51-
(cd dist && node -e 'import("sent")' --input-type=module)
50+
(cd dist && node -e 'require("@sent/node")')
51+
(cd dist && node -e 'import("@sent/node")' --input-type=module)
5252

5353
if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
5454
then

scripts/utils/postprocess-files.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('fs');
22
const path = require('path');
33
const { parse } = require('@typescript-eslint/parser');
44

5-
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'sent/';
5+
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? '@sent/node/';
66

77
const distDir =
88
process.env['DIST_PATH'] ?
@@ -142,7 +142,7 @@ async function postprocess() {
142142

143143
if (file.endsWith('.d.ts')) {
144144
// work around bad tsc behavior
145-
// if we have `import { type Readable } from 'sent/_shims/index'`,
145+
// if we have `import { type Readable } from '@sent/node/_shims/index'`,
146146
// tsc sometimes replaces `Readable` with `import("stream").Readable` inline
147147
// in the output .d.ts
148148
transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable');

src/_shims/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 👋 Wondering what everything in here does?
22

3-
`sent` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
3+
`@sent/node` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
44
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
55

6-
To do this, `sent` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
6+
To do this, `@sent/node` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
77

88
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
99
automatically select the correct shims for each environment. However, conditional exports are a fairly new
@@ -15,32 +15,32 @@ getting the wrong raw `Response` type from `.asResponse()`, for example.
1515

1616
The user can work around these issues by manually importing one of:
1717

18-
- `import 'sent/shims/node'`
19-
- `import 'sent/shims/web'`
18+
- `import '@sent/node/shims/node'`
19+
- `import '@sent/node/shims/web'`
2020

2121
All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.
2222

2323
### How it works - Runtime
2424

25-
Runtime shims get installed by calling `setShims` exported by `sent/_shims/registry`.
25+
Runtime shims get installed by calling `setShims` exported by `@sent/node/_shims/registry`.
2626

27-
Manually importing `sent/shims/node` or `sent/shims/web`, calls `setShims` with the respective runtime shims.
27+
Manually importing `@sent/node/shims/node` or `@sent/node/shims/web`, calls `setShims` with the respective runtime shims.
2828

29-
All client code imports shims from `sent/_shims/index`, which:
29+
All client code imports shims from `@sent/node/_shims/index`, which:
3030

3131
- checks if shims have been set manually
32-
- if not, calls `setShims` with the shims from `sent/_shims/auto/runtime`
33-
- re-exports the installed shims from `sent/_shims/registry`.
32+
- if not, calls `setShims` with the shims from `@sent/node/_shims/auto/runtime`
33+
- re-exports the installed shims from `@sent/node/_shims/registry`.
3434

35-
`sent/_shims/auto/runtime` exports web runtime shims.
36-
If the `node` export condition is set, the export map replaces it with `sent/_shims/auto/runtime-node`.
35+
`@sent/node/_shims/auto/runtime` exports web runtime shims.
36+
If the `node` export condition is set, the export map replaces it with `@sent/node/_shims/auto/runtime-node`.
3737

3838
### How it works - Type time
3939

40-
All client code imports shim types from `sent/_shims/index`, which selects the manual types from `sent/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `sent/_shims/auto/types`.
40+
All client code imports shim types from `@sent/node/_shims/index`, which selects the manual types from `@sent/node/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `@sent/node/_shims/auto/types`.
4141

42-
`sent/_shims/manual-types` exports an empty namespace.
43-
Manually importing `sent/shims/node` or `sent/shims/web` merges declarations into this empty namespace, so they get picked up by `sent/_shims/index`.
42+
`@sent/node/_shims/manual-types` exports an empty namespace.
43+
Manually importing `@sent/node/shims/node` or `@sent/node/shims/web` merges declarations into this empty namespace, so they get picked up by `@sent/node/_shims/index`.
4444

45-
`sent/_shims/auto/types` exports web type definitions.
46-
If the `node` export condition is set, the export map replaces it with `sent/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
45+
`@sent/node/_shims/auto/types` exports web type definitions.
46+
If the `node` export condition is set, the export map replaces it with `@sent/node/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.

src/_shims/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
import { manual } from './manual-types';
5-
import * as auto from 'sent/_shims/auto/types';
5+
import * as auto from '@sent/node/_shims/auto/types';
66
import { type RequestOptions } from '../core';
77

88
type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual;

src/_shims/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
const shims = require('./registry');
5-
const auto = require('sent/_shims/auto/runtime');
5+
const auto = require('@sent/node/_shims/auto/runtime');
66
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
77
for (const property of Object.keys(shims)) {
88
Object.defineProperty(exports, property, {

src/_shims/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
import * as shims from './registry.mjs';
5-
import * as auto from 'sent/_shims/auto/runtime';
5+
import * as auto from '@sent/node/_shims/auto/runtime';
66
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
77
export * from './registry.mjs';

0 commit comments

Comments
 (0)