{"version":3,"sources":["jsdelivr-header.js","/npm/@ypi/core@0.0.7/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNO,SAAU,cAEf,sBACA,yBACA,0BACK,WAEP,IAAI,OAAS,KACb,MAAM,QAAU,CAAC,IAAK,CAAC,4BAAe,cAChC,YAAc,CAAC,EAWrB,SAAS,KAAK,GAEZ,OADA,OAAS,YAAY,KAAK,MAAM,KACzB,CACT,CAWA,SAAS,YAAY,GAEnB,OAAO,CACT,CAMA,SAAS,WAAW,GAClB,MAAM,EAAU,QAAQ,GACxB,GAAI,EAAS,OAAO,EACpB,MAAM,IAAI,yBAAyB,EAAO,oBAC5C,CAYA,SAAS,MAAM,GACb,IAAK,OACH,MAAM,IAAI,sBACR,6CAIJ,IACE,EAAU,IAAI,CAChB,CAAE,MAAO,GAEP,MADA,QAAQ,IAAI,GACN,IAAI,sBAAsB,oCAClC,CACA,MAAM,EAAU,EAAQ,KAAK,OAAQ,YAGrC,OAFA,YAAY,EAAQ,MAAQ,EAC5B,QAAQ,EAAQ,MAAQ,GAAW,EAC5B,QAAQ,EAAQ,KACzB,CAYA,SAAS,cAAc,EAAM,GAQ3B,OAPA,OAAO,KAAK,aAAa,SAAS,IAChC,MAAM,EAAa,YAAY,GAC/B,GAAI,EAAW,cAAe,CAC5B,MAAM,EAAS,EAAW,cAAc,EAAM,GAC9C,QAAQ,GAAO,GAAU,CAC3B,KAEK,OACT,eAEe,CAAC,UAAM,YAAO","file":"/npm/@ypi/core@0.0.7/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@ypi/core@0.0.7/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import YAML from \"yaml\";\nimport {\n  YpiNotInitidException,\n  YpiModuleNotSetException,\n  YpiNotModuleException,\n} from \"./errors\";\n\nlet config = null;\nconst modules = {ypi: {registerModel, apply}};\nconst bareModules = {};\n/**\n * Will check and set your configuratuion. Throws an error on missconfiguration.\n *\n * @param {string} yaml - Configuration of your Ypi as a string of yaml\n * @return {boolean} Returns true if everythings fine;\n *\n * @example\n *\n *     Ypi.init(ymal)\n */\nfunction init(yaml) {\n  config = checkConfig(YAML.parse(yaml));\n  return true;\n}\n/**\n * Checks the config.\n *\n * @param {object} toTest - Configuration of your Ypi as a string of yaml\n * @return {boolean} Returns the config;\n *\n * @example\n *\n *     Ypi.checkConfig(toTest)\n */\nfunction checkConfig(toTest) {\n  // enter config test here.\n  return toTest;\n}\n/**\n * Provides all initialized modules by its Type.\n * @param {string} type - Type of the module.\n * @return {object} Returns module;\n */\nfunction getModules(type) {\n  const yModule = modules[type];\n  if (yModule) return yModule;\n  throw new YpiModuleNotSetException(type + \" was not applied.\");\n}\n/**\n * Will apply the configuration on a Ypi - submodule.\n * Throws an error on version missmatch.\n *\n * @param {object} YModule - Configuration of your Ypi as a string of yaml\n * @return {object} Returns initailized module;\n *\n * @example\n *\n *     Ypi.init(yexpress)\n */\nfunction apply(YModule) {\n  if (!config) {\n    throw new YpiNotInitidException(\n      \"Please init the Ypi core component first.\"\n    );\n  }\n  // yModule.version();\n  try {\n    YModule = new YModule();\n  } catch (err) {\n    console.log(err);\n    throw new YpiNotModuleException(\"This Module is not an Ypi module.\");\n  }\n  const initied = YModule.init(config, getModules);\n  bareModules[YModule.type] = YModule;\n  modules[YModule.type] = initied || YModule;\n  return modules[YModule.type];\n}\n/**\n * Call to init custom modules on the fly\n *\n * @param {object} name - name of the module\n * @param {object} config - module config\n * @return {object} config;\n *\n * @example\n *\n *     Ypi.registerModule({scope: {}, struct: {name: \"String\"}})\n */\nfunction registerModel(name, config) {\n  Object.keys(bareModules).forEach((key) => {\n    const bareModule = bareModules[key];\n    if (bareModule.registerModel) {\n      const inited = bareModule.registerModel(name, config);\n      modules[key] = inited || bareModule;\n    }\n  });\n  return modules;\n}\n\nexport default {init, apply, registerModel};\n"]}