@takuhon/activity 0.12.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/LICENSE +202 -0
- package/NOTICE +10 -0
- package/README.md +46 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +181 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Takuhon contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@takuhon/core
|
|
2
|
+
Copyright 2026 Takuhon contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Takuhon project
|
|
5
|
+
(https://github.com/takuhon-dev/takuhon).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
|
+
|
|
9
|
+
Third-party dependencies retain their own licenses; see this package's
|
|
10
|
+
node_modules listing for details.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @takuhon/activity
|
|
2
|
+
|
|
3
|
+
Developer-activity fetchers for [takuhon](https://github.com/takuhon-dev/takuhon).
|
|
4
|
+
|
|
5
|
+
This package reads the profile owner's configured **GitHub** and **WakaTime**
|
|
6
|
+
activity and assembles an `ActivitySnapshot` (the shape defined by
|
|
7
|
+
`@takuhon/core`). It performs the network I/O that `@takuhon/core` deliberately
|
|
8
|
+
does not, and reuses core's pure transforms to shape the result.
|
|
9
|
+
|
|
10
|
+
A sync step — the `takuhon activity sync` CLI command or a Cloudflare scheduled
|
|
11
|
+
(cron) job — calls `fetchActivitySnapshot`, then persists the snapshot through
|
|
12
|
+
an `ActivityStorage`. Rendering then reads the stored snapshot statically; the
|
|
13
|
+
public render path never calls these APIs.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { fetchActivitySnapshot } from '@takuhon/activity';
|
|
19
|
+
|
|
20
|
+
const snapshot = await fetchActivitySnapshot(
|
|
21
|
+
takuhon.settings.activity, // owner-curated config from takuhon.json
|
|
22
|
+
{
|
|
23
|
+
githubToken: process.env.TAKUHON_GITHUB_TOKEN, // optional; required for contributions
|
|
24
|
+
wakatimeKey: process.env.TAKUHON_WAKATIME_KEY, // required for coding time
|
|
25
|
+
},
|
|
26
|
+
{ onError: (source, err) => console.warn(`activity sync: ${source} failed`, err) },
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Each source degrades gracefully: one that is disabled, unconfigured, missing
|
|
31
|
+
its secret, or failing is simply omitted (reported via `onError`) rather than
|
|
32
|
+
failing the whole snapshot. `isEmptySnapshot(snapshot)` reports when nothing was
|
|
33
|
+
gathered, so the caller can keep the last-known snapshot instead of overwriting
|
|
34
|
+
it with an empty one.
|
|
35
|
+
|
|
36
|
+
## Signals
|
|
37
|
+
|
|
38
|
+
| Signal | Source | Auth |
|
|
39
|
+
| ------------- | --------------------------------------------------------- | --------------------------------------------- |
|
|
40
|
+
| Language % | GitHub REST `repos/{owner}/{repo}/languages` (aggregated) | Optional token (raises rate limit) |
|
|
41
|
+
| Contributions | GitHub GraphQL `contributionsCollection` | **Token required** (calendar is GraphQL-only) |
|
|
42
|
+
| Coding time | WakaTime `users/{user}/stats/{range}` | **API key required** |
|
|
43
|
+
|
|
44
|
+
Secrets are provided per sync run and never stored in `takuhon.json` or the
|
|
45
|
+
snapshot. The `fetch` implementation is injectable for testing; it defaults to
|
|
46
|
+
the runtime global (Node 22+ / Cloudflare Workers).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ActivitySettings, ActivitySnapshot, ContributionCalendar } from '@takuhon/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build an {@link ActivitySnapshot} from the owner's configured sources.
|
|
5
|
+
*
|
|
6
|
+
* Each source is fetched independently and degrades gracefully: a source that
|
|
7
|
+
* is disabled, unconfigured, missing its secret, or failing is simply omitted
|
|
8
|
+
* (its error is reported via {@link ActivityFetchDeps.onError}) rather than
|
|
9
|
+
* aborting the whole snapshot. The caller (a CLI command or scheduled job)
|
|
10
|
+
* decides what to do with a snapshot that gathered nothing — typically keeping
|
|
11
|
+
* the last-known one rather than overwriting it with an empty result.
|
|
12
|
+
*
|
|
13
|
+
* This module performs network I/O, so it lives outside `@takuhon/core` (which
|
|
14
|
+
* is platform-independent); it reuses core's pure transforms to shape the data.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Secrets for the activity sources. Never persisted; supplied per sync run. */
|
|
18
|
+
interface ActivitySecrets {
|
|
19
|
+
/** GitHub token. Optional for languages; REQUIRED for contributions. */
|
|
20
|
+
githubToken?: string;
|
|
21
|
+
/** WakaTime API key. REQUIRED to read coding time. */
|
|
22
|
+
wakatimeKey?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ActivityFetchDeps {
|
|
25
|
+
/** HTTP client. Defaults to the runtime global `fetch` (Node 22+ / Workers). */
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
/** Clock for `lastSyncedAt`; injectable for deterministic tests. */
|
|
28
|
+
now?: () => Date;
|
|
29
|
+
/** Reports a per-source failure so the caller can audit-log it. */
|
|
30
|
+
onError?: (source: 'github-languages' | 'github-contributions' | 'wakatime', err: unknown) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fetch and assemble the activity snapshot for the given config. Always
|
|
34
|
+
* resolves (never rejects): failures surface through `onError` and leave the
|
|
35
|
+
* corresponding field absent.
|
|
36
|
+
*/
|
|
37
|
+
declare function fetchActivitySnapshot(config: ActivitySettings, secrets?: ActivitySecrets, deps?: ActivityFetchDeps): Promise<ActivitySnapshot>;
|
|
38
|
+
/** True when the snapshot carries no metric data (only `lastSyncedAt`). */
|
|
39
|
+
declare function isEmptySnapshot(snapshot: ActivitySnapshot): boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* GitHub fetchers for the activity snapshot.
|
|
43
|
+
*
|
|
44
|
+
* Two signals are read:
|
|
45
|
+
* - **Language bytes** via the REST `repos/{owner}/{repo}/languages` endpoint,
|
|
46
|
+
* aggregated across the user's owned (non-fork) repositories. REST works
|
|
47
|
+
* unauthenticated (at a low rate limit); a token raises the limit.
|
|
48
|
+
* - **Contribution calendar** via the GraphQL `contributionsCollection`. The
|
|
49
|
+
* calendar is only exposed over GraphQL (the REST events API does not provide
|
|
50
|
+
* it), so this REQUIRES a token.
|
|
51
|
+
*
|
|
52
|
+
* The `fetch` implementation is injected so tests can supply fakes; in
|
|
53
|
+
* production it defaults to the runtime global (Node 22+ / Workers).
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/** Default cap on repositories scanned for languages, to bound fan-out. */
|
|
57
|
+
declare const DEFAULT_MAX_REPOS = 50;
|
|
58
|
+
/** Thrown when a GitHub request fails; carries no token or host-path detail. */
|
|
59
|
+
declare class GitHubFetchError extends Error {
|
|
60
|
+
constructor(message: string, options?: {
|
|
61
|
+
cause?: unknown;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
declare class GitHubClient {
|
|
65
|
+
private readonly fetchImpl;
|
|
66
|
+
constructor(fetchImpl?: typeof fetch);
|
|
67
|
+
/**
|
|
68
|
+
* Aggregate language byte counts across the user's owned, non-fork repos
|
|
69
|
+
* (capped at `maxRepos`, most-recently-pushed first). Returns raw bytes per
|
|
70
|
+
* language; the caller converts to percentages via `@takuhon/core`.
|
|
71
|
+
*/
|
|
72
|
+
fetchLanguages(username: string, token?: string, maxRepos?: number): Promise<Record<string, number>>;
|
|
73
|
+
/**
|
|
74
|
+
* Read the trailing-year contribution calendar. Requires a token (the
|
|
75
|
+
* calendar is GraphQL-only).
|
|
76
|
+
*/
|
|
77
|
+
fetchContributions(username: string, token: string): Promise<ContributionCalendar>;
|
|
78
|
+
private getJson;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* WakaTime fetcher for the activity snapshot.
|
|
83
|
+
*
|
|
84
|
+
* Reads total coding seconds over a range from the `users/{user}/stats/{range}`
|
|
85
|
+
* endpoint. WakaTime has no unauthenticated mode, so an API key is REQUIRED; it
|
|
86
|
+
* is sent as HTTP Basic auth (the key base64-encoded) and only ever flows
|
|
87
|
+
* through this sync step — never into any stored document.
|
|
88
|
+
*
|
|
89
|
+
* The `fetch` implementation is injected for tests; production defaults to the
|
|
90
|
+
* runtime global.
|
|
91
|
+
*/
|
|
92
|
+
/** Default stats range — recent activity rather than all-time. */
|
|
93
|
+
declare const DEFAULT_WAKATIME_RANGE = "last_year";
|
|
94
|
+
/** Thrown when a WakaTime request fails; carries no key or host-path detail. */
|
|
95
|
+
declare class WakaTimeFetchError extends Error {
|
|
96
|
+
constructor(message: string, options?: {
|
|
97
|
+
cause?: unknown;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
declare class WakaTimeClient {
|
|
101
|
+
private readonly fetchImpl;
|
|
102
|
+
constructor(fetchImpl?: typeof fetch);
|
|
103
|
+
/** Total coding seconds for `username` over `range` (default last year). */
|
|
104
|
+
fetchCodingSeconds(username: string, apiKey: string, range?: string): Promise<number>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { type ActivityFetchDeps, type ActivitySecrets, DEFAULT_MAX_REPOS, DEFAULT_WAKATIME_RANGE, GitHubClient, GitHubFetchError, WakaTimeClient, WakaTimeFetchError, fetchActivitySnapshot, isEmptySnapshot };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// src/fetch-snapshot.ts
|
|
2
|
+
import {
|
|
3
|
+
computeLanguagePercentages,
|
|
4
|
+
deriveRankTier,
|
|
5
|
+
formatCodingTime
|
|
6
|
+
} from "@takuhon/core";
|
|
7
|
+
|
|
8
|
+
// src/github.ts
|
|
9
|
+
var GITHUB_API = "https://api.github.com";
|
|
10
|
+
var USER_AGENT = "takuhon-activity";
|
|
11
|
+
var DEFAULT_MAX_REPOS = 50;
|
|
12
|
+
var GitHubFetchError = class extends Error {
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message, options);
|
|
15
|
+
this.name = "GitHubFetchError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var GitHubClient = class {
|
|
19
|
+
constructor(fetchImpl = fetch) {
|
|
20
|
+
this.fetchImpl = fetchImpl;
|
|
21
|
+
}
|
|
22
|
+
fetchImpl;
|
|
23
|
+
/**
|
|
24
|
+
* Aggregate language byte counts across the user's owned, non-fork repos
|
|
25
|
+
* (capped at `maxRepos`, most-recently-pushed first). Returns raw bytes per
|
|
26
|
+
* language; the caller converts to percentages via `@takuhon/core`.
|
|
27
|
+
*/
|
|
28
|
+
async fetchLanguages(username, token, maxRepos = DEFAULT_MAX_REPOS) {
|
|
29
|
+
const repos = await this.getJson(
|
|
30
|
+
`${GITHUB_API}/users/${encodeURIComponent(username)}/repos?per_page=100&type=owner&sort=pushed`,
|
|
31
|
+
token
|
|
32
|
+
);
|
|
33
|
+
const owned = repos.filter((repo) => !repo.fork).slice(0, maxRepos);
|
|
34
|
+
const totals = {};
|
|
35
|
+
for (const repo of owned) {
|
|
36
|
+
const langs = await this.getJson(
|
|
37
|
+
`${GITHUB_API}/repos/${encodeURIComponent(username)}/${encodeURIComponent(repo.name)}/languages`,
|
|
38
|
+
token
|
|
39
|
+
);
|
|
40
|
+
for (const [name, bytes] of Object.entries(langs)) {
|
|
41
|
+
totals[name] = (totals[name] ?? 0) + bytes;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return totals;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Read the trailing-year contribution calendar. Requires a token (the
|
|
48
|
+
* calendar is GraphQL-only).
|
|
49
|
+
*/
|
|
50
|
+
async fetchContributions(username, token) {
|
|
51
|
+
const query = "query($login:String!){user(login:$login){contributionsCollection{contributionCalendar{totalContributions weeks{contributionDays{date contributionCount}}}}}}";
|
|
52
|
+
const res = await this.fetchImpl(`${GITHUB_API}/graphql`, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: {
|
|
55
|
+
authorization: `Bearer ${token}`,
|
|
56
|
+
"content-type": "application/json",
|
|
57
|
+
"user-agent": USER_AGENT
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify({ query, variables: { login: username } })
|
|
60
|
+
});
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
throw new GitHubFetchError(`GitHub GraphQL responded ${String(res.status)}.`);
|
|
63
|
+
}
|
|
64
|
+
const json = await res.json();
|
|
65
|
+
if (json.errors && json.errors.length > 0) {
|
|
66
|
+
throw new GitHubFetchError(`GitHub GraphQL error: ${json.errors[0]?.message ?? "unknown"}.`);
|
|
67
|
+
}
|
|
68
|
+
const calendar = json.data?.user?.contributionsCollection?.contributionCalendar;
|
|
69
|
+
if (!calendar) {
|
|
70
|
+
throw new GitHubFetchError("GitHub GraphQL response missing the contribution calendar.");
|
|
71
|
+
}
|
|
72
|
+
const days = calendar.weeks.flatMap((week) => week.contributionDays).map((day) => ({ date: day.date, count: day.contributionCount }));
|
|
73
|
+
return { total: calendar.totalContributions, days };
|
|
74
|
+
}
|
|
75
|
+
async getJson(url, token) {
|
|
76
|
+
const headers = {
|
|
77
|
+
accept: "application/vnd.github+json",
|
|
78
|
+
"user-agent": USER_AGENT
|
|
79
|
+
};
|
|
80
|
+
if (token !== void 0 && token !== "") headers.authorization = `Bearer ${token}`;
|
|
81
|
+
const res = await this.fetchImpl(url, { headers });
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
throw new GitHubFetchError(`GitHub API responded ${String(res.status)}.`);
|
|
84
|
+
}
|
|
85
|
+
return await res.json();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/wakatime.ts
|
|
90
|
+
var WAKATIME_API = "https://wakatime.com/api/v1";
|
|
91
|
+
var DEFAULT_WAKATIME_RANGE = "last_year";
|
|
92
|
+
var WakaTimeFetchError = class extends Error {
|
|
93
|
+
constructor(message, options) {
|
|
94
|
+
super(message, options);
|
|
95
|
+
this.name = "WakaTimeFetchError";
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var WakaTimeClient = class {
|
|
99
|
+
constructor(fetchImpl = fetch) {
|
|
100
|
+
this.fetchImpl = fetchImpl;
|
|
101
|
+
}
|
|
102
|
+
fetchImpl;
|
|
103
|
+
/** Total coding seconds for `username` over `range` (default last year). */
|
|
104
|
+
async fetchCodingSeconds(username, apiKey, range = DEFAULT_WAKATIME_RANGE) {
|
|
105
|
+
const res = await this.fetchImpl(
|
|
106
|
+
`${WAKATIME_API}/users/${encodeURIComponent(username)}/stats/${encodeURIComponent(range)}`,
|
|
107
|
+
// WakaTime Basic auth: the API key is the username, base64-encoded.
|
|
108
|
+
{ headers: { authorization: `Basic ${btoa(apiKey)}` } }
|
|
109
|
+
);
|
|
110
|
+
if (!res.ok) {
|
|
111
|
+
throw new WakaTimeFetchError(`WakaTime API responded ${String(res.status)}.`);
|
|
112
|
+
}
|
|
113
|
+
const json = await res.json();
|
|
114
|
+
const seconds = json.data?.total_seconds;
|
|
115
|
+
if (typeof seconds !== "number") {
|
|
116
|
+
throw new WakaTimeFetchError("WakaTime response missing data.total_seconds.");
|
|
117
|
+
}
|
|
118
|
+
return seconds;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/fetch-snapshot.ts
|
|
123
|
+
async function fetchActivitySnapshot(config, secrets = {}, deps = {}) {
|
|
124
|
+
const fetchImpl = deps.fetch ?? fetch;
|
|
125
|
+
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
126
|
+
const onError = deps.onError ?? (() => void 0);
|
|
127
|
+
const github = new GitHubClient(fetchImpl);
|
|
128
|
+
const wakatime = new WakaTimeClient(fetchImpl);
|
|
129
|
+
const snapshot = { lastSyncedAt: now().toISOString() };
|
|
130
|
+
let contributionsTotal;
|
|
131
|
+
let codingSeconds;
|
|
132
|
+
const githubUser = config.github?.username;
|
|
133
|
+
if (githubUser !== void 0 && githubUser !== "") {
|
|
134
|
+
if (config.github?.showLanguages !== false) {
|
|
135
|
+
try {
|
|
136
|
+
const languages = computeLanguagePercentages(
|
|
137
|
+
await github.fetchLanguages(githubUser, secrets.githubToken)
|
|
138
|
+
);
|
|
139
|
+
if (languages.length > 0) snapshot.languages = languages;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
onError("github-languages", err);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (config.github?.showContributions !== false && secrets.githubToken) {
|
|
145
|
+
try {
|
|
146
|
+
const calendar = await github.fetchContributions(githubUser, secrets.githubToken);
|
|
147
|
+
snapshot.contributions = calendar;
|
|
148
|
+
contributionsTotal = calendar.total;
|
|
149
|
+
} catch (err) {
|
|
150
|
+
onError("github-contributions", err);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const wakatimeUser = config.wakatime?.username;
|
|
155
|
+
if (wakatimeUser !== void 0 && wakatimeUser !== "" && config.wakatime?.showCodingTime !== false && secrets.wakatimeKey) {
|
|
156
|
+
try {
|
|
157
|
+
codingSeconds = await wakatime.fetchCodingSeconds(wakatimeUser, secrets.wakatimeKey);
|
|
158
|
+
snapshot.codingTime = formatCodingTime(codingSeconds);
|
|
159
|
+
} catch (err) {
|
|
160
|
+
onError("wakatime", err);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (config.showRank !== false && (contributionsTotal !== void 0 || codingSeconds !== void 0)) {
|
|
164
|
+
snapshot.rank = deriveRankTier({ contributions: contributionsTotal, codingSeconds });
|
|
165
|
+
}
|
|
166
|
+
return snapshot;
|
|
167
|
+
}
|
|
168
|
+
function isEmptySnapshot(snapshot) {
|
|
169
|
+
return snapshot.languages === void 0 && snapshot.contributions === void 0 && snapshot.codingTime === void 0 && snapshot.rank === void 0;
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
DEFAULT_MAX_REPOS,
|
|
173
|
+
DEFAULT_WAKATIME_RANGE,
|
|
174
|
+
GitHubClient,
|
|
175
|
+
GitHubFetchError,
|
|
176
|
+
WakaTimeClient,
|
|
177
|
+
WakaTimeFetchError,
|
|
178
|
+
fetchActivitySnapshot,
|
|
179
|
+
isEmptySnapshot
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fetch-snapshot.ts","../src/github.ts","../src/wakatime.ts"],"sourcesContent":["/**\n * Build an {@link ActivitySnapshot} from the owner's configured sources.\n *\n * Each source is fetched independently and degrades gracefully: a source that\n * is disabled, unconfigured, missing its secret, or failing is simply omitted\n * (its error is reported via {@link ActivityFetchDeps.onError}) rather than\n * aborting the whole snapshot. The caller (a CLI command or scheduled job)\n * decides what to do with a snapshot that gathered nothing — typically keeping\n * the last-known one rather than overwriting it with an empty result.\n *\n * This module performs network I/O, so it lives outside `@takuhon/core` (which\n * is platform-independent); it reuses core's pure transforms to shape the data.\n */\n\nimport {\n computeLanguagePercentages,\n deriveRankTier,\n formatCodingTime,\n type ActivitySettings,\n type ActivitySnapshot,\n} from '@takuhon/core';\n\nimport { GitHubClient } from './github.js';\nimport { WakaTimeClient } from './wakatime.js';\n\n/** Secrets for the activity sources. Never persisted; supplied per sync run. */\nexport interface ActivitySecrets {\n /** GitHub token. Optional for languages; REQUIRED for contributions. */\n githubToken?: string;\n /** WakaTime API key. REQUIRED to read coding time. */\n wakatimeKey?: string;\n}\n\nexport interface ActivityFetchDeps {\n /** HTTP client. Defaults to the runtime global `fetch` (Node 22+ / Workers). */\n fetch?: typeof fetch;\n /** Clock for `lastSyncedAt`; injectable for deterministic tests. */\n now?: () => Date;\n /** Reports a per-source failure so the caller can audit-log it. */\n onError?: (\n source: 'github-languages' | 'github-contributions' | 'wakatime',\n err: unknown,\n ) => void;\n}\n\n/**\n * Fetch and assemble the activity snapshot for the given config. Always\n * resolves (never rejects): failures surface through `onError` and leave the\n * corresponding field absent.\n */\nexport async function fetchActivitySnapshot(\n config: ActivitySettings,\n secrets: ActivitySecrets = {},\n deps: ActivityFetchDeps = {},\n): Promise<ActivitySnapshot> {\n const fetchImpl = deps.fetch ?? fetch;\n const now = deps.now ?? ((): Date => new Date());\n const onError = deps.onError ?? ((): void => undefined);\n const github = new GitHubClient(fetchImpl);\n const wakatime = new WakaTimeClient(fetchImpl);\n\n const snapshot: ActivitySnapshot = { lastSyncedAt: now().toISOString() };\n\n let contributionsTotal: number | undefined;\n let codingSeconds: number | undefined;\n\n const githubUser = config.github?.username;\n if (githubUser !== undefined && githubUser !== '') {\n if (config.github?.showLanguages !== false) {\n try {\n const languages = computeLanguagePercentages(\n await github.fetchLanguages(githubUser, secrets.githubToken),\n );\n if (languages.length > 0) snapshot.languages = languages;\n } catch (err) {\n onError('github-languages', err);\n }\n }\n // Contributions require a token (GraphQL-only); skip silently without one.\n if (config.github?.showContributions !== false && secrets.githubToken) {\n try {\n const calendar = await github.fetchContributions(githubUser, secrets.githubToken);\n snapshot.contributions = calendar;\n contributionsTotal = calendar.total;\n } catch (err) {\n onError('github-contributions', err);\n }\n }\n }\n\n const wakatimeUser = config.wakatime?.username;\n if (\n wakatimeUser !== undefined &&\n wakatimeUser !== '' &&\n config.wakatime?.showCodingTime !== false &&\n secrets.wakatimeKey\n ) {\n try {\n codingSeconds = await wakatime.fetchCodingSeconds(wakatimeUser, secrets.wakatimeKey);\n snapshot.codingTime = formatCodingTime(codingSeconds);\n } catch (err) {\n onError('wakatime', err);\n }\n }\n\n // Only rank when at least one signal was gathered, so an unconfigured /\n // failed sync does not stamp a misleading \"D\".\n if (\n config.showRank !== false &&\n (contributionsTotal !== undefined || codingSeconds !== undefined)\n ) {\n snapshot.rank = deriveRankTier({ contributions: contributionsTotal, codingSeconds });\n }\n\n return snapshot;\n}\n\n/** True when the snapshot carries no metric data (only `lastSyncedAt`). */\nexport function isEmptySnapshot(snapshot: ActivitySnapshot): boolean {\n return (\n snapshot.languages === undefined &&\n snapshot.contributions === undefined &&\n snapshot.codingTime === undefined &&\n snapshot.rank === undefined\n );\n}\n","/**\n * GitHub fetchers for the activity snapshot.\n *\n * Two signals are read:\n * - **Language bytes** via the REST `repos/{owner}/{repo}/languages` endpoint,\n * aggregated across the user's owned (non-fork) repositories. REST works\n * unauthenticated (at a low rate limit); a token raises the limit.\n * - **Contribution calendar** via the GraphQL `contributionsCollection`. The\n * calendar is only exposed over GraphQL (the REST events API does not provide\n * it), so this REQUIRES a token.\n *\n * The `fetch` implementation is injected so tests can supply fakes; in\n * production it defaults to the runtime global (Node 22+ / Workers).\n */\n\nimport type { ContributionCalendar } from '@takuhon/core';\n\nconst GITHUB_API = 'https://api.github.com';\n\n/** GitHub requires a User-Agent on every request. */\nconst USER_AGENT = 'takuhon-activity';\n\n/** Default cap on repositories scanned for languages, to bound fan-out. */\nexport const DEFAULT_MAX_REPOS = 50;\n\ninterface RepoSummary {\n name: string;\n fork: boolean;\n}\n\ninterface GraphQLContributionResponse {\n data?: {\n user?: {\n contributionsCollection?: {\n contributionCalendar?: {\n totalContributions: number;\n weeks: { contributionDays: { date: string; contributionCount: number }[] }[];\n };\n };\n };\n };\n errors?: { message: string }[];\n}\n\n/** Thrown when a GitHub request fails; carries no token or host-path detail. */\nexport class GitHubFetchError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'GitHubFetchError';\n }\n}\n\nexport class GitHubClient {\n constructor(private readonly fetchImpl: typeof fetch = fetch) {}\n\n /**\n * Aggregate language byte counts across the user's owned, non-fork repos\n * (capped at `maxRepos`, most-recently-pushed first). Returns raw bytes per\n * language; the caller converts to percentages via `@takuhon/core`.\n */\n async fetchLanguages(\n username: string,\n token?: string,\n maxRepos = DEFAULT_MAX_REPOS,\n ): Promise<Record<string, number>> {\n const repos = await this.getJson<RepoSummary[]>(\n `${GITHUB_API}/users/${encodeURIComponent(username)}/repos?per_page=100&type=owner&sort=pushed`,\n token,\n );\n const owned = repos.filter((repo) => !repo.fork).slice(0, maxRepos);\n\n const totals: Record<string, number> = {};\n for (const repo of owned) {\n const langs = await this.getJson<Record<string, number>>(\n `${GITHUB_API}/repos/${encodeURIComponent(username)}/${encodeURIComponent(repo.name)}/languages`,\n token,\n );\n for (const [name, bytes] of Object.entries(langs)) {\n totals[name] = (totals[name] ?? 0) + bytes;\n }\n }\n return totals;\n }\n\n /**\n * Read the trailing-year contribution calendar. Requires a token (the\n * calendar is GraphQL-only).\n */\n async fetchContributions(username: string, token: string): Promise<ContributionCalendar> {\n const query =\n 'query($login:String!){user(login:$login){contributionsCollection{contributionCalendar{totalContributions weeks{contributionDays{date contributionCount}}}}}}';\n const res = await this.fetchImpl(`${GITHUB_API}/graphql`, {\n method: 'POST',\n headers: {\n authorization: `Bearer ${token}`,\n 'content-type': 'application/json',\n 'user-agent': USER_AGENT,\n },\n body: JSON.stringify({ query, variables: { login: username } }),\n });\n if (!res.ok) {\n throw new GitHubFetchError(`GitHub GraphQL responded ${String(res.status)}.`);\n }\n const json = (await res.json()) as GraphQLContributionResponse;\n if (json.errors && json.errors.length > 0) {\n throw new GitHubFetchError(`GitHub GraphQL error: ${json.errors[0]?.message ?? 'unknown'}.`);\n }\n const calendar = json.data?.user?.contributionsCollection?.contributionCalendar;\n if (!calendar) {\n throw new GitHubFetchError('GitHub GraphQL response missing the contribution calendar.');\n }\n const days = calendar.weeks\n .flatMap((week) => week.contributionDays)\n .map((day) => ({ date: day.date, count: day.contributionCount }));\n return { total: calendar.totalContributions, days };\n }\n\n private async getJson<T>(url: string, token?: string): Promise<T> {\n const headers: Record<string, string> = {\n accept: 'application/vnd.github+json',\n 'user-agent': USER_AGENT,\n };\n if (token !== undefined && token !== '') headers.authorization = `Bearer ${token}`;\n const res = await this.fetchImpl(url, { headers });\n if (!res.ok) {\n throw new GitHubFetchError(`GitHub API responded ${String(res.status)}.`);\n }\n return (await res.json()) as T;\n }\n}\n","/**\n * WakaTime fetcher for the activity snapshot.\n *\n * Reads total coding seconds over a range from the `users/{user}/stats/{range}`\n * endpoint. WakaTime has no unauthenticated mode, so an API key is REQUIRED; it\n * is sent as HTTP Basic auth (the key base64-encoded) and only ever flows\n * through this sync step — never into any stored document.\n *\n * The `fetch` implementation is injected for tests; production defaults to the\n * runtime global.\n */\n\nconst WAKATIME_API = 'https://wakatime.com/api/v1';\n\n/** Default stats range — recent activity rather than all-time. */\nexport const DEFAULT_WAKATIME_RANGE = 'last_year';\n\ninterface WakaTimeStatsResponse {\n data?: { total_seconds?: number };\n}\n\n/** Thrown when a WakaTime request fails; carries no key or host-path detail. */\nexport class WakaTimeFetchError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'WakaTimeFetchError';\n }\n}\n\nexport class WakaTimeClient {\n constructor(private readonly fetchImpl: typeof fetch = fetch) {}\n\n /** Total coding seconds for `username` over `range` (default last year). */\n async fetchCodingSeconds(\n username: string,\n apiKey: string,\n range = DEFAULT_WAKATIME_RANGE,\n ): Promise<number> {\n const res = await this.fetchImpl(\n `${WAKATIME_API}/users/${encodeURIComponent(username)}/stats/${encodeURIComponent(range)}`,\n // WakaTime Basic auth: the API key is the username, base64-encoded.\n { headers: { authorization: `Basic ${btoa(apiKey)}` } },\n );\n if (!res.ok) {\n throw new WakaTimeFetchError(`WakaTime API responded ${String(res.status)}.`);\n }\n const json = (await res.json()) as WakaTimeStatsResponse;\n const seconds = json.data?.total_seconds;\n if (typeof seconds !== 'number') {\n throw new WakaTimeFetchError('WakaTime response missing data.total_seconds.');\n }\n return seconds;\n }\n}\n"],"mappings":";AAcA;AAAA,EACE;AAAA,EACA;AA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AI,OAAO,QAAQ,sBAAsB,SAAS,QAAQ,aAAa;AACrE,UAAI;AACF,cAAM,WAAW,MAAM,OAAO,mBAAmB,YAAY,QAAQ,WAAW;AAChF,iBAAS,gBAAgB;AACzB,6BAAqB,SAAS;AAAA,MAChC,SAAS,KAAK;AACZ,gBAAQ,wBAAwB,GAAG;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,UAAU;AACtC,MACE,iBAAiB,UACjB,iBAAiB,MACjB,OAAO,UAAU,mBAAmB,SACpC,QAAQ,aACR;AACA,QAAI;AACF,sBAAgB,MAAM,SAAS,mBAAmB,cAAc,QAAQ,WAAW;AACnF,eAAS,aAAa,iBAAiB,aAAa;AAAA,IACtD,SAAS,KAAK;AACZ,cAAQ,YAAY,GAAG;AAAA,IACzB;AAAA,EACF;AAIA,MACE,OAAO,aAAa,UACnB,uBAAuB,UAAa,kBAAkB,SACvD;AACA,aAAS,OAAO,eAAe,EAAE,eAAe,oBAAoB,cAAc,CAAC;AAAA,EACrF;AAEA,SAAO;AACT;AAGO,SAAS,gBAAgB,UAAqC;AACnE,SACE,SAAS,cAAc,UACvB,SAAS,kBAAkB,UAC3B,SAAS,eAAe,UACxB,SAAS,SAAS;AAEtB;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@takuhon/activity",
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "Developer-activity fetchers (GitHub, WakaTime) that build a takuhon activity snapshot",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Takuhon contributors",
|
|
7
|
+
"homepage": "https://github.com/takuhon-dev/takuhon/tree/main/packages/activity#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/takuhon-dev/takuhon.git",
|
|
11
|
+
"directory": "packages/activity"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/takuhon-dev/takuhon/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"takuhon",
|
|
18
|
+
"profile",
|
|
19
|
+
"github",
|
|
20
|
+
"wakatime",
|
|
21
|
+
"activity"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"NOTICE"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"provenance": true
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.0.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@takuhon/core": "0.12.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"typecheck": "tsc",
|
|
50
|
+
"build": "tsup src/index.ts --format esm --dts --clean --sourcemap",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
}
|
|
53
|
+
}
|