@unveil/vk 1.0.0-beta.0 → 1.0.0-beta.2
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 +6 -2
- package/dist/index.d.mts +13 -8
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -33,11 +33,15 @@ console.log(eventsCount); // how many events we actually got back
|
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
35
|
analyze(username, {
|
|
36
|
-
|
|
36
|
+
provider: "github", // "github" (default) is the only provider for now
|
|
37
|
+
token: "ghp_...", // provider token. Optional, but strongly recommended
|
|
37
38
|
showEvents: true, // return the raw events too. Off by default
|
|
38
39
|
});
|
|
39
40
|
```
|
|
40
41
|
|
|
42
|
+
`provider` picks where the account lives. Only `github` (api.github.com) is
|
|
43
|
+
supported right now, and it is the default, so you can leave it out.
|
|
44
|
+
|
|
41
45
|
`token` is sent as `Authorization: Bearer`. Without it you are on the unauthenticated
|
|
42
46
|
rate limit, which is 60 requests per hour for the whole IP — and each `analyze`
|
|
43
47
|
call spends 4 of them. With a token you get 5000 per hour. The token needs no
|
|
@@ -75,7 +79,7 @@ analysis reports lower `confidence` to match.
|
|
|
75
79
|
|
|
76
80
|
`analyze` rejects instead of returning a partial result. A missing user, a
|
|
77
81
|
revoked token or an exhausted rate limit all come back as a plain `Error`
|
|
78
|
-
carrying
|
|
82
|
+
carrying the provider's own message, with the `status` and `url` of the failed request
|
|
79
83
|
attached to it:
|
|
80
84
|
|
|
81
85
|
```js
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { IdentifyResult } from "@unveil/identity";
|
|
2
2
|
import { GitHubEvent } from "@unveil/identity/providers/github";
|
|
3
|
+
//#region src/http.d.ts
|
|
4
|
+
declare class ProviderError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly url: string;
|
|
7
|
+
constructor(message: string, status: number, url: string);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
3
10
|
//#region src/index.d.ts
|
|
11
|
+
type Provider = "github";
|
|
12
|
+
type ProviderEvent = GitHubEvent;
|
|
4
13
|
type AnalyzeOptions = {
|
|
5
14
|
token?: string;
|
|
6
15
|
showEvents?: boolean;
|
|
16
|
+
provider?: Provider;
|
|
7
17
|
};
|
|
8
18
|
type AnalyzeReturn = {
|
|
9
19
|
analysis: IdentifyResult;
|
|
10
|
-
events:
|
|
20
|
+
events: ProviderEvent[];
|
|
11
21
|
eventsCount: number;
|
|
12
|
-
userId?: number;
|
|
22
|
+
userId?: number | string;
|
|
13
23
|
};
|
|
14
|
-
declare class GitHubError extends Error {
|
|
15
|
-
readonly status: number;
|
|
16
|
-
readonly url: string;
|
|
17
|
-
constructor(message: string, status: number, url: string);
|
|
18
|
-
}
|
|
19
24
|
declare function analyze(username: string, options?: AnalyzeOptions): Promise<AnalyzeReturn>;
|
|
20
25
|
//#endregion
|
|
21
|
-
export { AnalyzeOptions, AnalyzeReturn,
|
|
26
|
+
export { AnalyzeOptions, AnalyzeReturn, type GitHubEvent, type IdentifyResult, Provider, ProviderError, ProviderEvent, analyze };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{identify as e}from"@unveil/identity";import{fromGitHub as t}from"@unveil/identity/providers/github";
|
|
1
|
+
import{identify as e}from"@unveil/identity";import{fromGitHub as t}from"@unveil/identity/providers/github";function n(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))n.set(e,String(r));return`${e}?${n}`}var r=class extends Error{status;url;constructor(e,t,n){super(e),this.name=`ProviderError`,this.status=t,this.url=n}};async function i(e){try{let t=await e.json();if(t?.message)return t.message}catch{}return`${e.status} ${e.statusText}`}async function a(e,t={}){let n=await fetch(e,{headers:t});if(!n.ok)throw new r(await i(n),n.status,e);return n}async function o(e,t){return await(await a(e,t)).json()}async function s(e,t,n){let r=Array.from({length:e},(e,r)=>o(t(r+1),n));return(await Promise.all(r)).flat()}function c(e,t={}){return e?{...t,Authorization:`Bearer ${e}`}:t}const l=`https://api.github.com`;async function u(e,r){let i=encodeURIComponent(e),a=c(r,{Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`unveil-vk`}),u=await o(`${l}/users/${i}`,a),d=await s(3,e=>n(`${l}/users/${i}/events/public`,{per_page:100,page:e}),a);return{input:t({user:u,events:d}),events:d,userId:u.id}}const d={github:u};async function f(t,n){let r=n?.provider??`github`,i=d[r],{input:a,events:o,userId:s}=await i(t,n?.token);return{analysis:e(a),userId:s,events:n?.showEvents?o:[],eventsCount:o.length}}export{r as ProviderError,f as analyze};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unveil/vk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"description": "Fetch GitHub account activity and analyze it for automation patterns",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.22.0",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@biomejs/biome": "^2.5.6",
|
|
39
39
|
"@types/node": "^26.1.2",
|
|
40
|
-
"@unveil/identity": "3.0.0-beta.
|
|
40
|
+
"@unveil/identity": "3.0.0-beta.3",
|
|
41
41
|
"publint": "^0.3.22",
|
|
42
42
|
"tsdown": "^0.22.14",
|
|
43
43
|
"typescript": "^6.0.3",
|
|
44
44
|
"vitest": "^4.1.10"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@unveil/identity": "^3.0.0-beta.
|
|
47
|
+
"@unveil/identity": "^3.0.0-beta.3"
|
|
48
48
|
}
|
|
49
49
|
}
|