Skip to content

Commit e7b790c

Browse files
authored
🏷️ Export discriminated interfaces for SchemaRestPullRequestActivity (#17)
1 parent 4480cc6 commit e7b790c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+214
-156
lines changed

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"ts-autofix": "^1.0.0",
6565
"tsx": "^4.19.1",
6666
"typedoc": "^0.26.10",
67-
"typescript": "^5.6.3",
67+
"typescript": "5.7.0-beta",
6868
"typescript-eslint": "^8.10.0",
6969
"vitest": "^2.1.3"
7070
},
@@ -78,9 +78,17 @@
7878
"types": "./dist/cloud/index.d.ts",
7979
"default": "./dist/cloud/index.js"
8080
},
81+
"./cloud/openapi": {
82+
"types": "./dist/cloud/openapi/index.d.ts",
83+
"default": "./dist/cloud/openapi/index.js"
84+
},
8185
"./server": {
8286
"types": "./dist/server/index.d.ts",
8387
"default": "./dist/server/index.js"
88+
},
89+
"./server/openapi": {
90+
"types": "./dist/server/openapi/index.d.ts",
91+
"default": "./dist/server/openapi/index.js"
8492
}
8593
},
8694
"types": "dist/index.d.ts",

pnpm-lock.yaml

+38-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base64.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "vitest"
2-
import { fromBase64, toBase64 } from "./base64.js"
2+
import { fromBase64, toBase64 } from "./base64.ts"
33

