renovate 39.182.5 → 39.184.0
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.d.ts +1 -1
- package/dist/config/decrypt.js +10 -7
- package/dist/config/decrypt.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 -1
- package/dist/config/presets/http/index.js.map +1 -1
- package/dist/data/monorepo.json +2 -1
- package/dist/modules/datasource/artifactory/index.js +1 -1
- package/dist/modules/datasource/artifactory/index.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/deb/index.js +1 -1
- package/dist/modules/datasource/deb/index.js.map +1 -1
- package/dist/modules/datasource/docker/index.js +1 -1
- package/dist/modules/datasource/docker/index.js.map +1 -1
- 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/hexpm-bob/index.js +1 -1
- package/dist/modules/datasource/hexpm-bob/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/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/manager/batect-wrapper/artifacts.js +1 -1
- package/dist/modules/manager/batect-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/gradle-wrapper/artifacts.js +1 -1
- package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
- package/dist/modules/platform/bitbucket/index.js +1 -1
- package/dist/modules/platform/bitbucket/index.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/util/http/auth.js +0 -1
- package/dist/util/http/auth.js.map +1 -1
- package/dist/util/http/bitbucket-server.d.ts +4 -2
- package/dist/util/http/bitbucket-server.js +15 -18
- package/dist/util/http/bitbucket-server.js.map +1 -1
- package/dist/util/http/bitbucket.d.ts +5 -3
- package/dist/util/http/bitbucket.js +24 -27
- 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/gerrit.d.ts +6 -3
- package/dist/util/http/gerrit.js +11 -12
- package/dist/util/http/gerrit.js.map +1 -1
- package/dist/util/http/gitea.d.ts +4 -2
- package/dist/util/http/gitea.js +10 -11
- package/dist/util/http/gitea.js.map +1 -1
- package/dist/util/http/github.d.ts +7 -2
- package/dist/util/http/github.js +62 -58
- package/dist/util/http/github.js.map +1 -1
- package/dist/util/http/gitlab.d.ts +6 -3
- package/dist/util/http/gitlab.js +54 -44
- package/dist/util/http/gitlab.js.map +1 -1
- 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 +17 -0
- package/dist/util/http/http.js +3 -0
- package/dist/util/http/http.js.map +1 -0
- package/dist/util/http/index.d.ts +14 -7
- package/dist/util/http/index.js +64 -51
- package/dist/util/http/index.js.map +1 -1
- package/dist/util/http/types.d.ts +5 -9
- package/dist/util/http/types.js.map +1 -1
- package/dist/util/url.js +3 -8
- package/dist/util/url.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 +3 -3
@@ -1,53 +1,50 @@
|
|
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 logger_1 = require("../../logger");
|
7
|
-
const url_1 = require("../url");
|
8
7
|
const _1 = require(".");
|
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
|
-
exports.setBaseUrl = setBaseUrl;
|
13
|
+
}
|
16
14
|
class BitbucketHttp extends _1.Http {
|
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
|
-
if (
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
if (opts.paginate && !hasPagelen(resolvedURL)) {
|
29
|
-
const pagelen = opts.pagelen ?? MAX_PAGELEN;
|
30
|
-
resolvedURL.searchParams.set('pagelen', pagelen.toString());
|
21
|
+
async requestJsonUnsafe(method, options) {
|
22
|
+
const resolvedUrl = this.resolveUrl(options.url, options.httpOptions);
|
23
|
+
const opts = { ...options, url: resolvedUrl };
|
24
|
+
const paginate = opts.httpOptions?.paginate;
|
25
|
+
if (paginate && !hasPagelen(resolvedUrl)) {
|
26
|
+
const pagelen = opts.httpOptions.pagelen ?? MAX_PAGELEN;
|
27
|
+
resolvedUrl.searchParams.set('pagelen', pagelen.toString());
|
31
28
|
}
|
32
|
-
const result = await super.
|
33
|
-
if (
|
29
|
+
const result = await super.requestJsonUnsafe(method, opts);
|
30
|
+
if (paginate && isPagedResult(result.body)) {
|
34
31
|
const resultBody = result.body;
|
35
|
-
let
|
36
|
-
let
|
37
|
-
|
38
|
-
|
32
|
+
let nextURL = result.body.next;
|
33
|
+
let page = 2;
|
34
|
+
for (; nextURL && page <= MAX_PAGES; page++) {
|
35
|
+
resolvedUrl.searchParams.set('page', page.toString());
|
36
|
+
const nextResult = await super.requestJsonUnsafe(method, opts);
|
39
37
|
resultBody.values.push(...nextResult.body.values);
|
40
|
-
nextURL = nextResult.body
|
41
|
-
page += 1;
|
38
|
+
nextURL = nextResult.body.next;
|
42
39
|
}
|
43
40
|
// Override other page-related attributes
|
44
41
|
resultBody.pagelen = resultBody.values.length;
|
45
42
|
resultBody.size =
|
46
43
|
page <= MAX_PAGES
|
47
44
|
? resultBody.values.length
|
48
|
-
: /*
|
45
|
+
: /* v8 ignore next */ undefined;
|
49
46
|
resultBody.next =
|
50
|
-
page <= MAX_PAGES ? nextURL : /*
|
47
|
+
page <= MAX_PAGES ? nextURL : /* v8 ignore next */ undefined;
|
51
48
|
}
|
52
49
|
return result;
|
53
50
|
}
|
@@ -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":";;;AAWA,gCAEC;;AAbD,kEAAkC;AAIlC,wBAAyB;AAEzB,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,OAA0B;IAC3D,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,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;QAE5C,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAY,CAAC,OAAO,IAAI,WAAW,CAAC;YACzD,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS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,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 type { InternalJsonUnsafeOptions } from './http';\nimport type { HttpMethod, HttpOptions, HttpResponse } from './types';\nimport { Http } from '.';\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 Http<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 = { ...options, url: resolvedUrl };\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 = 2;\n\n for (; nextURL && page <= MAX_PAGES; page++) {\n resolvedUrl.searchParams.set('page', page.toString());\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 resultBody.size =\n page <= MAX_PAGES\n ? resultBody.values.length\n : /* v8 ignore next */ undefined;\n resultBody.next =\n page <= MAX_PAGES ? nextURL : /* v8 ignore next */ undefined;\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,OAAO,SAAsB,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,GAAW,EACX,IAAO;QAEP,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC;QAEpB,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC;QACjD,CAAC;QAED,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,YAAY,CACV,IAAY,EACZ,cAAuB;QAEvB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,GAAW,EACX,IAAqB;QAErB,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,CAAC;YAErD,sBAAc,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAEpC,MAAM,YAAY,GAAG,IAAA,mBAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAE3C,MAAM,YAAY,GAAG,wBAAe,CAAC,KAAK,CAAC;gBACzC,IAAI;gBACJ,YAAY;gBACZ,YAAY;gBACZ,SAAS;aACV,CAAC,CAAC;YAEH,
|
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,KAA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AM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAE3C,MAAM,YAAY,GAAG,wBAAe,CAAC,KAAK,CAAC;gBACzC,IAAI;gBACJ,YAAY;gBACZ,YAAY;gBACZ,SAAS;aACV,CAAC,CAAC;YAEH,2CAA2C;YAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,eAAM,CAAC,KAAK,CAAC,2CAA2C,GAAG,EAAE,CAAC,CAAC;gBAC/D,OAAO,IAAI,CAAC;YACd,CAAC;YAED,eAAM,CAAC,KAAK,CACV,sBAAsB,GAAG,UAAU,IAAI,kBAAkB,YAAY,GAAG,CACzE,CAAC;YACF,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,YAAyB,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACtC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;YACtC,eAAM,CAAC,KAAK,CACV,sCAAsC,GAAG,SAAS,SAAS,EAAE,CAC9D,CAAC;YACF,sBAAc,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,UAAU,GAAG,IAAA,mBAAY,EAC7B,SAAS,CAAC,YAA+B,EACzC,IAAI,CACL,CAAC;YACF,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YAC9C,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,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"]}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import type {
|
2
|
-
import {
|
1
|
+
import type { InternalHttpOptions } from './http';
|
2
|
+
import type { HttpOptions } from './types';
|
3
|
+
import { Http } from '.';
|
3
4
|
export declare function setBaseUrl(url: string): void;
|
4
5
|
/**
|
5
6
|
* Access Gerrit REST-API and strip-of the "magic prefix" from responses.
|
@@ -7,6 +8,8 @@ export declare function setBaseUrl(url: string): void;
|
|
7
8
|
*/
|
8
9
|
export declare class GerritHttp extends Http {
|
9
10
|
private static magicPrefix;
|
11
|
+
protected get baseUrl(): string | undefined;
|
10
12
|
constructor(options?: HttpOptions);
|
11
|
-
protected
|
13
|
+
protected resolveUrl(requestUrl: string | URL, options: HttpOptions | undefined): URL;
|
14
|
+
protected processOptions(url: URL, options: InternalHttpOptions): void;
|
12
15
|
}
|
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 _1 = require(".");
|
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 _1.Http {
|
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":";;;
|
1
|
+
{"version":3,"file":"gerrit.js","sourceRoot":"","sources":["../../../lib/util/http/gerrit.ts"],"names":[],"mappings":";;;AAQA,gCAEC;AAVD,sCAAsC;AACtC,oCAAiC;AACjC,gCAAmC;AAGnC,wBAAyB;AAEzB,IAAI,OAAe,CAAC;AACpB,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,GAAG,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAa,UAAW,SAAQ,OAAI;IAC1B,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 type { InternalHttpOptions } from './http';\nimport type { HttpOptions } from './types';\nimport { Http } from '.';\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 Http {\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,12 @@
|
|
1
|
-
import type {
|
1
|
+
import type { InternalJsonUnsafeOptions } from './http';
|
2
|
+
import type { HttpMethod, HttpOptions, HttpResponse } from './types';
|
2
3
|
import { Http } from '.';
|
3
4
|
export declare const setBaseUrl: (newBaseUrl: string) => void;
|
4
5
|
export interface GiteaHttpOptions extends HttpOptions {
|
5
6
|
paginate?: boolean;
|
6
7
|
}
|
7
8
|
export declare class GiteaHttp extends Http<GiteaHttpOptions> {
|
9
|
+
protected get baseUrl(): string | undefined;
|
8
10
|
constructor(hostType?: string, options?: HttpOptions);
|
9
|
-
protected
|
11
|
+
protected requestJsonUnsafe<T = unknown>(method: HttpMethod, options: InternalJsonUnsafeOptions<GiteaHttpOptions>): Promise<HttpResponse<T>>;
|
10
12
|
}
|
package/dist/util/http/gitea.js
CHANGED
@@ -3,7 +3,6 @@ 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 url_1 = require("../url");
|
7
6
|
const _1 = require(".");
|
8
7
|
let baseUrl;
|
9
8
|
const setBaseUrl = (newBaseUrl) => {
|
@@ -19,29 +18,29 @@ function getPaginationContainer(body) {
|
|
19
18
|
}
|
20
19
|
return null;
|
21
20
|
}
|
22
|
-
function resolveUrl(path, base) {
|
23
|
-
const resolvedUrlString = (0, url_1.resolveBaseUrl)(base, path);
|
24
|
-
return new URL(resolvedUrlString);
|
25
|
-
}
|
26
21
|
class GiteaHttp extends _1.Http {
|
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;
|
1
|
+
{"version":3,"file":"gitea.js","sourceRoot":"","sources":["../../../lib/util/http/gitea.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAGlC,wBAAyB;AAEzB,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,OAAsB;IACnD,IAAuB,OAAO;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,YAAY,QAAiB,EAAE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AED,EAAE,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAzCD,8BAyCC","sourcesContent":["import is from '@sindresorhus/is';\nimport type { InternalJsonUnsafeOptions } from './http';\nimport type { HttpMethod, HttpOptions, HttpResponse } from './types';\nimport { Http } from '.';\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 Http<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,4 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { InternalHttpOptions, InternalJsonUnsafeOptions } from './http';
|
2
|
+
import type { GotLegacyError } from './legacy';
|
3
|
+
import type { GraphqlOptions, HttpMethod, HttpOptions, HttpResponse } from './types';
|
2
4
|
import { Http } from '.';
|
3
5
|
export declare const setBaseUrl: (url: string) => void;
|
4
6
|
export interface GithubHttpOptions extends HttpOptions {
|
@@ -23,8 +25,11 @@ interface GraphqlPageCacheItem {
|
|
23
25
|
}
|
24
26
|
export type GraphqlPageCache = Record<string, GraphqlPageCacheItem>;
|
25
27
|
export declare class GithubHttp extends Http<GithubHttpOptions> {
|
28
|
+
protected get baseUrl(): string | undefined;
|
26
29
|
constructor(hostType?: string, options?: GithubHttpOptions);
|
27
|
-
protected
|
30
|
+
protected processOptions(url: URL, opts: InternalHttpOptions & GithubHttpOptions): void;
|
31
|
+
protected handleError(url: string | URL, opts: HttpOptions, err: GotLegacyError): never;
|
32
|
+
protected requestJsonUnsafe<T>(method: HttpMethod, options: InternalJsonUnsafeOptions<GithubHttpOptions>): Promise<HttpResponse<T>>;
|
28
33
|
requestGraphql<T = unknown>(query: string, options?: GraphqlOptions): Promise<GithubGraphqlResponse<T> | null>;
|
29
34
|
queryRepoField<T = Record<string, unknown>>(query: string, fieldName: string, options?: GraphqlOptions): Promise<T[]>;
|
30
35
|
/**
|
package/dist/util/http/github.js
CHANGED
@@ -165,17 +165,15 @@ function replaceUrlBase(url, baseUrl) {
|
|
165
165
|
return new URL(relativeUrl, baseUrl);
|
166
166
|
}
|
167
167
|
class GithubHttp extends _1.Http {
|
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;
|