Skip to content

Commit 47ba213

Browse files
authored
ci: fix npm publish permissions (#2601)
* Fix permissions * Update deps * Re-add GITHUB_TOKEN * Lint
1 parent 697f7fe commit 47ba213

File tree

17 files changed

+214
-220
lines changed

17 files changed

+214
-220
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
branches:
66
- main
77

8-
env:
9-
GITHUB_TOKEN: ${{ secrets.OPENAPI_TS_BOT_GITHUB_TOKEN }}
10-
118
permissions:
129
id-token: write # Required for OIDC
1310
contents: write
@@ -16,10 +13,6 @@ permissions:
1613
jobs:
1714
changelog:
1815
runs-on: ubuntu-latest
19-
if: ${{ github.repository_owner == 'openapi-ts' }}
20-
permissions:
21-
contents: write
22-
pull-requests: write
2316
steps:
2417
- name: Git setup
2518
uses: actions/checkout@v6
@@ -45,3 +38,5 @@ jobs:
4538
publish: pnpm exec changeset publish
4639
commit: "[ci] release"
4740
title: "[ci] release"
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.OPENAPI_TS_BOT_GITHUB_TOKEN }}

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
33
"root": true,
44
"files": {
55
"includes": ["**", "!**/dist", "!**/package.json"]

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
},
2121
"devDependencies": {
2222
"@arethetypeswrong/cli": "0.18.2",
23-
"@biomejs/biome": "2.2.6",
23+
"@biomejs/biome": "2.3.14",
2424
"@changesets/changelog-github": "0.5.2",
2525
"@changesets/cli": "2.29.8",
2626
"@playwright/test": "1.56.0",
27-
"@size-limit/preset-small-lib": "11.2.0",
27+
"@size-limit/preset-small-lib": "12.0.0",
2828
"@types/node": "25.2.2",
29-
"prettier": "3.6.2",
30-
"size-limit": "11.2.0",
31-
"turbo": "2.5.8",
29+
"prettier": "3.8.1",
30+
"size-limit": "12.0.0",
31+
"turbo": "2.8.3",
3232
"typescript": "catalog:",
3333
"unbuild": "3.6.1",
3434
"vitest": "4.0.18"

packages/openapi-fetch/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": false,
3-
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
44
"extends": "//",
55
"files": {
66
"includes": ["src/**", "test/**", "!**/examples/**", "!test/**/schemas/**", "!test/bench/**/*.min.js"]

packages/openapi-fetch/src/index.d.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ export type ParamsOption<T> = T extends {
9292
: { params: T["parameters"] }
9393
: DefaultParamsOption;
9494

95-
export type RequestBodyOption<T> = OperationRequestBodyContent<T> extends never
96-
? { body?: never }
97-
: IsOperationRequestBodyOptional<T> extends true
98-
? { body?: OperationRequestBodyContent<T> }
99-
: { body: OperationRequestBodyContent<T> };
95+
export type RequestBodyOption<T> =
96+
OperationRequestBodyContent<T> extends never
97+
? { body?: never }
98+
: IsOperationRequestBodyOptional<T> extends true
99+
? { body?: OperationRequestBodyContent<T> }
100+
: { body: OperationRequestBodyContent<T> };
100101

101102
export type FetchOptions<T> = RequestOptions<T> & Omit<RequestInit, "body" | "headers">;
102103

@@ -177,19 +178,17 @@ export type Middleware =
177178
};
178179

179180
/** This type helper makes the 2nd function param required if params/requestBody are required; otherwise, optional */
180-
export type MaybeOptionalInit<Params, Location extends keyof Params> = RequiredKeysOf<
181-
FetchOptions<FilterKeys<Params, Location>>
182-
> extends never
183-
? FetchOptions<FilterKeys<Params, Location>> | undefined
184-
: FetchOptions<FilterKeys<Params, Location>>;
181+
export type MaybeOptionalInit<Params, Location extends keyof Params> =
182+
RequiredKeysOf<FetchOptions<FilterKeys<Params, Location>>> extends never
183+
? FetchOptions<FilterKeys<Params, Location>> | undefined
184+
: FetchOptions<FilterKeys<Params, Location>>;
185185

186186
// The final init param to accept.
187187
// - Determines if the param is optional or not.
188188
// - Performs arbitrary [key: string] addition.
189189
// Note: the addition MUST happen after all the inference happens (otherwise TS can’t infer if init is required or not).
190-
type InitParam<Init> = RequiredKeysOf<Init> extends never
191-
? [(Init & { [key: string]: unknown })?]
192-
: [Init & { [key: string]: unknown }];
190+
type InitParam<Init> =
191+
RequiredKeysOf<Init> extends never ? [(Init & { [key: string]: unknown })?] : [Init & { [key: string]: unknown }];
193192

194193
export type ClientMethod<
195194
Paths extends Record<string, Record<HttpMethod, {}>>,
@@ -240,19 +239,18 @@ export interface Client<Paths extends {}, Media extends MediaType = MediaType> {
240239
eject(...middleware: Middleware[]): void;
241240
}
242241

243-
export type ClientPathsWithMethod<
244-
CreatedClient extends Client<any, any>,
245-
Method extends HttpMethod,
246-
> = CreatedClient extends Client<infer Paths, infer _Media> ? PathsWithMethod<Paths, Method> : never;
242+
export type ClientPathsWithMethod<CreatedClient extends Client<any, any>, Method extends HttpMethod> =
243+
CreatedClient extends Client<infer Paths, infer _Media> ? PathsWithMethod<Paths, Method> : never;
247244

248245
export type MethodResponse<
249246
CreatedClient extends Client<any, any>,
250247
Method extends HttpMethod,
251248
Path extends ClientPathsWithMethod<CreatedClient, Method>,
252249
Options = {},
253-
> = CreatedClient extends Client<infer Paths extends { [key: string]: any }, infer Media extends MediaType>
254-
? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]>
255-
: never;
250+
> =
251+
CreatedClient extends Client<infer Paths extends { [key: string]: any }, infer Media extends MediaType>
252+
? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]>
253+
: never;
256254

