MCPcopy Create free account
hub / github.com/cli/cli / subscriptions

Method subscriptions

evals/src/suites/events/github.ts:54–83  ·  view source on GitHub ↗

Lists every active subscription of the caller, following pagination links.

()

Source from the content-addressed store, hash-verified

52
53 /** Lists every active subscription of the caller, following pagination links. */
54 async subscriptions(): Promise<Subscription[]> {
55 const all: Subscription[] = [];
56 let path: string | undefined = "/event-subscriptions?per_page=100";
57 for (let pages = 0; path; pages++) {
58 // The API lists at most twice an owner's limit, so this many pages means the links are looping.
59 if (pages >= 10) throw new Error("Event subscription listing did not end");
60 if (!/^\/event-subscriptions\?/.test(path)) throw new Error("Unexpected event subscription pagination link");
61 const page: { body: unknown; next?: string } = await this.page<unknown>("GET", path);
62 const body = record(page.body);
63 if (!Array.isArray(body.subscriptions) || body.subscriptions.length > 100) {
64 throw new Error("Invalid event subscription listing");
65 }
66 all.push(...body.subscriptions.map(value => {
67 const subscription = record(value);
68 if (typeof subscription.id !== "string" || !/^sub_[A-Za-z0-9]+$/.test(subscription.id)
69 || typeof subscription.resource_url !== "string"
70 || !Array.isArray(subscription.event_types)
71 || !subscription.event_types.every(type => typeof type === "string")) {
72 throw new Error("Invalid event subscription listing");
73 }
74 return {
75 id: subscription.id,
76 resource_url: subscription.resource_url,
77 event_types: subscription.event_types,
78 };
79 }));
80 path = page.next;
81 }
82 return all;
83 }
84
85 greeting(repo: string, ref: string): Promise<string> {
86 return this.fileContent(repo, "greeting.txt", ref);

Callers 5

startFunction · 0.95
github.test.tsFile · 0.80
harness.test.tsFile · 0.80
captureSnapshotFunction · 0.80
cleanupFunction · 0.80

Calls 2

pushMethod · 0.80
recordFunction · 0.50

Tested by

no test coverage detected