budibase/packages/common/lib/schema/models.js.map

1 line
1.8 KiB
Plaintext

{"version":3,"sources":["../../src/schema/models.js"],"names":["newModel","id","name","fields","validationRules","primaryField","views","canDeleteModel","models","modelId","errors","model","links","filter","f","type","typeOptions","link","push","canDelete","length"],"mappings":"8HAAA,kC;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,WAAO;AAC7BC,IAAAA,EAAE,EAAE,wBADyB;AAE7BC,IAAAA,IAAI,EAAE,EAFuB;AAG7BC,IAAAA,MAAM,EAAE,EAHqB;AAI7BC,IAAAA,eAAe,EAAE,EAJY;AAK7BC,IAAAA,YAAY,EAAE,EALe;AAM7BC,IAAAA,KAAK,EAAE,EANsB,EAAP,EAAjB;;;AASP;;;;;;AAMO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,MAAD,EAASC,OAAT,EAAqB;AACjD,MAAMC,MAAM,GAAG,EAAf,CADiD;;AAG/BF,EAAAA,MAH+B,aAGjD,oDAA0B,KAAjBG,KAAiB;AACxB,UAAMC,KAAK,GAAGD,KAAK,CAACR,MAAN,CAAaU,MAAb;AACZ,gBAAAC,CAAC,UAAIA,CAAC,CAACC,IAAF,KAAW,MAAX,IAAqBD,CAAC,CAACE,WAAF,CAAcP,OAAd,KAA0BA,OAAnD,EADW,CAAd,CADwB;;;AAKPG,MAAAA,KALO,cAKxB,uDAAwB,KAAfK,IAAe;AACtBP,UAAAA,MAAM,CAACQ,IAAP;AACUP,UAAAA,KAAK,CAACT,IADhB,uDAC+De,IAAI,CAACf,IADpE;;AAGD,SATuB;AAUzB,KAbgD;;AAejD,SAAO;AACLQ,IAAAA,MAAM,EAANA,MADK;AAELS,IAAAA,SAAS,EAAET,MAAM,CAACU,MAAP,GAAgB,CAFtB,EAAP;;AAID,CAnBM,C","sourcesContent":["import { generate } from \"shortid\"\n\nexport const newModel = () => ({\n id: generate(),\n name: \"\",\n fields: [],\n validationRules: [],\n primaryField: \"\",\n views: [],\n})\n\n/**\n *\n * @param {Array} models\n * @param {string} modelId\n * @returns {}\n */\nexport const canDeleteModel = (models, modelId) => {\n const errors = []\n\n for (let model of models) {\n const links = model.fields.filter(\n f => f.type === \"link\" && f.typeOptions.modelId === modelId\n )\n\n for (let link of links) {\n errors.push(\n `The \"${model.name}\" model links to this model, via field \"${link.name}\"`\n )\n }\n }\n\n return {\n errors,\n canDelete: errors.length > 0,\n }\n}\n"],"file":"models.js"}