@stats-organization/github-readme-stats-core 2.1.4 → 2.2.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/build/api/gist.d.ts +2 -7
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +28 -26
- package/build/api/index.d.ts +3 -8
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +32 -36
- package/build/api/pin.d.ts +2 -7
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +18 -33
- package/build/api/top-langs.d.ts +2 -7
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +32 -44
- package/build/api/wakatime.d.ts +2 -7
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +28 -26
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/common-options.d.ts +13 -0
- package/build/cards/common-options.d.ts.map +1 -0
- package/build/cards/common-options.js +1 -0
- package/build/cards/gist.d.ts +11 -16
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +26 -31
- package/build/cards/repo.d.ts +19 -16
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +79 -72
- package/build/cards/stats.d.ts +29 -44
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +118 -173
- package/build/cards/top-languages.d.ts +81 -77
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +186 -184
- package/build/cards/wakatime.d.ts +21 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +92 -109
- package/build/common/Card.d.ts +41 -14
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +92 -31
- package/build/common/I18n.d.ts +4 -2
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/color.d.ts +91 -15
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +163 -17
- package/build/common/config.d.ts +2 -1
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +16 -26
- package/build/common/constants.d.ts +2 -1
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/date.d.ts +37 -0
- package/build/common/date.d.ts.map +1 -0
- package/build/common/date.js +31 -0
- package/build/common/html.js +1 -1
- package/build/common/http.d.ts +37 -5
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +29 -6
- package/build/common/icons.d.ts +1 -0
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +1 -0
- package/build/common/languageColors.d.ts +11 -0
- package/build/common/languageColors.d.ts.map +1 -0
- package/build/common/languageColors.js +15 -0
- package/build/common/languageColors.json +10 -1
- package/build/common/ops.d.ts +27 -33
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +31 -48
- package/build/common/render.d.ts +154 -113
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +209 -92
- package/build/common/retryer.d.ts +15 -6
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +2 -0
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +28 -64
- package/build/fetchers/repo.d.ts +12 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +27 -68
- package/build/fetchers/stats.d.ts +24 -17
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +302 -184
- package/build/fetchers/top-languages.d.ts +10 -15
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +52 -103
- package/build/fetchers/types.d.ts +130 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- package/build/fetchers/wakatime.d.ts +9 -5
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +8 -4
- package/build/graphql/contributionsDocument.d.ts +18 -0
- package/build/graphql/contributionsDocument.d.ts.map +1 -0
- package/build/graphql/contributionsDocument.js +30 -0
- package/build/graphql/generated/common.d.ts +42 -0
- package/build/graphql/generated/common.d.ts.map +1 -0
- package/build/graphql/generated/common.js +2 -0
- package/build/graphql/generated/gist.d.ts +44 -0
- package/build/graphql/generated/gist.d.ts.map +1 -0
- package/build/graphql/generated/gist.js +27 -0
- package/build/graphql/generated/repo.d.ts +67 -0
- package/build/graphql/generated/repo.d.ts.map +1 -0
- package/build/graphql/generated/repo.js +30 -0
- package/build/graphql/generated/stats.d.ts +150 -0
- package/build/graphql/generated/stats.d.ts.map +1 -0
- package/build/graphql/generated/stats.js +95 -0
- package/build/graphql/generated/top-languages.d.ts +54 -0
- package/build/graphql/generated/top-languages.d.ts.map +1 -0
- package/build/graphql/generated/top-languages.js +27 -0
- package/build/graphql/graphqlDocument.d.ts +22 -0
- package/build/graphql/graphqlDocument.d.ts.map +1 -0
- package/build/graphql/graphqlDocument.js +8 -0
- package/build/graphql/reposContributedToDocument.d.ts +27 -0
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
- package/build/graphql/reposContributedToDocument.js +59 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/themes/index.d.ts +32 -0
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +28 -0
- package/build/translations.d.ts +17 -0
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +17 -0
- package/package.json +14 -8
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/_github-username-regex.d.ts +4 -0
- package/src/api/gist.js +31 -31
- package/src/api/index.js +40 -42
- package/src/api/pin.js +20 -38
- package/src/api/top-langs.js +36 -49
- package/src/api/wakatime.js +31 -31
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/common-options.ts +13 -0
- package/src/cards/{gist.js → gist.ts} +37 -37
- package/src/cards/{repo.js → repo.ts} +107 -79
- package/src/cards/{stats.js → stats.ts} +173 -210
- package/src/cards/{top-languages.js → top-languages.ts} +325 -243
- package/src/cards/{wakatime.js → wakatime.ts} +158 -127
- package/src/common/Card.ts +123 -43
- package/src/common/I18n.ts +6 -2
- package/src/common/color.ts +240 -28
- package/src/common/config.ts +22 -29
- package/src/common/constants.ts +3 -1
- package/src/common/date.ts +45 -0
- package/src/common/html.ts +1 -1
- package/src/common/http.ts +71 -0
- package/src/common/icons.ts +1 -0
- package/src/common/languageColors.json +10 -1
- package/src/common/languageColors.ts +19 -0
- package/src/common/ops.ts +158 -0
- package/src/common/render.ts +652 -0
- package/src/common/retryer.ts +21 -12
- package/src/fetchers/gist.ts +79 -0
- package/src/fetchers/repo.ts +114 -0
- package/src/fetchers/stats.ts +743 -0
- package/src/fetchers/top-languages.ts +135 -0
- package/src/fetchers/{types.d.ts → types.ts} +28 -20
- package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
- package/src/graphql/contributionsDocument.ts +44 -0
- package/src/graphql/generated/common.ts +26 -0
- package/src/graphql/generated/gist.ts +59 -0
- package/src/graphql/generated/repo.ts +90 -0
- package/src/graphql/generated/stats.ts +194 -0
- package/src/graphql/generated/top-languages.ts +75 -0
- package/src/graphql/graphqlDocument.ts +25 -0
- package/src/graphql/queries/gist.graphql +25 -0
- package/src/graphql/queries/repo.graphql +28 -0
- package/src/graphql/queries/stats.graphql +120 -0
- package/src/graphql/queries/top-languages.graphql +34 -0
- package/src/graphql/reposContributedToDocument.ts +86 -0
- package/src/index.ts +3 -1
- package/src/themes/index.ts +33 -0
- package/src/translations.ts +17 -0
- package/src/cards/types.d.ts +0 -78
- package/src/common/http.js +0 -19
- package/src/common/ops.js +0 -170
- package/src/common/render.js +0 -440
- package/src/fetchers/gist.js +0 -112
- package/src/fetchers/repo.js +0 -161
- package/src/fetchers/stats.js +0 -474
- package/src/fetchers/top-languages.js +0 -175
- package/src/themes/README.md +0 -229
package/build/common/config.js
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
* @param value Comma-separated string.
|
|
3
3
|
* @returns Parsed string values.
|
|
4
4
|
*/
|
|
5
|
-
const parseCsv = (value) =>
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const parseCsv = (value) => value ? value.split(",") : undefined;
|
|
6
|
+
/**
|
|
7
|
+
* @param value Raw `FETCH_MULTI_PAGE_STARS` value.
|
|
8
|
+
* @returns Page limit: `"true"` means every page, a positive number caps the pages, anything else means one.
|
|
9
|
+
*/
|
|
10
|
+
const parseFetchMultiPageStars = (value) => {
|
|
11
|
+
if (value === "true") {
|
|
12
|
+
return Infinity;
|
|
8
13
|
}
|
|
9
|
-
|
|
14
|
+
const limit = Number(value);
|
|
15
|
+
return limit > 0 ? limit : 1;
|
|
10
16
|
};
|
|
11
17
|
/**
|
|
12
18
|
* @param env Environment variables to inspect.
|
|
@@ -27,34 +33,18 @@ const getDefaultEnv = () => {
|
|
|
27
33
|
const processEnv = globalThis.process?.env;
|
|
28
34
|
return processEnv ?? {};
|
|
29
35
|
};
|
|
30
|
-
/**
|
|
31
|
-
* @param config (Partial) config values to normalize.
|
|
32
|
-
* @returns Normalized config object with defaults applied.
|
|
33
|
-
*/
|
|
34
|
-
const normalizeConfig = (config = {}) => {
|
|
35
|
-
return {
|
|
36
|
-
whitelist: config.whitelist,
|
|
37
|
-
gistWhitelist: config.gistWhitelist,
|
|
38
|
-
excludeRepositories: config.excludeRepositories ?? [],
|
|
39
|
-
fetchMultiPageStars: config.fetchMultiPageStars,
|
|
40
|
-
pats: config.pats ?? [],
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
36
|
let currentConfig;
|
|
44
37
|
/**
|
|
45
38
|
* @param env Environment variables used to build the runtime config.
|
|
46
39
|
*/
|
|
47
40
|
export const loadConfigFromEnv = (env = getDefaultEnv()) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
gistWhitelist,
|
|
54
|
-
excludeRepositories,
|
|
55
|
-
fetchMultiPageStars: env["FETCH_MULTI_PAGE_STARS"],
|
|
41
|
+
currentConfig = {
|
|
42
|
+
whitelist: parseCsv(env["WHITELIST"]),
|
|
43
|
+
gistWhitelist: parseCsv(env["GIST_WHITELIST"]),
|
|
44
|
+
excludeRepositories: parseCsv(env["EXCLUDE_REPO"]) ?? [],
|
|
45
|
+
fetchMultiPageStars: parseFetchMultiPageStars(env["FETCH_MULTI_PAGE_STARS"]),
|
|
56
46
|
pats: parsePATsFromEnv(env),
|
|
57
|
-
}
|
|
47
|
+
};
|
|
58
48
|
};
|
|
59
49
|
loadConfigFromEnv();
|
|
60
50
|
export const getConfig = () => currentConfig;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { RepositoryAffiliation } from "../graphql/generated/common.js";
|
|
1
2
|
/**
|
|
2
3
|
* Valid owner affiliations for GitHub API queries.
|
|
3
4
|
*/
|
|
4
|
-
declare const OWNER_AFFILIATIONS: Array<
|
|
5
|
+
declare const OWNER_AFFILIATIONS: Array<RepositoryAffiliation>;
|
|
5
6
|
export { OWNER_AFFILIATIONS };
|
|
6
7
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAIpD,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A span between two dates, as GitHub's range arguments take it. */
|
|
2
|
+
interface GitHubDateRange {
|
|
3
|
+
/** Start of the range, inclusive. */
|
|
4
|
+
from: Date;
|
|
5
|
+
/** End of the range, inclusive. */
|
|
6
|
+
to: Date;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Format a date as a GitHub `DateTime` scalar.
|
|
10
|
+
* Seconds precision, no milliseconds.
|
|
11
|
+
*
|
|
12
|
+
* @param date Date to format.
|
|
13
|
+
* @returns e.g. `2024-01-01T00:00:00Z`.
|
|
14
|
+
*/
|
|
15
|
+
declare const toGitHubDateTime: (date: Date) => string;
|
|
16
|
+
/**
|
|
17
|
+
* The full UTC span of a calendar year, both ends inclusive.
|
|
18
|
+
*
|
|
19
|
+
* The end matters to callers that would otherwise leave a range open:
|
|
20
|
+
* GitHub's `contributionsCollection` defaults `to` to one year after `from`,
|
|
21
|
+
* which pulls the next 1st of January into the year.
|
|
22
|
+
*
|
|
23
|
+
* @param year Four-digit year.
|
|
24
|
+
* @returns The range covering it.
|
|
25
|
+
*/
|
|
26
|
+
declare const getGitHubYearRange: (year: number) => GitHubDateRange;
|
|
27
|
+
/**
|
|
28
|
+
* Get diff in minutes between two dates.
|
|
29
|
+
*
|
|
30
|
+
* @param d1 First date.
|
|
31
|
+
* @param d2 Second date.
|
|
32
|
+
* @returns Number of minutes between the two dates.
|
|
33
|
+
*/
|
|
34
|
+
declare const dateDiff: (d1: Date, d2: Date) => number;
|
|
35
|
+
export { dateDiff, getGitHubYearRange, toGitHubDateTime };
|
|
36
|
+
export type { GitHubDateRange };
|
|
37
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/common/date.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,UAAU,eAAe;IACvB,qCAAqC;IACrC,IAAI,EAAE,IAAI,CAAC;IACX,mCAAmC;IACnC,EAAE,EAAE,IAAI,CAAC;CACV;AAED;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,MACA,CAAC;AAExC;;;;;;;;;GASG;AACH,QAAA,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,eAGzC,CAAC;AAEH;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ,GAAI,IAAI,IAAI,EAAE,IAAI,IAAI,KAAG,MACkB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a date as a GitHub `DateTime` scalar.
|
|
3
|
+
* Seconds precision, no milliseconds.
|
|
4
|
+
*
|
|
5
|
+
* @param date Date to format.
|
|
6
|
+
* @returns e.g. `2024-01-01T00:00:00Z`.
|
|
7
|
+
*/
|
|
8
|
+
const toGitHubDateTime = (date) => `${date.toISOString().slice(0, 19)}Z`;
|
|
9
|
+
/**
|
|
10
|
+
* The full UTC span of a calendar year, both ends inclusive.
|
|
11
|
+
*
|
|
12
|
+
* The end matters to callers that would otherwise leave a range open:
|
|
13
|
+
* GitHub's `contributionsCollection` defaults `to` to one year after `from`,
|
|
14
|
+
* which pulls the next 1st of January into the year.
|
|
15
|
+
*
|
|
16
|
+
* @param year Four-digit year.
|
|
17
|
+
* @returns The range covering it.
|
|
18
|
+
*/
|
|
19
|
+
const getGitHubYearRange = (year) => ({
|
|
20
|
+
from: new Date(Date.UTC(year, 0, 1)),
|
|
21
|
+
to: new Date(Date.UTC(year, 11, 31, 23, 59, 59)),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Get diff in minutes between two dates.
|
|
25
|
+
*
|
|
26
|
+
* @param d1 First date.
|
|
27
|
+
* @param d2 Second date.
|
|
28
|
+
* @returns Number of minutes between the two dates.
|
|
29
|
+
*/
|
|
30
|
+
const dateDiff = (d1, d2) => Math.round((d1.getTime() - d2.getTime()) / (1000 * 60));
|
|
31
|
+
export { dateDiff, getGitHubYearRange, toGitHubDateTime };
|
package/build/common/html.js
CHANGED
package/build/common/http.d.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
+
import type { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
2
|
+
import type { GraphQLDocument } from "../graphql/graphqlDocument.js";
|
|
3
|
+
/** Response of a GraphQL call: the envelope the GitHub API wraps results in. */
|
|
4
|
+
type GraphQLResponse<TResult> = AxiosResponse<{
|
|
5
|
+
data: TResult;
|
|
6
|
+
errors?: Array<{
|
|
7
|
+
type?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
1
11
|
/**
|
|
2
|
-
*
|
|
12
|
+
* @param document Generated query document.
|
|
13
|
+
* @param scheme `Authorization` scheme for the token.
|
|
14
|
+
* @returns A fetcher `retryer` can drive.
|
|
15
|
+
*/
|
|
16
|
+
declare const createGraphQLFetcher: <TResult, TVariables>(document: GraphQLDocument<TResult, TVariables>, scheme: "bearer" | "token") => (variables: TVariables, token: string) => Promise<GraphQLResponse<TResult>>;
|
|
17
|
+
/** Body of a GraphQL request sent to the GitHub API. */
|
|
18
|
+
interface GraphQLRequest {
|
|
19
|
+
/** The GraphQL query. */
|
|
20
|
+
query: string;
|
|
21
|
+
/** Variables referenced by the query. */
|
|
22
|
+
variables: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Send an untyped GraphQL request to the GitHub API.
|
|
26
|
+
*
|
|
27
|
+
* @param data Request data.
|
|
28
|
+
* @param headers Request headers.
|
|
29
|
+
* @returns Request response.
|
|
30
|
+
*
|
|
31
|
+
* @description Superseded by {@link createGraphQLFetcher}.
|
|
32
|
+
* Still used by the backend status endpoints for their own `rateLimit` query,
|
|
33
|
+
* and part of this package's published API.
|
|
3
34
|
*
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
* @returns {Promise<any>} Request response.
|
|
35
|
+
* @todo consider dropping this once those endpoints post through axios directly,
|
|
36
|
+
* which they already depend on.
|
|
7
37
|
*/
|
|
8
|
-
|
|
38
|
+
declare const request: (data: GraphQLRequest, headers: NonNullable<AxiosRequestConfig["headers"]>) => Promise<AxiosResponse>;
|
|
39
|
+
export { createGraphQLFetcher, request };
|
|
40
|
+
export type { GraphQLResponse };
|
|
9
41
|
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/common/http.
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/common/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIrE,gFAAgF;AAChF,KAAK,eAAe,CAAC,OAAO,IAAI,aAAa,CAAC;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAAC,CAAC;AAEH;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,GAAI,OAAO,EAAE,UAAU,EAC/C,UAAU,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,EAC9C,QAAQ,QAAQ,GAAG,OAAO,MAGxB,WAAW,UAAU,EACrB,OAAO,MAAM,KACZ,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAQpC,CAAC;AAEF,wDAAwD;AACxD,UAAU,cAAc;IACtB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,OAAO,GACX,MAAM,cAAc,EACpB,SAAS,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAClD,OAAO,CAAC,aAAa,CAOvB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/build/common/http.js
CHANGED
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
const GITHUB_GRAPHQL_API = "https://api.github.com/graphql";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* @param document Generated query document.
|
|
5
|
+
* @param scheme `Authorization` scheme for the token.
|
|
6
|
+
* @returns A fetcher `retryer` can drive.
|
|
7
|
+
*/
|
|
8
|
+
const createGraphQLFetcher = (document, scheme) => {
|
|
9
|
+
return (variables, token) => {
|
|
10
|
+
return axios({
|
|
11
|
+
url: GITHUB_GRAPHQL_API,
|
|
12
|
+
method: "post",
|
|
13
|
+
headers: { Authorization: `${scheme} ${token}` },
|
|
14
|
+
data: { query: document.text, variables },
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Send an untyped GraphQL request to the GitHub API.
|
|
20
|
+
*
|
|
21
|
+
* @param data Request data.
|
|
22
|
+
* @param headers Request headers.
|
|
23
|
+
* @returns Request response.
|
|
24
|
+
*
|
|
25
|
+
* @description Superseded by {@link createGraphQLFetcher}.
|
|
26
|
+
* Still used by the backend status endpoints for their own `rateLimit` query,
|
|
27
|
+
* and part of this package's published API.
|
|
4
28
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
* @returns {Promise<any>} Request response.
|
|
29
|
+
* @todo consider dropping this once those endpoints post through axios directly,
|
|
30
|
+
* which they already depend on.
|
|
8
31
|
*/
|
|
9
32
|
const request = (data, headers) => {
|
|
10
33
|
return axios({
|
|
11
|
-
url:
|
|
34
|
+
url: GITHUB_GRAPHQL_API,
|
|
12
35
|
method: "post",
|
|
13
36
|
headers,
|
|
14
37
|
data,
|
|
15
38
|
});
|
|
16
39
|
};
|
|
17
|
-
export { request };
|
|
40
|
+
export { createGraphQLFetcher, request };
|
package/build/common/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/common/icons.ts"],"names":[],"mappings":"AA0BA,QAAA,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/common/icons.ts"],"names":[],"mappings":"AA0BA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;CAgBV,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,QAAQ,GACZ,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,YAAY,MAAM,KACjB,MAyBF,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
|
package/build/common/icons.js
CHANGED
|
@@ -37,6 +37,7 @@ const icons = {
|
|
|
37
37
|
discussions_started: `<path fill-rule="evenodd" d="M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z" />`,
|
|
38
38
|
discussions_answered: `<path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" />`,
|
|
39
39
|
comments: `<path d="M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z" />`,
|
|
40
|
+
contributions: `<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7.25-3.25v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5a.75.75 0 0 1 1.5 0Z"/>`,
|
|
40
41
|
gist: `<path fill-rule="evenodd" d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm7.47 3.97a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L10.69 8 9.22 6.53a.75.75 0 0 1 0-1.06ZM6.78 6.53 5.31 8l1.47 1.47a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-2-2a.75.75 0 0 1 0-1.06l2-2a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z" />`,
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Shown for languages missing from the generated table, and for a null API color. */
|
|
2
|
+
declare const DEFAULT_LANG_COLOR = "#858585";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a language's brand color from the generated table.
|
|
5
|
+
*
|
|
6
|
+
* @param name Language name as GitHub spells it.
|
|
7
|
+
* @returns The language's hex color, or the default gray when it is unknown.
|
|
8
|
+
*/
|
|
9
|
+
declare const getLanguageColor: (name: string) => string;
|
|
10
|
+
export { DEFAULT_LANG_COLOR, getLanguageColor };
|
|
11
|
+
//# sourceMappingURL=languageColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languageColors.d.ts","sourceRoot":"","sources":["../../src/common/languageColors.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,QAAA,MAAM,kBAAkB,YAAY,CAAC;AAKrC;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAExC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import languageColorsJson from "./languageColors.json" with { type: "json" };
|
|
2
|
+
/** Shown for languages missing from the generated table, and for a null API color. */
|
|
3
|
+
const DEFAULT_LANG_COLOR = "#858585";
|
|
4
|
+
// The generated JSON types has literal keys; index it as a plain lookup table.
|
|
5
|
+
const languageColors = languageColorsJson;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a language's brand color from the generated table.
|
|
8
|
+
*
|
|
9
|
+
* @param name Language name as GitHub spells it.
|
|
10
|
+
* @returns The language's hex color, or the default gray when it is unknown.
|
|
11
|
+
*/
|
|
12
|
+
const getLanguageColor = (name) => {
|
|
13
|
+
return languageColors[name] ?? DEFAULT_LANG_COLOR;
|
|
14
|
+
};
|
|
15
|
+
export { DEFAULT_LANG_COLOR, getLanguageColor };
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"Awk": "#c30e9b",
|
|
45
45
|
"B (Formal Method)": "#8aa8c5",
|
|
46
46
|
"B4X": "#00e4ff",
|
|
47
|
+
"BAML": "#a855f7",
|
|
47
48
|
"BASIC": "#ff0000",
|
|
48
49
|
"BQN": "#2b7067",
|
|
49
50
|
"Ballerina": "#FF5000",
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"Blade": "#f7523f",
|
|
59
60
|
"BlitzBasic": "#00FFAE",
|
|
60
61
|
"BlitzMax": "#cd6400",
|
|
62
|
+
"Blueprint": "#3584E4",
|
|
61
63
|
"Bluespec": "#12223c",
|
|
62
64
|
"Bluespec BH": "#12223c",
|
|
63
65
|
"Boo": "#d4bec1",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"Bru": "#F4AA41",
|
|
70
72
|
"BuildStream": "#006bff",
|
|
71
73
|
"C": "#555555",
|
|
72
|
-
"C#": "#
|
|
74
|
+
"C#": "#7355dd",
|
|
73
75
|
"C++": "#f34b7d",
|
|
74
76
|
"C3": "#2563eb",
|
|
75
77
|
"CAP CDS": "#0092d1",
|
|
@@ -210,6 +212,7 @@
|
|
|
210
212
|
"Glimmer JS": "#F5835F",
|
|
211
213
|
"Glimmer TS": "#3178c6",
|
|
212
214
|
"Glyph": "#c1ac7f",
|
|
215
|
+
"Gno": "#226c57",
|
|
213
216
|
"Gnuplot": "#f0a9f0",
|
|
214
217
|
"Go": "#00ADD8",
|
|
215
218
|
"Go Checksums": "#00ADD8",
|
|
@@ -227,6 +230,7 @@
|
|
|
227
230
|
"Graphviz (DOT)": "#2596be",
|
|
228
231
|
"Groovy": "#4298b8",
|
|
229
232
|
"Groovy Server Pages": "#4298b8",
|
|
233
|
+
"GtkRC": "#7fe719",
|
|
230
234
|
"HAProxy": "#106da9",
|
|
231
235
|
"HCL": "#844FBA",
|
|
232
236
|
"HIP": "#4F3A4F",
|
|
@@ -416,6 +420,7 @@
|
|
|
416
420
|
"OpenSCAD": "#e5cd45",
|
|
417
421
|
"Option List": "#476732",
|
|
418
422
|
"Org": "#77aa99",
|
|
423
|
+
"OverPy": "#78b355",
|
|
419
424
|
"OverpassQL": "#cce2aa",
|
|
420
425
|
"Oxygene": "#cdd0e3",
|
|
421
426
|
"Oz": "#fab738",
|
|
@@ -445,10 +450,12 @@
|
|
|
445
450
|
"Portugol": "#f8bd00",
|
|
446
451
|
"PostCSS": "#dc3a0c",
|
|
447
452
|
"PostScript": "#da291c",
|
|
453
|
+
"Power Query": "#d38e0d",
|
|
448
454
|
"PowerBuilder": "#8f0f8d",
|
|
449
455
|
"PowerShell": "#012456",
|
|
450
456
|
"Praat": "#c8506d",
|
|
451
457
|
"Prisma": "#0c344b",
|
|
458
|
+
"Pro*C": "#bb8368",
|
|
452
459
|
"Processing": "#0096D8",
|
|
453
460
|
"Procfile": "#3B2F63",
|
|
454
461
|
"Prolog": "#74283c",
|
|
@@ -490,6 +497,7 @@
|
|
|
490
497
|
"Rebol": "#358a5b",
|
|
491
498
|
"Record Jar": "#0673ba",
|
|
492
499
|
"Red": "#f50000",
|
|
500
|
+
"Redscript": "#f44336",
|
|
493
501
|
"Regular Expression": "#009a00",
|
|
494
502
|
"Ren'Py": "#ff7f7f",
|
|
495
503
|
"Rez": "#FFDAB3",
|
|
@@ -659,6 +667,7 @@
|
|
|
659
667
|
"nanorc": "#2d004d",
|
|
660
668
|
"nesC": "#94B0C7",
|
|
661
669
|
"ooc": "#b0b77e",
|
|
670
|
+
"pkg-config": "#2b5e82",
|
|
662
671
|
"q": "#0040cd",
|
|
663
672
|
"reStructuredText": "#141414",
|
|
664
673
|
"sed": "#64b970",
|
package/build/common/ops.d.ts
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
|
+
import type { RepositoryAffiliation } from "../graphql/generated/common.js";
|
|
1
2
|
/**
|
|
2
3
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
3
4
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @returns
|
|
5
|
+
* @param value The value to parse.
|
|
6
|
+
* @returns The parsed value.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
declare const parseBoolean: (value: string | boolean) => boolean | undefined;
|
|
8
9
|
/**
|
|
9
10
|
* Parse string to array of strings.
|
|
10
11
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @returns
|
|
12
|
+
* @param str The string to parse.
|
|
13
|
+
* @returns The array of strings.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
declare const parseArray: (str: string) => Array<string>;
|
|
15
16
|
/**
|
|
16
17
|
* Clamp the given number between the given range.
|
|
17
18
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
19
|
+
* @param number The number to clamp.
|
|
20
|
+
* @param min The minimum value.
|
|
21
|
+
* @param max The maximum value.
|
|
22
|
+
* @returns The clamped number.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
declare const clampValue: (number: string | number, min: number, max: number) => number;
|
|
24
25
|
/**
|
|
25
26
|
* Lowercase and trim string.
|
|
26
27
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
28
|
+
* @param name String to lowercase and trim.
|
|
29
|
+
* @returns Lowercased and trimmed string.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
declare const lowercaseTrim: (name: string) => string;
|
|
31
32
|
/**
|
|
32
33
|
* Split array of languages in two columns.
|
|
33
34
|
*
|
|
34
35
|
* @template T Language object.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @returns
|
|
36
|
+
* @param arr Array of languages.
|
|
37
|
+
* @param perChunk Number of languages per column.
|
|
38
|
+
* @returns Array of languages split in two columns.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
declare const chunkArray: <T>(arr: Array<T>, perChunk: number) => Array<Array<T>>;
|
|
40
41
|
/**
|
|
41
42
|
* Parse emoji from string.
|
|
42
43
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
44
|
+
* @param str String to parse emoji from.
|
|
45
|
+
* @returns String with emoji parsed.
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get diff in minutes between two dates.
|
|
49
|
-
*
|
|
50
|
-
* @param {Date} d1 First date.
|
|
51
|
-
* @param {Date} d2 Second date.
|
|
52
|
-
* @returns {number} Number of minutes between the two dates.
|
|
53
|
-
*/
|
|
54
|
-
export function dateDiff(d1: Date, d2: Date): number;
|
|
47
|
+
declare const parseEmojis: (str: string) => string;
|
|
55
48
|
/**
|
|
56
49
|
* Parse owner affiliations.
|
|
57
50
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
51
|
+
* @param affiliations input affiliations to be parsed.
|
|
52
|
+
* @returns Parsed affiliations.
|
|
60
53
|
*
|
|
61
54
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
62
55
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
declare const parseOwnerAffiliations: (affiliations: Array<string>) => Array<RepositoryAffiliation>;
|
|
57
|
+
declare const buildSearchFilter: (repos?: Array<string> | string, owners?: Array<string> | string) => string;
|
|
58
|
+
export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis, parseOwnerAffiliations, buildSearchFilter, };
|
|
65
59
|
//# sourceMappingURL=ops.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/common/ops.
|
|
1
|
+
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/common/ops.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAK5E;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,OAAO,KAAG,OAAO,GAAG,SAazD,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,KAAK,CAAC,MAAM,CAK7C,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,GACd,QAAQ,MAAM,GAAG,MAAM,EACvB,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAKF,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAmC,CAAC;AAE1E;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,GAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAQtE,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAOlC,CAAC;AAKF;;;;;;;GAOG;AACH,QAAA,MAAM,sBAAsB,GAC1B,cAAc,KAAK,CAAC,MAAM,CAAC,KAC1B,KAAK,CAAC,qBAAqB,CAiB7B,CAAC;AAEF,QAAA,MAAM,iBAAiB,GACrB,QAAO,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,EAClC,SAAQ,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,KAClC,MAUF,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,iBAAiB,GAClB,CAAC"}
|
package/build/common/ops.js
CHANGED
|
@@ -4,8 +4,8 @@ import { CustomError } from "./error.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @returns
|
|
7
|
+
* @param value The value to parse.
|
|
8
|
+
* @returns The parsed value.
|
|
9
9
|
*/
|
|
10
10
|
const parseBoolean = (value) => {
|
|
11
11
|
if (typeof value === "boolean") {
|
|
@@ -24,8 +24,8 @@ const parseBoolean = (value) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Parse string to array of strings.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
27
|
+
* @param str The string to parse.
|
|
28
|
+
* @returns The array of strings.
|
|
29
29
|
*/
|
|
30
30
|
const parseArray = (str) => {
|
|
31
31
|
if (!str) {
|
|
@@ -36,50 +36,46 @@ const parseArray = (str) => {
|
|
|
36
36
|
/**
|
|
37
37
|
* Clamp the given number between the given range.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
39
|
+
* @param number The number to clamp.
|
|
40
|
+
* @param min The minimum value.
|
|
41
|
+
* @param max The maximum value.
|
|
42
|
+
* @returns The clamped number.
|
|
43
43
|
*/
|
|
44
44
|
const clampValue = (number, min, max) => {
|
|
45
|
-
|
|
46
|
-
if (Number.isNaN(parseInt(number, 10))) {
|
|
45
|
+
if (Number.isNaN(parseInt(String(number), 10))) {
|
|
47
46
|
return min;
|
|
48
47
|
}
|
|
49
|
-
return Math.max(min, Math.min(number, max));
|
|
48
|
+
return Math.max(min, Math.min(Number(number), max));
|
|
50
49
|
};
|
|
51
50
|
/**
|
|
52
51
|
* Lowercase and trim string.
|
|
53
52
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
53
|
+
* @param name String to lowercase and trim.
|
|
54
|
+
* @returns Lowercased and trimmed string.
|
|
56
55
|
*/
|
|
57
56
|
const lowercaseTrim = (name) => name.toLowerCase().trim();
|
|
58
57
|
/**
|
|
59
58
|
* Split array of languages in two columns.
|
|
60
59
|
*
|
|
61
60
|
* @template T Language object.
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @returns
|
|
61
|
+
* @param arr Array of languages.
|
|
62
|
+
* @param perChunk Number of languages per column.
|
|
63
|
+
* @returns Array of languages split in two columns.
|
|
65
64
|
*/
|
|
66
65
|
const chunkArray = (arr, perChunk) => {
|
|
67
66
|
return arr.reduce((resultArray, item, index) => {
|
|
68
67
|
const chunkIndex = Math.floor(index / perChunk);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
resultArray[chunkIndex].push(item);
|
|
68
|
+
const chunk = resultArray[chunkIndex] ?? [];
|
|
69
|
+
chunk.push(item);
|
|
70
|
+
resultArray[chunkIndex] = chunk;
|
|
75
71
|
return resultArray;
|
|
76
72
|
}, []);
|
|
77
73
|
};
|
|
78
74
|
/**
|
|
79
75
|
* Parse emoji from string.
|
|
80
76
|
*
|
|
81
|
-
* @param
|
|
82
|
-
* @returns
|
|
77
|
+
* @param str String to parse emoji from.
|
|
78
|
+
* @returns String with emoji parsed.
|
|
83
79
|
*/
|
|
84
80
|
const parseEmojis = (str) => {
|
|
85
81
|
if (!str) {
|
|
@@ -89,24 +85,12 @@ const parseEmojis = (str) => {
|
|
|
89
85
|
return toEmoji.get(emoji) || "";
|
|
90
86
|
});
|
|
91
87
|
};
|
|
92
|
-
|
|
93
|
-
* Get diff in minutes between two dates.
|
|
94
|
-
*
|
|
95
|
-
* @param {Date} d1 First date.
|
|
96
|
-
* @param {Date} d2 Second date.
|
|
97
|
-
* @returns {number} Number of minutes between the two dates.
|
|
98
|
-
*/
|
|
99
|
-
const dateDiff = (d1, d2) => {
|
|
100
|
-
const date1 = new Date(d1);
|
|
101
|
-
const date2 = new Date(d2);
|
|
102
|
-
const diff = date1.getTime() - date2.getTime();
|
|
103
|
-
return Math.round(diff / (1000 * 60));
|
|
104
|
-
};
|
|
88
|
+
const isOwnerAffiliation = (value) => OWNER_AFFILIATIONS.some((affiliation) => affiliation === value);
|
|
105
89
|
/**
|
|
106
90
|
* Parse owner affiliations.
|
|
107
91
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @returns
|
|
92
|
+
* @param affiliations input affiliations to be parsed.
|
|
93
|
+
* @returns Parsed affiliations.
|
|
110
94
|
*
|
|
111
95
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
112
96
|
*/
|
|
@@ -114,23 +98,22 @@ const parseOwnerAffiliations = (affiliations) => {
|
|
|
114
98
|
// Set default value for ownerAffiliations.
|
|
115
99
|
// NOTE: Done here since parseArray() will always return an empty array even nothing
|
|
116
100
|
//was specified.
|
|
117
|
-
affiliations
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: ["OWNER"];
|
|
101
|
+
const normalized = affiliations.length > 0
|
|
102
|
+
? affiliations.map((affiliation) => affiliation.toUpperCase())
|
|
103
|
+
: ["OWNER"];
|
|
121
104
|
// Check if ownerAffiliations contains valid values.
|
|
122
|
-
if (
|
|
105
|
+
if (!normalized.every(isOwnerAffiliation)) {
|
|
123
106
|
throw new CustomError("Invalid query parameter", CustomError.INVALID_AFFILIATION);
|
|
124
107
|
}
|
|
125
|
-
return
|
|
108
|
+
return normalized;
|
|
126
109
|
};
|
|
127
110
|
const buildSearchFilter = (repos = [], owners = []) => {
|
|
128
|
-
|
|
111
|
+
const repoFilter = Array.isArray(repos) && repos.length > 0
|
|
129
112
|
? repos.map((r) => `repo:${r} `).join("")
|
|
130
113
|
: "";
|
|
131
|
-
|
|
114
|
+
const orgFilter = Array.isArray(owners) && owners.length > 0
|
|
132
115
|
? owners.map((o) => `owner:${o} `).join("")
|
|
133
116
|
: "";
|
|
134
117
|
return repoFilter + orgFilter;
|
|
135
118
|
};
|
|
136
|
-
export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis,
|
|
119
|
+
export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis, parseOwnerAffiliations, buildSearchFilter, };
|