-
Notifications
You must be signed in to change notification settings - Fork 230
wire format for a nonEmpty field in string/[]string params #1912
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |||||||||||||||||
| SecretParamOptions, | ||||||||||||||||||
| InternalExpression, | ||||||||||||||||||
| InterpolationExpression, | ||||||||||||||||||
| SupportsNonEmpty, | ||||||||||||||||||
| } from "./types"; | ||||||||||||||||||
|
|
||||||||||||||||||
| export { BUCKET_PICKER, select, multiSelect } from "./types"; | ||||||||||||||||||
|
|
@@ -181,7 +182,7 @@ | |||||||||||||||||
| * @param options Configuration options for the parameter. | ||||||||||||||||||
| * @returns A parameter with a `string` return type for `.value`. | ||||||||||||||||||
| */ | ||||||||||||||||||
| export function defineString(name: string, options: ParamOptions<string> = {}): StringParam { | ||||||||||||||||||
| export function defineString(name: string, options: ParamOptions<string> & SupportsNonEmpty = {}): StringParam { | ||||||||||||||||||
|
Check failure on line 185 in src/params/index.ts
|
||||||||||||||||||
| const param = new StringParam(name, options); | ||||||||||||||||||
| registerParam(param); | ||||||||||||||||||
| return param; | ||||||||||||||||||
|
Comment on lines
+185
to
188
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the conditional
Suggested change
|
||||||||||||||||||
|
|
@@ -235,7 +236,7 @@ | |||||||||||||||||
| * @param options Configuration options for the parameter. | ||||||||||||||||||
| * @returns A parameter with a `string[]` return type for `.value`. | ||||||||||||||||||
| */ | ||||||||||||||||||
| export function defineList(name: string, options: ParamOptions<string[]> = {}): ListParam { | ||||||||||||||||||
| export function defineList(name: string, options: ParamOptions<string[]> & SupportsNonEmpty = {}): ListParam { | ||||||||||||||||||
|
Check failure on line 239 in src/params/index.ts
|
||||||||||||||||||
| const param = new ListParam(name, options); | ||||||||||||||||||
| registerParam(param); | ||||||||||||||||||
| return param; | ||||||||||||||||||
|
Comment on lines
+239
to
242
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the conditional
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -411,6 +411,8 @@ | |||||||||||||||||||||||||||||||
| input?: ParamInput<T>; | ||||||||||||||||||||||||||||||||
| /** Optional format annotation for additional type information (e.g., "json" for JSON-encoded secrets). */ | ||||||||||||||||||||||||||||||||
| format?: string; | ||||||||||||||||||||||||||||||||
| /** Disallows the empty string/empty list when prompting for input. */ | ||||||||||||||||||||||||||||||||
| nonEmpty?: boolean; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
|
|
@@ -429,13 +431,18 @@ | |||||||||||||||||||||||||||||||
| type: ParamValueType; | ||||||||||||||||||||||||||||||||
| input?: ParamInput<T>; | ||||||||||||||||||||||||||||||||
| format?: string; | ||||||||||||||||||||||||||||||||
| nonEmpty?: boolean; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** Configuration options which can be used to customize the prompting behavior of a parameter. */ | ||||||||||||||||||||||||||||||||
| /** Basic configuration options which can be used to customize the prompting behavior of a parameter. */ | ||||||||||||||||||||||||||||||||
| export type ParamOptions<T extends string | number | boolean | string[]> = Omit< | ||||||||||||||||||||||||||||||||
| ParamSpec<T>, | ||||||||||||||||||||||||||||||||
| "name" | "type" | ||||||||||||||||||||||||||||||||
| "name" | "type" | "nonEmpty" | ||||||||||||||||||||||||||||||||
| >; | ||||||||||||||||||||||||||||||||
| /** A configuration to disallow empty string/empty list, which is unioned to Paramoptions for types where it has meaning. */ | ||||||||||||||||||||||||||||||||
| export type SupportsNonEmpty = { | ||||||||||||||||||||||||||||||||
| nonEmpty?: boolean; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Check failure on line 445 in src/params/types.ts
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+437
to
+445
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating a separate
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typescript knowers: does this work? Is this remotely readable? I think I blacked out when I read this and saw a vision of Cthulhu as I was under, but maybe I'm not sufficiently rocq-brained.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this works. There's other ways too. |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** Configuration options which can be used to customize the behavior of a secret parameter. */ | ||||||||||||||||||||||||||||||||
| export interface SecretParamOptions { | ||||||||||||||||||||||||||||||||
|
|
@@ -453,7 +460,7 @@ | |||||||||||||||||||||||||||||||
| export abstract class Param<T extends string | number | boolean | string[]> extends Expression<T> { | ||||||||||||||||||||||||||||||||
| static type: ParamValueType = "string"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| constructor(readonly name: string, readonly options: ParamOptions<T> = {}) { | ||||||||||||||||||||||||||||||||
| constructor(readonly name: string, readonly options: ParamOptions<T> & SupportsNonEmpty = {}) { | ||||||||||||||||||||||||||||||||
| super(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+463
to
465
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
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.
Since
SupportsNonEmptyis no longer needed as a separate type, we can remove its import.