mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-01 21:13:11 +00:00
fix: The Types for the new config need to be propagated
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { Config } from "../config/builder"
|
||||
import { ExtractConfigType } from "../config/builder/config"
|
||||
import { ActionMetaData, ActionResult, Effects, ExportedAction } from "../types"
|
||||
import { Utils, utils } from "../util"
|
||||
|
||||
export class CreatedAction<WrapperData, Type extends Record<string, any>> {
|
||||
export class CreatedAction<
|
||||
WrapperData,
|
||||
ConfigType extends Record<string, any> | Config<any, any, any>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
> {
|
||||
private constructor(
|
||||
public readonly myMetaData: Omit<ActionMetaData, "input"> & {
|
||||
input: Config<Type, WrapperData, never>
|
||||
input: Config<Type, WrapperData, Type>
|
||||
},
|
||||
readonly fn: (options: {
|
||||
effects: Effects
|
||||
@@ -17,14 +22,11 @@ export class CreatedAction<WrapperData, Type extends Record<string, any>> {
|
||||
|
||||
static of<
|
||||
WrapperData,
|
||||
Input extends Config<Type, WrapperData, never>,
|
||||
Type extends Record<string, any> = (Input extends Config<any, infer B, any>
|
||||
? B
|
||||
: never) &
|
||||
Record<string, any>,
|
||||
ConfigType extends Record<string, any> | Config<any, any, any>,
|
||||
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
|
||||
>(
|
||||
metaData: Omit<ActionMetaData, "input"> & {
|
||||
input: Config<Type, WrapperData, never>
|
||||
input: Config<Type, WrapperData, Type>
|
||||
},
|
||||
fn: (options: {
|
||||
effects: Effects
|
||||
@@ -32,7 +34,7 @@ export class CreatedAction<WrapperData, Type extends Record<string, any>> {
|
||||
input: Type
|
||||
}) => Promise<ActionResult>,
|
||||
) {
|
||||
return new CreatedAction<WrapperData, Type>(metaData, fn)
|
||||
return new CreatedAction<WrapperData, ConfigType, Type>(metaData, fn)
|
||||
}
|
||||
|
||||
exportedAction: ExportedAction = ({ effects, input }) => {
|
||||
|
||||
Reference in New Issue
Block a user