repo-sdk 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -148,7 +148,7 @@ It reports every capability enabled by default, and a second options argument si
148
148
 
149
149
  ## Errors
150
150
 
151
- Every failure is a `RepoError` with a closed `code` union: `unauthorized`, `forbidden`, `not_found`, `rate_limited`, `validation`, `unsupported`, `provider_error`, `network_error`.
151
+ Every failure is a `RepoError` with a closed `code` union: `unauthorized`, `forbidden`, `not_found`, `rate_limited`, `validation`, `unsupported`, `provider_error`, `invalid_response`, `network_error`.
152
152
 
153
153
  ```ts
154
154
  import { RepoError } from 'repo-sdk';
@@ -1,6 +1,6 @@
1
1
  import { t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { a as isRecord, i as filenameFromContentDisposition, l as decodeCursor, n as commitWebUrlBuilder, s as toCloneUrl, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  import { a as headShaOrUndefined, n as timingSafeEqual, r as toIncomingWebhook } from "./verify-BBMVxz8q.js";
5
5
  //#region src/providers/azure-devops/auth.ts
6
6
  /**
package/dist/bitbucket.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { a as isRecord, c as assertSameOriginUrl, i as filenameFromContentDisposition, l as decodeCursor, n as commitWebUrlBuilder, s as toCloneUrl, t as clampPerPage, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  import { a as headShaOrUndefined, i as verifyHmacSignature, r as toIncomingWebhook } from "./verify-BBMVxz8q.js";
5
5
  //#region src/providers/bitbucket/index.ts
6
6
  const BASE_URL = "https://api.bitbucket.org/2.0";
package/dist/git-http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { f as stringToBase64, l as decodeCursor, s as toCloneUrl, t as clampPerPage, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  //#region src/providers/git-http/index.ts
5
5
  const CAPABILITIES = {
6
6
  userProfile: false,
package/dist/gitea.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { a as isRecord, c as assertSameOriginUrl, i as filenameFromContentDisposition, l as decodeCursor, n as commitWebUrlBuilder, o as parseLinkNext, r as encodeRefPath, s as toCloneUrl, t as clampPerPage, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  import { a as headShaOrUndefined, n as timingSafeEqual, r as toIncomingWebhook, t as hmacSha256Hex } from "./verify-BBMVxz8q.js";
5
5
  //#region src/providers/gitea/index.ts
6
6
  const DEFAULT_BASE_URL = "https://gitea.com/api/v1";
package/dist/github.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as codeFromStatus, t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { a as isRecord, c as assertSameOriginUrl, d as bytesToBase64Url, i as filenameFromContentDisposition, l as decodeCursor, n as commitWebUrlBuilder, o as parseLinkNext, r as encodeRefPath, s as toCloneUrl, t as clampPerPage, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  import { a as headShaOrUndefined, i as verifyHmacSignature, r as toIncomingWebhook } from "./verify-BBMVxz8q.js";
5
5
  //#region src/providers/github/app-auth.ts
6
6
  const RSA_ALGORITHM_IDENTIFIER = [
package/dist/gitlab.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as RepoError } from "./errors-Cxq_CqYv.js";
2
2
  import { a as isRecord, c as assertSameOriginUrl, i as filenameFromContentDisposition, l as decodeCursor, n as commitWebUrlBuilder, o as parseLinkNext, s as toCloneUrl, t as clampPerPage, u as encodeCursor } from "./shared-C6m-C4My.js";
3
- import { t as HttpClient } from "./http-BcC1vIan.js";
3
+ import { t as HttpClient } from "./http-DOXOhL_I.js";
4
4
  import { a as headShaOrUndefined, n as timingSafeEqual, r as toIncomingWebhook } from "./verify-BBMVxz8q.js";
5
5
  //#region src/providers/gitlab/index.ts
6
6
  const DEFAULT_BASE_URL = "https://gitlab.com/api/v4";
@@ -50,10 +50,26 @@ var HttpClient = class {
50
50
  }
51
51
  async json(path, options = {}) {
52
52
  const response = await this.raw(path, options);
53
- return {
54
- data: response.status === 204 ? void 0 : await response.json(),
53
+ if (response.status === 204) return {
54
+ data: void 0,
55
55
  response
56
56
  };
57
+ const text = await response.text();
58
+ try {
59
+ return {
60
+ data: JSON.parse(text),
61
+ response
62
+ };
63
+ } catch (error) {
64
+ const url = this.buildUrl(path, options.query);
65
+ throw new RepoError(`${this.options.provider} returned a non-JSON response from ${url.origin}${url.pathname}`, {
66
+ code: "invalid_response",
67
+ provider: this.options.provider,
68
+ status: response.status,
69
+ cause: error,
70
+ secrets: this.options.secrets?.() ?? []
71
+ });
72
+ }
57
73
  }
58
74
  async toError(response) {
59
75
  const text = await response.text().catch(() => "");
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ interface DetectWebhookProviderInput {
74
74
  declare function detectWebhookProvider(input: Request | DetectWebhookProviderInput): Promise<ProviderName | undefined>;
75
75
  //#endregion
76
76
  //#region src/errors.d.ts
77
- type RepoErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'rate_limited' | 'validation' | 'unsupported' | 'provider_error' | 'network_error';
77
+ type RepoErrorCode = 'unauthorized' | 'forbidden' | 'not_found' | 'rate_limited' | 'validation' | 'unsupported' | 'provider_error' | 'invalid_response' | 'network_error';
78
78
  interface RepoErrorOptions {
79
79
  code: RepoErrorCode;
80
80
  provider: ProviderName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Unified TypeScript SDK for git providers — GitHub, GitLab, Bitbucket, Azure DevOps, Gitea",
5
5
  "license": "MIT",
6
6
  "author": "Robin Genz <mail@robingenz.dev>",