@optique/clack 1.3.0-dev.2417 → 1.3.0-dev.2418
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/index.cjs +14 -1
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +4 -3
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,8 @@ function getPromptFunctions() {
|
|
|
58
58
|
* Wraps a parser with an interactive Clack prompt fallback.
|
|
59
59
|
*
|
|
60
60
|
* @param parser Inner parser that reads CLI values.
|
|
61
|
-
* @param config Type-safe Clack prompt configuration
|
|
61
|
+
* @param config Type-safe Clack prompt configuration, or a configuration
|
|
62
|
+
* derived from dependency sources via `derivePromptConfig()`.
|
|
62
63
|
* @returns A parser with interactive prompt fallback, always in async mode.
|
|
63
64
|
* @throws {Error} If prompt execution fails with an unexpected error or if the
|
|
64
65
|
* inner parser throws while parsing or completing.
|
|
@@ -192,4 +193,16 @@ function normalizeOptions(options) {
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
//#endregion
|
|
196
|
+
Object.defineProperty(exports, 'derivePromptConfig', {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function () {
|
|
199
|
+
return __optique_prompt.derivePromptConfig;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(exports, 'isDerivedPromptConfig', {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function () {
|
|
205
|
+
return __optique_prompt.isDerivedPromptConfig;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
195
208
|
exports.prompt = prompt;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FluentParser } from "@optique/core/fluent";
|
|
2
2
|
import { Mode, Parser } from "@optique/core/parser";
|
|
3
|
-
import { PromptCondition } from "@optique/prompt";
|
|
3
|
+
import { DerivePromptConfigContext, DerivePromptConfigOptions, DerivePromptConfigsContext, DerivePromptConfigsOptions, DerivedPromptConfig, DerivedPromptConfig as DerivedPromptConfig$1, PromptCondition, derivePromptConfig, isDerivedPromptConfig } from "@optique/prompt";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
|
|
@@ -146,16 +146,28 @@ type StringPromptConfig = TextConfig | PasswordConfig | SelectConfig;
|
|
|
146
146
|
*/
|
|
147
147
|
type PromptConfig<T> = BasePromptConfig<Exclude<T, null | undefined>> & PromptCondition<T>;
|
|
148
148
|
type BasePromptConfig<T> = T extends boolean ? ConfirmConfig : T extends number ? NumberPromptConfig : T extends string ? StringPromptConfig : T extends readonly string[] ? MultiselectConfig : never;
|
|
149
|
+
/**
|
|
150
|
+
* Union of every prompt configuration this package can execute,
|
|
151
|
+
* regardless of the parser value type.
|
|
152
|
+
*
|
|
153
|
+
* Derived prompt configurations resolve against this union: the adapter's
|
|
154
|
+
* configuration type supplies the resolver's return type, so a resolver
|
|
155
|
+
* may produce any prompt kind the adapter supports.
|
|
156
|
+
*
|
|
157
|
+
* @since 1.3.0
|
|
158
|
+
*/
|
|
159
|
+
type RuntimePromptConfig = ConfirmConfig | NumberPromptConfig | StringPromptConfig | MultiselectConfig;
|
|
149
160
|
/**
|
|
150
161
|
* Wraps a parser with an interactive Clack prompt fallback.
|
|
151
162
|
*
|
|
152
163
|
* @param parser Inner parser that reads CLI values.
|
|
153
|
-
* @param config Type-safe Clack prompt configuration
|
|
164
|
+
* @param config Type-safe Clack prompt configuration, or a configuration
|
|
165
|
+
* derived from dependency sources via `derivePromptConfig()`.
|
|
154
166
|
* @returns A parser with interactive prompt fallback, always in async mode.
|
|
155
167
|
* @throws {Error} If prompt execution fails with an unexpected error or if the
|
|
156
168
|
* inner parser throws while parsing or completing.
|
|
157
169
|
* @since 1.2.0
|
|
158
170
|
*/
|
|
159
|
-
declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue>): FluentParser<"async", TValue, TState>;
|
|
171
|
+
declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue> | DerivedPromptConfig$1<RuntimePromptConfig, NoInfer<TValue>>): FluentParser<"async", TValue, TState>;
|
|
160
172
|
//#endregion
|
|
161
|
-
export { ConfirmConfig, MultiselectConfig, NumberPromptConfig, Option, PasswordConfig, PromptConfig, SelectConfig, StringPromptConfig, TextConfig, prompt };
|
|
173
|
+
export { ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, MultiselectConfig, NumberPromptConfig, Option, PasswordConfig, PromptConfig, RuntimePromptConfig, SelectConfig, StringPromptConfig, TextConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PromptCondition } from "@optique/prompt";
|
|
1
|
+
import { DerivePromptConfigContext, DerivePromptConfigOptions, DerivePromptConfigsContext, DerivePromptConfigsOptions, DerivedPromptConfig, DerivedPromptConfig as DerivedPromptConfig$1, PromptCondition, derivePromptConfig, isDerivedPromptConfig } from "@optique/prompt";
|
|
2
2
|
import { FluentParser } from "@optique/core/fluent";
|
|
3
3
|
import { Mode, Parser } from "@optique/core/parser";
|
|
4
4
|
|
|
@@ -146,16 +146,28 @@ type StringPromptConfig = TextConfig | PasswordConfig | SelectConfig;
|
|
|
146
146
|
*/
|
|
147
147
|
type PromptConfig<T> = BasePromptConfig<Exclude<T, null | undefined>> & PromptCondition<T>;
|
|
148
148
|
type BasePromptConfig<T> = T extends boolean ? ConfirmConfig : T extends number ? NumberPromptConfig : T extends string ? StringPromptConfig : T extends readonly string[] ? MultiselectConfig : never;
|
|
149
|
+
/**
|
|
150
|
+
* Union of every prompt configuration this package can execute,
|
|
151
|
+
* regardless of the parser value type.
|
|
152
|
+
*
|
|
153
|
+
* Derived prompt configurations resolve against this union: the adapter's
|
|
154
|
+
* configuration type supplies the resolver's return type, so a resolver
|
|
155
|
+
* may produce any prompt kind the adapter supports.
|
|
156
|
+
*
|
|
157
|
+
* @since 1.3.0
|
|
158
|
+
*/
|
|
159
|
+
type RuntimePromptConfig = ConfirmConfig | NumberPromptConfig | StringPromptConfig | MultiselectConfig;
|
|
149
160
|
/**
|
|
150
161
|
* Wraps a parser with an interactive Clack prompt fallback.
|
|
151
162
|
*
|
|
152
163
|
* @param parser Inner parser that reads CLI values.
|
|
153
|
-
* @param config Type-safe Clack prompt configuration
|
|
164
|
+
* @param config Type-safe Clack prompt configuration, or a configuration
|
|
165
|
+
* derived from dependency sources via `derivePromptConfig()`.
|
|
154
166
|
* @returns A parser with interactive prompt fallback, always in async mode.
|
|
155
167
|
* @throws {Error} If prompt execution fails with an unexpected error or if the
|
|
156
168
|
* inner parser throws while parsing or completing.
|
|
157
169
|
* @since 1.2.0
|
|
158
170
|
*/
|
|
159
|
-
declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue>): FluentParser<"async", TValue, TState>;
|
|
171
|
+
declare function prompt<M extends Mode, TValue, TState>(parser: Parser<M, TValue, TState>, config: PromptConfig<TValue> | DerivedPromptConfig$1<RuntimePromptConfig, NoInfer<TValue>>): FluentParser<"async", TValue, TState>;
|
|
160
172
|
//#endregion
|
|
161
|
-
export { ConfirmConfig, MultiselectConfig, NumberPromptConfig, Option, PasswordConfig, PromptConfig, SelectConfig, StringPromptConfig, TextConfig, prompt };
|
|
173
|
+
export { ConfirmConfig, type DerivePromptConfigContext, type DerivePromptConfigOptions, type DerivePromptConfigsContext, type DerivePromptConfigsOptions, type DerivedPromptConfig, MultiselectConfig, NumberPromptConfig, Option, PasswordConfig, PromptConfig, RuntimePromptConfig, SelectConfig, StringPromptConfig, TextConfig, derivePromptConfig, isDerivedPromptConfig, prompt };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { confirm, isCancel, multiselect, password, select, text } from "@clack/prompts";
|
|
2
2
|
import { message } from "@optique/core/message";
|
|
3
|
-
import { createPromptAdapter } from "@optique/prompt";
|
|
3
|
+
import { createPromptAdapter, derivePromptConfig, isDerivedPromptConfig } from "@optique/prompt";
|
|
4
4
|
|
|
5
5
|
//#region src/index.ts
|
|
6
6
|
const promptFunctionsOverrideSymbol = Symbol.for("@optique/clack/prompt-functions");
|
|
@@ -35,7 +35,8 @@ function getPromptFunctions() {
|
|
|
35
35
|
* Wraps a parser with an interactive Clack prompt fallback.
|
|
36
36
|
*
|
|
37
37
|
* @param parser Inner parser that reads CLI values.
|
|
38
|
-
* @param config Type-safe Clack prompt configuration
|
|
38
|
+
* @param config Type-safe Clack prompt configuration, or a configuration
|
|
39
|
+
* derived from dependency sources via `derivePromptConfig()`.
|
|
39
40
|
* @returns A parser with interactive prompt fallback, always in async mode.
|
|
40
41
|
* @throws {Error} If prompt execution fails with an unexpected error or if the
|
|
41
42
|
* inner parser throws while parsing or completing.
|
|
@@ -169,4 +170,4 @@ function normalizeOptions(options) {
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
//#endregion
|
|
172
|
-
export { prompt };
|
|
173
|
+
export { derivePromptConfig, isDerivedPromptConfig, prompt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/clack",
|
|
3
|
-
"version": "1.3.0-dev.
|
|
3
|
+
"version": "1.3.0-dev.2418",
|
|
4
4
|
"description": "Interactive prompt support for Optique via Clack",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"sideEffects": false,
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@clack/prompts": "^1.6.0",
|
|
65
|
-
"@optique/core": "1.3.0-dev.
|
|
66
|
-
"@optique/prompt": "1.3.0-dev.
|
|
65
|
+
"@optique/core": "1.3.0-dev.2418+afa5cda1",
|
|
66
|
+
"@optique/prompt": "1.3.0-dev.2418+afa5cda1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@optique/env": "1.3.0-dev.
|
|
70
|
-
"@optique/run": "1.3.0-dev.
|
|
69
|
+
"@optique/env": "1.3.0-dev.2418+afa5cda1",
|
|
70
|
+
"@optique/run": "1.3.0-dev.2418+afa5cda1",
|
|
71
71
|
"@types/node": "^24.0.0",
|
|
72
72
|
"fast-check": "^4.7.0",
|
|
73
73
|
"tsdown": "^0.13.0",
|