@realtek/core-theme-live 0.0.440 → 0.0.444

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"diceCandidateMapper-BjMhHno3.cjs","names":[],"sources":["../src/services/diceCandidateMapper.js"],"sourcesContent":["/**\r\n * Dice Candidate Response Mapper\r\n * \r\n * Transforms Dice API candidate responses into the existing Internal Candidate\r\n * List API format. This ensures the frontend receives an identical response\r\n * schema regardless of the data source.\r\n * \r\n * Reusable for additional external sources (Monster, CareerBuilder, LinkedIn, etc.)\r\n */\r\n\r\n/**\r\n * Normalizes skills from various Dice skill formats into a simple string array\r\n */\r\nfunction firstPresentValue(...values) {\r\n return values.find((value) => value !== undefined && value !== null && String(value).trim() !== '');\r\n}\r\n\r\nfunction getPathValue(record, path) {\r\n if (!record || !path) return undefined;\r\n if (Object.prototype.hasOwnProperty.call(record, path)) return record[path];\r\n return String(path)\r\n .split('.')\r\n .reduce((value, key) => value?.[key], record);\r\n}\r\n\r\nfunction isLikelyInternalRecordId(value) {\r\n return /^[a-f0-9]{24}$/i.test(String(value ?? '').trim());\r\n}\r\n\r\nfunction isLikelyDiceProfileId(value) {\r\n const text = String(value ?? '').trim();\r\n return (\r\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)\r\n || /^[a-f0-9]{40,}$/i.test(text)\r\n );\r\n}\r\n\r\nfunction isLikelyDiceCandidateId(value, candidate) {\r\n const text = String(value ?? '').trim();\r\n const knownCandidateId = firstPresentValue(\r\n candidate?.candidateId,\r\n candidate?.customFields?.diceProfileData?.candidateId,\r\n );\r\n\r\n return (\r\n (knownCandidateId && text === String(knownCandidateId).trim())\r\n || /^[a-f0-9]{40,}-\\d+$/i.test(text)\r\n );\r\n}\r\n\r\nfunction findLikelyDiceProfileId(record) {\r\n const seen = new Set();\r\n const candidates = [];\r\n\r\n const visit = (value, path = '') => {\r\n if (value === null || value === undefined) return;\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n const text = String(value).trim();\r\n const keyLooksRelevant = /(^|[._-])(dice|profile|source|external).*(id|guid|uuid)$|(^|[._-])(id|guid|uuid)$/i.test(path);\r\n if (text && keyLooksRelevant && isLikelyDiceProfileId(text)) {\r\n candidates.push({ path, value: text });\r\n }\r\n return;\r\n }\r\n if (typeof value !== 'object' || seen.has(value)) return;\r\n seen.add(value);\r\n Object.entries(value).forEach(([key, child]) => {\r\n visit(child, path ? `${path}.${key}` : key);\r\n });\r\n };\r\n\r\n visit(record);\r\n\r\n return candidates.find((candidate) => /dice|profile|source|external/i.test(candidate.path))?.value\r\n ?? candidates[0]?.value\r\n ?? '';\r\n}\r\n\r\nexport function resolveDiceProfileId(candidate) {\r\n if (!candidate || typeof candidate !== 'object') return '';\r\n\r\n // Check if this is a Dice candidate\r\n const isDiceCandidate = (() => {\r\n const source = candidate?.sourceType\r\n ?? candidate?.profileSource\r\n ?? candidate?.selectedSource;\r\n const normalizedSources = Array.isArray(source) ? source : [source];\r\n return normalizedSources.some(\r\n (value) => String(value ?? '').trim().toLowerCase() === 'dice',\r\n );\r\n })();\r\n\r\n const explicitPaths = [\r\n 'diceId',\r\n 'diceID',\r\n 'dice_id',\r\n 'diceProfileId',\r\n 'diceProfileID',\r\n 'diceProfileGuid',\r\n 'profileId',\r\n 'profileID',\r\n 'profileGuid',\r\n 'sourceId',\r\n 'sourceProfileId',\r\n 'externalId',\r\n 'externalProfileId',\r\n 'customFields.diceId',\r\n 'customFields.diceProfileId',\r\n 'customFields.profileId',\r\n 'customFields.externalProfileId',\r\n 'customFields.diceProfileData.diceId',\r\n 'customFields.diceProfileData.diceID',\r\n 'customFields.diceProfileData.id',\r\n 'customFields.diceProfileData._id',\r\n 'customFields.diceProfileData.profileId',\r\n 'customFields.diceProfileData.profileID',\r\n 'customFields.diceProfileData.diceProfileId',\r\n 'customFields.diceProfileData.diceProfileID',\r\n 'customFields.diceProfileData.guid',\r\n 'customFields.diceProfileData.uuid',\r\n 'customFields.diceProfileData.externalId',\r\n 'customFields.diceProfileData.candidateid',\r\n 'customFields.diceProfileData.candidateId',\r\n ];\r\n\r\n const explicitDiceId = firstPresentValue(\r\n ...explicitPaths.map((path) => getPathValue(candidate, path)),\r\n );\r\n\r\n if (explicitDiceId && !isLikelyDiceCandidateId(explicitDiceId, candidate)) {\r\n return String(explicitDiceId);\r\n }\r\n\r\n const likelyNestedId = findLikelyDiceProfileId(candidate);\r\n if (likelyNestedId) return likelyNestedId;\r\n\r\n const genericId = firstPresentValue(candidate.id, candidate._id);\r\n \r\n // For Dice candidates, accept the ID even if it looks like an internal MongoDB ObjectId\r\n // For non-Dice candidates, reject IDs that look like internal record IDs\r\n if (genericId && (isDiceCandidate || !isLikelyInternalRecordId(genericId))) {\r\n return String(genericId);\r\n }\r\n \r\n return '';\r\n}\r\n\r\nexport function normalizeDiceSkills(skills) {\r\n if (!skills) return [];\r\n \r\n if (Array.isArray(skills)) {\r\n return skills\r\n .map(skill => {\r\n // Handle Dice format: {skill: \"courts\", lastUsed: 2026}\r\n if (skill?.skill) return skill.skill;\r\n // Handle other object formats\r\n if (typeof skill === 'object' && skill !== null) {\r\n if (skill?.name) return skill.name;\r\n if (skill?.skillName) return skill.skillName;\r\n if (skill?.value) return skill.value;\r\n }\r\n // Handle string skills\r\n if (typeof skill === 'string') return skill;\r\n return null;\r\n })\r\n .filter(Boolean);\r\n }\r\n \r\n if (typeof skills === 'string') {\r\n return skills.split(',').map(s => s.trim()).filter(Boolean);\r\n }\r\n \r\n return [];\r\n}\r\n\r\n/**\r\n * Normalizes location from various Dice location formats\r\n */\r\nfunction normalizeDiceLocation(candidate) {\r\n // Try locations array first (common in Dice)\r\n if (Array.isArray(candidate.locations) && candidate.locations.length > 0) {\r\n const loc = candidate.locations[0];\r\n if (typeof loc === 'string') return loc;\r\n if (loc?.region) return loc.region;\r\n if (loc?.city) return loc.city;\r\n if (loc?.name) return loc.name;\r\n if (loc?.location) return loc.location;\r\n }\r\n \r\n // Try direct location fields\r\n return (\r\n candidate.currentLocation ??\r\n candidate.location ??\r\n candidate.city ??\r\n candidate.region ??\r\n ''\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes experience from various Dice experience formats\r\n */\r\nfunction normalizeDiceExperience(candidate) {\r\n const exp = (\r\n candidate.totalExperience ??\r\n candidate.experience ??\r\n candidate.yearsOfExperience ??\r\n candidate.exp ??\r\n candidate.totalYearsOfExperience ??\r\n candidate.workExperienceYears\r\n );\r\n \r\n return exp != null && exp !== '' ? exp : null;\r\n}\r\n\r\n/**\r\n * Normalizes date from various Dice date formats\r\n */\r\nfunction normalizeDiceDate(candidate) {\r\n return (\r\n candidate.dateLastUpdated ??\r\n candidate.updatedAt ??\r\n candidate.createdAt ??\r\n candidate.createdDate ??\r\n candidate.dateCreated ??\r\n null\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes name from various Dice name formats\r\n */\r\nfunction normalizeDiceName(candidate) {\r\n const parts = [\r\n candidate.firstName,\r\n candidate.middleName,\r\n candidate.lastName,\r\n ].filter(Boolean);\r\n \r\n if (parts.length > 0) return parts.join(' ');\r\n \r\n return (\r\n candidate.fullName ??\r\n candidate.name ??\r\n candidate.candidateName ??\r\n ''\r\n );\r\n}\r\n\r\n/**\r\n * Maps a single Dice candidate to the Internal Candidate format\r\n * \r\n * @param {Object} diceCandidate - Raw Dice API candidate object\r\n * @param {number} index - Index for fallback ID generation\r\n * @returns {Object} Mapped candidate in Internal format\r\n */\r\nexport function mapDiceCandidateToInternal(diceCandidate, index = 0) {\r\n if (!diceCandidate || typeof diceCandidate !== 'object') {\r\n return {\r\n id: `dice-candidate-${index}`,\r\n diceId: '',\r\n candidateId: '',\r\n firstName: '',\r\n lastName: '',\r\n name: '-',\r\n designation: '-',\r\n currentLocation: '',\r\n location: '',\r\n exp: '',\r\n totalExperience: null,\r\n skills: [],\r\n createdAt: null,\r\n createdOn: '-',\r\n sourceType: 'dice',\r\n profileSource: 'dice',\r\n };\r\n }\r\n\r\n const fullName = normalizeDiceName(diceCandidate);\r\n const nameParts = fullName.split(' ');\r\n const firstName = nameParts[0] || '';\r\n const lastName = nameParts.length > 1 ? nameParts[nameParts.length - 1] : '';\r\n \r\n const location = normalizeDiceLocation(diceCandidate);\r\n const experience = normalizeDiceExperience(diceCandidate);\r\n const createdOn = normalizeDiceDate(diceCandidate);\r\n const diceProfileId = resolveDiceProfileId(diceCandidate);\r\n const candidateId = diceCandidate.candidateId\r\n ?? diceCandidate.customFields?.diceProfileData?.candidateId\r\n ?? `dice-candidate-${index}`;\r\n \r\n // Extract skills from various possible fields\r\n const rawSkills = diceCandidate.skills ?? \r\n diceCandidate.technicalSkills ?? \r\n diceCandidate.primarySkills ??\r\n diceCandidate.keySkills ??\r\n [];\r\n \r\n const skills = normalizeDiceSkills(rawSkills);\r\n \r\n // Debug logging to verify transformation\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[DiceMapper] Original skills:', rawSkills);\r\n console.log('[DiceMapper] Mapped skills:', skills);\r\n console.log('[DiceMapper] Dice IDs:', {\r\n id: diceProfileId,\r\n diceId: diceProfileId,\r\n candidateId,\r\n });\r\n }\r\n\r\n return {\r\n // Preserve original Dice fields for reference\r\n ...diceCandidate,\r\n \r\n // Map to Internal candidate schema. Keep the Dice profile id as the primary id.\r\n id: diceProfileId,\r\n diceId: diceProfileId,\r\n candidateId,\r\n \r\n // Name fields\r\n firstName,\r\n lastName,\r\n middleName: diceCandidate.middleName || '',\r\n name: fullName || '-',\r\n fullName: fullName || '',\r\n \r\n // Professional info\r\n designation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '-',\r\n currentDesignation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '',\r\n jobTitle: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? '',\r\n \r\n // Location\r\n currentLocation: location || '',\r\n location: location || '',\r\n city: diceCandidate.city ?? diceCandidate.locations?.[0]?.city ?? '',\r\n region: diceCandidate.region ?? diceCandidate.locations?.[0]?.region ?? '',\r\n \r\n // Experience\r\n totalExperience: experience,\r\n experience: experience,\r\n yearsOfExperience: experience,\r\n exp: experience != null && experience !== '' ? `${experience} yrs` : '',\r\n \r\n // Skills\r\n skills,\r\n technicalSkills: skills,\r\n primarySkills: skills,\r\n \r\n // Dates\r\n createdAt: createdOn,\r\n createdOn: createdOn ? String(createdOn) : '-',\r\n updatedAt: createdOn,\r\n dateLastUpdated: createdOn,\r\n \r\n // Source identification\r\n sourceType: 'dice',\r\n profileSource: 'dice',\r\n selectedSource: ['dice'],\r\n \r\n // Additional fields with defaults\r\n email: diceCandidate.email ?? diceCandidate.emailAddress ?? '',\r\n phone: diceCandidate.phone ?? diceCandidate.phoneNumber ?? diceCandidate.mobile ?? '',\r\n summary: diceCandidate.summary ?? diceCandidate.bio ?? diceCandidate.description ?? '',\r\n resume: diceCandidate.resume ?? diceCandidate.resumeUrl ?? diceCandidate.cvUrl ?? '',\r\n \r\n // Status and metadata\r\n isActive: true,\r\n isDeleted: false,\r\n };\r\n}\r\n\r\n/**\r\n * Maps an array of Dice candidates to the Internal Candidate format\r\n * \r\n * @param {Array} diceCandidates - Array of raw Dice API candidate objects\r\n * @returns {Array} Array of mapped candidates in Internal format\r\n */\r\nexport function mapDiceCandidatesToInternal(diceCandidates) {\r\n if (!Array.isArray(diceCandidates)) {\r\n return [];\r\n }\r\n \r\n return diceCandidates.map((candidate, index) => \r\n mapDiceCandidateToInternal(candidate, index)\r\n );\r\n}\r\n\r\n/**\r\n * Transforms a Dice API response to match the existing Candidate List API response format\r\n * \r\n * @param {Object} diceResponse - Raw Dice API response\r\n * @param {Object} originalResponseStructure - The expected response structure from Internal API\r\n * @returns {Object} Transformed response matching Internal API format\r\n */\r\nexport function transformDiceResponseToInternalFormat(diceResponse, originalResponseStructure = {}) {\r\n if (!diceResponse || typeof diceResponse !== 'object') {\r\n return {\r\n status: 'success',\r\n data: {\r\n fields: [],\r\n actions: [],\r\n columnActions: [],\r\n count: 0,\r\n data: [],\r\n },\r\n };\r\n }\r\n\r\n // Extract candidates array from various possible response structures\r\n const diceCandidates = Array.isArray(diceResponse) \r\n ? diceResponse \r\n : diceResponse?.data?.data ?? \r\n diceResponse?.data?.applicant ?? \r\n diceResponse?.data?.candidates ?? \r\n diceResponse?.data?.items ?? \r\n diceResponse?.items ?? \r\n diceResponse?.candidates ?? \r\n diceResponse?.records ?? \r\n [];\r\n\r\n // Map Dice candidates to Internal format\r\n const mappedCandidates = mapDiceCandidatesToInternal(diceCandidates);\r\n\r\n // Extract count from various possible locations\r\n const count = (\r\n diceResponse?.data?.count?.searchCount ??\r\n diceResponse?.data?.count?.total ??\r\n diceResponse?.count?.searchCount ??\r\n diceResponse?.count?.total ??\r\n diceResponse?.total ??\r\n diceResponse?.totalCount ??\r\n mappedCandidates.length\r\n );\r\n\r\n // Preserve existing metadata from the original response structure\r\n return {\r\n status: diceResponse?.status ?? 'success',\r\n data: {\r\n // Preserve fields, actions, columnActions from original structure\r\n fields: originalResponseStructure?.fields ?? diceResponse?.data?.fields ?? diceResponse?.fields ?? [],\r\n actions: originalResponseStructure?.actions ?? diceResponse?.data?.actions ?? diceResponse?.actions ?? [],\r\n columnActions: originalResponseStructure?.columnActions ?? diceResponse?.data?.columnActions ?? diceResponse?.columnActions ?? [],\r\n \r\n // Count and mapped data\r\n count: Number(count) || 0,\r\n data: mappedCandidates,\r\n \r\n // Preserve any additional metadata\r\n ...(diceResponse?.data?.actionRules && { actionRules: diceResponse.data.actionRules }),\r\n ...(diceResponse?.data?.tabs && { tabs: diceResponse.data.tabs }),\r\n ...(diceResponse?.data?.tabField && { tabField: diceResponse.data.tabField }),\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Checks if a response contains Dice candidates\r\n * \r\n * @param {Array|Object} response - API response to check\r\n * @returns {boolean} True if response contains Dice candidates\r\n */\r\nexport function isDiceResponse(response) {\r\n if (!response) return false;\r\n \r\n const candidates = Array.isArray(response) \r\n ? response \r\n : response?.data?.data ?? \r\n response?.data?.applicant ?? \r\n response?.data?.candidates ?? \r\n response?.data?.items ?? \r\n response?.items ?? \r\n [];\r\n \r\n if (!Array.isArray(candidates) || candidates.length === 0) {\r\n return false;\r\n }\r\n \r\n // Check first few candidates for Dice source indicators\r\n const sampleSize = Math.min(candidates.length, 5);\r\n for (let i = 0; i < sampleSize; i++) {\r\n const candidate = candidates[i];\r\n const sourceType = candidate?.sourceType ?? candidate?.profileSource ?? '';\r\n if (String(sourceType).toLowerCase() === 'dice') {\r\n return true;\r\n }\r\n }\r\n \r\n return false;\r\n}\r\n\r\nexport default {\r\n mapDiceCandidateToInternal,\r\n mapDiceCandidatesToInternal,\r\n transformDiceResponseToInternalFormat,\r\n isDiceResponse,\r\n};\r\n"],"mappings":"+OAaA,SAAS,EAAkB,GAAG,EAAQ,CACpC,OAAO,EAAO,KAAM,GAAU,GAAiC,MAAQ,OAAO,CAAK,CAAC,CAAC,KAAK,IAAM,EAAE,CACpG,CAEA,SAAS,EAAa,EAAQ,EAAM,CAC9B,MAAC,GAAU,CAAC,GAEhB,OADI,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAI,EAAU,EAAO,GAC/D,OAAO,CAAI,CAAC,CAChB,MAAM,GAAG,CAAC,CACV,QAAQ,EAAO,IAAQ,IAAQ,GAAM,CAAM,CAChD,CAEA,SAAS,EAAyB,EAAO,CACvC,MAAO,kBAAkB,KAAK,OAAO,GAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAC1D,CAEA,SAAS,EAAsB,EAAO,CACpC,IAAM,EAAO,OAAO,GAAS,EAAE,CAAC,CAAC,KAAK,EACtC,MACE,kEAAkE,KAAK,CAAI,GACxE,mBAAmB,KAAK,CAAI,CAEnC,CAEA,SAAS,EAAwB,EAAO,EAAW,CACjD,IAAM,EAAO,OAAO,GAAS,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AAc,GAAW,eAAiB,GACxE,GAAI,OAAO,CAAU,CAAC,CAAC,YAAY,IAAM,OACvC,MAAO,EAEX,CAEA,MAAO,EACT"}
1
+ {"version":3,"file":"diceCandidateMapper-BjMhHno3.cjs","names":[],"sources":["../src/services/diceCandidateMapper.js"],"sourcesContent":["/**\n * Dice Candidate Response Mapper\n * \n * Transforms Dice API candidate responses into the existing Internal Candidate\n * List API format. This ensures the frontend receives an identical response\n * schema regardless of the data source.\n * \n * Reusable for additional external sources (Monster, CareerBuilder, LinkedIn, etc.)\n */\n\n/**\n * Normalizes skills from various Dice skill formats into a simple string array\n */\nfunction firstPresentValue(...values) {\n return values.find((value) => value !== undefined && value !== null && String(value).trim() !== '');\n}\n\nfunction getPathValue(record, path) {\n if (!record || !path) return undefined;\n if (Object.prototype.hasOwnProperty.call(record, path)) return record[path];\n return String(path)\n .split('.')\n .reduce((value, key) => value?.[key], record);\n}\n\nfunction isLikelyInternalRecordId(value) {\n return /^[a-f0-9]{24}$/i.test(String(value ?? '').trim());\n}\n\nfunction isLikelyDiceProfileId(value) {\n const text = String(value ?? '').trim();\n return (\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)\n || /^[a-f0-9]{40,}$/i.test(text)\n );\n}\n\nfunction isLikelyDiceCandidateId(value, candidate) {\n const text = String(value ?? '').trim();\n const knownCandidateId = firstPresentValue(\n candidate?.candidateId,\n candidate?.customFields?.diceProfileData?.candidateId,\n );\n\n return (\n (knownCandidateId && text === String(knownCandidateId).trim())\n || /^[a-f0-9]{40,}-\\d+$/i.test(text)\n );\n}\n\nfunction findLikelyDiceProfileId(record) {\n const seen = new Set();\n const candidates = [];\n\n const visit = (value, path = '') => {\n if (value === null || value === undefined) return;\n if (typeof value === 'string' || typeof value === 'number') {\n const text = String(value).trim();\n const keyLooksRelevant = /(^|[._-])(dice|profile|source|external).*(id|guid|uuid)$|(^|[._-])(id|guid|uuid)$/i.test(path);\n if (text && keyLooksRelevant && isLikelyDiceProfileId(text)) {\n candidates.push({ path, value: text });\n }\n return;\n }\n if (typeof value !== 'object' || seen.has(value)) return;\n seen.add(value);\n Object.entries(value).forEach(([key, child]) => {\n visit(child, path ? `${path}.${key}` : key);\n });\n };\n\n visit(record);\n\n return candidates.find((candidate) => /dice|profile|source|external/i.test(candidate.path))?.value\n ?? candidates[0]?.value\n ?? '';\n}\n\nexport function resolveDiceProfileId(candidate) {\n if (!candidate || typeof candidate !== 'object') return '';\n\n // Check if this is a Dice candidate\n const isDiceCandidate = (() => {\n const source = candidate?.sourceType\n ?? candidate?.profileSource\n ?? candidate?.selectedSource;\n const normalizedSources = Array.isArray(source) ? source : [source];\n return normalizedSources.some(\n (value) => String(value ?? '').trim().toLowerCase() === 'dice',\n );\n })();\n\n const explicitPaths = [\n 'diceId',\n 'diceID',\n 'dice_id',\n 'diceProfileId',\n 'diceProfileID',\n 'diceProfileGuid',\n 'profileId',\n 'profileID',\n 'profileGuid',\n 'sourceId',\n 'sourceProfileId',\n 'externalId',\n 'externalProfileId',\n 'customFields.diceId',\n 'customFields.diceProfileId',\n 'customFields.profileId',\n 'customFields.externalProfileId',\n 'customFields.diceProfileData.diceId',\n 'customFields.diceProfileData.diceID',\n 'customFields.diceProfileData.id',\n 'customFields.diceProfileData._id',\n 'customFields.diceProfileData.profileId',\n 'customFields.diceProfileData.profileID',\n 'customFields.diceProfileData.diceProfileId',\n 'customFields.diceProfileData.diceProfileID',\n 'customFields.diceProfileData.guid',\n 'customFields.diceProfileData.uuid',\n 'customFields.diceProfileData.externalId',\n 'customFields.diceProfileData.candidateid',\n 'customFields.diceProfileData.candidateId',\n ];\n\n const explicitDiceId = firstPresentValue(\n ...explicitPaths.map((path) => getPathValue(candidate, path)),\n );\n\n if (explicitDiceId && !isLikelyDiceCandidateId(explicitDiceId, candidate)) {\n return String(explicitDiceId);\n }\n\n const likelyNestedId = findLikelyDiceProfileId(candidate);\n if (likelyNestedId) return likelyNestedId;\n\n const genericId = firstPresentValue(candidate.id, candidate._id);\n \n // For Dice candidates, accept the ID even if it looks like an internal MongoDB ObjectId\n // For non-Dice candidates, reject IDs that look like internal record IDs\n if (genericId && (isDiceCandidate || !isLikelyInternalRecordId(genericId))) {\n return String(genericId);\n }\n \n return '';\n}\n\nexport function normalizeDiceSkills(skills) {\n if (!skills) return [];\n \n if (Array.isArray(skills)) {\n return skills\n .map(skill => {\n // Handle Dice format: {skill: \"courts\", lastUsed: 2026}\n if (skill?.skill) return skill.skill;\n // Handle other object formats\n if (typeof skill === 'object' && skill !== null) {\n if (skill?.name) return skill.name;\n if (skill?.skillName) return skill.skillName;\n if (skill?.value) return skill.value;\n }\n // Handle string skills\n if (typeof skill === 'string') return skill;\n return null;\n })\n .filter(Boolean);\n }\n \n if (typeof skills === 'string') {\n return skills.split(',').map(s => s.trim()).filter(Boolean);\n }\n \n return [];\n}\n\n/**\n * Normalizes location from various Dice location formats\n */\nfunction normalizeDiceLocation(candidate) {\n // Try locations array first (common in Dice)\n if (Array.isArray(candidate.locations) && candidate.locations.length > 0) {\n const loc = candidate.locations[0];\n if (typeof loc === 'string') return loc;\n if (loc?.region) return loc.region;\n if (loc?.city) return loc.city;\n if (loc?.name) return loc.name;\n if (loc?.location) return loc.location;\n }\n \n // Try direct location fields\n return (\n candidate.currentLocation ??\n candidate.location ??\n candidate.city ??\n candidate.region ??\n ''\n );\n}\n\n/**\n * Normalizes experience from various Dice experience formats\n */\nfunction normalizeDiceExperience(candidate) {\n const exp = (\n candidate.totalExperience ??\n candidate.experience ??\n candidate.yearsOfExperience ??\n candidate.exp ??\n candidate.totalYearsOfExperience ??\n candidate.workExperienceYears\n );\n \n return exp != null && exp !== '' ? exp : null;\n}\n\n/**\n * Normalizes date from various Dice date formats\n */\nfunction normalizeDiceDate(candidate) {\n return (\n candidate.dateLastUpdated ??\n candidate.updatedAt ??\n candidate.createdAt ??\n candidate.createdDate ??\n candidate.dateCreated ??\n null\n );\n}\n\n/**\n * Normalizes name from various Dice name formats\n */\nfunction normalizeDiceName(candidate) {\n const parts = [\n candidate.firstName,\n candidate.middleName,\n candidate.lastName,\n ].filter(Boolean);\n \n if (parts.length > 0) return parts.join(' ');\n \n return (\n candidate.fullName ??\n candidate.name ??\n candidate.candidateName ??\n ''\n );\n}\n\n/**\n * Maps a single Dice candidate to the Internal Candidate format\n * \n * @param {Object} diceCandidate - Raw Dice API candidate object\n * @param {number} index - Index for fallback ID generation\n * @returns {Object} Mapped candidate in Internal format\n */\nexport function mapDiceCandidateToInternal(diceCandidate, index = 0) {\n if (!diceCandidate || typeof diceCandidate !== 'object') {\n return {\n id: `dice-candidate-${index}`,\n diceId: '',\n candidateId: '',\n firstName: '',\n lastName: '',\n name: '-',\n designation: '-',\n currentLocation: '',\n location: '',\n exp: '',\n totalExperience: null,\n skills: [],\n createdAt: null,\n createdOn: '-',\n sourceType: 'dice',\n profileSource: 'dice',\n };\n }\n\n const fullName = normalizeDiceName(diceCandidate);\n const nameParts = fullName.split(' ');\n const firstName = nameParts[0] || '';\n const lastName = nameParts.length > 1 ? nameParts[nameParts.length - 1] : '';\n \n const location = normalizeDiceLocation(diceCandidate);\n const experience = normalizeDiceExperience(diceCandidate);\n const createdOn = normalizeDiceDate(diceCandidate);\n const diceProfileId = resolveDiceProfileId(diceCandidate);\n const candidateId = diceCandidate.candidateId\n ?? diceCandidate.customFields?.diceProfileData?.candidateId\n ?? `dice-candidate-${index}`;\n \n // Extract skills from various possible fields\n const rawSkills = diceCandidate.skills ?? \n diceCandidate.technicalSkills ?? \n diceCandidate.primarySkills ??\n diceCandidate.keySkills ??\n [];\n \n const skills = normalizeDiceSkills(rawSkills);\n \n // Debug logging to verify transformation\n if (process.env.NODE_ENV === 'development') {\n console.log('[DiceMapper] Original skills:', rawSkills);\n console.log('[DiceMapper] Mapped skills:', skills);\n console.log('[DiceMapper] Dice IDs:', {\n id: diceProfileId,\n diceId: diceProfileId,\n candidateId,\n });\n }\n\n return {\n // Preserve original Dice fields for reference\n ...diceCandidate,\n \n // Map to Internal candidate schema. Keep the Dice profile id as the primary id.\n id: diceProfileId,\n diceId: diceProfileId,\n candidateId,\n \n // Name fields\n firstName,\n lastName,\n middleName: diceCandidate.middleName || '',\n name: fullName || '-',\n fullName: fullName || '',\n \n // Professional info\n designation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '-',\n currentDesignation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '',\n jobTitle: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? '',\n \n // Location\n currentLocation: location || '',\n location: location || '',\n city: diceCandidate.city ?? diceCandidate.locations?.[0]?.city ?? '',\n region: diceCandidate.region ?? diceCandidate.locations?.[0]?.region ?? '',\n \n // Experience\n totalExperience: experience,\n experience: experience,\n yearsOfExperience: experience,\n exp: experience != null && experience !== '' ? `${experience} yrs` : '',\n \n // Skills\n skills,\n technicalSkills: skills,\n primarySkills: skills,\n \n // Dates\n createdAt: createdOn,\n createdOn: createdOn ? String(createdOn) : '-',\n updatedAt: createdOn,\n dateLastUpdated: createdOn,\n \n // Source identification\n sourceType: 'dice',\n profileSource: 'dice',\n selectedSource: ['dice'],\n \n // Additional fields with defaults\n email: diceCandidate.email ?? diceCandidate.emailAddress ?? '',\n phone: diceCandidate.phone ?? diceCandidate.phoneNumber ?? diceCandidate.mobile ?? '',\n summary: diceCandidate.summary ?? diceCandidate.bio ?? diceCandidate.description ?? '',\n resume: diceCandidate.resume ?? diceCandidate.resumeUrl ?? diceCandidate.cvUrl ?? '',\n \n // Status and metadata\n isActive: true,\n isDeleted: false,\n };\n}\n\n/**\n * Maps an array of Dice candidates to the Internal Candidate format\n * \n * @param {Array} diceCandidates - Array of raw Dice API candidate objects\n * @returns {Array} Array of mapped candidates in Internal format\n */\nexport function mapDiceCandidatesToInternal(diceCandidates) {\n if (!Array.isArray(diceCandidates)) {\n return [];\n }\n \n return diceCandidates.map((candidate, index) => \n mapDiceCandidateToInternal(candidate, index)\n );\n}\n\n/**\n * Transforms a Dice API response to match the existing Candidate List API response format\n * \n * @param {Object} diceResponse - Raw Dice API response\n * @param {Object} originalResponseStructure - The expected response structure from Internal API\n * @returns {Object} Transformed response matching Internal API format\n */\nexport function transformDiceResponseToInternalFormat(diceResponse, originalResponseStructure = {}) {\n if (!diceResponse || typeof diceResponse !== 'object') {\n return {\n status: 'success',\n data: {\n fields: [],\n actions: [],\n columnActions: [],\n count: 0,\n data: [],\n },\n };\n }\n\n // Extract candidates array from various possible response structures\n const diceCandidates = Array.isArray(diceResponse) \n ? diceResponse \n : diceResponse?.data?.data ?? \n diceResponse?.data?.applicant ?? \n diceResponse?.data?.candidates ?? \n diceResponse?.data?.items ?? \n diceResponse?.items ?? \n diceResponse?.candidates ?? \n diceResponse?.records ?? \n [];\n\n // Map Dice candidates to Internal format\n const mappedCandidates = mapDiceCandidatesToInternal(diceCandidates);\n\n // Extract count from various possible locations\n const count = (\n diceResponse?.data?.count?.searchCount ??\n diceResponse?.data?.count?.total ??\n diceResponse?.count?.searchCount ??\n diceResponse?.count?.total ??\n diceResponse?.total ??\n diceResponse?.totalCount ??\n mappedCandidates.length\n );\n\n // Preserve existing metadata from the original response structure\n return {\n status: diceResponse?.status ?? 'success',\n data: {\n // Preserve fields, actions, columnActions from original structure\n fields: originalResponseStructure?.fields ?? diceResponse?.data?.fields ?? diceResponse?.fields ?? [],\n actions: originalResponseStructure?.actions ?? diceResponse?.data?.actions ?? diceResponse?.actions ?? [],\n columnActions: originalResponseStructure?.columnActions ?? diceResponse?.data?.columnActions ?? diceResponse?.columnActions ?? [],\n \n // Count and mapped data\n count: Number(count) || 0,\n data: mappedCandidates,\n \n // Preserve any additional metadata\n ...(diceResponse?.data?.actionRules && { actionRules: diceResponse.data.actionRules }),\n ...(diceResponse?.data?.tabs && { tabs: diceResponse.data.tabs }),\n ...(diceResponse?.data?.tabField && { tabField: diceResponse.data.tabField }),\n },\n };\n}\n\n/**\n * Checks if a response contains Dice candidates\n * \n * @param {Array|Object} response - API response to check\n * @returns {boolean} True if response contains Dice candidates\n */\nexport function isDiceResponse(response) {\n if (!response) return false;\n \n const candidates = Array.isArray(response) \n ? response \n : response?.data?.data ?? \n response?.data?.applicant ?? \n response?.data?.candidates ?? \n response?.data?.items ?? \n response?.items ?? \n [];\n \n if (!Array.isArray(candidates) || candidates.length === 0) {\n return false;\n }\n \n // Check first few candidates for Dice source indicators\n const sampleSize = Math.min(candidates.length, 5);\n for (let i = 0; i < sampleSize; i++) {\n const candidate = candidates[i];\n const sourceType = candidate?.sourceType ?? candidate?.profileSource ?? '';\n if (String(sourceType).toLowerCase() === 'dice') {\n return true;\n }\n }\n \n return false;\n}\n\nexport default {\n mapDiceCandidateToInternal,\n mapDiceCandidatesToInternal,\n transformDiceResponseToInternalFormat,\n isDiceResponse,\n};\n"],"mappings":"+OAaA,SAAS,EAAkB,GAAG,EAAQ,CACpC,OAAO,EAAO,KAAM,GAAU,GAAiC,MAAQ,OAAO,CAAK,CAAC,CAAC,KAAK,IAAM,EAAE,CACpG,CAEA,SAAS,EAAa,EAAQ,EAAM,CAC9B,MAAC,GAAU,CAAC,GAEhB,OADI,OAAO,UAAU,eAAe,KAAK,EAAQ,CAAI,EAAU,EAAO,GAC/D,OAAO,CAAI,CAAC,CAChB,MAAM,GAAG,CAAC,CACV,QAAQ,EAAO,IAAQ,IAAQ,GAAM,CAAM,CAChD,CAEA,SAAS,EAAyB,EAAO,CACvC,MAAO,kBAAkB,KAAK,OAAO,GAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAC1D,CAEA,SAAS,EAAsB,EAAO,CACpC,IAAM,EAAO,OAAO,GAAS,EAAE,CAAC,CAAC,KAAK,EACtC,MACE,kEAAkE,KAAK,CAAI,GACxE,mBAAmB,KAAK,CAAI,CAEnC,CAEA,SAAS,EAAwB,EAAO,EAAW,CACjD,IAAM,EAAO,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AAa,GAAW,YAAc,GAAW,eAAiB,GACxE,GAAI,OAAO,CAAU,CAAC,CAAC,YAAY,IAAM,OACvC,MAAO,EAEX,CAEA,MAAO,EACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"diceCandidateMapper-DqBO4EhL.js","names":[],"sources":["../src/services/diceCandidateMapper.js"],"sourcesContent":["/**\r\n * Dice Candidate Response Mapper\r\n * \r\n * Transforms Dice API candidate responses into the existing Internal Candidate\r\n * List API format. This ensures the frontend receives an identical response\r\n * schema regardless of the data source.\r\n * \r\n * Reusable for additional external sources (Monster, CareerBuilder, LinkedIn, etc.)\r\n */\r\n\r\n/**\r\n * Normalizes skills from various Dice skill formats into a simple string array\r\n */\r\nfunction firstPresentValue(...values) {\r\n return values.find((value) => value !== undefined && value !== null && String(value).trim() !== '');\r\n}\r\n\r\nfunction getPathValue(record, path) {\r\n if (!record || !path) return undefined;\r\n if (Object.prototype.hasOwnProperty.call(record, path)) return record[path];\r\n return String(path)\r\n .split('.')\r\n .reduce((value, key) => value?.[key], record);\r\n}\r\n\r\nfunction isLikelyInternalRecordId(value) {\r\n return /^[a-f0-9]{24}$/i.test(String(value ?? '').trim());\r\n}\r\n\r\nfunction isLikelyDiceProfileId(value) {\r\n const text = String(value ?? '').trim();\r\n return (\r\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)\r\n || /^[a-f0-9]{40,}$/i.test(text)\r\n );\r\n}\r\n\r\nfunction isLikelyDiceCandidateId(value, candidate) {\r\n const text = String(value ?? '').trim();\r\n const knownCandidateId = firstPresentValue(\r\n candidate?.candidateId,\r\n candidate?.customFields?.diceProfileData?.candidateId,\r\n );\r\n\r\n return (\r\n (knownCandidateId && text === String(knownCandidateId).trim())\r\n || /^[a-f0-9]{40,}-\\d+$/i.test(text)\r\n );\r\n}\r\n\r\nfunction findLikelyDiceProfileId(record) {\r\n const seen = new Set();\r\n const candidates = [];\r\n\r\n const visit = (value, path = '') => {\r\n if (value === null || value === undefined) return;\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n const text = String(value).trim();\r\n const keyLooksRelevant = /(^|[._-])(dice|profile|source|external).*(id|guid|uuid)$|(^|[._-])(id|guid|uuid)$/i.test(path);\r\n if (text && keyLooksRelevant && isLikelyDiceProfileId(text)) {\r\n candidates.push({ path, value: text });\r\n }\r\n return;\r\n }\r\n if (typeof value !== 'object' || seen.has(value)) return;\r\n seen.add(value);\r\n Object.entries(value).forEach(([key, child]) => {\r\n visit(child, path ? `${path}.${key}` : key);\r\n });\r\n };\r\n\r\n visit(record);\r\n\r\n return candidates.find((candidate) => /dice|profile|source|external/i.test(candidate.path))?.value\r\n ?? candidates[0]?.value\r\n ?? '';\r\n}\r\n\r\nexport function resolveDiceProfileId(candidate) {\r\n if (!candidate || typeof candidate !== 'object') return '';\r\n\r\n // Check if this is a Dice candidate\r\n const isDiceCandidate = (() => {\r\n const source = candidate?.sourceType\r\n ?? candidate?.profileSource\r\n ?? candidate?.selectedSource;\r\n const normalizedSources = Array.isArray(source) ? source : [source];\r\n return normalizedSources.some(\r\n (value) => String(value ?? '').trim().toLowerCase() === 'dice',\r\n );\r\n })();\r\n\r\n const explicitPaths = [\r\n 'diceId',\r\n 'diceID',\r\n 'dice_id',\r\n 'diceProfileId',\r\n 'diceProfileID',\r\n 'diceProfileGuid',\r\n 'profileId',\r\n 'profileID',\r\n 'profileGuid',\r\n 'sourceId',\r\n 'sourceProfileId',\r\n 'externalId',\r\n 'externalProfileId',\r\n 'customFields.diceId',\r\n 'customFields.diceProfileId',\r\n 'customFields.profileId',\r\n 'customFields.externalProfileId',\r\n 'customFields.diceProfileData.diceId',\r\n 'customFields.diceProfileData.diceID',\r\n 'customFields.diceProfileData.id',\r\n 'customFields.diceProfileData._id',\r\n 'customFields.diceProfileData.profileId',\r\n 'customFields.diceProfileData.profileID',\r\n 'customFields.diceProfileData.diceProfileId',\r\n 'customFields.diceProfileData.diceProfileID',\r\n 'customFields.diceProfileData.guid',\r\n 'customFields.diceProfileData.uuid',\r\n 'customFields.diceProfileData.externalId',\r\n 'customFields.diceProfileData.candidateid',\r\n 'customFields.diceProfileData.candidateId',\r\n ];\r\n\r\n const explicitDiceId = firstPresentValue(\r\n ...explicitPaths.map((path) => getPathValue(candidate, path)),\r\n );\r\n\r\n if (explicitDiceId && !isLikelyDiceCandidateId(explicitDiceId, candidate)) {\r\n return String(explicitDiceId);\r\n }\r\n\r\n const likelyNestedId = findLikelyDiceProfileId(candidate);\r\n if (likelyNestedId) return likelyNestedId;\r\n\r\n const genericId = firstPresentValue(candidate.id, candidate._id);\r\n \r\n // For Dice candidates, accept the ID even if it looks like an internal MongoDB ObjectId\r\n // For non-Dice candidates, reject IDs that look like internal record IDs\r\n if (genericId && (isDiceCandidate || !isLikelyInternalRecordId(genericId))) {\r\n return String(genericId);\r\n }\r\n \r\n return '';\r\n}\r\n\r\nexport function normalizeDiceSkills(skills) {\r\n if (!skills) return [];\r\n \r\n if (Array.isArray(skills)) {\r\n return skills\r\n .map(skill => {\r\n // Handle Dice format: {skill: \"courts\", lastUsed: 2026}\r\n if (skill?.skill) return skill.skill;\r\n // Handle other object formats\r\n if (typeof skill === 'object' && skill !== null) {\r\n if (skill?.name) return skill.name;\r\n if (skill?.skillName) return skill.skillName;\r\n if (skill?.value) return skill.value;\r\n }\r\n // Handle string skills\r\n if (typeof skill === 'string') return skill;\r\n return null;\r\n })\r\n .filter(Boolean);\r\n }\r\n \r\n if (typeof skills === 'string') {\r\n return skills.split(',').map(s => s.trim()).filter(Boolean);\r\n }\r\n \r\n return [];\r\n}\r\n\r\n/**\r\n * Normalizes location from various Dice location formats\r\n */\r\nfunction normalizeDiceLocation(candidate) {\r\n // Try locations array first (common in Dice)\r\n if (Array.isArray(candidate.locations) && candidate.locations.length > 0) {\r\n const loc = candidate.locations[0];\r\n if (typeof loc === 'string') return loc;\r\n if (loc?.region) return loc.region;\r\n if (loc?.city) return loc.city;\r\n if (loc?.name) return loc.name;\r\n if (loc?.location) return loc.location;\r\n }\r\n \r\n // Try direct location fields\r\n return (\r\n candidate.currentLocation ??\r\n candidate.location ??\r\n candidate.city ??\r\n candidate.region ??\r\n ''\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes experience from various Dice experience formats\r\n */\r\nfunction normalizeDiceExperience(candidate) {\r\n const exp = (\r\n candidate.totalExperience ??\r\n candidate.experience ??\r\n candidate.yearsOfExperience ??\r\n candidate.exp ??\r\n candidate.totalYearsOfExperience ??\r\n candidate.workExperienceYears\r\n );\r\n \r\n return exp != null && exp !== '' ? exp : null;\r\n}\r\n\r\n/**\r\n * Normalizes date from various Dice date formats\r\n */\r\nfunction normalizeDiceDate(candidate) {\r\n return (\r\n candidate.dateLastUpdated ??\r\n candidate.updatedAt ??\r\n candidate.createdAt ??\r\n candidate.createdDate ??\r\n candidate.dateCreated ??\r\n null\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes name from various Dice name formats\r\n */\r\nfunction normalizeDiceName(candidate) {\r\n const parts = [\r\n candidate.firstName,\r\n candidate.middleName,\r\n candidate.lastName,\r\n ].filter(Boolean);\r\n \r\n if (parts.length > 0) return parts.join(' ');\r\n \r\n return (\r\n candidate.fullName ??\r\n candidate.name ??\r\n candidate.candidateName ??\r\n ''\r\n );\r\n}\r\n\r\n/**\r\n * Maps a single Dice candidate to the Internal Candidate format\r\n * \r\n * @param {Object} diceCandidate - Raw Dice API candidate object\r\n * @param {number} index - Index for fallback ID generation\r\n * @returns {Object} Mapped candidate in Internal format\r\n */\r\nexport function mapDiceCandidateToInternal(diceCandidate, index = 0) {\r\n if (!diceCandidate || typeof diceCandidate !== 'object') {\r\n return {\r\n id: `dice-candidate-${index}`,\r\n diceId: '',\r\n candidateId: '',\r\n firstName: '',\r\n lastName: '',\r\n name: '-',\r\n designation: '-',\r\n currentLocation: '',\r\n location: '',\r\n exp: '',\r\n totalExperience: null,\r\n skills: [],\r\n createdAt: null,\r\n createdOn: '-',\r\n sourceType: 'dice',\r\n profileSource: 'dice',\r\n };\r\n }\r\n\r\n const fullName = normalizeDiceName(diceCandidate);\r\n const nameParts = fullName.split(' ');\r\n const firstName = nameParts[0] || '';\r\n const lastName = nameParts.length > 1 ? nameParts[nameParts.length - 1] : '';\r\n \r\n const location = normalizeDiceLocation(diceCandidate);\r\n const experience = normalizeDiceExperience(diceCandidate);\r\n const createdOn = normalizeDiceDate(diceCandidate);\r\n const diceProfileId = resolveDiceProfileId(diceCandidate);\r\n const candidateId = diceCandidate.candidateId\r\n ?? diceCandidate.customFields?.diceProfileData?.candidateId\r\n ?? `dice-candidate-${index}`;\r\n \r\n // Extract skills from various possible fields\r\n const rawSkills = diceCandidate.skills ?? \r\n diceCandidate.technicalSkills ?? \r\n diceCandidate.primarySkills ??\r\n diceCandidate.keySkills ??\r\n [];\r\n \r\n const skills = normalizeDiceSkills(rawSkills);\r\n \r\n // Debug logging to verify transformation\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('[DiceMapper] Original skills:', rawSkills);\r\n console.log('[DiceMapper] Mapped skills:', skills);\r\n console.log('[DiceMapper] Dice IDs:', {\r\n id: diceProfileId,\r\n diceId: diceProfileId,\r\n candidateId,\r\n });\r\n }\r\n\r\n return {\r\n // Preserve original Dice fields for reference\r\n ...diceCandidate,\r\n \r\n // Map to Internal candidate schema. Keep the Dice profile id as the primary id.\r\n id: diceProfileId,\r\n diceId: diceProfileId,\r\n candidateId,\r\n \r\n // Name fields\r\n firstName,\r\n lastName,\r\n middleName: diceCandidate.middleName || '',\r\n name: fullName || '-',\r\n fullName: fullName || '',\r\n \r\n // Professional info\r\n designation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '-',\r\n currentDesignation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '',\r\n jobTitle: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? '',\r\n \r\n // Location\r\n currentLocation: location || '',\r\n location: location || '',\r\n city: diceCandidate.city ?? diceCandidate.locations?.[0]?.city ?? '',\r\n region: diceCandidate.region ?? diceCandidate.locations?.[0]?.region ?? '',\r\n \r\n // Experience\r\n totalExperience: experience,\r\n experience: experience,\r\n yearsOfExperience: experience,\r\n exp: experience != null && experience !== '' ? `${experience} yrs` : '',\r\n \r\n // Skills\r\n skills,\r\n technicalSkills: skills,\r\n primarySkills: skills,\r\n \r\n // Dates\r\n createdAt: createdOn,\r\n createdOn: createdOn ? String(createdOn) : '-',\r\n updatedAt: createdOn,\r\n dateLastUpdated: createdOn,\r\n \r\n // Source identification\r\n sourceType: 'dice',\r\n profileSource: 'dice',\r\n selectedSource: ['dice'],\r\n \r\n // Additional fields with defaults\r\n email: diceCandidate.email ?? diceCandidate.emailAddress ?? '',\r\n phone: diceCandidate.phone ?? diceCandidate.phoneNumber ?? diceCandidate.mobile ?? '',\r\n summary: diceCandidate.summary ?? diceCandidate.bio ?? diceCandidate.description ?? '',\r\n resume: diceCandidate.resume ?? diceCandidate.resumeUrl ?? diceCandidate.cvUrl ?? '',\r\n \r\n // Status and metadata\r\n isActive: true,\r\n isDeleted: false,\r\n };\r\n}\r\n\r\n/**\r\n * Maps an array of Dice candidates to the Internal Candidate format\r\n * \r\n * @param {Array} diceCandidates - Array of raw Dice API candidate objects\r\n * @returns {Array} Array of mapped candidates in Internal format\r\n */\r\nexport function mapDiceCandidatesToInternal(diceCandidates) {\r\n if (!Array.isArray(diceCandidates)) {\r\n return [];\r\n }\r\n \r\n return diceCandidates.map((candidate, index) => \r\n mapDiceCandidateToInternal(candidate, index)\r\n );\r\n}\r\n\r\n/**\r\n * Transforms a Dice API response to match the existing Candidate List API response format\r\n * \r\n * @param {Object} diceResponse - Raw Dice API response\r\n * @param {Object} originalResponseStructure - The expected response structure from Internal API\r\n * @returns {Object} Transformed response matching Internal API format\r\n */\r\nexport function transformDiceResponseToInternalFormat(diceResponse, originalResponseStructure = {}) {\r\n if (!diceResponse || typeof diceResponse !== 'object') {\r\n return {\r\n status: 'success',\r\n data: {\r\n fields: [],\r\n actions: [],\r\n columnActions: [],\r\n count: 0,\r\n data: [],\r\n },\r\n };\r\n }\r\n\r\n // Extract candidates array from various possible response structures\r\n const diceCandidates = Array.isArray(diceResponse) \r\n ? diceResponse \r\n : diceResponse?.data?.data ?? \r\n diceResponse?.data?.applicant ?? \r\n diceResponse?.data?.candidates ?? \r\n diceResponse?.data?.items ?? \r\n diceResponse?.items ?? \r\n diceResponse?.candidates ?? \r\n diceResponse?.records ?? \r\n [];\r\n\r\n // Map Dice candidates to Internal format\r\n const mappedCandidates = mapDiceCandidatesToInternal(diceCandidates);\r\n\r\n // Extract count from various possible locations\r\n const count = (\r\n diceResponse?.data?.count?.searchCount ??\r\n diceResponse?.data?.count?.total ??\r\n diceResponse?.count?.searchCount ??\r\n diceResponse?.count?.total ??\r\n diceResponse?.total ??\r\n diceResponse?.totalCount ??\r\n mappedCandidates.length\r\n );\r\n\r\n // Preserve existing metadata from the original response structure\r\n return {\r\n status: diceResponse?.status ?? 'success',\r\n data: {\r\n // Preserve fields, actions, columnActions from original structure\r\n fields: originalResponseStructure?.fields ?? diceResponse?.data?.fields ?? diceResponse?.fields ?? [],\r\n actions: originalResponseStructure?.actions ?? diceResponse?.data?.actions ?? diceResponse?.actions ?? [],\r\n columnActions: originalResponseStructure?.columnActions ?? diceResponse?.data?.columnActions ?? diceResponse?.columnActions ?? [],\r\n \r\n // Count and mapped data\r\n count: Number(count) || 0,\r\n data: mappedCandidates,\r\n \r\n // Preserve any additional metadata\r\n ...(diceResponse?.data?.actionRules && { actionRules: diceResponse.data.actionRules }),\r\n ...(diceResponse?.data?.tabs && { tabs: diceResponse.data.tabs }),\r\n ...(diceResponse?.data?.tabField && { tabField: diceResponse.data.tabField }),\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Checks if a response contains Dice candidates\r\n * \r\n * @param {Array|Object} response - API response to check\r\n * @returns {boolean} True if response contains Dice candidates\r\n */\r\nexport function isDiceResponse(response) {\r\n if (!response) return false;\r\n \r\n const candidates = Array.isArray(response) \r\n ? response \r\n : response?.data?.data ?? \r\n response?.data?.applicant ?? \r\n response?.data?.candidates ?? \r\n response?.data?.items ?? \r\n response?.items ?? \r\n [];\r\n \r\n if (!Array.isArray(candidates) || candidates.length === 0) {\r\n return false;\r\n }\r\n \r\n // Check first few candidates for Dice source indicators\r\n const sampleSize = Math.min(candidates.length, 5);\r\n for (let i = 0; i < sampleSize; i++) {\r\n const candidate = candidates[i];\r\n const sourceType = candidate?.sourceType ?? candidate?.profileSource ?? '';\r\n if (String(sourceType).toLowerCase() === 'dice') {\r\n return true;\r\n }\r\n }\r\n \r\n return false;\r\n}\r\n\r\nexport default {\r\n mapDiceCandidateToInternal,\r\n mapDiceCandidatesToInternal,\r\n transformDiceResponseToInternalFormat,\r\n isDiceResponse,\r\n};\r\n"],"mappings":";;;;;;;;;;AAaA,SAAS,EAAkB,GAAG,GAAQ;CACpC,OAAO,EAAO,MAAM,MAAU,KAAiC,QAAQ,OAAO,CAAK,CAAC,CAAC,KAAK,MAAM,EAAE;AACpG;AAEA,SAAS,EAAa,GAAQ,GAAM;CAC9B,OAAC,KAAU,CAAC,IAEhB,OADI,OAAO,UAAU,eAAe,KAAK,GAAQ,CAAI,IAAU,EAAO,KAC/D,OAAO,CAAI,CAAC,CAChB,MAAM,GAAG,CAAC,CACV,QAAQ,GAAO,MAAQ,IAAQ,IAAM,CAAM;AAChD;AAEA,SAAS,EAAyB,GAAO;CACvC,OAAO,kBAAkB,KAAK,OAAO,KAAS,EAAE,CAAC,CAAC,KAAK,CAAC;AAC1D;AAEA,SAAS,EAAsB,GAAO;CACpC,IAAM,IAAO,OAAO,KAAS,EAAE,CAAC,CAAC,KAAK;CACtC,OACE,kEAAkE,KAAK,CAAI,KACxE,mBAAmB,KAAK,CAAI;AAEnC;AAEA,SAAS,EAAwB,GAAO,GAAW;CACjD,IAAM,IAAO,OA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IAAY,EAAW,IACvB,IAAa,GAAW,cAAc,GAAW,iBAAiB;EACxE,IAAI,OAAO,CAAU,CAAC,CAAC,YAAY,MAAM,QACvC,OAAO;CAEX;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"diceCandidateMapper-DqBO4EhL.js","names":[],"sources":["../src/services/diceCandidateMapper.js"],"sourcesContent":["/**\n * Dice Candidate Response Mapper\n * \n * Transforms Dice API candidate responses into the existing Internal Candidate\n * List API format. This ensures the frontend receives an identical response\n * schema regardless of the data source.\n * \n * Reusable for additional external sources (Monster, CareerBuilder, LinkedIn, etc.)\n */\n\n/**\n * Normalizes skills from various Dice skill formats into a simple string array\n */\nfunction firstPresentValue(...values) {\n return values.find((value) => value !== undefined && value !== null && String(value).trim() !== '');\n}\n\nfunction getPathValue(record, path) {\n if (!record || !path) return undefined;\n if (Object.prototype.hasOwnProperty.call(record, path)) return record[path];\n return String(path)\n .split('.')\n .reduce((value, key) => value?.[key], record);\n}\n\nfunction isLikelyInternalRecordId(value) {\n return /^[a-f0-9]{24}$/i.test(String(value ?? '').trim());\n}\n\nfunction isLikelyDiceProfileId(value) {\n const text = String(value ?? '').trim();\n return (\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)\n || /^[a-f0-9]{40,}$/i.test(text)\n );\n}\n\nfunction isLikelyDiceCandidateId(value, candidate) {\n const text = String(value ?? '').trim();\n const knownCandidateId = firstPresentValue(\n candidate?.candidateId,\n candidate?.customFields?.diceProfileData?.candidateId,\n );\n\n return (\n (knownCandidateId && text === String(knownCandidateId).trim())\n || /^[a-f0-9]{40,}-\\d+$/i.test(text)\n );\n}\n\nfunction findLikelyDiceProfileId(record) {\n const seen = new Set();\n const candidates = [];\n\n const visit = (value, path = '') => {\n if (value === null || value === undefined) return;\n if (typeof value === 'string' || typeof value === 'number') {\n const text = String(value).trim();\n const keyLooksRelevant = /(^|[._-])(dice|profile|source|external).*(id|guid|uuid)$|(^|[._-])(id|guid|uuid)$/i.test(path);\n if (text && keyLooksRelevant && isLikelyDiceProfileId(text)) {\n candidates.push({ path, value: text });\n }\n return;\n }\n if (typeof value !== 'object' || seen.has(value)) return;\n seen.add(value);\n Object.entries(value).forEach(([key, child]) => {\n visit(child, path ? `${path}.${key}` : key);\n });\n };\n\n visit(record);\n\n return candidates.find((candidate) => /dice|profile|source|external/i.test(candidate.path))?.value\n ?? candidates[0]?.value\n ?? '';\n}\n\nexport function resolveDiceProfileId(candidate) {\n if (!candidate || typeof candidate !== 'object') return '';\n\n // Check if this is a Dice candidate\n const isDiceCandidate = (() => {\n const source = candidate?.sourceType\n ?? candidate?.profileSource\n ?? candidate?.selectedSource;\n const normalizedSources = Array.isArray(source) ? source : [source];\n return normalizedSources.some(\n (value) => String(value ?? '').trim().toLowerCase() === 'dice',\n );\n })();\n\n const explicitPaths = [\n 'diceId',\n 'diceID',\n 'dice_id',\n 'diceProfileId',\n 'diceProfileID',\n 'diceProfileGuid',\n 'profileId',\n 'profileID',\n 'profileGuid',\n 'sourceId',\n 'sourceProfileId',\n 'externalId',\n 'externalProfileId',\n 'customFields.diceId',\n 'customFields.diceProfileId',\n 'customFields.profileId',\n 'customFields.externalProfileId',\n 'customFields.diceProfileData.diceId',\n 'customFields.diceProfileData.diceID',\n 'customFields.diceProfileData.id',\n 'customFields.diceProfileData._id',\n 'customFields.diceProfileData.profileId',\n 'customFields.diceProfileData.profileID',\n 'customFields.diceProfileData.diceProfileId',\n 'customFields.diceProfileData.diceProfileID',\n 'customFields.diceProfileData.guid',\n 'customFields.diceProfileData.uuid',\n 'customFields.diceProfileData.externalId',\n 'customFields.diceProfileData.candidateid',\n 'customFields.diceProfileData.candidateId',\n ];\n\n const explicitDiceId = firstPresentValue(\n ...explicitPaths.map((path) => getPathValue(candidate, path)),\n );\n\n if (explicitDiceId && !isLikelyDiceCandidateId(explicitDiceId, candidate)) {\n return String(explicitDiceId);\n }\n\n const likelyNestedId = findLikelyDiceProfileId(candidate);\n if (likelyNestedId) return likelyNestedId;\n\n const genericId = firstPresentValue(candidate.id, candidate._id);\n \n // For Dice candidates, accept the ID even if it looks like an internal MongoDB ObjectId\n // For non-Dice candidates, reject IDs that look like internal record IDs\n if (genericId && (isDiceCandidate || !isLikelyInternalRecordId(genericId))) {\n return String(genericId);\n }\n \n return '';\n}\n\nexport function normalizeDiceSkills(skills) {\n if (!skills) return [];\n \n if (Array.isArray(skills)) {\n return skills\n .map(skill => {\n // Handle Dice format: {skill: \"courts\", lastUsed: 2026}\n if (skill?.skill) return skill.skill;\n // Handle other object formats\n if (typeof skill === 'object' && skill !== null) {\n if (skill?.name) return skill.name;\n if (skill?.skillName) return skill.skillName;\n if (skill?.value) return skill.value;\n }\n // Handle string skills\n if (typeof skill === 'string') return skill;\n return null;\n })\n .filter(Boolean);\n }\n \n if (typeof skills === 'string') {\n return skills.split(',').map(s => s.trim()).filter(Boolean);\n }\n \n return [];\n}\n\n/**\n * Normalizes location from various Dice location formats\n */\nfunction normalizeDiceLocation(candidate) {\n // Try locations array first (common in Dice)\n if (Array.isArray(candidate.locations) && candidate.locations.length > 0) {\n const loc = candidate.locations[0];\n if (typeof loc === 'string') return loc;\n if (loc?.region) return loc.region;\n if (loc?.city) return loc.city;\n if (loc?.name) return loc.name;\n if (loc?.location) return loc.location;\n }\n \n // Try direct location fields\n return (\n candidate.currentLocation ??\n candidate.location ??\n candidate.city ??\n candidate.region ??\n ''\n );\n}\n\n/**\n * Normalizes experience from various Dice experience formats\n */\nfunction normalizeDiceExperience(candidate) {\n const exp = (\n candidate.totalExperience ??\n candidate.experience ??\n candidate.yearsOfExperience ??\n candidate.exp ??\n candidate.totalYearsOfExperience ??\n candidate.workExperienceYears\n );\n \n return exp != null && exp !== '' ? exp : null;\n}\n\n/**\n * Normalizes date from various Dice date formats\n */\nfunction normalizeDiceDate(candidate) {\n return (\n candidate.dateLastUpdated ??\n candidate.updatedAt ??\n candidate.createdAt ??\n candidate.createdDate ??\n candidate.dateCreated ??\n null\n );\n}\n\n/**\n * Normalizes name from various Dice name formats\n */\nfunction normalizeDiceName(candidate) {\n const parts = [\n candidate.firstName,\n candidate.middleName,\n candidate.lastName,\n ].filter(Boolean);\n \n if (parts.length > 0) return parts.join(' ');\n \n return (\n candidate.fullName ??\n candidate.name ??\n candidate.candidateName ??\n ''\n );\n}\n\n/**\n * Maps a single Dice candidate to the Internal Candidate format\n * \n * @param {Object} diceCandidate - Raw Dice API candidate object\n * @param {number} index - Index for fallback ID generation\n * @returns {Object} Mapped candidate in Internal format\n */\nexport function mapDiceCandidateToInternal(diceCandidate, index = 0) {\n if (!diceCandidate || typeof diceCandidate !== 'object') {\n return {\n id: `dice-candidate-${index}`,\n diceId: '',\n candidateId: '',\n firstName: '',\n lastName: '',\n name: '-',\n designation: '-',\n currentLocation: '',\n location: '',\n exp: '',\n totalExperience: null,\n skills: [],\n createdAt: null,\n createdOn: '-',\n sourceType: 'dice',\n profileSource: 'dice',\n };\n }\n\n const fullName = normalizeDiceName(diceCandidate);\n const nameParts = fullName.split(' ');\n const firstName = nameParts[0] || '';\n const lastName = nameParts.length > 1 ? nameParts[nameParts.length - 1] : '';\n \n const location = normalizeDiceLocation(diceCandidate);\n const experience = normalizeDiceExperience(diceCandidate);\n const createdOn = normalizeDiceDate(diceCandidate);\n const diceProfileId = resolveDiceProfileId(diceCandidate);\n const candidateId = diceCandidate.candidateId\n ?? diceCandidate.customFields?.diceProfileData?.candidateId\n ?? `dice-candidate-${index}`;\n \n // Extract skills from various possible fields\n const rawSkills = diceCandidate.skills ?? \n diceCandidate.technicalSkills ?? \n diceCandidate.primarySkills ??\n diceCandidate.keySkills ??\n [];\n \n const skills = normalizeDiceSkills(rawSkills);\n \n // Debug logging to verify transformation\n if (process.env.NODE_ENV === 'development') {\n console.log('[DiceMapper] Original skills:', rawSkills);\n console.log('[DiceMapper] Mapped skills:', skills);\n console.log('[DiceMapper] Dice IDs:', {\n id: diceProfileId,\n diceId: diceProfileId,\n candidateId,\n });\n }\n\n return {\n // Preserve original Dice fields for reference\n ...diceCandidate,\n \n // Map to Internal candidate schema. Keep the Dice profile id as the primary id.\n id: diceProfileId,\n diceId: diceProfileId,\n candidateId,\n \n // Name fields\n firstName,\n lastName,\n middleName: diceCandidate.middleName || '',\n name: fullName || '-',\n fullName: fullName || '',\n \n // Professional info\n designation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '-',\n currentDesignation: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? diceCandidate.currentDesignation ?? '',\n jobTitle: diceCandidate.currentJobTitle ?? diceCandidate.jobTitle ?? diceCandidate.designation ?? '',\n \n // Location\n currentLocation: location || '',\n location: location || '',\n city: diceCandidate.city ?? diceCandidate.locations?.[0]?.city ?? '',\n region: diceCandidate.region ?? diceCandidate.locations?.[0]?.region ?? '',\n \n // Experience\n totalExperience: experience,\n experience: experience,\n yearsOfExperience: experience,\n exp: experience != null && experience !== '' ? `${experience} yrs` : '',\n \n // Skills\n skills,\n technicalSkills: skills,\n primarySkills: skills,\n \n // Dates\n createdAt: createdOn,\n createdOn: createdOn ? String(createdOn) : '-',\n updatedAt: createdOn,\n dateLastUpdated: createdOn,\n \n // Source identification\n sourceType: 'dice',\n profileSource: 'dice',\n selectedSource: ['dice'],\n \n // Additional fields with defaults\n email: diceCandidate.email ?? diceCandidate.emailAddress ?? '',\n phone: diceCandidate.phone ?? diceCandidate.phoneNumber ?? diceCandidate.mobile ?? '',\n summary: diceCandidate.summary ?? diceCandidate.bio ?? diceCandidate.description ?? '',\n resume: diceCandidate.resume ?? diceCandidate.resumeUrl ?? diceCandidate.cvUrl ?? '',\n \n // Status and metadata\n isActive: true,\n isDeleted: false,\n };\n}\n\n/**\n * Maps an array of Dice candidates to the Internal Candidate format\n * \n * @param {Array} diceCandidates - Array of raw Dice API candidate objects\n * @returns {Array} Array of mapped candidates in Internal format\n */\nexport function mapDiceCandidatesToInternal(diceCandidates) {\n if (!Array.isArray(diceCandidates)) {\n return [];\n }\n \n return diceCandidates.map((candidate, index) => \n mapDiceCandidateToInternal(candidate, index)\n );\n}\n\n/**\n * Transforms a Dice API response to match the existing Candidate List API response format\n * \n * @param {Object} diceResponse - Raw Dice API response\n * @param {Object} originalResponseStructure - The expected response structure from Internal API\n * @returns {Object} Transformed response matching Internal API format\n */\nexport function transformDiceResponseToInternalFormat(diceResponse, originalResponseStructure = {}) {\n if (!diceResponse || typeof diceResponse !== 'object') {\n return {\n status: 'success',\n data: {\n fields: [],\n actions: [],\n columnActions: [],\n count: 0,\n data: [],\n },\n };\n }\n\n // Extract candidates array from various possible response structures\n const diceCandidates = Array.isArray(diceResponse) \n ? diceResponse \n : diceResponse?.data?.data ?? \n diceResponse?.data?.applicant ?? \n diceResponse?.data?.candidates ?? \n diceResponse?.data?.items ?? \n diceResponse?.items ?? \n diceResponse?.candidates ?? \n diceResponse?.records ?? \n [];\n\n // Map Dice candidates to Internal format\n const mappedCandidates = mapDiceCandidatesToInternal(diceCandidates);\n\n // Extract count from various possible locations\n const count = (\n diceResponse?.data?.count?.searchCount ??\n diceResponse?.data?.count?.total ??\n diceResponse?.count?.searchCount ??\n diceResponse?.count?.total ??\n diceResponse?.total ??\n diceResponse?.totalCount ??\n mappedCandidates.length\n );\n\n // Preserve existing metadata from the original response structure\n return {\n status: diceResponse?.status ?? 'success',\n data: {\n // Preserve fields, actions, columnActions from original structure\n fields: originalResponseStructure?.fields ?? diceResponse?.data?.fields ?? diceResponse?.fields ?? [],\n actions: originalResponseStructure?.actions ?? diceResponse?.data?.actions ?? diceResponse?.actions ?? [],\n columnActions: originalResponseStructure?.columnActions ?? diceResponse?.data?.columnActions ?? diceResponse?.columnActions ?? [],\n \n // Count and mapped data\n count: Number(count) || 0,\n data: mappedCandidates,\n \n // Preserve any additional metadata\n ...(diceResponse?.data?.actionRules && { actionRules: diceResponse.data.actionRules }),\n ...(diceResponse?.data?.tabs && { tabs: diceResponse.data.tabs }),\n ...(diceResponse?.data?.tabField && { tabField: diceResponse.data.tabField }),\n },\n };\n}\n\n/**\n * Checks if a response contains Dice candidates\n * \n * @param {Array|Object} response - API response to check\n * @returns {boolean} True if response contains Dice candidates\n */\nexport function isDiceResponse(response) {\n if (!response) return false;\n \n const candidates = Array.isArray(response) \n ? response \n : response?.data?.data ?? \n response?.data?.applicant ?? \n response?.data?.candidates ?? \n response?.data?.items ?? \n response?.items ?? \n [];\n \n if (!Array.isArray(candidates) || candidates.length === 0) {\n return false;\n }\n \n // Check first few candidates for Dice source indicators\n const sampleSize = Math.min(candidates.length, 5);\n for (let i = 0; i < sampleSize; i++) {\n const candidate = candidates[i];\n const sourceType = candidate?.sourceType ?? candidate?.profileSource ?? '';\n if (String(sourceType).toLowerCase() === 'dice') {\n return true;\n }\n }\n \n return false;\n}\n\nexport default {\n mapDiceCandidateToInternal,\n mapDiceCandidatesToInternal,\n transformDiceResponseToInternalFormat,\n isDiceResponse,\n};\n"],"mappings":";;;;;;;;;;AAaA,SAAS,EAAkB,GAAG,GAAQ;CACpC,OAAO,EAAO,MAAM,MAAU,KAAiC,QAAQ,OAAO,CAAK,CAAC,CAAC,KAAK,MAAM,EAAE;AACpG;AAEA,SAAS,EAAa,GAAQ,GAAM;CAC9B,OAAC,KAAU,CAAC,IAEhB,OADI,OAAO,UAAU,eAAe,KAAK,GAAQ,CAAI,IAAU,EAAO,KAC/D,OAAO,CAAI,CAAC,CAChB,MAAM,GAAG,CAAC,CACV,QAAQ,GAAO,MAAQ,IAAQ,IAAM,CAAM;AAChD;AAEA,SAAS,EAAyB,GAAO;CACvC,OAAO,kBAAkB,KAAK,OAAO,KAAS,EAAE,CAAC,CAAC,KAAK,CAAC;AAC1D;AAEA,SAAS,EAAsB,GAAO;CACpC,IAAM,IAAO,OAAO,KAAS,EAAE,CAAC,CAAC,KAAK;CACtC,OACE,kEAAkE,KAAK,CAAI,KACxE,mBAAmB,KAAK,CAAI;AAEnC;AAEA,SA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,IAAI,GAAG,IAAI,GAAY,KAAK;EACnC,IAAM,IAAY,EAAW,IACvB,IAAa,GAAW,cAAc,GAAW,iBAAiB;EACxE,IAAI,OAAO,CAAU,CAAC,CAAC,YAAY,MAAM,QACvC,OAAO;CAEX;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"formGroupsCache-Bbz-28ws.cjs","names":[],"sources":["../src/services/formGroupsCache.js"],"sourcesContent":["// formGroupsCache — one network request per distinct form-groups query.\r\n//\r\n// WHY\r\n// A single page routinely asks for the SAME form-groups payload several times\r\n// over, because the parts that need it are independent of each other and none\r\n// of them can know the others exist: on Quick Submit the job header card, the\r\n// form's cross-module prefill and a job-source lookup each fetch the same job,\r\n// and the submission config is fetched once unscoped and again client-scoped.\r\n// Those payloads are large (60 kB for a submission config), so the duplicates\r\n// are the expensive kind — a measured 245-request, ~4.8 s load with several\r\n// identical 60 kB and 15 kB responses in it.\r\n//\r\n// The honest fix is not to make each caller aware of the others — that couples\r\n// components that have no business knowing about each other, and breaks the\r\n// moment a new one is added. It is to make the REQUEST idempotent: identical\r\n// queries fired close together share one response.\r\n//\r\n// TWO MECHANISMS, deliberately:\r\n//\r\n// • in-flight coalescing — a query that is already running is joined rather\r\n// than reissued. Always safe: the answer cannot be staler than the request\r\n// that is still in the air.\r\n// • a SHORT time-to-live — covers the common case where the duplicates are\r\n// sequential rather than overlapping (a child mounts after its parent's\r\n// fetch has already resolved). This is the part that can serve stale data,\r\n// so it is kept to a few seconds and any write invalidates the whole cache.\r\n//\r\n// Errors are never cached: a failed fetch removes its entry so the next caller\r\n// retries for real instead of inheriting the failure.\r\n//\r\n// Nothing here knows a module or a field. The cache key is the request URL, so\r\n// scopes that differ in any way (id, clientId, view, group, action) are\r\n// different entries and can never be served each other's data.\r\n\r\n// Long enough to cover one page's mount burst, short enough that no realistic\r\n// user action fits inside it. Writes invalidate regardless — see below.\r\nconst DEFAULT_TTL_MS = 4000;\r\n\r\nconst entries = new Map(); // url -> { at, promise }\r\n\r\nlet ttlMs = DEFAULT_TTL_MS;\r\n\r\n/** Test/host hook: change the window, or set 0 to keep only in-flight coalescing. */\r\nexport function setFormGroupsCacheTtl(ms) {\r\n ttlMs = Math.max(0, Number(ms) || 0);\r\n}\r\n\r\n/**\r\n * Drop everything. Called after any module write: a save is exactly the moment\r\n * a cached payload stops describing the record, and a stale read here would\r\n * show the user their own change missing.\r\n */\r\nexport function invalidateFormGroupsCache() {\r\n entries.clear();\r\n}\r\n\r\n/**\r\n * fetchFormGroupsCached — run `loader()` for `url`, or join/replay a recent\r\n * identical run.\r\n *\r\n * `loader` returns the RAW payload, so every caller shares one request no\r\n * matter which shape it goes on to read out of it (the groups array, or the\r\n * whole envelope with recordMeta).\r\n */\r\nexport function fetchFormGroupsCached(url, loader) {\r\n const now = Date.now();\r\n const hit = entries.get(url);\r\n // A pending entry is always joinable; a settled one only within the window.\r\n if (hit && (hit.pending || now - hit.at < ttlMs)) return hit.promise;\r\n\r\n const entry = { at: now, pending: true };\r\n entry.promise = Promise.resolve()\r\n .then(loader)\r\n .then((value) => {\r\n entry.pending = false;\r\n // Stamp on COMPLETION, not on start: a slow request must not begin life\r\n // already half-expired, or a burst behind it would reissue immediately.\r\n entry.at = Date.now();\r\n return value;\r\n })\r\n .catch((err) => {\r\n // Never cache a failure — the next caller must get a real attempt.\r\n if (entries.get(url) === entry) entries.delete(url);\r\n throw err;\r\n });\r\n entries.set(url, entry);\r\n return entry.promise;\r\n}\r\n\r\nexport default { fetchFormGroupsCached, invalidateFormGroupsCache, setFormGroupsCacheTtl };\r\n"],"mappings":"kHAoCM,EAAiB,IAEjB,EAAU,IAAI,IAEhB,EAAQ,EAYZ,SAAgB,GAA4B,CAC1C,EAAQ,MAAM,CAChB,CAUA,SAAgB,EAAsB,EAAK,EAAQ,CACjD,IAAM,EAAM,KAAK,IAAI,EACf,EAAM,EAAQ,IAAI,CAAG,EAE3B,GAAI,IAAQ,EAAI,SAAW,EAAM,EAAI,GAAK,GAAQ,OAAO,EAAI,QAE7D,IAAM,EAAQ,CAAE,GAAI,EAAK,QAAS,EAAK,EAgBvC,MAfA,GAAM,QAAU,QAAQ,QAAQ,CAAC,CAC9B,KAAK,CAAM,CAAC,CACZ,KAAM,IACL,EAAM,QAAU,GAGhB,EAAM,GAAK,KAAK,IAAI,EACb,EACR,CAAC,CACD,MAAO,GAAQ,CAGd,MADI,EAAQ,IAAI,CAAG,IAAM,GAAO,EAAQ,OAAO,CAAG,EAC5C,CACR,CAAC,EACH,EAAQ,IAAI,EAAK,CAAK,EACf,EAAM,OACf"}
1
+ {"version":3,"file":"formGroupsCache-Bbz-28ws.cjs","names":[],"sources":["../src/services/formGroupsCache.js"],"sourcesContent":["// formGroupsCache — one network request per distinct form-groups query.\n//\n// WHY\n// A single page routinely asks for the SAME form-groups payload several times\n// over, because the parts that need it are independent of each other and none\n// of them can know the others exist: on Quick Submit the job header card, the\n// form's cross-module prefill and a job-source lookup each fetch the same job,\n// and the submission config is fetched once unscoped and again client-scoped.\n// Those payloads are large (60 kB for a submission config), so the duplicates\n// are the expensive kind — a measured 245-request, ~4.8 s load with several\n// identical 60 kB and 15 kB responses in it.\n//\n// The honest fix is not to make each caller aware of the others — that couples\n// components that have no business knowing about each other, and breaks the\n// moment a new one is added. It is to make the REQUEST idempotent: identical\n// queries fired close together share one response.\n//\n// TWO MECHANISMS, deliberately:\n//\n// • in-flight coalescing — a query that is already running is joined rather\n// than reissued. Always safe: the answer cannot be staler than the request\n// that is still in the air.\n// • a SHORT time-to-live — covers the common case where the duplicates are\n// sequential rather than overlapping (a child mounts after its parent's\n// fetch has already resolved). This is the part that can serve stale data,\n// so it is kept to a few seconds and any write invalidates the whole cache.\n//\n// Errors are never cached: a failed fetch removes its entry so the next caller\n// retries for real instead of inheriting the failure.\n//\n// Nothing here knows a module or a field. The cache key is the request URL, so\n// scopes that differ in any way (id, clientId, view, group, action) are\n// different entries and can never be served each other's data.\n\n// Long enough to cover one page's mount burst, short enough that no realistic\n// user action fits inside it. Writes invalidate regardless — see below.\nconst DEFAULT_TTL_MS = 4000;\n\nconst entries = new Map(); // url -> { at, promise }\n\nlet ttlMs = DEFAULT_TTL_MS;\n\n/** Test/host hook: change the window, or set 0 to keep only in-flight coalescing. */\nexport function setFormGroupsCacheTtl(ms) {\n ttlMs = Math.max(0, Number(ms) || 0);\n}\n\n/**\n * Drop everything. Called after any module write: a save is exactly the moment\n * a cached payload stops describing the record, and a stale read here would\n * show the user their own change missing.\n */\nexport function invalidateFormGroupsCache() {\n entries.clear();\n}\n\n/**\n * fetchFormGroupsCached — run `loader()` for `url`, or join/replay a recent\n * identical run.\n *\n * `loader` returns the RAW payload, so every caller shares one request no\n * matter which shape it goes on to read out of it (the groups array, or the\n * whole envelope with recordMeta).\n */\nexport function fetchFormGroupsCached(url, loader) {\n const now = Date.now();\n const hit = entries.get(url);\n // A pending entry is always joinable; a settled one only within the window.\n if (hit && (hit.pending || now - hit.at < ttlMs)) return hit.promise;\n\n const entry = { at: now, pending: true };\n entry.promise = Promise.resolve()\n .then(loader)\n .then((value) => {\n entry.pending = false;\n // Stamp on COMPLETION, not on start: a slow request must not begin life\n // already half-expired, or a burst behind it would reissue immediately.\n entry.at = Date.now();\n return value;\n })\n .catch((err) => {\n // Never cache a failure — the next caller must get a real attempt.\n if (entries.get(url) === entry) entries.delete(url);\n throw err;\n });\n entries.set(url, entry);\n return entry.promise;\n}\n\nexport default { fetchFormGroupsCached, invalidateFormGroupsCache, setFormGroupsCacheTtl };\n"],"mappings":"kHAoCM,EAAiB,IAEjB,EAAU,IAAI,IAEhB,EAAQ,EAYZ,SAAgB,GAA4B,CAC1C,EAAQ,MAAM,CAChB,CAUA,SAAgB,EAAsB,EAAK,EAAQ,CACjD,IAAM,EAAM,KAAK,IAAI,EACf,EAAM,EAAQ,IAAI,CAAG,EAE3B,GAAI,IAAQ,EAAI,SAAW,EAAM,EAAI,GAAK,GAAQ,OAAO,EAAI,QAE7D,IAAM,EAAQ,CAAE,GAAI,EAAK,QAAS,EAAK,EAgBvC,MAfA,GAAM,QAAU,QAAQ,QAAQ,CAAC,CAC9B,KAAK,CAAM,CAAC,CACZ,KAAM,IACL,EAAM,QAAU,GAGhB,EAAM,GAAK,KAAK,IAAI,EACb,EACR,CAAC,CACD,MAAO,GAAQ,CAGd,MADI,EAAQ,IAAI,CAAG,IAAM,GAAO,EAAQ,OAAO,CAAG,EAC5C,CACR,CAAC,EACH,EAAQ,IAAI,EAAK,CAAK,EACf,EAAM,OACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"formGroupsCache-JeC59oNe.js","names":[],"sources":["../src/services/formGroupsCache.js"],"sourcesContent":["// formGroupsCache — one network request per distinct form-groups query.\r\n//\r\n// WHY\r\n// A single page routinely asks for the SAME form-groups payload several times\r\n// over, because the parts that need it are independent of each other and none\r\n// of them can know the others exist: on Quick Submit the job header card, the\r\n// form's cross-module prefill and a job-source lookup each fetch the same job,\r\n// and the submission config is fetched once unscoped and again client-scoped.\r\n// Those payloads are large (60 kB for a submission config), so the duplicates\r\n// are the expensive kind — a measured 245-request, ~4.8 s load with several\r\n// identical 60 kB and 15 kB responses in it.\r\n//\r\n// The honest fix is not to make each caller aware of the others — that couples\r\n// components that have no business knowing about each other, and breaks the\r\n// moment a new one is added. It is to make the REQUEST idempotent: identical\r\n// queries fired close together share one response.\r\n//\r\n// TWO MECHANISMS, deliberately:\r\n//\r\n// • in-flight coalescing — a query that is already running is joined rather\r\n// than reissued. Always safe: the answer cannot be staler than the request\r\n// that is still in the air.\r\n// • a SHORT time-to-live — covers the common case where the duplicates are\r\n// sequential rather than overlapping (a child mounts after its parent's\r\n// fetch has already resolved). This is the part that can serve stale data,\r\n// so it is kept to a few seconds and any write invalidates the whole cache.\r\n//\r\n// Errors are never cached: a failed fetch removes its entry so the next caller\r\n// retries for real instead of inheriting the failure.\r\n//\r\n// Nothing here knows a module or a field. The cache key is the request URL, so\r\n// scopes that differ in any way (id, clientId, view, group, action) are\r\n// different entries and can never be served each other's data.\r\n\r\n// Long enough to cover one page's mount burst, short enough that no realistic\r\n// user action fits inside it. Writes invalidate regardless — see below.\r\nconst DEFAULT_TTL_MS = 4000;\r\n\r\nconst entries = new Map(); // url -> { at, promise }\r\n\r\nlet ttlMs = DEFAULT_TTL_MS;\r\n\r\n/** Test/host hook: change the window, or set 0 to keep only in-flight coalescing. */\r\nexport function setFormGroupsCacheTtl(ms) {\r\n ttlMs = Math.max(0, Number(ms) || 0);\r\n}\r\n\r\n/**\r\n * Drop everything. Called after any module write: a save is exactly the moment\r\n * a cached payload stops describing the record, and a stale read here would\r\n * show the user their own change missing.\r\n */\r\nexport function invalidateFormGroupsCache() {\r\n entries.clear();\r\n}\r\n\r\n/**\r\n * fetchFormGroupsCached — run `loader()` for `url`, or join/replay a recent\r\n * identical run.\r\n *\r\n * `loader` returns the RAW payload, so every caller shares one request no\r\n * matter which shape it goes on to read out of it (the groups array, or the\r\n * whole envelope with recordMeta).\r\n */\r\nexport function fetchFormGroupsCached(url, loader) {\r\n const now = Date.now();\r\n const hit = entries.get(url);\r\n // A pending entry is always joinable; a settled one only within the window.\r\n if (hit && (hit.pending || now - hit.at < ttlMs)) return hit.promise;\r\n\r\n const entry = { at: now, pending: true };\r\n entry.promise = Promise.resolve()\r\n .then(loader)\r\n .then((value) => {\r\n entry.pending = false;\r\n // Stamp on COMPLETION, not on start: a slow request must not begin life\r\n // already half-expired, or a burst behind it would reissue immediately.\r\n entry.at = Date.now();\r\n return value;\r\n })\r\n .catch((err) => {\r\n // Never cache a failure — the next caller must get a real attempt.\r\n if (entries.get(url) === entry) entries.delete(url);\r\n throw err;\r\n });\r\n entries.set(url, entry);\r\n return entry.promise;\r\n}\r\n\r\nexport default { fetchFormGroupsCached, invalidateFormGroupsCache, setFormGroupsCacheTtl };\r\n"],"mappings":";;;;;IAoCM,IAAiB,KAEjB,oBAAU,IAAI,IAAI,GAEpB,IAAQ;AAYZ,SAAgB,IAA4B;CAC1C,EAAQ,MAAM;AAChB;AAUA,SAAgB,EAAsB,GAAK,GAAQ;CACjD,IAAM,IAAM,KAAK,IAAI,GACf,IAAM,EAAQ,IAAI,CAAG;CAE3B,IAAI,MAAQ,EAAI,WAAW,IAAM,EAAI,KAAK,IAAQ,OAAO,EAAI;CAE7D,IAAM,IAAQ;EAAE,IAAI;EAAK,SAAS;CAAK;CAgBvC,OAfA,EAAM,UAAU,QAAQ,QAAQ,CAAC,CAC9B,KAAK,CAAM,CAAC,CACZ,MAAM,OACL,EAAM,UAAU,IAGhB,EAAM,KAAK,KAAK,IAAI,GACb,EACR,CAAC,CACD,OAAO,MAAQ;EAGd,MADI,EAAQ,IAAI,CAAG,MAAM,KAAO,EAAQ,OAAO,CAAG,GAC5C;CACR,CAAC,GACH,EAAQ,IAAI,GAAK,CAAK,GACf,EAAM;AACf"}
1
+ {"version":3,"file":"formGroupsCache-JeC59oNe.js","names":[],"sources":["../src/services/formGroupsCache.js"],"sourcesContent":["// formGroupsCache — one network request per distinct form-groups query.\n//\n// WHY\n// A single page routinely asks for the SAME form-groups payload several times\n// over, because the parts that need it are independent of each other and none\n// of them can know the others exist: on Quick Submit the job header card, the\n// form's cross-module prefill and a job-source lookup each fetch the same job,\n// and the submission config is fetched once unscoped and again client-scoped.\n// Those payloads are large (60 kB for a submission config), so the duplicates\n// are the expensive kind — a measured 245-request, ~4.8 s load with several\n// identical 60 kB and 15 kB responses in it.\n//\n// The honest fix is not to make each caller aware of the others — that couples\n// components that have no business knowing about each other, and breaks the\n// moment a new one is added. It is to make the REQUEST idempotent: identical\n// queries fired close together share one response.\n//\n// TWO MECHANISMS, deliberately:\n//\n// • in-flight coalescing — a query that is already running is joined rather\n// than reissued. Always safe: the answer cannot be staler than the request\n// that is still in the air.\n// • a SHORT time-to-live — covers the common case where the duplicates are\n// sequential rather than overlapping (a child mounts after its parent's\n// fetch has already resolved). This is the part that can serve stale data,\n// so it is kept to a few seconds and any write invalidates the whole cache.\n//\n// Errors are never cached: a failed fetch removes its entry so the next caller\n// retries for real instead of inheriting the failure.\n//\n// Nothing here knows a module or a field. The cache key is the request URL, so\n// scopes that differ in any way (id, clientId, view, group, action) are\n// different entries and can never be served each other's data.\n\n// Long enough to cover one page's mount burst, short enough that no realistic\n// user action fits inside it. Writes invalidate regardless — see below.\nconst DEFAULT_TTL_MS = 4000;\n\nconst entries = new Map(); // url -> { at, promise }\n\nlet ttlMs = DEFAULT_TTL_MS;\n\n/** Test/host hook: change the window, or set 0 to keep only in-flight coalescing. */\nexport function setFormGroupsCacheTtl(ms) {\n ttlMs = Math.max(0, Number(ms) || 0);\n}\n\n/**\n * Drop everything. Called after any module write: a save is exactly the moment\n * a cached payload stops describing the record, and a stale read here would\n * show the user their own change missing.\n */\nexport function invalidateFormGroupsCache() {\n entries.clear();\n}\n\n/**\n * fetchFormGroupsCached — run `loader()` for `url`, or join/replay a recent\n * identical run.\n *\n * `loader` returns the RAW payload, so every caller shares one request no\n * matter which shape it goes on to read out of it (the groups array, or the\n * whole envelope with recordMeta).\n */\nexport function fetchFormGroupsCached(url, loader) {\n const now = Date.now();\n const hit = entries.get(url);\n // A pending entry is always joinable; a settled one only within the window.\n if (hit && (hit.pending || now - hit.at < ttlMs)) return hit.promise;\n\n const entry = { at: now, pending: true };\n entry.promise = Promise.resolve()\n .then(loader)\n .then((value) => {\n entry.pending = false;\n // Stamp on COMPLETION, not on start: a slow request must not begin life\n // already half-expired, or a burst behind it would reissue immediately.\n entry.at = Date.now();\n return value;\n })\n .catch((err) => {\n // Never cache a failure — the next caller must get a real attempt.\n if (entries.get(url) === entry) entries.delete(url);\n throw err;\n });\n entries.set(url, entry);\n return entry.promise;\n}\n\nexport default { fetchFormGroupsCached, invalidateFormGroupsCache, setFormGroupsCacheTtl };\n"],"mappings":";;;;;IAoCM,IAAiB,KAEjB,oBAAU,IAAI,IAAI,GAEpB,IAAQ;AAYZ,SAAgB,IAA4B;CAC1C,EAAQ,MAAM;AAChB;AAUA,SAAgB,EAAsB,GAAK,GAAQ;CACjD,IAAM,IAAM,KAAK,IAAI,GACf,IAAM,EAAQ,IAAI,CAAG;CAE3B,IAAI,MAAQ,EAAI,WAAW,IAAM,EAAI,KAAK,IAAQ,OAAO,EAAI;CAE7D,IAAM,IAAQ;EAAE,IAAI;EAAK,SAAS;CAAK;CAgBvC,OAfA,EAAM,UAAU,QAAQ,QAAQ,CAAC,CAC9B,KAAK,CAAM,CAAC,CACZ,MAAM,OACL,EAAM,UAAU,IAGhB,EAAM,KAAK,KAAK,IAAI,GACb,EACR,CAAC,CACD,OAAO,MAAQ;EAGd,MADI,EAAQ,IAAI,CAAG,MAAM,KAAO,EAAQ,OAAO,CAAG,GAC5C;CACR,CAAC,GACH,EAAQ,IAAI,GAAK,CAAK,GACf,EAAM;AACf"}