{"version":3,"file":"index.mjs","sources":["../../../../src/services/document-service/attributes/index.ts"],"sourcesContent":["import { curry } from 'lodash/fp';\n\nimport type { UID, Modules, Schema } from '@strapi/types';\n\nimport transforms from './transforms';\n\n// aliasing the type to make it easier to read\ntype Data = Modules.Documents.Params.Data.Input;\n\nconst applyTransforms = curry((schema: Schema.Schema, data: Data) => {\n const attributeNames = Object.keys(data) as Array;\n\n for (const attributeName of attributeNames) {\n const value = data[attributeName];\n\n const attribute = schema.attributes[attributeName];\n\n if (!attribute) {\n continue;\n }\n\n const transform = transforms[attribute.type];\n\n if (transform) {\n const attributeContext = { attributeName, attribute };\n\n data[attributeName] = transform(value, attributeContext);\n }\n }\n\n return data;\n});\n\nexport { applyTransforms };\n"],"names":["applyTransforms","curry","schema","data","attributeNames","Object","keys","attributeName","value","attribute","attributes","transform","transforms","type","attributeContext"],"mappings":";;;AASMA,MAAAA,eAAAA,GAAkBC,KAAM,CAAA,CAACC,MAAuBC,EAAAA,IAAAA,GAAAA;IACpD,MAAMC,cAAAA,GAAiBC,MAAOC,CAAAA,IAAI,CAACH,IAAAA,CAAAA;IAEnC,KAAK,MAAMI,iBAAiBH,cAAgB,CAAA;QAC1C,MAAMI,KAAAA,GAAQL,IAAI,CAACI,aAAc,CAAA;AAEjC,QAAA,MAAME,SAAYP,GAAAA,MAAAA,CAAOQ,UAAU,CAACH,aAAc,CAAA;AAElD,QAAA,IAAI,CAACE,SAAW,EAAA;AACd,YAAA;AACF;AAEA,QAAA,MAAME,SAAYC,GAAAA,UAAU,CAACH,SAAAA,CAAUI,IAAI,CAAC;AAE5C,QAAA,IAAIF,SAAW,EAAA;AACb,YAAA,MAAMG,gBAAmB,GAAA;AAAEP,gBAAAA,aAAAA;AAAeE,gBAAAA;AAAU,aAAA;AAEpDN,YAAAA,IAAI,CAACI,aAAAA,CAAc,GAAGI,SAAAA,CAAUH,KAAOM,EAAAA,gBAAAA,CAAAA;AACzC;AACF;IAEA,OAAOX,IAAAA;AACT,CAAA;;;;"}