get(path, parsed = true) { if (parsed) { const value = get(this.parsed, path, null) if (value == null) { const keys = path.split('.') const key = last(keys) return get(this.parsed.default, key) } return value } else { return get(this.data, path) } }
const mapChanges = (changes, side, toValue) => { if (!changes.length) { return []; } const computeLineNumber = side === 'old' ? computeOldLineNumber : computeNewLineNumber; const changesByLineNumber = keyBy(changes, computeLineNumber); const maxLineNumber = computeLineNumber(last(changes)); return Array.from({length: maxLineNumber}).map((value, i) => toValue(changesByLineNumber[i + 1])); }
/** * Create a new message instance which will have any default values set on * the interface by any applicable setters exposed publically. Optionally, API * key and User Id can be supplied at function invocation to override any * values set for these fields on the interface. * @function newMessage * @param {String} [apiKey] - the Chatbase API key * @param {String} [userId] - the Chatbase user id * @returns {MessageStateWrapper} - a new instance of MessageStateWrapper */ newMessage (apiKey=null, userId=null) { const key = apiKey ? apiKey : this.api_key; const id = userId ? userId : this.user_id; const msg = new MessageSetMessage(key, id) .setPlatform(this.platform) .setVersion(this.version) .setIntent(this.intent) .setCustomSessionId(this.session_id) .setClientTimeout(this.transport_timeout); if (this.type === MessageSink.messageTypes().agent) { msg.setAsTypeAgent(); } else if (this.type === MessageSink.messageTypes().user) { msg.setAsTypeUser(); } this.messages.push(msg); return last(this.messages); }
} else { newRow[titleMap[col]] = content if (col !== last(Object.keys(titleMap))) return // there's still more to collect results.push({ ...newRow }) newRow = {}
static extractPayloadsFromMessageSet (messages) { var messagePayloadSet = []; for (var i = 0; i < messages.length; i++) { messagePayloadSet.push(messages[i].exportCreatePayload()); if (last(messagePayloadSet) instanceof Error) { // return the error return last(messagePayloadSet); } } return messagePayloadSet; }
get(path, parsed = true) { if (parsed) { const value = get(this.parsed, path, null) if (value == null) { const keys = path.split('.') const key = last(keys) return get(this.parsed.default, key) } return value } else { return get(this.data, path) } }
get(path, parsed = true) { if (parsed) { const value = get(this.parsed, path, null) if (value == null) { const keys = path.split('.') const key = last(keys) return get(this.parsed.default, key) } return value } else { return get(this.data, path) } }
get(path, parsed = true) { if (parsed) { const value = get(this.parsed, path, null) if (value == null) { const keys = path.split('.') const key = last(keys) return get(this.parsed.default, key) } return value } else { return get(this.data, path) } }