Skip to content

Commit c546f46

Browse files
chore: break long lines in snippets into multiline
1 parent 00a9097 commit c546f46

File tree

9 files changed

+137
-27
lines changed

9 files changed

+137
-27
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ You can use the `for await … of` syntax to iterate through items across all pa
163163
async function fetchAllDeploymentListResponses(params) {
164164
const allDeploymentListResponses = [];
165165
// Automatically fetches more pages as needed.
166-
for await (const deploymentListResponse of client.deployments.list({ app_name: 'YOUR_APP', limit: 2 })) {
166+
for await (const deploymentListResponse of client.deployments.list({
167+
app_name: 'YOUR_APP',
168+
limit: 2,
169+
})) {
167170
allDeploymentListResponses.push(deploymentListResponse);
168171
}
169172
return allDeploymentListResponses;
@@ -203,7 +206,9 @@ const response = await client.browsers.create({ stealth: true }).asResponse();
203206
console.log(response.headers.get('X-My-Header'));
204207
console.log(response.statusText); // access the underlying Response object
205208

206-
const { data: browser, response: raw } = await client.browsers.create({ stealth: true }).withResponse();
209+
const { data: browser, response: raw } = await client.browsers
210+
.create({ stealth: true })
211+
.withResponse();
207212
console.log(raw.headers.get('X-My-Header'));
208213
console.log(browser.session_id);
209214
```

tests/api-resources/agents/auth/auth.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ describe('resource auth', () => {
6363
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
6464
await expect(
6565
client.agents.auth.list(
66-
{ limit: 100, offset: 0, profile_name: 'profile_name', target_domain: 'target_domain' },
66+
{
67+
limit: 100,
68+
offset: 0,
69+
profile_name: 'profile_name',
70+
target_domain: 'target_domain',
71+
},
6772
{ path: '/_stainless_unknown_path' },
6873
),
6974
).rejects.toThrow(Kernel.NotFoundError);

tests/api-resources/apps.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ describe('resource apps', () => {
2525
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
2626
await expect(
2727
client.apps.list(
28-
{ app_name: 'app_name', limit: 1, offset: 0, version: 'version' },
28+
{
29+
app_name: 'app_name',
30+
limit: 1,
31+
offset: 0,
32+
version: 'version',
33+
},
2934
{ path: '/_stainless_unknown_path' },
3035
),
3136
).rejects.toThrow(Kernel.NotFoundError);

tests/api-resources/browser-pools.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ describe('resource browserPools', () => {
2929
headless: false,
3030
kiosk_mode: true,
3131
name: 'my-pool',
32-
profile: { id: 'id', name: 'name', save_changes: true },
32+
profile: {
33+
id: 'id',
34+
name: 'name',
35+
save_changes: true,
36+
},
3337
proxy_id: 'proxy_id',
3438
stealth: true,
3539
timeout_seconds: 60,
36-
viewport: { height: 800, width: 1280, refresh_rate: 60 },
40+
viewport: {
41+
height: 800,
42+
width: 1280,
43+
refresh_rate: 60,
44+
},
3745
});
3846
});
3947

@@ -71,11 +79,19 @@ describe('resource browserPools', () => {
7179
headless: false,
7280
kiosk_mode: true,
7381
name: 'my-pool',
74-
profile: { id: 'id', name: 'name', save_changes: true },
82+
profile: {
83+
id: 'id',
84+
name: 'name',
85+
save_changes: true,
86+
},
7587
proxy_id: 'proxy_id',
7688
stealth: true,
7789
timeout_seconds: 60,
78-
viewport: { height: 800, width: 1280, refresh_rate: 60 },
90+
viewport: {
91+
height: 800,
92+
width: 1280,
93+
refresh_rate: 60,
94+
},
7995
});
8096
});
8197

tests/api-resources/browsers/browsers.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ describe('resource browsers', () => {
3131
invocation_id: 'rr33xuugxj9h0bkf1rdt2bet',
3232
kiosk_mode: true,
3333
persistence: { id: 'my-awesome-browser-for-user-1234' },
34-
profile: { id: 'id', name: 'name', save_changes: true },
34+
profile: {
35+
id: 'id',
36+
name: 'name',
37+
save_changes: true,
38+
},
3539
proxy_id: 'proxy_id',
3640
stealth: true,
3741
timeout_seconds: 10,
38-
viewport: { height: 800, width: 1280, refresh_rate: 60 },
42+
viewport: {
43+
height: 800,
44+
width: 1280,
45+
refresh_rate: 60,
46+
},
3947
},
4048
{ path: '/_stainless_unknown_path' },
4149
),
@@ -71,7 +79,11 @@ describe('resource browsers', () => {
7179
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
7280
await expect(
7381
client.browsers.list(
74-
{ include_deleted: true, limit: 1, offset: 0 },
82+
{
83+
include_deleted: true,
84+
limit: 1,
85+
offset: 0,
86+
},
7587
{ path: '/_stainless_unknown_path' },
7688
),
7789
).rejects.toThrow(Kernel.NotFoundError);

tests/api-resources/browsers/computer.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ describe('resource computer', () => {
1313
await expect(
1414
client.browsers.computer.captureScreenshot(
1515
'id',
16-
{ region: { height: 0, width: 0, x: 0, y: 0 } },
16+
{
17+
region: {
18+
height: 0,
19+
width: 0,
20+
x: 0,
21+
y: 0,
22+
},
23+
},
1724
{ path: '/_stainless_unknown_path' },
1825
),
1926
).rejects.toThrow(Kernel.NotFoundError);
@@ -89,7 +96,11 @@ describe('resource computer', () => {
8996

9097
// Prism tests are disabled
9198
test.skip('moveMouse: required and optional params', async () => {
92-
const response = await client.browsers.computer.moveMouse('id', { x: 0, y: 0, hold_keys: ['string'] });
99+
const response = await client.browsers.computer.moveMouse('id', {
100+
x: 0,
101+
y: 0,
102+
hold_keys: ['string'],
103+
});
93104
});
94105

95106
// Prism tests are disabled

tests/api-resources/credentials.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ describe('resource credentials', () => {
7474
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
7575
await expect(
7676
client.credentials.list(
77-
{ domain: 'domain', limit: 100, offset: 0 },
77+
{
78+
domain: 'domain',
79+
limit: 100,
80+
offset: 0,
81+
},
7882
{ path: '/_stainless_unknown_path' },
7983
),
8084
).rejects.toThrow(Kernel.NotFoundError);

tests/api-resources/deployments.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ describe('resource deployments', () => {
4949
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
5050
await expect(
5151
client.deployments.list(
52-
{ app_name: 'app_name', limit: 1, offset: 0 },
52+
{
53+
app_name: 'app_name',
54+
limit: 1,
55+
offset: 0,
56+
},
5357
{ path: '/_stainless_unknown_path' },
5458
),
5559
).rejects.toThrow(Kernel.NotFoundError);

tests/index.test.ts

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ describe('instantiate client', () => {
8787
error: jest.fn(),
8888
};
8989

90-
const client = new Kernel({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
90+
const client = new Kernel({
91+
logger: logger,
92+
logLevel: 'debug',
93+
apiKey: 'My API Key',
94+
});
9195

9296
await forceAPIResponseForClient(client);
9397
expect(debugMock).toHaveBeenCalled();
@@ -107,7 +111,11 @@ describe('instantiate client', () => {
107111
error: jest.fn(),
108112
};
109113

110-
const client = new Kernel({ logger: logger, logLevel: 'info', apiKey: 'My API Key' });
114+
const client = new Kernel({
115+
logger: logger,
116+
logLevel: 'info',
117+
apiKey: 'My API Key',
118+
});
111119

112120
await forceAPIResponseForClient(client);
113121
expect(debugMock).not.toHaveBeenCalled();
@@ -157,7 +165,11 @@ describe('instantiate client', () => {
157165
};
158166

159167
process.env['KERNEL_LOG'] = 'debug';
160-
const client = new Kernel({ logger: logger, logLevel: 'off', apiKey: 'My API Key' });
168+
const client = new Kernel({
169+
logger: logger,
170+
logLevel: 'off',
171+
apiKey: 'My API Key',
172+
});
161173

162174
await forceAPIResponseForClient(client);
163175
expect(debugMock).not.toHaveBeenCalled();
@@ -173,7 +185,11 @@ describe('instantiate client', () => {
173185
};
174186

175187
process.env['KERNEL_LOG'] = 'not a log level';
176-
const client = new Kernel({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
188+
const client = new Kernel({
189+
logger: logger,
190+
logLevel: 'debug',
191+
apiKey: 'My API Key',
192+
});
177193
expect(client.logLevel).toBe('debug');
178194
expect(warnMock).not.toHaveBeenCalled();
179195
});
@@ -267,7 +283,11 @@ describe('instantiate client', () => {
267283
return new Response(JSON.stringify({}), { headers: { 'Content-Type': 'application/json' } });
268284
};
269285

270-
const client = new Kernel({ baseURL: 'http://localhost:5000/', apiKey: 'My API Key', fetch: testFetch });
286+
const client = new Kernel({
287+
baseURL: 'http://localhost:5000/',
288+
apiKey: 'My API Key',
289+
fetch: testFetch,
290+
});
271291

272292
await client.patch('/foo');
273293
expect(capturedRequest?.method).toEqual('PATCH');
@@ -320,7 +340,11 @@ describe('instantiate client', () => {
320340
`"Ambiguous URL; The \`baseURL\` option (or KERNEL_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`,
321341
);
322342

323-
const client = new Kernel({ apiKey: 'My API Key', baseURL: null, environment: 'production' });
343+
const client = new Kernel({
344+
apiKey: 'My API Key',
345+
baseURL: null,
346+
environment: 'production',
347+
});
324348
expect(client.baseURL).toEqual('https://api.onkernel.com/');
325349
});
326350