44
test("toBase64", ({ expect }) => {
55
const based = toBase64("Copyright © 2024 CodeRabbit")

src/cloud/client.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "vitest"
2-
import { createBitbucketCloudClient } from "./client.js"
2+
import { createBitbucketCloudClient } from "./client.ts"
33

44
test("createBitbucketCloudClient", ({ expect }) => {
55
const client = createBitbucketCloudClient()

src/cloud/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client, ClientOptions } from "openapi-fetch"
22
import createClient from "openapi-fetch"
3-
import type { paths } from "./openapi/index.js"
3+
import type { paths } from "./openapi/index.ts"
44

55
/**
66
* Creates an `openapi-fetch` client using {@link createClient}.

src/cloud/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from "./client.js"
2-
export type * from "./openapi/index.js"
1+
export * from "./client.ts"
2+
export type * as OpenApi from "./openapi/index.ts"

src/cloud/openapi/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type * from "./openapi-typescript.js"
1+
export type * from "./openapi-typescript.ts"

src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "vitest"
2-
import * as index from "./index.js"
2+
import * as index from "./index.ts"
33

44
test("index", ({ expect }) => {
55
expect(index).toBeDefined()

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from "./base64.js"
2-
export * as cloud from "./cloud/index.js"
3-
export * as server from "./server/index.js"
1+
export * from "./base64.ts"
2+
export * as BitbucketCloud from "./cloud/index.ts"
3+
export * as BitbucketServer from "./server/index.ts"

src/server/client.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "vitest"
2-
import { createBitbucketServerClient } from "./client.js"
2+
import { createBitbucketServerClient } from "./client.ts"
33

44
test("createBitbucketServerClient", ({ expect }) => {
55
const client = createBitbucketServerClient()

src/server/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client, ClientOptions } from "openapi-fetch"
22
import createClient from "openapi-fetch"
3-
import type { paths } from "./openapi/index.js"
3+
import type { paths } from "./openapi/index.ts"
44

55
/**
66
* Creates an `openapi-fetch` client using {@link createClient}.

src/server/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export * from "./client.js"
2-
export type * from "./openapi/index.js"
3-
export * from "./webhooks/index.js"
1+
export * from "./client.ts"
2+
export * from "./interfaces/index.ts"
3+
export type * as OpenApi from "./openapi/index.ts"
4+
export * from "./webhooks/index.ts"

src/server/interfaces/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./schema_rest_pull_request_activity.ts"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import type {
2+
SchemaRestComment,
3+
SchemaRestPullRequestActivity as SchemaRestPullRequestActivityBase,
4+
} from "../openapi/index.ts"
5+
6+
export type SchemaRestPullRequestActivity =
7+
| SchemaRestPullRequestActivityCommented
8+
| SchemaRestPullRequestActivityOpened
9+
| SchemaRestPullRequestActivityUpdated
10+
type User = SchemaRestPullRequestActivityBase["user"]
11+
12+
export interface SchemaRestPullRequestActivityCommented
13+
extends SchemaRestPullRequestActivityBase {
14+
readonly action: "COMMENTED"
15+
readonly comment?: SchemaRestComment
16+
readonly commentAnchor?: SchemaRestComment["anchor"]
17+
}
18+
19+
export interface SchemaRestPullRequestActivityOpened
20+
extends SchemaRestPullRequestActivityBase {
21+
readonly action: "OPENED"
22+
}
23+
24+
export interface SchemaRestPullRequestActivityUpdated
25+
extends SchemaRestPullRequestActivityBase {
26+
readonly action: "UPDATED"
27+
readonly addedReviewers: User[]
28+
readonly removedReviewers: User[]
29+
}
30+
31+
export function isSchemaRestPullRequestActivityCommented(
32+
activity: SchemaRestPullRequestActivity,
33+
): activity is SchemaRestPullRequestActivityCommented {
34+
return activity.action === "COMMENTED"
35+
}
36+
37+
export function isSchemaRestPullRequestActivityOpened(
38+
activity: SchemaRestPullRequestActivity,
39+
): activity is SchemaRestPullRequestActivityOpened {
40+
return activity.action === "OPENED"
41+
}
42+
43+
export function isSchemaRestPullRequestActivityUpdated(
44+
activity: SchemaRestPullRequestActivity,
45+
): activity is SchemaRestPullRequestActivityUpdated {
46+
return activity.action === "UPDATED"
47+
}

src/server/openapi/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type * from "./openapi-typescript.js"
1+
export type * from "./openapi-typescript.ts"

src/server/webhooks/events/event.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { PrEvent } from "./pr/event.js"
2-
import { prEventKeys } from "./pr/event.js"
3-
import type { ProjectEvent } from "./project/event.js"
4-
import { projectEventKeys } from "./project/event.js"
5-
import type { RepoEvent } from "./repo/event.js"
6-
import { repoEventKeys } from "./repo/event.js"
1+
import type { PrEvent } from "./pr/event.ts"
2+
import { prEventKeys } from "./pr/event.ts"
3+
import type { ProjectEvent } from "./project/event.ts"
4+
import { projectEventKeys } from "./project/event.ts"
5+
import type { RepoEvent } from "./repo/event.ts"
6+
import { repoEventKeys } from "./repo/event.ts"
77

88
/**
99
* When you have a webhook with an event, Bitbucket Data Center sends the event

src/server/webhooks/events/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from "./event.js"
2-
export * as pr from "./pr/index.js"
3-
export * as project from "./project/index.js"
4-
export * as repo from "./repo/index.js"
5-
export * from "./suggestion_state.js"
1+
export * from "./event.ts"
2+
export * as pr from "./pr/index.ts"
3+
export * as project from "./project/index.ts"
4+
export * as repo from "./repo/index.ts"
5+
export * from "./suggestion_state.ts"

src/server/webhooks/events/pr/comment_added.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {
66
SchemaPullRequestParticipant,
77
SchemaRepository,
88
SchemaRestMinimalRef,
9-
} from "../../../openapi/openapi-typescript.js"
10-
import type { SuggestionState } from "../suggestion_state.js"
9+
} from "../../../openapi/openapi-typescript.ts"
10+
import type { SuggestionState } from "../suggestion_state.ts"
1111

1212
export interface Actor {
1313
readonly active: boolean

src/server/webhooks/events/pr/comment_deleted.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {
22
SchemaPullRequest,
33
SchemaRepository,
4-
} from "../../../openapi/openapi-typescript.js"
4+
} from "../../../openapi/openapi-typescript.ts"
55

66
export interface Actor {
77
readonly active: boolean

0 commit comments

Comments
 (0)