Skip to content
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
32 changes: 32 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to NPM in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml
name: Publish NPM
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: |
yarn install

- name: Publish to NPM
run: |
bash ./bin/publish-npm
env:
NPM_TOKEN: ${{ secrets.SFC_NODES_NPM_TOKEN || secrets.NPM_TOKEN }}
Comment on lines +13 to +32

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 months ago

To fix the problem, add a permissions block to the workflow to explicitly specify the minimal access required for the GITHUB_TOKEN. Based on the workflow tasks, it likely only requires contents: read to check out the repository code and packages: write to publish to NPM. This should be added at the root of the workflow to apply to all jobs unless overridden by job-specific permissions.

Suggested changeset 1
.github/workflows/publish-npm.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml
--- a/.github/workflows/publish-npm.yml
+++ b/.github/workflows/publish-npm.yml
@@ -2,6 +2,9 @@
 # It can also be run manually to re-publish to NPM in case it failed for some reason.
 # You can run this workflow by navigating to https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml
 name: Publish NPM
+permissions:
+  contents: read
+  packages: write
 on:
   workflow_dispatch:
 
EOF
@@ -2,6 +2,9 @@
# It can also be run manually to re-publish to NPM in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml
name: Publish NPM
permissions:
contents: read
packages: write
on:
workflow_dispatch:

