@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.
Files changed (71) hide show
  1. package/dist/api/rawFile.d.ts +20 -0
  2. package/dist/api/rawFile.d.ts.map +1 -0
  3. package/dist/api/rawFile.js +25 -0
  4. package/dist/api/rawFile.js.map +1 -0
  5. package/dist/api/repos.d.ts +21 -0
  6. package/dist/api/repos.d.ts.map +1 -0
  7. package/dist/api/repos.js +32 -0
  8. package/dist/api/repos.js.map +1 -0
  9. package/dist/api/users.d.ts +21 -0
  10. package/dist/api/users.d.ts.map +1 -0
  11. package/dist/api/users.js +20 -0
  12. package/dist/api/users.js.map +1 -0
  13. package/dist/class/ApiEndpoint.d.ts +20 -0
  14. package/dist/class/ApiEndpoint.d.ts.map +1 -0
  15. package/dist/class/ApiEndpoint.js +60 -0
  16. package/dist/class/ApiEndpoint.js.map +1 -0
  17. package/dist/class/GithubClient.d.ts +22 -0
  18. package/dist/class/GithubClient.d.ts.map +1 -0
  19. package/dist/class/GithubClient.js +21 -0
  20. package/dist/class/GithubClient.js.map +1 -0
  21. package/dist/class/HttpLinkParser.d.ts +4 -0
  22. package/dist/class/HttpLinkParser.d.ts.map +1 -0
  23. package/dist/class/HttpLinkParser.js +14 -0
  24. package/dist/class/HttpLinkParser.js.map +1 -0
  25. package/dist/class/createApiProxy.d.ts +2 -0
  26. package/dist/class/createApiProxy.d.ts.map +1 -0
  27. package/dist/class/createApiProxy.js +8 -0
  28. package/dist/class/createApiProxy.js.map +1 -0
  29. package/dist/constants.d.ts +4 -0
  30. package/dist/constants.d.ts.map +1 -0
  31. package/{src/constants.ts → dist/constants.js} +1 -0
  32. package/dist/constants.js.map +1 -0
  33. package/{src/index.ts → dist/index.d.ts} +2 -5
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +5 -0
  36. package/dist/index.js.map +1 -0
  37. package/{src/types.ts → dist/types.d.ts} +14 -27
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/types.js +2 -0
  40. package/dist/types.js.map +1 -0
  41. package/package.json +5 -2
  42. package/.all-contributorsrc +0 -16
  43. package/.editorconfig +0 -14
  44. package/.github/dependabot.yml +0 -25
  45. package/.github/workflows/codeql.yml +0 -78
  46. package/.github/workflows/node.js.yml +0 -52
  47. package/.github/workflows/publish.yml +0 -29
  48. package/.github/workflows/scorecards.yml +0 -76
  49. package/SECURITY.md +0 -5
  50. package/docs/api/ApiEndpoint.md +0 -66
  51. package/docs/api/GithubClient.md +0 -50
  52. package/docs/api/fetchRawFile.md +0 -106
  53. package/docs/api/repos.md +0 -97
  54. package/docs/api/users.md +0 -76
  55. package/eslint.config.mjs +0 -3
  56. package/src/api/rawFile.ts +0 -73
  57. package/src/api/repos.ts +0 -88
  58. package/src/api/users.ts +0 -51
  59. package/src/class/ApiEndpoint.ts +0 -108
  60. package/src/class/GithubClient.ts +0 -62
  61. package/src/class/HttpLinkParser.ts +0 -17
  62. package/src/class/createApiProxy.ts +0 -9
  63. package/test/ApiEndpoint.spec.ts +0 -362
  64. package/test/GithubClient.spec.ts +0 -185
  65. package/test/HttpLinkParser.spec.ts +0 -78
  66. package/test/createApiProxy.spec.ts +0 -58
  67. package/test/rawFile.spec.ts +0 -382
  68. package/test/repos.spec.ts +0 -221
  69. package/test/tsconfig.json +0 -11
  70. package/test/users.spec.ts +0 -159
  71. package/tsconfig.json +0 -11
@@ -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
- }