diff --git a/app/domains/beratungshilfe/formular/xstateConfig.ts b/app/domains/beratungshilfe/formular/xstateConfig.ts index 710ec05ff..cc3be51f6 100644 --- a/app/domains/beratungshilfe/formular/xstateConfig.ts +++ b/app/domains/beratungshilfe/formular/xstateConfig.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import merge from "lodash/merge"; import persoenlicheDatenFlow from "~/domains/shared/formular/persoenlicheDaten/flow.json"; import type { Config } from "~/services/flow/server/buildFlowController"; import { abgabeXstateConfig } from "./abgabe/xstateConfig"; @@ -38,7 +38,7 @@ export const beratungshilfeXstateConfig = { "anwaltliche-vertretung": anwaltlicheVertretungXstateConfig, rechtsproblem: rechtsproblemXstateConfig, "finanzielle-angaben": beratungshilfeFinanzielleAngabenXstateConfig, - "persoenliche-daten": _.merge(persoenlicheDatenFlow, { + "persoenliche-daten": merge(persoenlicheDatenFlow, { meta: { done: beratungshilfePersoenlicheDatenDone }, states: { start: { diff --git a/app/domains/fluggastrechte/formular/index.ts b/app/domains/fluggastrechte/formular/index.ts index de6eb8857..e038ef993 100644 --- a/app/domains/fluggastrechte/formular/index.ts +++ b/app/domains/fluggastrechte/formular/index.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import merge from "lodash/merge"; import type { AllContextKeys } from "~/domains/common"; import type { Flow } from "~/domains/flows.server"; import type { ArrayConfigServer } from "~/services/array"; @@ -116,26 +116,26 @@ export const fluggastrechtFlow = { "redirect-vorabcheck-ergebnis": { on: {} }, }, }, - grundvoraussetzungen: _.merge(grundvoraussetzungenFlow, { + grundvoraussetzungen: merge(grundvoraussetzungenFlow, { meta: { done: grundvoraussetzungenDone }, }), - "streitwert-kosten": _.merge(streitwertKostenFlow, { + "streitwert-kosten": merge(streitwertKostenFlow, { meta: { done: streitwertKostenDone }, }), - flugdaten: _.merge(flugdatenFlow, { meta: { done: flugdatenDone } }), - "persoenliche-daten": _.merge(persoenlicheDatenFlow, { + flugdaten: merge(flugdatenFlow, { meta: { done: flugdatenDone } }), + "persoenliche-daten": merge(persoenlicheDatenFlow, { states: { person: { meta: { done: personDone } }, "weitere-personen": { meta: { done: weiterePersonenDone } }, }, }), - prozessfuehrung: _.merge(prozessfuehrungFlow, { + prozessfuehrung: merge(prozessfuehrungFlow, { meta: { done: prozessfuehrungDone }, }), - zusammenfassung: _.merge(zusammenfassungFlow, { + zusammenfassung: merge(zusammenfassungFlow, { meta: { done: () => false }, }), - abgabe: _.merge(abgabeFlow, { + abgabe: merge(abgabeFlow, { meta: { done: () => false }, }), }, diff --git a/app/domains/geldEinklagen/formular/index.ts b/app/domains/geldEinklagen/formular/index.ts index 1392247b3..01e83f454 100644 --- a/app/domains/geldEinklagen/formular/index.ts +++ b/app/domains/geldEinklagen/formular/index.ts @@ -1,4 +1,5 @@ -import _ from "lodash"; +import merge from "lodash/merge"; +import cloneDeep from "lodash/cloneDeep"; import type { Flow } from "~/domains/flows.server"; import type { GeldEinklagenFormularContext } from "./context"; import geldEinklagenFormularFlow from "./flow.json"; @@ -27,9 +28,9 @@ export const geldEinklagenFormular = { berechneteGerichtskosten: berechneteGerichtskosten.toString(), }; }, - config: _.merge(geldEinklagenFormularFlow, { + config: merge(geldEinklagenFormularFlow, { states: { - "persoenliche-daten": _.merge(_.cloneDeep(persoenlicheDatenFlow), { + "persoenliche-daten": merge(cloneDeep(persoenlicheDatenFlow), { meta: { done: ({ context }: { context: GeldEinklagenFormularContext }) => Boolean( diff --git a/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/xStateConfig.ts b/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/xStateConfig.ts index f046544a0..c7b16dc5d 100644 --- a/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/xStateConfig.ts +++ b/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/xStateConfig.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import mapValues from "lodash/mapValues"; import { and } from "xstate"; import type { Context } from "~/domains/contexts"; import type { Flow } from "~/domains/flows.server"; @@ -64,7 +64,7 @@ export const getProzesskostenhilfeEinkuenfteSubflow = ( _doneFunction: ProzesskostenhilfeFinanzielleAngabenEinkuenfteGuard = einkuenfteDone, subflowPrefix?: PKHEinkuenfteSubflowTypes, ) => { - const stepIds = _.mapValues(einkuenfteStepIds, (step) => + const stepIds = mapValues(einkuenfteStepIds, (step) => subflowPrefix ? `${subflowPrefix}-${step}` : step, ); diff --git a/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/xstateConfig.ts b/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/xstateConfig.ts index 288f4edcd..3a837e0b0 100644 --- a/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/xstateConfig.ts +++ b/app/domains/prozesskostenhilfe/formular/finanzielleAngaben/xstateConfig.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import merge from "lodash/merge"; import type { Config } from "~/services/flow/server/buildFlowController"; import type { ProzesskostenhilfeFinanzielleAngabenContext } from "./context"; import { @@ -99,7 +99,7 @@ export const finanzielleAngabenXstateConfig = { ], }, }, - "partner-einkuenfte": _.merge( + "partner-einkuenfte": merge( getProzesskostenhilfeEinkuenfteSubflow(einkuenfteDone, "partner"), { states: { diff --git a/app/domains/prozesskostenhilfe/services/pdf/pdfForm/I_zahlungsverpflichtungen.ts b/app/domains/prozesskostenhilfe/services/pdf/pdfForm/I_zahlungsverpflichtungen.ts index 81499ef0f..7da919f7f 100644 --- a/app/domains/prozesskostenhilfe/services/pdf/pdfForm/I_zahlungsverpflichtungen.ts +++ b/app/domains/prozesskostenhilfe/services/pdf/pdfForm/I_zahlungsverpflichtungen.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import partition from "lodash/partition"; import type { ProzesskostenhilfePDF } from "data/pdf/prozesskostenhilfe/prozesskostenhilfe.generated"; import type { ProzesskostenhilfeFormularContext } from "~/domains/prozesskostenhilfe/formular"; import { finanzielleAngabeEinkuenfteGuards as einkuenfteGuards } from "~/domains/prozesskostenhilfe/formular/finanzielleAngaben/einkuenfte/guards"; @@ -187,7 +187,7 @@ export const fillZahlungsverpflichtungen: PkhPdfFillFunction = ({ ...versicherungen.map(mapVersicherungToZahlungsverpflichtung), ]; - const [zahlungLong, zahlungShort] = _.partition( + const [zahlungLong, zahlungShort] = partition( zahlungenWithDescription, (zahlung) => zahlung.description.length > diff --git a/app/routes/shared/pdfDownloadLoader.ts b/app/routes/shared/pdfDownloadLoader.ts index b44c90b95..089a75878 100644 --- a/app/routes/shared/pdfDownloadLoader.ts +++ b/app/routes/shared/pdfDownloadLoader.ts @@ -1,5 +1,5 @@ import { redirect, type LoaderFunctionArgs } from "@remix-run/node"; -import _ from "lodash"; +import isEmpty from "lodash/isEmpty"; import type { BeratungshilfeFormularContext } from "~/domains/beratungshilfe/formular"; import { beratungshilfePdfFromUserdata } from "~/domains/beratungshilfe/services/pdf"; import { parsePathname, type FlowId } from "~/domains/flowIds"; @@ -67,7 +67,7 @@ export async function pdfDownloadLoader({ request }: LoaderFunctionArgs) { (await getSessionData(flowId, request.headers.get("Cookie"))).userData, flowId, ); - if (_.isEmpty(userData)) return redirect(flowId); + if (isEmpty(userData)) return redirect(flowId); const fileContent = await pdfFunction(userData, flowTranslations); const fileSize = fileContent.length; diff --git a/app/services/array/resolveArraysFromKeys.ts b/app/services/array/resolveArraysFromKeys.ts index ee5a0caaa..9cbe6b289 100644 --- a/app/services/array/resolveArraysFromKeys.ts +++ b/app/services/array/resolveArraysFromKeys.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import set from "lodash/set"; import type { Context } from "~/domains/contexts"; import { resolveArrayCharacter } from "./resolveArrayCharacter"; @@ -8,7 +8,7 @@ export const resolveArraysFromKeys = ( ) => { const resolvedObject: Context = {}; Object.entries(data).forEach(([key, value]) => - _.set(resolvedObject, resolveArrayCharacter(key, arrayIndexes), value), + set(resolvedObject, resolveArrayCharacter(key, arrayIndexes), value), ); return resolvedObject; }; diff --git a/app/services/cms/fetchAllFormFields.ts b/app/services/cms/fetchAllFormFields.ts index 483c4cca0..3edb87ce2 100644 --- a/app/services/cms/fetchAllFormFields.ts +++ b/app/services/cms/fetchAllFormFields.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import merge from "lodash/merge"; import type { FlowId } from "~/domains/flowIds"; import { flows } from "~/domains/flows.server"; import { flowPageApiIdFromFlowType } from "./apiFromFlowType"; @@ -29,7 +29,7 @@ export async function fetchAllFormFields( ) : {}; - return _.merge(formFields, formFieldsStaging); + return merge(formFields, formFieldsStaging); } function formFieldsFromEntries( diff --git a/app/services/flow/pageData.ts b/app/services/flow/pageData.ts index 277ffe47c..b9539efe3 100644 --- a/app/services/flow/pageData.ts +++ b/app/services/flow/pageData.ts @@ -1,7 +1,7 @@ -import _ from "lodash"; +import merge from "lodash/merge"; import type { Context } from "~/domains/contexts"; import { type PageData } from "./pageDataSchema"; export function addPageDataToUserData(userData: Context, pageData: PageData) { - return _.merge(userData, { pageData }); + return merge(userData, { pageData }); } diff --git a/app/services/flow/pruner.ts b/app/services/flow/pruner.ts index a8ad39ac1..926b37d55 100644 --- a/app/services/flow/pruner.ts +++ b/app/services/flow/pruner.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import pick from "lodash/pick"; import type { Context } from "~/domains/contexts"; import type { FlowId } from "~/domains/flowIds"; import { flows } from "~/domains/flows.server"; @@ -16,7 +16,7 @@ export async function pruneIrrelevantData(data: Context, flowId: FlowId) { const flowController = buildFlowController({ guards, config, data }); const formPaths = validFormPaths(flowController); const validFormFields = filterFormFields(formFields, formPaths); - return _.pick(data, validFormFields); + return pick(data, validFormFields); } export function filterFormFields( diff --git a/app/services/flow/server/buildFlowController.ts b/app/services/flow/server/buildFlowController.ts index b5a7e9bd0..32eeb08d8 100644 --- a/app/services/flow/server/buildFlowController.ts +++ b/app/services/flow/server/buildFlowController.ts @@ -1,5 +1,5 @@ import { getShortestPaths } from "@xstate/graph"; -import _ from "lodash"; +import isEqual from "lodash/isEqual"; import type { MachineConfig, MachineContext, @@ -117,7 +117,7 @@ const findNode = (machine: FlowStateMachine, stepId: string) => { value: pathToStateValue(statepath), context: {}, }); - return resolvedState._nodes.find((node) => _.isEqual(node.path, statepath)); + return resolvedState._nodes.find((node) => isEqual(node.path, statepath)); }; const isFinalStep = (machine: FlowStateMachine, stepId: string) => { diff --git a/app/services/flow/server/flowTransitionValidation.ts b/app/services/flow/server/flowTransitionValidation.ts index 101027ed2..6e756258a 100644 --- a/app/services/flow/server/flowTransitionValidation.ts +++ b/app/services/flow/server/flowTransitionValidation.ts @@ -1,4 +1,4 @@ -import _ from "lodash"; +import isEmpty from "lodash/isEmpty"; import type { FlowId } from "~/domains/flowIds"; import type { Flow } from "~/domains/flows.server"; import { buildFlowController } from "./buildFlowController"; @@ -27,7 +27,7 @@ export async function validateFlowTransition( ): Promise { const { sourceFlowId, eligibleSourcePages } = config; - if (_.isEmpty(eligibleSourcePages)) { + if (isEmpty(eligibleSourcePages)) { throw Error("This property should not be empty"); } diff --git a/app/services/session.server/fieldsFromContext.ts b/app/services/session.server/fieldsFromContext.ts index 8d839915a..badf5d86c 100644 --- a/app/services/session.server/fieldsFromContext.ts +++ b/app/services/session.server/fieldsFromContext.ts @@ -1,4 +1,5 @@ -import _ from "lodash"; +import zipObject from "lodash/zipObject"; +import at from "lodash/at"; import type { Context } from "~/domains/contexts"; import { resolveArrayCharacter } from "~/services/array/resolveArrayCharacter"; import { pageDataSchema } from "~/services/flow/pageDataSchema"; @@ -12,5 +13,5 @@ export const fieldsFromContext = (context: Context, fieldnames: string[]) => { const resolvedFieldnames = fieldnames.map((fieldname) => resolveArrayCharacter(fieldname, arrayIndexes), ); - return _.zipObject(fieldnames, _.at(context, resolvedFieldnames)); + return zipObject(fieldnames, at(context, resolvedFieldnames)); }; diff --git a/app/services/session.server/index.ts b/app/services/session.server/index.ts index 8f58133b2..f7dd1910a 100644 --- a/app/services/session.server/index.ts +++ b/app/services/session.server/index.ts @@ -1,7 +1,7 @@ import crypto from "crypto"; import type { Cookie, Session } from "@remix-run/node"; import { createSessionStorage, createCookie } from "@remix-run/node"; -import _ from "lodash"; +import merge from "lodash/merge"; import { type Context } from "~/domains/contexts"; import { flowIds, type FlowId } from "~/domains/flowIds"; import { config } from "~/services/env/env.server"; @@ -70,7 +70,7 @@ export const getSessionData = async ( }; export const updateSession = (session: Session, validatedData: Context) => { - const mergedData = _.merge(session.data, validatedData); + const mergedData = merge(session.data, validatedData); Object.entries(mergedData).forEach(([key, value]) => { session.set(key, value); }); diff --git a/scripts/airlines.ts b/scripts/airlines.ts index 326cf5ba5..9789a3a90 100644 --- a/scripts/airlines.ts +++ b/scripts/airlines.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import fs from "node:fs"; -import _ from "lodash"; +import uniqBy from "lodash/uniqBy"; interface Airline { name: string; @@ -28,7 +28,7 @@ function processAirlineRow(row: string): Airline { } function saveAirlinesInFile(airlines: Airline[]): void { - const data = JSON.stringify(_.uniqBy(airlines, "iata")); + const data = JSON.stringify(uniqBy(airlines, "iata")); const saveFilePath = "data/airlines/data.json"; fs.writeFile(saveFilePath, data, (error) => { diff --git a/scripts/airports.ts b/scripts/airports.ts index 31a7b125f..94adcce5a 100644 --- a/scripts/airports.ts +++ b/scripts/airports.ts @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import fs from "fs"; import { getName } from "i18n-iso-countries"; -import _ from "lodash"; +import uniqBy from "lodash/uniqBy"; import { z } from "zod"; import type { Airport } from "~/domains/fluggastrechte/services/airports/type"; @@ -159,7 +159,7 @@ async function fetchAllAirports(): Promise { async function fetchAndSaveAirports() { const airports = await fetchAllAirports(); - const data = JSON.stringify(_.uniqBy(airports, "iata")); + const data = JSON.stringify(uniqBy(airports, "iata")); fs.writeFileSync(FILE_PATH_AIRPORTS_DATA, data); console.log(`${FILE_PATH_AIRPORTS_DATA} written correctly`); diff --git a/scripts/unusedStrapiEntries.ts b/scripts/unusedStrapiEntries.ts index dbcbf2f5d..e689aaf5c 100644 --- a/scripts/unusedStrapiEntries.ts +++ b/scripts/unusedStrapiEntries.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { readFileSync } from "node:fs"; -import _ from "lodash"; +import partition from "lodash/partition"; import { flows } from "~/domains/flows.server"; import { strapiFileSchema, type StrapiSchemas } from "~/services/cms/schemas"; import { type Config } from "~/services/flow/server/buildFlowController"; @@ -38,11 +38,11 @@ function urlsFromPages(pages: MinimalPage[]) { } function partitionPagesByStepId(pages: MinimalPage[]) { - return _.partition(pages, (page) => page.stepId !== null); + return partition(pages, (page) => page.stepId !== null); } function partitionPagesByFlowId(pages: MinimalPage[]) { - return _.partition(pages, (page) => page.flow_ids.length > 0); + return partition(pages, (page) => page.flow_ids.length > 0); } function unusedStrapiEntry() {