@arcane-utils/ingestion
Version:
Ingestion utilities for Arcane
1 lines • 2.81 kB
Source Map (JSON)
{"version":3,"sources":["../src/ingestion.ts"],"sourcesContent":["\nimport { isNil } from 'lodash'\nimport moment from 'moment'\n\nimport { Ingestion } from '@arcane-utils/types'\n\n\n/**\n * Determines if the product evolution information should be called.\n *\n * This function evaluates whether the product evolution information needs to be updated\n * based on the following criteria:\n * - The last calculation date is not the same as today.\n * - The identifier key exists.\n * - The identifier key is not empty.\n *\n * @param {Ingestion} dataIngestion - The ingestion data object containing product evolution information.\n * @returns {boolean} - Returns true if product evolution information should be called, false otherwise.\n */\nexport const shouldCallProductEvolutionCalculator = (\n dataIngestion: Ingestion\n): boolean => {\n const today = moment()\n if (\n isNil(dataIngestion.product_evolution_info) ||\n isNil(dataIngestion.product_evolution_info.identifier_key) ||\n dataIngestion.product_evolution_info.identifier_key.length === 0\n ) {\n return false\n }\n if (isNil(dataIngestion.product_evolution_info.last_calculation) || isNil(dataIngestion.product_evolution_info.last_calculation.date)) {\n return true\n }\n const lastCalculationDate = moment(dataIngestion.product_evolution_info.last_calculation.date)\n return !(today.isSame(lastCalculationDate, 'day'))\n}\n\n\n\nexport const PREFIX_IMPORT = 'pf__import__'\n\n/**\n * Builds the datalake import file name for a given ingestion, mirroring the Python\n * convention: `pf__import__<client_id>__<import_id>` with every space replaced by `_`.\n *\n * @param clientId - Id of the client owning the import.\n * @param importId - Id of the import (e.g. the master ingestion id).\n * @returns The normalized import file name.\n */\nexport const createFileName = (clientId: string, importId: number): string =>\n [`${PREFIX_IMPORT}${clientId}`, importId.toString()].join('__').replace(/ /g, '_')\n"],"mappings":"6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,EAAA,yCAAAC,IAAA,eAAAC,EAAAL,GACA,IAAAM,EAAsB,kBACtBC,EAAmB,uBAiBNH,EACXI,GACY,CACZ,IAAMC,KAAQ,EAAAC,SAAO,EACrB,MACE,SAAMF,EAAc,sBAAsB,MAC1C,SAAMA,EAAc,uBAAuB,cAAc,GACzDA,EAAc,uBAAuB,eAAe,SAAW,EAE/D,MAAO,GAET,MAAI,SAAMA,EAAc,uBAAuB,gBAAgB,MAAK,SAAMA,EAAc,uBAAuB,iBAAiB,IAAI,EAClI,MAAO,GAET,IAAMG,KAAsB,EAAAD,SAAOF,EAAc,uBAAuB,iBAAiB,IAAI,EAC7F,MAAO,CAAEC,EAAM,OAAOE,EAAqB,KAAK,CAClD,EAIaT,EAAgB,eAUhBC,EAAiB,CAACS,EAAkBC,IAC/C,CAAC,GAAGX,CAAa,GAAGU,CAAQ,GAAIC,EAAS,SAAS,CAAC,EAAE,KAAK,IAAI,EAAE,QAAQ,KAAM,GAAG","names":["ingestion_exports","__export","PREFIX_IMPORT","createFileName","shouldCallProductEvolutionCalculator","__toCommonJS","import_lodash","import_moment","dataIngestion","today","moment","lastCalculationDate","clientId","importId"]}