From 74fbe344fa6365a0df18ecd8dc2406623a4f56a5 Mon Sep 17 00:00:00 2001 From: jongomez Date: Fri, 10 Nov 2023 15:06:54 +0000 Subject: [PATCH] fetch job and challenges lists and update JobsPerDepartment data source --- packages/docusaurus-playground/.env | 1 + .../docusaurus.config.js | 12 + .../docusaurus-playground/src/pages/index.mdx | 3 +- .../static/generated/challenges.json | 860 ++++++++++++++++++ .../static/generated/jobs.json | 289 ++++++ packages/logos-docusaurus-preset/package.json | 3 +- packages/logos-docusaurus-preset/src/index.ts | 2 +- .../src/plugins/generatedData.plugin.ts | 41 +- .../src/types/github.ts | 45 + .../src/utils/github.utils.ts | 134 +++ .../src/validateOptions.ts | 12 +- .../JobsPerDepartment/JobsPerDepartment.tsx | 64 +- .../SingleDepartmentJobs.tsx | 2 +- .../jobsPerDepartmentDummyData.ts | 2 +- .../mdx/JobsPerDepartment/useFetchJobs.ts | 161 ---- yarn.lock | 7 + 16 files changed, 1437 insertions(+), 201 deletions(-) create mode 100644 packages/docusaurus-playground/.env create mode 100644 packages/docusaurus-playground/static/generated/challenges.json create mode 100644 packages/docusaurus-playground/static/generated/jobs.json create mode 100644 packages/logos-docusaurus-preset/src/types/github.ts create mode 100644 packages/logos-docusaurus-preset/src/utils/github.utils.ts delete mode 100644 packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/useFetchJobs.ts diff --git a/packages/docusaurus-playground/.env b/packages/docusaurus-playground/.env new file mode 100644 index 0000000..705960f --- /dev/null +++ b/packages/docusaurus-playground/.env @@ -0,0 +1 @@ +GITHUB_ACCESS_TOKEN= \ No newline at end of file diff --git a/packages/docusaurus-playground/docusaurus.config.js b/packages/docusaurus-playground/docusaurus.config.js index ec516ca..1b9991d 100644 --- a/packages/docusaurus-playground/docusaurus.config.js +++ b/packages/docusaurus-playground/docusaurus.config.js @@ -45,6 +45,18 @@ const config = { routeBasePath: '/', path: 'docs', }, + generated: { + challenges: { + repoArray: [ + { owner: 'logos-co', repo: 'nomos-node' }, + { owner: 'logos-co', repo: 'nomos-specs' }, + ], + githubAccessToken: process.env.GITHUB_ACCESS_TOKEN, + }, + jobList: { + jobBoard: 'waku', + }, + }, }), ], ], diff --git a/packages/docusaurus-playground/src/pages/index.mdx b/packages/docusaurus-playground/src/pages/index.mdx index 6b22eb5..8572ad2 100644 --- a/packages/docusaurus-playground/src/pages/index.mdx +++ b/packages/docusaurus-playground/src/pages/index.mdx @@ -20,6 +20,7 @@ import { ShowcaseCard, JobsPerDepartment, } from '../components/mdx' +import * as jobData from '/generated/jobs.json' @@ -353,4 +354,4 @@ import { Build on Waku - + diff --git a/packages/docusaurus-playground/static/generated/challenges.json b/packages/docusaurus-playground/static/generated/challenges.json new file mode 100644 index 0000000..bd47421 --- /dev/null +++ b/packages/docusaurus-playground/static/generated/challenges.json @@ -0,0 +1,860 @@ +[ + { + "logos-co/nomos-node": [ + { + "id": "I_kwDOITdFfs5Zappx", + "title": "Mock NetworkBackend", + "url": "https://github.com/logos-co/nomos-node/issues/31", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["enhancement", "help wanted"], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": null, + "created_at": "2022-12-16T12:51:53Z", + "updated_at": "2022-12-19T11:17:44Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5Zat-A", + "title": "MockNetwork Backend (Preloaded version)", + "url": "https://github.com/logos-co/nomos-node/issues/32", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": null, + "created_at": "2022-12-16T13:06:07Z", + "updated_at": "2022-12-16T13:06:49Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5ZauYy", + "title": "MockNetwork Backend (Service Based version)", + "url": "https://github.com/logos-co/nomos-node/issues/33", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOITdFfs5Qv7jr", + "author": "danielSanchezQ", + "body": "Mock network implementation (service based version): https://github.com/logos-co/nomos-research/issues/31", + "createdAt": "2022-12-16T13:08:52Z" + } + ], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": null, + "created_at": "2022-12-16T13:07:33Z", + "updated_at": "2022-12-16T13:09:04Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5ZavIa", + "title": "Consensus mocknetwork adapter", + "url": "https://github.com/logos-co/nomos-node/issues/34", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": null, + "created_at": "2022-12-16T13:09:55Z", + "updated_at": "2022-12-16T13:12:50Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5ZavJ3", + "title": "Mempool mocknetwork adapter", + "url": "https://github.com/logos-co/nomos-node/issues/35", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": null, + "created_at": "2022-12-16T13:10:00Z", + "updated_at": "2022-12-16T13:13:52Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5dOnjg", + "title": "Mempool network adapter unique identifier", + "url": "https://github.com/logos-co/nomos-node/issues/59", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["Mempool", "network", "idea"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-01-31T11:14:38Z", + "updated_at": "2023-01-31T11:14:38Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5eiHIB", + "title": "Message storage consideration", + "url": "https://github.com/logos-co/nomos-node/issues/76", + "user": { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-02-15T14:54:40Z", + "updated_at": "2023-02-15T14:54:40Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5gQVVY", + "title": "Carnot execution simulation application", + "url": "https://github.com/logos-co/nomos-node/issues/92", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["consensus", "simulation"], + "commentCount": 2, + "comments": [ + { + "id": "IC_kwDOITdFfs5XAq_2", + "author": "danielSanchezQ", + "body": "This is the initial list of things to do. @al8n @bacv, please edit the list as completed or add new items as needed.\r\nThe relate the PRs, or create tasks in the board for each item you take. 🚀 ", + "createdAt": "2023-03-08T09:02:44Z" + }, + { + "id": "IC_kwDOITdFfs5YY5BM", + "author": "bacv", + "body": "Notes regarding next tasks:\r\n- [x] Warding - Analyze simulation state and implement the stopping of simulation.\r\n - [x] The difference minimum view and and maximum view in the individual nodes need to be tracked. #108\r\n - [x] Track stalled nodes (e.g incoming queue is empty, the node doesn't write to other queues). #109 \r\n- [x] Output processor - Gather states from every node during each step. Data needs to be per view. #111 \r\n- [x] Runners\r\n - [x] Synchronous runner - track the state and decide when to dump the data #111 \r\n - [x] Asynchronous runner - track the state and decide when to dump the data #111 \r\n - [x] A cache that stores the view number and the vector of nodeids and state. #119\r\n - [x] `Update` method - updates node state for that view #119\r\n - [x] Integrate cache withing the runners #119\r\n- [x] Mock Carnot node - every step will increment the view count. #114 \r\n- [x] Carnot node settings:\r\n - [x] Configurable network behavior. #110 \r\n - [x] Layout per view, accessible withing the node. #114 \r\n- [ ] Overlay trait needs to accept `seed` parameter when the layout is generated. https://github.com/logos-co/nomos-node/pull/122#discussion_r1187134287\r\n- [ ] Investigate if ViewId + ViewOverlay pairs need to be shared state. Nodes should recreate an overlay from seed. (Mentioned in https://github.com/logos-co/nomos-research/pull/114#discussion_r1159808313)", + "createdAt": "2023-03-24T14:43:51Z" + } + ], + "assignees": [], + "milestone": "Simulation App", + "created_at": "2023-03-08T08:59:56Z", + "updated_at": "2023-06-19T13:27:17Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5gxj8x", + "title": "Mempool Disccusion", + "url": "https://github.com/logos-co/nomos-node/issues/95", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["Mempool"], + "commentCount": 3, + "comments": [ + { + "id": "IC_kwDOITdFfs5Xg4Ay", + "author": "zeegomo", + "body": "If we decide that blocks only contain transactions hashes, then we need a way to retrieve transactions. \r\nIt's not too different from how a node that joins the network later has to download blocks actually.\r\n\r\nI think it could be valuable to have committed transactions in a coldish storage and conflate storage of pending transactions and transactions in blocks not yet committed, as we might have to access both", + "createdAt": "2023-03-14T14:45:05Z" + }, + { + "id": "IC_kwDOITdFfs5XhAe1", + "author": "danielSanchezQ", + "body": "> If we decide that blocks only contain transactions hashes, then we need a way to retrieve transactions. It's not too different from how a node that joins the network later has to download blocks actually.\r\n> \r\n> I think it could be valuable to have committed transactions in a coldish storage and conflate storage of pending transactions and transactions in blocks not yet committed, as we might have to access both\r\n\r\nThat way we make the mempool work only over the transactions ids right? So if retrieving a transaction it should be from this storage?", + "createdAt": "2023-03-14T15:01:35Z" + }, + { + "id": "IC_kwDOITdFfs5Xm0oT", + "author": "alvatar", + "body": "The mempool is subject to further research at this point. We cannot make an informed decision yet.\r\nFor now, the simplest mempool will do, and then we will work on this from a research perspective.\r\nTo clarify a few points:\r\n- Codex cannot be used for the mempool. It can be used for archival nodes, but that's a different use case.\r\n- The mempool will have a focus on privacy, likely being threshold-encrypted. \r\n- Ideally, the mempool guarantees data availability (ie like Narwhal), and the consensus will operate on the hashes of the mempool.\r\n", + "createdAt": "2023-03-15T11:00:57Z" + } + ], + "assignees": [], + "milestone": null, + "created_at": "2023-03-14T14:30:52Z", + "updated_at": "2023-03-15T11:15:31Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5gyh8x", + "title": "Remove block_transactions function in `Mempool` trait", + "url": "https://github.com/logos-co/nomos-node/issues/96", + "user": { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + }, + "labels": ["Mempool"], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOITdFfs5Xkr9G", + "author": "al8n", + "body": "Reopen this issue, because I think it auto-closed by the merge but we do not actually fix this issue.", + "createdAt": "2023-03-15T02:58:05Z" + } + ], + "assignees": [], + "milestone": null, + "created_at": "2023-03-14T16:31:00Z", + "updated_at": "2023-03-15T02:58:06Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5k3Xw1", + "title": "Block and Votes validation", + "url": "https://github.com/logos-co/nomos-node/issues/132", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["bug", "consensus"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Carnot Implementation", + "created_at": "2023-05-02T11:19:18Z", + "updated_at": "2023-05-02T11:19:28Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5k3aKB", + "title": "Remove TimeoutQc from NewView votes", + "url": "https://github.com/logos-co/nomos-node/issues/134", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["enhancement", "consensus"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Carnot Implementation", + "created_at": "2023-05-02T11:26:29Z", + "updated_at": "2023-05-02T11:26:29Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5lU0Ri", + "title": "Simulation metadata", + "url": "https://github.com/logos-co/nomos-node/issues/142", + "user": { + "login": "bacv", + "avatarUrl": "https://avatars.githubusercontent.com/u/2364987?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-05-08T10:05:58Z", + "updated_at": "2023-05-11T09:28:39Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5n1pPI", + "title": "Node consensus safe net", + "url": "https://github.com/logos-co/nomos-node/issues/171", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["consensus", "testing"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Carnot safe net", + "created_at": "2023-06-05T16:15:49Z", + "updated_at": "2023-06-26T09:37:38Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5n1pTj", + "title": "Carnot node long running tests", + "url": "https://github.com/logos-co/nomos-node/issues/174", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["consensus", "testing"], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOITdFfs5gBmbZ", + "author": "danielSanchezQ", + "body": "@AlbertoSoutullo This is the issue for tracking the long running tests with kurtosis", + "createdAt": "2023-06-28T08:59:45Z" + } + ], + "assignees": [ + { + "login": "AlbertoSoutullo", + "avatarUrl": "https://avatars.githubusercontent.com/u/23367096?u=908f327cf3085a462d5e5a013446e465e1d54f73&v=4" + } + ], + "milestone": "Carnot safe net", + "created_at": "2023-06-05T16:16:02Z", + "updated_at": "2023-06-28T08:59:51Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5ouExR", + "title": "Reduce public API from consensus service", + "url": "https://github.com/logos-co/nomos-node/issues/190", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-06-14T13:25:52Z", + "updated_at": "2023-06-14T13:31:17Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5pfaOc", + "title": "Node panics on unexpected block", + "url": "https://github.com/logos-co/nomos-node/issues/220", + "user": { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + }, + "labels": [], + "commentCount": 3, + "comments": [ + { + "id": "IC_kwDOITdFfs5fiGUy", + "author": "danielSanchezQ", + "body": "\"No parent\" means that the parent is not present, not that the block comes without the parent field right?", + "createdAt": "2023-06-22T14:48:11Z" + }, + { + "id": "IC_kwDOITdFfs5fk5oa", + "author": "youngjoon-lee", + "body": "> \"No parent\" means that the parent is not present\r\n\r\nIf so, I have a feeling that some other `assert!()` in consensus-engine may be also potential attack points. What do you think about changing assertions to Err?", + "createdAt": "2023-06-23T01:29:28Z" + }, + { + "id": "IC_kwDOITdFfs5fyK40", + "author": "zeegomo", + "body": "> \"No parent\" means that the parent is not present, not that the block comes without the parent field right?\r\n\r\nExactly\r\n\r\n\r\n> If so, I have a feeling that some other assert!() in consensus-engine may be also potential attack points. What do you think about changing assertions to Err?\r\n\r\nThe asserts are there to verify the public API contract is respected (i.e. some functions have preconditions that allow you to call them only when certain statements are true). We could also make them errors instead, the important thing is that we filter those cases at some point (either before feeding them to the engine or at the engine by returning errors instead). ", + "createdAt": "2023-06-26T08:42:42Z" + } + ], + "assignees": [], + "milestone": null, + "created_at": "2023-06-22T14:46:17Z", + "updated_at": "2023-06-26T08:42:42Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5qA6vn", + "title": "Simulation: support specifying node to network region in configuration.", + "url": "https://github.com/logos-co/nomos-node/issues/235", + "user": { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + }, + "labels": ["enhancement", "simulation"], + "commentCount": 3, + "comments": [ + { + "id": "IC_kwDOITdFfs5gCIpO", + "author": "danielSanchezQ", + "body": "They should be assigned based in some specific distribution. I think everything is calculated here: https://github.com/logos-co/nomos-node/blob/224a3a53f5c164cd5dec147f49177bc8f65a634a/simulations/src/network/regions.rs#L123", + "createdAt": "2023-06-28T10:40:24Z" + }, + { + "id": "IC_kwDOITdFfs5gCK3p", + "author": "al8n", + "body": "> They should be assigned based in some specific distribution. I think everything is calculated here: https://github.com/logos-co/nomos-node/blob/224a3a53f5c164cd5dec147f49177bc8f65a634a/simulations/src/network/regions.rs#L123\n\nYeah, but in the logs we cannot know such node belongs to which region. Then, I think we can assign the region information to the node, and then we can easily see a node belongs to which region from logs and analyze.", + "createdAt": "2023-06-28T10:47:46Z" + }, + { + "id": "IC_kwDOITdFfs5gCLqr", + "author": "danielSanchezQ", + "body": "> > They should be assigned based in some specific distribution. I think everything is calculated here: https://github.com/logos-co/nomos-node/blob/224a3a53f5c164cd5dec147f49177bc8f65a634a/simulations/src/network/regions.rs#L123\r\n> \r\n> Yeah, but in the logs we cannot know such node belongs to which region. Then, I think we can assign the region information to the node, and then we can easily see a node belongs to which region from logs and analyze.\r\n\r\nYeah. The way to go here IMO would be to log or dump the final distribution (regions map). No need to go too fancy here. ", + "createdAt": "2023-06-28T10:50:35Z" + } + ], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": "Simulation App", + "created_at": "2023-06-28T10:06:06Z", + "updated_at": "2023-06-28T10:50:36Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5qZ3mN", + "title": "Network layer rewrite", + "url": "https://github.com/logos-co/nomos-node/issues/236", + "user": { + "login": "youngjoon-lee", + "avatarUrl": "https://avatars.githubusercontent.com/u/5462944?u=fbb2556cd66f7852f2bc526ce4e39369f834f3b6&v=4" + }, + "labels": ["network"], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOITdFfs5lEXUN", + "author": "youngjoon-lee", + "body": "The first iteration is done. The folowing bullet points need to be done in the future.\r\n\r\n> - libp2p transports (TCP, QUIC, or both)\r\n> - libp2p transport authentication (Noise)\r\n> - libp2p gossipsub message signing", + "createdAt": "2023-08-28T12:49:40Z" + } + ], + "assignees": [], + "milestone": "Carnot Implementation", + "created_at": "2023-07-03T02:29:59Z", + "updated_at": "2023-08-28T12:49:40Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5qeEMi", + "title": "Consensus starts when there are no valid peers", + "url": "https://github.com/logos-co/nomos-node/issues/239", + "user": { + "login": "AlbertoSoutullo", + "avatarUrl": "https://avatars.githubusercontent.com/u/23367096?u=908f327cf3085a462d5e5a013446e465e1d54f73&v=4" + }, + "labels": [], + "commentCount": 4, + "comments": [ + { + "id": "IC_kwDOITdFfs5gfgb5", + "author": "danielSanchezQ", + "body": "@Zeegomo didn't we had this issue with the end-to-end tests?\r\n", + "createdAt": "2023-07-03T16:44:39Z" + }, + { + "id": "IC_kwDOITdFfs5ggNUI", + "author": "zeegomo", + "body": "> Unless I am doing something wrong, it looks like the consensus starts with no valid peers, and it gets \"stuck\" even tho I succesfully add new peers afterwards, here is a screenshot of the log\r\n\r\nThis is likely because the node doesn't wait for the network to be ready before sending the first message, and if enough of those messages get lost the round cannot advance.\r\nThis occurrence was very rare in testing and those rare occasions should have been fixed by https://github.com/logos-co/nomos-node/commit/b884e1ceca1a1148f23babb6e062c5487b70548b.\r\n\r\nFor reference, we always start the leader for view 1 first (should be the first node in the config list) and put it in the `initial_peers` section of other nodes. \r\n\r\n> and it gets \"stuck\" even tho I succesfully add new peers afterwards,\r\n\r\nthis is kind of expected as the node does not attempt to resend messages. It should actually trigger the unhappy path procedure to restore the network but as that has not been tested (working on it atm) it's possible it's not working", + "createdAt": "2023-07-03T19:39:45Z" + }, + { + "id": "IC_kwDOITdFfs5gmLWv", + "author": "AlbertoSoutullo", + "body": "> > Unless I am doing something wrong, it looks like the consensus starts with no valid peers, and it gets \"stuck\" even tho I succesfully add new peers afterwards, here is a screenshot of the log\r\n> \r\n> This is likely because the node doesn't wait for the network to be ready before sending the first message, and if enough of those messages get lost the round cannot advance. This occurrence was very rare in testing and those rare occasions should have been fixed by [b884e1c](https://github.com/logos-co/nomos-node/commit/b884e1ceca1a1148f23babb6e062c5487b70548b).\r\n> \r\n> For reference, we always start the leader for view 1 first (should be the first node in the config list) and put it in the `initial_peers` section of other nodes.\r\n> \r\n> > and it gets \"stuck\" even tho I succesfully add new peers afterwards,\r\n> \r\n> this is kind of expected as the node does not attempt to resend messages. It should actually trigger the unhappy path procedure to restore the network but as that has not been tested (working on it atm) it's possible it's not working\r\n\r\nThanks for answering! Do I wait then until new instructions?", + "createdAt": "2023-07-04T18:50:01Z" + }, + { + "id": "IC_kwDOITdFfs5gqgmQ", + "author": "AlbertoSoutullo", + "body": "Looks like it's working with PR #245 \r\n\r\nFeel free to close this issue if you want!", + "createdAt": "2023-07-05T13:25:30Z" + } + ], + "assignees": [], + "milestone": null, + "created_at": "2023-07-03T14:12:16Z", + "updated_at": "2023-07-05T13:25:30Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5tB6vC", + "title": "mixnet_delay in sim configuration", + "url": "https://github.com/logos-co/nomos-node/issues/276", + "user": { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + }, + "labels": ["simulation"], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + } + ], + "milestone": "Simulation App", + "created_at": "2023-07-31T13:39:51Z", + "updated_at": "2023-07-31T13:41:04Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5tQhn1", + "title": "Tailor cache size per-message type", + "url": "https://github.com/logos-co/nomos-node/issues/284", + "user": { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-08-02T12:02:41Z", + "updated_at": "2023-08-02T12:02:41Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5H9", + "title": "Nomos playground (testnet)", + "url": "https://github.com/logos-co/nomos-node/issues/348", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:57:53Z", + "updated_at": "2023-09-18T13:35:22Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5O6", + "title": "Coordination layer transactions", + "url": "https://github.com/logos-co/nomos-node/issues/352", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:58:11Z", + "updated_at": "2023-08-31T09:00:53Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5WN", + "title": "Nomos node docker", + "url": "https://github.com/logos-co/nomos-node/issues/357", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:58:28Z", + "updated_at": "2023-08-31T09:02:40Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5XF", + "title": "Mixnet node docker", + "url": "https://github.com/logos-co/nomos-node/issues/358", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:58:31Z", + "updated_at": "2023-08-31T09:02:48Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5YO", + "title": "Nomos config", + "url": "https://github.com/logos-co/nomos-node/issues/359", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:58:33Z", + "updated_at": "2023-08-31T09:03:15Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5vw5ZK", + "title": "Mixnet config", + "url": "https://github.com/logos-co/nomos-node/issues/360", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-08-31T08:58:36Z", + "updated_at": "2023-08-31T09:03:36Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5wsw6f", + "title": "Measure the quality of unobservability", + "url": "https://github.com/logos-co/nomos-node/issues/391", + "user": { + "login": "youngjoon-lee", + "avatarUrl": "https://avatars.githubusercontent.com/u/5462944?u=fbb2556cd66f7852f2bc526ce4e39369f834f3b6&v=4" + }, + "labels": ["mixnet"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Mixnet", + "created_at": "2023-09-11T15:38:26Z", + "updated_at": "2023-11-06T06:25:16Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs5yKJJA", + "title": "Document and standardize API", + "url": "https://github.com/logos-co/nomos-node/issues/444", + "user": { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + }, + "labels": ["documentation"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-09-27T10:52:28Z", + "updated_at": "2023-09-27T10:52:34Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs51Q4rb", + "title": "API Documentation: `utoipa` does not support generics", + "url": "https://github.com/logos-co/nomos-node/issues/491", + "user": { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + }, + "labels": ["documentation", "enhancement"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-10-30T02:45:03Z", + "updated_at": "2023-10-30T02:45:03Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs51j3ID", + "title": "Handle service state update events in `nomos-node-api`", + "url": "https://github.com/logos-co/nomos-node/issues/500", + "user": { + "login": "al8n", + "avatarUrl": "https://avatars.githubusercontent.com/u/42351146?u=f9252ee6a123643f6b4ddbc54852581fc8b99ecd&v=4" + }, + "labels": ["enhancement"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": "Nomos testnet (playground)", + "created_at": "2023-11-01T12:59:55Z", + "updated_at": "2023-11-01T13:00:30Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs51rpaL", + "title": "Investigate why tests fail if we include the block id during serialization", + "url": "https://github.com/logos-co/nomos-node/issues/506", + "user": { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + }, + "labels": ["bug"], + "commentCount": 0, + "comments": [], + "assignees": [], + "milestone": null, + "created_at": "2023-11-02T14:24:37Z", + "updated_at": "2023-11-02T14:24:37Z", + "projects": [] + }, + { + "id": "I_kwDOITdFfs52dRiG", + "title": "Add a tighter feature gate for metrics functionality", + "url": "https://github.com/logos-co/nomos-node/issues/523", + "user": { + "login": "bacv", + "avatarUrl": "https://avatars.githubusercontent.com/u/2364987?v=4" + }, + "labels": ["metrics"], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "bacv", + "avatarUrl": "https://avatars.githubusercontent.com/u/2364987?v=4" + } + ], + "milestone": null, + "created_at": "2023-11-10T10:50:11Z", + "updated_at": "2023-11-10T10:50:11Z", + "projects": [] + } + ] + }, + { + "logos-co/nomos-specs": [ + { + "id": "I_kwDOJL6gRs5llikO", + "title": "Review Random Beacon Spec being implemented by dev", + "url": "https://github.com/logos-co/nomos-specs/issues/25", + "user": { + "login": "MForensic", + "avatarUrl": "https://avatars.githubusercontent.com/u/33738574?v=4" + }, + "labels": [], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOJL6gRs5b8bKe", + "author": "MForensic", + "body": "Couldn't link the pull request, but mentioning it here. https://github.com/logos-co/nomos-specs/pull/24/files", + "createdAt": "2023-05-10T17:30:21Z" + } + ], + "assignees": [ + { + "login": "MForensic", + "avatarUrl": "https://avatars.githubusercontent.com/u/33738574?v=4" + } + ], + "milestone": null, + "created_at": "2023-05-10T17:17:15Z", + "updated_at": "2023-05-11T23:13:37Z", + "projects": [] + }, + { + "id": "I_kwDOJL6gRs5mtQf1", + "title": "Carnot from genesis block", + "url": "https://github.com/logos-co/nomos-specs/issues/26", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": [], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOJL6gRs5dAkUI", + "author": "danielSanchezQ", + "body": "Related comment on bumping view when adding genesis: https://github.com/logos-co/nomos-specs/pull/24#discussion_r1200718234", + "createdAt": "2023-05-24T04:05:58Z" + } + ], + "assignees": [ + { + "login": "zeegomo", + "avatarUrl": "https://avatars.githubusercontent.com/u/21265557?u=ea50ee0cd3b6ef42d1d3adb59688134155639045&v=4" + } + ], + "milestone": null, + "created_at": "2023-05-24T04:05:11Z", + "updated_at": "2023-05-24T04:05:58Z", + "projects": [] + }, + { + "id": "I_kwDOJL6gRs5mtRfc", + "title": "Construct `EntropyOverlay` from entropy", + "url": "https://github.com/logos-co/nomos-specs/issues/27", + "user": { + "login": "danielSanchezQ", + "avatarUrl": "https://avatars.githubusercontent.com/u/1133113?v=4" + }, + "labels": ["enhancement"], + "commentCount": 1, + "comments": [ + { + "id": "IC_kwDOJL6gRs5dAlLw", + "author": "danielSanchezQ", + "body": "Coming from here: https://github.com/logos-co/nomos-specs/pull/24#discussion_r1200702385", + "createdAt": "2023-05-24T04:12:07Z" + } + ], + "assignees": [], + "milestone": null, + "created_at": "2023-05-24T04:11:37Z", + "updated_at": "2023-05-24T04:12:07Z", + "projects": [] + }, + { + "id": "I_kwDOJL6gRs5n16NA", + "title": "Writing unit tests for PoS attestation mechanism Carnot", + "url": "https://github.com/logos-co/nomos-specs/issues/32", + "user": { + "login": "MForensic", + "avatarUrl": "https://avatars.githubusercontent.com/u/33738574?v=4" + }, + "labels": [], + "commentCount": 0, + "comments": [], + "assignees": [ + { + "login": "MForensic", + "avatarUrl": "https://avatars.githubusercontent.com/u/33738574?v=4" + } + ], + "milestone": null, + "created_at": "2023-06-05T17:04:32Z", + "updated_at": "2023-06-05T17:05:04Z", + "projects": [] + } + ] + } +] diff --git a/packages/docusaurus-playground/static/generated/jobs.json b/packages/docusaurus-playground/static/generated/jobs.json new file mode 100644 index 0000000..dd201d9 --- /dev/null +++ b/packages/docusaurus-playground/static/generated/jobs.json @@ -0,0 +1,289 @@ +{ + "departments": [ + { + "id": 87842, + "name": "App", + "parent_id": 43806, + "child_ids": [87847, 87852, 87850, 87848, 45530, 87849], + "jobs": [] + }, + { + "id": 54504, + "name": "Brand Design Studio", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 45532, + "name": "Business Development", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 87841, + "name": "Codex", + "parent_id": 43806, + "child_ids": [], + "jobs": [] + }, + { + "id": 84549, + "name": "Communications", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 45531, + "name": "Design", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 87847, + "name": "Desktop", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 87852, + "name": "Documentation", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 45547, + "name": "Engineering ", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 49925, + "name": "Finance", + "parent_id": 87845, + "child_ids": [], + "jobs": [] + }, + { + "id": 87854, + "name": "Infrastructure", + "parent_id": 43806, + "child_ids": [], + "jobs": [] + }, + { + "id": 87853, + "name": "Insights", + "parent_id": 87845, + "child_ids": [], + "jobs": [] + }, + { + "id": 87850, + "name": "Keycard", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 145838, + "name": "Leadership", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 74156, + "name": "Legal", + "parent_id": 87845, + "child_ids": [], + "jobs": [] + }, + { + "id": 91698, + "name": "Logos", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 43807, + "name": "Marketing", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 87848, + "name": "Mobile", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 87843, + "name": "Nimbus", + "parent_id": 43806, + "child_ids": [], + "jobs": [] + }, + { + "id": 144866, + "name": "Nomos", + "parent_id": 43806, + "child_ids": [], + "jobs": [] + }, + { + "id": 45548, + "name": "People Operations", + "parent_id": 87845, + "child_ids": [], + "jobs": [] + }, + { + "id": 45530, + "name": "Product Design", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 90941, + "name": "Program Management", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 43806, + "name": "Research & Development", + "parent_id": null, + "child_ids": [ + 87842, 87841, 87854, 87843, 144866, 87846, 87981, 87847, 87852, 87850, + 87848, 45530, 87849 + ], + "jobs": [] + }, + { + "id": 87851, + "name": "Security", + "parent_id": 87845, + "child_ids": [], + "jobs": [] + }, + { + "id": 87845, + "name": "Services", + "parent_id": null, + "child_ids": [49925, 87853, 74156, 45548, 87851], + "jobs": [] + }, + { + "id": 91697, + "name": "Status App ", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 54783, + "name": "Technical Writing ", + "parent_id": null, + "child_ids": [], + "jobs": [] + }, + { + "id": 87846, + "name": "Vac", + "parent_id": 43806, + "child_ids": [], + "jobs": [] + }, + { + "id": 87981, + "name": "Waku", + "parent_id": 43806, + "child_ids": [], + "jobs": [ + { + "absolute_url": "https://boards.greenhouse.io/waku/jobs/5499678", + "data_compliance": [ + { + "type": "gdpr", + "requires_consent": false, + "requires_processing_consent": false, + "requires_retention_consent": false, + "retention_period": null + } + ], + "internal_job_id": 2707470, + "location": { "name": "Remote (Worldwide)" }, + "metadata": null, + "id": 5499678, + "updated_at": "2023-11-10T10:02:59-05:00", + "requisition_id": "WAK-GL-1", + "title": "Growth Lead" + }, + { + "absolute_url": "https://boards.greenhouse.io/waku/jobs/5453098", + "data_compliance": [ + { + "type": "gdpr", + "requires_consent": false, + "requires_processing_consent": false, + "requires_retention_consent": false, + "retention_period": null + } + ], + "internal_job_id": 1830496, + "location": { "name": "Remote, Worldwide" }, + "metadata": null, + "id": 5453098, + "updated_at": "2023-10-20T07:01:13-04:00", + "requisition_id": "PROV-Sec-3", + "title": "Protocol Researcher (Distributed Systems)" + }, + { + "absolute_url": "https://boards.greenhouse.io/waku/jobs/5453103", + "data_compliance": [ + { + "type": "gdpr", + "requires_consent": false, + "requires_processing_consent": false, + "requires_retention_consent": false, + "retention_period": null + } + ], + "internal_job_id": 2694724, + "location": { "name": "Remote (Worldwide)" }, + "metadata": null, + "id": 5453103, + "updated_at": "2023-10-20T13:12:19-04:00", + "requisition_id": "WAK-BD-1", + "title": "Technical Business Development Lead " + } + ] + }, + { + "id": 87849, + "name": "Web", + "parent_id": 87842, + "child_ids": [], + "jobs": [] + }, + { + "id": 0, + "name": "No Department", + "parent_id": null, + "child_ids": [], + "jobs": [] + } + ] +} diff --git a/packages/logos-docusaurus-preset/package.json b/packages/logos-docusaurus-preset/package.json index 8c6dbf4..fea8e02 100644 --- a/packages/logos-docusaurus-preset/package.json +++ b/packages/logos-docusaurus-preset/package.json @@ -29,7 +29,8 @@ "@docusaurus/utils-validation": "^2.4.1", "docusaurus-plugin-sass": "^0.2.3", "fs-extra": "^10.1.0", - "lodash": "^4.17.21" + "lodash": "^4.17.21", + "node-fetch": "2" }, "engines": { "node": ">=16.14" diff --git a/packages/logos-docusaurus-preset/src/index.ts b/packages/logos-docusaurus-preset/src/index.ts index 6fc1eb4..b1fad6a 100644 --- a/packages/logos-docusaurus-preset/src/index.ts +++ b/packages/logos-docusaurus-preset/src/index.ts @@ -121,7 +121,7 @@ export default function logosPreset( } } - if (options.generated) plugins.push([generatedDataPlugin, {}]) + if (options.generated) plugins.push([generatedDataPlugin, options.generated]) return { plugins, diff --git a/packages/logos-docusaurus-preset/src/plugins/generatedData.plugin.ts b/packages/logos-docusaurus-preset/src/plugins/generatedData.plugin.ts index 0390fad..6f9a959 100644 --- a/packages/logos-docusaurus-preset/src/plugins/generatedData.plugin.ts +++ b/packages/logos-docusaurus-preset/src/plugins/generatedData.plugin.ts @@ -2,14 +2,18 @@ import { PluginModule } from '@docusaurus/types' import * as fsp from 'fs/promises' import * as fs from 'fs' import path from 'path' +import fetch from 'node-fetch' +import { fetchGithubIssues } from '../utils/github.utils' type JobListConfig = { - url: string + jobBoard: string } type ChallengeConfig = { - repo: string - owner: string + repoArray: { + repo: string + owner: string + }[] githubAccessToken: string } @@ -18,23 +22,35 @@ export type GeneratedDataPluginConfig = { challenges?: ChallengeConfig } -const fetchJobList = async ({ url, out }: { out: string } & JobListConfig) => { - const list = [] +export type FetchJobListParams = { + jobBoard: string + out: string +} - await fsp.writeFile(out, JSON.stringify(list)) +const fetchJobList = async ({ jobBoard, out }: FetchJobListParams) => { + try { + const response = await fetch( + `https://boards-api.greenhouse.io/v1/boards/${jobBoard}/departments`, + ) + const jobDepartmentData = await response.json() + + await fsp.writeFile(out, JSON.stringify(jobDepartmentData)) + } catch (err) { + console.error('\nfetchJobList error:') + console.error(err) + } } const fetchChallenges = async ({ - owner, - repo, + repoArray, out, githubAccessToken, }: { out: string } & ChallengeConfig) => { - const list = [] + const issues = await fetchGithubIssues(repoArray, githubAccessToken) - await fsp.writeFile(out, JSON.stringify(list)) + await fsp.writeFile(out, JSON.stringify(issues)) } export const generatedDataPlugin: PluginModule = (context, options) => { @@ -51,14 +67,13 @@ export const generatedDataPlugin: PluginModule = (context, options) => { loadContent: async () => { if (jobList) await fetchJobList({ - url: jobList.url, + jobBoard: jobList.jobBoard, out: path.join(outDir, 'jobs.json'), }) if (challenges) await fetchChallenges({ - repo: challenges.repo, - owner: challenges.owner, + repoArray: challenges.repoArray, githubAccessToken: challenges.githubAccessToken, out: path.join(outDir, 'challenges.json'), }) diff --git a/packages/logos-docusaurus-preset/src/types/github.ts b/packages/logos-docusaurus-preset/src/types/github.ts new file mode 100644 index 0000000..b90beec --- /dev/null +++ b/packages/logos-docusaurus-preset/src/types/github.ts @@ -0,0 +1,45 @@ +type GithubProject = { + name: string +} + +type GithubUser = { + login: string + avatarUrl: string +} + +type GithubComment = { + id: string + author: string + body: string + createdAt: string +} + +type GithubAssignee = { + login: string + avatarUrl: string +} + +export type GithubIssue = { + id: string + title: string + body?: string + url: string + user: GithubUser + labels: string[] + commentCount: number + comments: GithubComment[] + assignees: GithubAssignee[] + milestone?: string + created_at: string + updated_at: string + projects: GithubProject[] +} + +export type GithubIssuesPerRepo = { + [key: string]: GithubIssue[] +} + +export type RepoOwnerArray = { + repo: string + owner: string +}[] diff --git a/packages/logos-docusaurus-preset/src/utils/github.utils.ts b/packages/logos-docusaurus-preset/src/utils/github.utils.ts new file mode 100644 index 0000000..27ab549 --- /dev/null +++ b/packages/logos-docusaurus-preset/src/utils/github.utils.ts @@ -0,0 +1,134 @@ +import { + GithubIssue, + GithubIssuesPerRepo, + RepoOwnerArray, +} from '../types/github' +import fetch from 'node-fetch' + +const https = require('https') + +// Inspired by: +// https://github.com/acid-info/rnd-dynamic-list/blob/master/challenges/fetch-challenges-multiple-private-graphql.js + +const sanitizeAlias = (str) => str.replace(/-/g, '_') + +const createQueryPart = (owner, repo) => { + const alias = sanitizeAlias(`${owner}_${repo}`) + return ` + ${alias}: repository(owner: "${owner}", name: "${repo}") { + issues(first: 100, states: OPEN) { + nodes { + id + title + url + author { + login + avatarUrl + } + labels(first: 10) { + nodes { + name + } + } + commentCount: comments { + totalCount + } + commentsDetailed: comments(first: 10) { + nodes { + id + author { + login + } + body + createdAt + } + } + assignees(first: 10) { + nodes { + login + avatarUrl + } + } + milestone { + title + } + createdAt + updatedAt + projectCards(first: 10) { + nodes { + project { + name + url + } + } + } + } + } + } + ` +} + +export const fetchGithubIssues = async ( + repoOwnerArray: RepoOwnerArray, + githubAccessToken: string, +): Promise => { + let query = '{' + repoOwnerArray.forEach(({ owner, repo }) => { + query += createQueryPart(owner, repo) + }) + query += '}' + + const response = await fetch('https://api.github.com/graphql', { + method: 'POST', + headers: { + 'User-Agent': 'NodeJS-Script', + Authorization: `Bearer ${githubAccessToken}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ query }), + }) + + if (!response.ok) { + throw new Error(`GitHub API responded with status ${response.status}`) + } + + const responseData = await response.json() + + const parsedIssues: GithubIssuesPerRepo[] = repoOwnerArray.map( + ({ owner, repo }) => { + const alias = sanitizeAlias(`${owner}_${repo}`) + const rawIssues = responseData.data[alias]?.issues.nodes || [] + return { + [`${owner}/${repo}`]: rawIssues.map( + (issue): GithubIssue => ({ + id: issue.id, + title: issue.title, + url: issue.url, + user: { + login: issue.author.login, + avatarUrl: issue.author.avatarUrl, + }, + labels: issue.labels.nodes.map((label) => label.name), + commentCount: issue.commentCount.totalCount, + comments: issue.commentsDetailed.nodes.map((comment) => ({ + id: comment.id, + author: comment.author.login, + body: comment.body, + createdAt: comment.createdAt, + })), + assignees: issue.assignees.nodes, + milestone: issue.milestone ? issue.milestone.title : null, + created_at: issue.createdAt, + updated_at: issue.updatedAt, + projects: issue.projectCards.nodes.map((card) => ({ + name: card.project.name, + url: card.project.url, + })), + }), + ), + } + }, + ) + + return parsedIssues +} diff --git a/packages/logos-docusaurus-preset/src/validateOptions.ts b/packages/logos-docusaurus-preset/src/validateOptions.ts index 0916f09..d2ed894 100644 --- a/packages/logos-docusaurus-preset/src/validateOptions.ts +++ b/packages/logos-docusaurus-preset/src/validateOptions.ts @@ -21,11 +21,17 @@ const schema = Joi.object({ generated: Joi.object({ challenges: Joi.object({ githubAccessToken: Joi.string().required(), - owner: Joi.string().required(), - repo: Joi.string().required(), + repoArray: Joi.array() + .items( + Joi.object({ + repo: Joi.string().required(), + owner: Joi.string().required(), + }), + ) + .required(), }).optional(), jobList: Joi.object({ - url: Joi.string().uri().required(), + jobBoard: Joi.string().uri().required(), }).optional(), }).optional(), }) diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/JobsPerDepartment.tsx b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/JobsPerDepartment.tsx index e503998..f7eba87 100644 --- a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/JobsPerDepartment.tsx +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/JobsPerDepartment.tsx @@ -1,9 +1,38 @@ import { Typography } from '@acid-info/lsd-react' import { SingleDepartmentJobs } from './SingleDepartmentJobs' -import useFetchJobs, { JobDepartmentArray } from './useFetchJobs' import React from 'react' import { jobsPerDepartmentDummyData } from './jobsPerDepartmentDummyData' +export type JobDepartmentData = { + id: number + name: string + parent_id: number | null + child_ids: number[] + jobs: Job[] +} + +type Job = { + absolute_url: string + data_compliance?: { + type: string + requires_consent: boolean + requires_processing_consent: boolean + requires_retention_consent: boolean + retention_period: null | string + }[] + internal_job_id: number + location: { + name: string + } + metadata?: any + id: number + updated_at: string + requisition_id: string + title: string +} + +export type JobDepartmentArray = JobDepartmentData[] | null + type JobsPerDepartmentHeaderProps = { message?: string } @@ -34,42 +63,39 @@ const hasJobs = (jobsPerDepartment: JobDepartmentArray): boolean => { } type JobsPerDepartmentProps = React.HTMLAttributes & { - jobBoard: string + jobData: { departments?: JobDepartmentArray } titleFilter?: string fetchAll?: boolean useDummyData?: boolean } export const JobsPerDepartment: React.FC = ({ - jobBoard, + jobData, titleFilter = '', fetchAll = false, useDummyData = false, ...props }) => { - const { data, error, isLoading } = useFetchJobs( - jobBoard, - titleFilter, - useDummyData ? jobsPerDepartmentDummyData : null, - ) + let jobArray: JobDepartmentData[] | undefined | null = useDummyData + ? jobsPerDepartmentDummyData + : jobData?.departments - if (isLoading) { - // Skipping loading state for now, as per the designer's request. - return - } - - if (error) { - return - } - - if (!data || !hasJobs(data)) { + if (!jobArray || !hasJobs(jobArray)) { return } + // Filter jobs in each department based on titleFilter + if (jobArray && titleFilter) { + jobArray = jobArray.map((department) => ({ + ...department, + jobs: department.jobs.filter((job) => job.title.includes(titleFilter)), + })) + } + return (
- {data.map((department) => { + {jobArray.map((department) => { return ( ) diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/SingleDepartmentJobs.tsx b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/SingleDepartmentJobs.tsx index 2a26e61..94aa981 100644 --- a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/SingleDepartmentJobs.tsx +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/SingleDepartmentJobs.tsx @@ -1,9 +1,9 @@ import { Typography } from '@acid-info/lsd-react' -import { JobDepartmentData } from './useFetchJobs' import React from 'react' import { IconExternalLink } from '@logos-theme/components/Icon' import './JobsPerDepartment.scss' import Link from '@docusaurus/Link' +import { JobDepartmentData } from '.' type SingleDepartmentJobsProps = { department: JobDepartmentData diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/jobsPerDepartmentDummyData.ts b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/jobsPerDepartmentDummyData.ts index ee967da..9583fed 100644 --- a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/jobsPerDepartmentDummyData.ts +++ b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/jobsPerDepartmentDummyData.ts @@ -1,4 +1,4 @@ -import { JobDepartmentArray } from './useFetchJobs' +import { JobDepartmentArray } from '.' // Only for dev purposes - prevents making multiple requests to the API while developing. export const jobsPerDepartmentDummyData: JobDepartmentArray = [ diff --git a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/useFetchJobs.ts b/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/useFetchJobs.ts deleted file mode 100644 index 570ef79..0000000 --- a/packages/logos-docusaurus-theme/src/client/components/mdx/JobsPerDepartment/useFetchJobs.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { useEffect, useRef, useState } from 'react' - -/* -// Here's an array with some possible job boards: -const allJobBoards = [ - 'testacidinfo', // Acid Test job board - 'logos', - 'nimbus', - 'codex', - 'status72', // Note: this job board has all the jobs from the other job boards - 'nomos', - 'thestatusnetwork', - 'instituteoffreetechnologies', // aka IFT - 'vac', - 'waku', -] as const -*/ - -export type JobDepartmentName = string - -export type JobDepartmentData = { - id: number - name: string - parent_id: number | null - child_ids: number[] - jobs: Job[] -} - -export type Job = { - absolute_url: string - data_compliance?: { - type: string - requires_consent: boolean - requires_processing_consent: boolean - requires_retention_consent: boolean - retention_period: null | string - }[] - internal_job_id: number - location: { - name: string - } - metadata?: any - id: number - updated_at: string - requisition_id: string - title: string -} - -export type JobDepartmentArray = JobDepartmentData[] | null - -type UseFetchJobsReturn = { - data: JobDepartmentArray - error: Error | null - isLoading: boolean -} - -const parseJobDepartments = ( - rawJobDepartmentData: any, - titleFilter?: string, -): JobDepartmentArray => { - const jobDepartmentArray = rawJobDepartmentData?.departments - - if (!jobDepartmentArray) { - throw Error('No departments found in rawJobDepartmentData') - } - - if (!Array.isArray(jobDepartmentArray)) { - throw Error('The received jobDepartmentArray is not an array') - } - - // Map through each department and filter its jobs based on titleFilter - const processedJobDepartmentArray: JobDepartmentData[] = - jobDepartmentArray.map((department: JobDepartmentData) => { - let filteredJobs = department.jobs - - if (titleFilter) { - filteredJobs = department.jobs.filter((job) => - job.title.includes(titleFilter), - ) - } - - return { - ...department, - jobs: filteredJobs, - } - }) - - return processedJobDepartmentArray -} - -// Fetches jobs from greenhouse via their department endpoint: -// https://developers.greenhouse.io/job-board.html#list-departments - -export const useFetchJobs = ( - jobBoardToFetch: string, - titleFilter: string = '', - dummyResponse: JobDepartmentArray = null, -): UseFetchJobsReturn => { - const [data, setData] = useState(null) - const [error, setError] = useState(null) - const [isLoading, setIsLoading] = useState(false) - const isMounted = useRef(true) - - const fetchJobs = async (): Promise<{ - jobsPerDepartment: JobDepartmentArray - errorData: Error | null - }> => { - try { - if (dummyResponse) { - return { jobsPerDepartment: dummyResponse, errorData: null } - } - - const response = await fetch( - `https://boards-api.greenhouse.io/v1/boards/${jobBoardToFetch}/departments`, - ) - const jobDepartmentData = await response.json() - - const jobsPerDepartment: JobDepartmentArray = parseJobDepartments( - jobDepartmentData, - titleFilter, - ) - - return { - jobsPerDepartment, - errorData: null, - } - } catch (err) { - const errorData = - err instanceof Error - ? err - : typeof err === 'string' - ? new Error(err) - : new Error('Unknown error') - - console.error(err) - return { jobsPerDepartment: null, errorData } - } - } - - useEffect(() => { - if (isLoading) return - - setIsLoading(true) - fetchJobs().then(({ jobsPerDepartment, errorData }) => { - // We should not update state if the component is unmounted. - if (!isMounted.current) return - - if (jobsPerDepartment) setData(jobsPerDepartment) - if (errorData) setError(errorData) - setIsLoading(false) - }) - - return () => { - isMounted.current = false - } - }, []) - - return { data, error, isLoading } -} - -export default useFetchJobs diff --git a/yarn.lock b/yarn.lock index 6fb18ec..d439f96 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12461,6 +12461,13 @@ node-emoji@^1.10.0: dependencies: lodash "^4.17.21" +node-fetch@2: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-fetch@2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"