@stats-forge/github-stats-forge-core 0.0.2 → 0.1.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/README.md +0 -10
- package/build/api/api-result.d.ts +6 -7
- package/build/api/api-result.d.ts.map +1 -1
- package/build/api/api-result.js +4 -5
- package/build/api/gist.d.ts +3 -10
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +4 -11
- package/build/api/index.d.ts +12 -12
- package/build/api/params.d.ts +11 -8
- package/build/api/params.d.ts.map +1 -1
- package/build/api/params.js +16 -14
- package/build/api/pin.d.ts +3 -19
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +6 -22
- package/build/api/stats.d.ts +10 -4
- package/build/api/stats.d.ts.map +1 -1
- package/build/api/stats.js +6 -32
- package/build/api/top-langs.d.ts +12 -6
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +6 -26
- package/build/api/wakatime.d.ts +13 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +4 -21
- package/build/calculateRank.d.ts +0 -9
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +12 -17
- package/build/cards/gist.d.ts +2 -4
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +27 -36
- package/build/cards/options.d.ts +1 -1
- package/build/cards/repo.d.ts +2 -4
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +61 -93
- package/build/cards/stats.d.ts +3 -8
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +119 -165
- package/build/cards/top-languages.d.ts +5 -31
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +176 -384
- package/build/cards/wakatime.d.ts +4 -6
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +118 -185
- package/build/common/Card.d.ts +14 -62
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +97 -199
- package/build/common/I18n.d.ts +0 -6
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +3 -6
- package/build/common/color.d.ts +4 -17
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +67 -49
- package/build/common/config.d.ts +4 -14
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +3 -16
- package/build/common/constants.d.ts +4 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +3 -1
- package/build/common/date.d.ts +0 -2
- package/build/common/date.d.ts.map +1 -1
- package/build/common/date.js +0 -2
- package/build/common/emojiMap.d.ts +8 -0
- package/build/common/emojiMap.d.ts.map +1 -0
- package/build/common/emojiMap.js +10 -0
- package/build/common/emojiMap.json +1915 -0
- package/build/common/error.d.ts +1 -10
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +1 -10
- package/build/common/fmt.d.ts +3 -15
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +7 -35
- package/build/common/http.d.ts +2 -7
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +8 -17
- package/build/common/icons.d.ts +18 -20
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +103 -67
- package/build/common/languageColors.d.ts +0 -1
- package/build/common/languageColors.d.ts.map +1 -1
- package/build/common/languageColors.js +1 -4
- package/build/common/languageColors.json +18 -2
- package/build/common/ops.d.ts +3 -14
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +19 -30
- package/build/common/render.d.ts +28 -82
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +175 -211
- package/build/common/retryer.d.ts +2 -7
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +4 -11
- package/build/fetchers/gist.d.ts +2 -5
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +1 -5
- package/build/fetchers/index.d.ts +12 -12
- package/build/fetchers/repo.d.ts +2 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +20 -33
- package/build/fetchers/stats.d.ts +2 -32
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +27 -86
- package/build/fetchers/top-languages.d.ts +2 -9
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +15 -31
- package/build/fetchers/types.d.ts +1 -1
- package/build/fetchers/wakatime.d.ts +2 -6
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +1 -5
- package/build/graphql/contributionsDocument.d.ts +3 -3
- package/build/graphql/contributionsDocument.d.ts.map +1 -1
- package/build/graphql/contributionsDocument.js +0 -1
- package/build/graphql/generated/gist.d.ts +1 -1
- package/build/graphql/generated/repo.d.ts +1 -1
- package/build/graphql/generated/stats.d.ts +3 -3
- package/build/graphql/generated/top-languages.d.ts +2 -2
- package/build/graphql/graphqlDocument.d.ts +0 -1
- package/build/graphql/graphqlDocument.d.ts.map +1 -1
- package/build/graphql/graphqlDocument.js +0 -1
- package/build/graphql/reposContributedToDocument.d.ts +4 -5
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
- package/build/graphql/reposContributedToDocument.js +0 -2
- package/build/markup/css.d.ts +35 -0
- package/build/markup/css.d.ts.map +1 -0
- package/build/markup/css.js +64 -0
- package/build/markup/element.d.ts +41 -0
- package/build/markup/element.d.ts.map +1 -0
- package/build/markup/element.js +127 -0
- package/build/markup/html.d.ts +13 -0
- package/build/markup/html.d.ts.map +1 -0
- package/build/markup/html.js +27 -0
- package/build/markup/index.d.ts +9 -0
- package/build/markup/index.d.ts.map +1 -0
- package/build/markup/index.js +6 -0
- package/build/markup/serialize.d.ts +16 -0
- package/build/markup/serialize.d.ts.map +1 -0
- package/build/markup/serialize.js +17 -0
- package/build/themes/index.d.ts +332 -333
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +1 -1
- package/build/translations.d.ts +2 -6
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +621 -628
- package/package.json +17 -26
- package/src/api/api-result.ts +10 -9
- package/src/api/gist.ts +11 -18
- package/src/api/index.ts +12 -12
- package/src/api/params.ts +27 -21
- package/src/api/pin.ts +13 -28
- package/src/api/stats.ts +13 -39
- package/src/api/top-langs.ts +13 -33
- package/src/api/wakatime.ts +11 -28
- package/src/calculateRank.ts +12 -23
- package/src/cards/gist.ts +40 -43
- package/src/cards/options.ts +1 -1
- package/src/cards/repo.ts +97 -107
- package/src/cards/stats.ts +165 -184
- package/src/cards/top-languages.ts +297 -413
- package/src/cards/wakatime.ts +193 -221
- package/src/common/Card.ts +165 -217
- package/src/common/I18n.ts +3 -6
- package/src/common/color.ts +80 -57
- package/src/common/config.ts +5 -18
- package/src/common/constants.ts +5 -2
- package/src/common/date.ts +0 -2
- package/src/common/emojiMap.json +1915 -0
- package/src/common/emojiMap.ts +13 -0
- package/src/common/error.ts +2 -11
- package/src/common/fmt.ts +7 -44
- package/src/common/http.ts +9 -15
- package/src/common/icons.ts +117 -42
- package/src/common/languageColors.json +18 -2
- package/src/common/languageColors.ts +1 -4
- package/src/common/ops.ts +26 -34
- package/src/common/render.ts +279 -232
- package/src/common/retryer.ts +8 -15
- package/src/fetchers/gist.ts +8 -12
- package/src/fetchers/index.ts +12 -12
- package/src/fetchers/repo.ts +27 -40
- package/src/fetchers/stats.ts +44 -102
- package/src/fetchers/top-languages.ts +26 -40
- package/src/fetchers/types.ts +1 -1
- package/src/fetchers/wakatime.ts +5 -9
- package/src/graphql/contributionsDocument.ts +7 -5
- package/src/graphql/generated/gist.ts +1 -1
- package/src/graphql/generated/repo.ts +1 -1
- package/src/graphql/generated/stats.ts +2 -2
- package/src/graphql/generated/top-languages.ts +2 -2
- package/src/graphql/graphqlDocument.ts +0 -1
- package/src/graphql/reposContributedToDocument.ts +6 -7
- package/src/markup/css.ts +118 -0
- package/src/markup/element.ts +246 -0
- package/src/markup/html.ts +34 -0
- package/src/markup/index.ts +9 -0
- package/src/markup/serialize.ts +27 -0
- package/src/themes/index.ts +1 -1
- package/src/translations.ts +622 -629
- package/build/cards/index.d.ts +0 -11
- package/build/cards/index.d.ts.map +0 -1
- package/build/cards/index.js +0 -7
- package/build/common/html.d.ts +0 -8
- package/build/common/html.d.ts.map +0 -1
- package/build/common/html.js +0 -14
- package/build/index.d.ts +0 -15
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -10
- package/src/_emoji-name-map.d.ts +0 -10
- package/src/_github-username-regex.d.ts +0 -4
- package/src/cards/index.ts +0 -21
- package/src/common/html.ts +0 -17
- package/src/index.ts +0 -18
package/README.md
CHANGED
|
@@ -100,16 +100,6 @@ const config = new CardConfig({
|
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
## Rendering from data you already hold
|
|
104
|
-
|
|
105
|
-
If you cache stats yourself, skip the fetchers and render directly:
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
import { renderStatsCard } from '@stats-forge/github-stats-forge-core/cards';
|
|
109
|
-
|
|
110
|
-
const svg = renderStatsCard(myStats, { theme: 'dracula', hide_rank: true });
|
|
111
|
-
```
|
|
112
|
-
|
|
113
103
|
Every card is labelled for screen readers: the SVG carries `role="img"` with a `<title>`
|
|
114
104
|
and `<desc>` describing what it shows, since assistive technology cannot reach the text
|
|
115
105
|
inside an image role.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ColorParams } from '../common/color.
|
|
2
|
-
import type { ErrorCode } from '../common/error.
|
|
1
|
+
import type { ColorParams } from '../common/color.ts';
|
|
2
|
+
import type { ErrorCode } from '../common/error.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Why a card could not be rendered, in a form a host can act on.
|
|
5
5
|
* The same failure is also drawn onto the result's `content`,
|
|
@@ -33,12 +33,11 @@ export type ApiResult = {
|
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Turns anything a handler threw into the one shape it answers with.
|
|
36
|
+
* Anything that is not a `CardError` is treated as upstream's.
|
|
36
37
|
*
|
|
37
|
-
* @param err The failure.
|
|
38
|
-
* Anything that is not a `CardError` is treated as upstream's.
|
|
39
|
-
* @param renderOptions Colors the error card is drawn with;
|
|
40
|
-
* omitted when it was a color that was rejected.
|
|
41
38
|
* @returns The rendered error.
|
|
42
39
|
*/
|
|
43
|
-
export declare const errorResult: (err: unknown,
|
|
40
|
+
export declare const errorResult: (err: unknown,
|
|
41
|
+
/** omitted when it was a color that was rejected, which cannot draw its own error card */
|
|
42
|
+
renderOptions?: ColorParams) => ApiResult;
|
|
44
43
|
//# sourceMappingURL=api-result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-result.d.ts","sourceRoot":"","sources":["../../src/api/api-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GACjB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN
|
|
1
|
+
{"version":3,"file":"api-result.d.ts","sourceRoot":"","sources":["../../src/api/api-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GACjB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QACjB,OAAO;AACZ,0FAA0F;gBAC1E,WAAW,KAC1B,SAsBF,CAAC"}
|
package/build/api/api-result.js
CHANGED
|
@@ -2,14 +2,13 @@ import { CardError } from '../common/error.js';
|
|
|
2
2
|
import { renderError } from '../common/render.js';
|
|
3
3
|
/**
|
|
4
4
|
* Turns anything a handler threw into the one shape it answers with.
|
|
5
|
+
* Anything that is not a `CardError` is treated as upstream's.
|
|
5
6
|
*
|
|
6
|
-
* @param err The failure.
|
|
7
|
-
* Anything that is not a `CardError` is treated as upstream's.
|
|
8
|
-
* @param renderOptions Colors the error card is drawn with;
|
|
9
|
-
* omitted when it was a color that was rejected.
|
|
10
7
|
* @returns The rendered error.
|
|
11
8
|
*/
|
|
12
|
-
export const errorResult = (err,
|
|
9
|
+
export const errorResult = (err,
|
|
10
|
+
/** omitted when it was a color that was rejected, which cannot draw its own error card */
|
|
11
|
+
renderOptions) => {
|
|
13
12
|
const error = CardError.from(err);
|
|
14
13
|
return {
|
|
15
14
|
status: 'error',
|
package/build/api/gist.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { CardConfig } from '../common/config.
|
|
3
|
-
import type { ApiResult } from './api-result.
|
|
4
|
-
import type { ApiQuery } from './params.
|
|
2
|
+
import type { CardConfig } from '../common/config.ts';
|
|
3
|
+
import type { ApiResult } from './api-result.ts';
|
|
4
|
+
import type { ApiQuery } from './params.ts';
|
|
5
5
|
/** What the gist endpoint accepts, on top of the shared color params. */
|
|
6
6
|
declare const gistQuery: z.ZodMiniObject<{
|
|
7
7
|
id: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
@@ -15,13 +15,6 @@ type GistApiQuery = ApiQuery<typeof gistQuery>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Render the gist card for a set of query params.
|
|
17
17
|
*
|
|
18
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
19
|
-
* @param query.id GitHub gist ID.
|
|
20
|
-
* @param query.border_radius Card border radius.
|
|
21
|
-
* @param query.show_owner Whether to show the gist owner.
|
|
22
|
-
* @param query.browser_rendering Whether the browser wraps the description text.
|
|
23
|
-
* @param query.hide_border Whether to hide the card border.
|
|
24
|
-
* @param config Deployment config supplying the PAT pool.
|
|
25
18
|
* @returns The rendered card, or a rendered error.
|
|
26
19
|
*/
|
|
27
20
|
export declare const gist: (query: GistApiQuery, config: CardConfig) => Promise<ApiResult>;
|
package/build/api/gist.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/api/gist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,yEAAyE;AACzE,QAAA,MAAM,SAAS;;;;;;iBAMb,CAAC;AAEH,yEAAyE;AACzE,KAAK,YAAY,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/api/gist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,yEAAyE;AACzE,QAAA,MAAM,SAAS;;;;;;iBAMb,CAAC;AAEH,yEAAyE;AACzE,KAAK,YAAY,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,IAAI,UAAiB,YAAY,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CA8BrF,CAAC"}
|
package/build/api/gist.js
CHANGED
|
@@ -14,13 +14,6 @@ const gistQuery = z.object({
|
|
|
14
14
|
/**
|
|
15
15
|
* Render the gist card for a set of query params.
|
|
16
16
|
*
|
|
17
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
18
|
-
* @param query.id GitHub gist ID.
|
|
19
|
-
* @param query.border_radius Card border radius.
|
|
20
|
-
* @param query.show_owner Whether to show the gist owner.
|
|
21
|
-
* @param query.browser_rendering Whether the browser wraps the description text.
|
|
22
|
-
* @param query.hide_border Whether to hide the card border.
|
|
23
|
-
* @param config Deployment config supplying the PAT pool.
|
|
24
17
|
* @returns The rendered card, or a rendered error.
|
|
25
18
|
*/
|
|
26
19
|
export const gist = async (query, config) => {
|
|
@@ -28,9 +21,9 @@ export const gist = async (query, config) => {
|
|
|
28
21
|
try {
|
|
29
22
|
colors = parseColorParams(query);
|
|
30
23
|
}
|
|
31
|
-
catch (
|
|
24
|
+
catch (error) {
|
|
32
25
|
// A rejected color cannot be used to draw its own error card.
|
|
33
|
-
return errorResult(
|
|
26
|
+
return errorResult(error);
|
|
34
27
|
}
|
|
35
28
|
try {
|
|
36
29
|
const { id, border_radius, show_owner, browser_rendering, hide_border } = parseParams(gistQuery, query);
|
|
@@ -46,7 +39,7 @@ export const gist = async (query, config) => {
|
|
|
46
39
|
}),
|
|
47
40
|
};
|
|
48
41
|
}
|
|
49
|
-
catch (
|
|
50
|
-
return errorResult(
|
|
42
|
+
catch (error) {
|
|
43
|
+
return errorResult(error, colors);
|
|
51
44
|
}
|
|
52
45
|
};
|
package/build/api/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { gist } from './gist.
|
|
2
|
-
export { pin } from './pin.
|
|
3
|
-
export { stats } from './stats.
|
|
4
|
-
export { topLangs } from './top-langs.
|
|
5
|
-
export { wakatime } from './wakatime.
|
|
6
|
-
export type { ApiError, ApiResult } from './api-result.
|
|
7
|
-
export { CardConfig } from '../common/config.
|
|
8
|
-
export type { CardConfigInit, PersonalAccessToken } from '../common/config.
|
|
9
|
-
export type { FetchLike } from '../common/http.
|
|
10
|
-
export type { ErrorCode } from '../common/error.
|
|
11
|
-
export { themes } from '../themes/index.
|
|
12
|
-
export type { ThemeName } from '../themes/index.
|
|
1
|
+
export { gist } from './gist.ts';
|
|
2
|
+
export { pin } from './pin.ts';
|
|
3
|
+
export { stats } from './stats.ts';
|
|
4
|
+
export { topLangs } from './top-langs.ts';
|
|
5
|
+
export { wakatime } from './wakatime.ts';
|
|
6
|
+
export type { ApiError, ApiResult } from './api-result.ts';
|
|
7
|
+
export { CardConfig } from '../common/config.ts';
|
|
8
|
+
export type { CardConfigInit, PersonalAccessToken } from '../common/config.ts';
|
|
9
|
+
export type { FetchLike } from '../common/http.ts';
|
|
10
|
+
export type { ErrorCode } from '../common/error.ts';
|
|
11
|
+
export { themes } from '../themes/index.ts';
|
|
12
|
+
export type { ThemeName } from '../themes/index.ts';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/build/api/params.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { ColorParams } from '../common/color.
|
|
2
|
+
import type { ColorParams } from '../common/color.ts';
|
|
3
3
|
/**
|
|
4
4
|
* @file The api layer is the trust boundary:
|
|
5
5
|
* a query string arrives as strings, and each endpoint declares what it accepts as a schema over them.
|
|
@@ -42,6 +42,11 @@ declare const yearParam: z.ZodMiniType<number | undefined, string | undefined>;
|
|
|
42
42
|
* Rejected before any request is made, and yielded unchanged otherwise.
|
|
43
43
|
*/
|
|
44
44
|
declare const safeParam: z.ZodMiniType<string | undefined, string | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* A GitHub login, stricter than `safeParam`: no leading, trailing or doubled hyphen.
|
|
47
|
+
* Rejected here so a malformed one is a permanent error rather than the NOT_FOUND GitHub answers.
|
|
48
|
+
*/
|
|
49
|
+
declare const usernameParam: z.ZodMiniType<string | undefined, string | undefined>;
|
|
45
50
|
/**
|
|
46
51
|
* A comma-separated list of ids, checked before it is split.
|
|
47
52
|
* The safe pattern allows the commas, so one check covers the whole list.
|
|
@@ -57,7 +62,6 @@ declare const localeParam: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<strin
|
|
|
57
62
|
/**
|
|
58
63
|
* A param the card only renders as one of a fixed set of values.
|
|
59
64
|
*
|
|
60
|
-
* @param values The accepted values, as the card that renders them declares them.
|
|
61
65
|
* @returns Schema yielding one of `values`, or `undefined` when absent.
|
|
62
66
|
*/
|
|
63
67
|
declare const enumParam: <const T extends ReadonlyArray<string>>(values: T) => z.ZodMiniType<T[number] | undefined, string | undefined>;
|
|
@@ -73,21 +77,20 @@ type ApiQuery<TSchema extends z.ZodMiniType> = Partial<z.input<TSchema>> & Color
|
|
|
73
77
|
* Only the first rejection is reported:
|
|
74
78
|
* the error card has room for one line.
|
|
75
79
|
*
|
|
76
|
-
* @param schema The endpoint's schema.
|
|
77
|
-
* @param query Raw query params.
|
|
78
|
-
* @returns The parsed params.
|
|
79
80
|
* @throws {CardError} When the schema rejects a param.
|
|
81
|
+
*
|
|
82
|
+
* @returns The parsed params.
|
|
80
83
|
*/
|
|
81
84
|
declare const parseParams: <TSchema extends z.ZodMiniType>(schema: TSchema, query: unknown) => z.output<TSchema>;
|
|
82
85
|
/**
|
|
83
86
|
* The color params, validated.
|
|
84
87
|
* Split from the endpoint's own schema because a rejected color cannot then be used to render its own error card.
|
|
85
88
|
*
|
|
86
|
-
* @param query Raw query params.
|
|
87
|
-
* @returns The color params.
|
|
88
89
|
* @throws {CardError} When a param does not hold a color or a gradient.
|
|
90
|
+
*
|
|
91
|
+
* @returns The color params.
|
|
89
92
|
*/
|
|
90
93
|
declare const parseColorParams: (query: unknown) => ColorParams;
|
|
91
94
|
export type { ApiQuery };
|
|
92
|
-
export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, yearParam, };
|
|
95
|
+
export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, usernameParam, yearParam, };
|
|
93
96
|
//# sourceMappingURL=params.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/api/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/api/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOtD;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,QAAA,MAAM,QAAQ,4CAAyB,CAAC;AAiCxC;;;GAGG;AACH,QAAA,MAAM,YAAY,wHAIjB,CAAC;AAEF,8DAA8D;AAC9D,QAAA,MAAM,SAAS,6GAA4C,CAAC;AAE5D;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAGtE,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,aAAa,uHAGlB,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAGpE,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAEpE,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,aAAa,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAExE,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,aAAa,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAGnE,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,WAAW,uHAGhB,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,SAAS,GAAI,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,UAC9C,CAAC,KACR,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CACqC,CAAC;AAmBhG;;;;GAIG;AACH,KAAK,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;AAcvF;;;;;;;;;GASG;AACH,QAAA,MAAM,WAAW,GAAI,OAAO,SAAS,CAAC,CAAC,WAAW,UACxC,OAAO,SACR,OAAO,KACb,CAAC,CAAC,MAAM,CAAC,OAAO,CAMlB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,gBAAgB,UAAW,OAAO,KAAG,WAAoD,CAAC;AAEhG,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,GACV,CAAC"}
|
package/build/api/params.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
2
|
import { COLOR_PARAM_KEYS, THEME_PARAM_KEYS, isValidColorInput } from '../common/color.js';
|
|
3
|
+
import { GITHUB_USERNAME_PATTERN } from '../common/constants.js';
|
|
3
4
|
import { CardError } from '../common/error.js';
|
|
4
5
|
import { parseArray, parseBoolean } from '../common/ops.js';
|
|
5
6
|
import { isLocaleAvailable } from '../translations.js';
|
|
@@ -14,7 +15,7 @@ import { isLocaleAvailable } from '../translations.js';
|
|
|
14
15
|
*/
|
|
15
16
|
/** Every param arrives as a string, or not at all. */
|
|
16
17
|
const rawParam = z.optional(z.string());
|
|
17
|
-
/** Characters a
|
|
18
|
+
/** Characters a repository, owner or gist id may contain. */
|
|
18
19
|
const SAFE_PATTERN = /^[-\w/.,]+$/;
|
|
19
20
|
/**
|
|
20
21
|
* Every rejection the api can put on an error card, in one place.
|
|
@@ -24,6 +25,7 @@ const REJECTION_MESSAGES = {
|
|
|
24
25
|
number: (param) => `Invalid number input for parameter "${param}"`,
|
|
25
26
|
year: (param) => `Invalid number input for parameter "${param}"`,
|
|
26
27
|
unsafe: (param) => `Parameter "${param}" contains unsafe characters`,
|
|
28
|
+
username: (param) => `Invalid username input for parameter "${param}"`,
|
|
27
29
|
locale: () => 'Locale not found',
|
|
28
30
|
enum: (param) => `Incorrect ${param} input`,
|
|
29
31
|
color: (param) => `Invalid color input for parameter "${param}"`,
|
|
@@ -32,8 +34,6 @@ const REJECTION_MESSAGES = {
|
|
|
32
34
|
* A check that words its own rejection:
|
|
33
35
|
* the message is built from the kind and the param's path rather than passed in.
|
|
34
36
|
*
|
|
35
|
-
* @param kind What the check rejects the param for.
|
|
36
|
-
* @param passes Whether a value is acceptable.
|
|
37
37
|
* @returns The check, ready for `.check()`.
|
|
38
38
|
*/
|
|
39
39
|
const rejects = (kind, passes) => z.refine((value) => typeof value !== 'string' || passes(value), {
|
|
@@ -55,12 +55,12 @@ const listParam = z.pipe(rawParam, z.transform(parseArray));
|
|
|
55
55
|
* `parseFloat`, matching the coercion `Card` performs internally, so `?border_radius=10px` still renders `rx="10"`.
|
|
56
56
|
* Yields the parsed number, or `undefined` when the param is absent.
|
|
57
57
|
*/
|
|
58
|
-
const numberParam = z.pipe(rawParam.check(rejects('number', (value) => Number.isFinite(parseFloat(value)))), z.transform((value) => (value === undefined ? undefined : parseFloat(value))));
|
|
58
|
+
const numberParam = z.pipe(rawParam.check(rejects('number', (value) => Number.isFinite(Number.parseFloat(value)))), z.transform((value) => (value === undefined ? undefined : Number.parseFloat(value))));
|
|
59
59
|
/**
|
|
60
60
|
* A number the card already falls back from — widths, counts, line heights:
|
|
61
61
|
* `NaN` reaches the renderer, which answers it with its own default.
|
|
62
62
|
*/
|
|
63
|
-
const looseIntParam = z.pipe(rawParam, z.transform((value) => (value === undefined ? undefined : parseInt(value, 10))));
|
|
63
|
+
const looseIntParam = z.pipe(rawParam, z.transform((value) => (value === undefined ? undefined : Number.parseInt(value, 10))));
|
|
64
64
|
/**
|
|
65
65
|
* A four-digit year.
|
|
66
66
|
* Anything else builds a `DateTime` GitHub rejects, so it is a permanent error here rather than a failed request later.
|
|
@@ -72,6 +72,11 @@ const yearParam = z.pipe(rawParam.check(rejects('year', (value) => /^\d{4}$/.tes
|
|
|
72
72
|
* Rejected before any request is made, and yielded unchanged otherwise.
|
|
73
73
|
*/
|
|
74
74
|
const safeParam = rawParam.check(rejects('unsafe', (value) => !value || SAFE_PATTERN.test(value)));
|
|
75
|
+
/**
|
|
76
|
+
* A GitHub login, stricter than `safeParam`: no leading, trailing or doubled hyphen.
|
|
77
|
+
* Rejected here so a malformed one is a permanent error rather than the NOT_FOUND GitHub answers.
|
|
78
|
+
*/
|
|
79
|
+
const usernameParam = rawParam.check(rejects('username', (value) => !value || GITHUB_USERNAME_PATTERN.test(value)));
|
|
75
80
|
/**
|
|
76
81
|
* A comma-separated list of ids, checked before it is split.
|
|
77
82
|
* The safe pattern allows the commas, so one check covers the whole list.
|
|
@@ -87,7 +92,6 @@ const localeParam = z.pipe(rawParam.check(rejects('locale', (value) => !value ||
|
|
|
87
92
|
/**
|
|
88
93
|
* A param the card only renders as one of a fixed set of values.
|
|
89
94
|
*
|
|
90
|
-
* @param values The accepted values, as the card that renders them declares them.
|
|
91
95
|
* @returns Schema yielding one of `values`, or `undefined` when absent.
|
|
92
96
|
*/
|
|
93
97
|
const enumParam = (values) => rawParam.check(rejects('enum', (value) => values.includes(value)));
|
|
@@ -108,11 +112,10 @@ const colorParamsSchema = z.object(Object.fromEntries(COLOR_PARAM_KEYS.map((key)
|
|
|
108
112
|
* Every rejection is the query's fault, so they share one code
|
|
109
113
|
* and differ only in the message the check already worded.
|
|
110
114
|
*
|
|
111
|
-
* @param error What the schema rejected.
|
|
112
115
|
* @returns The failure, ready to render.
|
|
113
116
|
*/
|
|
114
117
|
const toCardError = (error) => {
|
|
115
|
-
const issue = error.issues
|
|
118
|
+
const [issue] = error.issues;
|
|
116
119
|
return CardError.invalidParam(String(issue?.path[0] ?? ''), issue?.message ?? 'Invalid input');
|
|
117
120
|
};
|
|
118
121
|
/**
|
|
@@ -121,10 +124,9 @@ const toCardError = (error) => {
|
|
|
121
124
|
* Only the first rejection is reported:
|
|
122
125
|
* the error card has room for one line.
|
|
123
126
|
*
|
|
124
|
-
* @param schema The endpoint's schema.
|
|
125
|
-
* @param query Raw query params.
|
|
126
|
-
* @returns The parsed params.
|
|
127
127
|
* @throws {CardError} When the schema rejects a param.
|
|
128
|
+
*
|
|
129
|
+
* @returns The parsed params.
|
|
128
130
|
*/
|
|
129
131
|
const parseParams = (schema, query) => {
|
|
130
132
|
const result = z.safeParse(schema, query);
|
|
@@ -137,9 +139,9 @@ const parseParams = (schema, query) => {
|
|
|
137
139
|
* The color params, validated.
|
|
138
140
|
* Split from the endpoint's own schema because a rejected color cannot then be used to render its own error card.
|
|
139
141
|
*
|
|
140
|
-
* @param query Raw query params.
|
|
141
|
-
* @returns The color params.
|
|
142
142
|
* @throws {CardError} When a param does not hold a color or a gradient.
|
|
143
|
+
*
|
|
144
|
+
* @returns The color params.
|
|
143
145
|
*/
|
|
144
146
|
const parseColorParams = (query) => parseParams(colorParamsSchema, query);
|
|
145
|
-
export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, yearParam, };
|
|
147
|
+
export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, usernameParam, yearParam, };
|
package/build/api/pin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { CardConfig } from '../common/config.
|
|
3
|
-
import type { ApiResult } from './api-result.
|
|
4
|
-
import type { ApiQuery } from './params.
|
|
2
|
+
import type { CardConfig } from '../common/config.ts';
|
|
3
|
+
import type { ApiResult } from './api-result.ts';
|
|
4
|
+
import type { ApiQuery } from './params.ts';
|
|
5
5
|
/** What the pin endpoint accepts, on top of the shared color params. */
|
|
6
6
|
declare const pinQuery: z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
@@ -24,22 +24,6 @@ type PinApiQuery = ApiQuery<typeof pinQuery>;
|
|
|
24
24
|
/**
|
|
25
25
|
* Render the repository card for a set of query params.
|
|
26
26
|
*
|
|
27
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
28
|
-
* @param query.username GitHub username the repository belongs to.
|
|
29
|
-
* @param query.repo Repository name.
|
|
30
|
-
* @param query.hide_border Whether to hide the card border.
|
|
31
|
-
* @param query.card_width Card width.
|
|
32
|
-
* @param query.show_owner Whether to show the repository owner.
|
|
33
|
-
* @param query.browser_rendering Whether the browser wraps the description text.
|
|
34
|
-
* @param query.show Comma-separated extra stats to show.
|
|
35
|
-
* @param query.show_icons Whether to show the stat icons.
|
|
36
|
-
* @param query.number_format How numbers are abbreviated.
|
|
37
|
-
* @param query.text_bold Whether the stat values are bold.
|
|
38
|
-
* @param query.line_height Line height between the stats.
|
|
39
|
-
* @param query.locale Language the card is rendered in.
|
|
40
|
-
* @param query.border_radius Card border radius.
|
|
41
|
-
* @param query.description_lines_count Lines the description is wrapped to.
|
|
42
|
-
* @param config Deployment config supplying the PAT pool.
|
|
43
27
|
* @returns The rendered card, or a rendered error.
|
|
44
28
|
*/
|
|
45
29
|
export declare const pin: (query: PinApiQuery, config: CardConfig) => Promise<ApiResult>;
|
package/build/api/pin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/api/pin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/api/pin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAc5C,wEAAwE;AACxE,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;iBAeZ,CAAC;AAEH,yEAAyE;AACzE,KAAK,WAAW,GAAG,QAAQ,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CA8DnF,CAAC"}
|
package/build/api/pin.js
CHANGED
|
@@ -2,10 +2,10 @@ import * as z from 'zod/mini';
|
|
|
2
2
|
import { renderRepoCard } from '../cards/repo.js';
|
|
3
3
|
import { fetchRepo } from '../fetchers/repo.js';
|
|
4
4
|
import { errorResult } from './api-result.js';
|
|
5
|
-
import { booleanParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeParam, } from './params.js';
|
|
5
|
+
import { booleanParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeParam, usernameParam, } from './params.js';
|
|
6
6
|
/** What the pin endpoint accepts, on top of the shared color params. */
|
|
7
7
|
const pinQuery = z.object({
|
|
8
|
-
username:
|
|
8
|
+
username: usernameParam,
|
|
9
9
|
repo: safeParam,
|
|
10
10
|
hide_border: booleanParam,
|
|
11
11
|
card_width: looseIntParam,
|
|
@@ -23,22 +23,6 @@ const pinQuery = z.object({
|
|
|
23
23
|
/**
|
|
24
24
|
* Render the repository card for a set of query params.
|
|
25
25
|
*
|
|
26
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
27
|
-
* @param query.username GitHub username the repository belongs to.
|
|
28
|
-
* @param query.repo Repository name.
|
|
29
|
-
* @param query.hide_border Whether to hide the card border.
|
|
30
|
-
* @param query.card_width Card width.
|
|
31
|
-
* @param query.show_owner Whether to show the repository owner.
|
|
32
|
-
* @param query.browser_rendering Whether the browser wraps the description text.
|
|
33
|
-
* @param query.show Comma-separated extra stats to show.
|
|
34
|
-
* @param query.show_icons Whether to show the stat icons.
|
|
35
|
-
* @param query.number_format How numbers are abbreviated.
|
|
36
|
-
* @param query.text_bold Whether the stat values are bold.
|
|
37
|
-
* @param query.line_height Line height between the stats.
|
|
38
|
-
* @param query.locale Language the card is rendered in.
|
|
39
|
-
* @param query.border_radius Card border radius.
|
|
40
|
-
* @param query.description_lines_count Lines the description is wrapped to.
|
|
41
|
-
* @param config Deployment config supplying the PAT pool.
|
|
42
26
|
* @returns The rendered card, or a rendered error.
|
|
43
27
|
*/
|
|
44
28
|
export const pin = async (query, config) => {
|
|
@@ -46,9 +30,9 @@ export const pin = async (query, config) => {
|
|
|
46
30
|
try {
|
|
47
31
|
colors = parseColorParams(query);
|
|
48
32
|
}
|
|
49
|
-
catch (
|
|
33
|
+
catch (error) {
|
|
50
34
|
// A rejected color cannot be used to draw its own error card.
|
|
51
|
-
return errorResult(
|
|
35
|
+
return errorResult(error);
|
|
52
36
|
}
|
|
53
37
|
try {
|
|
54
38
|
const { username, repo, hide_border, card_width, show_owner, browser_rendering, show, show_icons, number_format, text_bold, line_height, locale, border_radius, description_lines_count, } = parseParams(pinQuery, query);
|
|
@@ -81,7 +65,7 @@ export const pin = async (query, config) => {
|
|
|
81
65
|
}),
|
|
82
66
|
};
|
|
83
67
|
}
|
|
84
|
-
catch (
|
|
85
|
-
return errorResult(
|
|
68
|
+
catch (error) {
|
|
69
|
+
return errorResult(error, colors);
|
|
86
70
|
}
|
|
87
71
|
};
|
package/build/api/stats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { CardConfig } from '../common/config.
|
|
3
|
-
import type { ApiResult } from './api-result.
|
|
4
|
-
import type { ApiQuery } from './params.
|
|
2
|
+
import type { CardConfig } from '../common/config.ts';
|
|
3
|
+
import type { ApiResult } from './api-result.ts';
|
|
4
|
+
import type { ApiQuery } from './params.ts';
|
|
5
5
|
/** What the stats endpoint accepts, on top of the shared color params. */
|
|
6
6
|
declare const statsQuery: z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
@@ -31,11 +31,17 @@ declare const statsQuery: z.ZodMiniObject<{
|
|
|
31
31
|
}, z.core.$strip>;
|
|
32
32
|
/** The query this endpoint accepts, checked against the schema above. */
|
|
33
33
|
type StatsApiQuery = ApiQuery<typeof statsQuery>;
|
|
34
|
+
/**
|
|
35
|
+
* Render the stats card for a set of query params.
|
|
36
|
+
*
|
|
37
|
+
* @returns The rendered card, or a rendered error.
|
|
38
|
+
*/
|
|
39
|
+
declare const renderStats: (query: StatsApiQuery, config: CardConfig) => Promise<ApiResult>;
|
|
34
40
|
/**
|
|
35
41
|
* The card, with the values its enum params accept.
|
|
36
42
|
* A UI reads them off the function it calls, e.g. `stats.LAYOUTS`.
|
|
37
43
|
*/
|
|
38
|
-
export declare const stats:
|
|
44
|
+
export declare const stats: typeof renderStats & {
|
|
39
45
|
RANK_ICONS: readonly ["default", "github", "percentile"];
|
|
40
46
|
};
|
|
41
47
|
export {};
|
package/build/api/stats.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/api/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAgB5C,0EAA0E;AAC1E,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBd,CAAC;AAEH,yEAAyE;AACzE,KAAK,aAAa,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/api/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAgB5C,0EAA0E;AAC1E,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBd,CAAC;AAEH,yEAAyE;AACzE,KAAK,aAAa,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AAEjD;;;;GAIG;AACH,QAAA,MAAM,WAAW,UAAiB,aAAa,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CAoGtF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,KAAK;;CAEhB,CAAC"}
|
package/build/api/stats.js
CHANGED
|
@@ -2,10 +2,10 @@ import * as z from 'zod/mini';
|
|
|
2
2
|
import { RANK_ICONS, renderStatsCard } from '../cards/stats.js';
|
|
3
3
|
import { fetchStats } from '../fetchers/stats.js';
|
|
4
4
|
import { errorResult } from './api-result.js';
|
|
5
|
-
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam,
|
|
5
|
+
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, usernameParam, yearParam, } from './params.js';
|
|
6
6
|
/** What the stats endpoint accepts, on top of the shared color params. */
|
|
7
7
|
const statsQuery = z.object({
|
|
8
|
-
username:
|
|
8
|
+
username: usernameParam,
|
|
9
9
|
repo: safeListParam,
|
|
10
10
|
owner: safeListParam,
|
|
11
11
|
hide: listParam,
|
|
@@ -33,32 +33,6 @@ const statsQuery = z.object({
|
|
|
33
33
|
/**
|
|
34
34
|
* Render the stats card for a set of query params.
|
|
35
35
|
*
|
|
36
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
37
|
-
* @param query.username GitHub username.
|
|
38
|
-
* @param query.repo Comma-separated repositories the search-based stats are scoped to.
|
|
39
|
-
* @param query.owner Comma-separated owners the search-based stats are scoped to.
|
|
40
|
-
* @param query.hide Comma-separated stats to hide.
|
|
41
|
-
* @param query.hide_title Whether to hide the card title.
|
|
42
|
-
* @param query.hide_border Whether to hide the card border.
|
|
43
|
-
* @param query.card_width Card width.
|
|
44
|
-
* @param query.hide_rank Whether to hide the rank circle.
|
|
45
|
-
* @param query.show_icons Whether to show the stat icons.
|
|
46
|
-
* @param query.include_all_commits Whether to count commits of all time.
|
|
47
|
-
* @param query.commits_year Year the commits are counted for.
|
|
48
|
-
* @param query.line_height Line height between the stats.
|
|
49
|
-
* @param query.text_bold Whether the stat values are bold.
|
|
50
|
-
* @param query.exclude_repo Comma-separated repositories to exclude.
|
|
51
|
-
* @param query.custom_title Card title.
|
|
52
|
-
* @param query.locale Language the card is rendered in.
|
|
53
|
-
* @param query.disable_animations Whether to disable the card animations.
|
|
54
|
-
* @param query.border_radius Card border radius.
|
|
55
|
-
* @param query.number_format How numbers are abbreviated.
|
|
56
|
-
* @param query.role Comma-separated owner affiliations to include.
|
|
57
|
-
* @param query.number_precision Decimals kept when a number is abbreviated.
|
|
58
|
-
* @param query.rank_icon Which rank indicator to draw.
|
|
59
|
-
* @param query.show Comma-separated extra stats to show.
|
|
60
|
-
* @param query.contribs_include_own_repos Whether the contributed-to counts include the user's own repositories.
|
|
61
|
-
* @param config Deployment config supplying the PAT pool.
|
|
62
36
|
* @returns The rendered card, or a rendered error.
|
|
63
37
|
*/
|
|
64
38
|
const renderStats = async (query, config) => {
|
|
@@ -66,9 +40,9 @@ const renderStats = async (query, config) => {
|
|
|
66
40
|
try {
|
|
67
41
|
colors = parseColorParams(query);
|
|
68
42
|
}
|
|
69
|
-
catch (
|
|
43
|
+
catch (error) {
|
|
70
44
|
// A rejected color cannot be used to draw its own error card.
|
|
71
|
-
return errorResult(
|
|
45
|
+
return errorResult(error);
|
|
72
46
|
}
|
|
73
47
|
try {
|
|
74
48
|
const { username, repo, owner, hide, hide_title, hide_border, card_width, hide_rank, show_icons, include_all_commits, commits_year, 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, } = parseParams(statsQuery, query);
|
|
@@ -119,8 +93,8 @@ const renderStats = async (query, config) => {
|
|
|
119
93
|
}, username, repository, owner),
|
|
120
94
|
};
|
|
121
95
|
}
|
|
122
|
-
catch (
|
|
123
|
-
return errorResult(
|
|
96
|
+
catch (error) {
|
|
97
|
+
return errorResult(error, colors);
|
|
124
98
|
}
|
|
125
99
|
};
|
|
126
100
|
/**
|
package/build/api/top-langs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { CardConfig } from '../common/config.
|
|
3
|
-
import type { ApiResult } from './api-result.
|
|
4
|
-
import type { ApiQuery } from './params.
|
|
2
|
+
import type { CardConfig } from '../common/config.ts';
|
|
3
|
+
import type { ApiResult } from './api-result.ts';
|
|
4
|
+
import type { ApiQuery } from './params.ts';
|
|
5
5
|
/** What the top-languages endpoint accepts, on top of the shared color params. */
|
|
6
6
|
declare const topLangsQuery: z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
@@ -9,7 +9,7 @@ declare const topLangsQuery: z.ZodMiniObject<{
|
|
|
9
9
|
hide_title: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
10
10
|
hide_border: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
11
11
|
card_width: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
|
|
12
|
-
layout: z.ZodMiniType<"compact" | "
|
|
12
|
+
layout: z.ZodMiniType<"compact" | "donut" | "donut-vertical" | "normal" | "pie" | undefined, string | undefined, z.core.$ZodTypeInternals<"compact" | "donut" | "donut-vertical" | "normal" | "pie" | undefined, string | undefined>>;
|
|
13
13
|
langs_count: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
|
|
14
14
|
exclude_repo: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
|
|
15
15
|
size_weight: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
|
|
@@ -21,15 +21,21 @@ declare const topLangsQuery: z.ZodMiniObject<{
|
|
|
21
21
|
disable_animations: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
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
|
-
stats_format: z.ZodMiniType<"
|
|
24
|
+
stats_format: z.ZodMiniType<"bytes" | "percentages" | undefined, string | undefined, z.core.$ZodTypeInternals<"bytes" | "percentages" | undefined, string | undefined>>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
26
|
/** The query this endpoint accepts, checked against the schema above. */
|
|
27
27
|
type TopLangsApiQuery = ApiQuery<typeof topLangsQuery>;
|
|
28
|
+
/**
|
|
29
|
+
* Render the top languages card for a set of query params.
|
|
30
|
+
*
|
|
31
|
+
* @returns The rendered card, or a rendered error.
|
|
32
|
+
*/
|
|
33
|
+
declare const renderTopLangs: (query: TopLangsApiQuery, config: CardConfig) => Promise<ApiResult>;
|
|
28
34
|
/**
|
|
29
35
|
* The card, with the values its enum params accept.
|
|
30
36
|
* A UI reads them off the function it calls, e.g. `topLangs.LAYOUTS`.
|
|
31
37
|
*/
|
|
32
|
-
export declare const topLangs:
|
|
38
|
+
export declare const topLangs: typeof renderTopLangs & {
|
|
33
39
|
LAYOUTS: readonly ["compact", "normal", "donut", "donut-vertical", "pie"];
|
|
34
40
|
STATS_FORMATS: readonly ["percentages", "bytes"];
|
|
35
41
|
};
|
|
@@ -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;AAO9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAc5C,kFAAkF;AAClF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAmBjB,CAAC;AAEH,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,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;AAO9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAc5C,kFAAkF;AAClF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAmBjB,CAAC;AAEH,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAEvD;;;;GAIG;AACH,QAAA,MAAM,cAAc,UAAiB,gBAAgB,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CAgE5F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;CAGnB,CAAC"}
|