@stats-forge/github-stats-forge-core 0.0.1

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.
Files changed (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/build/api/api-result.d.ts +44 -0
  4. package/build/api/api-result.d.ts.map +1 -0
  5. package/build/api/api-result.js +33 -0
  6. package/build/api/gist.d.ts +29 -0
  7. package/build/api/gist.d.ts.map +1 -0
  8. package/build/api/gist.js +52 -0
  9. package/build/api/index.d.ts +13 -0
  10. package/build/api/index.d.ts.map +1 -0
  11. package/build/api/index.js +8 -0
  12. package/build/api/params.d.ts +93 -0
  13. package/build/api/params.d.ts.map +1 -0
  14. package/build/api/params.js +145 -0
  15. package/build/api/pin.d.ts +47 -0
  16. package/build/api/pin.d.ts.map +1 -0
  17. package/build/api/pin.js +87 -0
  18. package/build/api/stats.d.ts +42 -0
  19. package/build/api/stats.d.ts.map +1 -0
  20. package/build/api/stats.js +132 -0
  21. package/build/api/top-langs.d.ts +37 -0
  22. package/build/api/top-langs.d.ts.map +1 -0
  23. package/build/api/top-langs.js +101 -0
  24. package/build/api/wakatime.d.ts +34 -0
  25. package/build/api/wakatime.d.ts.map +1 -0
  26. package/build/api/wakatime.js +91 -0
  27. package/build/calculateRank.d.ts +29 -0
  28. package/build/calculateRank.d.ts.map +1 -0
  29. package/build/calculateRank.js +58 -0
  30. package/build/cards/gist.d.ts +16 -0
  31. package/build/cards/gist.d.ts.map +1 -0
  32. package/build/cards/gist.js +119 -0
  33. package/build/cards/index.d.ts +11 -0
  34. package/build/cards/index.d.ts.map +1 -0
  35. package/build/cards/index.js +7 -0
  36. package/build/cards/options.d.ts +19 -0
  37. package/build/cards/options.d.ts.map +1 -0
  38. package/build/cards/options.js +1 -0
  39. package/build/cards/repo.d.ts +25 -0
  40. package/build/cards/repo.d.ts.map +1 -0
  41. package/build/cards/repo.js +276 -0
  42. package/build/cards/stats.d.ts +37 -0
  43. package/build/cards/stats.d.ts.map +1 -0
  44. package/build/cards/stats.js +457 -0
  45. package/build/cards/top-languages.d.ts +153 -0
  46. package/build/cards/top-languages.d.ts.map +1 -0
  47. package/build/cards/top-languages.js +805 -0
  48. package/build/cards/wakatime.d.ts +31 -0
  49. package/build/cards/wakatime.d.ts.map +1 -0
  50. package/build/cards/wakatime.js +376 -0
  51. package/build/common/Card.d.ts +121 -0
  52. package/build/common/Card.d.ts.map +1 -0
  53. package/build/common/Card.js +305 -0
  54. package/build/common/I18n.d.ts +27 -0
  55. package/build/common/I18n.d.ts.map +1 -0
  56. package/build/common/I18n.js +35 -0
  57. package/build/common/color.d.ts +112 -0
  58. package/build/common/color.d.ts.map +1 -0
  59. package/build/common/color.js +188 -0
  60. package/build/common/config.d.ts +53 -0
  61. package/build/common/config.d.ts.map +1 -0
  62. package/build/common/config.js +87 -0
  63. package/build/common/constants.d.ts +7 -0
  64. package/build/common/constants.d.ts.map +1 -0
  65. package/build/common/constants.js +9 -0
  66. package/build/common/date.d.ts +29 -0
  67. package/build/common/date.d.ts.map +1 -0
  68. package/build/common/date.js +23 -0
  69. package/build/common/error.d.ts +87 -0
  70. package/build/common/error.d.ts.map +1 -0
  71. package/build/common/error.js +108 -0
  72. package/build/common/fmt.d.ts +28 -0
  73. package/build/common/fmt.d.ts.map +1 -0
  74. package/build/common/fmt.js +68 -0
  75. package/build/common/html.d.ts +8 -0
  76. package/build/common/html.d.ts.map +1 -0
  77. package/build/common/html.js +14 -0
  78. package/build/common/http.d.ts +53 -0
  79. package/build/common/http.d.ts.map +1 -0
  80. package/build/common/http.js +47 -0
  81. package/build/common/icons.d.ts +28 -0
  82. package/build/common/icons.d.ts.map +1 -0
  83. package/build/common/icons.js +77 -0
  84. package/build/common/languageColors.d.ts +11 -0
  85. package/build/common/languageColors.d.ts.map +1 -0
  86. package/build/common/languageColors.js +15 -0
  87. package/build/common/languageColors.json +678 -0
  88. package/build/common/log.d.ts +9 -0
  89. package/build/common/log.d.ts.map +1 -0
  90. package/build/common/log.js +8 -0
  91. package/build/common/ops.d.ts +59 -0
  92. package/build/common/ops.d.ts.map +1 -0
  93. package/build/common/ops.js +115 -0
  94. package/build/common/render.d.ts +196 -0
  95. package/build/common/render.d.ts.map +1 -0
  96. package/build/common/render.js +474 -0
  97. package/build/common/retryer.d.ts +36 -0
  98. package/build/common/retryer.d.ts.map +1 -0
  99. package/build/common/retryer.js +67 -0
  100. package/build/fetchers/gist.d.ts +15 -0
  101. package/build/fetchers/gist.d.ts.map +1 -0
  102. package/build/fetchers/gist.js +68 -0
  103. package/build/fetchers/index.d.ts +13 -0
  104. package/build/fetchers/index.d.ts.map +1 -0
  105. package/build/fetchers/index.js +10 -0
  106. package/build/fetchers/repo.d.ts +27 -0
  107. package/build/fetchers/repo.d.ts.map +1 -0
  108. package/build/fetchers/repo.js +100 -0
  109. package/build/fetchers/stats.d.ts +74 -0
  110. package/build/fetchers/stats.d.ts.map +1 -0
  111. package/build/fetchers/stats.js +498 -0
  112. package/build/fetchers/top-languages.d.ts +23 -0
  113. package/build/fetchers/top-languages.d.ts.map +1 -0
  114. package/build/fetchers/top-languages.js +89 -0
  115. package/build/fetchers/types.d.ts +130 -0
  116. package/build/fetchers/types.d.ts.map +1 -0
  117. package/build/fetchers/types.js +1 -0
  118. package/build/fetchers/wakatime.d.ts +19 -0
  119. package/build/fetchers/wakatime.d.ts.map +1 -0
  120. package/build/fetchers/wakatime.js +36 -0
  121. package/build/graphql/contributionsDocument.d.ts +18 -0
  122. package/build/graphql/contributionsDocument.d.ts.map +1 -0
  123. package/build/graphql/contributionsDocument.js +30 -0
  124. package/build/graphql/generated/common.d.ts +42 -0
  125. package/build/graphql/generated/common.d.ts.map +1 -0
  126. package/build/graphql/generated/common.js +2 -0
  127. package/build/graphql/generated/gist.d.ts +44 -0
  128. package/build/graphql/generated/gist.d.ts.map +1 -0
  129. package/build/graphql/generated/gist.js +27 -0
  130. package/build/graphql/generated/repo.d.ts +67 -0
  131. package/build/graphql/generated/repo.d.ts.map +1 -0
  132. package/build/graphql/generated/repo.js +30 -0
  133. package/build/graphql/generated/stats.d.ts +150 -0
  134. package/build/graphql/generated/stats.d.ts.map +1 -0
  135. package/build/graphql/generated/stats.js +95 -0
  136. package/build/graphql/generated/top-languages.d.ts +54 -0
  137. package/build/graphql/generated/top-languages.d.ts.map +1 -0
  138. package/build/graphql/generated/top-languages.js +27 -0
  139. package/build/graphql/graphqlDocument.d.ts +22 -0
  140. package/build/graphql/graphqlDocument.d.ts.map +1 -0
  141. package/build/graphql/graphqlDocument.js +8 -0
  142. package/build/graphql/reposContributedToDocument.d.ts +27 -0
  143. package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
  144. package/build/graphql/reposContributedToDocument.js +59 -0
  145. package/build/index.d.ts +15 -0
  146. package/build/index.d.ts.map +1 -0
  147. package/build/index.js +10 -0
  148. package/build/themes/index.d.ts +505 -0
  149. package/build/themes/index.d.ts.map +1 -0
  150. package/build/themes/index.js +505 -0
  151. package/build/translations.d.ts +1153 -0
  152. package/build/translations.d.ts.map +1 -0
  153. package/build/translations.js +1156 -0
  154. package/package.json +114 -0
  155. package/src/_emoji-name-map.d.ts +10 -0
  156. package/src/_github-username-regex.d.ts +4 -0
  157. package/src/api/api-result.ts +69 -0
  158. package/src/api/gist.ts +66 -0
  159. package/src/api/index.ts +16 -0
  160. package/src/api/params.ts +221 -0
  161. package/src/api/pin.ts +126 -0
  162. package/src/api/stats.ts +195 -0
  163. package/src/api/top-langs.ts +150 -0
  164. package/src/api/wakatime.ts +130 -0
  165. package/src/calculateRank.ts +91 -0
  166. package/src/cards/gist.ts +169 -0
  167. package/src/cards/index.ts +21 -0
  168. package/src/cards/options.ts +18 -0
  169. package/src/cards/repo.ts +376 -0
  170. package/src/cards/stats.ts +615 -0
  171. package/src/cards/top-languages.ts +1077 -0
  172. package/src/cards/wakatime.ts +501 -0
  173. package/src/common/Card.ts +364 -0
  174. package/src/common/I18n.ts +51 -0
  175. package/src/common/color.ts +296 -0
  176. package/src/common/config.ts +118 -0
  177. package/src/common/constants.ts +12 -0
  178. package/src/common/date.ts +34 -0
  179. package/src/common/error.ts +163 -0
  180. package/src/common/fmt.ts +86 -0
  181. package/src/common/html.ts +17 -0
  182. package/src/common/http.ts +98 -0
  183. package/src/common/icons.ts +80 -0
  184. package/src/common/languageColors.json +678 -0
  185. package/src/common/languageColors.ts +19 -0
  186. package/src/common/log.ts +12 -0
  187. package/src/common/ops.ts +145 -0
  188. package/src/common/render.ts +641 -0
  189. package/src/common/retryer.ts +111 -0
  190. package/src/fetchers/gist.ts +82 -0
  191. package/src/fetchers/index.ts +25 -0
  192. package/src/fetchers/repo.ts +140 -0
  193. package/src/fetchers/stats.ts +742 -0
  194. package/src/fetchers/top-languages.ts +134 -0
  195. package/src/fetchers/types.ts +136 -0
  196. package/src/fetchers/wakatime.ts +56 -0
  197. package/src/graphql/contributionsDocument.ts +44 -0
  198. package/src/graphql/generated/common.ts +26 -0
  199. package/src/graphql/generated/gist.ts +56 -0
  200. package/src/graphql/generated/repo.ts +79 -0
  201. package/src/graphql/generated/stats.ts +180 -0
  202. package/src/graphql/generated/top-languages.ts +66 -0
  203. package/src/graphql/graphqlDocument.ts +25 -0
  204. package/src/graphql/queries/gist.graphql +25 -0
  205. package/src/graphql/queries/repo.graphql +28 -0
  206. package/src/graphql/queries/stats.graphql +113 -0
  207. package/src/graphql/queries/top-languages.graphql +27 -0
  208. package/src/graphql/reposContributedToDocument.ts +83 -0
  209. package/src/index.ts +18 -0
  210. package/src/themes/index.ts +519 -0
  211. package/src/translations.ts +1169 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Anurag Hazra, Abhijit Gupta, martin-mfg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @stats-forge/github-stats-forge-core
2
+
3
+ Core library powering [GitHub Stats Forge](https://github.com/stats-forge/github-stats-forge):
4
+ it turns GitHub and WakaTime data into SVG cards.
5
+
6
+ It is what the CLI and any self-hosted endpoint call. Nothing here touches the
7
+ environment or the filesystem — you pass a config in, you get a string of SVG back — so it
8
+ behaves the same under Node, in a browser and under a test runner.
9
+
10
+ ```sh
11
+ pnpm add @stats-forge/github-stats-forge-core
12
+ ```
13
+
14
+ Requires Node 24 or newer.
15
+
16
+ ## Quick start
17
+
18
+ An endpoint is one call. The handler parses the query string, fetches, renders, and hands
19
+ back either the card or a rendered error:
20
+
21
+ ```ts
22
+ import { CardConfig, stats } from '@stats-forge/github-stats-forge-core/api';
23
+
24
+ const config = new CardConfig({ pats: [{ name: 'PAT_1', value: process.env.PAT_1! }] });
25
+
26
+ const result = await stats({ username: 'anuraghazra', theme: 'tokyonight' }, config);
27
+
28
+ if (result.status === 'error') {
29
+ console.error(result.error.code, result.error.message);
30
+ }
31
+ // `content` is an SVG either way: a failure is a card that says what went wrong.
32
+ response.setHeader('Content-Type', 'image/svg+xml');
33
+ response.end(result.content);
34
+ ```
35
+
36
+ ## Entry points
37
+
38
+ Import the layer you need rather than the whole package:
39
+
40
+ | Path | What it holds |
41
+ | ----------- | ---------------------------------------------------------- |
42
+ | `/api` | The five endpoint handlers, `ApiResult`, `CardConfig` |
43
+ | `/cards` | The render functions, for data you already hold |
44
+ | `/fetchers` | The GitHub and WakaTime fetchers, `retryer`, `CardError` |
45
+ | `/themes` | The theme table and `ThemeName` |
46
+ | `.` | The handlers plus `CardConfig`, `themes` and `renderError` |
47
+
48
+ ## The five cards
49
+
50
+ Each handler is a named export carrying the values its enum params accept, so a UI can
51
+ read the choices off the function it calls instead of hardcoding them:
52
+
53
+ | Handler | Card | Lists it carries |
54
+ | ---------- | ---------------------------------------- | ---------------------------- |
55
+ | `stats` | Commits, PRs, issues, reviews and a rank | `RANK_ICONS` |
56
+ | `topLangs` | Most used languages | `LAYOUTS`, `STATS_FORMATS` |
57
+ | `pin` | A pinned repository | — |
58
+ | `gist` | A gist | — |
59
+ | `wakatime` | WakaTime coding time | `LAYOUTS`, `DISPLAY_FORMATS` |
60
+
61
+ ```ts
62
+ import { topLangs } from '@stats-forge/github-stats-forge-core/api';
63
+
64
+ topLangs.LAYOUTS; // ['compact', 'normal', 'donut', 'donut-vertical', 'pie'] — what `?layout=` accepts
65
+ ```
66
+
67
+ ## Config
68
+
69
+ `CardConfig` is built by the host rather than read from the environment, and it is
70
+ immutable — `with()` returns a copy, which is how a host swaps in a per-request token:
71
+
72
+ ```ts
73
+ import { CardConfig } from '@stats-forge/github-stats-forge-core/api';
74
+
75
+ const base = CardConfig.fromEnv(process.env); // reads PAT_1, PAT_2, … plus the allowlists
76
+ const forThisRequest = base.with({ pats: [{ name: 'user', value: userToken }] });
77
+ ```
78
+
79
+ | Field | What it does |
80
+ | --------------------- | ------------------------------------------------------------------- |
81
+ | `pats` | The token pool; the retryer rotates through it on a rate limit |
82
+ | `fetch` | The transport every request goes through (see below) |
83
+ | `usernameAllowlist` | Restrict which users this deployment serves; `undefined` allows all |
84
+ | `gistAllowlist` | The same, for gist ids |
85
+ | `excludeRepositories` | Repositories left out of star counts |
86
+ | `fetchMultiPageStars` | How many pages of starred repos to walk; `Infinity` for all |
87
+
88
+ ### Substituting the transport
89
+
90
+ `fetch` defaults to the global one, resolved at call time. Passing your own is how you
91
+ mock, cache or proxy every request the library makes — no global patching:
92
+
93
+ ```ts
94
+ const config = new CardConfig({
95
+ pats,
96
+ fetch: async (url, init) => {
97
+ const cached = await cache.get(url);
98
+ return cached ?? cache.put(url, await fetch(url, init));
99
+ },
100
+ });
101
+ ```
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
+ Every card is labelled for screen readers: the SVG carries `role="img"` with a `<title>`
114
+ and `<desc>` describing what it shows, since assistive technology cannot reach the text
115
+ inside an image role.
116
+
117
+ ## Errors
118
+
119
+ Everything throws a `CardError`, and the handler turns it into a result rather than a
120
+ rejection. `ApiResult` is a union, so a host branches on the code instead of parsing the
121
+ SVG:
122
+
123
+ ```ts
124
+ const result = await stats({ username }, config);
125
+ if (result.status === 'error') {
126
+ const { code, param, message } = result.error;
127
+ // 'invalid_param' | 'missing_param' | 'not_found' | 'no_tokens' | 'rate_limited' | 'upstream'
128
+ if (result.retryable) {
129
+ // a retry may help; the rest are permanent and safe to cache
130
+ }
131
+ }
132
+ ```
133
+
134
+ ## Themes
135
+
136
+ ```ts
137
+ import { themes } from '@stats-forge/github-stats-forge-core/themes';
138
+
139
+ Object.keys(themes); // 79 names, and what `?theme=` accepts
140
+ ```
141
+
142
+ An unknown theme name falls back to the default rather than failing, so a typo still
143
+ renders a card.
144
+
145
+ ## Acknowledgements
146
+
147
+ It continues the work of [github-stats-extended](https://github.com/stats-organization/github-stats-extended),
148
+ which is itself based on [github-readme-stats](https://github.com/anuraghazra/github-readme-stats).
@@ -0,0 +1,44 @@
1
+ import type { ColorParams } from '../common/color.js';
2
+ import type { ErrorCode } from '../common/error.js';
3
+ /**
4
+ * Why a card could not be rendered, in a form a host can act on.
5
+ * The same failure is also drawn onto the result's `content`,
6
+ * so a host never has to read the SVG to find out what happened.
7
+ */
8
+ export interface ApiError {
9
+ /** Why it failed. */
10
+ code: ErrorCode;
11
+ /** First line of the error card. */
12
+ message: string;
13
+ /** Second line of the error card, when the code has more to say. */
14
+ secondaryMessage: string | undefined;
15
+ /**
16
+ * The first param at fault, when the failure names one.
17
+ * `missing_param` names every missing param in `message`, and not every
18
+ * `invalid_param` comes from a single param, so this can be absent.
19
+ */
20
+ param: string | undefined;
21
+ }
22
+ /** What every api handler returns: a rendered card, or a rendered error. */
23
+ export type ApiResult = {
24
+ status: 'success';
25
+ content: string;
26
+ } | {
27
+ status: 'error';
28
+ /** Whether repeating the request could produce a different answer. */
29
+ retryable: boolean;
30
+ error: ApiError;
31
+ /** The error, drawn as a card. */
32
+ content: string;
33
+ };
34
+ /**
35
+ * Turns anything a handler threw into the one shape it answers with.
36
+ *
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
+ * @returns The rendered error.
42
+ */
43
+ export declare const errorResult: (err: unknown, renderOptions?: ColorParams) => ApiResult;
44
+ //# sourceMappingURL=api-result.d.ts.map
@@ -0,0 +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;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,EAAE,gBAAgB,WAAW,KAAG,SAsBvE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { CardError } from '../common/error.js';
2
+ import { renderError } from '../common/render.js';
3
+ /**
4
+ * Turns anything a handler threw into the one shape it answers with.
5
+ *
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
+ * @returns The rendered error.
11
+ */
12
+ export const errorResult = (err, renderOptions) => {
13
+ const error = CardError.from(err);
14
+ return {
15
+ status: 'error',
16
+ retryable: error.retryable,
17
+ error: {
18
+ code: error.code,
19
+ message: error.message,
20
+ secondaryMessage: error.secondaryMessage,
21
+ param: error.param,
22
+ },
23
+ content: renderError({
24
+ message: error.message,
25
+ secondaryMessage: error.secondaryMessage,
26
+ renderOptions: {
27
+ ...renderOptions,
28
+ // A missing param is the caller's to fix, so the card links its docs instead.
29
+ show_repo_link: error.code !== 'missing_param',
30
+ },
31
+ }),
32
+ };
33
+ };
@@ -0,0 +1,29 @@
1
+ import * as z from 'zod/mini';
2
+ import type { CardConfig } from '../common/config.js';
3
+ import type { ApiResult } from './api-result.js';
4
+ import type { ApiQuery } from './params.js';
5
+ /** What the gist endpoint accepts, on top of the shared color params. */
6
+ declare const gistQuery: z.ZodMiniObject<{
7
+ id: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
8
+ border_radius: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
9
+ show_owner: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
10
+ browser_rendering: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
11
+ hide_border: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
12
+ }, z.core.$strip>;
13
+ /** The query this endpoint accepts, checked against the schema above. */
14
+ type GistApiQuery = ApiQuery<typeof gistQuery>;
15
+ /**
16
+ * Render the gist card for a set of query params.
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
+ * @returns The rendered card, or a rendered error.
26
+ */
27
+ export declare const gist: (query: GistApiQuery, config: CardConfig) => Promise<ApiResult>;
28
+ export {};
29
+ //# sourceMappingURL=gist.d.ts.map
@@ -0,0 +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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAU,OAAO,YAAY,EAAE,QAAQ,UAAU,KAAG,OAAO,CAAC,SAAS,CA8BrF,CAAC"}
@@ -0,0 +1,52 @@
1
+ import * as z from 'zod/mini';
2
+ import { renderGistCard } from '../cards/gist.js';
3
+ import { fetchGist } from '../fetchers/gist.js';
4
+ import { errorResult } from './api-result.js';
5
+ import { booleanParam, numberParam, parseColorParams, parseParams, safeParam } from './params.js';
6
+ /** What the gist endpoint accepts, on top of the shared color params. */
7
+ const gistQuery = z.object({
8
+ id: safeParam,
9
+ border_radius: numberParam,
10
+ show_owner: booleanParam,
11
+ browser_rendering: booleanParam,
12
+ hide_border: booleanParam,
13
+ });
14
+ /**
15
+ * Render the gist card for a set of query params.
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
+ * @returns The rendered card, or a rendered error.
25
+ */
26
+ export const gist = async (query, config) => {
27
+ let colors;
28
+ try {
29
+ colors = parseColorParams(query);
30
+ }
31
+ catch (err) {
32
+ // A rejected color cannot be used to draw its own error card.
33
+ return errorResult(err);
34
+ }
35
+ try {
36
+ const { id, border_radius, show_owner, browser_rendering, hide_border } = parseParams(gistQuery, query);
37
+ const gistData = await fetchGist({ id }, config);
38
+ return {
39
+ status: 'success',
40
+ content: renderGistCard(gistData, {
41
+ ...colors,
42
+ border_radius,
43
+ show_owner,
44
+ browser_rendering,
45
+ hide_border,
46
+ }),
47
+ };
48
+ }
49
+ catch (err) {
50
+ return errorResult(err, colors);
51
+ }
52
+ };
@@ -0,0 +1,13 @@
1
+ export { gist } from './gist.js';
2
+ export { pin } from './pin.js';
3
+ export { stats } from './stats.js';
4
+ export { topLangs } from './top-langs.js';
5
+ export { wakatime } from './wakatime.js';
6
+ export type { ApiError, ApiResult } from './api-result.js';
7
+ export { CardConfig } from '../common/config.js';
8
+ export type { CardConfigInit, PersonalAccessToken } from '../common/config.js';
9
+ export type { FetchLike } from '../common/http.js';
10
+ export type { ErrorCode } from '../common/error.js';
11
+ export { themes } from '../themes/index.js';
12
+ export type { ThemeName } from '../themes/index.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { gist } from './gist.js';
2
+ export { pin } from './pin.js';
3
+ export { stats } from './stats.js';
4
+ export { topLangs } from './top-langs.js';
5
+ export { wakatime } from './wakatime.js';
6
+ // every handler but `wakatime` needs the PAT pool, and that one still needs the transport.
7
+ export { CardConfig } from '../common/config.js';
8
+ export { themes } from '../themes/index.js';
@@ -0,0 +1,93 @@
1
+ import * as z from 'zod/mini';
2
+ import type { ColorParams } from '../common/color.js';
3
+ /**
4
+ * @file The api layer is the trust boundary:
5
+ * a query string arrives as strings, and each endpoint declares what it accepts as a schema over them.
6
+ * Parsing happens here once;
7
+ * the render functions are handed typed values and keep their own defaults.
8
+ *
9
+ * `zod/mini` rather than `zod`:
10
+ * this package ships to the browser, and the functional API tree-shakes down to the checks used below.
11
+ */
12
+ /** Every param arrives as a string, or not at all. */
13
+ declare const rawParam: z.ZodMiniOptional<z.ZodMiniString<string>>;
14
+ /**
15
+ * `?x=true` / `?x=false`.
16
+ * Anything else is `undefined`, which leaves the card's own default in place.
17
+ */
18
+ declare const booleanParam: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
19
+ /** Comma-separated values, empty when the param is absent. */
20
+ declare const listParam: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
21
+ /**
22
+ * A number the card cannot fall back from, so a malformed one is rejected here:
23
+ * a render-time guard would throw into the generic catch and read as a temporary error.
24
+ *
25
+ * `parseFloat`, matching the coercion `Card` performs internally, so `?border_radius=10px` still renders `rx="10"`.
26
+ * Yields the parsed number, or `undefined` when the param is absent.
27
+ */
28
+ declare const numberParam: z.ZodMiniType<number | undefined, string | undefined>;
29
+ /**
30
+ * A number the card already falls back from — widths, counts, line heights:
31
+ * `NaN` reaches the renderer, which answers it with its own default.
32
+ */
33
+ declare const looseIntParam: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
34
+ /**
35
+ * A four-digit year.
36
+ * Anything else builds a `DateTime` GitHub rejects, so it is a permanent error here rather than a failed request later.
37
+ * Yields the year, or `undefined` when the param is absent.
38
+ */
39
+ declare const yearParam: z.ZodMiniType<number | undefined, string | undefined>;
40
+ /**
41
+ * An id the fetchers put in a URL.
42
+ * Rejected before any request is made, and yielded unchanged otherwise.
43
+ */
44
+ declare const safeParam: z.ZodMiniType<string | undefined, string | undefined>;
45
+ /**
46
+ * A comma-separated list of ids, checked before it is split.
47
+ * The safe pattern allows the commas, so one check covers the whole list.
48
+ * Yields the split values, empty when the param is absent.
49
+ */
50
+ declare const safeListParam: z.ZodMiniType<Array<string>, string | undefined>;
51
+ /**
52
+ * A locale the cards have translations for.
53
+ * One wording for every endpoint:
54
+ * the message names the param, as the number and color rejections do.
55
+ */
56
+ declare const localeParam: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string | undefined, string | undefined>>;
57
+ /**
58
+ * A param the card only renders as one of a fixed set of values.
59
+ *
60
+ * @param values The accepted values, as the card that renders them declares them.
61
+ * @returns Schema yielding one of `values`, or `undefined` when absent.
62
+ */
63
+ declare const enumParam: <const T extends ReadonlyArray<string>>(values: T) => z.ZodMiniType<T[number] | undefined, string | undefined>;
64
+ /**
65
+ * The query an endpoint accepts, derived from its own schema.
66
+ * Every param is optional and every value a string, which is all a query string can carry;
67
+ * naming it lets a consumer typecheck the object it builds.
68
+ */
69
+ type ApiQuery<TSchema extends z.ZodMiniType> = Partial<z.input<TSchema>> & ColorParams;
70
+ /**
71
+ * Runs a query through an endpoint's schema.
72
+ *
73
+ * Only the first rejection is reported:
74
+ * the error card has room for one line.
75
+ *
76
+ * @param schema The endpoint's schema.
77
+ * @param query Raw query params.
78
+ * @returns The parsed params.
79
+ * @throws {CardError} When the schema rejects a param.
80
+ */
81
+ declare const parseParams: <TSchema extends z.ZodMiniType>(schema: TSchema, query: unknown) => z.output<TSchema>;
82
+ /**
83
+ * The color params, validated.
84
+ * Split from the endpoint's own schema because a rejected color cannot then be used to render its own error card.
85
+ *
86
+ * @param query Raw query params.
87
+ * @returns The color params.
88
+ * @throws {CardError} When a param does not hold a color or a gradient.
89
+ */
90
+ declare const parseColorParams: (query: unknown) => ColorParams;
91
+ export type { ApiQuery };
92
+ export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, yearParam, };
93
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +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;AAMtD;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,QAAA,MAAM,QAAQ,4CAAyB,CAAC;AAkCxC;;;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;;;;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;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,EACtD,QAAQ,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;AAevF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW,GAAI,OAAO,SAAS,CAAC,CAAC,WAAW,EAChD,QAAQ,OAAO,EACf,OAAO,OAAO,KACb,CAAC,CAAC,MAAM,CAAC,OAAO,CAMlB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,gBAAgB,GAAI,OAAO,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,SAAS,GACV,CAAC"}
@@ -0,0 +1,145 @@
1
+ import * as z from 'zod/mini';
2
+ import { COLOR_PARAM_KEYS, THEME_PARAM_KEYS, isValidColorInput } from '../common/color.js';
3
+ import { CardError } from '../common/error.js';
4
+ import { parseArray, parseBoolean } from '../common/ops.js';
5
+ import { isLocaleAvailable } from '../translations.js';
6
+ /**
7
+ * @file The api layer is the trust boundary:
8
+ * a query string arrives as strings, and each endpoint declares what it accepts as a schema over them.
9
+ * Parsing happens here once;
10
+ * the render functions are handed typed values and keep their own defaults.
11
+ *
12
+ * `zod/mini` rather than `zod`:
13
+ * this package ships to the browser, and the functional API tree-shakes down to the checks used below.
14
+ */
15
+ /** Every param arrives as a string, or not at all. */
16
+ const rawParam = z.optional(z.string());
17
+ /** Characters a username, repository, owner or gist id may contain. */
18
+ const SAFE_PATTERN = /^[-\w/.,]+$/;
19
+ /**
20
+ * Every rejection the api can put on an error card, in one place.
21
+ * The param comes from the issue's own path, so no schema repeats its own name.
22
+ */
23
+ const REJECTION_MESSAGES = {
24
+ number: (param) => `Invalid number input for parameter "${param}"`,
25
+ year: (param) => `Invalid number input for parameter "${param}"`,
26
+ unsafe: (param) => `Parameter "${param}" contains unsafe characters`,
27
+ locale: () => 'Locale not found',
28
+ enum: (param) => `Incorrect ${param} input`,
29
+ color: (param) => `Invalid color input for parameter "${param}"`,
30
+ };
31
+ /**
32
+ * A check that words its own rejection:
33
+ * the message is built from the kind and the param's path rather than passed in.
34
+ *
35
+ * @param kind What the check rejects the param for.
36
+ * @param passes Whether a value is acceptable.
37
+ * @returns The check, ready for `.check()`.
38
+ */
39
+ const rejects = (kind, passes) => z.refine((value) => typeof value !== 'string' || passes(value), {
40
+ error: (issue) => REJECTION_MESSAGES[kind](String(issue.path?.[0] ?? '')),
41
+ });
42
+ /**
43
+ * `?x=true` / `?x=false`.
44
+ * Anything else is `undefined`, which leaves the card's own default in place.
45
+ */
46
+ const booleanParam = z.pipe(rawParam,
47
+ // Narrowed: `parseBoolean` also takes booleans, which a query string cannot hold.
48
+ z.transform((value) => parseBoolean(value)));
49
+ /** Comma-separated values, empty when the param is absent. */
50
+ const listParam = z.pipe(rawParam, z.transform(parseArray));
51
+ /**
52
+ * A number the card cannot fall back from, so a malformed one is rejected here:
53
+ * a render-time guard would throw into the generic catch and read as a temporary error.
54
+ *
55
+ * `parseFloat`, matching the coercion `Card` performs internally, so `?border_radius=10px` still renders `rx="10"`.
56
+ * Yields the parsed number, or `undefined` when the param is absent.
57
+ */
58
+ const numberParam = z.pipe(rawParam.check(rejects('number', (value) => Number.isFinite(parseFloat(value)))), z.transform((value) => (value === undefined ? undefined : parseFloat(value))));
59
+ /**
60
+ * A number the card already falls back from — widths, counts, line heights:
61
+ * `NaN` reaches the renderer, which answers it with its own default.
62
+ */
63
+ const looseIntParam = z.pipe(rawParam, z.transform((value) => (value === undefined ? undefined : parseInt(value, 10))));
64
+ /**
65
+ * A four-digit year.
66
+ * Anything else builds a `DateTime` GitHub rejects, so it is a permanent error here rather than a failed request later.
67
+ * Yields the year, or `undefined` when the param is absent.
68
+ */
69
+ const yearParam = z.pipe(rawParam.check(rejects('year', (value) => /^\d{4}$/.test(value))), z.transform((value) => (value === undefined ? undefined : Number(value))));
70
+ /**
71
+ * An id the fetchers put in a URL.
72
+ * Rejected before any request is made, and yielded unchanged otherwise.
73
+ */
74
+ const safeParam = rawParam.check(rejects('unsafe', (value) => !value || SAFE_PATTERN.test(value)));
75
+ /**
76
+ * A comma-separated list of ids, checked before it is split.
77
+ * The safe pattern allows the commas, so one check covers the whole list.
78
+ * Yields the split values, empty when the param is absent.
79
+ */
80
+ const safeListParam = z.pipe(safeParam, z.transform(parseArray));
81
+ /**
82
+ * A locale the cards have translations for.
83
+ * One wording for every endpoint:
84
+ * the message names the param, as the number and color rejections do.
85
+ */
86
+ const localeParam = z.pipe(rawParam.check(rejects('locale', (value) => !value || isLocaleAvailable(value))), z.transform((value) => value?.toLowerCase()));
87
+ /**
88
+ * A param the card only renders as one of a fixed set of values.
89
+ *
90
+ * @param values The accepted values, as the card that renders them declares them.
91
+ * @returns Schema yielding one of `values`, or `undefined` when absent.
92
+ */
93
+ const enumParam = (values) => rawParam.check(rejects('enum', (value) => values.includes(value)));
94
+ /**
95
+ * Every color param an endpoint accepts, validated and picked in one pass.
96
+ *
97
+ * Theme params are `rawParam`:
98
+ * they name a theme, and an unknown name falls back to the default rather than being an error.
99
+ */
100
+ const colorParamsSchema = z.object(Object.fromEntries(COLOR_PARAM_KEYS.map((key) => [
101
+ key,
102
+ THEME_PARAM_KEYS.includes(key)
103
+ ? rawParam
104
+ : rawParam.check(rejects('color', isValidColorInput)),
105
+ ])));
106
+ /**
107
+ * Turns a rejection back into the error the api answers with.
108
+ * Every rejection is the query's fault, so they share one code
109
+ * and differ only in the message the check already worded.
110
+ *
111
+ * @param error What the schema rejected.
112
+ * @returns The failure, ready to render.
113
+ */
114
+ const toCardError = (error) => {
115
+ const issue = error.issues[0];
116
+ return CardError.invalidParam(String(issue?.path[0] ?? ''), issue?.message ?? 'Invalid input');
117
+ };
118
+ /**
119
+ * Runs a query through an endpoint's schema.
120
+ *
121
+ * Only the first rejection is reported:
122
+ * the error card has room for one line.
123
+ *
124
+ * @param schema The endpoint's schema.
125
+ * @param query Raw query params.
126
+ * @returns The parsed params.
127
+ * @throws {CardError} When the schema rejects a param.
128
+ */
129
+ const parseParams = (schema, query) => {
130
+ const result = z.safeParse(schema, query);
131
+ if (!result.success) {
132
+ throw toCardError(result.error);
133
+ }
134
+ return result.data;
135
+ };
136
+ /**
137
+ * The color params, validated.
138
+ * Split from the endpoint's own schema because a rejected color cannot then be used to render its own error card.
139
+ *
140
+ * @param query Raw query params.
141
+ * @returns The color params.
142
+ * @throws {CardError} When a param does not hold a color or a gradient.
143
+ */
144
+ const parseColorParams = (query) => parseParams(colorParamsSchema, query);
145
+ export { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, safeListParam, safeParam, yearParam, };
@@ -0,0 +1,47 @@
1
+ import * as z from 'zod/mini';
2
+ import type { CardConfig } from '../common/config.js';
3
+ import type { ApiResult } from './api-result.js';
4
+ import type { ApiQuery } from './params.js';
5
+ /** What the pin endpoint accepts, on top of the shared color params. */
6
+ declare const pinQuery: z.ZodMiniObject<{
7
+ username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
8
+ repo: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
9
+ hide_border: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
10
+ card_width: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
11
+ show_owner: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
12
+ browser_rendering: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
13
+ show: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
14
+ show_icons: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
15
+ number_format: z.ZodMiniOptional<z.ZodMiniString<string>>;
16
+ text_bold: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
17
+ line_height: z.ZodMiniOptional<z.ZodMiniString<string>>;
18
+ locale: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string | undefined, string | undefined>>;
19
+ border_radius: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
20
+ description_lines_count: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
21
+ }, z.core.$strip>;
22
+ /** The query this endpoint accepts, checked against the schema above. */
23
+ type PinApiQuery = ApiQuery<typeof pinQuery>;
24
+ /**
25
+ * Render the repository card for a set of query params.
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
+ * @returns The rendered card, or a rendered error.
44
+ */
45
+ export declare const pin: (query: PinApiQuery, config: CardConfig) => Promise<ApiResult>;
46
+ export {};
47
+ //# sourceMappingURL=pin.d.ts.map