@openally/github.sdk 1.1.0 → 1.1.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.
- package/dist/api/rawFile.d.ts +20 -0
- package/dist/api/rawFile.d.ts.map +1 -0
- package/dist/api/rawFile.js +25 -0
- package/dist/api/rawFile.js.map +1 -0
- package/dist/api/repos.d.ts +21 -0
- package/dist/api/repos.d.ts.map +1 -0
- package/dist/api/repos.js +32 -0
- package/dist/api/repos.js.map +1 -0
- package/dist/api/users.d.ts +21 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +20 -0
- package/dist/api/users.js.map +1 -0
- package/dist/class/ApiEndpoint.d.ts +20 -0
- package/dist/class/ApiEndpoint.d.ts.map +1 -0
- package/dist/class/ApiEndpoint.js +60 -0
- package/dist/class/ApiEndpoint.js.map +1 -0
- package/dist/class/GithubClient.d.ts +22 -0
- package/dist/class/GithubClient.d.ts.map +1 -0
- package/dist/class/GithubClient.js +21 -0
- package/dist/class/GithubClient.js.map +1 -0
- package/dist/class/HttpLinkParser.d.ts +4 -0
- package/dist/class/HttpLinkParser.d.ts.map +1 -0
- package/dist/class/HttpLinkParser.js +14 -0
- package/dist/class/HttpLinkParser.js.map +1 -0
- package/dist/class/createApiProxy.d.ts +2 -0
- package/dist/class/createApiProxy.d.ts.map +1 -0
- package/dist/class/createApiProxy.js +8 -0
- package/dist/class/createApiProxy.js.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/{src/constants.ts → dist/constants.js} +1 -0
- package/dist/constants.js.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +2 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/{src/types.ts → dist/types.d.ts} +14 -27
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +5 -2
- package/.all-contributorsrc +0 -16
- package/.editorconfig +0 -14
- package/.github/dependabot.yml +0 -25
- package/.github/workflows/codeql.yml +0 -78
- package/.github/workflows/node.js.yml +0 -52
- package/.github/workflows/publish.yml +0 -29
- package/.github/workflows/scorecards.yml +0 -76
- package/SECURITY.md +0 -5
- package/docs/api/ApiEndpoint.md +0 -66
- package/docs/api/GithubClient.md +0 -50
- package/docs/api/fetchRawFile.md +0 -106
- package/docs/api/repos.md +0 -97
- package/docs/api/users.md +0 -76
- package/eslint.config.mjs +0 -3
- package/src/api/rawFile.ts +0 -73
- package/src/api/repos.ts +0 -88
- package/src/api/users.ts +0 -51
- package/src/class/ApiEndpoint.ts +0 -108
- package/src/class/GithubClient.ts +0 -62
- package/src/class/HttpLinkParser.ts +0 -17
- package/src/class/createApiProxy.ts +0 -9
- package/test/ApiEndpoint.spec.ts +0 -362
- package/test/GithubClient.spec.ts +0 -185
- package/test/HttpLinkParser.spec.ts +0 -78
- package/test/createApiProxy.spec.ts +0 -58
- package/test/rawFile.spec.ts +0 -382
- package/test/repos.spec.ts +0 -221
- package/test/tsconfig.json +0 -11
- package/test/users.spec.ts +0 -159
- package/tsconfig.json +0 -11
package/test/users.spec.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
// Import Node.js Dependencies
|
|
2
|
-
import { describe, it, beforeEach, afterEach } from "node:test";
|
|
3
|
-
import assert from "node:assert/strict";
|
|
4
|
-
|
|
5
|
-
// Import Third-party Dependencies
|
|
6
|
-
import { MockAgent, setGlobalDispatcher, getGlobalDispatcher, type Dispatcher } from "undici";
|
|
7
|
-
|
|
8
|
-
// Import Internal Dependencies
|
|
9
|
-
import { ApiEndpoint } from "../src/class/ApiEndpoint.ts";
|
|
10
|
-
import { users, createUsersProxy } from "../src/api/users.ts";
|
|
11
|
-
|
|
12
|
-
// CONSTANTS
|
|
13
|
-
const kGithubOrigin = "https://api.github.com";
|
|
14
|
-
const kUserEndpoints = ["orgs", "repos", "gists", "followers", "following", "starred"] as const;
|
|
15
|
-
|
|
16
|
-
describe("Users API", () => {
|
|
17
|
-
let mockAgent: MockAgent;
|
|
18
|
-
let originalDispatcher: Dispatcher;
|
|
19
|
-
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
originalDispatcher = getGlobalDispatcher();
|
|
22
|
-
mockAgent = new MockAgent();
|
|
23
|
-
mockAgent.disableNetConnect();
|
|
24
|
-
setGlobalDispatcher(mockAgent);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterEach(async() => {
|
|
28
|
-
await mockAgent.close();
|
|
29
|
-
setGlobalDispatcher(originalDispatcher);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("createUsersProxy()", () => {
|
|
33
|
-
it("should return an ApiEndpoint for each standard user endpoint", () => {
|
|
34
|
-
const proxy = createUsersProxy();
|
|
35
|
-
|
|
36
|
-
for (const endpoint of kUserEndpoints) {
|
|
37
|
-
const result = proxy.testuser[endpoint]();
|
|
38
|
-
assert.ok(result instanceof ApiEndpoint, `${endpoint}() should return an ApiEndpoint`);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should create independent ApiEndpoints per username", () => {
|
|
43
|
-
const proxy = createUsersProxy();
|
|
44
|
-
|
|
45
|
-
const fooOrgs = proxy.foo.orgs();
|
|
46
|
-
const barOrgs = proxy.bar.orgs();
|
|
47
|
-
|
|
48
|
-
assert.ok(fooOrgs instanceof ApiEndpoint);
|
|
49
|
-
assert.ok(barOrgs instanceof ApiEndpoint);
|
|
50
|
-
assert.notStrictEqual(fooOrgs, barOrgs);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should pass the token from config to the ApiEndpoint", async() => {
|
|
54
|
-
const proxy = createUsersProxy({ token: "mytoken" });
|
|
55
|
-
|
|
56
|
-
mockAgent
|
|
57
|
-
.get(kGithubOrigin)
|
|
58
|
-
.intercept({
|
|
59
|
-
path: "/users/testuser/repos",
|
|
60
|
-
method: "GET",
|
|
61
|
-
headers: { authorization: "token mytoken" }
|
|
62
|
-
})
|
|
63
|
-
.reply(200, JSON.stringify([]), {
|
|
64
|
-
headers: { "content-type": "application/json" }
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
await assert.doesNotReject(proxy.testuser.repos().all());
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("should create a new ApiEndpoint on each method call", () => {
|
|
71
|
-
const proxy = createUsersProxy();
|
|
72
|
-
|
|
73
|
-
const first = proxy.testuser.repos();
|
|
74
|
-
const second = proxy.testuser.repos();
|
|
75
|
-
|
|
76
|
-
assert.notStrictEqual(first, second);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe("users (default export)", () => {
|
|
81
|
-
it("should be a UsersProxy with no token", async() => {
|
|
82
|
-
mockAgent
|
|
83
|
-
.get(kGithubOrigin)
|
|
84
|
-
.intercept({ path: "/users/octocat/orgs", method: "GET" })
|
|
85
|
-
.reply(200, JSON.stringify([{ id: 1, login: "github" }]), {
|
|
86
|
-
headers: { "content-type": "application/json" }
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const result = await users.octocat.orgs().all();
|
|
90
|
-
|
|
91
|
-
assert.deepEqual(result, [{ id: 1, login: "github" }]);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should fetch repos for a user", async() => {
|
|
95
|
-
mockAgent
|
|
96
|
-
.get(kGithubOrigin)
|
|
97
|
-
.intercept({ path: "/users/octocat/repos", method: "GET" })
|
|
98
|
-
.reply(200, JSON.stringify([{ id: 42, name: "hello-world" }]), {
|
|
99
|
-
headers: { "content-type": "application/json" }
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const result = await users.octocat.repos().all();
|
|
103
|
-
|
|
104
|
-
assert.deepEqual(result, [{ id: 42, name: "hello-world" }]);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should fetch followers for a user", async() => {
|
|
108
|
-
mockAgent
|
|
109
|
-
.get(kGithubOrigin)
|
|
110
|
-
.intercept({ path: "/users/octocat/followers", method: "GET" })
|
|
111
|
-
.reply(200, JSON.stringify([{ login: "user1" }, { login: "user2" }]), {
|
|
112
|
-
headers: { "content-type": "application/json" }
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const result = await users.octocat.followers().all();
|
|
116
|
-
|
|
117
|
-
assert.deepEqual(result, [{ login: "user1" }, { login: "user2" }]);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("should fetch following for a user", async() => {
|
|
121
|
-
mockAgent
|
|
122
|
-
.get(kGithubOrigin)
|
|
123
|
-
.intercept({ path: "/users/octocat/following", method: "GET" })
|
|
124
|
-
.reply(200, JSON.stringify([{ login: "user3" }]), {
|
|
125
|
-
headers: { "content-type": "application/json" }
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const result = await users.octocat.following().all();
|
|
129
|
-
|
|
130
|
-
assert.deepEqual(result, [{ login: "user3" }]);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should fetch gists for a user", async() => {
|
|
134
|
-
mockAgent
|
|
135
|
-
.get(kGithubOrigin)
|
|
136
|
-
.intercept({ path: "/users/octocat/gists", method: "GET" })
|
|
137
|
-
.reply(200, JSON.stringify([{ id: "abc123" }]), {
|
|
138
|
-
headers: { "content-type": "application/json" }
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const result = await users.octocat.gists().all();
|
|
142
|
-
|
|
143
|
-
assert.deepEqual(result, [{ id: "abc123" }]);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("should fetch starred repos for a user", async() => {
|
|
147
|
-
mockAgent
|
|
148
|
-
.get(kGithubOrigin)
|
|
149
|
-
.intercept({ path: "/users/octocat/starred", method: "GET" })
|
|
150
|
-
.reply(200, JSON.stringify([{ id: 99, name: "starred-repo" }]), {
|
|
151
|
-
headers: { "content-type": "application/json" }
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const result = await users.octocat.starred().all();
|
|
155
|
-
|
|
156
|
-
assert.deepEqual(result, [{ id: 99, name: "starred-repo" }]);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@openally/config.typescript/esm-ts-next",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"types": ["node"],
|
|
7
|
-
"lib": ["ES2022", "ES2023", "ES2024", "ESNext"],
|
|
8
|
-
},
|
|
9
|
-
"include": ["src"],
|
|
10
|
-
"exclude": ["node_modules", "dist"]
|
|
11
|
-
}
|