Skip to content

Commit 553f3fe

Browse files
committed
fix: types
1 parent 336b2d5 commit 553f3fe

File tree

11 files changed

+163
-153
lines changed

11 files changed

+163
-153
lines changed

src/command/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,4 @@ type CommandGenericReducer<T = unknown> = (values: any, properties: CommandPrope
376376

377377
export interface CommandEmpty extends FluentInterface<Model<CommandState, CommandActions>> {}
378378

379-
export type CommandValuesLookup<T extends CommandEmpty> = Values<LookupModel<T>['log']>
379+
export type CommandLookupValues<T extends CommandEmpty> = Values<LookupModel<T>['log']>

src/compose/get-options-variables.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { compact, intersection, keys } from 'lodash-es'
22
import type { InputBooleanStateInitial } from '../input/boolean/types'
33
import type { InputChoiceStateInitial } from '../input/choice/types'
44
import type { InputCountStateInitial } from '../input/count/types'
5-
import type { InputGroupState } from '../input/group/types'
5+
import type { InputGroupStateInitial } from '../input/group/types'
66
import type { InputStringStateInitial } from '../input/string/types'
77
import { type GenericOption, type GenericVariable, InputType, type Match } from '../types'
88

@@ -11,7 +11,7 @@ export const getOptionsVariables = (
1111
| InputBooleanStateInitial
1212
| InputChoiceStateInitial
1313
| InputCountStateInitial
14-
| InputGroupState
14+
| InputGroupStateInitial
1515
| InputStringStateInitial,
1616
match: Match,
1717
) => {

src/compose/placeholder-input-help-group.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import type { FluentInterface, Model, Reducer } from '@escapace/fluent'
22
import { help } from '../help/help'
33
import { group } from '../input/group/domain-language'
44
import type {
5-
ActionDescription,
6-
ActionInput,
7-
ActionReducer,
8-
ActionReference,
9-
Settings,
5+
InputGroupActionDescription,
6+
InputGroupActionInput,
7+
InputGroupActionReducer,
8+
InputGroupActionReference,
9+
InputGroupSettings,
1010
} from '../input/group/types'
1111
import { PLACEHOLDER_REFERENCES } from '../types'
1212
import { extract } from '../utilities/extract'
@@ -15,19 +15,19 @@ import { placeholderInputHelpBoolean } from './placeholder-input-boolean'
1515
export const placeholderInputHelpGroup: FluentInterface<
1616
Model<
1717
Reducer<
18-
Settings,
18+
InputGroupSettings,
1919
[
20-
ActionReducer<boolean | undefined>,
21-
ActionInput<typeof placeholderInputHelpBoolean>,
22-
ActionDescription,
23-
ActionReference<PLACEHOLDER_REFERENCES.INPUT>,
20+
InputGroupActionReducer<boolean | undefined>,
21+
InputGroupActionInput<typeof placeholderInputHelpBoolean>,
22+
InputGroupActionDescription,
23+
InputGroupActionReference<PLACEHOLDER_REFERENCES.INPUT>,
2424
]
2525
>,
2626
[
27-
ActionReducer<boolean | undefined>,
28-
ActionInput<typeof placeholderInputHelpBoolean>,
29-
ActionDescription,
30-
ActionReference<PLACEHOLDER_REFERENCES.INPUT>,
27+
InputGroupActionReducer<boolean | undefined>,
28+
InputGroupActionInput<typeof placeholderInputHelpBoolean>,
29+
InputGroupActionDescription,
30+
InputGroupActionReference<PLACEHOLDER_REFERENCES.INPUT>,
3131
]
3232
>
3333
> = extract(

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export type * from './command/types'
1919
export type * from './input/boolean/types'
2020
export type * from './input/choice/types'
2121
export type * from './input/count/types'
22+
export type * from './input/group/types'
23+
export type * from './input/string/types'
2224

2325
import { noop } from 'lodash-es'
2426
import { composeFactory } from './compose/compose-factory'

src/input/group/domain-language.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { boolean } from '../boolean/domain-language'
66
import { count } from '../count/domain-language'
77
import { group } from './domain-language'
88
import { reducer } from './reducer'
9-
import { type PropertiesInputGroup, TypeAction } from './types'
9+
import { type InputGroupProperties, InputGroupTypeAction } from './types'
1010

1111
describe('input/group', () => {
1212
it('domain-language', () => {
@@ -22,7 +22,7 @@ describe('input/group', () => {
2222
assert.deepEqual(log(test0), [
2323
{
2424
payload: reference,
25-
type: TypeAction.Reference,
25+
type: InputGroupTypeAction.Reference,
2626
},
2727
])
2828

@@ -44,11 +44,11 @@ describe('input/group', () => {
4444
assert.deepEqual(log(test1), [
4545
{
4646
payload: 'description',
47-
type: TypeAction.Description,
47+
type: InputGroupTypeAction.Description,
4848
},
4949
{
5050
payload: reference,
51-
type: TypeAction.Reference,
51+
type: InputGroupTypeAction.Reference,
5252
},
5353
])
5454

@@ -78,19 +78,19 @@ describe('input/group', () => {
7878
assert.deepEqual(log(test2), [
7979
{
8080
payload: inputB,
81-
type: TypeAction.Input,
81+
type: InputGroupTypeAction.Input,
8282
},
8383
{
8484
payload: inputA,
85-
type: TypeAction.Input,
85+
type: InputGroupTypeAction.Input,
8686
},
8787
{
8888
payload: 'description',
89-
type: TypeAction.Description,
89+
type: InputGroupTypeAction.Description,
9090
},
9191
{
9292
payload: reference,
93-
type: TypeAction.Reference,
93+
type: InputGroupTypeAction.Reference,
9494
},
9595
])
9696

@@ -105,7 +105,7 @@ describe('input/group', () => {
105105
variables: [],
106106
})
107107

108-
const function_ = (value: LookupValues<typeof test2>, _: PropertiesInputGroup) => value
108+
const function_ = (value: LookupValues<typeof test2>, _: InputGroupProperties) => value
109109

110110
const test3 = test2.reducer(function_)
111111

@@ -114,23 +114,23 @@ describe('input/group', () => {
114114
assert.deepEqual(log(test3), [
115115
{
116116
payload: function_,
117-
type: TypeAction.Reducer,
117+
type: InputGroupTypeAction.Reducer,
118118
},
119119
{
120120
payload: inputB,
121-
type: TypeAction.Input,
121+
type: InputGroupTypeAction.Input,
122122
},
123123
{
124124
payload: inputA,
125-
type: TypeAction.Input,
125+
type: InputGroupTypeAction.Input,
126126
},
127127
{
128128
payload: 'description',
129-
type: TypeAction.Description,
129+
type: InputGroupTypeAction.Description,
130130
},
131131
{
132132
payload: reference,
133-
type: TypeAction.Reference,
133+
type: InputGroupTypeAction.Reference,
134134
},
135135
])
136136

src/input/group/domain-language.ts

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,33 @@ import { assert } from '../../utilities/assert'
66
import { wrap, reducer as reducerDefault } from './reducer'
77
import { extract } from '../../utilities/extract'
88
import {
9-
type ActionDescription,
10-
type GenericInputGroupReducer,
11-
type ActionReducer,
12-
type ActionInput,
13-
type ActionReference,
14-
type Actions,
15-
type Settings,
16-
type State,
17-
TypeAction,
9+
type InputGroupActionDescription,
10+
type InputGroupReducerGeneric,
11+
type InputGroupActionReducer,
12+
type InputGroupActionInput,
13+
type InputGroupActionReference,
14+
type InputGroupActions,
15+
type InputGroupSettings,
16+
type InputGroupState,
17+
InputGroupTypeAction,
1818
} from './types'
1919

20-
const fluentReducer = (log: Actions): State => {
20+
const fluentReducer = (log: InputGroupActions): InputGroupState => {
2121
const reference = (
22-
find(log, (action) => action.type === TypeAction.Reference) as ActionReference | undefined
22+
find(log, (action) => action.type === InputGroupTypeAction.Reference) as
23+
| InputGroupActionReference
24+
| undefined
2325
)?.payload
2426

25-
const description = find(log, (action) => action.type === TypeAction.Description)?.payload
27+
const description = find(
28+
log,
29+
(action) => action.type === InputGroupTypeAction.Description,
30+
)?.payload
2631

2732
const rlog = reverse([...log])
2833

2934
const inputs = map(
30-
filter(rlog, ({ type }) => type === TypeAction.Input) as ActionInput[],
35+
filter(rlog, ({ type }) => type === InputGroupTypeAction.Input) as InputGroupActionInput[],
3136
(value) => value.payload,
3237
)
3338

@@ -37,10 +42,12 @@ const fluentReducer = (log: Actions): State => {
3742
const variables = flatMap(inputs, (value) => value[SYMBOL_STATE].variables)
3843

3944
const reducerMaybe = (
40-
find(log, (action) => action.type === TypeAction.Reducer) as ActionReducer | undefined
45+
find(log, (action) => action.type === InputGroupTypeAction.Reducer) as
46+
| InputGroupActionReducer
47+
| undefined
4148
)?.payload
4249

43-
const reducer: GenericInputGroupReducer =
50+
const reducer: InputGroupReducerGeneric =
4451
reducerMaybe === undefined
4552
? reducerDefault
4653
: async (values, properties) => reducerMaybe(await wrap(values, properties), properties)
@@ -57,75 +64,75 @@ const fluentReducer = (log: Actions): State => {
5764
}
5865
}
5966

60-
export const group = builder<Settings>([
67+
export const group = builder<InputGroupSettings>([
6168
{
6269
[Options.Interface]: (dispatch) => ({
6370
reference(reference: Reference) {
6471
assert.reference(reference)
6572

66-
return dispatch<ActionReference>({
73+
return dispatch<InputGroupActionReference>({
6774
payload: reference,
68-
type: TypeAction.Reference,
75+
type: InputGroupTypeAction.Reference,
6976
})
7077
},
7178
}),
7279
[Options.Keys]: ['reference'],
7380
[Options.Once]: true,
7481
[Options.Reducer]: fluentReducer,
75-
[Options.Type]: TypeAction.Reference,
82+
[Options.Type]: InputGroupTypeAction.Reference,
7683
},
7784
{
78-
[Options.Dependencies]: [TypeAction.Reference],
85+
[Options.Dependencies]: [InputGroupTypeAction.Reference],
7986
[Options.Interface]: (dispatch) => ({
8087
description(description: string) {
8188
assert.string(description)
8289

83-
return dispatch<ActionDescription>({
90+
return dispatch<InputGroupActionDescription>({
8491
payload: description,
85-
type: TypeAction.Description,
92+
type: InputGroupTypeAction.Description,
8693
})
8794
},
8895
}),
8996
[Options.Keys]: ['description'],
9097
[Options.Once]: true,
9198
[Options.Reducer]: fluentReducer,
92-
[Options.Type]: TypeAction.Description,
99+
[Options.Type]: InputGroupTypeAction.Description,
93100
},
94101
{
95-
[Options.Conflicts]: [TypeAction.Reducer],
96-
[Options.Dependencies]: [TypeAction.Description],
102+
[Options.Conflicts]: [InputGroupTypeAction.Reducer],
103+
[Options.Dependencies]: [InputGroupTypeAction.Description],
97104
[Options.Interface]: (dispatch, log, state) => ({
98105
input(value: Input) {
99106
assert.input(value, { log, state })
100107

101108
const payload = extract(value)
102109

103-
return dispatch<ActionInput>({
110+
return dispatch<InputGroupActionInput>({
104111
payload,
105-
type: TypeAction.Input,
112+
type: InputGroupTypeAction.Input,
106113
})
107114
},
108115
}),
109116
[Options.Keys]: ['input'],
110117
[Options.Once]: false,
111118
[Options.Reducer]: fluentReducer,
112-
[Options.Type]: TypeAction.Input,
119+
[Options.Type]: InputGroupTypeAction.Input,
113120
},
114121
{
115122
[Options.Enabled]: (_, state) => !state.isEmpty,
116123
[Options.Interface]: (dispatch) => ({
117-
reducer(value: GenericInputGroupReducer) {
124+
reducer(value: InputGroupReducerGeneric) {
118125
assert.function(value)
119126

120-
return dispatch<ActionReducer>({
127+
return dispatch<InputGroupActionReducer>({
121128
payload: value,
122-
type: TypeAction.Reducer,
129+
type: InputGroupTypeAction.Reducer,
123130
})
124131
},
125132
}),
126133
[Options.Keys]: ['reducer'],
127134
[Options.Once]: true,
128135
[Options.Reducer]: fluentReducer,
129-
[Options.Type]: TypeAction.Reducer,
136+
[Options.Type]: InputGroupTypeAction.Reducer,
130137
},
131138
])

src/input/group/reducer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import { SYMBOL_LOG, SYMBOL_STATE } from '@escapace/fluent'
44
import { assign, filter, includes, map, omit } from 'lodash-es'
55
import { type GenericOption, type GenericVariable, InputType, type Reference } from './../../types'
6-
import type { GenericInputGroupReducer, PropertiesInputGroup } from './types'
6+
import type { InputGroupReducerGeneric, InputGroupProperties } from './types'
77

88
export const wrap = async (
99
values: Array<GenericOption<any> | GenericVariable<any>>,
10-
properties: PropertiesInputGroup,
10+
properties: InputGroupProperties,
1111
): Promise<Record<Reference, any>> =>
1212
// eslint-disable-next-line typescript/no-unsafe-return
1313
assign(
@@ -33,7 +33,7 @@ export const wrap = async (
3333
)),
3434
)
3535

36-
export const reducer: GenericInputGroupReducer = async (
36+
export const reducer: InputGroupReducerGeneric = async (
3737
values,
3838
properties,
3939
): Promise<Record<Reference, any>> => await wrap(values, properties)

0 commit comments

Comments
 (0)