private shouldProcess()

in firestore-genai-chatbot/functions/src/firestore-onwrite-processor/index.ts [32:51]


  private shouldProcess(change: Change, changeType: ChangeType, state: State) {
    const newValue = this.getLatestInputValue(change);
    const oldValue = this.getPreviousInputValue(change);

    const hasChanged =
      changeType === ChangeType.CREATE ||
      (this.processUpdates &&
        changeType === ChangeType.UPDATE &&
        oldValue !== newValue);

    if (
      !newValue ||
      [State.PROCESSING, State.COMPLETED, State.ERROR].includes(state) ||
      !hasChanged ||
      typeof newValue !== 'string'
    ) {
      return false;
    }
    return true;
  }