-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: threshold schema, slice and migration #425
Conversation
src/schemas/generator/v2/index.ts
Outdated
allowlist: z.string().array(), | ||
includeStaticAssets: z.boolean(), | ||
scriptName: z.string().default('my-script.js'), | ||
thresholds: z.array(ThresholdSchema), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thresholds
array is the only addition here.
@@ -0,0 +1,42 @@ | |||
import { z } from 'zod' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface State { | ||
thresholds: Array<Threshold> | ||
} | ||
|
||
interface Actions { | ||
addThreshold: (threshold: Threshold) => void | ||
updateThreshold: (threshold: Threshold) => void | ||
deleteThreshold: (id: string) => void | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial state and actions to get some UI and validation working in the upcoming branch.
src/schemas/generator/v2/index.ts
Outdated
allowlist: z.string().array(), | ||
includeStaticAssets: z.boolean(), | ||
scriptName: z.string().default('my-script.js'), | ||
thresholds: z.array(ThresholdSchema), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might be able to avoid adding a new schema version if you default thresholds to an empty array:
thresholds: z.array(ThresholdSchema).default([])
Since it's a new property added to schema, all what migrate
does is initiate an empty array, which can be done using zod's default
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked perfectly, thanks for the suggestion! 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Description
This PR is part of the Thresholds feature #369. It contains the initial setup including the Schema, Slice, and Migration.
How to Test
Checklist
npm run lint
) and all checks pass.npm test
) and all tests pass.Screenshots (if appropriate):
Related PR(s)/Issue(s)