From 184569373c0556f23df0a2c29184f13c22f4b323 Mon Sep 17 00:00:00 2001 From: Khiet Tam Nguyen Date: Thu, 28 Nov 2024 22:36:25 +1100 Subject: [PATCH] docs: jsdoc added for wrapWhereClauseInParenthesis and mergeWhereClauses --- .../components/common_components/common.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/modules/components/common_components/common.ts b/src/modules/components/common_components/common.ts index e73643aa..4216eb57 100644 --- a/src/modules/components/common_components/common.ts +++ b/src/modules/components/common_components/common.ts @@ -1860,6 +1860,15 @@ export class Common { return new Promise(resolve => setTimeout(resolve, time)); } + /** + * Wraps the given `WhereClause` in parentheses - useful for merging. + * + * @param {WhereClause} clause - The `WhereClause` to be wrapped. + * @returns {{beginClause: WhereClause, endClause: WhereClause}} An object + * containing the `beginClause` (the wrapped version of the input + * `clause`) and the `endClause` (the last clause where the right + * side of the expression ends with a close parenthesis). + */ private static wrapWhereClauseInParenthesis(clause: WhereClause): { beginClause: WhereClause, endClause: WhereClause } { const clone = JSON.parse(JSON.stringify(clause)) as WhereClause; clone.left.openParen = (clone.left.openParen ?? 0) + 1; @@ -1871,6 +1880,17 @@ export class Common { return { beginClause: clone, endClause: current }; } + /** + * Merges two `WhereClause` objects into a single clause, joining them with + * a logical operator (defaults AND). + * + * @param {WhereClause} [where1] - First clause to merge + * @param {WhereClause} [where2] - Second clause to merge + * @param {LogicalOperator} [operator='AND'] - Operator for joing clauses + * + * @returns {WhereClause|undefined} A new `WhereClause` that represents the + * merged expression, or `undefined` if neither clauses were provided. + */ static mergeWhereClauses( where1?: WhereClause, where2?: WhereClause,