second part of conversion from nodejs to powershell

This commit is contained in:
2026-07-01 16:39:58 +02:00
parent 2dec14af4a
commit e282ab8576
2 changed files with 817 additions and 255 deletions
+41 -40
View File
@@ -199,6 +199,47 @@ function formatVariableValue(value, renderContext = {}) {
return JSON.stringify(value);
}
export function mergeRequestConfig(base, updates) {
if (!updates || typeof updates !== 'object') {
return base;
}
const merged = { ...(base || {}) };
if (Object.prototype.hasOwnProperty.call(updates, 'auth')) {
if (updates.auth === 'inherit') {
if (merged.auth && typeof merged.auth === 'object') {
merged.auth = merged.auth;
} else {
delete merged.auth;
}
} else if (typeof updates.auth === 'object' && updates.auth !== null) {
merged.auth = updates.auth;
} else {
delete merged.auth;
}
} else {
delete merged.auth;
}
if (Array.isArray(updates.variables)) {
const variables = [...(Array.isArray(base.variables) ? base.variables : [])];
const byName = new Map();
for (const variable of variables) {
if (variable && variable.name) {
byName.set(String(variable.name), variable);
}
}
for (const variable of updates.variables) {
if (variable && variable.name) {
byName.set(String(variable.name), variable);
}
}
merged.variables = [...byName.values()];
}
return merged;
}
export function getRequestConfigForFile(yamlFile, sourceDir) {
const resolved = [];
const seenFiles = new Set();
@@ -267,46 +308,6 @@ export function getRequestConfigForFile(yamlFile, sourceDir) {
return resolved.reduce((result, config) => mergeRequestConfig(result, config), {});
}
export function mergeRequestConfig(base, updates) {
if (!updates || typeof updates !== 'object') {
return base;
}
const merged = { ...(base || {}) };
if (Object.prototype.hasOwnProperty.call(updates, 'auth')) {
if (updates.auth === 'inherit') {
if (merged.auth && typeof merged.auth === 'object') {
merged.auth = merged.auth;
} else {
delete merged.auth;
}
} else if (typeof updates.auth === 'object' && updates.auth !== null) {
merged.auth = updates.auth;
} else {
delete merged.auth;
}
} else {
delete merged.auth;
}
if (Array.isArray(updates.variables)) {
const variables = [...(Array.isArray(base.variables) ? base.variables : [])];
const byName = new Map();
for (const variable of variables) {
if (variable && variable.name) {
byName.set(String(variable.name), variable);
}
}
for (const variable of updates.variables) {
if (variable && variable.name) {
byName.set(String(variable.name), variable);
}
}
merged.variables = [...byName.values()];
}
return merged;
}
export function buildRequestContent(request, requestName, requestConfig = {}, dotenvVariables = new Set()) {
const lines = [];