@stats-forge/github-stats-forge-core 0.1.0 → 0.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/contributed-to.d.ts +23 -0
- package/build/api/contributed-to.d.ts.map +1 -0
- package/build/api/contributed-to.js +43 -0
- package/build/api/gist.d.ts +8 -15
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +14 -29
- package/build/api/handler.d.ts +16 -0
- package/build/api/handler.d.ts.map +1 -0
- package/build/api/handler.js +29 -0
- package/build/api/index.d.ts +1 -0
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +1 -0
- package/build/api/params.d.ts +11 -5
- package/build/api/params.d.ts.map +1 -1
- package/build/api/params.js +26 -6
- package/build/api/pin.d.ts +11 -15
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +34 -46
- package/build/api/stats.d.ts +15 -22
- package/build/api/stats.d.ts.map +1 -1
- package/build/api/stats.js +59 -72
- package/build/api/top-langs.d.ts +11 -22
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +34 -51
- package/build/api/wakatime.d.ts +10 -24
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +27 -47
- package/build/cards/contributed-to.d.ts +19 -0
- package/build/cards/contributed-to.d.ts.map +1 -0
- package/build/cards/contributed-to.js +242 -0
- package/build/cards/gist.d.ts +1 -0
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +13 -9
- package/build/cards/repo.d.ts +12 -1
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +40 -18
- package/build/cards/stats.d.ts +15 -3
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +91 -76
- package/build/cards/top-languages.d.ts +13 -2
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +26 -9
- package/build/cards/wakatime.d.ts +13 -2
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +22 -9
- package/build/common/Card.d.ts +9 -0
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +44 -9
- package/build/common/I18n.d.ts +1 -1
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +4 -2
- package/build/common/brand.d.ts +76 -0
- package/build/common/brand.d.ts.map +1 -0
- package/build/common/brand.js +73 -0
- package/build/common/constants.d.ts +3 -1
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +3 -1
- package/build/common/date.d.ts +50 -3
- package/build/common/date.d.ts.map +1 -1
- package/build/common/date.js +104 -2
- package/build/common/icons.d.ts +4 -2
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +10 -5
- package/build/common/ops.d.ts +8 -3
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +8 -14
- package/build/common/render.d.ts +7 -1
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +60 -58
- package/build/fetchers/contributed-to.d.ts +62 -0
- package/build/fetchers/contributed-to.d.ts.map +1 -0
- package/build/fetchers/contributed-to.js +184 -0
- package/build/fetchers/graphql-error.d.ts +13 -0
- package/build/fetchers/graphql-error.d.ts.map +1 -0
- package/build/fetchers/graphql-error.js +29 -0
- package/build/fetchers/index.d.ts +2 -1
- package/build/fetchers/index.d.ts.map +1 -1
- package/build/fetchers/index.js +1 -0
- package/build/fetchers/stats.d.ts +14 -8
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +72 -195
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +3 -18
- package/build/fetchers/types.d.ts +24 -0
- package/build/fetchers/types.d.ts.map +1 -1
- package/build/graphql/contributionsCollection.d.ts +9 -0
- package/build/graphql/contributionsCollection.d.ts.map +1 -0
- package/build/graphql/contributionsCollection.js +12 -0
- package/build/graphql/contributionsDocument.d.ts +5 -5
- package/build/graphql/contributionsDocument.d.ts.map +1 -1
- package/build/graphql/contributionsDocument.js +8 -15
- package/build/graphql/generated/contributed-to.d.ts +22 -0
- package/build/graphql/generated/contributed-to.d.ts.map +1 -0
- package/build/graphql/generated/contributed-to.js +11 -0
- package/build/graphql/generated/stats.d.ts +13 -1
- package/build/graphql/generated/stats.d.ts.map +1 -1
- package/build/graphql/generated/stats.js +2 -2
- package/build/graphql/graphqlDocument.d.ts +1 -1
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
- package/build/graphql/reposContributedToDocument.js +11 -5
- package/build/translations.d.ts +64 -1
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +65 -1
- package/package.json +1 -1
- package/src/api/contributed-to.ts +84 -0
- package/src/api/gist.ts +20 -37
- package/src/api/handler.ts +42 -0
- package/src/api/index.ts +1 -0
- package/src/api/params.ts +48 -9
- package/src/api/pin.ts +33 -45
- package/src/api/stats.ts +78 -89
- package/src/api/top-langs.ts +34 -56
- package/src/api/wakatime.ts +33 -54
- package/src/cards/contributed-to.ts +373 -0
- package/src/cards/gist.ts +17 -8
- package/src/cards/repo.ts +44 -20
- package/src/cards/stats.ts +119 -90
- package/src/cards/top-languages.ts +27 -18
- package/src/cards/wakatime.ts +23 -13
- package/src/common/Card.ts +56 -11
- package/src/common/I18n.ts +4 -2
- package/src/common/brand.ts +109 -0
- package/src/common/constants.ts +4 -1
- package/src/common/date.ts +135 -3
- package/src/common/icons.ts +10 -5
- package/src/common/ops.ts +10 -19
- package/src/common/render.ts +65 -62
- package/src/fetchers/contributed-to.ts +271 -0
- package/src/fetchers/graphql-error.ts +36 -0
- package/src/fetchers/index.ts +3 -0
- package/src/fetchers/stats.ts +123 -274
- package/src/fetchers/top-languages.ts +5 -19
- package/src/fetchers/types.ts +26 -0
- package/src/graphql/contributionsCollection.ts +18 -0
- package/src/graphql/contributionsDocument.ts +11 -18
- package/src/graphql/generated/contributed-to.ts +25 -0
- package/src/graphql/generated/stats.ts +19 -6
- package/src/graphql/graphqlDocument.ts +1 -1
- package/src/graphql/queries/contributed-to.graphql +8 -0
- package/src/graphql/queries/stats.graphql +14 -2
- package/src/graphql/reposContributedToDocument.ts +11 -9
- package/src/translations.ts +77 -0
package/build/api/stats.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import {
|
|
2
|
+
import { renderStatsCard } from '../cards/stats.js';
|
|
3
|
+
import { OWNER_AFFILIATIONS } from '../common/constants.js';
|
|
3
4
|
import { fetchStats } from '../fetchers/stats.js';
|
|
4
|
-
import {
|
|
5
|
-
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam,
|
|
5
|
+
import { cardHandler } from './handler.js';
|
|
6
|
+
import { booleanParam, enumParam, fromParam, listParam, localeParam, looseIntParam, numberParam, ORDERED_RANGE, rawParam, safeListParam, toParam, usernameParam, } from './params.js';
|
|
6
7
|
/** What the stats endpoint accepts, on top of the shared color params. */
|
|
7
|
-
const statsQuery = z
|
|
8
|
+
const statsQuery = z
|
|
9
|
+
.object({
|
|
8
10
|
username: usernameParam,
|
|
9
11
|
repo: safeListParam,
|
|
10
12
|
owner: safeListParam,
|
|
@@ -15,7 +17,8 @@ const statsQuery = z.object({
|
|
|
15
17
|
hide_rank: booleanParam,
|
|
16
18
|
show_icons: booleanParam,
|
|
17
19
|
include_all_commits: booleanParam,
|
|
18
|
-
|
|
20
|
+
from: fromParam,
|
|
21
|
+
to: toParam,
|
|
19
22
|
line_height: rawParam,
|
|
20
23
|
text_bold: booleanParam,
|
|
21
24
|
exclude_repo: listParam,
|
|
@@ -26,81 +29,65 @@ const statsQuery = z.object({
|
|
|
26
29
|
number_format: rawParam,
|
|
27
30
|
role: listParam,
|
|
28
31
|
number_precision: looseIntParam,
|
|
29
|
-
rank_icon: enumParam(
|
|
32
|
+
rank_icon: enumParam(renderStatsCard.OPTIONS.rank_icon),
|
|
30
33
|
show: listParam,
|
|
31
34
|
contribs_include_own_repos: booleanParam,
|
|
32
|
-
})
|
|
35
|
+
})
|
|
36
|
+
.check(ORDERED_RANGE);
|
|
33
37
|
/**
|
|
34
38
|
* Render the stats card for a set of query params.
|
|
35
39
|
*
|
|
36
40
|
* @returns The rendered card, or a rendered error.
|
|
37
41
|
*/
|
|
38
|
-
const renderStats = async (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
line_height,
|
|
84
|
-
text_bold,
|
|
85
|
-
custom_title,
|
|
86
|
-
border_radius,
|
|
87
|
-
number_format,
|
|
88
|
-
number_precision,
|
|
89
|
-
locale,
|
|
90
|
-
disable_animations,
|
|
91
|
-
rank_icon,
|
|
92
|
-
show,
|
|
93
|
-
}, username, repository, owner),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
return errorResult(error, colors);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
42
|
+
const renderStats = cardHandler(statsQuery, async ({ username, repo, owner, hide, hide_title, hide_border, card_width, hide_rank, show_icons, include_all_commits, from, to, line_height, text_bold, exclude_repo, custom_title, locale, disable_animations, border_radius, number_format, role, number_precision, rank_icon, show, contribs_include_own_repos, }, colors, config) => {
|
|
43
|
+
// A bare repo name is scoped to the user whose card this is.
|
|
44
|
+
const repository = repo.map((name) => name.includes('/') ? name : `${username ?? ''}/${name}`);
|
|
45
|
+
const stats = await fetchStats({
|
|
46
|
+
username,
|
|
47
|
+
include_all_commits,
|
|
48
|
+
exclude_repo,
|
|
49
|
+
include_merged_pull_requests: show.includes('prs_merged') || show.includes('prs_merged_percentage'),
|
|
50
|
+
include_discussions: show.includes('discussions_started'),
|
|
51
|
+
include_discussions_answers: show.includes('discussions_answered'),
|
|
52
|
+
from,
|
|
53
|
+
to,
|
|
54
|
+
repo: repository,
|
|
55
|
+
owner,
|
|
56
|
+
include_prs_authored: show.includes('prs_authored'),
|
|
57
|
+
include_prs_commented: show.includes('prs_commented'),
|
|
58
|
+
include_prs_reviewed: show.includes('prs_reviewed'),
|
|
59
|
+
include_issues_authored: show.includes('issues_authored'),
|
|
60
|
+
include_issues_commented: show.includes('issues_commented'),
|
|
61
|
+
ownerAffiliations: role,
|
|
62
|
+
include_contributions: show.includes('contributions'),
|
|
63
|
+
include_all_time_contribs: show.includes('all_time_contribs'),
|
|
64
|
+
contribs_include_own_repos,
|
|
65
|
+
}, config);
|
|
66
|
+
return renderStatsCard(stats, {
|
|
67
|
+
...colors,
|
|
68
|
+
hide,
|
|
69
|
+
show_icons,
|
|
70
|
+
hide_title,
|
|
71
|
+
hide_border,
|
|
72
|
+
card_width,
|
|
73
|
+
hide_rank,
|
|
74
|
+
include_all_commits,
|
|
75
|
+
line_height,
|
|
76
|
+
text_bold,
|
|
77
|
+
custom_title,
|
|
78
|
+
border_radius,
|
|
79
|
+
number_format,
|
|
80
|
+
number_precision,
|
|
81
|
+
locale,
|
|
82
|
+
disable_animations,
|
|
83
|
+
rank_icon,
|
|
84
|
+
show,
|
|
85
|
+
}, username, repository, owner);
|
|
86
|
+
});
|
|
100
87
|
/**
|
|
101
|
-
* The card,
|
|
102
|
-
* A UI reads them off the function it calls
|
|
88
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
89
|
+
* A UI reads them off the function it calls: `stats.OPTIONS.rank_icon`.
|
|
103
90
|
*/
|
|
104
91
|
export const stats = Object.assign(renderStats, {
|
|
105
|
-
|
|
92
|
+
OPTIONS: { ...renderStatsCard.OPTIONS, role: OWNER_AFFILIATIONS },
|
|
106
93
|
});
|
package/build/api/top-langs.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const
|
|
2
|
+
/**
|
|
3
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
4
|
+
* A UI reads them off the function it calls: `topLangs.OPTIONS.layout`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const topLangs: ((query: import("./params.ts").ApiQuery<z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
8
8
|
hide: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
|
|
9
9
|
hide_title: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
@@ -22,22 +22,11 @@ declare const topLangsQuery: z.ZodMiniObject<{
|
|
|
22
22
|
hide_progress: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
23
23
|
hide_values: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
24
24
|
stats_format: z.ZodMiniType<"bytes" | "percentages" | undefined, string | undefined, z.core.$ZodTypeInternals<"bytes" | "percentages" | undefined, string | undefined>>;
|
|
25
|
-
}, z.core.$strip
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @returns The rendered card, or a rendered error.
|
|
32
|
-
*/
|
|
33
|
-
declare const renderTopLangs: (query: TopLangsApiQuery, config: CardConfig) => Promise<ApiResult>;
|
|
34
|
-
/**
|
|
35
|
-
* The card, with the values its enum params accept.
|
|
36
|
-
* A UI reads them off the function it calls, e.g. `topLangs.LAYOUTS`.
|
|
37
|
-
*/
|
|
38
|
-
export declare const topLangs: typeof renderTopLangs & {
|
|
39
|
-
LAYOUTS: readonly ["compact", "normal", "donut", "donut-vertical", "pie"];
|
|
40
|
-
STATS_FORMATS: readonly ["percentages", "bytes"];
|
|
25
|
+
}, z.core.$strip>>, config: import("./index.ts").CardConfig) => Promise<import("./api-result.ts").ApiResult>) & {
|
|
26
|
+
OPTIONS: {
|
|
27
|
+
layout: readonly ["compact", "normal", "donut", "donut-vertical", "pie"];
|
|
28
|
+
stats_format: readonly ["percentages", "bytes"];
|
|
29
|
+
role: import("../graphql/generated/common.ts").RepositoryAffiliation[];
|
|
30
|
+
};
|
|
41
31
|
};
|
|
42
|
-
export {};
|
|
43
32
|
//# sourceMappingURL=top-langs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"top-langs.d.ts","sourceRoot":"","sources":["../../src/api/top-langs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"top-langs.d.ts","sourceRoot":"","sources":["../../src/api/top-langs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAqG9B;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;CAEnB,CAAC"}
|
package/build/api/top-langs.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import {
|
|
2
|
+
import { renderTopLanguages } from '../cards/top-languages.js';
|
|
3
|
+
import { OWNER_AFFILIATIONS } from '../common/constants.js';
|
|
3
4
|
import { fetchTopLanguages } from '../fetchers/top-languages.js';
|
|
4
|
-
import {
|
|
5
|
-
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam,
|
|
5
|
+
import { cardHandler } from './handler.js';
|
|
6
|
+
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, rawParam, usernameParam, } from './params.js';
|
|
6
7
|
/** What the top-languages endpoint accepts, on top of the shared color params. */
|
|
7
8
|
const topLangsQuery = z.object({
|
|
8
9
|
username: usernameParam,
|
|
@@ -10,7 +11,7 @@ const topLangsQuery = z.object({
|
|
|
10
11
|
hide_title: booleanParam,
|
|
11
12
|
hide_border: booleanParam,
|
|
12
13
|
card_width: looseIntParam,
|
|
13
|
-
layout: enumParam(
|
|
14
|
+
layout: enumParam(renderTopLanguages.OPTIONS.layout),
|
|
14
15
|
langs_count: looseIntParam,
|
|
15
16
|
exclude_repo: listParam,
|
|
16
17
|
size_weight: numberParam,
|
|
@@ -22,60 +23,42 @@ const topLangsQuery = z.object({
|
|
|
22
23
|
disable_animations: booleanParam,
|
|
23
24
|
hide_progress: booleanParam,
|
|
24
25
|
hide_values: booleanParam,
|
|
25
|
-
stats_format: enumParam(
|
|
26
|
+
stats_format: enumParam(renderTopLanguages.OPTIONS.stats_format),
|
|
26
27
|
});
|
|
27
28
|
/**
|
|
28
29
|
* Render the top languages card for a set of query params.
|
|
29
30
|
*
|
|
30
31
|
* @returns The rendered card, or a rendered error.
|
|
31
32
|
*/
|
|
32
|
-
const renderTopLangs = async (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
card_width,
|
|
58
|
-
hide,
|
|
59
|
-
layout,
|
|
60
|
-
langs_count,
|
|
61
|
-
border_radius,
|
|
62
|
-
locale,
|
|
63
|
-
disable_animations,
|
|
64
|
-
hide_progress,
|
|
65
|
-
hide_values,
|
|
66
|
-
stats_format,
|
|
67
|
-
}),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
return errorResult(error, colors);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
33
|
+
const renderTopLangs = cardHandler(topLangsQuery, async ({ username, hide, hide_title, hide_border, card_width, layout, langs_count, exclude_repo, size_weight, count_weight, custom_title, locale, border_radius, role, disable_animations, hide_progress, hide_values, stats_format, }, colors, config) => {
|
|
34
|
+
const topLangs = await fetchTopLanguages({
|
|
35
|
+
username,
|
|
36
|
+
exclude_repo,
|
|
37
|
+
size_weight,
|
|
38
|
+
count_weight,
|
|
39
|
+
ownerAffiliations: role,
|
|
40
|
+
}, config);
|
|
41
|
+
return renderTopLanguages(topLangs, {
|
|
42
|
+
...colors,
|
|
43
|
+
custom_title,
|
|
44
|
+
hide_title,
|
|
45
|
+
hide_border,
|
|
46
|
+
card_width,
|
|
47
|
+
hide,
|
|
48
|
+
layout,
|
|
49
|
+
langs_count,
|
|
50
|
+
border_radius,
|
|
51
|
+
locale,
|
|
52
|
+
disable_animations,
|
|
53
|
+
hide_progress,
|
|
54
|
+
hide_values,
|
|
55
|
+
stats_format,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
74
58
|
/**
|
|
75
|
-
* The card,
|
|
76
|
-
* A UI reads them off the function it calls
|
|
59
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
60
|
+
* A UI reads them off the function it calls: `topLangs.OPTIONS.layout`.
|
|
77
61
|
*/
|
|
78
62
|
export const topLangs = Object.assign(renderTopLangs, {
|
|
79
|
-
|
|
80
|
-
STATS_FORMATS: TOP_LANG_STATS_FORMATS,
|
|
63
|
+
OPTIONS: { ...renderTopLanguages.OPTIONS, role: OWNER_AFFILIATIONS },
|
|
81
64
|
});
|
package/build/api/wakatime.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const
|
|
2
|
+
/**
|
|
3
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
4
|
+
* A UI reads them off the function it calls: `wakatime.OPTIONS.layout`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const wakatime: ((query: import("./params.ts").ApiQuery<z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
8
8
|
hide_border: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
9
9
|
card_width: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
|
|
@@ -19,24 +19,10 @@ declare const wakatimeQuery: z.ZodMiniObject<{
|
|
|
19
19
|
border_radius: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
|
|
20
20
|
display_format: z.ZodMiniType<"percent" | "time" | undefined, string | undefined, z.core.$ZodTypeInternals<"percent" | "time" | undefined, string | undefined>>;
|
|
21
21
|
disable_animations: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
22
|
-
}, z.core.$strip
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* WakaTime needs no GitHub token, so the config is read only for the transport it carries.
|
|
29
|
-
*
|
|
30
|
-
* @returns The rendered card, or a rendered error.
|
|
31
|
-
*/
|
|
32
|
-
declare const renderWakatime: (query: WakatimeApiQuery, config: CardConfig) => Promise<ApiResult>;
|
|
33
|
-
/**
|
|
34
|
-
* The card, with the values its enum params accept.
|
|
35
|
-
* A UI reads them off the function it calls, e.g. `wakatime.LAYOUTS`.
|
|
36
|
-
*/
|
|
37
|
-
export declare const wakatime: typeof renderWakatime & {
|
|
38
|
-
LAYOUTS: readonly ["compact", "normal"];
|
|
39
|
-
DISPLAY_FORMATS: readonly ["time", "percent"];
|
|
22
|
+
}, z.core.$strip>>, config: import("./index.ts").CardConfig) => Promise<import("./api-result.ts").ApiResult>) & {
|
|
23
|
+
OPTIONS: {
|
|
24
|
+
layout: readonly ["compact", "normal"];
|
|
25
|
+
display_format: readonly ["time", "percent"];
|
|
26
|
+
};
|
|
40
27
|
};
|
|
41
|
-
export {};
|
|
42
28
|
//# sourceMappingURL=wakatime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/api/wakatime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/api/wakatime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAuF9B;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;CAAyE,CAAC"}
|
package/build/api/wakatime.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import {
|
|
2
|
+
import { renderWakatimeCard } from '../cards/wakatime.js';
|
|
3
3
|
import { fetchWakatimeStats } from '../fetchers/wakatime.js';
|
|
4
|
-
import {
|
|
5
|
-
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam,
|
|
4
|
+
import { cardHandler } from './handler.js';
|
|
5
|
+
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, rawParam, safeParam, } from './params.js';
|
|
6
6
|
/** What the wakatime endpoint accepts, on top of the shared color params. */
|
|
7
7
|
const wakatimeQuery = z.object({
|
|
8
8
|
username: safeParam,
|
|
@@ -13,12 +13,12 @@ const wakatimeQuery = z.object({
|
|
|
13
13
|
hide_progress: booleanParam,
|
|
14
14
|
custom_title: rawParam,
|
|
15
15
|
locale: localeParam,
|
|
16
|
-
layout: enumParam(
|
|
16
|
+
layout: enumParam(renderWakatimeCard.OPTIONS.layout),
|
|
17
17
|
langs_count: looseIntParam,
|
|
18
18
|
hide: listParam,
|
|
19
19
|
api_domain: rawParam,
|
|
20
20
|
border_radius: numberParam,
|
|
21
|
-
display_format: enumParam(
|
|
21
|
+
display_format: enumParam(renderWakatimeCard.OPTIONS.display_format),
|
|
22
22
|
disable_animations: booleanParam,
|
|
23
23
|
});
|
|
24
24
|
/**
|
|
@@ -28,47 +28,27 @@ const wakatimeQuery = z.object({
|
|
|
28
28
|
*
|
|
29
29
|
* @returns The rendered card, or a rendered error.
|
|
30
30
|
*/
|
|
31
|
-
const renderWakatime = async (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
colors
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
card_width,
|
|
51
|
-
hide,
|
|
52
|
-
line_height,
|
|
53
|
-
hide_progress,
|
|
54
|
-
border_radius,
|
|
55
|
-
locale,
|
|
56
|
-
layout,
|
|
57
|
-
langs_count,
|
|
58
|
-
display_format,
|
|
59
|
-
disable_animations,
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
return errorResult(error, colors);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
31
|
+
const renderWakatime = cardHandler(wakatimeQuery, async ({ username, hide_border, card_width, line_height, hide_title, hide_progress, custom_title, locale, layout, langs_count, hide, api_domain, border_radius, display_format, disable_animations, }, colors, config) => {
|
|
32
|
+
const stats = await fetchWakatimeStats({ username, api_domain }, config);
|
|
33
|
+
return renderWakatimeCard(stats, {
|
|
34
|
+
...colors,
|
|
35
|
+
custom_title,
|
|
36
|
+
hide_title,
|
|
37
|
+
hide_border,
|
|
38
|
+
card_width,
|
|
39
|
+
hide,
|
|
40
|
+
line_height,
|
|
41
|
+
hide_progress,
|
|
42
|
+
border_radius,
|
|
43
|
+
locale,
|
|
44
|
+
layout,
|
|
45
|
+
langs_count,
|
|
46
|
+
display_format,
|
|
47
|
+
disable_animations,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
67
50
|
/**
|
|
68
|
-
* The card,
|
|
69
|
-
* A UI reads them off the function it calls
|
|
51
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
52
|
+
* A UI reads them off the function it calls: `wakatime.OPTIONS.layout`.
|
|
70
53
|
*/
|
|
71
|
-
export const wakatime = Object.assign(renderWakatime, {
|
|
72
|
-
LAYOUTS: WAKATIME_LAYOUTS,
|
|
73
|
-
DISPLAY_FORMATS,
|
|
74
|
-
});
|
|
54
|
+
export const wakatime = Object.assign(renderWakatime, { OPTIONS: renderWakatimeCard.OPTIONS });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ContributedToData } from '../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from './options.ts';
|
|
3
|
+
declare const MIN_CARD_WIDTH = 340;
|
|
4
|
+
interface ContributedToCardOptions extends CommonCardOptions {
|
|
5
|
+
locale: string;
|
|
6
|
+
hide_title: boolean;
|
|
7
|
+
card_width: number;
|
|
8
|
+
custom_title: string;
|
|
9
|
+
disable_animations: boolean;
|
|
10
|
+
hide_years: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Renders the repositories a user contributed to, ranked by contributions.
|
|
14
|
+
*
|
|
15
|
+
* @returns Contributed-to card SVG string.
|
|
16
|
+
*/
|
|
17
|
+
declare const renderContributedToCard: (data: ContributedToData, options?: CardOptions<ContributedToCardOptions>) => string;
|
|
18
|
+
export { renderContributedToCard, MIN_CARD_WIDTH };
|
|
19
|
+
//# sourceMappingURL=contributed-to.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contributed-to.d.ts","sourceRoot":"","sources":["../../src/cards/contributed-to.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK/E,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGnE,QAAA,MAAM,cAAc,MAAM,CAAC;AA8B3B,UAAU,wBAAyB,SAAQ,iBAAiB;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB;AAmKD;;;;GAIG;AACH,QAAA,MAAM,uBAAuB,SACrB,iBAAiB,YACd,WAAW,CAAC,wBAAwB,CAAC,KAC7C,MAkJF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC"}
|