-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): refactor tablegen and add more advanced features (#437)
* refactor(cli): rename typeWithLocation * feat(cli): add routes, schemaMode (unimplemented) to config, improve validation * feat(cli): implement schemaMode flag * refactor(store): use new tablegen in store * refactor(cli): improve some rendering utils * feat(cli): add support for singleton tables * feat(cli): autoformat tablegen output * refactor(cli): settle on pure ESM config, add .ts support * refactor(cli): use zod for StoreUserConfig validation * chore(cli): remove outdated comment about hardhat * build(cli): clean up dependencies * refactor(cli): improve errors * refactor(cli): add validation error customization * feat(cli): add component mode * fix(cli): add NotESMConfigError and fix esnext resolution issues * build(cli): switch to nodenext resolution * build(cli): add dev script for tsup --watch * refactor(cli): extract common zod schemas * feat(cli): add component mode shorthand * fix(cli): report and continue for errors during formatting * fix(cli): fix commas for combined singleton and schema modes * refactor(cli): update some old conditionals with better syntax * feat(cli): improve struct and library naming * refactor(cli): improve config arguments * feat(cli): support no struct for multicolumn tables * refactor(cli): rename renderSchema to renderTable * feat(cli): improve code structure for renderTable * fix(cli): make dir if absent * feat(cli): generate push for dynamic fields * feat(store): make all tables autogenerated * feat(cli): generate deleteRecord * feat(cli): add primary key typing * refactor(store): use new tablegen * fix(cli): add missed bool cast * fix(cli): always render deleteRecord * feat(cli): add storeArgument option * refactor(store): update store tables * feat(world): use tablegen for RouteAccess * fix(cli): missing bracket for int typecast * chore(cli): change route doc comment Co-authored-by: alvarius <[email protected]> * chore(cli): fix typo 1 Co-authored-by: alvarius <[email protected]> * chore(cli): fix typo 2 Co-authored-by: alvarius <[email protected]> * chore(cli): remove outdated comment --------- Co-authored-by: alvarius <[email protected]>
- Loading branch information
Showing
53 changed files
with
2,285 additions
and
2,267 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
declare module "netlify"; | ||
declare module "inquirer-prompt-suggest"; | ||
declare module "prettier-plugin-solidity"; | ||
declare module "long"; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { z } from "zod"; | ||
import { | ||
validateBaseRoute, | ||
validateCapitalizedName, | ||
validateRoute, | ||
validateSingleLevelRoute, | ||
validateUncapitalizedName, | ||
} from "./validation.js"; | ||
|
||
/** Capitalized names of objects, like tables and systems */ | ||
export const ObjectName = z.string().superRefine(validateCapitalizedName); | ||
/** Uncapitalized names of values, like keys and columns */ | ||
export const ValueName = z.string().superRefine(validateUncapitalizedName); | ||
|
||
/** Ordinary routes */ | ||
export const OrdinaryRoute = z.string().superRefine(validateRoute); | ||
/** Routes with exactly 1 non-empty level */ | ||
export const SingleLevelRoute = z.string().superRefine(validateSingleLevelRoute); | ||
/** Base routes (can be an empty string) */ | ||
export const BaseRoute = z.string().superRefine(validateBaseRoute); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { describe, expectTypeOf } from "vitest"; | ||
import { z } from "zod"; | ||
import { StoreConfig, StoreUserConfig } from "./loadStoreConfig.js"; | ||
|
||
describe("loadStoreConfig", () => { | ||
// Typecheck manual interfaces against zod | ||
expectTypeOf<StoreUserConfig>().toEqualTypeOf<z.input<typeof StoreConfig>>(); | ||
// type equality isn't deep for optionals | ||
expectTypeOf<StoreUserConfig["tables"][string]>().toEqualTypeOf<z.input<typeof StoreConfig>["tables"][string]>(); | ||
// TODO If more nested schemas are added, provide separate tests for them | ||
}); |
Oops, something went wrong.