1 line
No EOL
19 KiB
Text
1 line
No EOL
19 KiB
Text
{"version":3,"sources":["webpack://mcfObjects/webpack/universalModuleDefinition","webpack://mcfObjects/webpack/bootstrap","webpack://mcfObjects/./src/types/base.js","webpack://mcfObjects/./src/types/array.js","webpack://mcfObjects/./src/types/boolean.js","webpack://mcfObjects/./src/types/enum.js","webpack://mcfObjects/./src/types/number.js","webpack://mcfObjects/./src/types/string.js","webpack://mcfObjects/./src/types/typeFactory.js","webpack://mcfObjects/./src/definedObject.js","webpack://mcfObjects/./src/objects/file.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_BaseType","definition","this","validations","validate","validation","MCF_Array","addValidations","param","type","Array","isArray","Error","maxLength","length","minLength","MCF_Boolean","MCF_Enum","isAvailable","availableValues","reduce","availableValue","toString","MCF_Number","max","min","MCF_String","MCF_TypeFactory","definedObject","objectDefinition","getDefinition","fields","dictionary","field","MCF_DefinedObject","buildDefinedObject","validateValue","values","setValue","valueKey","undefined","JSON","stringify","keys","required","defaultValue","arrayItem","mustBeIncluded","fieldArray","getValue","includes","push","splice","indexOf","newValue","fileFieldsDefition","TYPE","extension","mimeType","content","MCF_File"],"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,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2BAGd,SAAchB,GACZ,IAAK,IAAMgD,KAAS/B,KAAKD,WAAW8B,OAClC,QAAqBS,IAAjBvD,EAAMgD,IAAkC,OAAVhD,EAAgB,CAChD,IAA+C,IAA3CiB,KAAKD,WAAW8B,OAAOE,GAAOW,SAChC,MAAM,IAAIhC,MAAJ,oBAAuBqB,EAAvB,iBAKR,QAHmDO,IAA/CtC,KAAKD,WAAW8B,OAAOE,GAAOY,eAChC5D,EAAMgD,GAAS/B,KAAKD,WAAW8B,OAAOE,GAAOY,eAEJ,IAAvC3C,KAAKD,WAAW8B,OAAOE,GAAvB,KACF,MAAM,IAAIrB,MAAJ,oBAAuBqB,EAAvB,2B,8BAMd,SAAiBA,EAAOa,EAAWC,GACjC,IAAMC,EAAa9C,KAAK+C,WAAWhB,IAAU,IAExCe,EAAWE,SAASJ,IAAcC,GAAgBC,EAAWG,KAAKL,GACnEE,EAAWE,SAASJ,KAAeC,GAAgBC,EAAWI,OAAOJ,EAAWK,QAAQP,GAAY,GAExG,IAAMQ,EAAW,GACjBA,EAASrB,GAASe,EAClB9C,KAAKoC,SAASgB,Q,+vDC1DlB,IAAMC,EAAqB,CACzBhF,KAAW,CAAEiF,KAAM,SAAUZ,UAAU,GACvCa,UAAW,CAAED,KAAM,UACnBE,SAAW,CAAEF,KAAM,UACnBG,QAAW,CAAEH,KAAM,SAAUX,aAAc,KAGxBe,E,gQACnB,WAAY3D,GAAY,O,4FAAA,qBAChB,CACJ8B,OAAQ,EAAF,KAAOwB,GAAuBtD,EAAW8B,QAC/CM,OAAQpC,EAAWoC,OAASpC,EAAWoC,OAASpC,I,UAJhBiC","file":"mcf-objects.js","sourcesContent":["(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","export default class MCF_BaseType {\n constructor(definition) {\n this.definition = definition\n this.validations = {}\n }\n\n getValue() {\n return this.value\n }\n\n setValue(value) {\n this.validate(value)\n this.value = value\n }\n\n validate(value) {\n for (const validation in this.validations) {\n this.validations[validation](value, this.definition)\n }\n }\n}\n","import MCF_BaseType from './base'\n\n\n\nexport default class MCF_Array extends MCF_BaseType {\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-Objects ==> MCF_Array validation: the type of ${value} isn't \"array\"`)\n }\n }\n\n for (const 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-Objects ==> MCF_Array validation: 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-Objects ==> MCF_Array validation: the length of the array \"${value}\" is lower than the minimum defined: ${definition.minLength}`)\n }\n }\n break\n }\n }\n }\n}\n","import MCF_BaseType from './base'\n\n\n\nexport default class MCF_Boolean extends MCF_BaseType {\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-Objects ==> MCF_Boolean creation: the type of the value ${value} isn't \"boolean\"`)\n }\n }\n }\n}\n","import MCF_BaseType from './base'\n\n\n\nexport default class MCF_Enum extends MCF_BaseType {\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-Objects ==> MCF_Enum validation: the value \"${value}\" isn't one of the next values, included in the field definition: ${definition.availableValues.toString()}`)\n }\n }\n }\n}\n","import MCF_BaseType from './base'\n\n\nexport default class MCF_Number extends MCF_BaseType {\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-Objects ==> MCF_Number validation: the type of the value ${value} isn't \"number\"`)\n }\n }\n\n for (const 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-Objects ==> MCF_Number validation: 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-Objects ==> MCF_Number validation: the value ${value} is lower than the minimum defined: ${definition.min}`)\n }\n }\n break\n }\n }\n }\n}\n","import MCF_BaseType from './base'\n\n\n\nexport default class MCF_String extends MCF_BaseType {\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-Objects ==> MCF_String validation: the type of ${value} isn't \"string\"`)\n }\n }\n\n for (const 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-Objects ==> MCF_String validation: 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-Objects ==> MCF_String validation: the length of the string \"${value}\" is lower than the minimum defined: ${definition.minLength}`)\n }\n }\n break\n }\n }\n }\n}\n","import MCF_Array from './array'\nimport MCF_Boolean from './boolean'\nimport MCF_Enum from './enum'\nimport MCF_Number from './number'\nimport MCF_String from './string'\n\n\n\nexport default class MCF_TypeFactory {\n static buildDefinedObject(definedObject) {\n const objectDefinition = definedObject.getDefinition()\n const fields = objectDefinition.fields\n const dictionary = {}\n for (const field in fields) {\n switch (fields[field]['TYPE']) {\n case 'array':\n dictionary[field] = new MCF_Array(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 'number':\n dictionary[field] = new MCF_Number(fields[field])\n break\n case 'string':\n dictionary[field] = new MCF_String(fields[field])\n break\n default:\n throw new Error(`MCF-Objects ==> The object type ${fields[field]['TYPE']} does not exist. Check the field definition in the object definition ${objectDefinition}`)\n }\n }\n return dictionary\n }\n}\n","import MCF_TypeFactory from './types/typeFactory'\n\n\n\nexport default class MCF_DefinedObject {\n constructor(definition) {\n this.definition = definition\n this.validations = {}\n this.fields = MCF_TypeFactory.buildDefinedObject(this)\n this.validateValue(definition.values)\n this.setValue(definition.values)\n }\n\n getValue() {\n const value = {}\n for (const field in this.fields) {\n value[field] = this.fields[field].value\n }\n return value\n }\n\n setValue(value) {\n for (const valueKey in value) {\n if (value[valueKey] === undefined) {\n this.fields[valueKey].value = undefined\n } else {\n if (this.fields[valueKey] === undefined) {\n throw new Error(`The field ${valueKey} doesn't exist in the current DefinedObject: ${JSON.stringify(Object.keys(this.fields), null, 2)}`)\n }\n this.fields[valueKey].setValue(value[valueKey])\n }\n }\n }\n\n getDefinition() {\n return this.definition\n }\n\n validateValue(value) {\n for (const 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\n updateArrayField(field, arrayItem, mustBeIncluded) {\n const fieldArray = this.getValue()[field] || []\n\n if (!fieldArray.includes(arrayItem) && mustBeIncluded) fieldArray.push(arrayItem)\n if (fieldArray.includes(arrayItem) && !mustBeIncluded) fieldArray.splice(fieldArray.indexOf(arrayItem), 1)\n\n const newValue = {}\n newValue[field] = fieldArray\n this.setValue(newValue)\n }\n}\n","import MCF_DefinedObject from '../definedObject'\n\n\n\nconst fileFieldsDefition = {\n name: { TYPE: 'string', required: true },\n extension: { TYPE: 'string' },\n mimeType: { TYPE: 'string' },\n content: { TYPE: 'string', defaultValue: '' },\n}\n\nexport default class MCF_File extends MCF_DefinedObject {\n constructor(definition) {\n super({\n fields: { ...fileFieldsDefition, ...definition.fields },\n values: definition.values ? definition.values : definition,\n })\n }\n}\n"],"sourceRoot":""} |