Skip to content

Commit 0f1bf6a

Browse files
Refactor input parsing to use z.string() instead of z.coerce.string() for improved type safety
1 parent 7d1b889 commit 0f1bf6a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

pr-review/src/config.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ function setSecret<T>(value: T): T {
7373
*/
7474
export const config = {
7575
/** The personal access token of the GitHub user that is used to create the review. */
76-
userToken: setSecret(parseInput(z.coerce.string(), "user-token")),
76+
userToken: setSecret(parseInput(z.string(), "user-token")),
7777

7878
/** The URL for GitHub REST API */
79-
githubApiUrl: parseInput(z.coerce.string(), "github-api-url"),
79+
githubApiUrl: parseInput(z.string(), "github-api-url"),
8080

8181
/** The owner of the repository for which the review should be created. */
82-
owner: parseInput(z.coerce.string(), "owner"),
82+
owner: parseInput(z.string(), "owner"),
8383

8484
/** The name of the repository for which the review should be created. */
85-
repo: parseInput(z.coerce.string(), "repo"),
85+
repo: parseInput(z.string(), "repo"),
8686

8787
/** The number of the pull request for which the review should be created. */
8888
prNumber: parseInput(z.coerce.number(), "pr-number"),
8989

9090
/** The hash of the commit representing the code before changes. Used as the starting point in comparison. */
91-
baseSha: parseInput(z.coerce.string(), "base-sha"),
91+
baseSha: parseInput(z.string(), "base-sha"),
9292

9393
/** The hash of the commit representing the code after changes. Used as the end point in comparison. */
94-
headSha: parseInput(z.coerce.string(), "head-sha"),
94+
headSha: parseInput(z.string(), "head-sha"),
9595

9696
/** The service key for your SAP AI Core service instance. */
9797
aicoreServiceKey: ((): ServiceKey => {
@@ -102,16 +102,16 @@ export const config = {
102102
})(),
103103

104104
/** A list of patterns that match the files that should be included in the review. */
105-
includeFiles: parseInputAsArray(z.coerce.string(), "include-files"),
105+
includeFiles: parseInputAsArray(z.string(), "include-files"),
106106

107107
/** A list of patterns that match the files that should be excluded from the review. */
108-
excludeFiles: parseInputAsArray(z.coerce.string(), "exclude-files"),
108+
excludeFiles: parseInputAsArray(z.string(), "exclude-files"),
109109

110110
/** A list of patterns for files that should always be included as context, regardless of whether the PR affects them. */
111-
includeContextFiles: parseInputAsArray(z.coerce.string(), "include-context-files"),
111+
includeContextFiles: parseInputAsArray(z.string(), "include-context-files"),
112112

113113
/** A list of patterns for files that should be excluded from context, regardless of whether the PR affects them. */
114-
excludeContextFiles: parseInputAsArray(z.coerce.string(), "exclude-context-files"),
114+
excludeContextFiles: parseInputAsArray(z.string(), "exclude-context-files"),
115115

116116
/** The name of the SAP AI Core model that is used to generate the review. */
117117
model: parseInput(ModelName, "model"),
@@ -120,7 +120,7 @@ export const config = {
120120
modelParameters: parseInputAsJson(ModelParameters, "model-parameters"),
121121

122122
/** The version of the model that is used to generate the review. */
123-
modelVersion: parseInput(z.coerce.string(), "model-version"),
123+
modelVersion: parseInput(z.string(), "model-version"),
124124

125125
/** The deployment configuration as JSON. For example, {"resourceGroup": "abcdefg"}. */
126126
deploymentConfig: parseInputAsJson(DeploymentConfig, "deployment-config"),
@@ -129,24 +129,24 @@ export const config = {
129129
showModelMetadataFooter: parseInput(z.stringbool(), "show-model-metadata-footer"),
130130

131131
/** The base prompt that is used to generate the review. */
132-
prompt: parseInput(z.coerce.string(), "prompt"),
132+
prompt: parseInput(z.string(), "prompt"),
133133

134134
/** Defines where the review will be posted. */
135135
displayMode: parseInput(z.enum(["review-comment", "review-comment-delta", "none"]), "display-mode"),
136136

137137
/** The prompt to use for the disclaimer. */
138-
disclaimerPrompt: parseInput(z.coerce.string(), "disclaimer-prompt"),
138+
disclaimerPrompt: parseInput(z.string(), "disclaimer-prompt"),
139139

140140
/** The text that is placed before the review. */
141-
headerText: parseInput(z.coerce.string(), "header-text"),
141+
headerText: parseInput(z.string(), "header-text"),
142142

143143
/** The text that is placed after the review. */
144-
footerText: parseInput(z.coerce.string(), "footer-text"),
144+
footerText: parseInput(z.string(), "footer-text"),
145145

146146
/** The action to take with previous results. */
147147
previousResults: parseInput(z.enum(["keep", "hide"]), "previous-results"),
148148

149149
/** Additional prompt text that is added to the base prompt. */
150-
promptAddition: parseInput(z.coerce.string(), "prompt-addition"),
150+
promptAddition: parseInput(z.string(), "prompt-addition"),
151151
}
152152
export type Config = typeof config

0 commit comments

Comments
 (0)