<commit_before>import { Saga } from 'resolve-core'
import {
  USER_PERSONAL_DATA_REQUESTED,
  USER_PROFILE_DELETED
} from '../user-profile.events'
import { systemToken } from '../jwt'

const saga: Saga = {
  handlers: {
    [USER_PERSONAL_DATA_REQUESTED]: async (context, event): Promise<void> => {
      // TODO: gather all data, make a zip with report and upload it to where?
      const { aggregateId: userId } = event
      const { sideEffects } = context

      const profile = await sideEffects.executeQuery({
        modelName: 'user-profiles',
        resolverName: 'profile',
        resolverArgs: { userId },
        jwtToken: systemToken()
      })

      // upload
      const archiveId = 'todo'

      await sideEffects.executeCommand({
        type: 'completePersonalDataGathering',
        aggregateName: 'user-profile',
        aggregateId: userId,
        payload: {
          archiveId
        }
      })
    },
    [USER_PROFILE_DELETED]: async ({ sideEffects }, event): Promise<void> => {
      await sideEffects.secretsManager.deleteSecret(event.aggregateId)
    }
  },
  sideEffects: {
    doSomething: (): Promise<void> => {
      return Promise.resolve()
    }
  }
}

export default saga<commit_msg>Cleanup<commit_after>import { Saga } from 'resolve-core'
import {
  USER_PERSONAL_DATA_REQUESTED,
  USER_PROFILE_DELETED
} from '../user-profile.events'
import { systemToken } from '../jwt'

const saga: Saga = {
  handlers: {
    [USER_PERSONAL_DATA_REQUESTED]: async (context, event): Promise<void> => {
      // TODO: gather all data, make a zip with report and upload it to where?
      const { aggregateId: userId } = event
      const { sideEffects } = context

      const profile = await sideEffects.executeQuery({
        modelName: 'user-profiles',
        resolverName: 'profile',
        resolverArgs: { userId },
        jwtToken: systemToken()
      })

      // upload
      const archiveId = 'todo'

      await sideEffects.executeCommand({
        type: 'completePersonalDataGathering',
        aggregateName: 'user-profile',
        aggregateId: userId,
        payload: {
          archiveId
        }
      })
    },
    [USER_PROFILE_DELETED]: async ({ sideEffects }, event): Promise<void> => {
      await sideEffects.secretsManager.deleteSecret(event.aggregateId)
    }
  }
}

export default saga
{'fraction_non_alphanumeric': 0.11319948739854763, 'fraction_numerical': 0.0, 'mean_word_length': 2.6651017214397497, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984379', 'n_tokens_mistral': 708, 'n_tokens_neox': 699, 'n_words': 162}