-
Notifications
You must be signed in to change notification settings - Fork 19
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
added changes for configurable column in target sheet #779
Conversation
Warning Rate limit exceeded@nitish-egov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 27 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent updates to the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant Client
participant API_Server
participant Campaign_Service
participant MDMS_Service
Client->>API_Server: Request campaign data
API_Server->>Campaign_Service: Fetch campaign data
Campaign_Service-->>API_Server: Return campaign data
API_Server->>Client: Respond with campaign data
Client->>API_Server: Request MDMS v2 data
API_Server->>MDMS_Service: Fetch MDMS v2 data
MDMS_Service-->>API_Server: Return MDMS v2 data
API_Server->>Client: Respond with MDMS v2 data
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Outside diff range and nitpick comments (11)
utilities/project-factory/src/server/config/constants.ts (1)
Line range hint
1-1
: Avoid shadowing global 'Error' object in imports.- import Error from "./error.interface" + import CustomError from "./error.interface"utilities/project-factory/src/server/config/index.ts (1)
Line range hint
6-84
: Updated configuration settings to align with QA environment requirements.Consider using environment variables for sensitive data like database credentials to enhance security.
utilities/project-factory/src/server/api/genericApis.ts (3)
Line range hint
72-72
: Replace directhasOwnProperty
usage withObject.hasOwn
.- if (!workbook.Sheets.hasOwnProperty(mainSheet)) { + if (!Object.hasOwn(workbook.Sheets, mainSheet)) {Direct usage of
hasOwnProperty
can lead to issues if the object's prototype has been modified. UsingObject.hasOwn()
is a safer alternative.
Line range hint
112-112
: DeclarelocalizedColumnName
at the function's root level.+ var localizedColumnName; localizedColumnName = getLocalizedName( expectedColumnName, localizationMap );
Declaring variables at the root of their enclosing function improves readability and reduces the chance of scoping errors.
Line range hint
178-185
: Consider replacingforEach
withfor...of
.- jsonData = jsonData.filter((element) => element !== undefined || element !== ''); + for (const element of jsonData) { + if (element !== undefined || element !== '') { + filteredData.push(element); + } + } + return filteredData;Using
for...of
can improve performance and readability, especially when dealing with operations that involve conditional logic inside loops.utilities/project-factory/src/server/utils/genericUtils.ts (2)
Line range hint
61-61
: Replace==
with===
to avoid type coercion issues.- status = errorResult?.code == "UNKNOWN_ERROR" ? 500 : status; + status = errorResult?.code === "UNKNOWN_ERROR" ? 500 : status;
Line range hint
154-154
: Replace==
with===
to ensure strict equality check.- desc: code == 304 ? "cached-response" : "new-response", + desc: code === 304 ? "cached-response" : "new-response",utilities/project-factory/src/server/validators/campaignValidators.ts (1)
Line range hint
450-471
: Refactor to improve readability and maintainability.- async function validateCreateRequest(request: any, localizationMap?: any) { - if (!request?.body?.ResourceDetails || Object.keys(request.body.ResourceDetails).length === 0) { - throwError("COMMON", 400, "VALIDATION_ERROR", "ResourceDetails is missing or empty or null"); - } - else { - // validate create request body - validateBodyViaSchema(createRequestSchema, request.body.ResourceDetails); - await validateCampaignId(request); - await validateHierarchyType(request, request?.body?.ResourceDetails?.hierarchyType, request?.body?.ResourceDetails?.tenantId); - if (request?.body?.ResourceDetails?.tenantId != request?.body?.RequestInfo?.userInfo?.tenantId) { - throwError("COMMON", 400, "VALIDATION_ERROR", "tenantId is not matching with userInfo"); - } - const fileUrl = await validateFile(request); - const localizationMap = await getLocalizedMessagesHandler(request, request?.body?.ResourceDetails?.tenantId); - if (request.body.ResourceDetails.type == 'boundary') { - await validateBoundarySheetData(request, fileUrl, localizationMap); - } - if (request?.body?.ResourceDetails?.type == 'boundaryWithTarget') { - const targetWorkbook: any = await getTargetWorkbook(fileUrl); - const hierarchy = await getHierarchy(request, request?.body?.ResourceDetails?.tenantId, request?.body?.ResourceDetails?.hierarchyType); - const finalValidHeadersForTargetSheetAsPerCampaignType = await getFinalValidHeadersForTargetSheetAsPerCampaignType(request, hierarchy, localizationMap); - validateTabsWithTargetInTargetSheet(request, targetConsider breaking down this large function into smaller, more manageable functions. This will improve readability and make the code easier to maintain.
utilities/project-factory/src/server/utils/campaignUtils.ts (3)
Line range hint
91-100
: ReplaceforEach
withfor...of
for better performance.- errorData.forEach((error: any) => { + for (const error of errorData) {Using
for...of
can enhance performance by reducing the overhead of function calls and improving readability.
Line range hint
97-97
: Use strict equality comparison (===
) instead of loose equality (==
).- if ((error?.status) && !(error?.status == "CREATED" || error?.status == "VALID")) { + if ((error?.status) && !(error?.status === "CREATED" || error?.status === "VALID")) {Using
===
prevents unintended type coercions and ensures that both type and value are checked, which is a best practice in JavaScript/TypeScript.
Line range hint
137-137
: Avoid using thedelete
operator for performance reasons.- delete desiredSheet[cellAddress]; + desiredSheet[cellAddress] = undefined;Setting properties to
undefined
is generally faster and does not affect the underlying performance of JavaScript engines as much asdelete
does.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- utilities/project-factory/src/server/api/campaignApis.ts (2 hunks)
- utilities/project-factory/src/server/api/genericApis.ts (7 hunks)
- utilities/project-factory/src/server/config/constants.ts (3 hunks)
- utilities/project-factory/src/server/config/index.ts (4 hunks)
- utilities/project-factory/src/server/service/dataManageService.ts (1 hunks)
- utilities/project-factory/src/server/utils/campaignUtils.ts (8 hunks)
- utilities/project-factory/src/server/utils/genericUtils.ts (7 hunks)
- utilities/project-factory/src/server/validators/campaignValidators.ts (3 hunks)
Additional context used
Biome
utilities/project-factory/src/server/service/dataManageService.ts
[error] 40-40: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 46-46: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 48-48: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 52-52: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 60-60: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 76-76: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
utilities/project-factory/src/server/config/constants.ts
[error] 1-1: Do not shadow the global "Error" property. (lint/suspicious/noShadowRestrictedNames)
Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
[error] 3-3: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 62-62: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 63-63: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 64-64: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 65-65: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 72-72: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 89-89: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 90-90: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 91-91: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 92-92: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 98-98: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 105-105: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 113-113: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 127-127: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===utilities/project-factory/src/server/api/campaignApis.ts
[error] 23-23: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 28-28: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 34-34: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 34-34: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 34-34: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 38-38: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 52-52: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 65-65: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 83-83: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 83-83: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 85-85: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 96-96: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 114-114: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 114-114: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 116-116: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 138-138: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 138-138: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 158-158: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 158-158: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 158-158: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
utilities/project-factory/src/server/api/genericApis.ts
[error] 37-37: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 51-51: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 72-72: Do not access Object.prototype method 'hasOwnProperty' from target object. (lint/suspicious/noPrototypeBuiltins)
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.
[error] 85-85: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 94-94: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 99-99: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 103-105: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 112-112: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 112-112: This variable implicitly has the any type. (lint/suspicious/noImplicitAnyLet)
Variable declarations without type annotation and initialization implicitly have the any type. Declare a type or initialize the variable with some value.
[error] 139-139: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 140-140: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 142-149: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 163-163: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 165-165: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 169-169: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 175-190: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 175-175: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 176-176: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 178-185: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 200-200: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
utilities/project-factory/src/server/utils/genericUtils.ts
[error] 39-39: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 41-41: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 47-47: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 59-59: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 60-60: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 61-61: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 62-62: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 69-69: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 69-69: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 85-85: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 103-103: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 154-154: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 162-162: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 163-163: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 175-175: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 176-176: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 188-188: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 189-189: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 191-191: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 192-192: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
utilities/project-factory/src/server/validators/campaignValidators.ts
[error] 28-28: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 28-28: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 28-28: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 30-36: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 30-30: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 38-38: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 40-40: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 43-43: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 46-49: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 46-46: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 53-53: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 53-53: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 53-53: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 54-60: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 54-54: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 63-63: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 65-65: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 68-68: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 71-74: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 71-71: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
utilities/project-factory/src/server/utils/campaignUtils.ts
[error] 23-23: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 23-23: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 40-40: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 44-44: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 57-57: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 82-82: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 82-82: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 82-82: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 82-82: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 83-83: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 89-89: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 91-100: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 91-91: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 97-97: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 97-97: Use === instead of ==.
== is only allowed when comparing againstnull
(lint/suspicious/noDoubleEquals)== is only allowed when comparing against null
Using == may be unsafe if you are relying on type coercion
Unsafe fix: Use ===
[error] 106-112: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 106-106: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 129-135: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 129-129: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 137-137: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Additional comments not posted (9)
utilities/project-factory/src/server/service/dataManageService.ts (1)
63-66
: Ensure type safety increateDataService
.- const localizationMap = await getLocalizedMessagesHandler(request, request?.body?.ResourceDetails?.tenantId); + const localizationMap: LocalizationMap = await getLocalizedMessagesHandler(request, request?.body?.ResourceDetails?.tenantId);utilities/project-factory/src/server/config/constants.ts (1)
Line range hint
11-24
: Updated error constants to enhance clarity and coverage.Also applies to: 56-57
utilities/project-factory/src/server/utils/genericUtils.ts (4)
11-11
: Updated import statement to include new utility functions.
Line range hint
382-411
: Refactored boundary data generation process to handle different tabs based on hierarchy type.
647-656
: Error handling inhandleGenerateError
function now includes detailed error information.
953-964
: Added new functiongetHeadersForTargetSheet
to handle headers based on different tabs and campaign types.utilities/project-factory/src/server/validators/campaignValidators.ts (1)
Line range hint
450-471
: Ensure proper error handling and validation invalidateCreateRequest
.Please verify that all possible error scenarios are handled correctly in this function, especially considering the critical nature of campaign validation.
utilities/project-factory/src/server/utils/campaignUtils.ts (2)
1585-1622
: Review the error handling and schema fetching logic.Ensure that the error handling is robust and that the schema fetching logic correctly handles all potential edge cases, including network failures and empty responses.
Verification successful
The error handling and schema fetching logic in the
getConfigurableColumnHeadersBasedOnCampaignType
function appears to be robust. The function includes specificthrowError
calls to handle scenarios such as empty MDMS responses, missing boundary code columns, and general errors during fetching.
throwError("COMMON", 400, "SCHEMA_ERROR", ...)
handles cases where the MDMS response is empty.throwError("COMMON", 400, "VALIDATION_ERROR", ...)
handles cases where the boundary code column is missing.- The catch block with
throwError("FILE", 400, "FETCHING_COLUMN_ERROR", ...)
handles general errors during fetching.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the schema fetching logic and error handling. # Test: Check if the schema fetching logic handles all edge cases. ast-grep --lang typescript --pattern $'try { $$$ throwError($_, $_, $_, $_) $$$ }' utilities/project-factory/src/server/utils/campaignUtils.tsLength of output: 149
Script:
#!/bin/bash # Description: Search for all throwError calls in the file to verify error handling. # Find all instances of throwError in the specified file rg 'throwError' utilities/project-factory/src/server/utils/campaignUtils.tsLength of output: 2572
11-11
: Ensure imports are organized and necessary.Verification successful
The verification process has confirmed that all the imports in
utilities/project-factory/src/server/utils/campaignUtils.ts
are being used within the file.
- : All imports in
utilities/project-factory/src/server/utils/campaignUtils.ts
are necessary and properly organized.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for unused imports and organize them. # Test: List unused imports. Expect: No output if all imports are used. rg --type typescript "import" utilities/project-factory/src/server/utils/campaignUtils.ts | grep -v "used"Length of output: 139
Script:
#!/bin/bash # Description: Check for unused imports and organize them. # Step 1: List all import statements in the file. echo "Import statements in campaignUtils.ts:" ast-grep --lang typescript --pattern 'import { $$$ } from "$_"' utilities/project-factory/src/server/utils/campaignUtils.ts # Step 2: Check usage of each imported item within the file. echo "Usage of imported items in campaignUtils.ts:" for item in $(ast-grep --lang typescript --pattern 'import { $$$ } from "$_"' utilities/project-factory/src/server/utils/campaignUtils.ts | grep -oP '(?<=\{ ).+?(?= \})' | tr ',' '\n' | tr -d ' '); do echo "Checking usage of $item:" rg --type ts "$item" utilities/project-factory/src/server/utils/campaignUtils.ts doneLength of output: 38849
utilities/project-factory/src/server/service/dataManageService.ts
Outdated
Show resolved
Hide resolved
@@ -6,7 +6,7 @@ import { getHeadersOfBoundarySheet, getHierarchy, handleResouceDetailsError } fr | |||
import { campaignDetailsSchema } from "../config/models/campaignDetails"; | |||
import Ajv from "ajv"; | |||
import { calculateKeyIndex, getDifferentDistrictTabs, getLocalizedHeaders, getLocalizedMessagesHandler, modifyTargetData, replicateRequest, throwError } from "../utils/genericUtils"; | |||
import { createBoundaryMap, generateProcessedFileAndPersist, getLocalizedName, getTargetBoundariesRelatedToCampaignId } from "../utils/campaignUtils"; | |||
import { createBoundaryMap, generateProcessedFileAndPersist, getFinalValidHeadersForTargetSheetAsPerCampaignType, getLocalizedName, getTargetBoundariesRelatedToCampaignId } from "../utils/campaignUtils"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace any
with more specific types to enhance type safety.
- import { createBoundaryMap, generateProcessedFileAndPersist, getFinalValidHeadersForTargetSheetAsPerCampaignType, getLocalizedName, getTargetBoundariesRelatedToCampaignId } from "../utils/campaignUtils";
+ import { createBoundaryMap, generateProcessedFileAndPersist, getFinalValidHeadersForTargetSheetAsPerCampaignType, getLocalizedName, getTargetBoundariesRelatedToCampaignId } from "../utils/campaignUtils";
Consider defining interfaces or types for the parameters and return values of these functions to avoid using any
. This will help in catching potential bugs at compile time.
Committable suggestion was skipped due to low confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Outside diff range and nitpick comments (13)
utilities/project-factory/src/server/service/dataManageService.ts (1)
69-72
: Ensure proper logging increateDataService
.Consider adding more descriptive logging before and after the validation to enhance traceability and debugging.
utilities/project-factory/src/server/utils/genericUtils.ts (6)
Line range hint
351-351
: Consider handling potentialundefined
values when using optional chaining.- const updateGeneratedResourceTopic = config?.kafka?.KAFKA_UPDATE_GENERATED_RESOURCE_DETAILS_TOPIC; + const updateGeneratedResourceTopic = config?.kafka?.KAFKA_UPDATE_GENERATED_RESOURCE_DETAILS_TOPIC ?? "default-topic";This change ensures that
updateGeneratedResourceTopic
has a default value if the optional chaining operation results inundefined
, preventing potential runtime errors.
Line range hint
424-431
: ReplaceforEach
withfor...of
for better performance and readability.- boundaryData.forEach((obj: any) => { + for (const obj of boundaryData) {Using
for...of
improves performance, especially with large arrays, and enhances code readability by reducing complexity.Also applies to: 434-440, 478-491, 646-648, 828-852, 925-929, 926-928
Line range hint
556-556
: Simplify computed expressions by using literal keys.- const key = getLocalizedName(config?.boundary?.boundaryCode, localizationMap); + const key = config?.boundary?.boundaryCode;Using direct property access instead of computed expressions can simplify the code and improve performance.
Also applies to: 558-558, 559-559, 560-560, 783-783
Line range hint
797-797
: Declare variables at the root of the enclosing function to avoid confusion.+ let errorString = ""; + let errorFound = false; - var errorString = ""; - var errorFound = false;This change ensures that the scope of the variables is clear and consistent throughout the function.
Also applies to: 798-798
Line range hint
816-816
: Handle potentialundefined
values when using optional chaining.- const fileResponse = await httpRequest(config.host.filestore + config.paths.filestore + "/url", {}, { tenantId: tenantId, fileStoreIds: fileStoreId }, "get"); + const fileResponse = await httpRequest(config.host.filestore + config.paths.filestore + "/url", {}, { tenantId: tenantId, fileStoreIds: fileStoreId }, "get") ?? {};Adding a fallback value ensures that
fileResponse
is always an object, preventing runtime errors if the optional chaining operation results inundefined
.
Line range hint
147-147
: Use lowercase 'number' instead of 'Number' for type annotations.- const getResponseInfo = (code: Number) => ({ + const getResponseInfo = (code: number) => ({Using lowercase primitives enhances consistency and aligns with TypeScript best practices.
utilities/project-factory/src/server/validators/campaignValidators.ts (3)
Line range hint
29-35
: Consider replacingforEach
withfor...of
for better performance.- boundaryItems.forEach((boundaryItem: any) => { + for (const boundaryItem of boundaryItems) {This change should be applied to all instances where
forEach
is used to iterate over arrays.Also applies to: 45-48, 53-59, 70-73, 185-190, 317-322, 537-551, 542-544, 637-640
Line range hint
279-279
: Declare variables at the root of the enclosing function to avoid confusion.- var response = await httpRequest(config.host.boundaryHost + config.paths.boundaryRelationship, request.body, boundaryEntitySearchParams); + const response = await httpRequest(config.host.boundaryHost + config.paths.boundaryRelationship, request.body, boundaryEntitySearchParams);This change should be applied to all instances where
var
is used inside functions.Also applies to: 647-647, 671-677
Line range hint
701-701
: Consider simplifying the computed expressions without using string literals.- const key = `${request?.body?.ResourceDetails?.hierarchyType}_${ele}`.toUpperCase() + const key = request.body.ResourceDetails.hierarchyType + '_' + ele.toUpperCase()This change should be applied to all instances where string literals are used in computed expressions.
Also applies to: 702-702, 703-703, 848-848
utilities/project-factory/src/server/utils/campaignUtils.ts (3)
Line range hint
154-154
: Avoid using thedelete
operator as it can impact performance.- delete request.body.userNameAndPassword; + request.body.userNameAndPassword = undefined;Using
undefined
assignment instead ofdelete
can help maintain performance especially in V8 engines.
Line range hint
325-325
: Declare variables at the root of the enclosing function to avoid confusion.- var createData = [], searchData = []; + let createData = [], searchData = [];This change ensures that the scope of the variables is clear and conforms to best practices in JavaScript.
Also applies to: 533-536, 550-550
Line range hint
588-606
: ReplaceforEach
withfor...of
loops to enhance performance.- boundaryData.forEach((row: any) => { + for (const row of boundaryData) {This change is suggested to improve performance by reducing the number of iterations over the same data set, especially beneficial for large arrays.
Also applies to: 619-639, 682-682
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- utilities/project-factory/src/server/api/campaignApis.ts (2 hunks)
- utilities/project-factory/src/server/api/genericApis.ts (6 hunks)
- utilities/project-factory/src/server/config/index.ts (1 hunks)
- utilities/project-factory/src/server/service/dataManageService.ts (1 hunks)
- utilities/project-factory/src/server/utils/campaignUtils.ts (7 hunks)
- utilities/project-factory/src/server/utils/genericUtils.ts (8 hunks)
- utilities/project-factory/src/server/validators/campaignValidators.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- utilities/project-factory/src/server/config/index.ts
Additional context used
Biome
utilities/project-factory/src/server/service/dataManageService.ts
[error] 44-44: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
utilities/project-factory/src/server/api/campaignApis.ts
[error] 28-28: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 38-38: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 174-193: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 197-222: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 230-232: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 236-238: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 237-237: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 243-243: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 247-247: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 324-324: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 476-476: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 532-540: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 573-573: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 574-574: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 583-583: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 593-593: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 596-596: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 599-599: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 608-608: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 710-710: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
utilities/project-factory/src/server/api/genericApis.ts
[error] 67-69: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 506-506: Unnecessary continue statement (lint/correctness/noUnnecessaryContinue)
Unsafe fix: Delete the unnecessary continue statement
[error] 738-738: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 767-767: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 769-769: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 773-773: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 797-797: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 801-803: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 861-861: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 862-862: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 892-892: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 895-895: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 896-896: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 897-897: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 898-898: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 899-899: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 900-900: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 1038-1038: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 184-184: Don't use 'String' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead
[error] 225-225: Don't use 'String' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'string' insteadutilities/project-factory/src/server/utils/genericUtils.ts
[error] 351-351: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 424-431: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 434-440: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 478-491: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 556-556: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 558-558: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 559-559: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 560-560: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 646-648: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 783-783: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 797-797: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 798-798: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 816-816: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 828-852: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 925-929: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 926-928: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 147-147: Don't use 'Number' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'number' insteadutilities/project-factory/src/server/validators/campaignValidators.ts
[error] 29-35: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 45-48: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 53-59: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 70-73: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 185-190: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 279-279: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 317-322: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 367-367: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 415-415: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 537-551: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 542-544: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 637-640: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 647-647: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 656-656: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 671-677: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 701-701: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 702-702: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 703-703: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 809-809: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 848-848: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
utilities/project-factory/src/server/utils/campaignUtils.ts
[error] 106-116: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 124-130: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 147-151: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 154-154: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 187-202: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 260-264: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 325-325: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 361-361: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 407-407: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 449-449: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 478-478: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 480-480: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 516-516: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 518-518: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 519-519: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 533-536: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 550-550: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 588-606: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 619-639: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 682-682: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
Additional comments not posted (4)
utilities/project-factory/src/server/api/genericApis.ts (1)
562-567
: Ensure correct integration of new utility functions for configurable headers.This script checks the usage of the newly integrated functions to ensure they are being used correctly across the project.
Verification successful
The search results indicate that the functions
getConfigurableColumnHeadersBasedOnCampaignType
andgetCampaignSearchResponse
are indeed integrated and used in various parts of the codebase. Here are the relevant locations:
utilities/project-factory/src/server/utils/genericUtils.ts
utilities/project-factory/src/server/utils/campaignUtils.ts
utilities/project-factory/src/server/api/genericApis.ts
utilities/project-factory/src/server/api/campaignApis.ts
These usages suggest that the new utility functions are integrated correctly and are being utilized in the system.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new utility functions integrate correctly and are used properly in the system. # Test: Search for the usage of `getConfigurableColumnHeadersBasedOnCampaignType` and `getCampaignSearchResponse`. rg --type typescript $'getConfigurableColumnHeadersBasedOnCampaignType|getCampaignSearchResponse'Length of output: 133
Script:
#!/bin/bash # Description: Verify that the new utility functions integrate correctly and are used properly in the system. # Test: Search for the usage of `getConfigurableColumnHeadersBasedOnCampaignType` and `getCampaignSearchResponse`. rg --type ts $'getConfigurableColumnHeadersBasedOnCampaignType|getCampaignSearchResponse'Length of output: 2420
utilities/project-factory/src/server/validators/campaignValidators.ts (2)
9-9
: Consider replacingany
with more specific types to enhance type safety.
Line range hint
367-367
: Check the usage of optional chaining to ensure it does not lead to runtime errors.Also applies to: 415-415, 656-656, 809-809
utilities/project-factory/src/server/utils/campaignUtils.ts (1)
Line range hint
361-361
: Check for potentialTypeError
due to unsafe usage of optional chaining.Ensure that the code properly handles cases where optional chaining might short-circuit with
undefined
, leading to runtime errors.Also applies to: 407-407
Verification successful
The search results indicate that optional chaining is used extensively throughout the codebase, including in the
campaignUtils.ts
file. Specifically, the lines in question:for (const activity of request?.body?.Activities) {and
if (request?.body?.Activities && Array.isArray(request?.body?.Activities && request?.body?.Activities.length > 0)) {do use optional chaining. However, the usage of optional chaining here is generally safe as it checks for the existence of
request.body
andrequest.body.Activities
before attempting to iterate overActivities
.Given the extensive use of optional chaining and the context provided, it appears that the codebase is designed to handle cases where properties might be
undefined
. Therefore, the potential for aTypeError
due to unsafe usage of optional chaining seems to be mitigated by these checks.
utilities/project-factory/src/server/utils/campaignUtils.ts:361
utilities/project-factory/src/server/utils/campaignUtils.ts:407
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of undefined values in optional chaining. # Test: Search for the usage of optional chaining in the file. rg --type typescript $'?.'Length of output: 105
Script:
#!/bin/bash # Description: Verify the handling of undefined values in optional chaining. # Test: Search for the usage of optional chaining in the file. rg --type typescript '\?\.'Length of output: 64
Script:
#!/bin/bash # Description: Verify the handling of undefined values in optional chaining. # Test: Search for the usage of optional chaining in the file. rg --glob '*.ts' '\?\.'Length of output: 108464
import { confirmProjectParentCreation, createProjectCampaignResourcData, getCampaignSearchResponse, getHierarchy, handleResouceDetailsError, projectCreate } from "../api/campaignApis"; | ||
import { getCampaignNumber, createAndUploadFile, getSheetData, createExcelSheet, getAutoGeneratedBoundaryCodesHandler, getTargetSheetData, createBoundaryEntities, createBoundaryRelationship, getMDMSV1Data, callMdmsV2Data } from "../api/genericApis"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing forEach
with for...of
loops for better performance.
- errorData.forEach((error: any) => {
+ for (const error of errorData) {
This change is recommended to avoid potential performance issues when working with large arrays, as forEach
can lead to multiple iterations over the same data.
Committable suggestion was skipped due to low confidence.
utilities/project-factory/src/server/service/dataManageService.ts
Outdated
Show resolved
Hide resolved
async function getCampaignSearchResponse(request: any) { | ||
try { | ||
logger.info(`searching for campaign details`); | ||
const requestInfo = { "RequestInfo": request?.body?.RequestInfo }; | ||
const campaignDetails = { "CampaignDetails": { tenantId: request?.query?.tenantId || request?.body?.ResourceDetails?.tenantId, "ids": [request?.query?.campaignId || request?.body?.ResourceDetails?.campaignId] } } | ||
const requestBody = { ...requestInfo, ...campaignDetails }; | ||
const req: any = replicateRequest(request, requestBody) | ||
const projectTypeSearchResponse: any = await searchProjectTypeCampaignService(req); | ||
return projectTypeSearchResponse; | ||
} catch (error: any) { | ||
throwError("COMMON", 400, "RESPONSE_NOT_FOUND_ERROR", error?.message) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor error handling in getCampaignSearchResponse
to improve robustness.
async function getCampaignSearchResponse(request: any) {
try {
logger.info(`searching for campaign details`);
const requestInfo = { "RequestInfo": request?.body?.RequestInfo };
const campaignDetails = { "CampaignDetails": { tenantId: request?.query?.tenantId || request?.body?.ResourceDetails?.tenantId, "ids": [request?.query?.campaignId || request?.body?.ResourceDetails?.campaignId] } }
const requestBody = { ...requestInfo, ...campaignDetails };
const req: any = replicateRequest(request, requestBody)
const projectTypeSearchResponse: any = await searchProjectTypeCampaignService(req);
return projectTypeSearchResponse;
} catch (error: any) {
logger.error(`Error while searching for campaign details: ${error.message}`);
throwError("COMMON", 400, "RESPONSE_NOT_FOUND_ERROR", error?.message)
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (5)
utilities/project-factory/src/server/utils/genericUtils.ts (5)
Line range hint
351-351
: Consider handling potentialundefined
values from optional chaining to avoid runtime errors.- const updateGeneratedResourceTopic = config?.kafka?.KAFKA_UPDATE_GENERATED_RESOURCE_DETAILS_TOPIC; + const updateGeneratedResourceTopic = config?.kafka?.KAFKA_UPDATE_GENERATED_RESOURCE_DETAILS_TOPIC ?? "default-topic";
Line range hint
423-430
: ReplaceforEach
withfor...of
loops for better performance and readability, especially when dealing with large arrays.- campaignDetails.forEach((detail: any) => { + for (const detail of campaignDetails) {Also applies to: 433-439, 477-490, 645-647, 827-851, 924-928, 925-927
Line range hint
555-555
: Simplify computed expressions by using literal keys where possible.- const localizedBoundaryCode = getLocalizedName(getBoundaryColumnName(), localizationMap) + const localizedBoundaryCode = localizationMap[getBoundaryColumnName()] || getBoundaryColumnName();Also applies to: 557-557, 558-558, 559-559, 782-782
Line range hint
796-796
: Declare variables at the root of the enclosing function to avoid potential scope confusion.+ let errorString = ""; + let errorFound = false; - for (const key of keys) { + for (const key of keys) {Also applies to: 797-797
Line range hint
147-147
: Use lowercase 'number' instead of 'Number' for type consistency.- const getResponseInfo = (code: Number) => ({ + const getResponseInfo = (code: number) => ({
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- utilities/project-factory/src/server/api/campaignApis.ts (2 hunks)
- utilities/project-factory/src/server/api/genericApis.ts (6 hunks)
- utilities/project-factory/src/server/config/index.ts (2 hunks)
- utilities/project-factory/src/server/utils/genericUtils.ts (8 hunks)
Files skipped from review as they are similar to previous changes (1)
- utilities/project-factory/src/server/config/index.ts
Additional context used
Biome
utilities/project-factory/src/server/api/campaignApis.ts
[error] 28-28: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 38-38: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 174-193: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 197-222: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 230-232: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 236-238: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 237-237: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 243-243: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 247-247: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 324-324: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 476-476: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 532-540: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 573-573: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 574-574: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 583-583: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 593-593: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 596-596: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 599-599: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 608-608: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 710-710: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
utilities/project-factory/src/server/api/genericApis.ts
[error] 67-69: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 506-506: Unnecessary continue statement (lint/correctness/noUnnecessaryContinue)
Unsafe fix: Delete the unnecessary continue statement
[error] 738-738: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 767-767: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 769-769: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 773-773: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 797-797: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 801-803: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 861-861: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 862-862: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 892-892: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 895-895: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 896-896: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 897-897: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 898-898: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 899-899: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 900-900: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 1038-1038: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 184-184: Don't use 'String' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead
[error] 225-225: Don't use 'String' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'string' insteadutilities/project-factory/src/server/utils/genericUtils.ts
[error] 351-351: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 423-430: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 433-439: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 477-490: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 555-555: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 557-557: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 558-558: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 559-559: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 645-647: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 782-782: The computed expression can be simplified without the use of a string literal. (lint/complexity/useLiteralKeys)
Unsafe fix: Use a literal key instead.
[error] 796-796: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 797-797: This var should be declared at the root of the enclosing function. (lint/correctness/noInnerDeclarations)
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.
[error] 815-815: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
[error] 827-851: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 924-928: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 925-927: Prefer for...of instead of forEach. (lint/complexity/noForEach)
forEach may lead to performance issues when working with large arrays. When combined with functions like filter or map, this causes multiple iterations over the same type.
[error] 147-147: Don't use 'Number' as a type. (lint/complexity/noBannedTypes)
Use lowercase primitives for consistency.
Safe fix: Use 'number' instead
Additional comments not posted (2)
utilities/project-factory/src/server/api/campaignApis.ts (1)
837-848
: Refactor error handling ingetCampaignSearchResponse
to improve robustness.async function getCampaignSearchResponse(request: any) { try { logger.info(`searching for campaign details`); const requestInfo = { "RequestInfo": request?.body?.RequestInfo }; const campaignDetails = { "CampaignDetails": { tenantId: request?.query?.tenantId || request?.body?.ResourceDetails?.tenantId, "ids": [request?.query?.campaignId || request?.body?.ResourceDetails?.campaignId] } } const requestBody = { ...requestInfo, ...campaignDetails }; const req: any = replicateRequest(request, requestBody) const projectTypeSearchResponse: any = await searchProjectTypeCampaignService(req); return projectTypeSearchResponse; } catch (error: any) { logger.error(`Error while searching for campaign details: ${error.message}`); throwError("COMMON", 400, "RESPONSE_NOT_FOUND_ERROR", error?.message) } }utilities/project-factory/src/server/api/genericApis.ts (1)
8-9
: Update imports to reflect function renaming and new additions.The changes in imports correctly reflect the renaming of
getFiltersFromCampaignSearchResponse
togetCampaignSearchResponse
and the addition ofgetConfigurableColumnHeadersBasedOnCampaignType
. This aligns with the updates incampaignApis.ts
and ensures consistency across the codebase.
* Updates the delivery rules logic for gender * * info message for status creating (#644) * success message if user cred sheet * send id with key resourceid * Send variant in sku also Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Feat : added boundary validation (#643) Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> * Update campaignValidators.ts (#645) * added delay in download (#646) * Update campaignValidators.ts (#647) * fixes (#649) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * fixed header validation (#648) * change in filter recursive (#650) * Update genericUtils.ts (#652) * fix (#651) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * updated lowest level hierarchy validation for target HLM -5948 (#654) * Update campaignValidators.ts (#655) * fixes-> cyclenumber issue, hover issue, dropdown height issue, * css * fixes-> cyclenumber issue, hover issue, dropdown height issue, (#656) * fixes-> cyclenumber issue, hover issue, dropdown height issue, * css --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Update campaignUtils.ts * fixed HLM-5970 * Feat : added boundary validation at data level * fixes * local add * Added boundary validation * Refactor * fixed HLM-5935 and HLM-5749 * Refactor * Feat : updated table * change campaignid in payload * Feat : added campaignId * Update campaignApis.ts * Update campaignValidators.ts * refactored * Refactor * assigned campaignId * Refactor * updated createRequest Schema * Feat : invalid Status Persist * status fix * version-fix * Update CODEOWNERS * core version updated and css fix for language dropdown * refactor (#676) * Uat signoff (#678) * change in filter recursive * lowest level * added validation related to target sheet headers * HLM-5916 * download button fixes in summary (#682) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Hlm 5927 (#687) * change in filter recursive * lowest level * added validation for boundary codes to be invalid other than that selected from UI in target upload * Added Delivery and cycle config for LLIN and SMC both (#688) * no of cycle and deivery drafted changes * fixes * add localisation code for boundaries * fixes * fixes * Value localise in summary screen, api error change * fixes * genarate api call fix * font size change for summary * login css change * HLM-5718: SMC delivery config enhancement * config update * added config for in between * fix config for llin * added mdms integration --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Fixed HLM-5988_warning message (#689) Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com> * download filename fixes (#693) * download button fixes in summary * download filename with custom name changes added --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * download filename fixes (#694) * download button fixes in summary * download filename with custom name changes added * config fix for llin --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * successful toast message is fixed (#695) * successful toast message is fixed * Update UploadData.js * HLM-5991: Alert Pop UP CR (#696) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * HLM-5718 changes (#703) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Localization cache (#706) * change in filter recursive * lowest level * refactored localization cache logic * Update README.md (#707) * Update README.md * Update README.md * Update utilities/project-factory/README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update README.md --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * HLM-5985_made lowest level changes (#708) * HLM-5985_made lowest level changes * resolved codeRabbit comments * Create LOCALSETUP.md (#709) * Create LOCALSETUP.md * Refactored config * Update LOCALSETUP.md * Update utilities/project-factory/LOCALSETUP.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/LOCALSETUP.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/LOCALSETUP.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/LOCALSETUP.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update LOCALSETUP.md --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * updated the localisation module config * Refactor config (#713) * Refactor config * Update utilities/project-factory/src/server/validators/campaignValidators.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/validators/campaignValidators.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/validators/campaignValidators.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update postman_collection.json (#714) * Update postman_collection.json * Update postman_collection.json * Delete utilities/project-factory/project_factory_swagger.yml (#715) * Feat : removed campaignId validation for boundary upload (#718) * updated the delay for boundary relationship * added logger for request TODO TEST will be reverted * Revert "added logger for request TODO TEST" This reverts commit d5c2bf5. * Schema validation (#719) * Feat : removed campaignId validation for boundary upload * Feat : added schema validation * Fixed mdms host * updated the logger messages * updated the loggers * delivery new changes, toast fix, error fix (#716) * delivery new changes, toast fix, error fix * new fixes * fixes * change text component to field component * added hierarchy * fix * fix * fix * fix * passing hierarchy from props --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Schema validation2 (#721) * Feat : removed campaignId validation for boundary upload * Feat : added schema validation * Fixed mdms host * Feat : added boundary validation * Feat : optimized product search * Fix : project mapping fixed (#722) * Fixed project search (#723) * smc fixes (#724) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Feat : added boundary confirmation (#727) * Fix: fixed processing boundary * Refactor * fixed HLM-6109 (#729) * gate fixes validation, ui ux (#731) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * integrated panelcard component (#732) * integrated panelcard component * Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/Response.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update genericUtils.ts (#733) * Create CHANGELOG.md (#717) * Update request.ts (#735) * fixed generate api issue (#734) Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> * Create CHANGELOG.md * gate fixes (#736) * gate fixes validation, ui ux * gate fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * added loader in the selecting boundaries (#737) * Update createAndSearch.ts (#738) * fix (#739) * fix * fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Patch 3 (#740) * change in filter recursive * lowest level * trimmed underscore and empty spaces * boundary fix (#742) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Update genericUtils.ts (#746) * fixed the delivery products issue * Fixed delivery conditions issue * Update campaignApis.ts (#747) * fixed warning toast (#748) * fixed warning toast * Update UploadData.js * fix (#749) * fix * fx * fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * core -update (#751) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * fixed stepper issue (#752) * fixed stepper issue * Update index.html * Feat : added user validation via individual (#753) * fixes (#754) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * code fix nabeel (#756) * fixes * fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Updated few loggers (#759) * updated few loggers flow * Update utilities/project-factory/src/server/api/campaignApis.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/utils/campaignUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/validators/campaignValidators.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/api/campaignApis.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update utilities/project-factory/src/server/utils/genericUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Updated the user Password generation logic #761 * Update Listener.ts (#730) * Update Listener.ts * added try catch logic in producer * Feat : added parallel batch execution (#767) * Feat : added parallel batch execution * Refactor * Update utilities/project-factory/src/server/validators/campaignValidators.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fixed the stepper (#765) * changes config (#769) * Project type config and added loggers for process of campaign (#772) * Feat : added themes in generate template (#773) * fixed the ajv package version for build issue * Feat : removed xlsx (#776) * HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT (#778) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * css update (#780) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * HLM-6179 and HLM-6180 (#777) * HLM-6179 and HLM-6180 * campaign name changes --------- Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> * Feat : fixed target generation (#781) * fixed tenantId issue (#784) * fix: resolved AJV-related Jenkins build issue reference #783 #786 (#787) * module ui fix * updated all the package version for build fixes * fixed kafka-error at target generation (#789) * updated core version (#791) * updated core version * updated css also * Update campaignValidators.ts (#794) * Updated the excel generation logic and files * added changes for configurable column in target sheet (#779) * change in filter recursive * lowest level * made target headers genearte through mdms schema * changed config index.ts * changed config index.ts * changes for now * added configurable column logic from schema HLM-6169 * updated validate of target columns through schema * added masterForColumnSchema in index.ts * formatted dataManageService * refactored lock TargetFields func * removed console.log * User creation performance improved (#800) * Feat : Improved user creation performance * Change status color * Update utilities/project-factory/src/server/utils/campaignUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update genericUtils.ts (#801) * Hlm 6170 (#802) * change in filter recursive * lowest level * HLM -6170 added logic for only village level data in target sheet and some refactoring * updated css (#804) * fixed button issue (#805) * HLM 6177: Error card implementation in summary screen (#806) * HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT * Added Error Cards in summary screen and redirection --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * added error button styles (#807) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * updated popUp css (#808) * HLM 6178: Implementing New Pop up screen in boundaries (#809) * added error button styles * Implementing New Pop up screen in boundaries --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Facility changes (#812) * Feat : changed facility Template * Feat : locked target templates * fixed colour issue (#813) * Updated the project type conversion logic for the "deliveryType" dont1 and n config * Unique field added (#814) * Feat : changed facility Template * Feat : locked target templates * Feat : added unique check logic * Target schema update (#815) * change in filter recursive * lowest level * updated shcema of target columns to be configurable * removed empty spaces from config index.ts * Active mapping (#817) * Feat : changed facility Template * Feat : locked target templates * Feat : added unique check logic * Feat : added mapping via active field * changes in the schema validation (#816) * Updated the workbench and css module version * Feat : added active inactive boundary check (#818) * Update campaignValidators.ts (#819) * added active inactive validation (#820) * changed api call time (#826) * Feat : added target sum mapping (#825) * added campaign type as filter (#827) * Update genericApis.ts (#828) * Update excelUtils.ts (#829) * UI issue fixes, icon fix in summary error (#831) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Target columns (#830) * change in filter recursive * lowest level * commit * Feat : target flow fixed for LLIN-mz * uat to dev --------- Co-authored-by: admin1 <nitish@egovernments.org> * Feat : freezed target columns (#833) * Target mr dn (#834) * change in filter recursive * lowest level * Feat : skipped validation temporarily * changes in the target validation (#835) * fixed error info (#837) * Added roboto font (#840) * Feat : added roboto font * Fixed config * target validation based on diff campaign types (#843) * change in filter recursive * lowest level * updated validation of target based on campaign type * fixed validation issue (#844) * Updated the workbench package version * fixed validation logic (#846) * fixed validation logic * Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Error messages improved (#848) * Feat : imporved error messages and initilised utils for tracking process * Fix ; unused variables fixed * Feat : improved error messages * Fix : download error fix (#850) * Update campaignUtils.ts (#851) * Update campaignUtils.ts * Update utilities/project-factory/src/server/utils/campaignUtils.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update campaignValidators.ts (#853) * HLM 6210: Toast, error focus fix and project type reset delivery data fix (#854) * HLM-6210: campaign type change reset delivery data fix, summary error focus fix * summary error focus fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * HLM-6225_added time out according to data (#855) * Update campaignValidators.ts (#859) * HLM 6210 (#858) * HLM-6210: campaign type change reset delivery data fix, summary error focus fix * summary error focus fix * parallel search fixes --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Remove validation (#852) * change in filter recursive * lowest level * removed unnecessary validation for target * spacing refactor * Update campaignValidators.ts (#863) * Header validation (#861) * change in filter recursive * lowest level * removed unnecessary validation for target * changed the logic of header validation * space refactor * Update campaignUtils.ts (#864) * fixed ui error (#865) * Read me (#867) * change in filter recursive * lowest level * removed unnecessary validation for target * changed the logic of header validation * fixed portugese language error * space refactoring * Update Dockerfile * Update Dockerfile * Update migrate.sh * Update Dockerfile * Update campaignValidators.ts (#868) * HLM 6210:campaign type change reset fix (#869) * HLM-6210: campaign type change reset delivery data fix, summary error focus fix * summary error focus fix * parallel search fixes * campaign type change reset fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Update excelUtils.ts for sheetHeaders wraping (#870) * Update package.json * updated error messages (#871) * feat : added jaeger-client tracing (#872) * updated the table config * Update campaignApis.ts (#875) * removed the schema and updated the db name * fixing generate API call, file auto delete, date error (#877) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Trim resource (#878) * Feat : trimmed resource persist message * Refactor * Removed reject error in produce message * fixed min time, draft logic (#879) * Update index.ts (#880) * added min ui error and facility usage (#883) * added min ui error and facility usage * changes * Update campaignUtils.ts (#884) * HLM 6007 (#885) * fixing generate API call, file auto delete, date error * generate api fix --------- Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * Update Dockerfile * Feat : docker config update (#886) * Update Dockerfile (#887) * Create buildWorkbenchUI.yml * Update README.md (#917) * Update buildWorkbenchUI.yml * Update README.md * Updated the DB Schema issue of Project-factory * fixed hierarchy order (#919) * User flag hcm (#920) * Feat : docker config update * Feat : added user create flag * Refactored * Update campaignUtils.ts * Update campaignMappingUtils.ts (#922) * Ashish egov patch 2 (#921) * Update index.ts * Update campaignApis.ts * Fixed the project type conversion and product duplicate issue * Update campaignApis.ts (#924) * Update campaignMappingUtils.ts (#925) * Update campaignMappingUtils.ts * Refactored * Update publishProjectFactory.yml * Update buildWorkbenchUI.yml * Update campaignMappingUtils.ts (#926) * Update request.ts (#928) * Update request.ts * Feat : updated httprequest * Feat : warning response added * Refactor * added start and enddate in cycles * Update campaignApis.ts (#930) * Update request.ts (#932) * fixed generate issue (#933) * Fixed project-type resources duplication * updated target error messages (#936) * fixed stepper from draft (#937) * Update Listener.ts * delivery type disable fix, product sku name change (#939) Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> * fixed error message issue (#941) * Redis integration (#940) * Feat : added redis * Feat : added redis retry * removed templates folder * updated the folder structure for health ui and removed utilties * Update publishAllPackages.yml * Update buildWorkbenchUI.yml --------- Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com> Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com> Co-authored-by: ashish-egov <137176738+ashish-egov@users.noreply.github.com> Co-authored-by: Bhavya-egov <137176879+Bhavya-egov@users.noreply.github.com> Co-authored-by: nitish-egov <137176807+nitish-egov@users.noreply.github.com> Co-authored-by: Bhavya-egov <bhavya.mangal@egovernments.org> Co-authored-by: ashish-egov <ashish.tiwari@egovernments.org> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Swathi-eGov <137176788+Swathi-eGov@users.noreply.github.com> Co-authored-by: admin1 <nitish@egovernments.org>
No description provided.