Skip to content

Commit 54866aa

Browse files
feat(api): manual updates
1 parent df1c791 commit 54866aa

File tree

17 files changed

+3453
-41
lines changed

17 files changed

+3453
-41
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-2d0de952cda743455598229e8f69c324bf65bbb908982b4fa3a36ff268b46a8d.yml
3-
openapi_spec_hash: 8016de730b9c2c26513bf624cd30a828
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-55484eb3c5a4487f67eb0ddc6b416b47792ad78685be2f3f33f586a1995a97dd.yml
3+
openapi_spec_hash: 32dad4966e2c03ced3e9d8b90f6b6a3b
44
config_hash: 1bee02a0eeb902e1ea32aa032bc70f54

src/client.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { APIResponseProps } from './internal/parse';
1212
import { getPlatformHeaders } from './internal/detect-platform';
1313
import * as Shims from './internal/shims';
1414
import * as Opts from './internal/request-options';
15+
import * as qs from './internal/qs';
1516
import { VERSION } from './version';
1617
import * as Errors from './core/error';
1718
import * as Uploads from './core/uploads';
@@ -201,24 +202,8 @@ export class StainlessV0 {
201202
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
202203
}
203204

204-
/**
205-
* Basic re-implementation of `qs.stringify` for primitive types.
206-
*/
207205
protected stringifyQuery(query: Record<string, unknown>): string {
208-
return Object.entries(query)
209-
.filter(([_, value]) => typeof value !== 'undefined')
210-
.map(([key, value]) => {
211-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
212-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
213-
}
214-
if (value === null) {
215-
return `${encodeURIComponent(key)}=`;
216-
}
217-
throw new Errors.StainlessV0Error(
218-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
219-
);
220-
})
221-
.join('&');
206+
return qs.stringify(query, { arrayFormat: 'comma' });
222207
}
223208

224209
private getUserAgent(): string {

src/internal/qs/LICENSE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10+
11+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/internal/qs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# qs
2+
3+
This is a vendored version of [neoqs](https://github.com/PuruVJ/neoqs) which is a TypeScript rewrite of [qs](https://github.com/ljharb/qs), a query string library.

src/internal/qs/formats.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Format } from './types';
2+
3+
export const default_format: Format = 'RFC3986';
4+
export const formatters: Record<Format, (str: PropertyKey) => string> = {
5+
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
6+
RFC3986: (v: PropertyKey) => String(v),
7+
};
8+
export const RFC1738 = 'RFC1738';
9+
export const RFC3986 = 'RFC3986';

src/internal/qs/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { default_format, formatters, RFC1738, RFC3986 } from './formats';
2+
3+
const formats = {
4+
formatters,
5+
RFC1738,
6+
RFC3986,
7+
default: default_format,
8+
};
9+
10+
export { stringify } from './stringify';
11+
export { formats };
12+
13+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';

0 commit comments

Comments
 (0)