renovate 40.0.0-next.2 → 40.0.0-next.21
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/config/decrypt/legacy.js +0 -1
- package/dist/config/decrypt/legacy.js.map +1 -1
- package/dist/config/decrypt.d.ts +3 -1
- package/dist/config/decrypt.js +56 -13
- package/dist/config/decrypt.js.map +1 -1
- package/dist/config/migrate-validate.js +3 -2
- package/dist/config/migrate-validate.js.map +1 -1
- package/dist/config/migration.js +2 -1
- package/dist/config/migration.js.map +1 -1
- package/dist/config/migrations/custom/rebase-stale-prs-migration.js +1 -1
- package/dist/config/migrations/custom/rebase-stale-prs-migration.js.map +1 -1
- package/dist/config/options/index.js +3 -3
- package/dist/config/options/index.js.map +1 -1
- package/dist/config/parse.js +2 -2
- package/dist/config/parse.js.map +1 -1
- package/dist/config/presets/gitea/index.js +0 -1
- package/dist/config/presets/gitea/index.js.map +1 -1
- package/dist/config/presets/github/index.js +0 -1
- package/dist/config/presets/github/index.js.map +1 -1
- package/dist/config/presets/gitlab/index.js +1 -1
- package/dist/config/presets/gitlab/index.js.map +1 -1
- package/dist/config/presets/http/index.js +1 -2
- package/dist/config/presets/http/index.js.map +1 -1
- package/dist/config/presets/index.js +0 -7
- package/dist/config/presets/index.js.map +1 -1
- package/dist/config/presets/internal/custom-managers.js +3 -4
- package/dist/config/presets/internal/custom-managers.js.map +1 -1
- package/dist/config/presets/internal/index.js +1 -3
- package/dist/config/presets/internal/index.js.map +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/validation.js +3 -5
- package/dist/config/validation.js.map +1 -1
- package/dist/config-validator.js +0 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/constants/category.js +0 -1
- package/dist/constants/category.js.map +1 -1
- package/dist/data/monorepo.json +2 -1
- package/dist/instrumentation/index.js +5 -3
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation/utils.js +1 -1
- package/dist/instrumentation/utils.js.map +1 -1
- package/dist/logger/cmd-serializer.js +0 -1
- package/dist/logger/cmd-serializer.js.map +1 -1
- package/dist/logger/config-serializer.js +0 -1
- package/dist/logger/config-serializer.js.map +1 -1
- package/dist/logger/index.js +0 -3
- package/dist/logger/index.js.map +1 -1
- package/dist/logger/once.js +4 -2
- package/dist/logger/once.js.map +1 -1
- package/dist/logger/pretty-stdout.js +0 -1
- package/dist/logger/pretty-stdout.js.map +1 -1
- package/dist/logger/renovate-logger.js +1 -1
- package/dist/logger/renovate-logger.js.map +1 -1
- package/dist/logger/utils.js +6 -11
- package/dist/logger/utils.js.map +1 -1
- package/dist/modules/datasource/artifactory/index.js +1 -1
- package/dist/modules/datasource/artifactory/index.js.map +1 -1
- package/dist/modules/datasource/azure-pipelines-tasks/index.js +11 -1
- package/dist/modules/datasource/azure-pipelines-tasks/index.js.map +1 -1
- package/dist/modules/datasource/azure-pipelines-tasks/schema.d.ts +16 -0
- package/dist/modules/datasource/azure-pipelines-tasks/schema.js +2 -0
- package/dist/modules/datasource/azure-pipelines-tasks/schema.js.map +1 -1
- package/dist/modules/datasource/crate/index.js +1 -1
- package/dist/modules/datasource/crate/index.js.map +1 -1
- package/dist/modules/datasource/custom/formats/html.js +1 -1
- package/dist/modules/datasource/custom/formats/html.js.map +1 -1
- package/dist/modules/datasource/custom/formats/yaml.js +1 -1
- package/dist/modules/datasource/custom/formats/yaml.js.map +1 -1
- package/dist/modules/datasource/custom/schema.d.ts +5 -5
- package/dist/modules/datasource/deb/index.js +1 -1
- package/dist/modules/datasource/deb/index.js.map +1 -1
- package/dist/modules/datasource/deno/schema.d.ts +8 -8
- package/dist/modules/datasource/docker/common.js +1 -1
- package/dist/modules/datasource/docker/common.js.map +1 -1
- package/dist/modules/datasource/docker/index.js +5 -3
- package/dist/modules/datasource/docker/index.js.map +1 -1
- package/dist/modules/datasource/docker/schema.d.ts +32 -32
- package/dist/modules/datasource/galaxy/schema.d.ts +1 -1
- package/dist/modules/datasource/galaxy-collection/schema.d.ts +3 -3
- package/dist/modules/datasource/gitea-releases/schema.d.ts +4 -4
- package/dist/modules/datasource/gitea-tags/schema.d.ts +4 -4
- package/dist/modules/datasource/github-release-attachments/index.js +2 -2
- package/dist/modules/datasource/github-release-attachments/index.js.map +1 -1
- package/dist/modules/datasource/go/base.js +1 -1
- package/dist/modules/datasource/go/base.js.map +1 -1
- package/dist/modules/datasource/go/releases-goproxy.js +1 -1
- package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
- package/dist/modules/datasource/golang-version/index.js +1 -1
- package/dist/modules/datasource/golang-version/index.js.map +1 -1
- package/dist/modules/datasource/hex/schema.d.ts +11 -11
- package/dist/modules/datasource/hexpm-bob/index.js +1 -1
- package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
- package/dist/modules/datasource/index.js +2 -2
- package/dist/modules/datasource/index.js.map +1 -1
- package/dist/modules/datasource/maven/util.js +1 -1
- package/dist/modules/datasource/maven/util.js.map +1 -1
- package/dist/modules/datasource/nuget/v2.js +1 -1
- package/dist/modules/datasource/nuget/v2.js.map +1 -1
- package/dist/modules/datasource/nuget/v3.js +1 -1
- package/dist/modules/datasource/nuget/v3.js.map +1 -1
- package/dist/modules/datasource/packagist/schema.d.ts +30 -30
- package/dist/modules/datasource/pod/index.js +1 -1
- package/dist/modules/datasource/pod/index.js.map +1 -1
- package/dist/modules/datasource/pypi/index.js +1 -1
- package/dist/modules/datasource/pypi/index.js.map +1 -1
- package/dist/modules/datasource/ruby-version/index.js +1 -1
- package/dist/modules/datasource/ruby-version/index.js.map +1 -1
- package/dist/modules/datasource/rubygems/index.js +1 -1
- package/dist/modules/datasource/rubygems/index.js.map +1 -1
- package/dist/modules/datasource/rubygems/versions-endpoint-cache.js +2 -2
- package/dist/modules/datasource/rubygems/versions-endpoint-cache.js.map +1 -1
- package/dist/modules/datasource/terraform-provider/index.js +1 -1
- package/dist/modules/datasource/terraform-provider/index.js.map +1 -1
- package/dist/modules/datasource/unity3d/index.d.ts +4 -1
- package/dist/modules/datasource/unity3d/index.js +36 -42
- package/dist/modules/datasource/unity3d/index.js.map +1 -1
- package/dist/modules/datasource/unity3d/schema.d.ts +47 -0
- package/dist/modules/datasource/unity3d/schema.js +17 -0
- package/dist/modules/datasource/unity3d/schema.js.map +1 -0
- package/dist/modules/manager/argocd/schema.d.ts +10 -10
- package/dist/modules/manager/azure-pipelines/schema.d.ts +10 -10
- package/dist/modules/manager/batect/schema.d.ts +6 -6
- package/dist/modules/manager/batect-wrapper/artifacts.js +1 -1
- package/dist/modules/manager/batect-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/bazel/rules/docker.d.ts +9 -9
- package/dist/modules/manager/bazel/rules/git.d.ts +10 -10
- package/dist/modules/manager/bazel/rules/git.js +7 -1
- package/dist/modules/manager/bazel/rules/git.js.map +1 -1
- package/dist/modules/manager/bazel/rules/go.d.ts +5 -5
- package/dist/modules/manager/bazel/rules/oci.d.ts +3 -3
- package/dist/modules/manager/bazel-module/parser/fragments.d.ts +40 -40
- package/dist/modules/manager/bazel-module/parser/maven.d.ts +27 -27
- package/dist/modules/manager/bazel-module/parser/oci.d.ts +17 -17
- package/dist/modules/manager/bazel-module/rules.d.ts +40 -40
- package/dist/modules/manager/bundler/artifacts.js.map +1 -1
- package/dist/modules/manager/cargo/schema.d.ts +100 -100
- package/dist/modules/manager/circleci/schema.d.ts +6 -6
- package/dist/modules/manager/composer/schema.d.ts +40 -40
- package/dist/modules/manager/composer/utils.js +9 -6
- package/dist/modules/manager/composer/utils.js.map +1 -1
- package/dist/modules/manager/crossplane/schema.d.ts +2 -2
- package/dist/modules/manager/custom/jsonata/index.js +4 -0
- package/dist/modules/manager/custom/jsonata/index.js.map +1 -1
- package/dist/modules/manager/custom/jsonata/schema.d.ts +7 -7
- package/dist/modules/manager/devbox/artifacts.d.ts +1 -1
- package/dist/modules/manager/devbox/artifacts.js +29 -11
- package/dist/modules/manager/devbox/artifacts.js.map +1 -1
- package/dist/modules/manager/fingerprint.generated.js +68 -68
- package/dist/modules/manager/fingerprint.generated.js.map +1 -1
- package/dist/modules/manager/fleet/schema.d.ts +12 -12
- package/dist/modules/manager/flux/schema.d.ts +50 -50
- package/dist/modules/manager/glasskube/schema.d.ts +8 -8
- package/dist/modules/manager/gradle-wrapper/artifacts.js +1 -1
- package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/maven/extract.js +3 -1
- package/dist/modules/manager/maven/extract.js.map +1 -1
- package/dist/modules/manager/mise/extract.js +1 -1
- package/dist/modules/manager/mise/extract.js.map +1 -1
- package/dist/modules/manager/nix/schema.d.ts +24 -24
- package/dist/modules/manager/npm/schema.d.ts +13 -13
- package/dist/modules/manager/nuget/schema.d.ts +8 -8
- package/dist/modules/manager/ocb/schema.d.ts +6 -6
- package/dist/modules/manager/pep621/schema.d.ts +55 -55
- package/dist/modules/manager/pep621/utils.js +1 -1
- package/dist/modules/manager/pep621/utils.js.map +1 -1
- package/dist/modules/manager/poetry/artifacts.js +3 -3
- package/dist/modules/manager/poetry/artifacts.js.map +1 -1
- package/dist/modules/manager/poetry/extract.js +2 -1
- package/dist/modules/manager/poetry/extract.js.map +1 -1
- package/dist/modules/manager/poetry/schema.d.ts +48 -48
- package/dist/modules/manager/sveltos/schema.d.ts +12 -12
- package/dist/modules/manager/terraform/lockfile/hash.d.ts +1 -1
- package/dist/modules/manager/vendir/schema.d.ts +27 -27
- package/dist/modules/platform/api.d.ts +1 -1
- package/dist/modules/platform/bitbucket/index.d.ts +1 -0
- package/dist/modules/platform/bitbucket/index.js +6 -1
- package/dist/modules/platform/bitbucket/index.js.map +1 -1
- package/dist/modules/platform/bitbucket/schema.d.ts +17 -17
- package/dist/modules/platform/bitbucket-server/index.d.ts +1 -1
- package/dist/modules/platform/bitbucket-server/index.js +13 -11
- package/dist/modules/platform/bitbucket-server/index.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/schema.d.ts +75 -0
- package/dist/modules/platform/bitbucket-server/schema.js +14 -1
- package/dist/modules/platform/bitbucket-server/schema.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/types.d.ts +2 -1
- package/dist/modules/platform/bitbucket-server/types.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/utils.d.ts +0 -2
- package/dist/modules/platform/bitbucket-server/utils.js +1 -51
- package/dist/modules/platform/bitbucket-server/utils.js.map +1 -1
- package/dist/modules/platform/gerrit/client.js +1 -1
- package/dist/modules/platform/gerrit/client.js.map +1 -1
- package/dist/modules/platform/gitea/index.d.ts +1 -0
- package/dist/modules/platform/gitea/index.js +11 -0
- package/dist/modules/platform/gitea/index.js.map +1 -1
- package/dist/modules/platform/gitea/schema.d.ts +8 -8
- package/dist/modules/platform/github/common.d.ts +2 -0
- package/dist/modules/platform/github/common.js +16 -0
- package/dist/modules/platform/github/common.js.map +1 -1
- package/dist/modules/platform/github/index.d.ts +1 -1
- package/dist/modules/platform/github/index.js +6 -4
- package/dist/modules/platform/github/index.js.map +1 -1
- package/dist/modules/platform/github/issue.d.ts +12 -12
- package/dist/modules/platform/github/schema.d.ts +65 -65
- package/dist/modules/platform/gitlab/index.d.ts +1 -0
- package/dist/modules/platform/gitlab/index.js +9 -0
- package/dist/modules/platform/gitlab/index.js.map +1 -1
- package/dist/modules/platform/scm.d.ts +1 -1
- package/dist/modules/versioning/composer/index.js +10 -0
- package/dist/modules/versioning/composer/index.js.map +1 -1
- package/dist/modules/versioning/npm/index.js +2 -1
- package/dist/modules/versioning/npm/index.js.map +1 -1
- package/dist/modules/versioning/schema.js +1 -1
- package/dist/modules/versioning/schema.js.map +1 -1
- package/dist/modules/versioning/types.d.ts +4 -0
- package/dist/modules/versioning/types.js.map +1 -1
- package/dist/proxy.js +2 -1
- package/dist/proxy.js.map +1 -1
- package/dist/renovate.js +2 -2
- package/dist/renovate.js.map +1 -1
- package/dist/util/cache/package/decorator.js +2 -2
- package/dist/util/cache/package/decorator.js.map +1 -1
- package/dist/util/cache/package/redis.js +0 -1
- package/dist/util/cache/package/redis.js.map +1 -1
- package/dist/util/cache/repository/impl/base.d.ts +1 -1
- package/dist/util/exec/containerbase.js +12 -12
- package/dist/util/exec/containerbase.js.map +1 -1
- package/dist/util/github/graphql/query-adapters/releases-query-adapter.d.ts +5 -5
- package/dist/util/http/auth.js +0 -1
- package/dist/util/http/auth.js.map +1 -1
- package/dist/util/http/bitbucket-server.d.ts +5 -4
- package/dist/util/http/bitbucket-server.js +17 -20
- package/dist/util/http/bitbucket-server.js.map +1 -1
- package/dist/util/http/bitbucket.d.ts +6 -5
- package/dist/util/http/bitbucket.js +30 -31
- package/dist/util/http/bitbucket.js.map +1 -1
- package/dist/util/http/cache/abstract-http-cache-provider.js +1 -1
- package/dist/util/http/cache/abstract-http-cache-provider.js.map +1 -1
- package/dist/util/http/cache/schema.d.ts +2 -2
- package/dist/util/http/errors.d.ts +2 -0
- package/dist/util/http/errors.js +8 -0
- package/dist/util/http/errors.js.map +1 -0
- package/dist/util/http/gerrit.d.ts +6 -4
- package/dist/util/http/gerrit.js +11 -12
- package/dist/util/http/gerrit.js.map +1 -1
- package/dist/util/http/gitea.d.ts +5 -4
- package/dist/util/http/gitea.js +12 -13
- package/dist/util/http/gitea.js.map +1 -1
- package/dist/util/http/github.d.ts +14 -8
- package/dist/util/http/github.js +64 -60
- package/dist/util/http/github.js.map +1 -1
- package/dist/util/http/gitlab.d.ts +7 -5
- package/dist/util/http/gitlab.js +56 -46
- package/dist/util/http/gitlab.js.map +1 -1
- package/dist/util/http/got.d.ts +9 -0
- package/dist/util/http/got.js +54 -0
- package/dist/util/http/got.js.map +1 -0
- package/dist/util/http/host-rules.d.ts +2 -1
- package/dist/util/http/host-rules.js.map +1 -1
- package/dist/util/http/http.d.ts +93 -0
- package/dist/util/http/http.js +339 -0
- package/dist/util/http/http.js.map +1 -0
- package/dist/util/http/index.d.ts +6 -74
- package/dist/util/http/index.js +5 -359
- package/dist/util/http/index.js.map +1 -1
- package/dist/util/http/legacy.js +4 -1
- package/dist/util/http/legacy.js.map +1 -1
- package/dist/util/http/types.d.ts +9 -16
- package/dist/util/http/types.js.map +1 -1
- package/dist/util/string.d.ts +15 -0
- package/dist/util/string.js +75 -0
- package/dist/util/string.js.map +1 -1
- package/dist/util/toml.d.ts +1 -0
- package/dist/util/toml.js +6 -0
- package/dist/util/toml.js.map +1 -1
- package/dist/util/url.js +3 -8
- package/dist/util/url.js.map +1 -1
- package/dist/util/yaml.js +2 -6
- package/dist/util/yaml.js.map +1 -1
- package/dist/workers/global/config/parse/env.js +3 -2
- package/dist/workers/global/config/parse/env.js.map +1 -1
- package/dist/workers/global/config/parse/file.js +19 -9
- package/dist/workers/global/config/parse/file.js.map +1 -1
- package/dist/workers/global/config/parse/host-rules-from-env.js +6 -2
- package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
- package/dist/workers/repository/cache.js +0 -1
- package/dist/workers/repository/cache.js.map +1 -1
- package/dist/workers/repository/onboarding/pr/config-description.js +3 -1
- package/dist/workers/repository/onboarding/pr/config-description.js.map +1 -1
- package/dist/workers/repository/update/pr/changelog/bitbucket/index.js +1 -1
- package/dist/workers/repository/update/pr/changelog/bitbucket/index.js.map +1 -1
- package/dist/workers/repository/update/pr/changelog/gitlab/index.js +1 -1
- package/dist/workers/repository/update/pr/changelog/gitlab/index.js.map +1 -1
- package/package.json +44 -49
- package/renovate-schema.json +2 -1
@@ -1,53 +1,52 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BitbucketHttp =
|
3
|
+
exports.BitbucketHttp = void 0;
|
4
|
+
exports.setBaseUrl = setBaseUrl;
|
4
5
|
const tslib_1 = require("tslib");
|
5
6
|
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
|
6
|
-
const
|
7
|
-
const url_1 = require("../url");
|
8
|
-
const _1 = require(".");
|
7
|
+
const http_1 = require("./http");
|
9
8
|
const MAX_PAGES = 100;
|
10
9
|
const MAX_PAGELEN = 100;
|
11
10
|
let baseUrl = 'https://api.bitbucket.org/';
|
12
|
-
|
11
|
+
function setBaseUrl(url) {
|
13
12
|
baseUrl = url;
|
14
|
-
}
|
15
|
-
|
16
|
-
|
13
|
+
}
|
14
|
+
class BitbucketHttp extends http_1.HttpBase {
|
15
|
+
get baseUrl() {
|
16
|
+
return baseUrl;
|
17
|
+
}
|
17
18
|
constructor(type = 'bitbucket', options) {
|
18
19
|
super(type, options);
|
19
20
|
}
|
20
|
-
async
|
21
|
-
const
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
resolvedURL.searchParams.set('pagelen', pagelen.toString());
|
21
|
+
async requestJsonUnsafe(method, options) {
|
22
|
+
const resolvedUrl = this.resolveUrl(options.url, options.httpOptions);
|
23
|
+
const opts = {
|
24
|
+
...options,
|
25
|
+
url: resolvedUrl,
|
26
|
+
};
|
27
|
+
const paginate = opts.httpOptions?.paginate;
|
28
|
+
if (paginate && !hasPagelen(resolvedUrl)) {
|
29
|
+
const pagelen = opts.httpOptions.pagelen ?? MAX_PAGELEN;
|
30
|
+
resolvedUrl.searchParams.set('pagelen', pagelen.toString());
|
31
31
|
}
|
32
|
-
const result = await super.
|
33
|
-
if (
|
32
|
+
const result = await super.requestJsonUnsafe(method, opts);
|
33
|
+
if (paginate && isPagedResult(result.body)) {
|
34
34
|
const resultBody = result.body;
|
35
|
+
let nextURL = result.body.next;
|
35
36
|
let page = 1;
|
36
|
-
|
37
|
-
|
38
|
-
const nextResult = await super.
|
37
|
+
for (; nextURL && page <= MAX_PAGES; page++) {
|
38
|
+
opts.url = nextURL;
|
39
|
+
const nextResult = await super.requestJsonUnsafe(method, opts);
|
39
40
|
resultBody.values.push(...nextResult.body.values);
|
40
|
-
nextURL = nextResult.body
|
41
|
-
page += 1;
|
41
|
+
nextURL = nextResult.body.next;
|
42
42
|
}
|
43
43
|
// Override other page-related attributes
|
44
44
|
resultBody.pagelen = resultBody.values.length;
|
45
|
+
/* v8 ignore start: hard to test all branches */
|
45
46
|
resultBody.size =
|
46
|
-
page <= MAX_PAGES
|
47
|
-
|
48
|
-
|
49
|
-
resultBody.next =
|
50
|
-
page <= MAX_PAGES ? nextURL : /* istanbul ignore next */ undefined;
|
47
|
+
page <= MAX_PAGES ? resultBody.values.length : undefined;
|
48
|
+
resultBody.next = page <= MAX_PAGES ? nextURL : undefined;
|
49
|
+
/* v8 ignore stop */
|
51
50
|
}
|
52
51
|
return result;
|
53
52
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bitbucket.js","sourceRoot":"","sources":["../../../lib/util/http/bitbucket.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"bitbucket.js","sourceRoot":"","sources":["../../../lib/util/http/bitbucket.ts"],"names":[],"mappings":";;;AAUA,gCAEC;;AAZD,kEAAkC;AAElC,iCAAkE;AAGlE,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,IAAI,OAAO,GAAG,4BAA4B,CAAC;AAE3C,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,GAAG,CAAC;AAChB,CAAC;AAOD,MAAa,aAAc,SAAQ,eAA8B;IAC/D,IAAuB,OAAO;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,YAAY,IAAI,GAAG,WAAW,EAAE,OAA8B;QAC5D,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IAEkB,KAAK,CAAC,iBAAiB,CACxC,MAAkB,EAClB,OAAwD;QAExD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACtE,MAAM,IAAI,GAAoD;YAC5D,GAAG,OAAO;YACV,GAAG,EAAE,WAAW;SACjB,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;QAE5C,IAAI,QAAQ,IAAI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B,CAAC;QAED,OAAO,MAAyB,CAAC;IACnC,CAAC;CACF;AAzDD,sCAyDC;AAED,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,CAAC,YAAE,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,aAAa,CAAI,GAAQ;IAChC,OAAO,YAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport type { PagedResult } from '../../modules/platform/bitbucket/types';\nimport { HttpBase, type InternalJsonUnsafeOptions } from './http';\nimport type { HttpMethod, HttpOptions, HttpResponse } from './types';\n\nconst MAX_PAGES = 100;\nconst MAX_PAGELEN = 100;\n\nlet baseUrl = 'https://api.bitbucket.org/';\n\nexport function setBaseUrl(url: string): void {\n baseUrl = url;\n}\n\nexport interface BitbucketHttpOptions extends HttpOptions {\n paginate?: boolean;\n pagelen?: number;\n}\n\nexport class BitbucketHttp extends HttpBase<BitbucketHttpOptions> {\n protected override get baseUrl(): string | undefined {\n return baseUrl;\n }\n\n constructor(type = 'bitbucket', options?: BitbucketHttpOptions) {\n super(type, options);\n }\n\n protected override async requestJsonUnsafe<T>(\n method: HttpMethod,\n options: InternalJsonUnsafeOptions<BitbucketHttpOptions>,\n ): Promise<HttpResponse<T>> {\n const resolvedUrl = this.resolveUrl(options.url, options.httpOptions);\n const opts: InternalJsonUnsafeOptions<BitbucketHttpOptions> = {\n ...options,\n url: resolvedUrl,\n };\n const paginate = opts.httpOptions?.paginate;\n\n if (paginate && !hasPagelen(resolvedUrl)) {\n const pagelen = opts.httpOptions!.pagelen ?? MAX_PAGELEN;\n resolvedUrl.searchParams.set('pagelen', pagelen.toString());\n }\n\n const result = await super.requestJsonUnsafe<T | PagedResult<T>>(\n method,\n opts,\n );\n\n if (paginate && isPagedResult(result.body)) {\n const resultBody = result.body;\n let nextURL = result.body.next;\n let page = 1;\n\n for (; nextURL && page <= MAX_PAGES; page++) {\n opts.url = nextURL;\n const nextResult = await super.requestJsonUnsafe<PagedResult<T>>(\n method,\n opts,\n );\n\n resultBody.values.push(...nextResult.body.values);\n nextURL = nextResult.body.next;\n }\n\n // Override other page-related attributes\n resultBody.pagelen = resultBody.values.length;\n /* v8 ignore start: hard to test all branches */\n resultBody.size =\n page <= MAX_PAGES ? resultBody.values.length : undefined;\n resultBody.next = page <= MAX_PAGES ? nextURL : undefined;\n /* v8 ignore stop */\n }\n\n return result as HttpResponse<T>;\n }\n}\n\nfunction hasPagelen(url: URL): boolean {\n return !is.nullOrUndefined(url.searchParams.get('pagelen'));\n}\n\nfunction isPagedResult<T>(obj: any): obj is PagedResult<T> {\n return is.nonEmptyObject(obj) && Array.isArray(obj.values);\n}\n"]}
|
@@ -43,7 +43,7 @@ class AbstractHttpCacheProvider {
|
|
43
43
|
httpResponse,
|
44
44
|
timestamp,
|
45
45
|
});
|
46
|
-
|
46
|
+
/* v8 ignore next 4: should never happen */
|
47
47
|
if (!newHttpCache) {
|
48
48
|
logger_1.logger.debug(`http cache: failed to persist cache for ${url}`);
|
49
49
|
return resp;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"abstract-http-cache-provider.js","sourceRoot":"","sources":["../../../../lib/util/http/cache/abstract-http-cache-provider.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,uCAA6C;AAE7C,kCAAuC;AACvC,qCAA2D;AAG3D,MAAsB,yBAAyB;IAI7C,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,SAAS,GAAG,wBAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QAED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,CAAC;CACF;AA/FD,8DA+FC","sourcesContent":["import { logger } from '../../../logger';\nimport { HttpCacheStats } from '../../stats';\nimport type { GotOptions, HttpResponse } from '../types';\nimport { copyResponse } from '../util';\nimport { type HttpCache, HttpCacheSchema } from './schema';\nimport type { HttpCacheProvider } from './types';\n\nexport abstract class AbstractHttpCacheProvider implements HttpCacheProvider {\n protected abstract load(url: string): Promise<unknown>;\n protected abstract persist(url: string, data: HttpCache): Promise<void>;\n\n async get(url: string): Promise<HttpCache | null> {\n const cache = await this.load(url);\n const httpCache = HttpCacheSchema.parse(cache);\n if (!httpCache) {\n return null;\n }\n\n return httpCache as HttpCache;\n }\n\n async setCacheHeaders<T extends Pick<GotOptions, 'headers'>>(\n url: string,\n opts: T,\n ): Promise<void> {\n const httpCache = await this.get(url);\n if (!httpCache) {\n return;\n }\n\n opts.headers ??= {};\n\n if (httpCache.etag) {\n opts.headers['If-None-Match'] = httpCache.etag;\n }\n\n if (httpCache.lastModified) {\n opts.headers['If-Modified-Since'] = httpCache.lastModified;\n }\n }\n\n bypassServer<T>(\n _url: string,\n _ignoreSoftTtl: boolean,\n ): Promise<HttpResponse<T> | null> {\n return Promise.resolve(null);\n }\n\n async wrapServerResponse<T>(\n url: string,\n resp: HttpResponse<T>,\n ): Promise<HttpResponse<T>> {\n if (resp.statusCode === 200) {\n const etag = resp.headers?.etag;\n const lastModified = resp.headers?.['last-modified'];\n\n HttpCacheStats.incRemoteMisses(url);\n\n const httpResponse = copyResponse(resp, true);\n const timestamp = new Date().toISOString();\n\n const newHttpCache = HttpCacheSchema.parse({\n etag,\n lastModified,\n httpResponse,\n timestamp,\n });\n\n /* v8 ignore next 4: should never happen */\n if (!newHttpCache) {\n logger.debug(`http cache: failed to persist cache for ${url}`);\n return resp;\n }\n\n logger.debug(\n `http cache: saving ${url} (etag=${etag}, lastModified=${lastModified})`,\n );\n await this.persist(url, newHttpCache as HttpCache);\n return resp;\n }\n\n if (resp.statusCode === 304) {\n const httpCache = await this.get(url);\n if (!httpCache) {\n return resp;\n }\n\n const timestamp = httpCache.timestamp;\n logger.debug(\n `http cache: Using cached response: ${url} from ${timestamp}`,\n );\n HttpCacheStats.incRemoteHits(url);\n const cachedResp = copyResponse(\n httpCache.httpResponse as HttpResponse<T>,\n true,\n );\n cachedResp.authorization = resp.authorization;\n return cachedResp;\n }\n\n return resp;\n }\n}\n"]}
|
@@ -6,13 +6,13 @@ export declare const HttpCacheSchema: z.ZodCatch<z.ZodNullable<z.ZodObject<{
|
|
6
6
|
timestamp: z.ZodString;
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
8
8
|
timestamp: string;
|
9
|
-
lastModified?: string | undefined;
|
10
9
|
etag?: string | undefined;
|
10
|
+
lastModified?: string | undefined;
|
11
11
|
httpResponse?: unknown;
|
12
12
|
}, {
|
13
13
|
timestamp: string;
|
14
|
-
lastModified?: string | undefined;
|
15
14
|
etag?: string | undefined;
|
15
|
+
lastModified?: string | undefined;
|
16
16
|
httpResponse?: unknown;
|
17
17
|
}>>>;
|
18
18
|
export type HttpCache = z.infer<typeof HttpCacheSchema>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.EmptyResultError = void 0;
|
4
|
+
// required for zod type safety with `Result.wrap`
|
5
|
+
class EmptyResultError extends Error {
|
6
|
+
}
|
7
|
+
exports.EmptyResultError = EmptyResultError;
|
8
|
+
//# sourceMappingURL=errors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../lib/util/http/errors.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAClD,MAAa,gBAAiB,SAAQ,KAAK;CAAG;AAA9C,4CAA8C","sourcesContent":["// required for zod type safety with `Result.wrap`\nexport class EmptyResultError extends Error {}\n"]}
|
@@ -1,12 +1,14 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import { HttpBase, type InternalHttpOptions } from './http';
|
2
|
+
import type { HttpOptions } from './types';
|
3
3
|
export declare function setBaseUrl(url: string): void;
|
4
4
|
/**
|
5
5
|
* Access Gerrit REST-API and strip-of the "magic prefix" from responses.
|
6
6
|
* @see https://gerrit-review.googlesource.com/Documentation/rest-api.html
|
7
7
|
*/
|
8
|
-
export declare class GerritHttp extends
|
8
|
+
export declare class GerritHttp extends HttpBase {
|
9
9
|
private static magicPrefix;
|
10
|
+
protected get baseUrl(): string | undefined;
|
10
11
|
constructor(options?: HttpOptions);
|
11
|
-
protected
|
12
|
+
protected resolveUrl(requestUrl: string | URL, options: HttpOptions | undefined): URL;
|
13
|
+
protected processOptions(url: URL, options: InternalHttpOptions): void;
|
12
14
|
}
|
package/dist/util/http/gerrit.js
CHANGED
@@ -5,7 +5,7 @@ exports.setBaseUrl = setBaseUrl;
|
|
5
5
|
const common_1 = require("../common");
|
6
6
|
const regex_1 = require("../regex");
|
7
7
|
const url_1 = require("../url");
|
8
|
-
const
|
8
|
+
const http_1 = require("./http");
|
9
9
|
let baseUrl;
|
10
10
|
function setBaseUrl(url) {
|
11
11
|
baseUrl = url;
|
@@ -14,21 +14,20 @@ function setBaseUrl(url) {
|
|
14
14
|
* Access Gerrit REST-API and strip-of the "magic prefix" from responses.
|
15
15
|
* @see https://gerrit-review.googlesource.com/Documentation/rest-api.html
|
16
16
|
*/
|
17
|
-
class GerritHttp extends
|
17
|
+
class GerritHttp extends http_1.HttpBase {
|
18
18
|
static magicPrefix = (0, regex_1.regEx)(/^\)]}'\n/g);
|
19
|
+
get baseUrl() {
|
20
|
+
return baseUrl;
|
21
|
+
}
|
19
22
|
constructor(options) {
|
20
23
|
super('gerrit', options);
|
21
24
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
opts.headers = {
|
29
|
-
...opts.headers,
|
30
|
-
};
|
31
|
-
return await super.request(url, opts);
|
25
|
+
resolveUrl(requestUrl, options) {
|
26
|
+
// ensure trailing slash for gerrit
|
27
|
+
return super.resolveUrl((0, url_1.isHttpUrl)(requestUrl) ? requestUrl : `${baseUrl}${requestUrl}`, options);
|
28
|
+
}
|
29
|
+
processOptions(url, options) {
|
30
|
+
options.parseJson = (text) => (0, common_1.parseJson)(text.replace(GerritHttp.magicPrefix, ''), url.pathname);
|
32
31
|
}
|
33
32
|
}
|
34
33
|
exports.GerritHttp = GerritHttp;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"gerrit.js","sourceRoot":"","sources":["../../../lib/util/http/gerrit.ts"],"names":[],"mappings":";;;AAOA,gCAEC;AATD,sCAAsC;AACtC,oCAAiC;AACjC,gCAAmC;
|
1
|
+
{"version":3,"file":"gerrit.js","sourceRoot":"","sources":["../../../lib/util/http/gerrit.ts"],"names":[],"mappings":";;;AAOA,gCAEC;AATD,sCAAsC;AACtC,oCAAiC;AACjC,gCAAmC;AACnC,iCAA4D;AAG5D,IAAI,OAAe,CAAC;AACpB,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,GAAG,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAa,UAAW,SAAQ,eAAQ;IAC9B,MAAM,CAAC,WAAW,GAAG,IAAA,aAAK,EAAC,WAAW,CAAC,CAAC;IAEhD,IAAuB,OAAO;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,YAAY,OAAqB;QAC/B,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;IAEkB,UAAU,CAC3B,UAAwB,EACxB,OAAgC;QAEhC,mCAAmC;QACnC,OAAO,KAAK,CAAC,UAAU,CACrB,IAAA,eAAS,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,UAAU,EAAE,EAC9D,OAAO,CACR,CAAC;IACJ,CAAC;IAEkB,cAAc,CAC/B,GAAQ,EACR,OAA4B;QAE5B,OAAO,CAAC,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CACnC,IAAA,kBAAS,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;;AA5BH,gCA6BC","sourcesContent":["import { parseJson } from '../common';\nimport { regEx } from '../regex';\nimport { isHttpUrl } from '../url';\nimport { HttpBase, type InternalHttpOptions } from './http';\nimport type { HttpOptions } from './types';\n\nlet baseUrl: string;\nexport function setBaseUrl(url: string): void {\n baseUrl = url;\n}\n\n/**\n * Access Gerrit REST-API and strip-of the \"magic prefix\" from responses.\n * @see https://gerrit-review.googlesource.com/Documentation/rest-api.html\n */\nexport class GerritHttp extends HttpBase {\n private static magicPrefix = regEx(/^\\)]}'\\n/g);\n\n protected override get baseUrl(): string | undefined {\n return baseUrl;\n }\n\n constructor(options?: HttpOptions) {\n super('gerrit', options);\n }\n\n protected override resolveUrl(\n requestUrl: string | URL,\n options: HttpOptions | undefined,\n ): URL {\n // ensure trailing slash for gerrit\n return super.resolveUrl(\n isHttpUrl(requestUrl) ? requestUrl : `${baseUrl}${requestUrl}`,\n options,\n );\n }\n\n protected override processOptions(\n url: URL,\n options: InternalHttpOptions,\n ): void {\n options.parseJson = (text: string) =>\n parseJson(text.replace(GerritHttp.magicPrefix, ''), url.pathname);\n }\n}\n"]}
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import { HttpBase, type InternalJsonUnsafeOptions } from './http';
|
2
|
+
import type { HttpMethod, HttpOptions, HttpResponse } from './types';
|
3
3
|
export declare const setBaseUrl: (newBaseUrl: string) => void;
|
4
4
|
export interface GiteaHttpOptions extends HttpOptions {
|
5
5
|
paginate?: boolean;
|
6
6
|
}
|
7
|
-
export declare class GiteaHttp extends
|
7
|
+
export declare class GiteaHttp extends HttpBase<GiteaHttpOptions> {
|
8
|
+
protected get baseUrl(): string | undefined;
|
8
9
|
constructor(hostType?: string, options?: HttpOptions);
|
9
|
-
protected
|
10
|
+
protected requestJsonUnsafe<T = unknown>(method: HttpMethod, options: InternalJsonUnsafeOptions<GiteaHttpOptions>): Promise<HttpResponse<T>>;
|
10
11
|
}
|
package/dist/util/http/gitea.js
CHANGED
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GiteaHttp = exports.setBaseUrl = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
|
6
|
-
const
|
7
|
-
const _1 = require(".");
|
6
|
+
const http_1 = require("./http");
|
8
7
|
let baseUrl;
|
9
8
|
const setBaseUrl = (newBaseUrl) => {
|
10
9
|
baseUrl = newBaseUrl.replace(/\/*$/, '/'); // TODO #12875
|
@@ -19,29 +18,29 @@ function getPaginationContainer(body) {
|
|
19
18
|
}
|
20
19
|
return null;
|
21
20
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
class GiteaHttp extends _1.Http {
|
21
|
+
class GiteaHttp extends http_1.HttpBase {
|
22
|
+
get baseUrl() {
|
23
|
+
return baseUrl;
|
24
|
+
}
|
27
25
|
constructor(hostType, options) {
|
28
26
|
super(hostType ?? 'gitea', options);
|
29
27
|
}
|
30
|
-
async
|
31
|
-
const resolvedUrl = resolveUrl(
|
28
|
+
async requestJsonUnsafe(method, options) {
|
29
|
+
const resolvedUrl = this.resolveUrl(options.url, options.httpOptions);
|
32
30
|
const opts = {
|
33
|
-
baseUrl,
|
34
31
|
...options,
|
32
|
+
url: resolvedUrl,
|
35
33
|
};
|
36
|
-
const res = await super.
|
34
|
+
const res = await super.requestJsonUnsafe(method, opts);
|
37
35
|
const pc = getPaginationContainer(res.body);
|
38
|
-
if (opts.paginate && pc) {
|
36
|
+
if (opts.httpOptions?.paginate && pc) {
|
37
|
+
delete opts.httpOptions.paginate;
|
39
38
|
const total = parseInt(res.headers['x-total-count'], 10);
|
40
39
|
let nextPage = parseInt(resolvedUrl.searchParams.get('page') ?? '1', 10);
|
41
40
|
while (total && pc.length < total) {
|
42
41
|
nextPage += 1;
|
43
42
|
resolvedUrl.searchParams.set('page', nextPage.toString());
|
44
|
-
const nextRes = await super.
|
43
|
+
const nextRes = await super.requestJsonUnsafe(method, opts);
|
45
44
|
const nextPc = getPaginationContainer(nextRes.body);
|
46
45
|
if (nextPc === null) {
|
47
46
|
break;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"gitea.js","sourceRoot":"","sources":["../../../lib/util/http/gitea.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAClC,
|
1
|
+
{"version":3,"file":"gitea.js","sourceRoot":"","sources":["../../../lib/util/http/gitea.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAClC,iCAAkE;AAGlE,IAAI,OAAe,CAAC;AACb,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAQ,EAAE;IACrD,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,cAAc;AAC3D,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAMF,SAAS,sBAAsB,CAAc,IAAa;IACxD,IAAI,YAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,IAAW,CAAC;IACrB,CAAC;IAED,IAAI,YAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,YAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACrE,OAAO,IAAI,CAAC,IAAW,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAa,SAAU,SAAQ,eAA0B;IACvD,IAAuB,OAAO;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,YAAY,QAAiB,EAAE,OAAqB;QAClD,KAAK,CAAC,QAAQ,IAAI,OAAO,EAA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C;YACrB,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAzCD,8BAyCC","sourcesContent":["import is from '@sindresorhus/is';\nimport { HttpBase, type InternalJsonUnsafeOptions } from './http';\nimport type { HttpMethod, HttpOptions, HttpResponse } from './types';\n\nlet baseUrl: string;\nexport const setBaseUrl = (newBaseUrl: string): void => {\n baseUrl = newBaseUrl.replace(/\\/*$/, '/'); // TODO #12875\n};\n\nexport interface GiteaHttpOptions extends HttpOptions {\n paginate?: boolean;\n}\n\nfunction getPaginationContainer<T = unknown>(body: unknown): T[] | null {\n if (is.array(body) && body.length) {\n return body as T[];\n }\n\n if (is.plainObject(body) && is.array(body?.data) && body.data.length) {\n return body.data as T[];\n }\n\n return null;\n}\n\nexport class GiteaHttp extends HttpBase<GiteaHttpOptions> {\n protected override get baseUrl(): string | undefined {\n return baseUrl;\n }\n\n constructor(hostType?: string, options?: HttpOptions) {\n super(hostType ?? 'gitea', options);\n }\n\n protected override async requestJsonUnsafe<T = unknown>(\n method: HttpMethod,\n options: InternalJsonUnsafeOptions<GiteaHttpOptions>,\n ): Promise<HttpResponse<T>> {\n const resolvedUrl = this.resolveUrl(options.url, options.httpOptions);\n const opts = {\n ...options,\n url: resolvedUrl,\n };\n const res = await super.requestJsonUnsafe<T>(method, opts);\n const pc = getPaginationContainer<T>(res.body);\n if (opts.httpOptions?.paginate && pc) {\n delete opts.httpOptions.paginate;\n const total = parseInt(res.headers['x-total-count'] as string, 10);\n let nextPage = parseInt(resolvedUrl.searchParams.get('page') ?? '1', 10);\n\n while (total && pc.length < total) {\n nextPage += 1;\n resolvedUrl.searchParams.set('page', nextPage.toString());\n\n const nextRes = await super.requestJsonUnsafe<T>(method, opts);\n const nextPc = getPaginationContainer<T>(nextRes.body);\n if (nextPc === null) {\n break;\n }\n\n pc.push(...nextPc);\n }\n }\n\n return res;\n }\n}\n"]}
|
@@ -1,11 +1,14 @@
|
|
1
|
-
import
|
2
|
-
import {
|
1
|
+
import { HttpBase, type InternalHttpOptions, type InternalJsonUnsafeOptions } from './http';
|
2
|
+
import type { GotLegacyError } from './legacy';
|
3
|
+
import type { GraphqlOptions, HttpMethod, HttpOptions, HttpResponse } from './types';
|
3
4
|
export declare const setBaseUrl: (url: string) => void;
|
4
|
-
export interface
|
5
|
+
export interface GithubBaseHttpOptions extends HttpOptions {
|
6
|
+
repository?: string;
|
7
|
+
}
|
8
|
+
export interface GithubHttpOptions extends GithubBaseHttpOptions {
|
5
9
|
paginate?: boolean | string;
|
6
10
|
paginationField?: string;
|
7
11
|
pageLimit?: number;
|
8
|
-
repository?: string;
|
9
12
|
}
|
10
13
|
export type GithubGraphqlResponse<T = unknown> = {
|
11
14
|
data: T;
|
@@ -22,9 +25,12 @@ interface GraphqlPageCacheItem {
|
|
22
25
|
pageSize: number;
|
23
26
|
}
|
24
27
|
export type GraphqlPageCache = Record<string, GraphqlPageCacheItem>;
|
25
|
-
export declare class GithubHttp extends
|
26
|
-
|
27
|
-
|
28
|
+
export declare class GithubHttp extends HttpBase<GithubHttpOptions> {
|
29
|
+
protected get baseUrl(): string | undefined;
|
30
|
+
constructor(hostType?: string, options?: HttpOptions);
|
31
|
+
protected processOptions(url: URL, opts: InternalHttpOptions & GithubBaseHttpOptions): void;
|
32
|
+
protected handleError(url: string | URL, opts: HttpOptions, err: GotLegacyError): never;
|
33
|
+
protected requestJsonUnsafe<T>(method: HttpMethod, options: InternalJsonUnsafeOptions<GithubHttpOptions>): Promise<HttpResponse<T>>;
|
28
34
|
requestGraphql<T = unknown>(query: string, options?: GraphqlOptions): Promise<GithubGraphqlResponse<T> | null>;
|
29
35
|
queryRepoField<T = Record<string, unknown>>(query: string, fieldName: string, options?: GraphqlOptions): Promise<T[]>;
|
30
36
|
/**
|
@@ -38,6 +44,6 @@ export declare class GithubHttp extends Http<GithubHttpOptions> {
|
|
38
44
|
* @example url = 'renovatebot/renovate/contents/package.json'
|
39
45
|
* @example url = 'package.json' & options.repository = 'renovatebot/renovate'
|
40
46
|
*/
|
41
|
-
getRawTextFile(url: string, options?: InternalHttpOptions &
|
47
|
+
getRawTextFile(url: string, options?: InternalHttpOptions & GithubBaseHttpOptions): Promise<HttpResponse>;
|
42
48
|
}
|
43
49
|
export {};
|
package/dist/util/http/github.js
CHANGED
@@ -14,7 +14,7 @@ const range_1 = require("../range");
|
|
14
14
|
const regex_1 = require("../regex");
|
15
15
|
const url_1 = require("../url");
|
16
16
|
const host_rules_1 = require("./host-rules");
|
17
|
-
const
|
17
|
+
const http_1 = require("./http");
|
18
18
|
const githubBaseUrl = 'https://api.github.com/';
|
19
19
|
let baseUrl = githubBaseUrl;
|
20
20
|
const setBaseUrl = (url) => {
|
@@ -164,18 +164,16 @@ function replaceUrlBase(url, baseUrl) {
|
|
164
164
|
const relativeUrl = `${url.pathname}${url.search}`;
|
165
165
|
return new URL(relativeUrl, baseUrl);
|
166
166
|
}
|
167
|
-
class GithubHttp extends
|
167
|
+
class GithubHttp extends http_1.HttpBase {
|
168
|
+
get baseUrl() {
|
169
|
+
return baseUrl;
|
170
|
+
}
|
168
171
|
constructor(hostType = 'github', options) {
|
169
172
|
super(hostType, options);
|
170
173
|
}
|
171
|
-
|
172
|
-
const opts = {
|
173
|
-
baseUrl,
|
174
|
-
...options,
|
175
|
-
throwHttpErrors: true,
|
176
|
-
};
|
174
|
+
processOptions(url, opts) {
|
177
175
|
if (!opts.token) {
|
178
|
-
const authUrl = new URL(
|
176
|
+
const authUrl = new URL(url);
|
179
177
|
if (opts.repository) {
|
180
178
|
// set authUrl to https://api.github.com/repos/org/repo or https://gihub.domain.com/api/v3/repos/org/repo
|
181
179
|
authUrl.hash = '';
|
@@ -199,62 +197,72 @@ class GithubHttp extends _1.Http {
|
|
199
197
|
...opts.headers,
|
200
198
|
accept,
|
201
199
|
};
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
200
|
+
}
|
201
|
+
handleError(url, opts, err) {
|
202
|
+
throw handleGotError(err, url, opts);
|
203
|
+
}
|
204
|
+
async requestJsonUnsafe(method, options) {
|
205
|
+
const httpOptions = options.httpOptions ?? {};
|
206
|
+
const resolvedUrl = this.resolveUrl(options.url, httpOptions);
|
207
|
+
const opts = {
|
208
|
+
...options,
|
209
|
+
url: resolvedUrl,
|
210
|
+
};
|
211
|
+
const result = await super.requestJsonUnsafe(method, opts);
|
212
|
+
if (httpOptions.paginate) {
|
213
|
+
delete httpOptions.cacheProvider;
|
214
|
+
// Check if result is paginated
|
215
|
+
const pageLimit = httpOptions.pageLimit ?? 10;
|
216
|
+
const linkHeader = (0, url_1.parseLinkHeader)(result?.headers?.link);
|
217
|
+
const next = linkHeader?.next;
|
218
|
+
if (next?.url && linkHeader?.last?.page) {
|
219
|
+
let lastPage = parseInt(linkHeader.last.page, 10);
|
220
|
+
if (!process.env.RENOVATE_PAGINATE_ALL &&
|
221
|
+
httpOptions.paginate !== 'all') {
|
222
|
+
lastPage = Math.min(pageLimit, lastPage);
|
223
|
+
}
|
224
|
+
const baseUrl = httpOptions.baseUrl ?? this.baseUrl;
|
225
|
+
const parsedUrl = new URL(next.url, baseUrl);
|
226
|
+
const rebasePagination = !!baseUrl &&
|
227
|
+
!!process.env.RENOVATE_X_REBASE_PAGINATION_LINKS &&
|
228
|
+
// Preserve github.com URLs for use cases like release notes
|
229
|
+
parsedUrl.origin !== 'https://api.github.com';
|
230
|
+
const firstPageUrl = rebasePagination
|
231
|
+
? replaceUrlBase(parsedUrl, baseUrl)
|
232
|
+
: parsedUrl;
|
233
|
+
const queue = [...(0, range_1.range)(2, lastPage)].map((pageNumber) => () => {
|
234
|
+
// copy before modifying searchParams
|
235
|
+
const nextUrl = new URL(firstPageUrl);
|
236
|
+
nextUrl.searchParams.set('page', String(pageNumber));
|
237
|
+
return super.requestJsonUnsafe(method, {
|
238
|
+
...opts,
|
239
|
+
url: nextUrl,
|
229
240
|
});
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
241
|
+
});
|
242
|
+
const pages = await p.all(queue);
|
243
|
+
if (httpOptions.paginationField && is_1.default.plainObject(result.body)) {
|
244
|
+
const paginatedResult = result.body[httpOptions.paginationField];
|
245
|
+
if (is_1.default.array(paginatedResult)) {
|
246
|
+
for (const nextPage of pages) {
|
247
|
+
if (is_1.default.plainObject(nextPage.body)) {
|
248
|
+
const nextPageResults = nextPage.body[httpOptions.paginationField];
|
249
|
+
if (is_1.default.array(nextPageResults)) {
|
250
|
+
paginatedResult.push(...nextPageResults);
|
240
251
|
}
|
241
252
|
}
|
242
253
|
}
|
243
254
|
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
255
|
+
}
|
256
|
+
else if (is_1.default.array(result.body)) {
|
257
|
+
for (const nextPage of pages) {
|
258
|
+
if (is_1.default.array(nextPage.body)) {
|
259
|
+
result.body.push(...nextPage.body);
|
249
260
|
}
|
250
261
|
}
|
251
262
|
}
|
252
263
|
}
|
253
|
-
return result;
|
254
|
-
}
|
255
|
-
catch (err) {
|
256
|
-
throw handleGotError(err, url, opts);
|
257
264
|
}
|
265
|
+
return result;
|
258
266
|
}
|
259
267
|
async requestGraphql(query, options = {}) {
|
260
268
|
const path = 'graphql';
|
@@ -366,11 +374,7 @@ class GithubHttp extends _1.Http {
|
|
366
374
|
if (options.repository && !httpRegex.test(options.repository)) {
|
367
375
|
newURL = (0, url_1.joinUrlParts)(options.repository, 'contents', url);
|
368
376
|
}
|
369
|
-
|
370
|
-
if (!is_1.default.string(result.body)) {
|
371
|
-
throw new Error(`Expected raw text file but received ${typeof result.body}`);
|
372
|
-
}
|
373
|
-
return result;
|
377
|
+
return await this.getText(newURL, newOptions);
|
374
378
|
}
|
375
379
|
}
|
376
380
|
exports.GithubHttp = GithubHttp;
|