Skip to content

chore(endpoint): add spacing to debug output #4108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/util-endpoints/src/debug/toDebugString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ export function toDebugString(input: FunctionObject): string;
export function toDebugString(input: FunctionReturn): string;
export function toDebugString(input: EndpointObject): string;
export function toDebugString(input: any): string {
if (typeof input !== 'object' || input == null) {
if (typeof input !== "object" || input == null) {
return input;
}

if ('ref' in input) {
return `$${toDebugString(input.ref)}`
if ("ref" in input) {
return `$${toDebugString(input.ref)}`;
}

if ('fn' in input) {
return `${input.fn}(${(input.argv || []).map(toDebugString)})`;
if ("fn" in input) {
return `${input.fn}(${(input.argv || []).map(toDebugString).join(", ")})`;
}

return JSON.stringify(input, null, 2);
}
}
4 changes: 2 additions & 2 deletions packages/util-endpoints/src/resolveEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR
const { endpointParams, logger } = options;
const { parameters, rules } = ruleSetObject;

options.logger?.debug(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);
options.logger?.debug?.(debugId, `Initial EndpointParams: ${toDebugString(endpointParams)}`);

// @ts-ignore Type 'undefined' is not assignable to type 'string | boolean' (2322)
const paramsWithDefault: [string, string | boolean][] = Object.entries(parameters)
Expand Down Expand Up @@ -48,7 +48,7 @@ export const resolveEndpoint = (ruleSetObject: RuleSetObject, options: EndpointR
}
}

options.logger?.debug(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);
options.logger?.debug?.(debugId, `Resolved endpoint: ${toDebugString(endpoint)}`);

return endpoint;
};
2 changes: 1 addition & 1 deletion packages/util-endpoints/src/utils/evaluateCondition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const evaluateCondition = ({ assign, ...fnArgs }: ConditionObject, option
}
const value = callFunction(fnArgs, options);

options.logger?.debug(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);
options.logger?.debug?.(debugId, `evaluateCondition: ${toDebugString(fnArgs)} = ${toDebugString(value)}`);

return {
result: value === "" ? true : !!value,
Expand Down
2 changes: 1 addition & 1 deletion packages/util-endpoints/src/utils/evaluateConditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const evaluateConditions = (conditions: ConditionObject[] = [], options:

if (toAssign) {
conditionsReferenceRecord[toAssign.name] = toAssign.value;
options.logger?.debug(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
options.logger?.debug?.(debugId, `assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const evaluateEndpointRule = (

const { url, properties, headers } = endpoint;

options.logger?.debug(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);
options.logger?.debug?.(debugId, `Resolving endpoint from template: ${toDebugString(endpoint)}`);

return {
...(headers != undefined && {
Expand Down