Separate GitHub repo into owner and repo, to match official SDK/API

This commit is contained in:
Matt Aitken
2023-06-22 10:38:53 +01:00
parent 939f33e791
commit 4ef76f72dc
4 changed files with 46 additions and 20 deletions
+4 -1
View File
@@ -441,6 +441,7 @@ type CreateRepoTriggerReturnType = <
TEventSpecification extends GitHubEvents
>(args: {
event: TEventSpecification;
owner: string;
repo: string;
}) => ExternalSourceTrigger<
TEventSpecification,
@@ -452,14 +453,16 @@ function createRepoTrigger(
): CreateRepoTriggerReturnType {
return <TEventSpecification extends GitHubEvents>({
event,
owner,
repo,
}: {
event: TEventSpecification;
owner: string;
repo: string;
}) => {
return new ExternalSourceTrigger({
event,
params: { repo },
params: { owner, repo },
source,
});
};
+14 -5
View File
@@ -33,25 +33,30 @@ export function createRepoEventSource(
integration: TriggerIntegration<IntegrationClient<Octokit, typeof tasks>>
): ExternalSource<
TriggerIntegration<IntegrationClient<Octokit, typeof tasks>>,
{ repo: string },
{ owner: string; repo: string },
"HTTP"
> {
return new ExternalSource("HTTP", {
id: "github.repo",
version: "0.1.1",
schema: z.object({ repo: z.string() }),
schema: z.object({ owner: z.string(), repo: z.string() }),
integration,
key: (params) => params.repo,
key: (params) => `${params.owner}/${params.repo}`,
properties: (params) => [
{
label: "Owner",
text: params.owner,
url: `https://github.com/${params.owner}`,
},
{
label: "Repo",
text: params.repo,
url: `https://github.com/${params.repo}`,
url: `https://github.com/${params.owner}/${params.repo}`,
},
],
filter: (params) => ({
repository: {
full_name: [params.repo],
full_name: [`${params.owner}/${params.repo}`],
},
}),
handler: webhookHandler,
@@ -64,6 +69,7 @@ export function createRepoEventSource(
const newWebhookData = await io.integration.updateWebhook(
"update-webhook",
{
owner: params.owner,
repo: params.repo,
hookId: httpSource.data.id,
url: httpSource.url,
@@ -82,6 +88,7 @@ export function createRepoEventSource(
}
const webhooks = await io.integration.listWebhooks("list-webhooks", {
owner: params.owner,
repo: params.repo,
});
@@ -94,6 +101,7 @@ export function createRepoEventSource(
const updatedWebhook = await io.integration.updateWebhook(
"update-webhook",
{
owner: params.owner,
repo: params.repo,
hookId: existingWebhook.id,
url: httpSource.url,
@@ -109,6 +117,7 @@ export function createRepoEventSource(
}
const webhook = await io.integration.createWebhook("create-webhook", {
owner: params.owner,
repo: params.repo,
events,
url: httpSource.url,