Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,29 @@
|
||||
export const AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY = "__automationConditionBranches" as const;
|
||||
|
||||
export type AutomationConditionBranch = "true" | "false";
|
||||
|
||||
export function automationConditionBranches(config: Record<string, unknown>): Readonly<Record<string, AutomationConditionBranch>> {
|
||||
const value = config[AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY];
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
return Object.fromEntries(
|
||||
Object.entries(value as Record<string, unknown>).filter((entry): entry is [string, AutomationConditionBranch] => entry[1] === "true" || entry[1] === "false")
|
||||
);
|
||||
}
|
||||
|
||||
export function automationConditionBranchForParent(config: Record<string, unknown>, parentStepKey: string): AutomationConditionBranch {
|
||||
return automationConditionBranches(config)[parentStepKey] ?? "true";
|
||||
}
|
||||
|
||||
export function withAutomationConditionBranch(
|
||||
config: Record<string, unknown>,
|
||||
parentStepKey: string,
|
||||
branch: AutomationConditionBranch | null
|
||||
): Record<string, unknown> {
|
||||
const branches = { ...automationConditionBranches(config) };
|
||||
if (branch === null) delete branches[parentStepKey];
|
||||
else branches[parentStepKey] = branch;
|
||||
const next = { ...config };
|
||||
if (Object.keys(branches).length === 0) delete next[AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY];
|
||||
else next[AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY] = branches;
|
||||
return next;
|
||||
}
|
||||
Reference in new issue
Block a user