Copilot is powered by AI and may make mistakes. Always verify output.
1 change: 1 addition & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
NPM_TOKEN: ${{ secrets.SFC_NODES_NPM_TOKEN || secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.1"
".": "0.1.0-alpha.2"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company%2Fsfc-nodes-b800806859333bacc88fa4236eae35c8cdbec62970b7fb9ad440a330f24a1622.yml
openapi_spec_hash: fa672b6ca8953a8059961a7559a607a9
config_hash: e089259785c0c81187a2b25ae04b8459
config_hash: e310f0f1f4275f17d4a3872005f33a90
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.2 (2025-07-22)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/sfcompute/nodes-typescript/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)

### Chores

* update SDK settings ([8db0e2d](https://github.com/sfcompute/nodes-typescript/commit/8db0e2dbb16e522c0e6e8970b5e2f1ddf5ee7f6f))

## 0.1.0-alpha.1 (2025-07-17)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/sfcompute/nodes-typescript/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
Expand Down
18 changes: 16 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ $ cd nodes-typescript
# With yarn
$ yarn link
$ cd ../my-package
$ yarn link sfc-nodes
$ yarn link @sfc/nodes-sdk-alpha

# With pnpm
$ pnpm link --global
$ cd ../my-package
$ pnpm link -—global sfc-nodes
$ pnpm link -—global @sfc/nodes-sdk-alpha
```

## Running tests
Expand Down Expand Up @@ -91,3 +91,17 @@ To format and fix all lint issues automatically:
```sh
$ yarn fix
```

## Publishing and releases

Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If
the changes aren't made through the automated pipeline, you may want to make releases manually.

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/sfcompute/nodes-typescript/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on
the environment.
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SFC Nodes TypeScript API Library

[![NPM version](<https://img.shields.io/npm/v/sfc-nodes.svg?label=npm%20(stable)>)](https://npmjs.org/package/sfc-nodes) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/sfc-nodes)
[![NPM version](<https://img.shields.io/npm/v/@sfc/nodes-sdk-alpha.svg?label=npm%20(stable)>)](https://npmjs.org/package/@sfc/nodes-sdk-alpha) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@sfc/nodes-sdk-alpha)

This library provides convenient access to the SFC Nodes REST API from server-side TypeScript or JavaScript.

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

```sh
npm install git+ssh://git@github.com:sfcompute/nodes-typescript.git
npm install @sfc/nodes-sdk-alpha
```

> [!NOTE]
> Once this package is [published to npm](https://www.stainless.com/docs/guides/publish), this will become: `npm install sfc-nodes`

## Usage

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

<!-- prettier-ignore -->
```js
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted
Expand All @@ -38,7 +35,7 @@ This library includes TypeScript definitions for all request params and response

<!-- prettier-ignore -->
```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted
Expand Down Expand Up @@ -160,7 +157,7 @@ The log level can be configured in two ways:
2. Using the `logLevel` client option (overrides the environment variable if set)

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
logLevel: 'debug', // Show all log messages
Expand Down Expand Up @@ -188,7 +185,7 @@ When providing a custom logger, the `logLevel` option still controls which messa
below the configured level will not be sent to your logger.

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';
import pino from 'pino';

const logger = pino();
Expand Down Expand Up @@ -257,7 +254,7 @@ globalThis.fetch = fetch;
Or pass it to the client:

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';
import fetch from 'my-fetch';

const client = new SFCNodes({ fetch });
Expand All @@ -268,7 +265,7 @@ const client = new SFCNodes({ fetch });
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.)

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
fetchOptions: {
Expand All @@ -285,7 +282,7 @@ options to requests:
<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>

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';
import * as undici from 'undici';

const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
Expand All @@ -299,7 +296,7 @@ const client = new SFCNodes({
<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>

```ts
import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
fetchOptions: {
Expand All @@ -311,7 +308,7 @@ const client = new SFCNodes({
<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>

```ts
import SFCNodes from 'npm:sfc-nodes';
import SFCNodes from 'npm:@sfc/nodes-sdk-alpha';

const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
const client = new SFCNodes({
Expand Down
4 changes: 4 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

errors=()

if [ -z "${NPM_TOKEN}" ]; then
errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default tseslint.config(
{
patterns: [
{
regex: '^sfc-nodes(/.*)?',
regex: '^@sfc/nodes-sdk-alpha(/.*)?',
message: 'Use a relative import, not a package import.',
},
],
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^sfc-nodes$': '<rootDir>/src/index.ts',
'^sfc-nodes/(.*)$': '<rootDir>/src/$1',
'^@sfc/nodes-sdk-alpha$': '<rootDir>/src/index.ts',
'^@sfc/nodes-sdk-alpha/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sfc-nodes",
"version": "0.1.0-alpha.1",
"name": "@sfc/nodes-sdk-alpha",
"version": "0.1.0-alpha.2",
"description": "The official TypeScript library for the SFC Nodes API",
"author": "SFC Nodes <hello@sfcompute.com>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -47,8 +47,8 @@
"typescript-eslint": "8.31.1"
},
"imports": {
"sfc-nodes": ".",
"sfc-nodes/*": "./src/*"
"@sfc/nodes-sdk-alpha": ".",
"@sfc/nodes-sdk-alpha/*": "./src/*"
},
"exports": {
".": {
Expand Down
6 changes: 3 additions & 3 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs

# Build into dist and will publish the package from there,
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
# This way importing from `"sfc-nodes/resources/foo"` works
# This way importing from `"@sfc/nodes-sdk-alpha/resources/foo"` works
# even with `"moduleResolution": "node"`

rm -rf dist; mkdir dist
Expand Down Expand Up @@ -42,8 +42,8 @@ node scripts/utils/postprocess-files.cjs

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
(cd dist && node -e 'require("sfc-nodes")')
(cd dist && node -e 'import("sfc-nodes")' --input-type=module)
(cd dist && node -e 'require("@sfc/nodes-sdk-alpha")')
(cd dist && node -e 'import("@sfc/nodes-sdk-alpha")' --input-type=module)

if [ -e ./scripts/build-deno ]
then
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.1.0-alpha.1'; // x-release-please-version
export const VERSION = '0.1.0-alpha.2'; // x-release-please-version
2 changes: 1 addition & 1 deletion tests/api-resources/nodes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
apiKey: 'My API Key',
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/vms/script.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
apiKey: 'My API Key',
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/vms/vms.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import SFCNodes from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';

const client = new SFCNodes({
apiKey: 'My API Key',
Expand Down
2 changes: 1 addition & 1 deletion tests/base64.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fromBase64, toBase64 } from 'sfc-nodes/internal/utils/base64';
import { fromBase64, toBase64 } from '@sfc/nodes-sdk-alpha/internal/utils/base64';

describe.each(['Buffer', 'atob'])('with %s', (mode) => {
let originalBuffer: BufferConstructor;
Expand Down
2 changes: 1 addition & 1 deletion tests/buildHeaders.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inspect } from 'node:util';
import { buildHeaders, type HeadersLike, type NullableHeaders } from 'sfc-nodes/internal/headers';
import { buildHeaders, type HeadersLike, type NullableHeaders } from '@sfc/nodes-sdk-alpha/internal/headers';

function inspectNullableHeaders(headers: NullableHeaders) {
return `NullableHeaders {${[
Expand Down
4 changes: 2 additions & 2 deletions tests/form.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { multipartFormRequestOptions, createForm } from 'sfc-nodes/internal/uploads';
import { toFile } from 'sfc-nodes/core/uploads';
import { multipartFormRequestOptions, createForm } from '@sfc/nodes-sdk-alpha/internal/uploads';
import { toFile } from '@sfc/nodes-sdk-alpha/core/uploads';

describe('form data validation', () => {
test('valid values do not error', async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIPromise } from 'sfc-nodes/core/api-promise';
import { APIPromise } from '@sfc/nodes-sdk-alpha/core/api-promise';

import util from 'node:util';
import SFCNodes from 'sfc-nodes';
import { APIUserAbortError } from 'sfc-nodes';
import SFCNodes from '@sfc/nodes-sdk-alpha';
import { APIUserAbortError } from '@sfc/nodes-sdk-alpha';
const defaultFetch = fetch;

describe('instantiate client', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/path.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPathTagFunction, encodeURIPath } from 'sfc-nodes/internal/utils/path';
import { createPathTagFunction, encodeURIPath } from '@sfc/nodes-sdk-alpha/internal/utils/path';
import { inspect } from 'node:util';
import { runInNewContext } from 'node:vm';

Expand Down
2 changes: 1 addition & 1 deletion tests/stringifyQuery.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { SFCNodes } from 'sfc-nodes';
import { SFCNodes } from '@sfc/nodes-sdk-alpha';

const { stringifyQuery } = SFCNodes.prototype as any;

Expand Down
6 changes: 3 additions & 3 deletions tests/uploads.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import type { ResponseLike } from 'sfc-nodes/internal/to-file';
import { toFile } from 'sfc-nodes/core/uploads';
import type { ResponseLike } from '@sfc/nodes-sdk-alpha/internal/to-file';
import { toFile } from '@sfc/nodes-sdk-alpha/core/uploads';
import { File } from 'node:buffer';

class MyClass {
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('missing File error message', () => {
});

test('is thrown', async () => {
const uploads = await import('sfc-nodes/core/uploads');
const uploads = await import('@sfc/nodes-sdk-alpha/core/uploads');
await expect(
uploads.toFile(mockResponse({ url: 'https://example.com/my/audio.mp3' })),
).rejects.toMatchInlineSnapshot(
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"compilerOptions": {
"rootDir": "./dist/src",
"paths": {
"sfc-nodes/*": ["dist/src/*"],
"sfc-nodes": ["dist/src/index.ts"]
"@sfc/nodes-sdk-alpha/*": ["dist/src/*"],
"@sfc/nodes-sdk-alpha": ["dist/src/index.ts"]
},
"noEmit": false,
"declaration": true,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"esModuleInterop": true,
"baseUrl": "./",
"paths": {
"sfc-nodes/*": ["src/*"],
"sfc-nodes": ["src/index.ts"]
"@sfc/nodes-sdk-alpha/*": ["src/*"],
"@sfc/nodes-sdk-alpha": ["src/index.ts"]
},
"noEmit": true,

Expand Down