Skip to content

Commit 5fd5615

Browse files
committed
SDK regeneration
0 parents  commit 5fd5615

File tree

281 files changed

+17796
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+17796
-0
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ci
2+
3+
on: [push]
4+
5+
jobs:
6+
compile:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v3
12+
13+
- name: Set up node
14+
uses: actions/setup-node@v3
15+
16+
- name: Compile
17+
run: yarn && yarn build
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v3
28+
29+
- name: Compile
30+
run: yarn && yarn test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
/dist

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
src
3+
tests
4+
.gitignore
5+
.github
6+
.fernignore
7+
.prettierrc.yml
8+
tsconfig.json
9+
yarn.lock

.prettierrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tabWidth: 4
2+
printWidth: 120

README.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Truefoundry TypeScript Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ftruefoundry%2Ftruefoundry-typescript-sdk)
4+
[![npm shield](https://img.shields.io/npm/v/truefoundry-sdk)](https://www.npmjs.com/package/truefoundry-sdk)
5+
6+
The Truefoundry TypeScript library provides convenient access to the Truefoundry API from TypeScript.
7+
8+
## Installation
9+
10+
```sh
11+
npm i -s truefoundry-sdk
12+
```
13+
14+
## Reference
15+
16+
A full reference for this library is available [here](./reference.md).
17+
18+
## Usage
19+
20+
Instantiate and use the client with the following:
21+
22+
```typescript
23+
import { TrueFoundryClient } from "truefoundry-sdk";
24+
25+
const client = new TrueFoundryClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
26+
await client.v1.artifactVersions.getSignedUrls({
27+
id: "id",
28+
paths: ["paths"],
29+
operation: "READ",
30+
});
31+
```
32+
33+
## Request And Response Types
34+
35+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
36+
following namespace:
37+
38+
```typescript
39+
import { TrueFoundry } from "truefoundry-sdk";
40+
41+
const request: TrueFoundry.GetSearchRunsGetRequest = {
42+
...
43+
};
44+
```
45+
46+
## Exception Handling
47+
48+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
49+
will be thrown.
50+
51+
```typescript
52+
import { TrueFoundryError } from "truefoundry-sdk";
53+
54+
try {
55+
await client.v1.artifactVersions.getSignedUrls(...);
56+
} catch (err) {
57+
if (err instanceof TrueFoundryError) {
58+
console.log(err.statusCode);
59+
console.log(err.message);
60+
console.log(err.body);
61+
}
62+
}
63+
```
64+
65+
## Pagination
66+
67+
List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
68+
69+
```typescript
70+
import { TrueFoundryClient } from "truefoundry-sdk";
71+
72+
const client = new TrueFoundryClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
73+
const response = await client.v1.artifacts.list();
74+
for await (const item of response) {
75+
console.log(item);
76+
}
77+
78+
// Or you can manually iterate page-by-page
79+
const page = await client.v1.artifacts.list();
80+
while (page.hasNextPage()) {
81+
page = page.getNextPage();
82+
}
83+
```
84+
85+
## Advanced
86+
87+
### Additional Headers
88+
89+
If you would like to send additional headers as part of the request, use the `headers` request option.
90+
91+
```typescript
92+
const response = await client.v1.artifactVersions.getSignedUrls(..., {
93+
headers: {
94+
'X-Custom-Header': 'custom value'
95+
}
96+
});
97+
```
98+
99+
### Retries
100+
101+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
102+
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
103+
retry limit (default: 2).
104+
105+
A request is deemed retriable when any of the following HTTP status codes is returned:
106+
107+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
108+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
109+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
110+
111+
Use the `maxRetries` request option to configure this behavior.
112+
113+
```typescript
114+
const response = await client.v1.artifactVersions.getSignedUrls(..., {
115+
maxRetries: 0 // override maxRetries at the request level
116+
});
117+
```
118+
119+
### Timeouts
120+
121+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
122+
123+
```typescript
124+
const response = await client.v1.artifactVersions.getSignedUrls(..., {
125+
timeoutInSeconds: 30 // override timeout to 30s
126+
});
127+
```
128+
129+
### Aborting Requests
130+
131+
The SDK allows users to abort requests at any point by passing in an abort signal.
132+
133+
```typescript
134+
const controller = new AbortController();
135+
const response = await client.v1.artifactVersions.getSignedUrls(..., {
136+
abortSignal: controller.signal
137+
});
138+
controller.abort(); // aborts the request
139+
```
140+
141+
### Runtime Compatibility
142+
143+
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
144+
runtimes:
145+
146+
- Node.js 18+
147+
- Vercel
148+
- Cloudflare Workers
149+
- Deno v1.25+
150+
- Bun 1.0+
151+
- React Native
152+
153+
### Customizing Fetch Client
154+
155+
The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an
156+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
157+
158+
```typescript
159+
import { TrueFoundryClient } from "truefoundry-sdk";
160+
161+
const client = new TrueFoundryClient({
162+
...
163+
fetcher: // provide your implementation here
164+
});
165+
```
166+
167+
## Contributing
168+
169+
While we value open-source contributions to this SDK, this library is generated programmatically.
170+
Additions made directly to this library would have to be moved over to our generation code,
171+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
172+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
173+
an issue first to discuss with us!
174+
175+
On the other hand, contributions to the README are always very welcome!

jest.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('jest').Config} */
2+
export default {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
moduleNameMapper: {
6+
"(.+)\.js$": "$1",
7+
},
8+
};

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "truefoundry-sdk",
3+
"version": "0.0.1",
4+
"private": false,
5+
"repository": "https://github.com/truefoundry/truefoundry-typescript-sdk",
6+
"main": "./index.js",
7+
"types": "./index.d.ts",
8+
"scripts": {
9+
"format": "prettier . --write --ignore-unknown",
10+
"build": "tsc",
11+
"prepack": "cp -rv dist/. .",
12+
"test": "jest"
13+
},
14+
"dependencies": {
15+
"url-join": "4.0.1",
16+
"form-data": "^4.0.0",
17+
"formdata-node": "^6.0.3",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
20+
"readable-stream": "^4.5.2",
21+
"js-base64": "3.7.7"
22+
},
23+
"devDependencies": {
24+
"@types/url-join": "4.0.1",
25+
"@types/qs": "^6.9.17",
26+
"@types/node-fetch": "^2.6.12",
27+
"@types/readable-stream": "^4.0.18",
28+
"webpack": "^5.97.1",
29+
"ts-loader": "^9.5.1",
30+
"jest": "^29.7.0",
31+
"@types/jest": "^29.5.14",
32+
"ts-jest": "^29.1.1",
33+
"jest-environment-jsdom": "^29.7.0",
34+
"@types/node": "^18.19.70",
35+
"prettier": "^3.4.2",
36+
"typescript": "~5.7.2"
37+
},
38+
"browser": {
39+
"fs": false,
40+
"os": false,
41+
"path": false
42+
}
43+
}

0 commit comments

Comments
 (0)