{"id":25652378,"url":"https://github.com/hyperweb-io/ast-challenge","last_synced_at":"2025-08-01T11:11:49.222Z","repository":{"id":112584155,"uuid":"559775946","full_name":"hyperweb-io/ast-challenge","owner":"hyperweb-io","description":"AST code challenge","archived":false,"fork":false,"pushed_at":"2022-12-26T04:42:08.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T18:17:48.028Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperweb-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-31T04:08:15.000Z","updated_at":"2025-02-02T12:57:15.000Z","dependencies_parsed_at":"2023-05-16T17:15:27.311Z","dependency_job_id":null,"html_url":"https://github.com/hyperweb-io/ast-challenge","commit_stats":null,"previous_names":["hyperweb-io/ast-challenge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fast-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fast-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fast-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperweb-io%2Fast-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperweb-io","download_url":"https://codeload.github.com/hyperweb-io/ast-challenge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240356193,"owners_count":19788513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-23T18:17:49.461Z","updated_at":"2025-02-23T18:17:51.482Z","avatar_url":"https://github.com/hyperweb-io.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ast-challenge\n\nWelcome! We're excited that you're interested in working with us, we hope you enjoy this challenge :)\n## Instructions\n\n1. create a cloned version of this repo (don't fork it publicly)\n2. keep the original git history and only add new commits to your clone\n3. make sure to include all of the [deliverables](#deliverables) mentioned in [challenge](#challenge)\n\n## setup\n\n```\nyarn install\n```\n\n## run tests\n\n```\nyarn test:watch\n```\n\n## AST -\u003e TS example\n\nlook inside of `__tests__/pure.test.ts` to see how to make ASTs with babel.\n\n## TS -\u003e AST example\n\nedit `./scripts/fixture.ts`, and then run\n\n```\nyarn test:ast\n```\n\nthen, look at the `./scripts/test-output.json` for the result\n\n# challenge\n\nTake the input and output below, and make a function that can generate this code using babel ASTs:\n\n### function input\n\n```json\n  {\n    \"Pools\": {\n        \"requestType\": \"QueryPoolsRequest\",\n        \"responseType\": \"QueryPoolsResponse\"\n    }\n  }\n```\n\n### function output\n\n```ts\nexport interface UsePoolsQuery\u003cTData\u003e extends ReactQueryParams\u003cQueryPoolsResponse, TData\u003e {\n    request?: QueryPoolsRequest;\n}\nconst usePools = \u003cTData = QueryPoolsResponse,\u003e({\n    request,\n    options\n}: UsePoolsQuery\u003cTData\u003e) =\u003e {\n    return useQuery\u003cQueryPoolsResponse, Error, TData\u003e([\"poolsQuery\", request], () =\u003e {\n        if (!queryService) throw new Error(\"Query Service not initialized\");\n        return queryService.pools(request);\n    }, options);\n};\n```\n\n### HINTS\n\n1. [example for converting AST to Typescript](#ast---ts-example)\n2. [example for converting Typescript to AST](#ts---ast-example)\n\n#### deliverables\n\nYou'll be writing a function to generate code, and we'll be writing a test as well as the code:\n\n- [ ] create a new test, call it `ast-challenge.test.ts` inside of [`__tests__`](./__tests__/) folder\n- [ ] write code for the creation of the AST inside of `src/index.ts`\n- [ ] write code for the converting AST into Typesript code inside of `__tests__/ast-challenge.test.ts`\n- [ ] use `expect(resultingCode).toMatchSnapshot()` to store output of code generation\n\nAfter completing the function, parameterize (meaning make function arguments to make dynamic) the following properties, so that a developer can use this method to generate many of these hooks. Be sure to include parameterization of these fields:\n\n- [ ] Query interface (`UsePoolsQuery`)\n- [ ] hook name (`usePools`)\n- [ ] request type (`QueryPoolsRequest`)\n- [ ] response type (`QueryPoolsResponse`)\n- [ ] queryService method name (`queryService.pools()`)\n- [ ] key name  (`poolsQuery`)\n\n#### bonus\n\n- [ ] add a test case in a new test that uses all methods from [`./example-methods.json`](./example-methods.json)\n- [ ] in the test case, use `expect(resultingCode).toMatchSnapshot()` and save the snapshot for all the code","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperweb-io%2Fast-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperweb-io%2Fast-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperweb-io%2Fast-challenge/lists"}