@theholocron/github-client 1.58.0-alpha.57 → 1.58.0-alpha.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1097,6 +1097,19 @@ export declare function listAppDeliveries(creds: GitHubAppCredentials, opts?: Li
1097
1097
  * sends it asynchronously, so this says only that it was accepted.
1098
1098
  */
1099
1099
  export declare function redeliverAppDelivery(creds: GitHubAppCredentials, deliveryId: number, opts?: Pick<GitHubClientOptions, "baseUrl" | "fetch">): Promise<void>;
1100
+ /**
1101
+ * The installation of the App this JWT identifies on one repository (`GET /repos/{repo}/installation`), or `undefined`
1102
+ * when the App is not installed there (404). A caller with no webhook to read the installation id from (a scheduled
1103
+ * job) finds it here before it asks for an installation token. Needs only the App's own JWT.
1104
+ *
1105
+ * `repo` must be exactly `owner/name`: anything else (extra segments, an empty segment, `.` or `..`) throws before a
1106
+ * request is made, and each segment is URL-encoded, so a malformed value can never reach another route.
1107
+ *
1108
+ * https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
1109
+ *
1110
+ * @throws Error when `repo` is not `owner/name`.
1111
+ */
1112
+ export declare function getRepoInstallation(creds: GitHubAppCredentials, repo: string, opts?: Pick<GitHubClientOptions, "baseUrl" | "fetch">): Promise<GitHubAppInstallation | undefined>;
1100
1113
  /**
1101
1114
  * GitHub's own webhook mechanics — signature verification and header/
1102
1115
  * payload shapes. Pure functions, no REST call, no auth token: these
package/dist/index.mjs CHANGED
@@ -1264,6 +1264,37 @@ async function listAppDeliveries(creds, opts = {}) {
1264
1264
  async function redeliverAppDelivery(creds, deliveryId, opts = {}) {
1265
1265
  await appFetch(creds, `/app/hook/deliveries/${deliveryId}/attempts`, opts, "POST");
1266
1266
  }
1267
+ /**
1268
+ * The installation of the App this JWT identifies on one repository (`GET /repos/{repo}/installation`), or `undefined`
1269
+ * when the App is not installed there (404). A caller with no webhook to read the installation id from (a scheduled
1270
+ * job) finds it here before it asks for an installation token. Needs only the App's own JWT.
1271
+ *
1272
+ * `repo` must be exactly `owner/name`: anything else (extra segments, an empty segment, `.` or `..`) throws before a
1273
+ * request is made, and each segment is URL-encoded, so a malformed value can never reach another route.
1274
+ *
1275
+ * https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
1276
+ *
1277
+ * @throws Error when `repo` is not `owner/name`.
1278
+ */
1279
+ async function getRepoInstallation(creds, repo, opts = {}) {
1280
+ const parts = repo.split("/");
1281
+ if (parts.length !== 2 || parts.some((p) => p === "" || p === "." || p === "..")) throw new Error(`a repository is "owner/name", not "${repo}"`);
1282
+ const [owner, name] = parts.map(encodeURIComponent);
1283
+ let raw;
1284
+ try {
1285
+ raw = await appGet(creds, `/repos/${owner}/${name}/installation`, opts);
1286
+ } catch (err) {
1287
+ if (err instanceof ProviderApiError && err.status === 404) return void 0;
1288
+ throw err;
1289
+ }
1290
+ return {
1291
+ id: Number(raw.id),
1292
+ account: account(raw.account),
1293
+ permissions: raw.permissions ?? {},
1294
+ events: raw.events ?? [],
1295
+ suspended: typeof raw.suspended_at === "string"
1296
+ };
1297
+ }
1267
1298
  // src/webhooks/webhooks.ts
1268
1299
  /**
1269
1300
  * GitHub's own webhook mechanics — signature verification and header/
@@ -1341,4 +1372,4 @@ function createGitHubClient(opts) {
1341
1372
  workflows: workflows(rest)
1342
1373
  };
1343
1374
  }
1344
- export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getApp, getInstallationAccessToken, listAppDeliveries, listAppInstallations, parseGitHubWebhookHeaders, parseTokenExpiration, redeliverAppDelivery, suspendAppInstallation, unsuspendAppInstallation, verifyGitHubWebhookSignature };
1375
+ export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getApp, getInstallationAccessToken, getRepoInstallation, listAppDeliveries, listAppInstallations, parseGitHubWebhookHeaders, parseTokenExpiration, redeliverAppDelivery, suspendAppInstallation, unsuspendAppInstallation, verifyGitHubWebhookSignature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/github-client",
3
- "version": "1.58.0-alpha.57",
3
+ "version": "1.58.0-alpha.58",
4
4
  "description": "A TypeScript client for the GitHub REST API",
5
5
  "keywords": [
6
6
  "github",
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@theholocron/http-client": "^1.58.0-alpha.57",
35
+ "@theholocron/http-client": "^1.58.0-alpha.58",
36
36
  "@theholocron/observability": "^0.7.0-alpha.7"
37
37
  },
38
38
  "devDependencies": {
@@ -45,10 +45,10 @@
45
45
  "tsdown": "^0.23.7",
46
46
  "typescript": "^6.0.3",
47
47
  "vitest": "^5.1.0",
48
- "@theholocron/tsdown-config": "^8.9.0-alpha.22",
49
- "@theholocron/vitest-config": "^8.9.0-alpha.22",
48
+ "@theholocron/eslint-config": "^8.9.0-alpha.22",
50
49
  "@theholocron/tsconfig": "^8.9.0-alpha.22",
51
- "@theholocron/eslint-config": "^8.9.0-alpha.22"
50
+ "@theholocron/tsdown-config": "^8.9.0-alpha.22",
51
+ "@theholocron/vitest-config": "^8.9.0-alpha.22"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22.0.0"