Skip to content

Commit

Permalink
🏷️ Export discriminated interfaces for SchemaRestPullRequestActivity (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NatoBoram authored Oct 21, 2024
1 parent 4480cc6 commit e7b790c
Show file tree
Hide file tree
Showing 55 changed files with 214 additions and 156 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"ts-autofix": "^1.0.0",
"tsx": "^4.19.1",
"typedoc": "^0.26.10",
"typescript": "^5.6.3",
"typescript": "5.7.0-beta",
"typescript-eslint": "^8.10.0",
"vitest": "^2.1.3"
},
Expand All @@ -78,9 +78,17 @@
"types": "./dist/cloud/index.d.ts",
"default": "./dist/cloud/index.js"
},
"./cloud/openapi": {
"types": "./dist/cloud/openapi/index.d.ts",
"default": "./dist/cloud/openapi/index.js"
},
"./server": {
"types": "./dist/server/index.d.ts",
"default": "./dist/server/index.js"
},
"./server/openapi": {
"types": "./dist/server/openapi/index.d.ts",
"default": "./dist/server/openapi/index.js"
}
},
"types": "dist/index.d.ts",
Expand Down
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/base64.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "vitest"
import { fromBase64, toBase64 } from "./base64.js"
import { fromBase64, toBase64 } from "./base64.ts"

test("toBase64", ({ expect }) => {
const based = toBase64("Copyright © 2024 CodeRabbit")
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "vitest"
import { createBitbucketCloudClient } from "./client.js"
import { createBitbucketCloudClient } from "./client.ts"

test("createBitbucketCloudClient", ({ expect }) => {
const client = createBitbucketCloudClient()
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Client, ClientOptions } from "openapi-fetch"
import createClient from "openapi-fetch"
import type { paths } from "./openapi/index.js"
import type { paths } from "./openapi/index.ts"

/**
* Creates an `openapi-fetch` client using {@link createClient}.
Expand Down
4 changes: 2 additions & 2 deletions src/cloud/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./client.js"
export type * from "./openapi/index.js"
export * from "./client.ts"
export type * as OpenApi from "./openapi/index.ts"
2 changes: 1 addition & 1 deletion src/cloud/openapi/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type * from "./openapi-typescript.js"
export type * from "./openapi-typescript.ts"
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "vitest"
import * as index from "./index.js"
import * as index from "./index.ts"

test("index", ({ expect }) => {
expect(index).toBeDefined()
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./base64.js"
export * as cloud from "./cloud/index.js"
export * as server from "./server/index.js"
export * from "./base64.ts"
export * as BitbucketCloud from "./cloud/index.ts"
export * as BitbucketServer from "./server/index.ts"
2 changes: 1 addition & 1 deletion src/server/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "vitest"
import { createBitbucketServerClient } from "./client.js"
import { createBitbucketServerClient } from "./client.ts"

test("createBitbucketServerClient", ({ expect }) => {
const client = createBitbucketServerClient()
Expand Down
2 changes: 1 addition & 1 deletion src/server/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Client, ClientOptions } from "openapi-fetch"
import createClient from "openapi-fetch"
import type { paths } from "./openapi/index.js"
import type { paths } from "./openapi/index.ts"

/**
* Creates an `openapi-fetch` client using {@link createClient}.
Expand Down
7 changes: 4 additions & 3 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./client.js"
export type * from "./openapi/index.js"
export * from "./webhooks/index.js"
export * from "./client.ts"
export * from "./interfaces/index.ts"
export type * as OpenApi from "./openapi/index.ts"
export * from "./webhooks/index.ts"
1 change: 1 addition & 0 deletions src/server/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./schema_rest_pull_request_activity.ts"
47 changes: 47 additions & 0 deletions src/server/interfaces/schema_rest_pull_request_activity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type {
SchemaRestComment,
SchemaRestPullRequestActivity as SchemaRestPullRequestActivityBase,
} from "../openapi/index.ts"

export type SchemaRestPullRequestActivity =
| SchemaRestPullRequestActivityCommented
| SchemaRestPullRequestActivityOpened
| SchemaRestPullRequestActivityUpdated
type User = SchemaRestPullRequestActivityBase["user"]

export interface SchemaRestPullRequestActivityCommented
extends SchemaRestPullRequestActivityBase {
readonly action: "COMMENTED"
readonly comment?: SchemaRestComment
readonly commentAnchor?: SchemaRestComment["anchor"]
}

export interface SchemaRestPullRequestActivityOpened
extends SchemaRestPullRequestActivityBase {
readonly action: "OPENED"
}

export interface SchemaRestPullRequestActivityUpdated
extends SchemaRestPullRequestActivityBase {
readonly action: "UPDATED"
readonly addedReviewers: User[]
readonly removedReviewers: User[]
}

export function isSchemaRestPullRequestActivityCommented(
activity: SchemaRestPullRequestActivity,
): activity is SchemaRestPullRequestActivityCommented {
return activity.action === "COMMENTED"
}

export function isSchemaRestPullRequestActivityOpened(
activity: SchemaRestPullRequestActivity,
): activity is SchemaRestPullRequestActivityOpened {
return activity.action === "OPENED"
}

export function isSchemaRestPullRequestActivityUpdated(
activity: SchemaRestPullRequestActivity,
): activity is SchemaRestPullRequestActivityUpdated {
return activity.action === "UPDATED"
}
2 changes: 1 addition & 1 deletion src/server/openapi/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type * from "./openapi-typescript.js"
export type * from "./openapi-typescript.ts"
12 changes: 6 additions & 6 deletions src/server/webhooks/events/event.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PrEvent } from "./pr/event.js"
import { prEventKeys } from "./pr/event.js"
import type { ProjectEvent } from "./project/event.js"
import { projectEventKeys } from "./project/event.js"
import type { RepoEvent } from "./repo/event.js"
import { repoEventKeys } from "./repo/event.js"
import type { PrEvent } from "./pr/event.ts"
import { prEventKeys } from "./pr/event.ts"
import type { ProjectEvent } from "./project/event.ts"
import { projectEventKeys } from "./project/event.ts"
import type { RepoEvent } from "./repo/event.ts"
import { repoEventKeys } from "./repo/event.ts"

/**
* When you have a webhook with an event, Bitbucket Data Center sends the event
Expand Down
10 changes: 5 additions & 5 deletions src/server/webhooks/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./event.js"
export * as pr from "./pr/index.js"
export * as project from "./project/index.js"
export * as repo from "./repo/index.js"
export * from "./suggestion_state.js"
export * from "./event.ts"
export * as pr from "./pr/index.ts"
export * as project from "./project/index.ts"
export * as repo from "./repo/index.ts"
export * from "./suggestion_state.ts"
4 changes: 2 additions & 2 deletions src/server/webhooks/events/pr/comment_added.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type {
SchemaPullRequestParticipant,
SchemaRepository,
SchemaRestMinimalRef,
} from "../../../openapi/openapi-typescript.js"
import type { SuggestionState } from "../suggestion_state.js"
} from "../../../openapi/openapi-typescript.ts"
import type { SuggestionState } from "../suggestion_state.ts"

export interface Actor {
readonly active: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/server/webhooks/events/pr/comment_deleted.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
SchemaPullRequest,
SchemaRepository,
} from "../../../openapi/openapi-typescript.js"
} from "../../../openapi/openapi-typescript.ts"

export interface Actor {
readonly active: boolean
Expand Down
Loading

0 comments on commit e7b790c

Please sign in to comment.