mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
feat: Making the auto config
This commit is contained in:
@@ -1,30 +1,22 @@
|
||||
import { Config } from "../config/builder/config"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { AutoConfig, AutoConfigFrom } from "./AutoConfig"
|
||||
import { AutoConfig } from "./AutoConfig"
|
||||
|
||||
export function setupAutoConfig<
|
||||
Store,
|
||||
Vault,
|
||||
Input extends Record<string, any>,
|
||||
Manifest extends SDKManifest,
|
||||
NestedConfigs extends {
|
||||
[key in keyof Manifest["dependencies"]]: unknown
|
||||
},
|
||||
>(
|
||||
_config: Config<Input, Store, Vault>,
|
||||
autoConfigs: AutoConfigFrom<Store, Vault, Input, NestedConfigs>,
|
||||
) {
|
||||
type C = typeof autoConfigs
|
||||
const answer = { ...autoConfigs } as unknown as {
|
||||
[k in keyof C]: AutoConfig<Store, Vault, Input, NestedConfigs>
|
||||
}
|
||||
for (const key in autoConfigs) {
|
||||
answer[key as keyof typeof autoConfigs] = new AutoConfig<
|
||||
autoConfigs: {
|
||||
[key in keyof Manifest["dependencies"] & string]: AutoConfig<
|
||||
Store,
|
||||
Vault,
|
||||
Input,
|
||||
NestedConfigs
|
||||
>(autoConfigs, key as keyof typeof autoConfigs)
|
||||
}
|
||||
return answer
|
||||
any
|
||||
>
|
||||
},
|
||||
) {
|
||||
return autoConfigs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user