Zod migration for improved selector generation - #34
Draft
miichom wants to merge 24 commits into
Draft
Conversation
…pteam, and metadata - Implemented character schema with detailed profile, class/job, minion, mount, and face accessory structures. - Created cwls schema for cross-world linkshell profiles and queries. - Developed freecompany schema encompassing company details, members, and rankings. - Added linkshell schema for linkshell profiles and member details. - Introduced pvpteam schema for player versus player team profiles and member information. - Established metadata enums for regions, datacenters, classes, jobs, races, and tribes. - Added utility functions for XPath to CSS conversion and selector context management. - Configured TypeScript settings for the project.
…tainability - Introduced a new utility function `resolveSchema` in `src/lib/utils.ts` to enhance schema resolution with metadata. - Removed outdated schemas: `character.ts`, `cwls.ts`, `freecompany.ts`, `linkshell.ts`, and `pvpteam.ts` to streamline the codebase. - Updated `src/utils.ts` to eliminate the old selector utility, integrating its functionality into the new schema resolution process. - Added a new TypeScript declaration file `zod.d.ts` to extend the Zod library with custom metadata types. - Cleaned up the `src/schemas/index.ts` to reflect the removal of obsolete schemas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is related to xivapi/nodestone#20, please check out this issue before deciding whether this should be included here or kept internally for
@xivapi/nodestone.Summary
As apart of the discussion of merging
@miichom/lodestoneinto@xivapi/nodestonefor better discoverability but more importantly overall better typings for the original project that inspired it. The latest version of the package uses CSS selectors instead of this improved approach for handling the scraped data via Zod by providing accurate typings for TypeScript and other languages using JSON packages that support thedraft-2020-12schema.Although, I have used personally XPath as the base as it was a artifact from when I was updating my package. If this is decided to switch to CSS as the base, supporting both XPath and CSS would still remain ideal for future support.
Changes made
git submodule addfor Node projects, importing it asgit://github.com/miichom/lodestone-css-selectorsas a dependency works just as well;import { ... } from "@xivapi/lodestone-css-selectors".Unsure of including
pyproject.toml- allowing developers to install it viapiporuvon a git repo, similar to Node. (Tried, unsure if needed or works — need help on this if we want)Todo
character.jsonand test to make sure it works as expected.Up for discussion
[Only for
.tsfiles] I addedtransforminto the Zod schemas, some Node projects may not need this included however it should not affect them if they don't usez.parseorz.safeParse- only if they import directly fromsrc/index.tsor@xivapi/lodestone-css-selectorsand use zod.