@elyx-code/project-logic-tree 0.0.7224 → 0.0.7226
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/editor/extensions/module/command-builder.d.ts +57 -0
- package/dist/editor/extensions/module/command-step-resolver.d.ts +5 -1
- package/dist/editor/extensions/module/extensions.d.ts +43 -9
- package/dist/editor/extensions/module/index.d.ts +1 -0
- package/dist/index.cjs +163 -163
- package/dist/index.js +37376 -37148
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IComposableCommand, ICommandStep, ICommandStepContext, ICommandOptionItem, ICommandPart, CommandStepType, NamedColor, ICommandExecutionContext, ICommandExecutionResult, IBeforeSubmitResult, ICommandValidationResult } from './extensions';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fluent builder for creating an ICommandStep.
|
|
5
|
+
*/
|
|
6
|
+
export declare class StepBuilder<TContext = any> {
|
|
7
|
+
private step;
|
|
8
|
+
constructor(id: string, label: string);
|
|
9
|
+
static option<TContext = any>(id: string, label: string): StepBuilder<TContext>;
|
|
10
|
+
static argument<TContext = any>(id: string, label: string): StepBuilder<TContext>;
|
|
11
|
+
static custom<TContext = any>(id: string, label: string): StepBuilder<TContext>;
|
|
12
|
+
setType(type: CommandStepType): this;
|
|
13
|
+
setPlaceholder(placeholder: string | ((ctx: ICommandStepContext<TContext>) => string)): this;
|
|
14
|
+
setGhostHint(ghostHint: string | ((ctx: ICommandStepContext<TContext>) => string)): this;
|
|
15
|
+
setRequired(required: boolean | ((ctx: ICommandStepContext<TContext>) => boolean)): this;
|
|
16
|
+
setAllowFreeText(allowFreeText: boolean | ((ctx: ICommandStepContext<TContext>) => boolean)): this;
|
|
17
|
+
when(condition: (ctx: ICommandStepContext<TContext>) => boolean): this;
|
|
18
|
+
setOptions(getOptions: (query: string, ctx: ICommandStepContext<TContext>) => Promise<ICommandOptionItem[]>): this;
|
|
19
|
+
setPartResolver(resolvePart: (valueOrOption: any, ctx: ICommandStepContext<TContext>, partIndex: number) => ICommandPart): this;
|
|
20
|
+
setValidator(validatePart: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => ICommandValidationResult | boolean): this;
|
|
21
|
+
onConfirmed(callback: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void): this;
|
|
22
|
+
build(): ICommandStep<TContext>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Fluent builder for creating an IComposableCommand.
|
|
26
|
+
*/
|
|
27
|
+
export declare class CommandBuilder<TContext = any> {
|
|
28
|
+
private cmd;
|
|
29
|
+
private staticSteps;
|
|
30
|
+
private subcommandsMap;
|
|
31
|
+
constructor(name: string);
|
|
32
|
+
static create<TContext = any>(name: string): CommandBuilder<TContext>;
|
|
33
|
+
setLabel(label: string): this;
|
|
34
|
+
setDescription(description: string): this;
|
|
35
|
+
setCategory(category: string): this;
|
|
36
|
+
setIcon(icon: string): this;
|
|
37
|
+
setNamedColor(namedColor: NamedColor | string): this;
|
|
38
|
+
addSubcommand(name: string, subcommand: IComposableCommand<TContext> | CommandBuilder<TContext>): this;
|
|
39
|
+
setSubcommands(subcommands: Record<string, IComposableCommand<TContext>> | IComposableCommand<TContext>[]): this;
|
|
40
|
+
addStep(step: ICommandStep<TContext> | StepBuilder<TContext>): this;
|
|
41
|
+
setSteps(steps: ICommandStep<TContext>[] | ((ctx: ICommandStepContext<TContext>) => ICommandStep<TContext>[])): this;
|
|
42
|
+
setNextStepResolver(getNextStep: (ctx: ICommandStepContext<TContext>) => ICommandStep<TContext> | null): this;
|
|
43
|
+
onPartConfirmed(handler: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void | ICommandStep<TContext> | ICommandStep<TContext>[]): this;
|
|
44
|
+
onPartRemoved(handler: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void): this;
|
|
45
|
+
setValidator(validator: (ctx: ICommandStepContext<TContext>) => ICommandValidationResult | boolean): this;
|
|
46
|
+
setBeforeSubmit(beforeSubmit: (ctx: ICommandExecutionContext) => Promise<IBeforeSubmitResult>): this;
|
|
47
|
+
setExecutor(execute: (ctx: ICommandExecutionContext) => Promise<ICommandExecutionResult>): this;
|
|
48
|
+
build(): IComposableCommand<TContext>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Functional factory helper for creating an IComposableCommand.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createCommand<TContext = any>(config: IComposableCommand<TContext>): IComposableCommand<TContext>;
|
|
54
|
+
/**
|
|
55
|
+
* Functional factory helper for creating an ICommandStep.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createStep<TContext = any>(config: ICommandStep<TContext>): ICommandStep<TContext>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { IComposableCommand, ICommandStepResolution, ICommandPart } from './extensions';
|
|
1
|
+
import { IComposableCommand, ICommandStepResolution, ICommandPart, ICommandStepContext } from './extensions';
|
|
2
2
|
|
|
3
3
|
export declare function getSubcommandsList(cmd: IComposableCommand): IComposableCommand[];
|
|
4
4
|
export declare function getSubcommandsMap(cmd: IComposableCommand): Record<string, IComposableCommand>;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a rich, standardized step context object for commands and lifecycle hooks.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createStepContext<TContext = any>(activeCommand: IComposableCommand<TContext> | null, activeSubcommand: IComposableCommand<TContext> | null, confirmedParts: ICommandPart[], activeSegmentText: string, ctx?: TContext): ICommandStepContext<TContext>;
|
|
5
9
|
/**
|
|
6
10
|
* Dynamically resolves the active step, placeholder, ghost hint, and completion state
|
|
7
11
|
* for a composable command based on the sequence of confirmed parts and active input.
|
|
@@ -234,8 +234,10 @@ export declare enum NamedColor {
|
|
|
234
234
|
ObjectValue = "object--value"
|
|
235
235
|
}
|
|
236
236
|
export interface ICommandPart {
|
|
237
|
+
id?: string;
|
|
238
|
+
stepId?: string;
|
|
237
239
|
index: number;
|
|
238
|
-
type: 'command' | 'subcommand' | 'option' | 'argument' | 'text' | 'node';
|
|
240
|
+
type: 'command' | 'subcommand' | 'option' | 'argument' | 'text' | 'node' | string;
|
|
239
241
|
label: string;
|
|
240
242
|
sublabel?: string;
|
|
241
243
|
value: string;
|
|
@@ -308,17 +310,43 @@ export interface ICommandOptionItem<TMetadata = any> {
|
|
|
308
310
|
metadata?: TMetadata;
|
|
309
311
|
rawEntity?: any;
|
|
310
312
|
}
|
|
313
|
+
export interface ICommandValidationResult {
|
|
314
|
+
isValid: boolean;
|
|
315
|
+
error?: string;
|
|
316
|
+
}
|
|
317
|
+
export interface ICommandStepContext<TContext = any> {
|
|
318
|
+
/** Project context / editor service */
|
|
319
|
+
context?: TContext;
|
|
320
|
+
project?: any;
|
|
321
|
+
/** Complete list of confirmed parts in sequence */
|
|
322
|
+
confirmedParts: ICommandPart[];
|
|
323
|
+
/** Dictionary mapping part id/type/stepId to ICommandPart */
|
|
324
|
+
partsMap: Record<string, ICommandPart>;
|
|
325
|
+
/** Text currently typed into active input segment */
|
|
326
|
+
activeSegmentText: string;
|
|
327
|
+
/** Active top-level command */
|
|
328
|
+
activeCommand: IComposableCommand<TContext> | null;
|
|
329
|
+
/** Active subcommand (if any) */
|
|
330
|
+
activeSubcommand: IComposableCommand<TContext> | null;
|
|
331
|
+
/** Helper to retrieve the value of a specific part by step ID or type */
|
|
332
|
+
getPartValue: <T = string>(idOrType: string) => T | undefined;
|
|
333
|
+
/** Helper to retrieve the full ICommandPart by step ID or type */
|
|
334
|
+
getPart: (idOrType: string) => ICommandPart | undefined;
|
|
335
|
+
}
|
|
311
336
|
export interface ICommandStep<TContext = any> {
|
|
312
337
|
id: string;
|
|
313
338
|
type: CommandStepType;
|
|
314
339
|
label: string;
|
|
315
|
-
placeholder?: string;
|
|
316
|
-
ghostHint?: string;
|
|
317
|
-
required?: boolean;
|
|
318
|
-
allowFreeText?: boolean;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
340
|
+
placeholder?: string | ((ctx: ICommandStepContext<TContext>) => string);
|
|
341
|
+
ghostHint?: string | ((ctx: ICommandStepContext<TContext>) => string);
|
|
342
|
+
required?: boolean | ((ctx: ICommandStepContext<TContext>) => boolean);
|
|
343
|
+
allowFreeText?: boolean | ((ctx: ICommandStepContext<TContext>) => boolean);
|
|
344
|
+
isEnabled?: (ctx: ICommandStepContext<TContext>) => boolean;
|
|
345
|
+
getOptions?: (query: string, ctx: ICommandStepContext<TContext>) => Promise<ICommandOptionItem[]>;
|
|
346
|
+
resolvePart: (valueOrOption: any, ctx: ICommandStepContext<TContext>, partIndex: number) => ICommandPart;
|
|
347
|
+
isStepSatisfied?: (value: string | ICommandPart, ctx: ICommandStepContext<TContext>) => boolean;
|
|
348
|
+
validatePart?: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => ICommandValidationResult | boolean;
|
|
349
|
+
onConfirmed?: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void;
|
|
322
350
|
}
|
|
323
351
|
export interface IComposableCommand<TContext = any> {
|
|
324
352
|
name: string;
|
|
@@ -328,7 +356,12 @@ export interface IComposableCommand<TContext = any> {
|
|
|
328
356
|
icon?: string;
|
|
329
357
|
namedColor?: NamedColor | string;
|
|
330
358
|
subcommands?: Record<string, IComposableCommand<TContext>> | IComposableCommand<TContext>[];
|
|
331
|
-
steps?: ICommandStep<TContext>[];
|
|
359
|
+
steps?: ICommandStep<TContext>[] | ((ctx: ICommandStepContext<TContext>) => ICommandStep<TContext>[]);
|
|
360
|
+
getNextStep?: (ctx: ICommandStepContext<TContext>) => ICommandStep<TContext> | null;
|
|
361
|
+
onInit?: (ctx: ICommandStepContext<TContext>) => void;
|
|
362
|
+
onPartConfirmed?: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void | ICommandStep<TContext> | ICommandStep<TContext>[];
|
|
363
|
+
onPartRemoved?: (part: ICommandPart, ctx: ICommandStepContext<TContext>) => void;
|
|
364
|
+
validate?: (ctx: ICommandStepContext<TContext>) => ICommandValidationResult | boolean;
|
|
332
365
|
beforeSubmit?: (ctx: ICommandExecutionContext) => Promise<IBeforeSubmitResult>;
|
|
333
366
|
execute?: (ctx: ICommandExecutionContext) => Promise<ICommandExecutionResult>;
|
|
334
367
|
getOptions?: (stage: CommandStage, query: string, ctx: ICommandAutocompleteContext) => Promise<any[]>;
|
|
@@ -343,6 +376,7 @@ export interface ICommandStepResolution<TContext = any> {
|
|
|
343
376
|
ghostHint?: string;
|
|
344
377
|
allowFreeText: boolean;
|
|
345
378
|
stage: CommandStage;
|
|
379
|
+
context?: ICommandStepContext<TContext>;
|
|
346
380
|
}
|
|
347
381
|
export interface ICommandExtensionModule extends IExtensionModuleCore {
|
|
348
382
|
beforeSubmit?: (ctx: ICommandExecutionContext) => Promise<IBeforeSubmitResult>;
|