From 11b9550d12c12686ac2e2013abd4b8f94bfb22b7 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 | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/modules/components/common_components/common.ts b/src/modules/components/common_components/common.ts index e73643aa..b45269cd 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,18 @@ export class Common { return { beginClause: clone, endClause: current }; } + /** + * Merges two `WhereClause` objects into a single clause, joining them with a + * logical operator. + * + * @param {WhereClause} [where1] - First clause to merge. Optional. + * @param {WhereClause} [where2] - Second clause to merge. Optional. + * @param {LogicalOperator} [operator='AND'] - Operator used to join the clauses + * (default is 'AND'). Optional. + * + * @returns {WhereClause|undefined} A new `WhereClause` that represents the merged + * expression, or `undefined` if both clauses are not provided. + */ static mergeWhereClauses( where1?: WhereClause, where2?: WhereClause,