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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module.exports = {
'unused-imports/no-unused-imports': 'error',
},
root: true,
ignorePatterns: ['dist/**/*', 'docs/**/*', 'tests/**/*'],
};
5 changes: 2 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE/bug_fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Examples: `fix: resolve memory leak` · `fix(api): handle null response` · `fix

## Changes

-
-
-
-

## Testing

Expand All @@ -32,4 +32,3 @@ Examples: `fix: resolve memory leak` · `fix(api): handle null response` · `fix
- [ ] PR title follows Conventional Commits format (`fix:` or `fix(scope):`)
- [ ] Root cause identified and documented
- [ ] Tests added to prevent regression

5 changes: 2 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Examples: `feat: add new SDK method` · `feat(storage): support file uploads` ·

## Changes

-
-
-
-

## Testing

Expand All @@ -37,4 +37,3 @@ Examples: `feat: add new SDK method` · `feat(storage): support file uploads` ·
- [ ] PR title follows Conventional Commits format (`feat:` or `feat(scope):`)
- [ ] Documentation updated (if needed)
- [ ] Breaking changes documented (if applicable)

5 changes: 2 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Examples: `feat: add new SDK method` · `feat(storage): support file uploads` ·

## Changes

-
-
-
-

## Testing

Expand All @@ -37,4 +37,3 @@ Examples: `feat: add new SDK method` · `feat(storage): support file uploads` ·
- [ ] PR title follows Conventional Commits format (`feat:` or `feat(scope):`)
- [ ] Documentation updated (if needed)
- [ ] Breaking changes documented (if applicable)

86 changes: 86 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: PUBLISH DOCS
on:
workflow_dispatch:
workflow_call:
release:
types: [published]
permissions:
contents: write # allows the 'Commit' step without tokens

jobs:
get_history: # create an artifact from the existing documentation builds
runs-on: ubuntu-latest
steps:
- name: get the gh-pages repo
uses: actions/checkout@v3
with:
ref: gh-pages

- name: tar the existing docs
run: |
mkdir -p ./docs
tar -cvf documentation.tar ./docs
Comment on lines +19 to +22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no .docs dir, should we create an error rather than an empty tar file? I assume things would just fail if the tar command exits with nonzero status, so just taking out the mkdir would do the trick?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is within the GH page repo, so if it doesn't exist it makes an empty one if it does it tars it up


- name: create a document artifact
uses: actions/upload-artifact@v3
with:
name: documentation
path: documentation.tar

build: # builds the distribution and then the documentation
needs: get_history
runs-on: ubuntu-latest
steps:
- name: Checkout src
uses: actions/checkout@v3

