effect 4.0.0-rc.113 → 4.0.0-rc.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Effect.d.ts +268 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +33 -2
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +1 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js.map +1 -1
- package/dist/FileSystem.d.ts +3 -4
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Match.d.ts +1 -14
- package/dist/Match.d.ts.map +1 -1
- package/dist/Schema.d.ts +4 -4
- package/dist/Schema.d.ts.map +1 -1
- package/dist/SchemaRepresentation.d.ts +39 -24
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +37 -23
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/internal/arbitrary/schema.js.map +1 -1
- package/dist/internal/effect.js +16 -8
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +221 -230
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +4 -4
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +6 -2
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +8 -7
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +1 -6
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +2 -0
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +271 -7
- package/src/Effectable.ts +2 -2
- package/src/FileSystem.ts +3 -4
- package/src/Match.ts +1 -1
- package/src/Schema.ts +4 -7
- package/src/SchemaRepresentation.ts +39 -24
- package/src/internal/arbitrary/schema.ts +16 -16
- package/src/internal/effect.ts +34 -11
- package/src/internal/schema/fromJsonSchemaDocument.ts +294 -268
- package/src/internal/schema/toCodeDocument.ts +4 -4
- package/src/unstable/cli/Prompt.ts +22 -11
- package/src/unstable/cli/internal/command.ts +2 -0
|
@@ -484,7 +484,7 @@ export function toCodeDocument(
|
|
|
484
484
|
`${element.isOptional ? "Schema.optionalKey(" : ""}${type.runtime}${element.isOptional ? ")" : ""}${
|
|
485
485
|
runtimeAnnotate(element.annotations, "annotateKey")
|
|
486
486
|
}`,
|
|
487
|
-
|
|
487
|
+
element.isOptional ? `(${type.Type})?` : type.Type
|
|
488
488
|
)
|
|
489
489
|
})
|
|
490
490
|
const rest = representation.rest.map((item, index) => recur(item, [...path, "rest", index]))
|
|
@@ -516,15 +516,15 @@ export function toCodeDocument(
|
|
|
516
516
|
const properties = representation.propertySignatures.map((property, index) => {
|
|
517
517
|
const isSymbol = typeof property.name === "symbol"
|
|
518
518
|
const name = isSymbol
|
|
519
|
-
? addSymbol(property.name)
|
|
519
|
+
? `[${addSymbol(property.name)}]`
|
|
520
520
|
: formatPropertyKey(property.name)
|
|
521
521
|
const type = recur(property.type, [...path, "propertySignatures", index, "type"])
|
|
522
522
|
let runtime = type.runtime
|
|
523
523
|
if (property.isMutable) runtime = `Schema.mutableKey(${runtime})`
|
|
524
524
|
if (property.isOptional) runtime = `Schema.optionalKey(${runtime})`
|
|
525
525
|
runtime += runtimeAnnotate(property.annotations, "annotateKey")
|
|
526
|
-
const runtimeName =
|
|
527
|
-
const typeName = `${property.isMutable ? "" : "readonly "}${
|
|
526
|
+
const runtimeName = property.name === "__proto__" ? `[${name}]` : name
|
|
527
|
+
const typeName = `${property.isMutable ? "" : "readonly "}${name}${property.isOptional ? "?" : ""}`
|
|
528
528
|
return {
|
|
529
529
|
code: makeCode(`${runtimeName}: ${runtime}`, `${typeName}: ${type.Type}`)
|
|
530
530
|
}
|
|
@@ -447,9 +447,9 @@ export interface FileOptions extends ThemeOptions {
|
|
|
447
447
|
*/
|
|
448
448
|
export interface SelectOptions<A> extends ThemeOptions {
|
|
449
449
|
/**
|
|
450
|
-
* The message to display
|
|
450
|
+
* The prompt message. Omit to display only the choices.
|
|
451
451
|
*/
|
|
452
|
-
readonly message
|
|
452
|
+
readonly message?: string | undefined
|
|
453
453
|
/**
|
|
454
454
|
* The choices to display to the user.
|
|
455
455
|
*/
|
|
@@ -468,6 +468,10 @@ export interface SelectOptions<A> extends ThemeOptions {
|
|
|
468
468
|
* @since 4.0.0
|
|
469
469
|
*/
|
|
470
470
|
export interface AutoCompleteOptions<A> extends SelectOptions<A> {
|
|
471
|
+
/**
|
|
472
|
+
* The required prompt message.
|
|
473
|
+
*/
|
|
474
|
+
readonly message: string
|
|
471
475
|
/**
|
|
472
476
|
* The label used for the filter display (defaults to "filter").
|
|
473
477
|
*/
|
|
@@ -2699,7 +2703,9 @@ const handleFileProcess = (options: FileOptionsReq) => {
|
|
|
2699
2703
|
})
|
|
2700
2704
|
}
|
|
2701
2705
|
|
|
2702
|
-
interface SelectOptionsReq<A> extends
|
|
2706
|
+
interface SelectOptionsReq<A> extends SelectOptions<A> {
|
|
2707
|
+
readonly maxPerPage: number
|
|
2708
|
+
}
|
|
2703
2709
|
interface MultiSelectOptionsReq extends MultiSelectOptions {}
|
|
2704
2710
|
|
|
2705
2711
|
type MultiSelectState = {
|
|
@@ -2826,7 +2832,7 @@ const renderMultiSelectNextFrame = Effect.fnUntraced(
|
|
|
2826
2832
|
const trailingSymbol = annotateSymbol(figures.pointerSmall, figures.mutedColor)
|
|
2827
2833
|
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options)
|
|
2828
2834
|
const error = renderMultiSelectError(state, figures.pointer, figures)
|
|
2829
|
-
return Ansi.cursorHide + promptMsg
|
|
2835
|
+
return Ansi.cursorHide + withSelectHeader(promptMsg, choices) + error
|
|
2830
2836
|
}
|
|
2831
2837
|
)
|
|
2832
2838
|
|
|
@@ -2839,7 +2845,7 @@ const renderMultiSelectSubmission = Effect.fnUntraced(
|
|
|
2839
2845
|
const selectedText = selectedChoices.join(", ")
|
|
2840
2846
|
const leadingSymbol = annotateSymbol(figures.tick, figures.successColor)
|
|
2841
2847
|
const trailingSymbol = annotateSymbol(figures.ellipsis, figures.mutedColor)
|
|
2842
|
-
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options)
|
|
2848
|
+
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options) ?? leadingSymbol
|
|
2843
2849
|
return promptMsg + " " + Ansi.annotate(selectedText, figures.submittedColor) + "\n"
|
|
2844
2850
|
}
|
|
2845
2851
|
)
|
|
@@ -2901,7 +2907,7 @@ const handleMultiSelectClear = <A>(options: SelectOptionsReq<A>) =>
|
|
|
2901
2907
|
const promptText = renderSelectOutput(figures.prefix, figures.pointerSmall, options, { plain: true })
|
|
2902
2908
|
const choicesText = renderMultiSelectChoices(state, options, figures, { plain: true })
|
|
2903
2909
|
const errorText = renderMultiSelectError(state, figures.pointer, figures, { plain: true })
|
|
2904
|
-
const clearOutput = clearOutputWithError(
|
|
2910
|
+
const clearOutput = clearOutputWithError(withSelectHeader(promptText, choicesText), columns, errorText)
|
|
2905
2911
|
return clearOutput + clearPrompt
|
|
2906
2912
|
})
|
|
2907
2913
|
|
|
@@ -3265,7 +3271,6 @@ type AutoCompleteState = {
|
|
|
3265
3271
|
readonly filtered: ReadonlyArray<number>
|
|
3266
3272
|
}
|
|
3267
3273
|
|
|
3268
|
-
interface SelectOptionsReq<A> extends OptionsReq<SelectOptions<A>> {}
|
|
3269
3274
|
interface AutoCompleteOptionsReq<A> extends OptionsReq<AutoCompleteOptions<A>> {}
|
|
3270
3275
|
|
|
3271
3276
|
const filterAutoCompleteChoices = <A>(choices: ReadonlyArray<SelectChoice<A>>, query: string) => {
|
|
@@ -3302,7 +3307,13 @@ const renderSelectOutput = <A>(
|
|
|
3302
3307
|
trailingSymbol: string,
|
|
3303
3308
|
options: SelectOptionsReq<A>,
|
|
3304
3309
|
renderOptions?: RenderOptions | undefined
|
|
3305
|
-
)
|
|
3310
|
+
): string | undefined =>
|
|
3311
|
+
options.message === undefined
|
|
3312
|
+
? undefined
|
|
3313
|
+
: renderPrompt("", options.message, leadingSymbol, trailingSymbol, renderOptions)
|
|
3314
|
+
|
|
3315
|
+
const withSelectHeader = (header: string | undefined, body: string): string =>
|
|
3316
|
+
header === undefined ? body : header + "\n" + body
|
|
3306
3317
|
|
|
3307
3318
|
const renderAutoCompleteFilter = <A>(
|
|
3308
3319
|
state: AutoCompleteState,
|
|
@@ -3464,7 +3475,7 @@ const renderSelectNextFrame = Effect.fnUntraced(function*<A>(state: SelectState,
|
|
|
3464
3475
|
const leadingSymbol = annotateSymbol(figures.prefix, figures.primaryColor)
|
|
3465
3476
|
const trailingSymbol = annotateSymbol(figures.pointerSmall, figures.mutedColor)
|
|
3466
3477
|
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options)
|
|
3467
|
-
return Ansi.cursorHide + promptMsg
|
|
3478
|
+
return Ansi.cursorHide + withSelectHeader(promptMsg, choices)
|
|
3468
3479
|
})
|
|
3469
3480
|
|
|
3470
3481
|
const renderAutoCompleteNextFrame = Effect.fnUntraced(function*<A>(
|
|
@@ -3484,7 +3495,7 @@ const renderSelectSubmission = Effect.fnUntraced(function*<A>(state: SelectState
|
|
|
3484
3495
|
const selected = options.choices[state].title
|
|
3485
3496
|
const leadingSymbol = annotateSymbol(figures.tick, figures.successColor)
|
|
3486
3497
|
const trailingSymbol = annotateSymbol(figures.ellipsis, figures.mutedColor)
|
|
3487
|
-
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options)
|
|
3498
|
+
const promptMsg = renderSelectOutput(leadingSymbol, trailingSymbol, options) ?? leadingSymbol
|
|
3488
3499
|
return promptMsg + " " + Ansi.annotate(selected, figures.submittedColor) + "\n"
|
|
3489
3500
|
})
|
|
3490
3501
|
|
|
@@ -3585,7 +3596,7 @@ const handleSelectClear = <A>(options: SelectOptionsReq<A>) =>
|
|
|
3585
3596
|
const clearPrompt = Ansi.eraseLine + Ansi.cursorLeft
|
|
3586
3597
|
const promptText = renderSelectOutput(figures.prefix, figures.pointerSmall, options, { plain: true })
|
|
3587
3598
|
const choicesText = renderSelectChoices(state, options, figures, { plain: true })
|
|
3588
|
-
const clearOutput = eraseText(
|
|
3599
|
+
const clearOutput = eraseText(withSelectHeader(promptText, choicesText), columns)
|
|
3589
3600
|
return clearOutput + clearPrompt
|
|
3590
3601
|
})
|
|
3591
3602
|
|
|
@@ -234,6 +234,8 @@ export const makeCommand = <const Name extends string, Input, E, R, ContextInput
|
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Converts a single flag param into a FlagDoc for help display.
|
|
237
|
+
*
|
|
238
|
+
* @internal
|
|
237
239
|
*/
|
|
238
240
|
export const toFlagDoc = (
|
|
239
241
|
single: Param.Single<typeof Param.flagKind, unknown>,
|