@replit/connectors 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
17
  import * as Pagination from './core/pagination';
@@ -466,8 +466,8 @@ export class Replit {
466
466
  return buildHeaders([{ Authorization: `Bearer ${this.token}` }]);
467
467
  }
468
468
 
469
- protected stringifyQuery(query: Record<string, unknown>): string {
470
- return qs.stringify(query, { arrayFormat: 'comma' });
469
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
470
+ return stringifyQuery(query);
471
471
  }
472
472
 
473
473
  private getUserAgent(): string {
@@ -499,12 +499,13 @@ export class Replit {
499
499
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
500
500
 
501
501
  const defaultQuery = this.defaultQuery();
502
- if (!isEmptyObj(defaultQuery)) {
503
- query = { ...defaultQuery, ...query };
502
+ const pathQuery = Object.fromEntries(url.searchParams);
503
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
504
+ query = { ...pathQuery, ...defaultQuery, ...query };
504
505
  }
505
506
 
506
507
  if (typeof query === 'object' && query && !Array.isArray(query)) {
507
- url.search = this.stringifyQuery(query as Record<string, unknown>);
508
+ url.search = this.stringifyQuery(query);
508
509
  }
509
510
 
510
511
  return url.toString();
@@ -833,9 +834,9 @@ export class Replit {
833
834
  }
834
835
  }
835
836
 
836
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
837
- // just do what it says, but otherwise calculate a default
838
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
837
+ // If the API asks us to wait a certain amount of time, just do what it
838
+ // says, but otherwise calculate a default
839
+ if (timeoutMillis === undefined) {
839
840
  const maxRetries = options.maxRetries ?? this.maxRetries;
840
841
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
841
842
  }
@@ -967,7 +968,7 @@ export class Replit {
967
968
  ) {
968
969
  return {
969
970
  bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
970
- body: this.stringifyQuery(body as Record<string, unknown>),
971
+ body: this.stringifyQuery(body),
971
972
  };
972
973
  } else {
973
974
  return this.#encoder({ body, headers });
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';