Skip to content

Commit

Permalink
chore: go live (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Sep 16, 2024
1 parent c86786d commit 31681bf
Show file tree
Hide file tree
Showing 16 changed files with 201 additions and 34 deletions.
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/runwayml/sdk-node/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: '18'

- name: Install dependencies
run: |
yarn install
- name: Publish to NPM
run: |
bash ./bin/publish-npm
env:
NPM_TOKEN: ${{ secrets.RUNWAYML_NPM_TOKEN || secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'runwayml/sdk-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
NPM_TOKEN: ${{ secrets.RUNWAYML_NPM_TOKEN || secrets.NPM_TOKEN }}

3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.1-alpha.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-0f66f9e1d151b4f957cba43f88b83bdcae6fa931269b549aec14848624a610ee.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-00c8db8bba8ad66c20debdbe1bb3e56123c3e9162f9310c49f1f5d748a40b96b.yml
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```bash
npm install git+ssh://git@github.com:stainless-sdks/runwayml-node.git
npm install git+ssh://git@github.com:runwayml/sdk-node.git
```

Alternatively, to link a local copy of the repo:

```bash
# Clone
git clone https://www.github.com/stainless-sdks/runwayml-node
cd runwayml-node
git clone https://www.github.com/runwayml/sdk-node
cd sdk-node

# With yarn
yarn link
Expand Down Expand Up @@ -99,7 +99,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

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

### Publish manually

Expand Down
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

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

The REST API documentation can be found on [docs.runwayml.com](https://docs.runwayml.com). The full API of this library can be found in [api.md](api.md).
The REST API documentation can be found on [dev.runwayml.com](https://dev.runwayml.com). The full API of this library can be found in [api.md](api.md).

It is generated with [Stainless](https://www.stainlessapi.com/).

## Installation

```sh
npm install git+ssh://git@github.com:stainless-sdks/runwayml-node.git
npm install git+ssh://git@github.com:runwayml/sdk-node.git
```

> [!NOTE]
Expand All @@ -30,7 +30,11 @@ const client = new RunwayML({
});

async function main() {
const imageToVideo = await client.imageToVideo.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' });
const imageToVideo = await client.imageToVideo.create({
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
});

console.log(imageToVideo.id);
}
Expand All @@ -51,7 +55,11 @@ const client = new RunwayML({
});

async function main() {
const params: RunwayML.ImageToVideoCreateParams = { model: 'REPLACE_ME', promptImage: 'REPLACE_ME' };
const params: RunwayML.ImageToVideoCreateParams = {
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
};
const imageToVideo: RunwayML.ImageToVideoCreateResponse = await client.imageToVideo.create(params);
}

Expand All @@ -70,7 +78,11 @@ a subclass of `APIError` will be thrown:
```ts
async function main() {
const imageToVideo = await client.imageToVideo
.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' })
.create({
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
})
.catch(async (err) => {
if (err instanceof RunwayML.APIError) {
console.log(err.status); // 400
Expand Down Expand Up @@ -114,7 +126,7 @@ const client = new RunwayML({
});

// Or, configure per-request:
await client.imageToVideo.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' }, {
await client.imageToVideo.create({ model: 'gen3a_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
maxRetries: 5,
});
```
Expand All @@ -131,7 +143,7 @@ const client = new RunwayML({
});

// Override per-request:
await client.imageToVideo.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' }, {
await client.imageToVideo.create({ model: 'gen3a_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -153,13 +165,21 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
const client = new RunwayML();

const response = await client.imageToVideo
.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' })
.create({
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: imageToVideo, response: raw } = await client.imageToVideo
.create({ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' })
.create({
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
})
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(imageToVideo.id);
Expand Down Expand Up @@ -225,7 +245,7 @@ import RunwayML from 'runwayml';
```

To do the inverse, add `import "runwayml/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/runwayml-node/tree/main/src/_shims#readme)).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/runwayml/sdk-node/tree/main/src/_shims#readme)).

### Logging and middleware

Expand Down Expand Up @@ -267,7 +287,11 @@ const client = new RunwayML({

// Override per-request:
await client.imageToVideo.create(
{ model: 'REPLACE_ME', promptImage: 'REPLACE_ME' },
{
model: 'gen3a_turbo',
promptImage: 'https://example.com/assets/bunny.jpg',
promptText: 'The bunny is eating a carrot',
},
{
httpAgent: new http.Agent({ keepAlive: false }),
},
Expand All @@ -284,7 +308,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

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

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/runwayml-node/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/runwayml/sdk-node/issues) with questions, bugs, or suggestions.

## Requirements

Expand Down
22 changes: 22 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

errors=()

if [ -z "${NPM_TOKEN}" ]; then
errors+=("The RUNWAYML_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
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"main": "dist/index.js",
"type": "commonjs",
"repository": "github:stainless-sdks/runwayml-node",
"repository": "github:runwayml/sdk-node",
"license": "Apache-2.0",
"packageManager": "yarn@1.22.22",
"files": [
Expand Down
67 changes: 67 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"packages": {
".": {}
},
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
"include-v-in-tag": true,
"include-component-in-tag": false,
"versioning": "prerelease",
"prerelease": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"pull-request-header": "Automated Release PR",
"pull-request-title-pattern": "release: ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "chore",
"section": "Chores"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactors"
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
],
"release-type": "node",
"extra-files": [
"src/version.ts",
"README.md"
]
}
2 changes: 1 addition & 1 deletion src/_shims/index-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getDefaultAgent(url: string) {
}
export function fileFromPath() {
throw new Error(
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/runwayml-node#file-uploads',
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/runwayml/sdk-node#file-uploads',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/_shims/web-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean }
getDefaultAgent: (url: string) => undefined,
fileFromPath: () => {
throw new Error(
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/runwayml-node#file-uploads',
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/runwayml/sdk-node#file-uploads',
);
},
isFsReadStream: (value: any) => false,
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class RunwayML extends Core.APIClient {
* API Client for interfacing with the RunwayML API.
*
* @param {string | undefined} [opts.apiKey=process.env['RUNWAYML_API_SECRET'] ?? undefined]
* @param {string | undefined} [opts.runwayVersion=2023-09-06]
* @param {string} [opts.baseURL=process.env['RUNWAYML_BASE_URL'] ?? https://playdoh.runwayml.com] - Override the default base URL for the API.
* @param {string | undefined} [opts.runwayVersion=2024-09-13]
* @param {string} [opts.baseURL=process.env['RUNWAYML_BASE_URL'] ?? https://api.dev.runwayml.com] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
Expand All @@ -96,7 +96,7 @@ export class RunwayML extends Core.APIClient {
constructor({
baseURL = Core.readEnv('RUNWAYML_BASE_URL'),
apiKey = Core.readEnv('RUNWAYML_API_SECRET'),
runwayVersion = '2023-09-06',
runwayVersion = '2024-09-13',
...opts
}: ClientOptions = {}) {
if (apiKey === undefined) {
Expand All @@ -109,7 +109,7 @@ export class RunwayML extends Core.APIClient {
apiKey,
runwayVersion,
...opts,
baseURL: baseURL || `https://playdoh.runwayml.com`,
baseURL: baseURL || `https://api.dev.runwayml.com`,
};

super({
Expand Down
8 changes: 2 additions & 6 deletions src/resources/image-to-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ export interface ImageToVideoCreateParams {
model: 'gen3a_turbo';

/**
* A URL pointing to an image. See documentation on input URLs.
* A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
* limited to 16MB. Responses must include a valid `Content-Length` header.
*/
promptImage: string;

/**
* A non-empty string up to 512 UTF-16 code points in length (that is,
* `promptText.length === 512` in JavaScript). This should describe in detail what
* should appear in the output.
*/
promptText?: string;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/resources/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export interface TaskRetrieveResponse {
/**
* If the status is `SUCCEEDED`, this will contain an array of strings. Each string
* will be a URL that returns an output from the task. URLs expire within 24-48
* hours.
* hours; fetch the task again to get fresh URLs. It is expected that you download
* the assets at these URLs and store them in your own storage system.
*/
output?: Array<string>;

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.0.1-alpha.0';
export const VERSION = '0.0.1-alpha.0'; // x-release-please-version
Loading

0 comments on commit 31681bf

Please sign in to comment.