Skip to content

Commit aa6302e

Browse files
chore(internal): codegen related update (#41)
1 parent 607ffef commit aa6302e

18 files changed

+72
-57
lines changed

.github/workflows/release-doctor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ jobs:
1919
bash ./bin/check-release-environment
2020
env:
2121
NPM_TOKEN: ${{ secrets.OPENLAYER_NPM_TOKEN || secrets.NPM_TOKEN }}
22+

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
201201
```ts
202202
const client = new Openlayer();
203203

204-
const response = await openlayer.inferencePipelines.data
204+
const response = await client.inferencePipelines.data
205205
.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
206206
config: {
207207
inputVariableNames: ['user_query'],
@@ -349,7 +349,7 @@ const client = new Openlayer({
349349
});
350350

351351
// Override per-request:
352-
await openlayer.inferencePipelines.data.stream(
352+
await client.inferencePipelines.data.stream(
353353
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
354354
{
355355
config: {

bin/check-release-environment

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ if [[ lenErrors -gt 0 ]]; then
1919
fi
2020

2121
echo "The environment is ready to push releases!"
22+

bin/publish-npm

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
set -eux
44

5-
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
5+
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
66

7+
# Build the project
78
yarn build
9+
10+
# Navigate to the dist directory
811
cd dist
9-
yarn publish --access public
12+
13+
# Get the version from package.json
14+
VERSION="$(node -p "require('./package.json').version")"
15+
16+
# Extract the pre-release tag if it exists
17+
if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
18+
# Extract the part before any dot in the pre-release identifier
19+
TAG="${BASH_REMATCH[1]}"
20+
else
21+
TAG="latest"
22+
fi
23+
24+
# Publish with the appropriate tag
25+
yarn publish --access public --tag "$TAG"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
2222
"tsn": "ts-node -r tsconfig-paths/register",
2323
"lint": "./scripts/lint",
24-
"fix": "eslint --fix --ext ts,js ."
24+
"fix": "./scripts/format"
2525
},
2626
"dependencies": {
2727
"@langchain/core": "^0.3.3",

scripts/format

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -e
55
cd "$(dirname "$0")/.."
66

77
echo "==> Running eslint --fix"
8-
./node_modules/.bin/eslint --fix --ext ts,js .
8+
ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --fix --ext ts,js .

scripts/mock

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"
2121

2222
# Run prism mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
24-
npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log &
24+
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL" &> .prism.log &
2525

2626
# Wait for server to come online
2727
echo -n "Waiting for server"
@@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then
3737

3838
echo
3939
else
40-
npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL"
40+
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL"
4141
fi

src/_shims/node-runtime.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import { Readable } from 'node:stream';
1313
import { type RequestOptions } from '../core';
1414
import { MultipartBody } from './MultipartBody';
1515
import { type Shims } from './registry';
16-
17-
// @ts-ignore (this package does not have proper export maps for this export)
18-
import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js';
16+
import { ReadableStream } from 'node:stream/web';
1917

2018
type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
2119

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export class Openlayer extends Core.APIClient {
165165
}
166166

167167
static Openlayer = this;
168+
static DEFAULT_TIMEOUT = 60000; // 1 minute
168169

169170
static OpenlayerError = Errors.OpenlayerError;
170171
static APIError = Errors.APIError;

tests/api-resources/commits/test-results.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource testResults', () => {
1212
test('list', async () => {
13-
const responsePromise = openlayer.commits.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
13+
const responsePromise = client.commits.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
1414
const rawResponse = await responsePromise.asResponse();
1515
expect(rawResponse).toBeInstanceOf(Response);
1616
const response = await responsePromise;
@@ -23,7 +23,7 @@ describe('resource testResults', () => {
2323
test('list: request options instead of params are passed correctly', async () => {
2424
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
2525
await expect(
26-
openlayer.commits.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
26+
client.commits.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2727
path: '/_stainless_unknown_path',
2828
}),
2929
).rejects.toThrow(Openlayer.NotFoundError);
@@ -32,7 +32,7 @@ describe('resource testResults', () => {
3232
test('list: request options and params are passed correctly', async () => {
3333
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
3434
await expect(
35-
openlayer.commits.testResults.list(
35+
client.commits.testResults.list(
3636
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
3737
{ includeArchived: true, page: 1, perPage: 1, status: 'passing', type: 'integrity' },
3838
{ path: '/_stainless_unknown_path' },

tests/api-resources/inference-pipelines/data.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource data', () => {
1212
test('stream: only required params', async () => {
13-
const responsePromise = openlayer.inferencePipelines.data.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
13+
const responsePromise = client.inferencePipelines.data.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
1414
config: { outputColumnName: 'output' },
1515
rows: [{ user_query: 'bar', output: 'bar', tokens: 'bar', cost: 'bar', timestamp: 'bar' }],
1616
});
@@ -24,7 +24,7 @@ describe('resource data', () => {
2424
});
2525

2626
test('stream: required and optional params', async () => {
27-
const response = await openlayer.inferencePipelines.data.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
27+
const response = await client.inferencePipelines.data.stream('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2828
config: {
2929
numOfTokenColumnName: 'tokens',
3030
contextColumnName: 'context',

tests/api-resources/inference-pipelines/inference-pipelines.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource inferencePipelines', () => {
1212
test('retrieve', async () => {
13-
const responsePromise = openlayer.inferencePipelines.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
13+
const responsePromise = client.inferencePipelines.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
1414
const rawResponse = await responsePromise.asResponse();
1515
expect(rawResponse).toBeInstanceOf(Response);
1616
const response = await responsePromise;
@@ -23,14 +23,14 @@ describe('resource inferencePipelines', () => {
2323
test('retrieve: request options instead of params are passed correctly', async () => {
2424
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
2525
await expect(
26-
openlayer.inferencePipelines.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
26+
client.inferencePipelines.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2727
path: '/_stainless_unknown_path',
2828
}),
2929
).rejects.toThrow(Openlayer.NotFoundError);
3030
});
3131

3232
test('update', async () => {
33-
const responsePromise = openlayer.inferencePipelines.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
33+
const responsePromise = client.inferencePipelines.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
3434
const rawResponse = await responsePromise.asResponse();
3535
expect(rawResponse).toBeInstanceOf(Response);
3636
const response = await responsePromise;
@@ -43,7 +43,7 @@ describe('resource inferencePipelines', () => {
4343
test('update: request options instead of params are passed correctly', async () => {
4444
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
4545
await expect(
46-
openlayer.inferencePipelines.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
46+
client.inferencePipelines.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
4747
path: '/_stainless_unknown_path',
4848
}),
4949
).rejects.toThrow(Openlayer.NotFoundError);
@@ -52,7 +52,7 @@ describe('resource inferencePipelines', () => {
5252
test('update: request options and params are passed correctly', async () => {
5353
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
5454
await expect(
55-
openlayer.inferencePipelines.update(
55+
client.inferencePipelines.update(
5656
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
5757
{
5858
description: 'This pipeline is used for production.',
@@ -65,7 +65,7 @@ describe('resource inferencePipelines', () => {
6565
});
6666

6767
test('delete', async () => {
68-
const responsePromise = openlayer.inferencePipelines.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
68+
const responsePromise = client.inferencePipelines.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
6969
const rawResponse = await responsePromise.asResponse();
7070
expect(rawResponse).toBeInstanceOf(Response);
7171
const response = await responsePromise;
@@ -78,7 +78,7 @@ describe('resource inferencePipelines', () => {
7878
test('delete: request options instead of params are passed correctly', async () => {
7979
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
8080
await expect(
81-
openlayer.inferencePipelines.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
81+
client.inferencePipelines.delete('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
8282
path: '/_stainless_unknown_path',
8383
}),
8484
).rejects.toThrow(Openlayer.NotFoundError);

tests/api-resources/inference-pipelines/rows.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource rows', () => {
1212
test('update: only required params', async () => {
13-
const responsePromise = openlayer.inferencePipelines.rows.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
13+
const responsePromise = client.inferencePipelines.rows.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
1414
inferenceId: 'inferenceId',
1515
row: {},
1616
});
@@ -24,7 +24,7 @@ describe('resource rows', () => {
2424
});
2525

2626
test('update: required and optional params', async () => {
27-
const response = await openlayer.inferencePipelines.rows.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
27+
const response = await client.inferencePipelines.rows.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2828
inferenceId: 'inferenceId',
2929
row: {},
3030
config: {

tests/api-resources/inference-pipelines/test-results.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource testResults', () => {
1212
test('list', async () => {
13-
const responsePromise = openlayer.inferencePipelines.testResults.list(
13+
const responsePromise = client.inferencePipelines.testResults.list(
1414
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
1515
);
1616
const rawResponse = await responsePromise.asResponse();
@@ -25,7 +25,7 @@ describe('resource testResults', () => {
2525
test('list: request options instead of params are passed correctly', async () => {
2626
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
2727
await expect(
28-
openlayer.inferencePipelines.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
28+
client.inferencePipelines.testResults.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
2929
path: '/_stainless_unknown_path',
3030
}),
3131
).rejects.toThrow(Openlayer.NotFoundError);
@@ -34,7 +34,7 @@ describe('resource testResults', () => {
3434
test('list: request options and params are passed correctly', async () => {
3535
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
3636
await expect(
37-
openlayer.inferencePipelines.testResults.list(
37+
client.inferencePipelines.testResults.list(
3838
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
3939
{ page: 1, perPage: 1, status: 'passing', type: 'integrity' },
4040
{ path: '/_stainless_unknown_path' },

tests/api-resources/projects/commits.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
@@ -33,7 +33,7 @@ describe('resource commits', () => {
3333
});
3434

3535
test('list', async () => {
36-
const responsePromise = openlayer.projects.commits.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
36+
const responsePromise = client.projects.commits.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
3737
const rawResponse = await responsePromise.asResponse();
3838
expect(rawResponse).toBeInstanceOf(Response);
3939
const response = await responsePromise;
@@ -46,7 +46,7 @@ describe('resource commits', () => {
4646
test('list: request options instead of params are passed correctly', async () => {
4747
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
4848
await expect(
49-
openlayer.projects.commits.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
49+
client.projects.commits.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
5050
path: '/_stainless_unknown_path',
5151
}),
5252
).rejects.toThrow(Openlayer.NotFoundError);
@@ -55,7 +55,7 @@ describe('resource commits', () => {
5555
test('list: request options and params are passed correctly', async () => {
5656
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
5757
await expect(
58-
openlayer.projects.commits.list(
58+
client.projects.commits.list(
5959
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
6060
{ page: 1, perPage: 1 },
6161
{ path: '/_stainless_unknown_path' },

tests/api-resources/projects/inference-pipelines.test.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import Openlayer from 'openlayer';
44
import { Response } from 'node-fetch';
55

6-
const openlayer = new Openlayer({
6+
const client = new Openlayer({
77
apiKey: 'My API Key',
88
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
99
});
1010

1111
describe('resource inferencePipelines', () => {
1212
test('create: only required params', async () => {
13-
const responsePromise = openlayer.projects.inferencePipelines.create(
13+
const responsePromise = client.projects.inferencePipelines.create(
1414
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
1515
{ description: 'This pipeline is used for production.', name: 'production' },
1616
);
@@ -24,16 +24,14 @@ describe('resource inferencePipelines', () => {
2424
});
2525

2626
test('create: required and optional params', async () => {
27-
const response = await openlayer.projects.inferencePipelines.create(
28-
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
29-
{ description: 'This pipeline is used for production.', name: 'production' },
30-
);
27+
const response = await client.projects.inferencePipelines.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
28+
description: 'This pipeline is used for production.',
29+
name: 'production',
30+
});
3131
});
3232

3333
test('list', async () => {
34-
const responsePromise = openlayer.projects.inferencePipelines.list(
35-
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
36-
);
34+
const responsePromise = client.projects.inferencePipelines.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
3735
const rawResponse = await responsePromise.asResponse();
3836
expect(rawResponse).toBeInstanceOf(Response);
3937
const response = await responsePromise;
@@ -46,7 +44,7 @@ describe('resource inferencePipelines', () => {
4644
test('list: request options instead of params are passed correctly', async () => {
4745
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
4846
await expect(
49-
openlayer.projects.inferencePipelines.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
47+
client.projects.inferencePipelines.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
5048
path: '/_stainless_unknown_path',
5149
}),
5250
).rejects.toThrow(Openlayer.NotFoundError);
@@ -55,7 +53,7 @@ describe('resource inferencePipelines', () => {
5553
test('list: request options and params are passed correctly', async () => {
5654
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
5755
await expect(
58-
openlayer.projects.inferencePipelines.list(
56+
client.projects.inferencePipelines.list(
5957
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
6058
{ name: 'name', page: 1, perPage: 1 },
6159
{ path: '/_stainless_unknown_path' },

0 commit comments

Comments
 (0)