257255
export default function createClient<Paths extends {}, Media extends MediaType = MediaType>(
258256
clientOptions?: ClientOptions,

packages/openapi-fetch/test/common/create-client.test.ts

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -98,75 +98,70 @@ describe("createClient options", () => {
9898
BODIES.map((body) => [method, body] as const),
9999
);
100100

101-
test.each(METHOD_BODY_COMBINATIONS)(
102-
"implicit default content-type for body-full requests - %s, %j",
103-
async (method, body) => {
104-
const contentType = await fireRequestAndGetContentType({
105-
method,
106-
fetchOptions: { body },
107-
});
108-
109-
expect(contentType).toBe("application/json");
110-
},
111-
);
101+
test.each(
102+
METHOD_BODY_COMBINATIONS,
103+
)("implicit default content-type for body-full requests - %s, %j", async (method, body) => {
104+
const contentType = await fireRequestAndGetContentType({
105+
method,
106+
fetchOptions: { body },
107+
});
112108

113-
test.each(METHOD_BODY_COMBINATIONS)(
114-
"provided default content-type for body-full requests - %s, %j",
115-
async (method, body) => {
116-
const contentType = await fireRequestAndGetContentType({
117-
defaultHeaders: { "content-type": "application/my-json" },
118-
method,
119-
fetchOptions: { body },
120-
});
121-
122-
expect(contentType).toBe("application/my-json");
123-
},
124-
);
109+
expect(contentType).toBe("application/json");
110+
});
125111

126-
test.each(METHOD_BODY_COMBINATIONS)(
127-
"native-fetch default content-type for body-full requests, when default is suppressed - %s, %j",
128-
async (method, body) => {
129-
const contentType = await fireRequestAndGetContentType({
130-
defaultHeaders: { "content-type": null },
131-
method,
132-
fetchOptions: { body },
133-
});
134-
// the fetch implementation won't allow sending a body without content-type,
135-
// and it defaults to `text/plain;charset=UTF-8`, however the actual default value
136-
// is irrelevant and might be flaky across different fetch implementations
137-
// for us, it's important that it's not `application/json`
138-
expect(contentType).not.toBe("application/json");
139-
},
140-
);
112+
test.each(
113+
METHOD_BODY_COMBINATIONS,
114+
)("provided default content-type for body-full requests - %s, %j", async (method, body) => {
115+
const contentType = await fireRequestAndGetContentType({
116+
defaultHeaders: { "content-type": "application/my-json" },
117+
method,
118+
fetchOptions: { body },
119+
});
141120

142-
test.each(METHOD_BODY_COMBINATIONS)(
143-
"specified content-type for body-full requests - %s, %j",
144-
async (method, body) => {
145-
const contentType = await fireRequestAndGetContentType({
146-
method,
147-
fetchOptions: {
148-
body,
149-
headers: { "content-type": "application/my-json" },
150-
},
151-
});
152-
153-
expect(contentType).toBe("application/my-json");
154-
},
155-
);
121+
expect(contentType).toBe("application/my-json");
122+
});
156123

157-
test.each(METHOD_BODY_COMBINATIONS)(
158-
"specified content-type for body-full requests, even when default is suppressed - %s, %j",
159-
async (method, body) => {
160-
const contentType = await fireRequestAndGetContentType({
161-
method,
162-
fetchOptions: {
163-
body,
164-
headers: { "content-type": "application/my-json" },
165-
},
166-
});
167-
168-
expect(contentType).toBe("application/my-json");
169-
},
170-
);
124+
test.each(
125+
METHOD_BODY_COMBINATIONS,
126+
)("native-fetch default content-type for body-full requests, when default is suppressed - %s, %j", async (method, body) => {
127+
const contentType = await fireRequestAndGetContentType({
128+
defaultHeaders: { "content-type": null },
129+
method,
130+
fetchOptions: { body },
131+
});
132+
// the fetch implementation won't allow sending a body without content-type,
133+
// and it defaults to `text/plain;charset=UTF-8`, however the actual default value
134+
// is irrelevant and might be flaky across different fetch implementations
135+
// for us, it's important that it's not `application/json`
136+
expect(contentType).not.toBe("application/json");
137+
});
138+
139+
test.each(
140+
METHOD_BODY_COMBINATIONS,
141+
)("specified content-type for body-full requests - %s, %j", async (method, body) => {
142+
const contentType = await fireRequestAndGetContentType({
143+
method,
144+
fetchOptions: {
145+
body,
146+
headers: { "content-type": "application/my-json" },
147+
},
148+
});
149+
150+
expect(contentType).toBe("application/my-json");
151+
});
152+
153+
test.each(
154+
METHOD_BODY_COMBINATIONS,
155+
)("specified content-type for body-full requests, even when default is suppressed - %s, %j", async (method, body) => {
156+
const contentType = await fireRequestAndGetContentType({
157+
method,
158+
fetchOptions: {
159+
body,
160+
headers: { "content-type": "application/my-json" },
161+
},
162+
});
163+
164+
expect(contentType).toBe("application/my-json");
165+
});
171166
});
172167
});

