@reliverse/rempts 1.7.32 → 1.7.34

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.
@@ -1 +1,2 @@
1
- export declare const confirm: any;
1
+ import type { ConfirmPromptOptions } from "../../types.js";
2
+ export declare const confirm: (options: ConfirmPromptOptions) => Promise<boolean>;
@@ -63,11 +63,15 @@ function renderPrompt(params) {
63
63
  export async function confirmPrompt(options) {
64
64
  const {
65
65
  title = "",
66
+ message,
67
+ // Alias for title
66
68
  defaultValue,
69
+ initialValue,
70
+ // Alias for defaultValue
71
+ content,
67
72
  titleColor = "cyan",
68
73
  titleTypography = "none",
69
74
  titleVariant,
70
- content,
71
75
  contentColor = "dim",
72
76
  contentTypography = "italic",
73
77
  contentVariant,
@@ -80,11 +84,13 @@ export async function confirmPrompt(options) {
80
84
  endTitleColor = "dim",
81
85
  border = true
82
86
  } = options;
87
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title;
88
+ const finalDefaultValue = defaultValue ?? initialValue;
83
89
  const rl = readline.createInterface({ input, output });
84
90
  let errorMessage = "";
85
- const effectiveDefault = defaultValue ?? true;
91
+ const effectiveDefault = finalDefaultValue ?? true;
86
92
  const defaultHint = effectiveDefault ? "[Y/n]" : "[y/N]";
87
- const adjustedTitle = displayInstructions ? title : `${re.blue(defaultHint)} ${title}`;
93
+ const adjustedTitle = displayInstructions ? finalTitle : `${re.blue(defaultHint)} ${finalTitle}`;
88
94
  const instructions = `Use <y/n> to confirm or deny, <Enter> for default (${effectiveDefault ? "Y" : "N"}), <Ctrl+C> to exit`;
89
95
  let lastUILineCount = 0;
90
96
  function endPrompt(isCtrlC = false) {
@@ -200,10 +200,14 @@ async function validateInput(input, validate) {
200
200
  export async function inputPrompt(options) {
201
201
  const {
202
202
  title,
203
+ message,
204
+ // Alias for title
203
205
  hint,
204
206
  hintPlaceholderColor = "blue",
205
207
  validate,
206
208
  defaultValue = "",
209
+ initialValue,
210
+ // Alias for defaultValue
207
211
  titleColor = "cyan",
208
212
  titleTypography = "none",
209
213
  titleVariant = "none",
@@ -225,6 +229,8 @@ export async function inputPrompt(options) {
225
229
  shouldStream = false,
226
230
  streamDelay = 20
227
231
  } = options;
232
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title;
233
+ const finalDefaultValue = defaultValue ?? initialValue;
228
234
  const terminal = readline.createInterface({
229
235
  input: process.stdin,
230
236
  output: process.stdout
@@ -257,7 +263,7 @@ export async function inputPrompt(options) {
257
263
  async function handleHardcodedInput() {
258
264
  msgUndoAll();
259
265
  await renderPromptUI({
260
- title,
266
+ title: finalTitle,
261
267
  hint,
262
268
  hintPlaceholderColor,
263
269
  content,
@@ -279,7 +285,7 @@ export async function inputPrompt(options) {
279
285
  shouldStream,
280
286
  streamDelay
281
287
  });
282
- const finalAnswer = currentInput || defaultValue;
288
+ const finalAnswer = currentInput || finalDefaultValue;
283
289
  const validated = await validateInput(finalAnswer, validate);
284
290
  if (!validated.isValid) {
285
291
  terminal.close();
@@ -303,7 +309,7 @@ export async function inputPrompt(options) {
303
309
  deleteLastLine();
304
310
  }
305
311
  await renderPromptUI({
306
- title,
312
+ title: finalTitle,
307
313
  hint,
308
314
  hintPlaceholderColor,
309
315
  content,
@@ -338,20 +344,20 @@ export async function inputPrompt(options) {
338
344
  if (showPlaceholder && currentInput !== "") {
339
345
  showPlaceholder = false;
340
346
  }
341
- const finalAnswer = currentInput || defaultValue;
347
+ const finalAnswer = currentInput || finalDefaultValue;
342
348
  const validated = await validateInput(finalAnswer, validate);
343
349
  if (validated.isValid) {
344
- if (!currentInput && defaultValue) {
350
+ if (!currentInput && finalDefaultValue) {
345
351
  if (mode === "password") {
346
352
  deleteLastLine();
347
353
  deleteLastLine();
348
354
  msg({
349
355
  type: "M_MIDDLE",
350
- title: ` ${getMaskChar(mask).repeat(defaultValue.length)}`
356
+ title: ` ${getMaskChar(mask).repeat(finalDefaultValue.length)}`
351
357
  });
352
358
  } else {
353
359
  deleteLastLine();
354
- msg({ type: "M_MIDDLE", title: ` ${re.reset(defaultValue)}` });
360
+ msg({ type: "M_MIDDLE", title: ` ${re.reset(finalDefaultValue)}` });
355
361
  }
356
362
  }
357
363
  if (errorMessage) {
@@ -1 +1,2 @@
1
- export declare const multiselect: any;
1
+ import type { MultiselectPromptParams } from "../../types.js";
2
+ export declare const multiselect: <T extends string>(params: MultiselectPromptParams<T>) => Promise<T[]>;
@@ -93,9 +93,11 @@ function renderPromptUI(params) {
93
93
  export async function multiselectPrompt(params) {
94
94
  const {
95
95
  title = "",
96
+ message,
96
97
  content = "",
97
98
  options,
98
99
  defaultValue = [],
100
+ initialValue,
99
101
  borderColor = "dim",
100
102
  titleColor = "cyan",
101
103
  titleTypography = "none",
@@ -112,8 +114,10 @@ export async function multiselectPrompt(params) {
112
114
  maxSelect,
113
115
  selectAll = false
114
116
  } = params;
115
- let pointer = defaultValue.length > 0 ? options.findIndex(
116
- (opt) => opt && isSelectOption(opt) && defaultValue.includes(opt.value) && !opt.disabled
117
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title;
118
+ const finalDefaultValue = defaultValue ?? initialValue;
119
+ let pointer = finalDefaultValue.length > 0 ? options.findIndex(
120
+ (opt) => opt && isSelectOption(opt) && finalDefaultValue.includes(opt.value) && !opt.disabled
117
121
  ) : 0;
118
122
  if (pointer === -1) {
119
123
  pointer = options.findIndex(
@@ -126,7 +130,7 @@ export async function multiselectPrompt(params) {
126
130
  const selectedOptions = new Set(
127
131
  selectAll ? options.map(
128
132
  (opt, index) => opt && isSelectOption(opt) && !opt.disabled ? index : -1
129
- ).filter((i) => i !== -1) : defaultValue.map(
133
+ ).filter((i) => i !== -1) : finalDefaultValue.map(
130
134
  (val) => options.findIndex((o) => o && isSelectOption(o) && o.value === val)
131
135
  ).filter(
132
136
  (i) => i >= 0 && options[i] && isSelectOption(options[i]) && !options[i].disabled
@@ -183,7 +187,7 @@ export async function multiselectPrompt(params) {
183
187
  }
184
188
  }
185
189
  lastUILineCount = renderPromptUI({
186
- title,
190
+ title: finalTitle,
187
191
  content,
188
192
  options,
189
193
  pointer,
@@ -205,7 +209,7 @@ export async function multiselectPrompt(params) {
205
209
  });
206
210
  }
207
211
  lastUILineCount = renderPromptUI({
208
- title,
212
+ title: finalTitle,
209
213
  content,
210
214
  options,
211
215
  pointer,
@@ -1 +1,2 @@
1
- export declare const select: any;
1
+ import type { SelectPromptParams } from "../../types.js";
2
+ export declare const select: <T extends string>(params: SelectPromptParams<T>) => Promise<T>;
@@ -1,34 +1,5 @@
1
- import type { BorderColorName, ColorName, SelectOption, TypographyName, VariantName } from "../../types.js";
2
- import { symbols } from "../msg-fmt/messages.js";
3
- interface SeparatorOption {
4
- separator: true;
5
- width?: number;
6
- symbol?: keyof typeof symbols;
7
- }
8
- interface SelectPromptParams<T extends string> {
9
- title?: string;
10
- message?: string;
11
- content?: string;
12
- options: (SelectOption<T> | SeparatorOption)[];
13
- defaultValue?: T;
14
- required?: boolean;
15
- borderColor?: BorderColorName;
16
- titleColor?: ColorName;
17
- titleTypography?: TypographyName;
18
- titleVariant?: VariantName;
19
- contentColor?: ColorName;
20
- contentTypography?: TypographyName;
21
- border?: boolean;
22
- endTitle?: string;
23
- endTitleColor?: ColorName;
24
- debug?: boolean;
25
- terminalWidth?: number;
26
- displayInstructions?: boolean;
27
- shouldStream?: boolean;
28
- streamDelay?: number;
29
- }
1
+ import type { SelectPromptParams } from "../../types.js";
30
2
  /**
31
3
  * Displays a selectable prompt in the terminal and returns the chosen value.
32
4
  */
33
5
  export declare function selectPrompt<T extends string>(params: SelectPromptParams<T>): Promise<T>;
34
- export {};
@@ -111,10 +111,11 @@ async function renderPromptUI(params) {
111
111
  export async function selectPrompt(params) {
112
112
  const {
113
113
  title = "",
114
- message = "",
114
+ message,
115
115
  content = "",
116
116
  options,
117
117
  defaultValue,
118
+ initialValue,
118
119
  required = false,
119
120
  borderColor = "dim",
120
121
  titleColor = "cyan",
@@ -131,9 +132,10 @@ export async function selectPrompt(params) {
131
132
  shouldStream = false,
132
133
  streamDelay = 20
133
134
  } = params;
134
- const finalTitle = message || title;
135
- let selectedIndex = defaultValue ? options.findIndex(
136
- (option) => isSelectOption(option) && option.value === defaultValue && !option.disabled
135
+ const finalTitle = message && title ? `${title}: ${message}` : message ?? title;
136
+ const finalDefaultValue = defaultValue ?? initialValue;
137
+ let selectedIndex = finalDefaultValue ? options.findIndex(
138
+ (option) => isSelectOption(option) && option.value === finalDefaultValue && !option.disabled
137
139
  ) : -1;
138
140
  if (selectedIndex === -1) {
139
141
  selectedIndex = options.findIndex(
package/bin/mod.d.ts CHANGED
@@ -17,7 +17,7 @@ export type { EmptyArgs, BaseArgProps, BaseArgDefinition, PositionalArgDefinitio
17
17
  export { loadCommand } from "./libs/launcher/run-command.js";
18
18
  export { addCompletions } from "./libs/launcher/trpc-orpc-support/completions.js";
19
19
  export { CliValidationError, FailedToExitError, } from "./libs/launcher/trpc-orpc-support/errors.js";
20
- export { TrpcCommand, parseRouter, createRpcCli, z, } from "./libs/launcher/trpc-orpc-support/index.js";
20
+ export { TrpcCommand, parseRouter, createRpcCli, z, trpcServer, zod, } from "./libs/launcher/trpc-orpc-support/index.js";
21
21
  export { flattenedProperties, incompatiblePropertyPairs, getDescription, getSchemaTypes, getEnumChoices, } from "./libs/launcher/trpc-orpc-support/json-schema.js";
22
22
  export type { CommandJSON } from "./libs/launcher/trpc-orpc-support/json.js";
23
23
  export { commandToJSON } from "./libs/launcher/trpc-orpc-support/json.js";
package/bin/mod.js CHANGED
@@ -41,7 +41,9 @@ export {
41
41
  TrpcCommand,
42
42
  parseRouter,
43
43
  createRpcCli,
44
- z
44
+ z,
45
+ trpcServer,
46
+ zod
45
47
  } from "./libs/launcher/trpc-orpc-support/index.js";
46
48
  export {
47
49
  flattenedProperties,
package/bin/types.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface PromptOptions {
26
26
  contentVariant?: VariantName;
27
27
  hint?: string;
28
28
  placeholder?: string;
29
- validate?: (value: any) => boolean | string | Promise<boolean | string>;
29
+ validate?: (value: any) => boolean | string | undefined | Promise<boolean | string | undefined>;
30
30
  defaultColor?: ColorName;
31
31
  defaultTypography?: TypographyName;
32
32
  choices?: ChoiceOptions[];
@@ -116,7 +116,9 @@ export interface ProgressBar {
116
116
  export type PromptType = "input" | "inputmasked" | "select" | "multiselect" | "nummultiselect" | "numselect" | "toggle" | "confirm" | "spinner" | "progressbar" | "results" | "nextsteps" | "animatedtext" | "date" | "end";
117
117
  export interface ConfirmPromptOptions {
118
118
  title: string;
119
+ message?: string;
119
120
  defaultValue?: boolean;
121
+ initialValue?: boolean;
120
122
  content?: string;
121
123
  titleColor?: ColorName;
122
124
  titleTypography?: TypographyName;
@@ -192,6 +194,7 @@ export type InputPromptOptions = {
192
194
  contentVariant?: VariantName;
193
195
  customSymbol?: string;
194
196
  defaultValue?: string;
197
+ initialValue?: string;
195
198
  endTitle?: string;
196
199
  endTitleColor?: ColorName;
197
200
  hardcoded?: {
@@ -201,6 +204,7 @@ export type InputPromptOptions = {
201
204
  };
202
205
  hint?: string;
203
206
  hintPlaceholderColor?: ColorName;
207
+ message?: string;
204
208
  mode?: "plain" | "password";
205
209
  mask?: string;
206
210
  placeholder?: string;
@@ -302,11 +306,36 @@ export interface SeparatorOption {
302
306
  width?: number;
303
307
  symbol?: SymbolName;
304
308
  }
309
+ export interface SelectPromptParams<T extends string> {
310
+ title?: string;
311
+ message?: string;
312
+ content?: string;
313
+ options: (SelectOption<T> | SeparatorOption)[];
314
+ defaultValue?: T;
315
+ initialValue?: T;
316
+ required?: boolean;
317
+ borderColor?: BorderColorName;
318
+ titleColor?: ColorName;
319
+ titleTypography?: TypographyName;
320
+ titleVariant?: VariantName;
321
+ contentColor?: ColorName;
322
+ contentTypography?: TypographyName;
323
+ border?: boolean;
324
+ endTitle?: string;
325
+ endTitleColor?: ColorName;
326
+ debug?: boolean;
327
+ terminalWidth?: number;
328
+ displayInstructions?: boolean;
329
+ shouldStream?: boolean;
330
+ streamDelay?: number;
331
+ }
305
332
  export interface MultiselectPromptParams<T extends string> {
306
333
  title: string;
334
+ message?: string;
307
335
  content?: string;
308
336
  options: (SelectOption<T> | SeparatorOption)[];
309
337
  defaultValue?: T[];
338
+ initialValue?: T[];
310
339
  borderColor?: BorderColorName;
311
340
  titleColor?: ColorName;
312
341
  titleTypography?: TypographyName;
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "license": "MIT",
45
45
  "name": "@reliverse/rempts",
46
46
  "type": "module",
47
- "version": "1.7.32",
47
+ "version": "1.7.34",
48
48
  "author": "reliverse",
49
49
  "bugs": {
50
50
  "email": "blefnk@gmail.com",