@webex/plugin-meetings 3.0.0-beta.274 → 3.0.0-beta.276

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,"names":["MAX_OOO_DELTA_COUNT","OOO_DELTA_WAIT_TIME","OOO_DELTA_WAIT_TIME_RANDOM_DELAY","Parser","deltaCompareFunc","left","right","loci","LT","GT","extract","extractComparisonState","isSequenceEmpty","result","compareSequence","baseSequence","queue","SortedQueue","status","onDeltaAction","workingCopy","syncTimer","incomingFullDto","isLoci","LoggerProxy","logger","info","comparisonResult","compareFullDtoSequence","USE_INCOMING","newLoci","isValid","size","processDeltaEvent","action","locus","enqueue","triggerSync","reason","stopSyncTimer","pause","DESYNC","timeout","Math","random","setTimeout","clearTimeout","WAIT","dequeue","isValidLocus","nextEvent","compare","lociComparison","debug","needToWait","startSyncTimer","locus2string","sequence","entries","length","at","current","incoming","comparison","min","max","currentIsNotUnique","unique","incomingIsNotUnique","currentTotalRange","end","incomingTotalRange","EQ","currentIsUnique","incomingIsUnique","currentUniqueMin","incomingUniqueMin","currentHasNoRange","start","incomingHasNoRange","neitherSeqHasRange","hasUniqOverlap","list","some","seq","currentUniqOverlap","incomingUniqOverlap","debugInfo","pack","packComparisonResult","compareDelta","compareToAction","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","LOCUS_DELTA_OUT_OF_ORDER","stack","Error","slice","USE_CURRENT","local","getMetaData","delta","getUniqueSequences","rules","checkSequenceOverlap","checkUnequalRanges","checkForUniqueEntries","checkIfOutOfSync","rule","ERROR","lociComparisonResult","split","first","last","rangeStart","rangeEnd","baseLoci","otherLoci","diff","getNumbersOutOfRange","output","filter","num","sort","a","b","hasEmptyEntries","hasEmptyRange","hasProp","prop","Object","prototype","hasOwnProperty","call","newData","oldData","debugCode","mStr","strings","join","replace","resolutionMap","debugMap","SO001","title","description","logic","SO002","UR001","UR002","UR003","UE001","UE002","OOS001","OOS002","OOS003","debugObj","resolution"],"sources":["parser.ts"],"sourcesContent":["import {difference} from 'lodash';\n\nimport SortedQueue from '../common/queue';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport Metrics from '../metrics';\nimport BEHAVIORAL_METRICS from '../metrics/constants';\n\nconst MAX_OOO_DELTA_COUNT = 5; // when we receive an out-of-order delta and the queue builds up to MAX_OOO_DELTA_COUNT, we do a sync with Locus\nconst OOO_DELTA_WAIT_TIME = 10000; // [ms] minimum wait time before we do a sync if we get out-of-order deltas\nconst OOO_DELTA_WAIT_TIME_RANDOM_DELAY = 5000; // [ms] max random delay added to OOO_DELTA_WAIT_TIME\n\ntype LocusDeltaDto = {\n baseSequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n sequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n syncUrl: string;\n};\n\n/**\n * Locus Delta Parser\n * @private\n * https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Delta-Events\n */\nexport default class Parser {\n // processing status\n status:\n | 'IDLE' // not doing anything\n | 'PAUSED' // paused, because we are doing a sync\n | 'WORKING' // processing a delta event\n | 'BLOCKED'; // received an out-of-order delta, so waiting for the missing one\n\n // loci comparison states\n static loci = {\n EQ: 'EQUAL',\n GT: 'GREATER_THAN',\n LT: 'LESS_THAN',\n DESYNC: 'DESYNC',\n USE_INCOMING: 'USE_INCOMING',\n USE_CURRENT: 'USE_CURRENT',\n WAIT: 'WAIT',\n ERROR: 'ERROR',\n };\n\n queue: SortedQueue<LocusDeltaDto>;\n workingCopy: any;\n syncTimer: null | number | NodeJS.Timeout;\n\n /**\n * @constructs Parser\n */\n constructor() {\n const deltaCompareFunc = (left: LocusDeltaDto, right: LocusDeltaDto) => {\n const {LT, GT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n\n if (Parser.isSequenceEmpty(left)) {\n return -1;\n }\n if (Parser.isSequenceEmpty(right)) {\n return 1;\n }\n const result = extract(Parser.compareSequence(left.baseSequence, right.baseSequence));\n\n if (result === LT) {\n return -1;\n }\n if (result === GT) {\n return 1;\n }\n\n return 0;\n };\n\n this.queue = new SortedQueue<LocusDeltaDto>(deltaCompareFunc);\n this.status = 'IDLE';\n this.onDeltaAction = null;\n this.workingCopy = null;\n this.syncTimer = null;\n }\n\n /**\n * Returns a debug string representing a locus delta - useful for logging\n *\n * @param {LocusDeltaDto} locus Locus delta\n * @returns {string}\n */\n static locus2string(locus: LocusDeltaDto) {\n if (!locus.sequence?.entries) {\n return 'invalid';\n }\n\n return locus.sequence.entries.length ? `seq=${locus.sequence.entries.at(-1)}` : 'empty';\n }\n\n /**\n * Checks if two sequences overlap in time,\n * the sequence with the higher minimum value is greater.\n * Chooses sequence with most recent data.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkSequenceOverlap(current, incoming) {\n let comparison = null;\n\n // if earliest working copy sequence is more recent than last incoming sequence\n if (current.min > incoming.max) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:SO001`;\n }\n // if last working copy sequence is before the earliest incoming sequence\n else if (current.max < incoming.min) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:SO002`;\n }\n\n // if no match above, defaults to null\n return comparison;\n }\n\n /**\n * Checks if two sequences have unequal ranges.\n * Chooses sequence with most larger range.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {object} loci comparison\n */\n static checkUnequalRanges(current, incoming) {\n let comparison = null;\n const currentIsNotUnique = current.unique.length === 0;\n const incomingIsNotUnique = incoming.unique.length === 0;\n const currentTotalRange = current.end - current.min;\n const incomingTotalRange = incoming.end - incoming.min;\n\n // no unique values for both loci\n if (currentIsNotUnique && incomingIsNotUnique) {\n // current working copy loci has a larger range\n if (currentTotalRange > incomingTotalRange) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UR001`;\n }\n // incoming delta loci has a larger range\n else if (currentTotalRange < incomingTotalRange) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UR002`;\n } else {\n // with no unique entries and with ranges either absent or\n // of the same size, the sequences are considered equal.\n comparison = `${Parser.loci.EQ}:UR003`;\n }\n }\n\n return comparison;\n }\n\n /**\n * Checks if either sequences has unique entries.\n * Entries are considered unique if they do not overlap\n * with other Loci sequences or range values.\n * Chooses sequence with the unique entries.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkForUniqueEntries(current, incoming) {\n let comparison = null;\n const currentIsUnique = current.unique.length > 0;\n const incomingIsUnique = incoming.unique.length > 0;\n\n // current has unique entries and incoming does not\n if (currentIsUnique && !incomingIsUnique) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UE001`;\n }\n // current has no unique entries but incoming does\n else if (!currentIsUnique && incomingIsUnique) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UE002`;\n }\n\n return comparison;\n }\n\n /**\n * Checks both Locus Delta objects to see if they are\n * out of sync with one another. If so sends a DESYNC\n * request to the server.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkIfOutOfSync(current, incoming) {\n let comparison = null;\n const currentUniqueMin = current.unique[0];\n const incomingUniqueMin = incoming.unique[0];\n\n const currentHasNoRange = !current.start && !current.end;\n const incomingHasNoRange = !incoming.start && !incoming.end;\n const neitherSeqHasRange = currentHasNoRange && incomingHasNoRange;\n\n const hasUniqOverlap = (list, min, max) => list.some((seq) => min < seq && seq < max);\n // current unique entries overlap the total range of incoming\n const currentUniqOverlap = hasUniqOverlap(current.unique, incoming.min, incoming.max);\n // vice-versa, incoming unique entries overlap the total range of current\n const incomingUniqOverlap = hasUniqOverlap(incoming.unique, current.min, current.max);\n\n if (neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap) {\n // outputs string indicating which condition occurred. ex: 0,1,0\n const debugInfo = `${+neitherSeqHasRange},${+currentUniqOverlap},${+incomingUniqOverlap}`;\n\n // send DESYNC to server\n comparison = `${Parser.loci.DESYNC}:OOS001:${debugInfo}`;\n } else if (currentUniqueMin > incomingUniqueMin) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:OOS002`;\n } else {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:OOS003`;\n }\n\n return comparison;\n }\n\n /**\n * Compares two loci to determine which one contains the most recent state\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static compare(current, incoming) {\n const {isSequenceEmpty} = Parser;\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n if (isSequenceEmpty(current) || isSequenceEmpty(incoming)) {\n return pack(Parser.loci.USE_INCOMING, 'C001');\n }\n\n if (incoming.baseSequence) {\n return pack(Parser.compareDelta(current, incoming), 'C002');\n }\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n const action = Parser.compareToAction(extract(result));\n\n return pack(action, result);\n }\n\n /**\n * Compares two loci sequences (with delta params) and indicates what action\n * to take.\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @private\n * @returns {string} loci comparison state\n */\n private static compareDelta(current, incoming) {\n const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n let comparison = extract(result);\n\n if (comparison !== LT) {\n return pack(Parser.compareToAction(comparison), result);\n }\n\n comparison = Parser.compareSequence(current.sequence, incoming.baseSequence);\n\n switch (extract(comparison)) {\n case GT:\n case EQ:\n comparison = USE_INCOMING;\n break;\n\n case LT:\n if (extract(Parser.compareSequence(incoming.baseSequence, incoming.sequence)) === EQ) {\n // special case where Locus sends a delta with baseSequence === sequence to trigger a sync,\n // because the delta event is too large to be sent over mercury connection\n comparison = DESYNC;\n } else {\n // the incoming locus has baseSequence from the future, so it is out-of-order,\n // we are missing 1 or more locus that should be in front of it, we need to wait for it\n comparison = WAIT;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LOCUS_DELTA_OUT_OF_ORDER, {\n stack: new Error().stack,\n });\n }\n break;\n default:\n comparison = DESYNC;\n }\n\n return pack(comparison, result);\n }\n\n /**\n * Compares Locus sequences - it should be called only for full Locus DTOs, not deltas\n *\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n static compareFullDtoSequence(current, incomingFullDto) {\n if (Parser.isSequenceEmpty(current) || Parser.isSequenceEmpty(incomingFullDto)) {\n return Parser.loci.USE_INCOMING;\n }\n\n // the sequence.entries list will always contain at least 1 entry\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n return incomingFullDto.sequence.entries.slice(-1)[0] > current.sequence.entries.slice(-1)[0]\n ? Parser.loci.USE_INCOMING\n : Parser.loci.USE_CURRENT;\n }\n\n /**\n * Returns true if the incoming full locus DTO is newer than the current working copy\n *\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n isNewFullLocus(incomingFullDto) {\n if (!Parser.isLoci(incomingFullDto)) {\n LoggerProxy.logger.info('Locus-info:parser#isNewFullLocus --> Ignoring non-locus object.');\n\n return false;\n }\n\n if (!this.workingCopy) {\n // we don't have a working copy yet, so any full locus is better than nothing\n return true;\n }\n\n const comparisonResult = Parser.compareFullDtoSequence(this.workingCopy, incomingFullDto);\n\n return comparisonResult === Parser.loci.USE_INCOMING;\n }\n\n /**\n * Compares Locus sequences\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incoming New Locus delta\n * @returns {string}\n */\n static compareSequence(current, incoming) {\n // Locus sequence comparison rules in order of priority.\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n const local: any = Parser.getMetaData(current);\n const delta: any = Parser.getMetaData(incoming);\n\n // update loci metadata\n local.unique = Parser.getUniqueSequences(local, delta);\n delta.unique = Parser.getUniqueSequences(delta, local);\n\n // Locus sequence comparison rules\n // order matters\n const rules = [\n Parser.checkSequenceOverlap,\n Parser.checkUnequalRanges,\n Parser.checkForUniqueEntries,\n Parser.checkIfOutOfSync,\n ];\n\n for (const rule of rules) {\n // Rule only returns a value if the rule applies,\n // otherwise returns null.\n const result = rule(local, delta);\n\n if (result) {\n return result;\n }\n }\n\n // error, none of rules above applied\n // should never get here as last rule\n // should be catch all.\n return Parser.loci.ERROR;\n }\n\n /**\n * Transates the result of a sequence comparison into an intended behavior\n * @param {string} result\n * @returns {string} Locus comparison action\n */\n static compareToAction(result: string) {\n const {DESYNC, EQ, ERROR, GT, LT, USE_CURRENT, USE_INCOMING} = Parser.loci;\n\n let action = ERROR;\n\n switch (result) {\n case EQ:\n case GT:\n action = USE_CURRENT;\n break;\n case LT:\n action = USE_INCOMING;\n break;\n case DESYNC:\n action = DESYNC;\n break;\n default:\n LoggerProxy.logger.info(\n `Locus-info:parser#compareToAction --> Error: ${result} is not a recognized sequence comparison result.`\n );\n }\n\n return action;\n }\n\n /**\n * Extracts a loci comparison from a string of data.\n * @param {string} lociComparisonResult Comparison result with extra data\n * @returns {string} Comparison of EQ, LT, GT, or DESYNC.\n */\n static extractComparisonState(lociComparisonResult: string) {\n return lociComparisonResult.split(':')[0];\n }\n\n /**\n * @typedef {object} LociMetadata\n * @property {number} start - Starting sequence number\n * @property {number} end - Ending sequence number\n * @property {number} first - First sequence number\n * @property {number} last - Last sequence number\n * @property {number} min - Minimum sequence number\n * @property {number} max - Maximum sequence number\n * @property {number} entries - Loci sequence entries\n */\n\n /**\n * Metadata for Locus delta\n * @param {Array.<number>} sequence Locus delta sequence\n * @returns {LociMetadata} Locus Delta Metadata\n */\n static getMetaData(sequence: any) {\n const {entries} = sequence;\n const first = entries[0];\n const last = entries.slice(-1)[0];\n\n // rangeStart or rangeEnd is 0 if a range doesn't exist\n const start = sequence.rangeStart;\n const end = sequence.rangeEnd;\n\n // sequence data\n return {\n start,\n end,\n first,\n last,\n // Rule is: rangeStart <= rangeEnd <= min(entries)\n min: start || first,\n // Grab last entry if exist else default to rangeEnd\n max: last || end,\n // keep reference to actual sequence entries\n entries,\n };\n }\n\n /**\n * Compares two Locus delta objects and notes unique\n * values contained within baseLoci.\n * @param {LociMetadata} baseLoci\n * @param {LociMetadata} otherLoci\n * @returns {Array.<number>} List of unique sequences\n */\n static getUniqueSequences(baseLoci: any, otherLoci: any) {\n const diff: any = difference(baseLoci.entries, otherLoci.entries);\n\n const {start, end} = otherLoci;\n\n return Parser.getNumbersOutOfRange(diff, start, end);\n }\n\n /**\n * Returns an array of numbers outside of a given range.\n * @param {Array.<number>} list Array to filter\n * @param {number} rangeStart Start of range\n * @param {number} rangeEnd End of range\n * @returns {Array.<number>} Array of numbers sorted ASC\n */\n static getNumbersOutOfRange(list: Array<number>, rangeStart: number, rangeEnd: number) {\n // Collect all numbers if number is outside of specified range\n const output = list.filter((num) => num < rangeStart || num > rangeEnd);\n\n // sort ascending\n return output.sort((a, b) => a - b);\n }\n\n /**\n * Checks if newLoci or workingCopy is invalid.\n * @param {Types~Locus} newLoci\n * @returns {boolean}\n */\n isValidLocus(newLoci) {\n let isValid = false;\n const {isLoci} = Parser;\n\n // one or both objects are not locus delta events\n if (!isLoci(this.workingCopy) || !isLoci(newLoci)) {\n LoggerProxy.logger.info(\n 'Locus-info:parser#processDeltaEvent --> Ignoring non-locus object. workingCopy:',\n this.workingCopy,\n 'newLoci:',\n newLoci\n );\n } else {\n isValid = true;\n }\n\n return isValid;\n }\n\n /**\n * Determines if a paricular locus's sequence is empty\n * @param {Types~Locus} locus\n * @returns {bool}\n */\n static isSequenceEmpty(locus) {\n const {sequence} = locus;\n const hasEmptyEntries = !sequence.entries?.length;\n const hasEmptyRange = sequence.rangeStart === 0 && sequence.rangeEnd === 0;\n\n return hasEmptyEntries && hasEmptyRange;\n }\n\n /**\n * Determines if an object has basic\n * structure of a locus object.\n * @param {Types~Locus} loci\n * @returns {boolean}\n */\n static isLoci(loci) {\n if (!loci || !loci.sequence) {\n return false;\n }\n const hasProp = (prop) => Object.prototype.hasOwnProperty.call(loci.sequence, prop);\n\n if (hasProp('rangeStart') && hasProp('rangeEnd')) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Processes next event in queue,\n * if queue is empty sets status to idle.\n * @returns {undefined}\n */\n nextEvent() {\n if (this.status === 'PAUSED') {\n LoggerProxy.logger.info('Locus-info:parser#nextEvent --> Locus parser paused.');\n\n return;\n }\n\n if (this.status === 'BLOCKED') {\n LoggerProxy.logger.info(\n 'Locus-info:parser#nextEvent --> Locus parser blocked by out-of-order delta.'\n );\n\n return;\n }\n\n // continue processing until queue is empty\n if (this.queue.size() > 0) {\n this.processDeltaEvent();\n } else {\n this.status = 'IDLE';\n }\n }\n\n /**\n * Function handler for delta actions,\n * is set by instance callee.\n * @param {string} action Locus delta action\n * @param {Types~Locus} locus Locus delta\n * @returns {undefined}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onDeltaAction(action: string, locus) {}\n\n /**\n * Event handler for locus delta events\n * @param {Types~Locus} loci Locus Delta\n * @returns {undefined}\n */\n onDeltaEvent(loci) {\n // enqueue the new loci\n this.queue.enqueue(loci);\n\n if (this.onDeltaAction) {\n if (this.status === 'BLOCKED') {\n if (this.queue.size() > MAX_OOO_DELTA_COUNT) {\n this.triggerSync('queue too big, blocked on out-of-order delta');\n } else {\n this.processDeltaEvent();\n }\n } else if (this.status === 'IDLE') {\n // Update status, ensure we only process one event at a time.\n this.status = 'WORKING';\n\n this.processDeltaEvent();\n }\n }\n }\n\n /**\n * Appends new data onto a string of existing data.\n * @param {string} newData\n * @param {string} oldData\n * @returns {string}\n */\n static packComparisonResult(newData: string, oldData: string) {\n return `${newData}:${oldData}`;\n }\n\n /**\n * Pause locus processing\n * @returns {undefined}\n */\n pause() {\n this.status = 'PAUSED';\n LoggerProxy.logger.info('Locus-info:parser#pause --> Locus parser paused.');\n }\n\n /**\n * Triggers a sync with Locus\n *\n * @param {string} reason used just for logging\n * @returns {undefined}\n */\n private triggerSync(reason: string) {\n LoggerProxy.logger.info(`Locus-info:parser#triggerSync --> doing sync, reason: ${reason}`);\n this.stopSyncTimer();\n this.pause();\n this.onDeltaAction(Parser.loci.DESYNC, this.workingCopy);\n }\n\n /**\n * Starts a timer with a random delay. When that timer expires we will do a sync.\n *\n * The main purpose of this timer is to handle a case when we get some out-of-order deltas,\n * so we start waiting to receive the missing delta. If that delta never arrives, this timer\n * will trigger a sync with Locus.\n *\n * @returns {undefined}\n */\n private startSyncTimer() {\n if (this.syncTimer === null) {\n const timeout = OOO_DELTA_WAIT_TIME + Math.random() * OOO_DELTA_WAIT_TIME_RANDOM_DELAY;\n\n this.syncTimer = setTimeout(() => {\n this.syncTimer = null;\n this.triggerSync('timer expired, blocked on out-of-order delta');\n }, timeout);\n }\n }\n\n /**\n * Stops the timer for triggering a sync\n *\n * @returns {undefined}\n */\n private stopSyncTimer() {\n if (this.syncTimer !== null) {\n clearTimeout(this.syncTimer);\n this.syncTimer = null;\n }\n }\n\n /**\n * Processes next locus delta in the queue,\n * continues until the queue is empty\n * or cleared.\n * @returns {undefined}\n */\n processDeltaEvent() {\n const {DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n const newLoci = this.queue.dequeue();\n\n if (!this.isValidLocus(newLoci)) {\n this.nextEvent();\n\n return;\n }\n\n const result = Parser.compare(this.workingCopy, newLoci);\n const lociComparison = extract(result);\n\n // limited debugging, use chrome extension\n // for full debugging.\n LoggerProxy.logger.debug(`Locus-info:parser#processDeltaEvent --> Locus Debug: ${result}`);\n\n let needToWait = false;\n\n if (lociComparison === DESYNC) {\n // wait for desync response\n this.pause();\n } else if (lociComparison === USE_INCOMING) {\n // update working copy for future comparisons.\n // Note: The working copy of parser gets updated in .onFullLocus()\n // and here when USE_INCOMING locus.\n this.workingCopy = newLoci;\n } else if (lociComparison === WAIT) {\n // we've taken newLoci from the front of the queue, so put it back there as we have to wait\n // for the one that should be in front of it, before we can process it\n this.queue.enqueue(newLoci);\n needToWait = true;\n }\n\n if (needToWait) {\n this.status = 'BLOCKED';\n this.startSyncTimer();\n } else {\n this.stopSyncTimer();\n\n if (this.status === 'BLOCKED') {\n // we are not blocked anymore\n this.status = 'WORKING';\n\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> received delta that we were waiting for ${Parser.locus2string(\n newLoci\n )}, not blocked anymore`\n );\n }\n }\n\n if (this.onDeltaAction) {\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> Locus Delta ${Parser.locus2string(\n newLoci\n )}, Action: ${lociComparison}`\n );\n\n this.onDeltaAction(lociComparison, newLoci);\n }\n\n this.nextEvent();\n }\n\n /**\n * Resume from a paused state\n * @returns {undefined}\n */\n resume() {\n LoggerProxy.logger.info('Locus-info:parser#resume --> Locus parser resumed.');\n this.status = 'WORKING';\n this.nextEvent();\n }\n\n /**\n * Gets related debug info for given error code\n * @param {string} debugCode Debug code\n * @param {string} comparison Locus comparison string\n * @returns {object} Debug message\n */\n static getDebugMessage(debugCode: string, comparison: string) {\n // removes extra spaces from multiline string\n const mStr = (strings) => strings.join('').replace(/\\s{2,}/g, ' ');\n\n const resolutionMap = {\n EQ: `${Parser.loci.LT}: is equal (current == incoming).`,\n LT: `${Parser.loci.LT}: choose right side (incoming).`,\n GT: `${Parser.loci.GT}: choose left side (current).`,\n };\n\n const debugMap = {\n SO001: {\n title: 'checkSequenceOverlap-001',\n description: mStr`Occurs if earliest working copy sequence is more \\\n recent than last incoming sequence.`,\n logic: 'current.min > incoming.max',\n },\n\n SO002: {\n title: 'checkSequenceOverlap-002',\n description: mStr`Occurs if last working copy sequence is before the \\\n earliest incoming sequence.`,\n logic: 'current.max < incoming.min',\n },\n\n UR001: {\n title: 'checkUnequalRanges-001',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the current working copy loci has a larger range.`,\n logic: 'currentTotalRange > incomingTotalRange',\n },\n\n UR002: {\n title: 'checkUnequalRanges-002',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the incoming delta loci has a larger range.`,\n logic: 'currentTotalRange < incomingTotalRange',\n },\n\n UR003: {\n title: 'checkUnequalRanges-003',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and with ranges either absent or of the same size, the sequences \\\n are considered equal.`,\n logic: 'currentTotalRange == incomingTotalRange',\n },\n\n UE001: {\n title: 'checkForUniqueEntries-001',\n description: mStr`Occurs if current loci has unique entries and \\\n incoming does not. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: 'currentIsUnique && !incomingIsUnique',\n },\n\n UE002: {\n title: 'checkForUniqueEntries-002',\n description: mStr`Occurs if current has no unique entries but \\\n incoming does. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: '!currentIsUnique && incomingIsUnique',\n },\n\n OOS001: {\n title: 'checkIfOutOfSync-001',\n description: mStr`Occurs if neither sequence has a range, or \\\n if the current loci unique entries overlap the total range of the \\\n incoming sequence, or if the incoming unique entries overlap \\\n the total range of current sequence.`,\n logic: 'neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap',\n },\n\n OOS002: {\n title: 'checkIfOutOfSync-002',\n description: mStr`Occurs if the minimum value from sequences that are \\\n unique to the current loci is greater than the minimum value from \\\n sequences that are unique to the incoming loci.`,\n logic: 'currentUniqueMin > incomingUniqueMin',\n },\n\n OOS003: {\n title: 'checkIfOutOfSync-003',\n description: mStr`Occurs if none of the comparison rules applied. \\\n It is a catch all.`,\n logic: 'else (catch all)',\n },\n };\n\n const debugObj = debugMap[debugCode];\n\n debugObj.title = `Debug: ${debugObj.title}`;\n debugObj.resolution = resolutionMap[comparison];\n\n return debugObj;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA;AACA;AAEA;AACA;AAAsD;AAEtD,IAAMA,mB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aCompareFunc","left","right","loci","LT","GT","extract","extractComparisonState","isSequenceEmpty","result","compareSequence","baseSequence","queue","SortedQueue","status","onDeltaAction","workingCopy","syncTimer","incomingFullDto","isLoci","LoggerProxy","logger","info","comparisonResult","compareFullDtoSequence","USE_INCOMING","newLoci","isValid","size","processDeltaEvent","action","locus","enqueue","triggerSync","reason","stopSyncTimer","pause","DESYNC","timeout","Math","random","setTimeout","clearTimeout","WAIT","LOCUS_URL_CHANGED","dequeue","isValidLocus","nextEvent","compare","lociComparison","debug","needToWait","startSyncTimer","locus2string","sequence","entries","length","at","current","incoming","comparison","min","max","currentIsNotUnique","unique","incomingIsNotUnique","currentTotalRange","end","incomingTotalRange","EQ","currentIsUnique","incomingIsUnique","currentUniqueMin","incomingUniqueMin","currentHasNoRange","start","incomingHasNoRange","neitherSeqHasRange","hasUniqOverlap","list","some","seq","currentUniqOverlap","incomingUniqOverlap","debugInfo","pack","packComparisonResult","compareDelta","compareToAction","url","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","LOCUS_DELTA_OUT_OF_ORDER","stack","Error","slice","USE_CURRENT","local","getMetaData","delta","getUniqueSequences","rules","checkSequenceOverlap","checkUnequalRanges","checkForUniqueEntries","checkIfOutOfSync","rule","ERROR","lociComparisonResult","split","first","last","rangeStart","rangeEnd","baseLoci","otherLoci","diff","getNumbersOutOfRange","output","filter","num","sort","a","b","hasEmptyEntries","hasEmptyRange","hasProp","prop","Object","prototype","hasOwnProperty","call","newData","oldData","debugCode","mStr","strings","join","replace","resolutionMap","debugMap","SO001","title","description","logic","SO002","UR001","UR002","UR003","UE001","UE002","OOS001","OOS002","OOS003","debugObj","resolution"],"sources":["parser.ts"],"sourcesContent":["import {difference} from 'lodash';\n\nimport SortedQueue from '../common/queue';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport Metrics from '../metrics';\nimport BEHAVIORAL_METRICS from '../metrics/constants';\n\nconst MAX_OOO_DELTA_COUNT = 5; // when we receive an out-of-order delta and the queue builds up to MAX_OOO_DELTA_COUNT, we do a sync with Locus\nconst OOO_DELTA_WAIT_TIME = 10000; // [ms] minimum wait time before we do a sync if we get out-of-order deltas\nconst OOO_DELTA_WAIT_TIME_RANDOM_DELAY = 5000; // [ms] max random delay added to OOO_DELTA_WAIT_TIME\n\ntype LocusDeltaDto = {\n url: string;\n baseSequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n sequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n syncUrl: string;\n};\n\n/**\n * Locus Delta Parser\n * @private\n * https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Delta-Events\n */\nexport default class Parser {\n // processing status\n status:\n | 'IDLE' // not doing anything\n | 'PAUSED' // paused, because we are doing a sync\n | 'WORKING' // processing a delta event\n | 'BLOCKED'; // received an out-of-order delta, so waiting for the missing one\n\n // loci comparison states\n static loci = {\n EQ: 'EQUAL',\n GT: 'GREATER_THAN',\n LT: 'LESS_THAN',\n DESYNC: 'DESYNC',\n USE_INCOMING: 'USE_INCOMING',\n USE_CURRENT: 'USE_CURRENT',\n WAIT: 'WAIT',\n ERROR: 'ERROR',\n LOCUS_URL_CHANGED: 'LOCUS_URL_CHANGED',\n };\n\n queue: SortedQueue<LocusDeltaDto>;\n workingCopy: any;\n syncTimer: null | number | NodeJS.Timeout;\n\n /**\n * @constructs Parser\n */\n constructor() {\n const deltaCompareFunc = (left: LocusDeltaDto, right: LocusDeltaDto) => {\n const {LT, GT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n\n if (Parser.isSequenceEmpty(left)) {\n return -1;\n }\n if (Parser.isSequenceEmpty(right)) {\n return 1;\n }\n const result = extract(Parser.compareSequence(left.baseSequence, right.baseSequence));\n\n if (result === LT) {\n return -1;\n }\n if (result === GT) {\n return 1;\n }\n\n return 0;\n };\n\n this.queue = new SortedQueue<LocusDeltaDto>(deltaCompareFunc);\n this.status = 'IDLE';\n this.onDeltaAction = null;\n this.workingCopy = null;\n this.syncTimer = null;\n }\n\n /**\n * Returns a debug string representing a locus delta - useful for logging\n *\n * @param {LocusDeltaDto} locus Locus delta\n * @returns {string}\n */\n static locus2string(locus: LocusDeltaDto) {\n if (!locus.sequence?.entries) {\n return 'invalid';\n }\n\n return locus.sequence.entries.length ? `seq=${locus.sequence.entries.at(-1)}` : 'empty';\n }\n\n /**\n * Checks if two sequences overlap in time,\n * the sequence with the higher minimum value is greater.\n * Chooses sequence with most recent data.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkSequenceOverlap(current, incoming) {\n let comparison = null;\n\n // if earliest working copy sequence is more recent than last incoming sequence\n if (current.min > incoming.max) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:SO001`;\n }\n // if last working copy sequence is before the earliest incoming sequence\n else if (current.max < incoming.min) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:SO002`;\n }\n\n // if no match above, defaults to null\n return comparison;\n }\n\n /**\n * Checks if two sequences have unequal ranges.\n * Chooses sequence with most larger range.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {object} loci comparison\n */\n static checkUnequalRanges(current, incoming) {\n let comparison = null;\n const currentIsNotUnique = current.unique.length === 0;\n const incomingIsNotUnique = incoming.unique.length === 0;\n const currentTotalRange = current.end - current.min;\n const incomingTotalRange = incoming.end - incoming.min;\n\n // no unique values for both loci\n if (currentIsNotUnique && incomingIsNotUnique) {\n // current working copy loci has a larger range\n if (currentTotalRange > incomingTotalRange) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UR001`;\n }\n // incoming delta loci has a larger range\n else if (currentTotalRange < incomingTotalRange) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UR002`;\n } else {\n // with no unique entries and with ranges either absent or\n // of the same size, the sequences are considered equal.\n comparison = `${Parser.loci.EQ}:UR003`;\n }\n }\n\n return comparison;\n }\n\n /**\n * Checks if either sequences has unique entries.\n * Entries are considered unique if they do not overlap\n * with other Loci sequences or range values.\n * Chooses sequence with the unique entries.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkForUniqueEntries(current, incoming) {\n let comparison = null;\n const currentIsUnique = current.unique.length > 0;\n const incomingIsUnique = incoming.unique.length > 0;\n\n // current has unique entries and incoming does not\n if (currentIsUnique && !incomingIsUnique) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UE001`;\n }\n // current has no unique entries but incoming does\n else if (!currentIsUnique && incomingIsUnique) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UE002`;\n }\n\n return comparison;\n }\n\n /**\n * Checks both Locus Delta objects to see if they are\n * out of sync with one another. If so sends a DESYNC\n * request to the server.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkIfOutOfSync(current, incoming) {\n let comparison = null;\n const currentUniqueMin = current.unique[0];\n const incomingUniqueMin = incoming.unique[0];\n\n const currentHasNoRange = !current.start && !current.end;\n const incomingHasNoRange = !incoming.start && !incoming.end;\n const neitherSeqHasRange = currentHasNoRange && incomingHasNoRange;\n\n const hasUniqOverlap = (list, min, max) => list.some((seq) => min < seq && seq < max);\n // current unique entries overlap the total range of incoming\n const currentUniqOverlap = hasUniqOverlap(current.unique, incoming.min, incoming.max);\n // vice-versa, incoming unique entries overlap the total range of current\n const incomingUniqOverlap = hasUniqOverlap(incoming.unique, current.min, current.max);\n\n if (neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap) {\n // outputs string indicating which condition occurred. ex: 0,1,0\n const debugInfo = `${+neitherSeqHasRange},${+currentUniqOverlap},${+incomingUniqOverlap}`;\n\n // send DESYNC to server\n comparison = `${Parser.loci.DESYNC}:OOS001:${debugInfo}`;\n } else if (currentUniqueMin > incomingUniqueMin) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:OOS002`;\n } else {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:OOS003`;\n }\n\n return comparison;\n }\n\n /**\n * Compares two loci to determine which one contains the most recent state\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static compare(current, incoming) {\n const {isSequenceEmpty} = Parser;\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n if (isSequenceEmpty(current) || isSequenceEmpty(incoming)) {\n return pack(Parser.loci.USE_INCOMING, 'C001');\n }\n\n if (incoming.baseSequence) {\n return pack(Parser.compareDelta(current, incoming), 'C002');\n }\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n const action = Parser.compareToAction(extract(result));\n\n return pack(action, result);\n }\n\n /**\n * Compares two loci sequences (with delta params) and indicates what action\n * to take.\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @private\n * @returns {string} loci comparison state\n */\n private static compareDelta(current, incoming) {\n const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = Parser.loci;\n\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n let comparison = extract(result);\n\n if (comparison !== LT) {\n return pack(Parser.compareToAction(comparison), result);\n }\n\n if (incoming.url !== current.url) {\n // when moving to/from a breakout session, the locus URL will change and also\n // the baseSequence, making incoming and current incomparable, so use a\n // unique comparison state\n return pack(LOCUS_URL_CHANGED, result);\n }\n\n comparison = Parser.compareSequence(current.sequence, incoming.baseSequence);\n\n switch (extract(comparison)) {\n case GT:\n case EQ:\n comparison = USE_INCOMING;\n break;\n\n case LT:\n if (extract(Parser.compareSequence(incoming.baseSequence, incoming.sequence)) === EQ) {\n // special case where Locus sends a delta with baseSequence === sequence to trigger a sync,\n // because the delta event is too large to be sent over mercury connection\n comparison = DESYNC;\n } else {\n // the incoming locus has baseSequence from the future, so it is out-of-order,\n // we are missing 1 or more locus that should be in front of it, we need to wait for it\n comparison = WAIT;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LOCUS_DELTA_OUT_OF_ORDER, {\n stack: new Error().stack,\n });\n }\n break;\n default:\n comparison = DESYNC;\n }\n\n return pack(comparison, result);\n }\n\n /**\n * Compares Locus sequences - it should be called only for full Locus DTOs, not deltas\n *\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n static compareFullDtoSequence(current, incomingFullDto) {\n if (Parser.isSequenceEmpty(current) || Parser.isSequenceEmpty(incomingFullDto)) {\n return Parser.loci.USE_INCOMING;\n }\n\n // the sequence.entries list will always contain at least 1 entry\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n return incomingFullDto.sequence.entries.slice(-1)[0] > current.sequence.entries.slice(-1)[0]\n ? Parser.loci.USE_INCOMING\n : Parser.loci.USE_CURRENT;\n }\n\n /**\n * Returns true if the incoming full locus DTO is newer than the current working copy\n *\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n isNewFullLocus(incomingFullDto) {\n if (!Parser.isLoci(incomingFullDto)) {\n LoggerProxy.logger.info('Locus-info:parser#isNewFullLocus --> Ignoring non-locus object.');\n\n return false;\n }\n\n if (!this.workingCopy) {\n // we don't have a working copy yet, so any full locus is better than nothing\n return true;\n }\n\n const comparisonResult = Parser.compareFullDtoSequence(this.workingCopy, incomingFullDto);\n\n return comparisonResult === Parser.loci.USE_INCOMING;\n }\n\n /**\n * Compares Locus sequences\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incoming New Locus delta\n * @returns {string}\n */\n static compareSequence(current, incoming) {\n // Locus sequence comparison rules in order of priority.\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n const local: any = Parser.getMetaData(current);\n const delta: any = Parser.getMetaData(incoming);\n\n // update loci metadata\n local.unique = Parser.getUniqueSequences(local, delta);\n delta.unique = Parser.getUniqueSequences(delta, local);\n\n // Locus sequence comparison rules\n // order matters\n const rules = [\n Parser.checkSequenceOverlap,\n Parser.checkUnequalRanges,\n Parser.checkForUniqueEntries,\n Parser.checkIfOutOfSync,\n ];\n\n for (const rule of rules) {\n // Rule only returns a value if the rule applies,\n // otherwise returns null.\n const result = rule(local, delta);\n\n if (result) {\n return result;\n }\n }\n\n // error, none of rules above applied\n // should never get here as last rule\n // should be catch all.\n return Parser.loci.ERROR;\n }\n\n /**\n * Transates the result of a sequence comparison into an intended behavior\n * @param {string} result\n * @returns {string} Locus comparison action\n */\n static compareToAction(result: string) {\n const {DESYNC, EQ, ERROR, GT, LT, USE_CURRENT, USE_INCOMING} = Parser.loci;\n\n let action = ERROR;\n\n switch (result) {\n case EQ:\n case GT:\n action = USE_CURRENT;\n break;\n case LT:\n action = USE_INCOMING;\n break;\n case DESYNC:\n action = DESYNC;\n break;\n default:\n LoggerProxy.logger.info(\n `Locus-info:parser#compareToAction --> Error: ${result} is not a recognized sequence comparison result.`\n );\n }\n\n return action;\n }\n\n /**\n * Extracts a loci comparison from a string of data.\n * @param {string} lociComparisonResult Comparison result with extra data\n * @returns {string} Comparison of EQ, LT, GT, or DESYNC.\n */\n static extractComparisonState(lociComparisonResult: string) {\n return lociComparisonResult.split(':')[0];\n }\n\n /**\n * @typedef {object} LociMetadata\n * @property {number} start - Starting sequence number\n * @property {number} end - Ending sequence number\n * @property {number} first - First sequence number\n * @property {number} last - Last sequence number\n * @property {number} min - Minimum sequence number\n * @property {number} max - Maximum sequence number\n * @property {number} entries - Loci sequence entries\n */\n\n /**\n * Metadata for Locus delta\n * @param {Array.<number>} sequence Locus delta sequence\n * @returns {LociMetadata} Locus Delta Metadata\n */\n static getMetaData(sequence: any) {\n const {entries} = sequence;\n const first = entries[0];\n const last = entries.slice(-1)[0];\n\n // rangeStart or rangeEnd is 0 if a range doesn't exist\n const start = sequence.rangeStart;\n const end = sequence.rangeEnd;\n\n // sequence data\n return {\n start,\n end,\n first,\n last,\n // Rule is: rangeStart <= rangeEnd <= min(entries)\n min: start || first,\n // Grab last entry if exist else default to rangeEnd\n max: last || end,\n // keep reference to actual sequence entries\n entries,\n };\n }\n\n /**\n * Compares two Locus delta objects and notes unique\n * values contained within baseLoci.\n * @param {LociMetadata} baseLoci\n * @param {LociMetadata} otherLoci\n * @returns {Array.<number>} List of unique sequences\n */\n static getUniqueSequences(baseLoci: any, otherLoci: any) {\n const diff: any = difference(baseLoci.entries, otherLoci.entries);\n\n const {start, end} = otherLoci;\n\n return Parser.getNumbersOutOfRange(diff, start, end);\n }\n\n /**\n * Returns an array of numbers outside of a given range.\n * @param {Array.<number>} list Array to filter\n * @param {number} rangeStart Start of range\n * @param {number} rangeEnd End of range\n * @returns {Array.<number>} Array of numbers sorted ASC\n */\n static getNumbersOutOfRange(list: Array<number>, rangeStart: number, rangeEnd: number) {\n // Collect all numbers if number is outside of specified range\n const output = list.filter((num) => num < rangeStart || num > rangeEnd);\n\n // sort ascending\n return output.sort((a, b) => a - b);\n }\n\n /**\n * Checks if newLoci or workingCopy is invalid.\n * @param {Types~Locus} newLoci\n * @returns {boolean}\n */\n isValidLocus(newLoci) {\n let isValid = false;\n const {isLoci} = Parser;\n\n // one or both objects are not locus delta events\n if (!isLoci(this.workingCopy) || !isLoci(newLoci)) {\n LoggerProxy.logger.info(\n 'Locus-info:parser#processDeltaEvent --> Ignoring non-locus object. workingCopy:',\n this.workingCopy,\n 'newLoci:',\n newLoci\n );\n } else {\n isValid = true;\n }\n\n return isValid;\n }\n\n /**\n * Determines if a paricular locus's sequence is empty\n * @param {Types~Locus} locus\n * @returns {bool}\n */\n static isSequenceEmpty(locus) {\n const {sequence} = locus;\n const hasEmptyEntries = !sequence.entries?.length;\n const hasEmptyRange = sequence.rangeStart === 0 && sequence.rangeEnd === 0;\n\n return hasEmptyEntries && hasEmptyRange;\n }\n\n /**\n * Determines if an object has basic\n * structure of a locus object.\n * @param {Types~Locus} loci\n * @returns {boolean}\n */\n static isLoci(loci) {\n if (!loci || !loci.sequence) {\n return false;\n }\n const hasProp = (prop) => Object.prototype.hasOwnProperty.call(loci.sequence, prop);\n\n if (hasProp('rangeStart') && hasProp('rangeEnd')) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Processes next event in queue,\n * if queue is empty sets status to idle.\n * @returns {undefined}\n */\n nextEvent() {\n if (this.status === 'PAUSED') {\n LoggerProxy.logger.info('Locus-info:parser#nextEvent --> Locus parser paused.');\n\n return;\n }\n\n if (this.status === 'BLOCKED') {\n LoggerProxy.logger.info(\n 'Locus-info:parser#nextEvent --> Locus parser blocked by out-of-order delta.'\n );\n\n return;\n }\n\n // continue processing until queue is empty\n if (this.queue.size() > 0) {\n this.processDeltaEvent();\n } else {\n this.status = 'IDLE';\n }\n }\n\n /**\n * Function handler for delta actions,\n * is set by instance callee.\n * @param {string} action Locus delta action\n * @param {Types~Locus} locus Locus delta\n * @returns {undefined}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onDeltaAction(action: string, locus) {}\n\n /**\n * Event handler for locus delta events\n * @param {Types~Locus} loci Locus Delta\n * @returns {undefined}\n */\n onDeltaEvent(loci) {\n // enqueue the new loci\n this.queue.enqueue(loci);\n\n if (this.onDeltaAction) {\n if (this.status === 'BLOCKED') {\n if (this.queue.size() > MAX_OOO_DELTA_COUNT) {\n this.triggerSync('queue too big, blocked on out-of-order delta');\n } else {\n this.processDeltaEvent();\n }\n } else if (this.status === 'IDLE') {\n // Update status, ensure we only process one event at a time.\n this.status = 'WORKING';\n\n this.processDeltaEvent();\n }\n }\n }\n\n /**\n * Appends new data onto a string of existing data.\n * @param {string} newData\n * @param {string} oldData\n * @returns {string}\n */\n static packComparisonResult(newData: string, oldData: string) {\n return `${newData}:${oldData}`;\n }\n\n /**\n * Pause locus processing\n * @returns {undefined}\n */\n pause() {\n this.status = 'PAUSED';\n LoggerProxy.logger.info('Locus-info:parser#pause --> Locus parser paused.');\n }\n\n /**\n * Triggers a sync with Locus\n *\n * @param {string} reason used just for logging\n * @returns {undefined}\n */\n private triggerSync(reason: string) {\n LoggerProxy.logger.info(`Locus-info:parser#triggerSync --> doing sync, reason: ${reason}`);\n this.stopSyncTimer();\n this.pause();\n this.onDeltaAction(Parser.loci.DESYNC, this.workingCopy);\n }\n\n /**\n * Starts a timer with a random delay. When that timer expires we will do a sync.\n *\n * The main purpose of this timer is to handle a case when we get some out-of-order deltas,\n * so we start waiting to receive the missing delta. If that delta never arrives, this timer\n * will trigger a sync with Locus.\n *\n * @returns {undefined}\n */\n private startSyncTimer() {\n if (this.syncTimer === null) {\n const timeout = OOO_DELTA_WAIT_TIME + Math.random() * OOO_DELTA_WAIT_TIME_RANDOM_DELAY;\n\n this.syncTimer = setTimeout(() => {\n this.syncTimer = null;\n this.triggerSync('timer expired, blocked on out-of-order delta');\n }, timeout);\n }\n }\n\n /**\n * Stops the timer for triggering a sync\n *\n * @returns {undefined}\n */\n private stopSyncTimer() {\n if (this.syncTimer !== null) {\n clearTimeout(this.syncTimer);\n this.syncTimer = null;\n }\n }\n\n /**\n * Processes next locus delta in the queue,\n * continues until the queue is empty\n * or cleared.\n * @returns {undefined}\n */\n processDeltaEvent() {\n const {DESYNC, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n const newLoci = this.queue.dequeue();\n\n if (!this.isValidLocus(newLoci)) {\n this.nextEvent();\n\n return;\n }\n\n const result = Parser.compare(this.workingCopy, newLoci);\n const lociComparison = extract(result);\n\n // limited debugging, use chrome extension\n // for full debugging.\n LoggerProxy.logger.debug(`Locus-info:parser#processDeltaEvent --> Locus Debug: ${result}`);\n\n let needToWait = false;\n\n switch (lociComparison) {\n case DESYNC:\n // wait for desync response\n this.pause();\n break;\n\n case USE_INCOMING:\n case LOCUS_URL_CHANGED:\n // update working copy for future comparisons.\n // Note: The working copy of parser gets updated in .onFullLocus()\n // and here when USE_INCOMING or LOCUS_URL_CHANGED locus.\n this.workingCopy = newLoci;\n break;\n\n case WAIT:\n // we've taken newLoci from the front of the queue, so put it back there as we have to wait\n // for the one that should be in front of it, before we can process it\n this.queue.enqueue(newLoci);\n needToWait = true;\n break;\n\n default:\n break;\n }\n\n if (needToWait) {\n this.status = 'BLOCKED';\n this.startSyncTimer();\n } else {\n this.stopSyncTimer();\n\n if (this.status === 'BLOCKED') {\n // we are not blocked anymore\n this.status = 'WORKING';\n\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> received delta that we were waiting for ${Parser.locus2string(\n newLoci\n )}, not blocked anymore`\n );\n }\n }\n\n if (this.onDeltaAction) {\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> Locus Delta ${Parser.locus2string(\n newLoci\n )}, Action: ${lociComparison}`\n );\n\n this.onDeltaAction(lociComparison, newLoci);\n }\n\n this.nextEvent();\n }\n\n /**\n * Resume from a paused state\n * @returns {undefined}\n */\n resume() {\n LoggerProxy.logger.info('Locus-info:parser#resume --> Locus parser resumed.');\n this.status = 'WORKING';\n this.nextEvent();\n }\n\n /**\n * Gets related debug info for given error code\n * @param {string} debugCode Debug code\n * @param {string} comparison Locus comparison string\n * @returns {object} Debug message\n */\n static getDebugMessage(debugCode: string, comparison: string) {\n // removes extra spaces from multiline string\n const mStr = (strings) => strings.join('').replace(/\\s{2,}/g, ' ');\n\n const resolutionMap = {\n EQ: `${Parser.loci.LT}: is equal (current == incoming).`,\n LT: `${Parser.loci.LT}: choose right side (incoming).`,\n GT: `${Parser.loci.GT}: choose left side (current).`,\n };\n\n const debugMap = {\n SO001: {\n title: 'checkSequenceOverlap-001',\n description: mStr`Occurs if earliest working copy sequence is more \\\n recent than last incoming sequence.`,\n logic: 'current.min > incoming.max',\n },\n\n SO002: {\n title: 'checkSequenceOverlap-002',\n description: mStr`Occurs if last working copy sequence is before the \\\n earliest incoming sequence.`,\n logic: 'current.max < incoming.min',\n },\n\n UR001: {\n title: 'checkUnequalRanges-001',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the current working copy loci has a larger range.`,\n logic: 'currentTotalRange > incomingTotalRange',\n },\n\n UR002: {\n title: 'checkUnequalRanges-002',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the incoming delta loci has a larger range.`,\n logic: 'currentTotalRange < incomingTotalRange',\n },\n\n UR003: {\n title: 'checkUnequalRanges-003',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and with ranges either absent or of the same size, the sequences \\\n are considered equal.`,\n logic: 'currentTotalRange == incomingTotalRange',\n },\n\n UE001: {\n title: 'checkForUniqueEntries-001',\n description: mStr`Occurs if current loci has unique entries and \\\n incoming does not. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: 'currentIsUnique && !incomingIsUnique',\n },\n\n UE002: {\n title: 'checkForUniqueEntries-002',\n description: mStr`Occurs if current has no unique entries but \\\n incoming does. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: '!currentIsUnique && incomingIsUnique',\n },\n\n OOS001: {\n title: 'checkIfOutOfSync-001',\n description: mStr`Occurs if neither sequence has a range, or \\\n if the current loci unique entries overlap the total range of the \\\n incoming sequence, or if the incoming unique entries overlap \\\n the total range of current sequence.`,\n logic: 'neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap',\n },\n\n OOS002: {\n title: 'checkIfOutOfSync-002',\n description: mStr`Occurs if the minimum value from sequences that are \\\n unique to the current loci is greater than the minimum value from \\\n sequences that are unique to the incoming loci.`,\n logic: 'currentUniqueMin > incomingUniqueMin',\n },\n\n OOS003: {\n title: 'checkIfOutOfSync-003',\n description: mStr`Occurs if none of the comparison rules applied. \\\n It is a catch all.`,\n logic: 'else (catch all)',\n },\n };\n\n const debugObj = debugMap[debugCode];\n\n debugObj.title = `Debug: ${debugObj.title}`;\n debugObj.resolution = resolutionMap[comparison];\n\n return debugObj;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA;AACA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AM,EAAE,QAAQ;EAChBZ,YAAY,EAAE,cAAc;EAC5BwE,WAAW,EAAE,aAAa;EAC1BtD,IAAI,EAAE,MAAM;EACZiE,KAAK,EAAE,OAAO;EACdhE,iBAAiB,EAAE;AACrB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import SortedQueue from '../common/queue';
3
3
  type LocusDeltaDto = {
4
+ url: string;
4
5
  baseSequence: {
5
6
  rangeStart: number;
6
7
  rangeEnd: number;
@@ -29,6 +30,7 @@ export default class Parser {
29
30
  USE_CURRENT: string;
30
31
  WAIT: string;
31
32
  ERROR: string;
33
+ LOCUS_URL_CHANGED: string;
32
34
  };
33
35
  queue: SortedQueue<LocusDeltaDto>;
34
36
  workingCopy: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-meetings",
3
- "version": "3.0.0-beta.274",
3
+ "version": "3.0.0-beta.276",
4
4
  "description": "",
5
5
  "license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
6
6
  "contributors": [
@@ -32,12 +32,12 @@
32
32
  "build": "yarn run -T tsc --declaration true --declarationDir ./dist/types"
33
33
  },
34
34
  "devDependencies": {
35
- "@webex/plugin-meetings": "3.0.0-beta.274",
36
- "@webex/test-helper-chai": "3.0.0-beta.274",
37
- "@webex/test-helper-mocha": "3.0.0-beta.274",
38
- "@webex/test-helper-mock-webex": "3.0.0-beta.274",
39
- "@webex/test-helper-retry": "3.0.0-beta.274",
40
- "@webex/test-helper-test-users": "3.0.0-beta.274",
35
+ "@webex/plugin-meetings": "3.0.0-beta.276",
36
+ "@webex/test-helper-chai": "3.0.0-beta.276",
37
+ "@webex/test-helper-mocha": "3.0.0-beta.276",
38
+ "@webex/test-helper-mock-webex": "3.0.0-beta.276",
39
+ "@webex/test-helper-retry": "3.0.0-beta.276",
40
+ "@webex/test-helper-test-users": "3.0.0-beta.276",
41
41
  "chai": "^4.3.4",
42
42
  "chai-as-promised": "^7.1.1",
43
43
  "jsdom-global": "3.0.2",
@@ -46,19 +46,19 @@
46
46
  "typescript": "^4.7.4"
47
47
  },
48
48
  "dependencies": {
49
- "@webex/common": "3.0.0-beta.274",
50
- "@webex/internal-media-core": "2.0.4",
51
- "@webex/internal-plugin-conversation": "3.0.0-beta.274",
52
- "@webex/internal-plugin-device": "3.0.0-beta.274",
53
- "@webex/internal-plugin-llm": "3.0.0-beta.274",
54
- "@webex/internal-plugin-mercury": "3.0.0-beta.274",
55
- "@webex/internal-plugin-metrics": "3.0.0-beta.274",
56
- "@webex/internal-plugin-support": "3.0.0-beta.274",
57
- "@webex/internal-plugin-user": "3.0.0-beta.274",
58
- "@webex/media-helpers": "3.0.0-beta.274",
59
- "@webex/plugin-people": "3.0.0-beta.274",
60
- "@webex/plugin-rooms": "3.0.0-beta.274",
61
- "@webex/webex-core": "3.0.0-beta.274",
49
+ "@webex/common": "3.0.0-beta.276",
50
+ "@webex/internal-media-core": "2.0.6",
51
+ "@webex/internal-plugin-conversation": "3.0.0-beta.276",
52
+ "@webex/internal-plugin-device": "3.0.0-beta.276",
53
+ "@webex/internal-plugin-llm": "3.0.0-beta.276",
54
+ "@webex/internal-plugin-mercury": "3.0.0-beta.276",
55
+ "@webex/internal-plugin-metrics": "3.0.0-beta.276",
56
+ "@webex/internal-plugin-support": "3.0.0-beta.276",
57
+ "@webex/internal-plugin-user": "3.0.0-beta.276",
58
+ "@webex/media-helpers": "3.0.0-beta.276",
59
+ "@webex/plugin-people": "3.0.0-beta.276",
60
+ "@webex/plugin-rooms": "3.0.0-beta.276",
61
+ "@webex/webex-core": "3.0.0-beta.276",
62
62
  "ampersand-collection": "^2.0.2",
63
63
  "bowser": "^2.11.0",
64
64
  "btoa": "^1.2.1",
@@ -169,7 +169,7 @@ export default class LocusInfo extends EventsScope {
169
169
  * @returns {undefined}
170
170
  */
171
171
  applyLocusDeltaData(action: string, locus: any, meeting: any) {
172
- const {DESYNC, USE_CURRENT, USE_INCOMING, WAIT} = LocusDeltaParser.loci;
172
+ const {DESYNC, USE_CURRENT, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = LocusDeltaParser.loci;
173
173
 
174
174
  switch (action) {
175
175
  case USE_INCOMING:
@@ -180,6 +180,7 @@ export default class LocusInfo extends EventsScope {
180
180
  // do nothing
181
181
  break;
182
182
  case DESYNC:
183
+ case LOCUS_URL_CHANGED:
183
184
  this.doLocusSync(meeting);
184
185
  break;
185
186
  default:
@@ -11,6 +11,7 @@ const OOO_DELTA_WAIT_TIME = 10000; // [ms] minimum wait time before we do a sync
11
11
  const OOO_DELTA_WAIT_TIME_RANDOM_DELAY = 5000; // [ms] max random delay added to OOO_DELTA_WAIT_TIME
12
12
 
13
13
  type LocusDeltaDto = {
14
+ url: string;
14
15
  baseSequence: {
15
16
  rangeStart: number;
16
17
  rangeEnd: number;
@@ -47,6 +48,7 @@ export default class Parser {
47
48
  USE_CURRENT: 'USE_CURRENT',
48
49
  WAIT: 'WAIT',
49
50
  ERROR: 'ERROR',
51
+ LOCUS_URL_CHANGED: 'LOCUS_URL_CHANGED',
50
52
  };
51
53
 
52
54
  queue: SortedQueue<LocusDeltaDto>;
@@ -267,7 +269,7 @@ export default class Parser {
267
269
  * @returns {string} loci comparison state
268
270
  */
269
271
  private static compareDelta(current, incoming) {
270
- const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT} = Parser.loci;
272
+ const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = Parser.loci;
271
273
 
272
274
  const {extractComparisonState: extract} = Parser;
273
275
  const {packComparisonResult: pack} = Parser;
@@ -279,6 +281,13 @@ export default class Parser {
279
281
  return pack(Parser.compareToAction(comparison), result);
280
282
  }
281
283
 
284
+ if (incoming.url !== current.url) {
285
+ // when moving to/from a breakout session, the locus URL will change and also
286
+ // the baseSequence, making incoming and current incomparable, so use a
287
+ // unique comparison state
288
+ return pack(LOCUS_URL_CHANGED, result);
289
+ }
290
+
282
291
  comparison = Parser.compareSequence(current.sequence, incoming.baseSequence);
283
292
 
284
293
  switch (extract(comparison)) {
@@ -693,7 +702,7 @@ export default class Parser {
693
702
  * @returns {undefined}
694
703
  */
695
704
  processDeltaEvent() {
696
- const {DESYNC, USE_INCOMING, WAIT} = Parser.loci;
705
+ const {DESYNC, USE_INCOMING, WAIT, LOCUS_URL_CHANGED} = Parser.loci;
697
706
  const {extractComparisonState: extract} = Parser;
698
707
  const newLoci = this.queue.dequeue();
699
708
 
@@ -712,19 +721,29 @@ export default class Parser {
712
721
 
713
722
  let needToWait = false;
714
723
 
715
- if (lociComparison === DESYNC) {
716
- // wait for desync response
717
- this.pause();
718
- } else if (lociComparison === USE_INCOMING) {
719
- // update working copy for future comparisons.
720
- // Note: The working copy of parser gets updated in .onFullLocus()
721
- // and here when USE_INCOMING locus.
722
- this.workingCopy = newLoci;
723
- } else if (lociComparison === WAIT) {
724
- // we've taken newLoci from the front of the queue, so put it back there as we have to wait
725
- // for the one that should be in front of it, before we can process it
726
- this.queue.enqueue(newLoci);
727
- needToWait = true;
724
+ switch (lociComparison) {
725
+ case DESYNC:
726
+ // wait for desync response
727
+ this.pause();
728
+ break;
729
+
730
+ case USE_INCOMING:
731
+ case LOCUS_URL_CHANGED:
732
+ // update working copy for future comparisons.
733
+ // Note: The working copy of parser gets updated in .onFullLocus()
734
+ // and here when USE_INCOMING or LOCUS_URL_CHANGED locus.
735
+ this.workingCopy = newLoci;
736
+ break;
737
+
738
+ case WAIT:
739
+ // we've taken newLoci from the front of the queue, so put it back there as we have to wait
740
+ // for the one that should be in front of it, before we can process it
741
+ this.queue.enqueue(newLoci);
742
+ needToWait = true;
743
+ break;
744
+
745
+ default:
746
+ break;
728
747
  }
729
748
 
730
749
  if (needToWait) {
@@ -1884,6 +1884,27 @@ describe('plugin-meetings', () => {
1884
1884
  });
1885
1885
  });
1886
1886
 
1887
+ it('applyLocusDeltaData handles LOCUS_URL_CHANGED action correctly', () => {
1888
+ const {LOCUS_URL_CHANGED} = LocusDeltaParser.loci;
1889
+ const fakeDeltaLocus = {id: 'fake delta locus'};
1890
+ const meeting = {
1891
+ meetingRequest: {
1892
+ getLocusDTO: sandbox.stub().resolves({body: fakeDeltaLocus}),
1893
+ },
1894
+ locusInfo: {
1895
+ handleLocusDelta: sandbox.stub(),
1896
+ },
1897
+ locusUrl: 'current locus url',
1898
+ };
1899
+
1900
+ locusInfo.locusParser.workingCopy = {
1901
+ syncUrl: 'current sync url',
1902
+ };
1903
+
1904
+ locusInfo.applyLocusDeltaData(LOCUS_URL_CHANGED, fakeLocus, meeting);
1905
+ assert.calledOnceWithExactly(meeting.meetingRequest.getLocusDTO, {url: 'current sync url'});
1906
+ });
1907
+
1887
1908
  describe('edge cases for sync failing', () => {
1888
1909
  const {DESYNC} = LocusDeltaParser.loci;
1889
1910
  const fakeFullLocusDto = {id: 'fake full locus dto'};
@@ -517,6 +517,22 @@
517
517
  "new": "seq4g",
518
518
  "result": "DESYNC",
519
519
  "description": "New seq is greater than current, but both current and new base have some unique entries."
520
+ },
521
+ "updt25": {
522
+ "current": "seq4",
523
+ "newbase": "seq5c",
524
+ "new": "seq5b",
525
+ "result": "WAIT",
526
+ "description": "Both new seq and new base are newer than current but are not equal"
527
+ },
528
+ "updt26": {
529
+ "current": "seq4",
530
+ "currentUrl": "locus url 1",
531
+ "newbase": "seq5c",
532
+ "new": "seq5b",
533
+ "newUrl": "locus url 2",
534
+ "result": "LOCUS_URL_CHANGED",
535
+ "description": "Locus url changes in incoming"
520
536
  }
521
537
  }
522
538
  }