1 line
No EOL
18 KiB
Text
1 line
No EOL
18 KiB
Text
{"version":3,"sources":["webpack://mcfObjects/webpack/universalModuleDefinition","webpack://mcfObjects/webpack/bootstrap","webpack://mcfObjects/./src/index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","MCF_Type","definition","this","validations","validate","validation","MCF_String","addValidations","param","type","Error","maxLength","length","minLength","MCF_Number","max","min","MCF_Boolean","MCF_Array","Array","isArray","MCF_Enum","isAvailable","availableValues","reduce","availableValue","toString","MCF_TypeFactory","definedObject","fields","getDefinition","dictionary","field","MCF_DefinedObject","buildDefinedObject","setValue","undefined","required","defaultValue","fileDefinition","filename","TYPE","extension","path","content","MCF_File","params"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,IARvB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,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Content":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"mcfObjects\"] = factory();\n\telse\n\t\troot[\"mcfObjects\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","// --== OBJECTS LIBRARY ==--\n// ========================================\n\nclass MCF_Type {\n constructor(definition){\n this.definition = definition;\n this.validations = {};\n\n }\n\n setValue(value){\n this.validate(value);\n this.value = value;\n }\n\n getValue(){\n return this.value;\n }\n\n validate(value){\n for (let validation in this.validations){\n this.validations[validation](value, this.definition);\n }\n }\n}\nclass MCF_String extends MCF_Type {\n constructor(definition){\n super(definition);\n this.addValidations();\n }\n\n addValidations(){\n this.validations.type = function(value) {\n if (typeof (value) !== \"string\") {\n throw new Error(`MCF_String creation: the type of ${value} isn't \"string\"`);\n }\n };\n\n for (let param in this.definition){\n switch (param) {\n case 'maxLength':\n this.validations.maxLength = function(value, definition){\n if (value.length > definition.maxLength){\n throw new Error(`MCF_String creation: the length of the string \"${value}\" is higher than the maximum defined: ${definition.maxLength}`);\n }\n };\n break;\n case 'minLength':\n this.validations.minLength = function(value, definition){\n if (value.length < definition.minLength){\n throw new Error(`MCF_String creation: the length of the string \"${value}\" is lower than the minimum defined: ${definition.minLength}`);\n }\n };\n break;\n }\n }\n }\n}\nclass MCF_Number extends MCF_Type{\n constructor(definition){\n super(definition);\n this.addValidations();\n }\n\n addValidations(){\n this.validations.type = function(value) {\n if (typeof (value) !== \"number\") {\n throw new Error(`MCF_Number creation: the type of the value ${value} isn't \"number\"`);\n }\n };\n\n for (let param in this.definition){\n switch (param) {\n case 'max':\n this.validations.max = function(value, definition){\n if (value > definition.max){\n throw new Error(`MCF_Number creation: the value ${value} is higher than the maximum defined: ${definition.max}`);\n }\n };\n break;\n case 'min':\n this.validations.min = function(value, definition){\n if (value < definition.min){\n throw new Error(`MCF_Number creation: the value ${value} is lower than the minimum defined: ${definition.min}`);\n }\n };\n break;\n }\n }\n }\n}\nclass MCF_Boolean extends MCF_Type{\n constructor(definition){\n super(definition);\n this.addValidations();\n }\n\n addValidations(){\n this.validations.type = function(value) {\n if (typeof (value) !== \"boolean\") {\n throw new Error(`MCF_Boolean creation: the type of the value ${value} isn't \"boolean\"`);\n }\n };\n }\n}\nclass MCF_Array extends MCF_Type {\n constructor(definition){\n super(definition);\n this.addValidations();\n }\n\n addValidations(){\n this.validations.type = function(value) {\n if (!Array.isArray(value)) {\n throw new Error(`MCF_Array creation: the type of ${value} isn't \"array\"`);\n }\n };\n\n for (let param in this.definition){\n switch (param) {\n case 'maxLength':\n this.validations.maxLength = function(value, definition){\n if (value.length > definition.maxLength){\n throw new Error(`MCF_Array creation: the length of the array \"${value}\" is higher than the maximum defined: ${definition.maxLength}`);\n }\n };\n break;\n case 'minLength':\n this.validations.minLength = function(value, definition){\n if (value.length < definition.minLength){\n throw new Error(`MCF_Array creation: the length of the array \"${value}\" is lower than the minimum defined: ${definition.minLength}`);\n }\n };\n break;\n }\n }\n }\n}\nclass MCF_Enum extends MCF_Type{\n constructor(definition){\n super(definition);\n this.addValidations();\n }\n\n addValidations(){\n this.validations.isAvailable = function(value, definition){\n const valueIsAvailable = definition.availableValues.reduce(function(isAvailable, availableValue){\n if (value === availableValue) return true;\n return isAvailable;\n }, false);\n if (!valueIsAvailable){\n throw new Error(`MCF_Enum creation: the value \"${value}\" isn't one of the next values, included in the field definition: ${definition.availableValues.toString()}`);\n }\n }\n }\n}\nclass MCF_TypeFactory {\n static buildDefinedObject(definedObject) {\n const objectDefinition = definedObject.getDefinition();\n let fields = objectDefinition.fields;\n let dictionary = {};\n for (let field in fields) {\n switch (fields[field]['TYPE']) {\n case 'string':\n dictionary[field] = new MCF_String(fields[field]);\n break;\n case 'number':\n dictionary[field] = new MCF_Number(fields[field]);\n break;\n case 'boolean':\n dictionary[field] = new MCF_Boolean(fields[field]);\n break;\n case 'enum':\n dictionary[field] = new MCF_Enum(fields[field]);\n break;\n case 'array':\n dictionary[field] = new MCF_Array(fields[field]);\n break;\n }\n }\n return dictionary;\n }\n}\nclass MCF_DefinedObject {\n constructor(definition){\n this.definition = definition;\n this.validations = {};\n this.fields = MCF_TypeFactory.buildDefinedObject(this);\n this.setValue(definition.value)\n }\n\n getDefinition(){\n return this.definition;\n }\n\n getValue(){\n let value = {};\n for (let field in this.fields){\n value[field] = this.fields[field].value;\n }\n return value;\n }\n\n setValue(value){\n for (let field in this.definition.fields){\n if (value[field] === undefined || value === null){\n if (this.definition.fields[field].required === true){\n throw new Error(`The field ${field} is required`);\n }\n if (this.definition.fields[field].defaultValue !== undefined){\n value[field] = this.definition.fields[field].defaultValue;\n }\n if (this.definition.fields[field].null === false){\n throw new Error(`The field ${field} can't be undefined`);\n }\n }\n }\n\n for (let field in value){\n if (value[field] === undefined){\n this.fields[field].value = undefined;\n } else {\n this.fields[field].setValue(value[field]);\n }\n }\n }\n\n setPropertiesValue(value){\n for (let field in value){\n this.fields[field].setValue(value[field]);\n }\n }\n}\n\nconst fileDefinition = {\n filename: {TYPE: 'string', required: true},\n extension: {TYPE: 'string', required: true},\n path: {TYPE: 'string', required: true},\n content: {TYPE: 'string'},\n}\n\nclass MCF_File extends MCF_DefinedObject {\n constructor(params) {\n super({\n fields: fileDefinition,\n value: params,\n })\n }\n}\n\nexport {\n MCF_DefinedObject as definedObject,\n MCF_File as mcfFile,\n};\n"],"sourceRoot":""} |