This commit is contained in:
Aiden McClelland
2025-02-18 15:54:33 -07:00
committed by GitHub
parent dd3a140cb1
commit df8c8dc93b
2 changed files with 10 additions and 2 deletions

View File

@@ -974,7 +974,7 @@ export class SystemForEmbassy implements System {
})) as U.Config })) as U.Config
if (!oldConfig) return if (!oldConfig) return
const moduleCode = await this.moduleCode const moduleCode = await this.moduleCode
const method = moduleCode.dependencies?.[id]?.autoConfigure const method = moduleCode?.dependencies?.[id]?.autoConfigure
if (!method) return if (!method) return
const newConfig = (await method( const newConfig = (await method(
polyfillEffects(effects, this.manifest), polyfillEffects(effects, this.manifest),

View File

@@ -146,6 +146,7 @@ export function transformOldConfigToNew(
spec: OldConfigSpec, spec: OldConfigSpec,
config: Record<string, any>, config: Record<string, any>,
): Record<string, any> { ): Record<string, any> {
if (!config) return config
return Object.entries(spec).reduce((obj, [key, val]) => { return Object.entries(spec).reduce((obj, [key, val]) => {
let newVal = config[key] let newVal = config[key]
@@ -157,7 +158,12 @@ export function transformOldConfigToNew(
} }
if (isUnion(val)) { if (isUnion(val)) {
const selection = config[key][val.tag.id] if (!config[key]) return obj
const selection = config[key]?.[val.tag.id]
if (!selection) return obj
delete config[key][val.tag.id] delete config[key][val.tag.id]
newVal = { newVal = {
@@ -170,6 +176,8 @@ export function transformOldConfigToNew(
} }
if (isList(val) && isObjectList(val)) { if (isList(val) && isObjectList(val)) {
if (!config[key]) return obj
newVal = (config[key] as object[]).map((obj) => newVal = (config[key] as object[]).map((obj) =>
transformOldConfigToNew( transformOldConfigToNew(
matchOldConfigSpec.unsafeCast(val.spec.spec), matchOldConfigSpec.unsafeCast(val.spec.spec),