packages/openapi-fetch/test/middleware/middleware.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ test("baseUrl can be overridden", async () => {
421421
});
422422

423423
test("auth header", async () => {
424-
let accessToken: string | undefined = undefined;
424+
let accessToken: string | undefined;
425425
const authMiddleware: Middleware = {
426426
async onRequest({ request }) {
427427
if (accessToken) {

packages/openapi-react-query/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": false,
3-
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
44
"extends": "//",
55
"files": {
66
"includes": ["**", "!dist/**", "!test/fixtures/**"]

packages/openapi-react-query/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ export type MethodResponse<
182182
? PathsWithMethod<Paths, Method>
183183
: never,
184184
Options = object,
185-
> = CreatedClient extends OpenapiQueryClient<infer Paths extends { [key: string]: any }, infer Media extends MediaType>
186-
? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]>
187-
: never;
185+
> =
186+
CreatedClient extends OpenapiQueryClient<infer Paths extends { [key: string]: any }, infer Media extends MediaType>
187+
? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>["data"]>
188+
: never;
188189

189190
// TODO: Add the ability to bring queryClient as argument
190191
export default function createClient<Paths extends {}, Media extends MediaType = MediaType>(

packages/openapi-typescript-helpers/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": false,
3-
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
44
"extends": "//",
55
"files": {
66
"includes": ["**/*"]

0 commit comments

Comments
 (0)