- run: mkdir -p ./docs
- name: Download the existing documents artifact
uses: actions/download-artifact@v3
with:
name: documentation
- run: tar -xf documentation.tar ./docs -C ./docs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we want to only untar things that start with ./docs? (probably fine given how the archive is created, but maybe would be confusing if we add more dirs later and they don't show up?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just for GH pages so yeah just that one


- name: Build
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
- run: npm ci
- run: npm run build # set up 'build' script in your package.json

- name: Build documents
run: npm run docs #set up 'docs' build script in your package.json

- name: tar the new docs
run: tar -cvf newdocumentation.tar ./docs

- name: create a new document artifact
uses: actions/upload-artifact@v3
with:
name: newdocumentation
path: newdocumentation.tar

commit: # commit the old and new merged documents to gh-pages/docs
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout the gh-pages repo
uses: actions/checkout@v3
with:
ref: gh-pages

- run: mkdir -p ./docs
- name: Download the new documents artifact
uses: actions/download-artifact@v3
with:
name: newdocumentation
- run: tar -xf newdocumentation.tar ./docs -C ./docs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here on the ./docs arg


- name: commit
run: |
git config --global user.email "username@users.noreply.github.com"
git config --global user.name "Continuous Integration"
git add .
git commit -m "CI updated the documentation"
git push
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Object Smoke Test & Coverage Check
name: SDK Smoke Tests & Coverage Check

on:
pull_request:
paths:
- 'src/objects/**'
- 'src/sdk/**'
- 'tests/smoketests/object-oriented/**'
workflow_dispatch:
inputs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dist-deno
.DS_Store
coverage-objects
object-coverage-report.json
docs
6 changes: 3 additions & 3 deletions jest.config.objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^@runloop/api-client$': '<rootDir>/src/index.ts',
'^@runloop/api-client$': '<rootDir>/src/sdk.ts',
'^@runloop/api-client/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^@runloop/api-client/(.*)$': '<rootDir>/src/$1',
},
Expand All @@ -18,9 +18,9 @@ module.exports = {
],
testMatch: ['**/tests/smoketests/object-oriented/**/*.test.ts'],
collectCoverageFrom: [
'src/objects/**/*.ts',
'src/sdk/**/*.ts',
'src/sdk.ts',
'!src/objects/index.ts',
'!src/sdk/index.ts',
'!**/*.d.ts',
'!**/node_modules/**',
],
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config: JestConfigWithTsJest = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^@runloop/api-client$': '<rootDir>/src/index.ts',
'^@runloop/api-client$': '<rootDir>/src/sdk.ts',
'^@runloop/api-client/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^@runloop/api-client/(.*)$': '<rootDir>/src/$1',
},
Expand Down
36 changes: 26 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.67.1",
"description": "The official TypeScript library for the Runloop API",
"author": "Runloop <support@runloop.ai>",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"types": "dist/sdk.d.ts",
"main": "dist/sdk.js",
"type": "commonjs",
"repository": "github:runloopai/api-client-ts",
"license": "MIT",
Expand All @@ -28,7 +28,11 @@
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build && ./scripts/utils/git-swap.sh; fi",
"tsn": "ts-node -r tsconfig-paths/register",
"lint": "./scripts/lint",
"fix": "./scripts/format"
"fix": "./scripts/format",
"docs": "typedoc --options typedoc.json",
"docs:watch": "typedoc --options typedoc.json --watch",
"predeploy-gh-pages": "yarn docs:sdk",
"deploy-gh-pages": "gh-pages -d typedoc"
},
"dependencies": {
"@types/node": "^18.11.18",
Expand All @@ -41,7 +45,12 @@
"uuidv7": "^1.0.2",
"zod": "^3.24.1"
},
"resolutions": {
"typedoc": "^0.28.14",
"typedoc-plugin-markdown": "^4.9.0"
},
"devDependencies": {
"@shipgirl/typedoc-plugin-versions": "^0.3.2",
"@swc/core": "^1.3.102",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.4.0",
Expand All @@ -50,18 +59,25 @@
"eslint": "^8.49.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-unused-imports": "^3.0.0",
"gh-pages": "^6.3.0",
"iconv-lite": "^0.6.3",
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.8.2"
"typedoc": "^0.28.14",
"typedoc-github-theme": "^0.3.1",
"typedoc-material-theme": "^1.4.1",
"typedoc-plugin-include-example": "^3.0.2",
"typedoc-plugin-markdown": "^4.9.0",
"typedoc-plugin-pages": "^1.1.0",
"typescript": "^5.9.0"
},
"sideEffects": [
"./_shims/index.js",
"./_shims/index.mjs",
"./_shims/sdk.js",
"./_shims/sdk.mjs",
"./shims/node.js",
"./shims/node.mjs",
"./shims/web.js",
Expand Down Expand Up @@ -105,11 +121,11 @@
},
".": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/sdk.d.ts",
"default": "./dist/sdk.js"
},
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
"types": "./dist/sdk.d.mts",
"default": "./dist/sdk.mjs"
},
"./*.mjs": {
"types": "./dist/*.d.ts",
Expand Down
14 changes: 7 additions & 7 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node scripts/utils/check-version.cjs

rm -rf dist; mkdir dist
# Copy src to dist/src and build from dist/src into dist, so that
# the source map for index.js.map will refer to ./src/index.ts etc
# the source map for sdk.js.map will refer to ./src/sdk.ts etc
cp -rp src README.md dist
rm dist/src/_shims/*-deno.ts dist/src/_shims/auto/*-deno.ts
for file in LICENSE CHANGELOG.md; do
Expand All @@ -32,15 +32,15 @@ node scripts/utils/make-dist-package-json.cjs > dist/package.json
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
# we need to add exports = module.exports = Runloop to index.js;
# No way to get that from index.ts because it would cause compile errors
# we need to add exports = module.exports = Runloop to sdk.js;
# No way to get that from sdk.ts because it would cause compile errors
# when building .mjs
node scripts/utils/fix-index-exports.cjs
# with "moduleResolution": "nodenext", if ESM resolves to index.d.ts,
# with "moduleResolution": "nodenext", if ESM resolves to sdk.d.ts,
# it'll have TS errors on the default import. But if it resolves to
# index.d.mts the default import will work (even though both files have
# sdk.d.mts the default import will work (even though both files have
# the same export default statement)
cp dist/index.d.ts dist/index.d.mts
cp dist/sdk.d.ts dist/sdk.d.mts
cp tsconfig.dist-src.json dist/src/tsconfig.json

node scripts/utils/postprocess-files.cjs
Expand All @@ -53,4 +53,4 @@ node scripts/utils/postprocess-files.cjs
if [ -e ./scripts/build-deno ]
then
./scripts/build-deno
fi
fi
10 changes: 5 additions & 5 deletions scripts/utils/fix-index-exports.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const fs = require('fs');
const path = require('path');

const indexJs =
const sdkJs =
process.env['DIST_PATH'] ?
path.resolve(process.env['DIST_PATH'], 'index.js')
: path.resolve(__dirname, '..', '..', 'dist', 'index.js');
path.resolve(process.env['DIST_PATH'], 'sdk.js')
: path.resolve(__dirname, '..', '..', 'dist', 'sdk.js');

let before = fs.readFileSync(indexJs, 'utf8');
let before = fs.readFileSync(sdkJs, 'utf8');
let after = before.replace(
/^\s*exports\.default\s*=\s*(\w+)/m,
'exports = module.exports = $1;\nexports.default = $1',
);
fs.writeFileSync(indexJs, after, 'utf8');
fs.writeFileSync(sdkJs, after, 'utf8');
38 changes: 20 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export interface ClientOptions {
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
* much longer than this timeout before the promise succeeds or fails.
*
* @unit milliseconds
*/
timeout?: number | undefined;

Expand Down Expand Up @@ -230,7 +229,15 @@ export interface ClientOptions {
}

/**
* API Client for interfacing with the Runloop API.
* API Client for interfacing with the Runloop API. This is the old api client. Use the new {@link RunloopSDK} instead.
* @example
* ```typescript
* import { RunloopSDK } from '@runloop/api-client';
* const runloop = new RunloopSDK();
* const devbox = await runloop.devbox.create();
* const result = await devbox.cmd.exec({ command: 'echo "Hello, World!"' });
* console.log(result.exitCode);
* ```
*/
export class Runloop extends Core.APIClient {
bearerToken: string;
Expand Down Expand Up @@ -578,20 +585,15 @@ export {
UnprocessableEntityError,
} from './error';

export { RunloopSDK } from './sdk';

// /**
// * @deprecated Use named imports instead of default import. This is the old api client. Use the new SDK instead.
// * @example
// * ```typescript
// * // Instead of: import Runloop from '@runloop/api-client'
// * import { RunloopSDK } from '@runloop/api-client'
// * const sdk = new RunloopSDK();
// * //For existing api client, use the api property
// * const client = new RunloopSDK();
// * const devbox = await client.api.devboxes.create({ name: 'my-devbox' });
// * ```
// */
// This WILL be deprecated soon.. not yet though.

/**
* @example
* ```typescript
* // Instead of: import Runloop from '@runloop/api-client'
* import { RunloopSDK } from '@runloop/api-client'
* const sdk = new RunloopSDK();
* //For existing api client, use the api property
* const client = new RunloopSDK();
* const devbox = await client.api.devboxes.create({ name: 'my-devbox' });
* ```
*/
export default Runloop;
Loading
Loading