@@ -358,7 +382,11 @@ describe('instantiate client', () => {
358382

359383
describe('withOptions', () => {
360384
test('creates a new client with overridden options', async () => {
361-
const client = new Kernel({ baseURL: 'http://localhost:5000/', maxRetries: 3, apiKey: 'My API Key' });
385+
const client = new Kernel({
386+
baseURL: 'http://localhost:5000/',
387+
maxRetries: 3,
388+
apiKey: 'My API Key',
389+
});
362390

363391
const newClient = client.withOptions({
364392
maxRetries: 5,
@@ -398,7 +426,11 @@ describe('instantiate client', () => {
398426
});
399427

400428
test('respects runtime property changes when creating new client', () => {
401-
const client = new Kernel({ baseURL: 'http://localhost:5000/', timeout: 1000, apiKey: 'My API Key' });
429+
const client = new Kernel({
430+
baseURL: 'http://localhost:5000/',
431+
timeout: 1000,
432+
apiKey: 'My API Key',
433+
});
402434

403435
// Modify the client properties directly after creation
404436
client.baseURL = 'http://localhost:6000/';
@@ -544,7 +576,11 @@ describe('retries', () => {
544576
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
545577
};
546578

547-
const client = new Kernel({ apiKey: 'My API Key', timeout: 10, fetch: testFetch });
579+
const client = new Kernel({
580+
apiKey: 'My API Key',
581+
timeout: 10,
582+
fetch: testFetch,
583+
});
548584

549585
expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
550586
expect(count).toEqual(2);
@@ -574,7 +610,11 @@ describe('retries', () => {
574610
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
575611
};
576612

577-
const client = new Kernel({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
613+
const client = new Kernel({
614+
apiKey: 'My API Key',
615+
fetch: testFetch,
616+
maxRetries: 4,
617+
});
578618

579619
expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
580620

@@ -598,7 +638,11 @@ describe('retries', () => {
598638
capturedRequest = init;
599639
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
600640
};
601-
const client = new Kernel({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
641+
const client = new Kernel({
642+
apiKey: 'My API Key',
643+
fetch: testFetch,
644+
maxRetries: 4,
645+
});
602646

603647
expect(
604648
await client.request({
@@ -660,7 +704,11 @@ describe('retries', () => {
660704
capturedRequest = init;
661705
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
662706
};
663-
const client = new Kernel({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
707+
const client = new Kernel({
708+
apiKey: 'My API Key',
709+
fetch: testFetch,
710+
maxRetries: 4,
711+
});
664712

665713
expect(
666714
await client.request({

0 commit comments

Comments
 (0)