feat(cli): add resolveDefaultResource

This commit is contained in:
Ruben Fiszel
2023-05-28 22:59:08 +02:00
parent 6b850fb485
commit e19fabb02f

View File

@@ -80,6 +80,19 @@ export async function getResource(
}
}
/**
* Resolve a resource value in case the default value was picked because the input payload was undefined
* @param obj resource value or path of the resource under the format `$res:path`
* @returns resource value
*/
export async function resolveDefaultResource(obj: any): Promise<any> {
if (typeof obj === "string" && obj.startsWith("$res:")) {
return await getResource(obj.substring(5), true);
} else {
return obj;
}
}
/**
* Get the full resource value by path
* @param path path of the resource, default to internal state path