Skip to content

Commit e489880

Browse files
chore(internal): add pure annotations, make base APIResource abstract
1 parent be3283b commit e489880

File tree

10 files changed

+27
-16
lines changed

10 files changed

+27
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"sshpk": "^1.18.0",
4646
"ts-jest": "^29.1.0",
4747
"ts-node": "^10.5.0",
48-
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz",
48+
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz",
4949
"tsconfig-paths": "^4.0.0",
5050
"typescript": "5.8.3",
5151
"typescript-eslint": "8.31.1"

scripts/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fi
3131
node scripts/utils/make-dist-package-json.cjs > dist/package.json
3232

3333
# build to .js/.mjs/.d.ts files
34-
npm exec tsc-multi
34+
./node_modules/.bin/tsc-multi
3535
# we need to patch index.js so that `new module.exports()` works for cjs backwards
3636
# compat. No way to get that from index.ts because it would cause compile errors
3737
# when building .mjs

src/core/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type { Gitpod } from '../client';
44

5-
export class APIResource {
5+
export abstract class APIResource {
66
protected _client: Gitpod;
77

88
constructor(client: Gitpod) {

src/internal/headers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
import { isReadonlyArray } from './utils/values';
4+
35
type HeaderValue = string | undefined | null;
46
export type HeadersLike =
57
| Headers
@@ -9,7 +11,7 @@ export type HeadersLike =
911
| null
1012
| NullableHeaders;
1113

12-
const brand_privateNullableHeaders = Symbol('brand.privateNullableHeaders');
14+
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
1315

1416
/**
1517
* @internal
@@ -25,8 +27,6 @@ export type NullableHeaders = {
2527
nulls: Set<string>;
2628
};
2729

28-
const isArray = Array.isArray as (val: unknown) => val is readonly unknown[];
29-
3030
function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [string, string | null]> {
3131
if (!headers) return;
3232

@@ -43,7 +43,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
4343
let iter: Iterable<readonly (HeaderValue | readonly HeaderValue[])[]>;
4444
if (headers instanceof Headers) {
4545
iter = headers.entries();
46-
} else if (isArray(headers)) {
46+
} else if (isReadonlyArray(headers)) {
4747
iter = headers;
4848
} else {
4949
shouldClear = true;
@@ -52,7 +52,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator<readonly [strin
5252
for (let row of iter) {
5353
const name = row[0];
5454
if (typeof name !== 'string') throw new TypeError('expected header name to be a string');
55-
const values = isArray(row[1]) ? row[1] : [row[1]];
55+
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
5656
let didClear = false;
5757
for (const value of values) {
5858
if (value === undefined) continue;

src/internal/uploads.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async (
9090
return { ...opts, body: await createForm(opts.body, fetch) };
9191
};
9292

93-
const supportsFormDataMap = new WeakMap<Fetch, Promise<boolean>>();
93+
const supportsFormDataMap = /** @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
9494

9595
/**
9696
* node-fetch doesn't support the global FormData object in recent node versions. Instead of sending

src/internal/utils/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const noopLogger = {
5858
debug: noop,
5959
};
6060

61-
let cachedLoggers = new WeakMap<Logger, [LogLevel, Logger]>();
61+
let cachedLoggers = /** @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
6262

6363
export function loggerFor(client: Gitpod): Logger {
6464
const logger = client.logger;

src/internal/utils/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
6060
/**
6161
* URI-encodes path params and ensures no unsafe /./ or /../ path segments are introduced.
6262
*/
63-
export const path = createPathTagFunction(encodeURIPath);
63+
export const path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);

src/internal/utils/values.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export const isAbsoluteURL = (url: string): boolean => {
99
return startsWithSchemeRegexp.test(url);
1010
};
1111

12+
export let isArray = (val: unknown): val is unknown[] => ((isArray = Array.isArray), isArray(val));
13+
export let isReadonlyArray = isArray as (val: unknown) => val is readonly unknown[];
14+
1215
/** Returns an object if the given value isn't an object, otherwise returns as-is */
1316
export function maybeObj(x: unknown): object {
1417
if (typeof x !== 'object') {

tsc-multi.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"targets": [
3-
{ "extname": ".js", "module": "commonjs", "shareHelpers": "internal/tslib.js" },
4-
{ "extname": ".mjs", "module": "esnext", "shareHelpers": "internal/tslib.mjs" }
3+
{
4+
"extname": ".js",
5+
"module": "commonjs",
6+
"shareHelpers": "internal/tslib.js"
7+
},
8+
{
9+
"extname": ".mjs",
10+
"module": "esnext",
11+
"shareHelpers": "internal/tslib.mjs"
12+
}
513
],
614
"projects": ["tsconfig.build.json"]
715
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,9 +3402,9 @@ ts-node@^10.5.0:
34023402
v8-compile-cache-lib "^3.0.0"
34033403
yn "3.1.1"
34043404

3405-
"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz":
3406-
version "1.1.4"
3407-
resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.4/tsc-multi-1.1.4.tgz#cbed459a9e902f5295ec3daaf1c7aa3b10427e55"
3405+
"tsc-multi@https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz":
3406+
version "1.1.7"
3407+
resolved "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.7/tsc-multi.tgz#52f40adf8b808bd0b633346d11cc4a8aeea465cd"
34083408
dependencies:
34093409
debug "^4.3.7"
34103410
fast-glob "^3.3.2"

0 commit comments

Comments
 (0)