mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-31 04:33:40 +00:00
wip: SDK up to createAction
This commit is contained in:
@@ -2,21 +2,19 @@ import { AutoConfigure, DeepPartial, Effects, ExpectedExports } from "../types"
|
||||
import { Utils, utils } from "../util"
|
||||
import { deepEqual } from "../util/deepEqual"
|
||||
import { deepMerge } from "../util/deepMerge"
|
||||
import { WrapperDataContract } from "../wrapperData/wrapperDataContract"
|
||||
|
||||
export type AutoConfigFrom<WD, Input, NestedConfigs> = {
|
||||
export type AutoConfigFrom<Store, Input, NestedConfigs> = {
|
||||
[key in keyof NestedConfigs & string]: (options: {
|
||||
effects: Effects
|
||||
localConfig: Input
|
||||
remoteConfig: NestedConfigs[key]
|
||||
utils: Utils<WD>
|
||||
utils: Utils<Store>
|
||||
}) => Promise<void | DeepPartial<NestedConfigs[key]>>
|
||||
}
|
||||
export class AutoConfig<WD, Input, NestedConfigs> {
|
||||
export class AutoConfig<Store, Input, NestedConfigs> {
|
||||
constructor(
|
||||
readonly wrapperDataContract: WrapperDataContract<WD>,
|
||||
readonly configs: AutoConfigFrom<WD, Input, NestedConfigs>,
|
||||
readonly path: keyof AutoConfigFrom<WD, Input, NestedConfigs>,
|
||||
readonly configs: AutoConfigFrom<Store, Input, NestedConfigs>,
|
||||
readonly path: keyof AutoConfigFrom<Store, Input, NestedConfigs>,
|
||||
) {}
|
||||
|
||||
async check(
|
||||
@@ -25,7 +23,7 @@ export class AutoConfig<WD, Input, NestedConfigs> {
|
||||
const origConfig = JSON.parse(JSON.stringify(options.localConfig))
|
||||
const newOptions = {
|
||||
...options,
|
||||
utils: utils(this.wrapperDataContract, options.effects),
|
||||
utils: utils<Store>(options.effects),
|
||||
localConfig: options.localConfig as Input,
|
||||
remoteConfig: options.remoteConfig as any,
|
||||
}
|
||||
@@ -46,7 +44,7 @@ export class AutoConfig<WD, Input, NestedConfigs> {
|
||||
): ReturnType<AutoConfigure["autoConfigure"]> {
|
||||
const newOptions = {
|
||||
...options,
|
||||
utils: utils(this.wrapperDataContract, options.effects),
|
||||
utils: utils<Store>(options.effects),
|
||||
localConfig: options.localConfig as Input,
|
||||
remoteConfig: options.remoteConfig as any,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user