diff --git a/packages/common/lib/common/apiWrapper.js.map b/packages/common/lib/common/apiWrapper.js.map index 0be7aeeb0e..a1ed6bc2e7 100644 --- a/packages/common/lib/common/apiWrapper.js.map +++ b/packages/common/lib/common/apiWrapper.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/apiWrapper.js"],"names":["apiWrapper","app","eventNamespace","isAuthorized","eventContext","func","pushCallStack","handleNotAuthorized","startDate","Date","now","elapsed","publish","onBegin","params","result","publishComplete","publishError","apiWrapperSync","error","err","UnauthorisedError","seedCallId","callId","createCallStack","threadCallId","stack","calls","push","namespace","popCallStack","pop","length","ctx","onError","endcontext","onComplete"],"mappings":"+ZAAA;AACA;AACA;;AAEO,IAAMA,UAAU,sHAAG;AACxBC,EAAAA,GADwB;AAExBC,EAAAA,cAFwB;AAGxBC,EAAAA,YAHwB;AAIxBC,EAAAA,YAJwB;AAKxBC,EAAAA,IALwB;;;AAQxBC,YAAAA,aAAa,CAACL,GAAD,EAAMC,cAAN,CAAb,CARwB;;AAUnBC,YAAAA,YAAY,CAACF,GAAD,CAVO;AAWtBM,YAAAA,mBAAmB,CAACN,GAAD,EAAMG,YAAN,EAAoBF,cAApB,CAAnB,CAXsB;;;;AAelBM,YAAAA,SAfkB,GAeNC,IAAI,CAACC,GAAL,EAfM;AAgBlBC,YAAAA,OAhBkB,GAgBR,SAAVA,OAAU,WAAMF,IAAI,CAACC,GAAL,KAAaF,SAAnB,EAhBQ;;;AAmBhBP,cAAAA,GAAG,CAACW,OAAJ,CAAYV,cAAc,CAACW,OAA3B,EAAoCT,YAApC,CAnBgB,mCAMrBU,MANqB,uEAMrBA,MANqB;;AAqBDT,cAAAA,IAAI,MAAJ,SAAQS,MAAR,CArBC,UAqBhBC,MArBgB;;AAuBhBC,cAAAA,eAAe,CAACf,GAAD,EAAMG,YAAN,EAAoBF,cAApB,EAAoCS,OAApC,EAA6CI,MAA7C,CAvBC;AAwBfA,YAAAA,MAxBe;;AA0BhBE,cAAAA,YAAY,CAA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CAACtB,OAAJ,GAAcA,OAAO,EAArB,CATmB;AAUbV,cAAAA,GAAG,CAACW,OAAJ,CAAYV,cAAc,CAACgC,OAA3B,EAAoCD,GAApC,CAVa;AAWnBH,YAAAA,YAAY,CAAC7B,GAAD,CAAZ,CAXmB,0DAAH,mBAAZgB,YAAY,qEAAlB;;;AAcA,IAAMD,eAAe,uHAAG;AACtBf,EAAAA,GADsB;AAEtBG,EAAAA,YAFsB;AAGtBF,EAAAA,cAHsB;AAItBS,EAAAA,OAJsB;AAKtBI,EAAAA,MALsB;;AAOhBoB,YAAAA,UAPgB,GAOH,mBAAU/B,YAAV,CAPG;AAQtB+B,YAAAA,UAAU,CAACpB,MAAX,GAAoBA,MAApB;AACAoB,YAAAA,UAAU,CAACxB,OAAX,GAAqBA,OAAO,EAA5B,CATsB;AAUhBV,cAAAA,GAAG,CAACW,OAAJ,CAAYV,cAAc,CAACkC,UAA3B,EAAuCD,UAAvC,CAVgB;AAWtBL,YAAAA,YAAY,CAAC7B,GAAD,CAAZ,CAXsB;AAYfc,YAAAA,MAZe,4DAAH,mBAAfC,eAAe,yEAArB,C;;;AAeehB,U","sourcesContent":["import { cloneDeep, isUndefined } from \"lodash/fp\"\r\nimport { generate } from \"shortid\"\r\nimport { UnauthorisedError } from \"./errors\"\r\n\r\nexport const apiWrapper = async (\r\n app,\r\n eventNamespace,\r\n isAuthorized,\r\n eventContext,\r\n func,\r\n ...params\r\n) => {\r\n pushCallStack(app, eventNamespace)\r\n\r\n if (!isAuthorized(app)) {\r\n handleNotAuthorized(app, eventContext, eventNamespace)\r\n return\r\n }\r\n\r\n const startDate = Date.now()\r\n const elapsed = () => Date.now() - startDate\r\n\r\n try {\r\n await app.publish(eventNamespace.onBegin, eventContext)\r\n\r\n const result = await func(...params)\r\n\r\n await publishComplete(app, eventContext, eventNamespace, elapsed, result)\r\n return result\r\n } catch (error) {\r\n await publishError(app, eventContext, eventNamespace, elapsed, error)\r\n throw error\r\n }\r\n}\r\n\r\nexport const apiWrapperSync = (\r\n app,\r\n eventNamespace,\r\n isAuthorized,\r\n eventContext,\r\n func,\r\n ...params\r\n) => {\r\n pushCallStack(app, eventNamespace)\r\n\r\n if (!isAuthorized(app)) {\r\n handleNotAuthorized(app, eventContext, eventNamespace)\r\n return\r\n }\r\n\r\n const startDate = Date.now()\r\n const elapsed = () => Date.now() - startDate\r\n\r\n try {\r\n app.publish(eventNamespace.onBegin, eventContext)\r\n\r\n const result = func(...params)\r\n\r\n publishComplete(app, eventContext, eventNamespace, elapsed, result)\r\n return result\r\n } catch (error) {\r\n publishError(app, eventContext, eventNamespace, elapsed, error)\r\n throw error\r\n }\r\n}\r\n\r\nconst handleNotAuthorized = (app, eventContext, eventNamespace) => {\r\n const err = new UnauthorisedError(`Unauthorized: ${eventNamespace}`)\r\n publishError(app, eventContext, eventNamespace, () => 0, err)\r\n throw err\r\n}\r\n\r\nconst pushCallStack = (app, eventNamespace, seedCallId) => {\r\n const callId = generate()\r\n\r\n const createCallStack = () => ({\r\n seedCallId: !isUndefined(seedCallId) ? seedCallId : callId,\r\n threadCallId: callId,\r\n stack: [],\r\n })\r\n\r\n if (isUndefined(app.calls)) {\r\n app.calls = createCallStack()\r\n }\r\n\r\n app.calls.stack.push({\r\n namespace: eventNamespace,\r\n callId,\r\n })\r\n}\r\n\r\nconst popCallStack = app => {\r\n app.calls.stack.pop()\r\n if (app.calls.stack.length === 0) {\r\n delete app.calls\r\n }\r\n}\r\n\r\nconst publishError = async (\r\n app,\r\n eventContext,\r\n eventNamespace,\r\n elapsed,\r\n err\r\n) => {\r\n const ctx = cloneDeep(eventContext)\r\n ctx.error = err\r\n ctx.elapsed = elapsed()\r\n await app.publish(eventNamespace.onError, ctx)\r\n popCallStack(app)\r\n}\r\n\r\nconst publishComplete = async (\r\n app,\r\n eventContext,\r\n eventNamespace,\r\n elapsed,\r\n result\r\n) => {\r\n const endcontext = cloneDeep(eventContext)\r\n endcontext.result = result\r\n endcontext.elapsed = elapsed()\r\n await app.publish(eventNamespace.onComplete, endcontext)\r\n popCallStack(app)\r\n return result\r\n}\r\n\r\nexport default apiWrapper\r\n"],"file":"apiWrapper.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/apiWrapper.js"],"names":["apiWrapper","app","eventNamespace","isAuthorized","eventContext","func","pushCallStack","handleNotAuthorized","startDate","Date","now","elapsed","publish","onBegin","params","result","publishComplete","publishError","apiWrapperSync","error","err","UnauthorisedError","seedCallId","callId","createCallStack","threadCallId","stack","calls","push","namespace","popCallStack","pop","length","ctx","onError","endcontext","onComplete"],"mappings":"+ZAAA;AACA;AACA;;AAEO,IAAMA,UAAU,sHAAG;AACxBC,EAAAA,GADwB;AAExBC,EAAAA,cAFwB;AAGxBC,EAAAA,YAHwB;AAIxBC,EAAAA,YAJwB;AAKxBC,EAAAA,IALwB;;;AAQxBC,YAAAA,aAAa,CAACL,GAAD,EAAMC,cAAN,CAAb,CARwB;;AAUnBC,YAAAA,YAAY,CAACF,GAAD,CAVO;AAWtBM,YAAAA,mBAAmB,CAACN,GAAD,EAAMG,YAAN,EAAoBF,cAApB,CAAnB,CAXsB;;;;AAelBM,YAAAA,SAfkB,GAeNC,IAAI,CAACC,GAAL,EAfM;AAgBlBC,YAAAA,OAhBkB,GAgBR,SAAVA,OAAU,WAAMF,IAAI,CAACC,GAAL,KAAaF,SAAnB,EAhBQ;;;AAmBhBP,cAAAA,GAAG,CAACW,OAAJ,CAAYV,cAAc,CAACW,OAA3B,EAAoCT,YAApC,CAnBgB,mCAMrBU,MANqB,uEAMrBA,MANqB;;AAqBDT,cAAAA,IAAI,MAAJ,SAAQS,MAAR,CArBC,UAqBhBC,MArBgB;;AAuBhBC,cAAAA,eAAe,CAACf,GAAD,EAAMG,YAAN,EAAoBF,cAApB,EAAoCS,OAApC,EAA6CI,MAA7C,CAvBC;AAwBfA,YAAAA,MAxBe;;AA0BhBE,cAAAA,YAAY,CAAChB,GAAD,EAAMG,YAAN,EAAoBF,cAApB,EAAoCS,OAApC,cA1BI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G,CAACW,OAAJ,CAAYV,cAAc,CAACgC,OAA3B,EAAoCD,GAApC,CAVa;AAWnBH,YAAAA,YAAY,CAAC7B,GAAD,CAAZ,CAXmB,0DAAH,mBAAZgB,YAAY,qEAAlB;;;AAcA,IAAMD,eAAe,uHAAG;AACtBf,EAAAA,GADsB;AAEtBG,EAAAA,YAFsB;AAGtBF,EAAAA,cAHsB;AAItBS,EAAAA,OAJsB;AAKtBI,EAAAA,MALsB;;AAOhBoB,YAAAA,UAPgB,GAOH,mBAAU/B,YAAV,CAPG;AAQtB+B,YAAAA,UAAU,CAACpB,MAAX,GAAoBA,MAApB;AACAoB,YAAAA,UAAU,CAACxB,OAAX,GAAqBA,OAAO,EAA5B,CATsB;AAUhBV,cAAAA,GAAG,CAACW,OAAJ,CAAYV,cAAc,CAACkC,UAA3B,EAAuCD,UAAvC,CAVgB;AAWtBL,YAAAA,YAAY,CAAC7B,GAAD,CAAZ,CAXsB;AAYfc,YAAAA,MAZe,4DAAH,mBAAfC,eAAe,yEAArB,C;;;AAeehB,U","sourcesContent":["import { cloneDeep, isUndefined } from \"lodash/fp\"\nimport { generate } from \"shortid\"\nimport { UnauthorisedError } from \"./errors\"\n\nexport const apiWrapper = async (\n app,\n eventNamespace,\n isAuthorized,\n eventContext,\n func,\n ...params\n) => {\n pushCallStack(app, eventNamespace)\n\n if (!isAuthorized(app)) {\n handleNotAuthorized(app, eventContext, eventNamespace)\n return\n }\n\n const startDate = Date.now()\n const elapsed = () => Date.now() - startDate\n\n try {\n await app.publish(eventNamespace.onBegin, eventContext)\n\n const result = await func(...params)\n\n await publishComplete(app, eventContext, eventNamespace, elapsed, result)\n return result\n } catch (error) {\n await publishError(app, eventContext, eventNamespace, elapsed, error)\n throw error\n }\n}\n\nexport const apiWrapperSync = (\n app,\n eventNamespace,\n isAuthorized,\n eventContext,\n func,\n ...params\n) => {\n pushCallStack(app, eventNamespace)\n\n if (!isAuthorized(app)) {\n handleNotAuthorized(app, eventContext, eventNamespace)\n return\n }\n\n const startDate = Date.now()\n const elapsed = () => Date.now() - startDate\n\n try {\n app.publish(eventNamespace.onBegin, eventContext)\n\n const result = func(...params)\n\n publishComplete(app, eventContext, eventNamespace, elapsed, result)\n return result\n } catch (error) {\n publishError(app, eventContext, eventNamespace, elapsed, error)\n throw error\n }\n}\n\nconst handleNotAuthorized = (app, eventContext, eventNamespace) => {\n const err = new UnauthorisedError(`Unauthorized: ${eventNamespace}`)\n publishError(app, eventContext, eventNamespace, () => 0, err)\n throw err\n}\n\nconst pushCallStack = (app, eventNamespace, seedCallId) => {\n const callId = generate()\n\n const createCallStack = () => ({\n seedCallId: !isUndefined(seedCallId) ? seedCallId : callId,\n threadCallId: callId,\n stack: [],\n })\n\n if (isUndefined(app.calls)) {\n app.calls = createCallStack()\n }\n\n app.calls.stack.push({\n namespace: eventNamespace,\n callId,\n })\n}\n\nconst popCallStack = app => {\n app.calls.stack.pop()\n if (app.calls.stack.length === 0) {\n delete app.calls\n }\n}\n\nconst publishError = async (\n app,\n eventContext,\n eventNamespace,\n elapsed,\n err\n) => {\n const ctx = cloneDeep(eventContext)\n ctx.error = err\n ctx.elapsed = elapsed()\n await app.publish(eventNamespace.onError, ctx)\n popCallStack(app)\n}\n\nconst publishComplete = async (\n app,\n eventContext,\n eventNamespace,\n elapsed,\n result\n) => {\n const endcontext = cloneDeep(eventContext)\n endcontext.result = result\n endcontext.elapsed = elapsed()\n await app.publish(eventNamespace.onComplete, endcontext)\n popCallStack(app)\n return result\n}\n\nexport default apiWrapper\n"],"file":"apiWrapper.js"} \ No newline at end of file diff --git a/packages/common/lib/common/compileCode.js.map b/packages/common/lib/common/compileCode.js.map index 4004d3743a..f32cc0ab6c 100644 --- a/packages/common/lib/common/compileCode.js.map +++ b/packages/common/lib/common/compileCode.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/compileCode.js"],"names":["compileCode","code","func","safeCode","trimmed","trim","endsWith","substring","length","e","message"],"mappings":"wGAAA;AACA;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAAAC,IAAI,EAAI;AACjC,MAAIC,IAAJ;AACA,MAAIC,QAAJ;;AAEA,MAAI,kBAAS,SAAT,EAAoBF,IAApB,CAAJ,EAA+B;AAC7BE,IAAAA,QAAQ,GAAGF,IAAX;AACD,GAFD,MAEO;AACL,QAAIG,OAAO,GAAGH,IAAI,CAACI,IAAL,EAAd;AACAD,IAAAA,OAAO,GAAGA,OAAO,CAACE,QAAR,CAAiB,GAAjB;AACNF,IAAAA,OAAO,CAACG,SAAR,CAAkB,CAAlB,EAAqBH,OAAO,CAACI,MAAR,GAAiB,CAAtC,CADM;AAENJ,IAAAA,OAFJ;AAGAD,IAAAA,QAAQ,qBAAcC,OAAd,MAAR;AACD;;AAED,MAAI;AACFF,IAAAA,IAAI,GAAG,+BAAMC,QAAN,CAAP;AACD,GAFD,CAEE,OAAOM,CAAP,EAAU;AACVA,IAAAA,CAAC,CAACC,OAAF,oCAAsCT,IAAtC,gBAAgDQ,CAAC,CAACC,OAAlD;AACA,UAAMD,CAAN;AACD;;AAED,SAAOP,IAAP;AACD,CAtBM,C","sourcesContent":["import { compileCode as cCode } from \"@nx-js/compiler-util\"\r\nimport { includes } from \"lodash/fp\"\r\n\r\nexport const compileCode = code => {\r\n let func\r\n let safeCode\r\n\r\n if (includes(\"return \")(code)) {\r\n safeCode = code\r\n } else {\r\n let trimmed = code.trim()\r\n trimmed = trimmed.endsWith(\";\")\r\n ? trimmed.substring(0, trimmed.length - 1)\r\n : trimmed\r\n safeCode = `return (${trimmed})`\r\n }\r\n\r\n try {\r\n func = cCode(safeCode)\r\n } catch (e) {\r\n e.message = `Error compiling code : ${code} : ${e.message}`\r\n throw e\r\n }\r\n\r\n return func\r\n}\r\n"],"file":"compileCode.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/compileCode.js"],"names":["compileCode","code","func","safeCode","trimmed","trim","endsWith","substring","length","e","message"],"mappings":"wGAAA;AACA;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAAAC,IAAI,EAAI;AACjC,MAAIC,IAAJ;AACA,MAAIC,QAAJ;;AAEA,MAAI,kBAAS,SAAT,EAAoBF,IAApB,CAAJ,EAA+B;AAC7BE,IAAAA,QAAQ,GAAGF,IAAX;AACD,GAFD,MAEO;AACL,QAAIG,OAAO,GAAGH,IAAI,CAACI,IAAL,EAAd;AACAD,IAAAA,OAAO,GAAGA,OAAO,CAACE,QAAR,CAAiB,GAAjB;AACNF,IAAAA,OAAO,CAACG,SAAR,CAAkB,CAAlB,EAAqBH,OAAO,CAACI,MAAR,GAAiB,CAAtC,CADM;AAENJ,IAAAA,OAFJ;AAGAD,IAAAA,QAAQ,qBAAcC,OAAd,MAAR;AACD;;AAED,MAAI;AACFF,IAAAA,IAAI,GAAG,+BAAMC,QAAN,CAAP;AACD,GAFD,CAEE,OAAOM,CAAP,EAAU;AACVA,IAAAA,CAAC,CAACC,OAAF,oCAAsCT,IAAtC,gBAAgDQ,CAAC,CAACC,OAAlD;AACA,UAAMD,CAAN;AACD;;AAED,SAAOP,IAAP;AACD,CAtBM,C","sourcesContent":["import { compileCode as cCode } from \"@nx-js/compiler-util\"\nimport { includes } from \"lodash/fp\"\n\nexport const compileCode = code => {\n let func\n let safeCode\n\n if (includes(\"return \")(code)) {\n safeCode = code\n } else {\n let trimmed = code.trim()\n trimmed = trimmed.endsWith(\";\")\n ? trimmed.substring(0, trimmed.length - 1)\n : trimmed\n safeCode = `return (${trimmed})`\n }\n\n try {\n func = cCode(safeCode)\n } catch (e) {\n e.message = `Error compiling code : ${code} : ${e.message}`\n throw e\n }\n\n return func\n}\n"],"file":"compileCode.js"} \ No newline at end of file diff --git a/packages/common/lib/common/errors.js.map b/packages/common/lib/common/errors.js.map index c39f05df0f..833284900a 100644 --- a/packages/common/lib/common/errors.js.map +++ b/packages/common/lib/common/errors.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/errors.js"],"names":["BadRequestError","message","httpStatusCode","Error","UnauthorisedError","ForbiddenError","NotFoundError","ConflictError"],"mappings":"i9CAAaA,e;AACX,2BAAYC,OAAZ,EAAqB;AACnB,8BAAMA,OAAN;AACA,UAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,yEAJkCC,K;;;AAOxBC,iB;AACX,6BAAYH,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,2EAJoCC,K;;;AAO1BE,c;AACX,0BAAYJ,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,wEAJiCC,K;;;AAOvBG,a;AACX,yBAAYL,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,uEAJgCC,K;;;AAOtBI,a;AACX,yBAAYN,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,uEAJgCC,K","sourcesContent":["export class BadRequestError extends Error {\r\n constructor(message) {\r\n super(message)\r\n this.httpStatusCode = 400\r\n }\r\n}\r\n\r\nexport class UnauthorisedError extends Error {\r\n constructor(message) {\r\n super(message)\r\n this.httpStatusCode = 401\r\n }\r\n}\r\n\r\nexport class ForbiddenError extends Error {\r\n constructor(message) {\r\n super(message)\r\n this.httpStatusCode = 403\r\n }\r\n}\r\n\r\nexport class NotFoundError extends Error {\r\n constructor(message) {\r\n super(message)\r\n this.httpStatusCode = 404\r\n }\r\n}\r\n\r\nexport class ConflictError extends Error {\r\n constructor(message) {\r\n super(message)\r\n this.httpStatusCode = 409\r\n }\r\n}\r\n"],"file":"errors.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/errors.js"],"names":["BadRequestError","message","httpStatusCode","Error","UnauthorisedError","ForbiddenError","NotFoundError","ConflictError"],"mappings":"i9CAAaA,e;AACX,2BAAYC,OAAZ,EAAqB;AACnB,8BAAMA,OAAN;AACA,UAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,yEAJkCC,K;;;AAOxBC,iB;AACX,6BAAYH,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,2EAJoCC,K;;;AAO1BE,c;AACX,0BAAYJ,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,wEAJiCC,K;;;AAOvBG,a;AACX,yBAAYL,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,uEAJgCC,K;;;AAOtBI,a;AACX,yBAAYN,OAAZ,EAAqB;AACnB,gCAAMA,OAAN;AACA,WAAKC,cAAL,GAAsB,GAAtB,CAFmB;AAGpB,G,uEAJgCC,K","sourcesContent":["export class BadRequestError extends Error {\n constructor(message) {\n super(message)\n this.httpStatusCode = 400\n }\n}\n\nexport class UnauthorisedError extends Error {\n constructor(message) {\n super(message)\n this.httpStatusCode = 401\n }\n}\n\nexport class ForbiddenError extends Error {\n constructor(message) {\n super(message)\n this.httpStatusCode = 403\n }\n}\n\nexport class NotFoundError extends Error {\n constructor(message) {\n super(message)\n this.httpStatusCode = 404\n }\n}\n\nexport class ConflictError extends Error {\n constructor(message) {\n super(message)\n this.httpStatusCode = 409\n }\n}\n"],"file":"errors.js"} \ No newline at end of file diff --git a/packages/common/lib/common/eventAggregator.js.map b/packages/common/lib/common/eventAggregator.js.map index 3dd9e6d67b..8c8719202d 100644 --- a/packages/common/lib/common/eventAggregator.js.map +++ b/packages/common/lib/common/eventAggregator.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/eventAggregator.js"],"names":["publish","handlers","eventName","context","handler","subscribe","push","createEventAggregator","eventAggregator"],"mappings":"iZAAA,+B;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAAAC,QAAQ,6HAAI,iBAAOC,SAAP,oLAAkBC,OAAlB,2DAA4B,EAA5B;AACrB,2BAAID,SAAJ,EAAeD,QAAf,CADqB;;AAGJA,cAAAA,QAAQ,CAACC,SAAD,CAHJ,sGAGfE,OAHe;AAIlBA,gBAAAA,OAAO,CAACF,SAAD,EAAYC,OAAZ,CAJW,gTAAJ,mEAAxB;;;;AAQA,IAAME,SAAS,GAAG,SAAZA,SAAY,CAAAJ,QAAQ,UAAI,UAACC,SAAD,EAAYE,OAAZ,EAAwB;AACpD,QAAI,CAAC,aAAIF,SAAJ,EAAeD,QAAf,CAAL,EAA+B;AAC7BA,MAAAA,QAAQ,CAACC,SAAD,CAAR,GAAsB,EAAtB;AACD;AACDD,IAAAA,QAAQ,CAACC,SAAD,CAAR,CAAoBI,IAApB,CAAyBF,OAAzB;AACD,GALyB,EAA1B;;AAOO,IAAMG,qBAAqB,GAAG,SAAxBA,qBAAwB,GAAM;AACzC,MAAMN,QAAQ,GAAG,EAAjB;AACA,MAAMO,eAAe,GAAG;AACtBR,IAAAA,OAAO,EAAEA,OAAO,CAACC,QAAD,CADM;AAEtBI,IAAAA,SAAS,EAAEA,SAAS,CAACJ,QAAD,CAFE,EAAxB;;AAIA,SAAOO,eAAP;AACD,CAPM,C;;AASQD,qB","sourcesContent":["import { has } from \"lodash/fp\"\r\n\r\nconst publish = handlers => async (eventName, context = {}) => {\r\n if (!has(eventName)(handlers)) return\r\n\r\n for (const handler of handlers[eventName]) {\r\n await handler(eventName, context)\r\n }\r\n}\r\n\r\nconst subscribe = handlers => (eventName, handler) => {\r\n if (!has(eventName)(handlers)) {\r\n handlers[eventName] = []\r\n }\r\n handlers[eventName].push(handler)\r\n}\r\n\r\nexport const createEventAggregator = () => {\r\n const handlers = {}\r\n const eventAggregator = {\r\n publish: publish(handlers),\r\n subscribe: subscribe(handlers),\r\n }\r\n return eventAggregator\r\n}\r\n\r\nexport default createEventAggregator\r\n"],"file":"eventAggregator.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/eventAggregator.js"],"names":["publish","handlers","eventName","context","handler","subscribe","push","createEventAggregator","eventAggregator"],"mappings":"iZAAA,+B;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAAAC,QAAQ,6HAAI,iBAAOC,SAAP,oLAAkBC,OAAlB,2DAA4B,EAA5B;AACrB,2BAAID,SAAJ,EAAeD,QAAf,CADqB;;AAGJA,cAAAA,QAAQ,CAACC,SAAD,CAHJ,sGAGfE,OAHe;AAIlBA,gBAAAA,OAAO,CAACF,SAAD,EAAYC,OAAZ,CAJW,gTAAJ,mEAAxB;;;;AAQA,IAAME,SAAS,GAAG,SAAZA,SAAY,CAAAJ,QAAQ,UAAI,UAACC,SAAD,EAAYE,OAAZ,EAAwB;AACpD,QAAI,CAAC,aAAIF,SAAJ,EAAeD,QAAf,CAAL,EAA+B;AAC7BA,MAAAA,QAAQ,CAACC,SAAD,CAAR,GAAsB,EAAtB;AACD;AACDD,IAAAA,QAAQ,CAACC,SAAD,CAAR,CAAoBI,IAApB,CAAyBF,OAAzB;AACD,GALyB,EAA1B;;AAOO,IAAMG,qBAAqB,GAAG,SAAxBA,qBAAwB,GAAM;AACzC,MAAMN,QAAQ,GAAG,EAAjB;AACA,MAAMO,eAAe,GAAG;AACtBR,IAAAA,OAAO,EAAEA,OAAO,CAACC,QAAD,CADM;AAEtBI,IAAAA,SAAS,EAAEA,SAAS,CAACJ,QAAD,CAFE,EAAxB;;AAIA,SAAOO,eAAP;AACD,CAPM,C;;AASQD,qB","sourcesContent":["import { has } from \"lodash/fp\"\n\nconst publish = handlers => async (eventName, context = {}) => {\n if (!has(eventName)(handlers)) return\n\n for (const handler of handlers[eventName]) {\n await handler(eventName, context)\n }\n}\n\nconst subscribe = handlers => (eventName, handler) => {\n if (!has(eventName)(handlers)) {\n handlers[eventName] = []\n }\n handlers[eventName].push(handler)\n}\n\nexport const createEventAggregator = () => {\n const handlers = {}\n const eventAggregator = {\n publish: publish(handlers),\n subscribe: subscribe(handlers),\n }\n return eventAggregator\n}\n\nexport default createEventAggregator\n"],"file":"eventAggregator.js"} \ No newline at end of file diff --git a/packages/common/lib/common/events.js.map b/packages/common/lib/common/events.js.map index f290ec2c42..edf1c04791 100644 --- a/packages/common/lib/common/events.js.map +++ b/packages/common/lib/common/events.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/events.js"],"names":["commonPlus","extra","common","_events","recordApi","save","getContext","getNew","load","validate","uploadFile","downloadFile","indexApi","buildIndex","listItems","aggregates","collectionApi","getAllowedRecordTypes","initialise","authApi","authenticate","authenticateTemporaryAccess","createTemporaryAccess","createUser","enableUser","disableUser","loadAccessLevels","getNewAccessLevel","getNewUser","getNewUserAuth","getUsers","saveAccessLevels","isAuthorized","changeMyPassword","setPasswordFromTemporaryCode","scorePassword","isValidPassword","validateUser","validateAccessLevels","setUserAccessLevels","templateApi","saveApplicationHierarchy","saveActionsAndTriggers","actionsApi","execute","_eventsList","makeEvent","area","method","name","areaKey","methodKey","obj","s","push","events","eventsList"],"mappings":"6IAAA;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK,UAAI,eAAM,CAAC,SAAD,EAAY,YAAZ,EAA0B,SAA1B,CAAN,EAA4CA,KAA5C,CAAJ,EAAxB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,WAAMF,UAAU,CAAC,EAAD,CAAhB,EAAf;;AAEA,IAAMG,OAAO,GAAG;AACdC,EAAAA,SAAS,EAAE;AACTC,IAAAA,IAAI,EAAEL,UAAU,CAAC,CAAC,WAAD,EAAc,iBAAd,EAAiC,iBAAjC,CAAD,CADP;AAET,cAAQE,MAAM,EAFL;AAGTI,IAAAA,UAAU,EAAEJ,MAAM,EAHT;AAITK,IAAAA,MAAM,EAAEL,MAAM,EAJL;AAKTM,IAAAA,IAAI,EAAEN,MAAM,EALH;AAMTO,IAAAA,QAAQ,EAAEP,MAAM,EANP;AAOTQ,IAAAA,UAAU,EAAER,MAAM,EAPT;AAQTS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B,CAAjB;AACD;AACF;AACF;;AAEM,IAAMM,MAAM,GAAGpD,OAAf,C;;AAEA,IAAMqD,UAAU,GAAGX,WAAnB,C;;AAEQ,EAAEU,MAAM,EAAEpD,OAAV,EAAmBqD,UAAU,EAAEX,WAA/B,E","sourcesContent":["import { union, reduce } from \"lodash/fp\"\r\n\r\nconst commonPlus = extra => union([\"onBegin\", \"onComplete\", \"onError\"])(extra)\r\n\r\nconst common = () => commonPlus([])\r\n\r\nconst _events = {\r\n recordApi: {\r\n save: commonPlus([\"onInvalid\", \"onRecordUpdated\", \"onRecordCreated\"]),\r\n delete: common(),\r\n getContext: common(),\r\n getNew: common(),\r\n load: common(),\r\n validate: common(),\r\n uploadFile: common(),\r\n downloadFile: common(),\r\n },\r\n indexApi: {\r\n buildIndex: common(),\r\n listItems: common(),\r\n delete: common(),\r\n aggregates: common(),\r\n },\r\n collectionApi: {\r\n getAllowedRecordTypes: common(),\r\n initialise: common(),\r\n delete: common(),\r\n },\r\n authApi: {\r\n authenticate: common(),\r\n authenticateTemporaryAccess: common(),\r\n createTemporaryAccess: common(),\r\n createUser: common(),\r\n enableUser: common(),\r\n disableUser: common(),\r\n loadAccessLevels: common(),\r\n getNewAccessLevel: common(),\r\n getNewUser: common(),\r\n getNewUserAuth: common(),\r\n getUsers: common(),\r\n saveAccessLevels: common(),\r\n isAuthorized: common(),\r\n changeMyPassword: common(),\r\n setPasswordFromTemporaryCode: common(),\r\n scorePassword: common(),\r\n isValidPassword: common(),\r\n validateUser: common(),\r\n validateAccessLevels: common(),\r\n setUserAccessLevels: common(),\r\n },\r\n templateApi: {\r\n saveApplicationHierarchy: common(),\r\n saveActionsAndTriggers: common(),\r\n },\r\n actionsApi: {\r\n execute: common(),\r\n },\r\n}\r\n\r\nconst _eventsList = []\r\n\r\nconst makeEvent = (area, method, name) => `${area}:${method}:${name}`\r\n\r\nfor (const areaKey in _events) {\r\n for (const methodKey in _events[areaKey]) {\r\n _events[areaKey][methodKey] = reduce((obj, s) => {\r\n obj[s] = makeEvent(areaKey, methodKey, s)\r\n return obj\r\n }, {})(_events[areaKey][methodKey])\r\n }\r\n}\r\n\r\nfor (const areaKey in _events) {\r\n for (const methodKey in _events[areaKey]) {\r\n for (const name in _events[areaKey][methodKey]) {\r\n _eventsList.push(_events[areaKey][methodKey][name])\r\n }\r\n }\r\n}\r\n\r\nexport const events = _events\r\n\r\nexport const eventsList = _eventsList\r\n\r\nexport default { events: _events, eventsList: _eventsList }\r\n"],"file":"events.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/events.js"],"names":["commonPlus","extra","common","_events","recordApi","save","getContext","getNew","load","validate","uploadFile","downloadFile","indexApi","buildIndex","listItems","aggregates","collectionApi","getAllowedRecordTypes","initialise","authApi","authenticate","authenticateTemporaryAccess","createTemporaryAccess","createUser","enableUser","disableUser","loadAccessLevels","getNewAccessLevel","getNewUser","getNewUserAuth","getUsers","saveAccessLevels","isAuthorized","changeMyPassword","setPasswordFromTemporaryCode","scorePassword","isValidPassword","validateUser","validateAccessLevels","setUserAccessLevels","templateApi","saveApplicationHierarchy","saveActionsAndTriggers","actionsApi","execute","_eventsList","makeEvent","area","method","name","areaKey","methodKey","obj","s","push","events","eventsList"],"mappings":"6IAAA;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK,UAAI,eAAM,CAAC,SAAD,EAAY,YAAZ,EAA0B,SAA1B,CAAN,EAA4CA,KAA5C,CAAJ,EAAxB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,WAAMF,UAAU,CAAC,EAAD,CAAhB,EAAf;;AAEA,IAAMG,OAAO,GAAG;AACdC,EAAAA,SAAS,EAAE;AACTC,IAAAA,IAAI,EAAEL,UAAU,CAAC,CAAC,WAAD,EAAc,iBAAd,EAAiC,iBAAjC,CAAD,CADP;AAET,cAAQE,MAAM,EAFL;AAGTI,IAAAA,UAAU,EAAEJ,MAAM,EAHT;AAITK,IAAAA,MAAM,EAAEL,MAAM,EAJL;AAKT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AjB,CAAnB,EAAgD;AAC9CN,MAAAA,WAAW,CAACS,IAAZ,CAAiBnD,OAAO,CAAC+C,QAAD,CAAP,CAAiBC,SAAjB,EAA4BF,IAA5B,CAAjB;AACD;AACF;AACF;;AAEM,IAAMM,MAAM,GAAGpD,OAAf,C;;AAEA,IAAMqD,UAAU,GAAGX,WAAnB,C;;AAEQ,EAAEU,MAAM,EAAEpD,OAAV,EAAmBqD,UAAU,EAAEX,WAA/B,E","sourcesContent":["import { union, reduce } from \"lodash/fp\"\n\nconst commonPlus = extra => union([\"onBegin\", \"onComplete\", \"onError\"])(extra)\n\nconst common = () => commonPlus([])\n\nconst _events = {\n recordApi: {\n save: commonPlus([\"onInvalid\", \"onRecordUpdated\", \"onRecordCreated\"]),\n delete: common(),\n getContext: common(),\n getNew: common(),\n load: common(),\n validate: common(),\n uploadFile: common(),\n downloadFile: common(),\n },\n indexApi: {\n buildIndex: common(),\n listItems: common(),\n delete: common(),\n aggregates: common(),\n },\n collectionApi: {\n getAllowedRecordTypes: common(),\n initialise: common(),\n delete: common(),\n },\n authApi: {\n authenticate: common(),\n authenticateTemporaryAccess: common(),\n createTemporaryAccess: common(),\n createUser: common(),\n enableUser: common(),\n disableUser: common(),\n loadAccessLevels: common(),\n getNewAccessLevel: common(),\n getNewUser: common(),\n getNewUserAuth: common(),\n getUsers: common(),\n saveAccessLevels: common(),\n isAuthorized: common(),\n changeMyPassword: common(),\n setPasswordFromTemporaryCode: common(),\n scorePassword: common(),\n isValidPassword: common(),\n validateUser: common(),\n validateAccessLevels: common(),\n setUserAccessLevels: common(),\n },\n templateApi: {\n saveApplicationHierarchy: common(),\n saveActionsAndTriggers: common(),\n },\n actionsApi: {\n execute: common(),\n },\n}\n\nconst _eventsList = []\n\nconst makeEvent = (area, method, name) => `${area}:${method}:${name}`\n\nfor (const areaKey in _events) {\n for (const methodKey in _events[areaKey]) {\n _events[areaKey][methodKey] = reduce((obj, s) => {\n obj[s] = makeEvent(areaKey, methodKey, s)\n return obj\n }, {})(_events[areaKey][methodKey])\n }\n}\n\nfor (const areaKey in _events) {\n for (const methodKey in _events[areaKey]) {\n for (const name in _events[areaKey][methodKey]) {\n _eventsList.push(_events[areaKey][methodKey][name])\n }\n }\n}\n\nexport const events = _events\n\nexport const eventsList = _eventsList\n\nexport default { events: _events, eventsList: _eventsList }\n"],"file":"events.js"} \ No newline at end of file diff --git a/packages/common/lib/common/index.js.map b/packages/common/lib/common/index.js.map index b4ce84d9f5..775e613d7a 100644 --- a/packages/common/lib/common/index.js.map +++ b/packages/common/lib/common/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/index.js"],"names":["$$","funcs","arg","$","keySep","trimKeySep","str","splitByKeySep","safeKey","key","joinKey","strs","paramsOrArray","length","s","toString","splitKey","getDirFomKey","dropRight","p","getFileFromKey","takeRight","head","configFolder","fieldDefinitions","templateDefinitions","appDefinitionFile","dirIndex","folderPath","getIndexKeyFromFileKey","ifExists","val","exists","notExists","getOrDefault","defaultVal","not","func","isDefined","isUndefined","isNonNull","isNull","isNotNaN","isNaN","allTrue","funcArgs","result","conditionFunc","anyTrue","insensitiveEquals","str1","str2","trim","toLowerCase","isSomething","isNothing","isNothingOrEmpty","v","somethingOrGetDefault","getDefaultFunc","somethingOrDefault","mapIfSomethingOrDefault","mapFunc","mapIfSomethingOrBlank","none","predicate","collection","all","isNotEmpty","ob","isAsync","fn","constructor","name","isNonEmptyArray","isArray","isNonEmptyString","isString","tryOr","failFunc","args","apply","_","tryAwaitOr","defineError","errorPrefix","err","message","tryOrIgnore","tryAwaitOrIgnore","causesException","e","executesWithoutException","handleErrorWith","returnValInError","handleErrorWithUndefined","undefined","switchCase","cases","value","nextCase","nextResult","isValue","val1","val2","isOneOf","vals","defaultCase","memberMatches","member","match","obj","StartsWith","searchFor","searchIn","contains","array","getHashCode","hash","i","char","l","charCodeAt","awEx","promise","isSafeInteger","n","Number","MAX_SAFE_INTEGER","toDateOrNull","Date","toBoolOrNull","toNumberOrNull","isArrayOfString","opts","pushAll","target","items","push","pause","duration","Promise","res","setTimeout","retry","retries","delay","then","events","eventsList","toNumber","toDate","toBool"],"mappings":"06DAAA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;AAkBA,qC;;AAEA;AACO,IAAMA,EAAE,GAAG,SAALA,EAAK,sCAAIC,KAAJ,oDAAIA,KAAJ,iCAAc,UAAAC,GAAG,UAAI,kBAAKD,KAAL,EAAYC,GAAZ,CAAJ,EAAjB,EAAX;;AAEP;gBACO,IAAMC,CAAC,GAAG,SAAJA,CAAI,CAACD,GAAD,EAAMD,KAAN,UAAgBD,EAAE,MAAF,6CAAMC,KAAN,GAAaC,GAAb,CAAhB,EAAV,C;;AAEA,IAAME,MAAM,GAAG,GAAf,C;AACP,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,GAAG,UAAI,kBAAKA,GAAL,EAAUF,MAAV,CAAJ,EAAtB;AACA,IAAMG,aAAa,GAAG,SAAhBA,aAAgB,CAAAD,GAAG,UAAI,eAAMF,MAAN,EAAcE,GAAd,CAAJ,EAAzB;AACO,IAAME,OAAO,GAAG,SAAVA,OAAU,CAAAC,GAAG;AACxB,mCAAWL,MAAX,SAAoBC,UAAU,CAACI,GAAD,CAA9B,aAA0CL,MAA1C,SAAmDA,MAAnD,GAA6DA,MAA7D,CADwB,GAAnB,C;AAEA,IAAMM,OAAO,GAAG,SAAVA,OAAU,GAAa,oCAATC,IAAS,yDAATA,IAAS;AAClC,MAAMC,aAAa,GAAID,IAAI,CAACE,MAAL,KAAgB,CAAjB,GAAsB,iBAAQF,IAAI,CAAC,CAAD,CAAZ,CAAtB,GAAyCA,IAAI,CAAC,CAAD,CAA7C,GAAmDA,IAAzE;AACA,SAAOR,CAAC,CAACS,aAAD,EAAgB;AACtB,kBAAO,UAAAE,CAAC,UAAI,CAAC,qBAAYA,CAAZ,CAAD,IAAmB,CAAC,gBAAOA,CAAP,CAApB,IAAiCA,CAAC,CAACC,QAAF,GAAaF,MAAb,GAAs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;AA0Db0F,EAAAA,KAAK,EAALA,KA1Da;AA2DbK,EAAAA,KAAK,EAALA,KA3Da;AA4DbT,EAAAA,OAAO,EAAPA,OA5Da,E","sourcesContent":["import {\r\n head,\r\n tail,\r\n findIndex,\r\n startsWith,\r\n dropRight,\r\n flow,\r\n takeRight,\r\n trim,\r\n replace,\r\n} from \"lodash\"\r\nimport {\r\n some,\r\n reduce,\r\n isEmpty,\r\n isArray,\r\n join,\r\n isString,\r\n isInteger,\r\n isDate,\r\n toNumber,\r\n isUndefined,\r\n isNaN,\r\n isNull,\r\n constant,\r\n split,\r\n includes,\r\n filter,\r\n} from \"lodash/fp\"\r\nimport { events, eventsList } from \"./events.js\"\r\n\r\n// this is the combinator function\r\nexport const $$ = (...funcs) => arg => flow(funcs)(arg)\r\n\r\n// this is the pipe function\r\nexport const $ = (arg, funcs) => $$(...funcs)(arg)\r\n\r\nexport const keySep = \"/\"\r\nconst trimKeySep = str => trim(str, keySep)\r\nconst splitByKeySep = str => split(keySep)(str)\r\nexport const safeKey = key =>\r\n replace(`${keySep}${trimKeySep(key)}`, `${keySep}${keySep}`, keySep)\r\nexport const joinKey = (...strs) => {\r\n const paramsOrArray = (strs.length === 1) & isArray(strs[0]) ? strs[0] : strs\r\n return $(paramsOrArray, [\r\n filter(s => !isUndefined(s) && !isNull(s) && s.toString().length > 0),\r\n join(keySep),\r\n safeKey,\r\n ])\r\n}\r\nexport const splitKey = $$(trimKeySep, splitByKeySep)\r\nexport const getDirFomKey = $$(splitKey, dropRight, p => joinKey(...p))\r\nexport const getFileFromKey = $$(splitKey, takeRight, head)\r\n\r\nexport const configFolder = `${keySep}.config`\r\nexport const fieldDefinitions = joinKey(configFolder, \"fields.json\")\r\nexport const templateDefinitions = joinKey(configFolder, \"templates.json\")\r\nexport const appDefinitionFile = joinKey(configFolder, \"appDefinition.json\")\r\nexport const dirIndex = folderPath =>\r\n joinKey(configFolder, \"dir\", ...splitKey(folderPath), \"dir.idx\")\r\nexport const getIndexKeyFromFileKey = $$(getDirFomKey, dirIndex)\r\n\r\nexport const ifExists = (val, exists, notExists) =>\r\n isUndefined(val)\r\n ? isUndefined(notExists)\r\n ? (() => {})()\r\n : notExists()\r\n : exists()\r\n\r\nexport const getOrDefault = (val, defaultVal) =>\r\n ifExists(\r\n val,\r\n () => val,\r\n () => defaultVal\r\n )\r\n\r\nexport const not = func => val => !func(val)\r\nexport const isDefined = not(isUndefined)\r\nexport const isNonNull = not(isNull)\r\nexport const isNotNaN = not(isNaN)\r\n\r\nexport const allTrue = (...funcArgs) => val =>\r\n reduce(\r\n (result, conditionFunc) =>\r\n (isNull(result) || result == true) && conditionFunc(val),\r\n null\r\n )(funcArgs)\r\n\r\nexport const anyTrue = (...funcArgs) => val =>\r\n reduce(\r\n (result, conditionFunc) => result == true || conditionFunc(val),\r\n null\r\n )(funcArgs)\r\n\r\nexport const insensitiveEquals = (str1, str2) =>\r\n str1.trim().toLowerCase() === str2.trim().toLowerCase()\r\n\r\nexport const isSomething = allTrue(isDefined, isNonNull, isNotNaN)\r\nexport const isNothing = not(isSomething)\r\nexport const isNothingOrEmpty = v => isNothing(v) || isEmpty(v)\r\nexport const somethingOrGetDefault = getDefaultFunc => val =>\r\n isSomething(val) ? val : getDefaultFunc()\r\nexport const somethingOrDefault = (val, defaultVal) =>\r\n somethingOrGetDefault(constant(defaultVal))(val)\r\n\r\nexport const mapIfSomethingOrDefault = (mapFunc, defaultVal) => val =>\r\n isSomething(val) ? mapFunc(val) : defaultVal\r\n\r\nexport const mapIfSomethingOrBlank = mapFunc =>\r\n mapIfSomethingOrDefault(mapFunc, \"\")\r\n\r\nexport const none = predicate => collection => !some(predicate)(collection)\r\n\r\nexport const all = predicate => collection =>\r\n none(v => !predicate(v))(collection)\r\n\r\nexport const isNotEmpty = ob => !isEmpty(ob)\r\nexport const isAsync = fn => fn.constructor.name === \"AsyncFunction\"\r\nexport const isNonEmptyArray = allTrue(isArray, isNotEmpty)\r\nexport const isNonEmptyString = allTrue(isString, isNotEmpty)\r\nexport const tryOr = failFunc => (func, ...args) => {\r\n try {\r\n return func.apply(null, ...args)\r\n } catch (_) {\r\n return failFunc()\r\n }\r\n}\r\n\r\nexport const tryAwaitOr = failFunc => async (func, ...args) => {\r\n try {\r\n return await func.apply(null, ...args)\r\n } catch (_) {\r\n return await failFunc()\r\n }\r\n}\r\n\r\nexport const defineError = (func, errorPrefix) => {\r\n try {\r\n return func()\r\n } catch (err) {\r\n err.message = `${errorPrefix} : ${err.message}`\r\n throw err\r\n }\r\n}\r\n\r\nexport const tryOrIgnore = tryOr(() => {})\r\nexport const tryAwaitOrIgnore = tryAwaitOr(async () => {})\r\nexport const causesException = func => {\r\n try {\r\n func()\r\n return false\r\n } catch (e) {\r\n return true\r\n }\r\n}\r\n\r\nexport const executesWithoutException = func => !causesException(func)\r\n\r\nexport const handleErrorWith = returnValInError =>\r\n tryOr(constant(returnValInError))\r\n\r\nexport const handleErrorWithUndefined = handleErrorWith(undefined)\r\n\r\nexport const switchCase = (...cases) => value => {\r\n const nextCase = () => head(cases)[0](value)\r\n const nextResult = () => head(cases)[1](value)\r\n\r\n if (isEmpty(cases)) return // undefined\r\n if (nextCase() === true) return nextResult()\r\n return switchCase(...tail(cases))(value)\r\n}\r\n\r\nexport const isValue = val1 => val2 => val1 === val2\r\nexport const isOneOf = (...vals) => val => includes(val)(vals)\r\nexport const defaultCase = constant(true)\r\nexport const memberMatches = (member, match) => obj => match(obj[member])\r\n\r\nexport const StartsWith = searchFor => searchIn =>\r\n startsWith(searchIn, searchFor)\r\n\r\nexport const contains = val => array => findIndex(array, v => v === val) > -1\r\n\r\nexport const getHashCode = s => {\r\n let hash = 0\r\n let i\r\n let char\r\n let l\r\n if (s.length == 0) return hash\r\n for (i = 0, l = s.length; i < l; i++) {\r\n char = s.charCodeAt(i)\r\n hash = (hash << 5) - hash + char\r\n hash |= 0 // Convert to 32bit integer\r\n }\r\n\r\n // converting to string, but dont want a \"-\" prefixed\r\n if (hash < 0) {\r\n return `n${(hash * -1).toString()}`\r\n }\r\n return hash.toString()\r\n}\r\n\r\n// thanks to https://blog.grossman.io/how-to-write-async-await-without-try-catch-blocks-in-javascript/\r\nexport const awEx = async promise => {\r\n try {\r\n const result = await promise\r\n return [undefined, result]\r\n } catch (error) {\r\n return [error, undefined]\r\n }\r\n}\r\n\r\nexport const isSafeInteger = n =>\r\n isInteger(n) &&\r\n n <= Number.MAX_SAFE_INTEGER &&\r\n n >= 0 - Number.MAX_SAFE_INTEGER\r\n\r\nexport const toDateOrNull = s =>\r\n isNull(s) ? null : isDate(s) ? s : new Date(s)\r\nexport const toBoolOrNull = s => (isNull(s) ? null : s === \"true\" || s === true)\r\nexport const toNumberOrNull = s => (isNull(s) ? null : toNumber(s))\r\n\r\nexport const isArrayOfString = opts => isArray(opts) && all(isString)(opts)\r\n\r\nexport const pushAll = (target, items) => {\r\n for (let i of items) target.push(i)\r\n}\r\n\r\nexport const pause = async duration =>\r\n new Promise(res => setTimeout(res, duration))\r\n\r\nexport const retry = async (fn, retries, delay, ...args) => {\r\n try {\r\n return await fn(...args)\r\n } catch (err) {\r\n if (retries > 1) {\r\n return await pause(delay).then(\r\n async () => await retry(fn, retries - 1, delay, ...args)\r\n )\r\n }\r\n throw err\r\n }\r\n}\r\n\r\nexport { events } from \"./events.js\"\r\n\r\nexport default {\r\n ifExists,\r\n getOrDefault,\r\n isDefined,\r\n isNonNull,\r\n isNotNaN,\r\n allTrue,\r\n isSomething,\r\n mapIfSomethingOrDefault,\r\n mapIfSomethingOrBlank,\r\n configFolder,\r\n fieldDefinitions,\r\n isNothing,\r\n not,\r\n switchCase,\r\n defaultCase,\r\n StartsWith,\r\n contains,\r\n templateDefinitions,\r\n handleErrorWith,\r\n handleErrorWithUndefined,\r\n tryOr,\r\n tryOrIgnore,\r\n tryAwaitOr,\r\n tryAwaitOrIgnore,\r\n dirIndex,\r\n keySep,\r\n $,\r\n $$,\r\n getDirFomKey,\r\n getFileFromKey,\r\n splitKey,\r\n somethingOrDefault,\r\n getIndexKeyFromFileKey,\r\n joinKey,\r\n somethingOrGetDefault,\r\n appDefinitionFile,\r\n isValue,\r\n all,\r\n isOneOf,\r\n memberMatches,\r\n defineError,\r\n anyTrue,\r\n isNonEmptyArray,\r\n causesException,\r\n executesWithoutException,\r\n none,\r\n getHashCode,\r\n awEx,\r\n events,\r\n eventsList,\r\n isNothingOrEmpty,\r\n isSafeInteger,\r\n toNumber,\r\n toDate: toDateOrNull,\r\n toBool: toBoolOrNull,\r\n isArrayOfString,\r\n insensitiveEquals,\r\n pause,\r\n retry,\r\n pushAll,\r\n}\r\n"],"file":"index.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/index.js"],"names":["$$","funcs","arg","$","keySep","trimKeySep","str","splitByKeySep","safeKey","key","joinKey","strs","paramsOrArray","length","s","toString","splitKey","getDirFomKey","dropRight","p","getFileFromKey","takeRight","head","configFolder","fieldDefinitions","templateDefinitions","appDefinitionFile","dirIndex","folderPath","getIndexKeyFromFileKey","ifExists","val","exists","notExists","getOrDefault","defaultVal","not","func","isDefined","isUndefined","isNonNull","isNull","isNotNaN","isNaN","allTrue","funcArgs","result","conditionFunc","anyTrue","insensitiveEquals","str1","str2","trim","toLowerCase","isSomething","isNothing","isNothingOrEmpty","v","somethingOrGetDefault","getDefaultFunc","somethingOrDefault","mapIfSomethingOrDefault","mapFunc","mapIfSomethingOrBlank","none","predicate","collection","all","isNotEmpty","ob","isAsync","fn","constructor","name","isNonEmptyArray","isArray","isNonEmptyString","isString","tryOr","failFunc","args","apply","_","tryAwaitOr","defineError","errorPrefix","err","message","tryOrIgnore","tryAwaitOrIgnore","causesException","e","executesWithoutException","handleErrorWith","returnValInError","handleErrorWithUndefined","undefined","switchCase","cases","value","nextCase","nextResult","isValue","val1","val2","isOneOf","vals","defaultCase","memberMatches","member","match","obj","StartsWith","searchFor","searchIn","contains","array","getHashCode","hash","i","char","l","charCodeAt","awEx","promise","isSafeInteger","n","Number","MAX_SAFE_INTEGER","toDateOrNull","Date","toBoolOrNull","toNumberOrNull","isArrayOfString","opts","pushAll","target","items","push","pause","duration","Promise","res","setTimeout","retry","retries","delay","then","events","eventsList","toNumber","toDate","toBool"],"mappings":"06DAAA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;AAkBA,qC;;AAEA;AACO,IAAMA,EAAE,GAAG,SAALA,EAAK,sCAAIC,KAAJ,oDAAIA,KAAJ,iCAAc,UAAAC,GAAG,UAAI,kBAAKD,KAAL,EAAYC,GAAZ,CAAJ,EAAjB,EAAX;;AAEP;gBACO,IAAMC,CAAC,GAAG,SAAJA,CAAI,CAACD,GAAD,EAAMD,KAAN,UAAgBD,EAAE,MAAF,6CAAMC,KAAN,GAAaC,GAAb,CAAhB,EAAV,C;;AAEA,IAAME,MAAM,GAAG,GAAf,C;AACP,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,GAAG,UAAI,kBAAKA,GAAL,EAAUF,MAAV,CAAJ,EAAtB;AACA,IAAMG,aAAa,GAAG,SAAhBA,aAAgB,CAAAD,GAAG,UAAI,eAAMF,MAAN,EAAcE,GAAd,CAAJ,EAAzB;AACO,IAAME,OAAO,GAAG,SAAVA,OAAU,CAAAC,GAAG;AACxB,mCAAWL,MAAX,SAAoBC,UAAU,CAACI,GAAD,CAA9B,aAA0CL,MAA1C,SAAmDA,MAAnD,GAA6DA,MAA7D,CADwB,GAAnB,C;AAEA,IAAMM,OAAO,GAAG,SAAVA,OAAU,GAAa,oCAATC,IAAS,yDAATA,IAAS;AAClC,MAAMC,aAAa,GAAID,IAAI,CAACE,MAAL,KAAgB,CAAjB,GAAsB,iBAAQF,IAAI,CAAC,CAAD,CAAZ,CAAtB,GAAyCA,IAAI,CAAC,CAAD,CAA7C,GAAmDA,IAAzE;AACA,SAAOR,CAAC,CAACS,aAAD,EAAgB;AACtB,kBAAO,UAAAE,CAAC,UAAI,CAAC,qBAAYA,CAAZ,CAAD,IAAmB,CAAC,gBAAOA,CAAP,CAApB,IAAiCA,CAAC,CA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AA,iBAAiB,EAAjBA,iBAzDa;AA0Db0F,EAAAA,KAAK,EAALA,KA1Da;AA2DbK,EAAAA,KAAK,EAALA,KA3Da;AA4DbT,EAAAA,OAAO,EAAPA,OA5Da,E","sourcesContent":["import {\n head,\n tail,\n findIndex,\n startsWith,\n dropRight,\n flow,\n takeRight,\n trim,\n replace,\n} from \"lodash\"\nimport {\n some,\n reduce,\n isEmpty,\n isArray,\n join,\n isString,\n isInteger,\n isDate,\n toNumber,\n isUndefined,\n isNaN,\n isNull,\n constant,\n split,\n includes,\n filter,\n} from \"lodash/fp\"\nimport { events, eventsList } from \"./events.js\"\n\n// this is the combinator function\nexport const $$ = (...funcs) => arg => flow(funcs)(arg)\n\n// this is the pipe function\nexport const $ = (arg, funcs) => $$(...funcs)(arg)\n\nexport const keySep = \"/\"\nconst trimKeySep = str => trim(str, keySep)\nconst splitByKeySep = str => split(keySep)(str)\nexport const safeKey = key =>\n replace(`${keySep}${trimKeySep(key)}`, `${keySep}${keySep}`, keySep)\nexport const joinKey = (...strs) => {\n const paramsOrArray = (strs.length === 1) & isArray(strs[0]) ? strs[0] : strs\n return $(paramsOrArray, [\n filter(s => !isUndefined(s) && !isNull(s) && s.toString().length > 0),\n join(keySep),\n safeKey,\n ])\n}\nexport const splitKey = $$(trimKeySep, splitByKeySep)\nexport const getDirFomKey = $$(splitKey, dropRight, p => joinKey(...p))\nexport const getFileFromKey = $$(splitKey, takeRight, head)\n\nexport const configFolder = `${keySep}.config`\nexport const fieldDefinitions = joinKey(configFolder, \"fields.json\")\nexport const templateDefinitions = joinKey(configFolder, \"templates.json\")\nexport const appDefinitionFile = joinKey(configFolder, \"appDefinition.json\")\nexport const dirIndex = folderPath =>\n joinKey(configFolder, \"dir\", ...splitKey(folderPath), \"dir.idx\")\nexport const getIndexKeyFromFileKey = $$(getDirFomKey, dirIndex)\n\nexport const ifExists = (val, exists, notExists) =>\n isUndefined(val)\n ? isUndefined(notExists)\n ? (() => {})()\n : notExists()\n : exists()\n\nexport const getOrDefault = (val, defaultVal) =>\n ifExists(\n val,\n () => val,\n () => defaultVal\n )\n\nexport const not = func => val => !func(val)\nexport const isDefined = not(isUndefined)\nexport const isNonNull = not(isNull)\nexport const isNotNaN = not(isNaN)\n\nexport const allTrue = (...funcArgs) => val =>\n reduce(\n (result, conditionFunc) =>\n (isNull(result) || result == true) && conditionFunc(val),\n null\n )(funcArgs)\n\nexport const anyTrue = (...funcArgs) => val =>\n reduce(\n (result, conditionFunc) => result == true || conditionFunc(val),\n null\n )(funcArgs)\n\nexport const insensitiveEquals = (str1, str2) =>\n str1.trim().toLowerCase() === str2.trim().toLowerCase()\n\nexport const isSomething = allTrue(isDefined, isNonNull, isNotNaN)\nexport const isNothing = not(isSomething)\nexport const isNothingOrEmpty = v => isNothing(v) || isEmpty(v)\nexport const somethingOrGetDefault = getDefaultFunc => val =>\n isSomething(val) ? val : getDefaultFunc()\nexport const somethingOrDefault = (val, defaultVal) =>\n somethingOrGetDefault(constant(defaultVal))(val)\n\nexport const mapIfSomethingOrDefault = (mapFunc, defaultVal) => val =>\n isSomething(val) ? mapFunc(val) : defaultVal\n\nexport const mapIfSomethingOrBlank = mapFunc =>\n mapIfSomethingOrDefault(mapFunc, \"\")\n\nexport const none = predicate => collection => !some(predicate)(collection)\n\nexport const all = predicate => collection =>\n none(v => !predicate(v))(collection)\n\nexport const isNotEmpty = ob => !isEmpty(ob)\nexport const isAsync = fn => fn.constructor.name === \"AsyncFunction\"\nexport const isNonEmptyArray = allTrue(isArray, isNotEmpty)\nexport const isNonEmptyString = allTrue(isString, isNotEmpty)\nexport const tryOr = failFunc => (func, ...args) => {\n try {\n return func.apply(null, ...args)\n } catch (_) {\n return failFunc()\n }\n}\n\nexport const tryAwaitOr = failFunc => async (func, ...args) => {\n try {\n return await func.apply(null, ...args)\n } catch (_) {\n return await failFunc()\n }\n}\n\nexport const defineError = (func, errorPrefix) => {\n try {\n return func()\n } catch (err) {\n err.message = `${errorPrefix} : ${err.message}`\n throw err\n }\n}\n\nexport const tryOrIgnore = tryOr(() => {})\nexport const tryAwaitOrIgnore = tryAwaitOr(async () => {})\nexport const causesException = func => {\n try {\n func()\n return false\n } catch (e) {\n return true\n }\n}\n\nexport const executesWithoutException = func => !causesException(func)\n\nexport const handleErrorWith = returnValInError =>\n tryOr(constant(returnValInError))\n\nexport const handleErrorWithUndefined = handleErrorWith(undefined)\n\nexport const switchCase = (...cases) => value => {\n const nextCase = () => head(cases)[0](value)\n const nextResult = () => head(cases)[1](value)\n\n if (isEmpty(cases)) return // undefined\n if (nextCase() === true) return nextResult()\n return switchCase(...tail(cases))(value)\n}\n\nexport const isValue = val1 => val2 => val1 === val2\nexport const isOneOf = (...vals) => val => includes(val)(vals)\nexport const defaultCase = constant(true)\nexport const memberMatches = (member, match) => obj => match(obj[member])\n\nexport const StartsWith = searchFor => searchIn =>\n startsWith(searchIn, searchFor)\n\nexport const contains = val => array => findIndex(array, v => v === val) > -1\n\nexport const getHashCode = s => {\n let hash = 0\n let i\n let char\n let l\n if (s.length == 0) return hash\n for (i = 0, l = s.length; i < l; i++) {\n char = s.charCodeAt(i)\n hash = (hash << 5) - hash + char\n hash |= 0 // Convert to 32bit integer\n }\n\n // converting to string, but dont want a \"-\" prefixed\n if (hash < 0) {\n return `n${(hash * -1).toString()}`\n }\n return hash.toString()\n}\n\n// thanks to https://blog.grossman.io/how-to-write-async-await-without-try-catch-blocks-in-javascript/\nexport const awEx = async promise => {\n try {\n const result = await promise\n return [undefined, result]\n } catch (error) {\n return [error, undefined]\n }\n}\n\nexport const isSafeInteger = n =>\n isInteger(n) &&\n n <= Number.MAX_SAFE_INTEGER &&\n n >= 0 - Number.MAX_SAFE_INTEGER\n\nexport const toDateOrNull = s =>\n isNull(s) ? null : isDate(s) ? s : new Date(s)\nexport const toBoolOrNull = s => (isNull(s) ? null : s === \"true\" || s === true)\nexport const toNumberOrNull = s => (isNull(s) ? null : toNumber(s))\n\nexport const isArrayOfString = opts => isArray(opts) && all(isString)(opts)\n\nexport const pushAll = (target, items) => {\n for (let i of items) target.push(i)\n}\n\nexport const pause = async duration =>\n new Promise(res => setTimeout(res, duration))\n\nexport const retry = async (fn, retries, delay, ...args) => {\n try {\n return await fn(...args)\n } catch (err) {\n if (retries > 1) {\n return await pause(delay).then(\n async () => await retry(fn, retries - 1, delay, ...args)\n )\n }\n throw err\n }\n}\n\nexport { events } from \"./events.js\"\n\nexport default {\n ifExists,\n getOrDefault,\n isDefined,\n isNonNull,\n isNotNaN,\n allTrue,\n isSomething,\n mapIfSomethingOrDefault,\n mapIfSomethingOrBlank,\n configFolder,\n fieldDefinitions,\n isNothing,\n not,\n switchCase,\n defaultCase,\n StartsWith,\n contains,\n templateDefinitions,\n handleErrorWith,\n handleErrorWithUndefined,\n tryOr,\n tryOrIgnore,\n tryAwaitOr,\n tryAwaitOrIgnore,\n dirIndex,\n keySep,\n $,\n $$,\n getDirFomKey,\n getFileFromKey,\n splitKey,\n somethingOrDefault,\n getIndexKeyFromFileKey,\n joinKey,\n somethingOrGetDefault,\n appDefinitionFile,\n isValue,\n all,\n isOneOf,\n memberMatches,\n defineError,\n anyTrue,\n isNonEmptyArray,\n causesException,\n executesWithoutException,\n none,\n getHashCode,\n awEx,\n events,\n eventsList,\n isNothingOrEmpty,\n isSafeInteger,\n toNumber,\n toDate: toDateOrNull,\n toBool: toBoolOrNull,\n isArrayOfString,\n insensitiveEquals,\n pause,\n retry,\n pushAll,\n}\n"],"file":"index.js"} \ No newline at end of file diff --git a/packages/common/lib/common/validationCommon.js.map b/packages/common/lib/common/validationCommon.js.map index d196a26738..421ded1c61 100644 --- a/packages/common/lib/common/validationCommon.js.map +++ b/packages/common/lib/common/validationCommon.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/common/validationCommon.js"],"names":["stringNotEmpty","s","trim","length","makerule","field","error","isValid","validationError","rule","item","applyRuleSet","ruleSet","itemToValidate","applyRule","isSomething","itemTovalidate"],"mappings":"wXAAA;AACA,gC;;AAEO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,CAAC,UAAI,wBAAYA,CAAZ,KAAkBA,CAAC,CAACC,IAAF,GAASC,MAAT,GAAkB,CAAxC,EAAxB,C;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,KAAR,EAAeC,OAAf,UAA4B,EAAEF,KAAK,EAALA,KAAF,EAASC,KAAK,EAALA,KAAT,EAAgBC,OAAO,EAAPA,OAAhB,EAA5B,EAAjB,C;;AAEA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,IAAD,EAAOC,IAAP,4BAAsBD,IAAtB,IAA4BC,IAAI,EAAJA,IAA5B,KAAxB,C;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe,CAAAC,OAAO,UAAI,UAAAC,cAAc;AACnD,oBAAED,OAAF,EAAW,CAAC,aAAIE,SAAS,CAACD,cAAD,CAAb,CAAD,EAAiC,gBAAOE,kBAAP,CAAjC,CAAX,CADmD,GAAlB,EAA5B,C;;AAGA,IAAMD,SAAS,GAAG,SAAZA,SAAY,CAAAE,cAAc,UAAI,UAAAP,IAAI;AAC7CA,MAAAA,IAAI,CAACF,OAAL,CAAaS,cAAb,IAA+B,IAA/B,GAAsCR,eAAe,CAACC,IAAD,EAAOO,cAAP,CADR,GAAR,EAAhC,C","sourcesContent":["import { filter, map } from \"lodash/fp\"\r\nimport { $, isSomething } from \"./index\"\r\n\r\nexport const stringNotEmpty = s => isSomething(s) && s.trim().length > 0\r\n\r\nexport const makerule = (field, error, isValid) => ({ field, error, isValid })\r\n\r\nexport const validationError = (rule, item) => ({ ...rule, item })\r\n\r\nexport const applyRuleSet = ruleSet => itemToValidate =>\r\n $(ruleSet, [map(applyRule(itemToValidate)), filter(isSomething)])\r\n\r\nexport const applyRule = itemTovalidate => rule =>\r\n rule.isValid(itemTovalidate) ? null : validationError(rule, itemTovalidate)\r\n"],"file":"validationCommon.js"} \ No newline at end of file +{"version":3,"sources":["../../src/common/validationCommon.js"],"names":["stringNotEmpty","s","trim","length","makerule","field","error","isValid","validationError","rule","item","applyRuleSet","ruleSet","itemToValidate","applyRule","isSomething","itemTovalidate"],"mappings":"wXAAA;AACA,gC;;AAEO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,CAAC,UAAI,wBAAYA,CAAZ,KAAkBA,CAAC,CAACC,IAAF,GAASC,MAAT,GAAkB,CAAxC,EAAxB,C;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,KAAR,EAAeC,OAAf,UAA4B,EAAEF,KAAK,EAALA,KAAF,EAASC,KAAK,EAALA,KAAT,EAAgBC,OAAO,EAAPA,OAAhB,EAA5B,EAAjB,C;;AAEA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,IAAD,EAAOC,IAAP,4BAAsBD,IAAtB,IAA4BC,IAAI,EAAJA,IAA5B,KAAxB,C;;AAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe,CAAAC,OAAO,UAAI,UAAAC,cAAc;AACnD,oBAAED,OAAF,EAAW,CAAC,aAAIE,SAAS,CAACD,cAAD,CAAb,CAAD,EAAiC,gBAAOE,kBAAP,CAAjC,CAAX,CADmD,GAAlB,EAA5B,C;;AAGA,IAAMD,SAAS,GAAG,SAAZA,SAAY,CAAAE,cAAc,UAAI,UAAAP,IAAI;AAC7CA,MAAAA,IAAI,CAACF,OAAL,CAAaS,cAAb,IAA+B,IAA/B,GAAsCR,eAAe,CAACC,IAAD,EAAOO,cAAP,CADR,GAAR,EAAhC,C","sourcesContent":["import { filter, map } from \"lodash/fp\"\nimport { $, isSomething } from \"./index\"\n\nexport const stringNotEmpty = s => isSomething(s) && s.trim().length > 0\n\nexport const makerule = (field, error, isValid) => ({ field, error, isValid })\n\nexport const validationError = (rule, item) => ({ ...rule, item })\n\nexport const applyRuleSet = ruleSet => itemToValidate =>\n $(ruleSet, [map(applyRule(itemToValidate)), filter(isSomething)])\n\nexport const applyRule = itemTovalidate => rule =>\n rule.isValid(itemTovalidate) ? null : validationError(rule, itemTovalidate)\n"],"file":"validationCommon.js"} \ No newline at end of file diff --git a/packages/common/lib/index.js.map b/packages/common/lib/index.js.map index b85820dd03..5b622752d3 100644 --- a/packages/common/lib/index.js.map +++ b/packages/common/lib/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"kpBAAA;AACA;AACA;AACA","sourcesContent":["export { validateRecord } from \"./records/validateRecord\";\r\nexport { events } from \"./common/events\";\r\nexport { safeParseField } from \"./schema/types\";\r\nexport { default as schemaValidator } from \"./schemaValidation\";"],"file":"index.js"} \ No newline at end of file +{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"kpBAAA;AACA;AACA;AACA","sourcesContent":["export { validateRecord } from \"./records/validateRecord\";\nexport { events } from \"./common/events\";\nexport { safeParseField } from \"./schema/types\";\nexport { default as schemaValidator } from \"./schemaValidation\";"],"file":"index.js"} \ No newline at end of file diff --git a/packages/common/lib/records/getNewRecord.js.map b/packages/common/lib/records/getNewRecord.js.map index c693ff3589..a5903d8b9a 100644 --- a/packages/common/lib/records/getNewRecord.js.map +++ b/packages/common/lib/records/getNewRecord.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/records/getNewRecord.js"],"names":["getNewRecord","schema","modelName","model","findModel","record","_id","modelId","field","properties"],"mappings":"yGAAA;;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,MAAD,EAASC,SAAT,EAAuB;AACjD,MAAMC,KAAK,GAAGF,MAAM,CAACG,SAAP,CAAiBF,SAAjB,CAAd;;AAEA,MAAMG,MAAM,GAAG;AACbC,IAAAA,GAAG,EAAE,wBADQ;AAEbC,IAAAA,OAAO,EAAEJ,KAAK,CAACG,GAFF,EAAf;;;AAKA,OAAK,IAAIE,KAAT,IAAkBL,KAAK,CAACF,MAAN,CAAaQ,UAA/B,EAA2C;AACzCJ,IAAAA,MAAM,CAACG,KAAD,CAAN,GAAgBA,KAAK,WAArB;AACD;;AAED,SAAOH,MAAP;AACD,CAbM,C","sourcesContent":["import { generate } from \"shortid\"\r\n\r\nexport const getNewRecord = (schema, modelName) => {\r\n const model = schema.findModel(modelName)\r\n\r\n const record = {\r\n _id: generate(),\r\n modelId: model._id,\r\n }\r\n\r\n for (let field in model.schema.properties) {\r\n record[field] = field.default\r\n }\r\n\r\n return record\r\n}\r\n"],"file":"getNewRecord.js"} \ No newline at end of file +{"version":3,"sources":["../../src/records/getNewRecord.js"],"names":["getNewRecord","schema","modelName","model","findModel","record","_id","modelId","field","properties"],"mappings":"yGAAA;;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,MAAD,EAASC,SAAT,EAAuB;AACjD,MAAMC,KAAK,GAAGF,MAAM,CAACG,SAAP,CAAiBF,SAAjB,CAAd;;AAEA,MAAMG,MAAM,GAAG;AACbC,IAAAA,GAAG,EAAE,wBADQ;AAEbC,IAAAA,OAAO,EAAEJ,KAAK,CAACG,GAFF,EAAf;;;AAKA,OAAK,IAAIE,KAAT,IAAkBL,KAAK,CAACF,MAAN,CAAaQ,UAA/B,EAA2C;AACzCJ,IAAAA,MAAM,CAACG,KAAD,CAAN,GAAgBA,KAAK,WAArB;AACD;;AAED,SAAOH,MAAP;AACD,CAbM,C","sourcesContent":["import { generate } from \"shortid\"\n\nexport const getNewRecord = (schema, modelName) => {\n const model = schema.findModel(modelName)\n\n const record = {\n _id: generate(),\n modelId: model._id,\n }\n\n for (let field in model.schema.properties) {\n record[field] = field.default\n }\n\n return record\n}\n"],"file":"getNewRecord.js"} \ No newline at end of file diff --git a/packages/common/lib/records/recordValidationRules.js.map b/packages/common/lib/records/recordValidationRules.js.map index b2436d7b82..789f133bc6 100644 --- a/packages/common/lib/records/recordValidationRules.js.map +++ b/packages/common/lib/records/recordValidationRules.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/records/recordValidationRules.js"],"names":["getNewRecordValidationRule","invalidField","messageWhenInvalid","expressionWhenValid","commonRecordValidationRules","fieldNotEmpty","fieldName","fieldBetween","min","max","toString","fieldGreaterThan"],"mappings":"6JAAO,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA6B;AACxCC,YADwC;AAExCC,kBAFwC;AAGxCC,mBAHwC;AAIpC;AACJF,MAAAA,YAAY,EAAZA,YADI;AAEJC,MAAAA,kBAAkB,EAAlBA,kBAFI;AAGJC,MAAAA,mBAAmB,EAAnBA,mBAHI,EAJoC,GAAnC,C;;;AAUA,IAAMC,2BAA2B,GAAG;AACzCC,EAAAA,aAAa,EAAE,uBAAAC,SAAS;AACtBN,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB;AAGbA,MAAAA,SAHa,2BAGaA,SAHb,mBADJ,GADiB;;;AAQzCC,EAAAA,YAAY,EAAE,sBAACD,SAAD,EAAYE,GAAZ,EAAiBC,GAAjB;AACZT,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB,8BAEQE,GAAG,CAACE,QAAJ,EAFR,kBAE8BD,GAAG,CAACC,QAAJ,EAF9B;AAGbJ,MAAAA,SAHa,mBAGKE,GAHL,0BAGwBF,SAHxB,mBAG0CG,GAH1C,OADd,GAR2B;;;AAezCE,EAAAA,gBAAgB,EAAE,0BAACL,SAAD,EAAYE,GAAZ,EAAiBC,GAAjB;AAChBT,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB,mCAEaE,GAAG,CAACE,QAAJ,EAFb,kBAEmCD,GAAG,CAACC,QAAJ,EAFnC;AAGbJ,MAAAA,SAHa,mBAGKE,GAHL,QADV,GAfuB,EAApC,C","sourcesContent":["export const getNewRecordValidationRule = (\r\n invalidField,\r\n messageWhenInvalid,\r\n expressionWhenValid\r\n) => ({\r\n invalidField,\r\n messageWhenInvalid,\r\n expressionWhenValid,\r\n})\r\n\r\nexport const commonRecordValidationRules = {\r\n fieldNotEmpty: fieldName =>\r\n getNewRecordValidationRule(\r\n fieldName,\r\n `${fieldName} is empty`,\r\n `record['${fieldName}'] && record['${fieldName}'].length > 0`\r\n ),\r\n\r\n fieldBetween: (fieldName, min, max) =>\r\n getNewRecordValidationRule(\r\n fieldName,\r\n `${fieldName} must be between ${min.toString()} and ${max.toString()}`,\r\n `record['${fieldName}'] >= ${min} && record['${fieldName}'] <= ${max} `\r\n ),\r\n\r\n fieldGreaterThan: (fieldName, min, max) =>\r\n getNewRecordValidationRule(\r\n fieldName,\r\n `${fieldName} must be greater than ${min.toString()} and ${max.toString()}`,\r\n `record['${fieldName}'] >= ${min} `\r\n ),\r\n}\r\n"],"file":"recordValidationRules.js"} \ No newline at end of file +{"version":3,"sources":["../../src/records/recordValidationRules.js"],"names":["getNewRecordValidationRule","invalidField","messageWhenInvalid","expressionWhenValid","commonRecordValidationRules","fieldNotEmpty","fieldName","fieldBetween","min","max","toString","fieldGreaterThan"],"mappings":"6JAAO,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA6B;AACxCC,YADwC;AAExCC,kBAFwC;AAGxCC,mBAHwC;AAIpC;AACJF,MAAAA,YAAY,EAAZA,YADI;AAEJC,MAAAA,kBAAkB,EAAlBA,kBAFI;AAGJC,MAAAA,mBAAmB,EAAnBA,mBAHI,EAJoC,GAAnC,C;;;AAUA,IAAMC,2BAA2B,GAAG;AACzCC,EAAAA,aAAa,EAAE,uBAAAC,SAAS;AACtBN,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB;AAGbA,MAAAA,SAHa,2BAGaA,SAHb,mBADJ,GADiB;;;AAQzCC,EAAAA,YAAY,EAAE,sBAACD,SAAD,EAAYE,GAAZ,EAAiBC,GAAjB;AACZT,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB,8BAEQE,GAAG,CAACE,QAAJ,EAFR,kBAE8BD,GAAG,CAACC,QAAJ,EAF9B;AAGbJ,MAAAA,SAHa,mBAGKE,GAHL,0BAGwBF,SAHxB,mBAG0CG,GAH1C,OADd,GAR2B;;;AAezCE,EAAAA,gBAAgB,EAAE,0BAACL,SAAD,EAAYE,GAAZ,EAAiBC,GAAjB;AAChBT,MAAAA,0BAA0B;AACxBM,MAAAA,SADwB;AAErBA,MAAAA,SAFqB,mCAEaE,GAAG,CAACE,QAAJ,EAFb,kBAEmCD,GAAG,CAACC,QAAJ,EAFnC;AAGbJ,MAAAA,SAHa,mBAGKE,GAHL,QADV,GAfuB,EAApC,C","sourcesContent":["export const getNewRecordValidationRule = (\n invalidField,\n messageWhenInvalid,\n expressionWhenValid\n) => ({\n invalidField,\n messageWhenInvalid,\n expressionWhenValid,\n})\n\nexport const commonRecordValidationRules = {\n fieldNotEmpty: fieldName =>\n getNewRecordValidationRule(\n fieldName,\n `${fieldName} is empty`,\n `record['${fieldName}'] && record['${fieldName}'].length > 0`\n ),\n\n fieldBetween: (fieldName, min, max) =>\n getNewRecordValidationRule(\n fieldName,\n `${fieldName} must be between ${min.toString()} and ${max.toString()}`,\n `record['${fieldName}'] >= ${min} && record['${fieldName}'] <= ${max} `\n ),\n\n fieldGreaterThan: (fieldName, min, max) =>\n getNewRecordValidationRule(\n fieldName,\n `${fieldName} must be greater than ${min.toString()} and ${max.toString()}`,\n `record['${fieldName}'] >= ${min} `\n ),\n}\n"],"file":"recordValidationRules.js"} \ No newline at end of file diff --git a/packages/common/lib/records/validateRecord.js.map b/packages/common/lib/records/validateRecord.js.map index 84a6151205..450ecedab3 100644 --- a/packages/common/lib/records/validateRecord.js.map +++ b/packages/common/lib/records/validateRecord.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/records/validateRecord.js"],"names":["fieldParseError","fieldName","value","fields","message","validateAllFieldParse","record","model","f","name","parseResult","errors","success","push","validateAllTypeConstraints","field","isNonEmptyString","m","e","runRecordValidationRules","runValidationRule","rule","isValid","expressionWhenValid","expressionContext","valid","invalidFields","messageWhenInvalid","validationRules","flatten","r","validateRecord","schema","findModel","_modelId","fieldParseFails","recordValidationRuleFails","typeContraintFails"],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,EAAEb,OAAO,EAAE,KAAX,EAAkBX,MAAM,EAAEwB,eAA1B,EAAP;AACD;;AAED,MAAMC,yBAAyB,GAAGjB,wBAAwB,CAACb,MAAD,EAASC,KAAT,CAA1D;AACA,MAAM8B,kBAAkB,GAAGvB,0BAA0B,CAACR,MAAD,EAASC,KAAT,CAArD;;AAEA;AACE,mBAAQ4B,eAAR;AACA,mBAAQC,yBAAR,CADA;AAEA,mBAAQC,kBAAR,CAHF;AAIE;AACA,WAAO,EAAEf,OAAO,EAAE,IAAX,EAAiBX,MAAM,EAAE,EAAzB,EAAP;AACD;;AAED,SAAO;AACLW,IAAAA,OAAO,EAAE,KADJ;AAELX,IAAAA,MAAM,EAAE;AACNwB,IAAAA,eADM;AAENE,IAAAA,kBAFM;AAGND,IAAAA,yBAHM,CAFH,EAAP;;;AAQD,CA5BM,C","sourcesContent":["import { map, reduce, filter, isEmpty, flatten, each, union } from \"lodash/fp\";\r\nimport { compileCode } from \"../common/compileCode\";\r\nimport {\r\n validateFieldParse,\r\n validateTypeConstraints,\r\n} from \"../schema/types/index.js\"\r\nimport { $, isNonEmptyString } from \"../common/index.js\"\r\n\r\nconst fieldParseError = (fieldName, value) => ({\r\n fields: [fieldName],\r\n message: `Could not parse field ${fieldName}:${value}`,\r\n})\r\n\r\nconst validateAllFieldParse = (record, model) =>\r\n $(model.fields, [\r\n map(f => ({ name: f.name, parseResult: validateFieldParse(f, record) })),\r\n reduce((errors, f) => {\r\n if (f.parseResult.success) return errors\r\n errors.push(fieldParseError(f.name, f.parseResult.value))\r\n return errors\r\n }, []),\r\n ])\r\n\r\nconst validateAllTypeConstraints = (record, model) => {\r\n const errors = []\r\n for (const field of model.fields) {\r\n $(validateTypeConstraints(field, record), [\r\n filter(isNonEmptyString),\r\n map(m => ({ message: m, fields: [field.name] })),\r\n each(e => errors.push(e)),\r\n ])\r\n }\r\n return errors\r\n}\r\n\r\nconst runRecordValidationRules = (record, model) => {\r\n const runValidationRule = rule => {\r\n const isValid = compileCode(rule.expressionWhenValid)\r\n const expressionContext = { record }\r\n return isValid(expressionContext)\r\n ? { valid: true }\r\n : {\r\n valid: false,\r\n fields: rule.invalidFields,\r\n message: rule.messageWhenInvalid,\r\n }\r\n }\r\n\r\n return $(model.validationRules, [\r\n map(runValidationRule),\r\n flatten,\r\n filter(r => r.valid === false),\r\n map(r => ({ fields: r.fields, message: r.message })),\r\n ])\r\n}\r\n\r\nexport const validateRecord = (schema, record) => {\r\n const model = schema.findModel(record._modelId)\r\n const fieldParseFails = validateAllFieldParse(record, model)\r\n\r\n // non parsing would cause further issues - exit here\r\n if (!isEmpty(fieldParseFails)) {\r\n return { isValid: false, errors: fieldParseFails }\r\n }\r\n\r\n const recordValidationRuleFails = runRecordValidationRules(record, model)\r\n const typeContraintFails = validateAllTypeConstraints(record, model)\r\n\r\n if (\r\n isEmpty(fieldParseFails) &&\r\n isEmpty(recordValidationRuleFails) &&\r\n isEmpty(typeContraintFails)\r\n ) {\r\n return { isValid: true, errors: [] }\r\n }\r\n\r\n return {\r\n isValid: false,\r\n errors: union(\r\n fieldParseFails,\r\n typeContraintFails,\r\n recordValidationRuleFails\r\n ),\r\n }\r\n}\r\n"],"file":"validateRecord.js"} \ No newline at end of file +{"version":3,"sources":["../../src/records/validateRecord.js"],"names":["fieldParseError","fieldName","value","fields","message","validateAllFieldParse","record","model","f","name","parseResult","errors","success","push","validateAllTypeConstraints","field","isNonEmptyString","m","e","runRecordValidationRules","runValidationRule","rule","isValid","expressionWhenValid","expressionContext","valid","invalidFields","messageWhenInvalid","validationRules","flatten","r","validateRecord","schema","findModel","_modelId","fieldParseFails","recordValidationRuleFails","typeContraintFails"],"mappings":"2GAAA;AACA;AACA;;;;AAIA,4C;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,SAAD,EAAYC,KAAZ,UAAuB;AAC7CC,IAAAA,MAAM,EAAE,CAACF,SAAD,CADqC;AAE7CG,IAAAA,OAAO,kCAA2BH,SAA3B,cAAwCC,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;AAEA;AACE,mBAAQ4B,eAAR;AACA,mBAAQC,yBAAR,CADA;AAEA,mBAAQC,kBAAR,CAHF;AAIE;AACA,WAAO,EAAEf,OAAO,EAAE,IAAX,EAAiBX,MAAM,EAAE,EAAzB,EAAP;AACD;;AAED,SAAO;AACLW,IAAAA,OAAO,EAAE,KADJ;AAELX,IAAAA,MAAM,EAAE;AACNwB,IAAAA,eADM;AAENE,IAAAA,kBAFM;AAGND,IAAAA,yBAHM,CAFH,EAAP;;;AAQD,CA5BM,C","sourcesContent":["import { map, reduce, filter, isEmpty, flatten, each, union } from \"lodash/fp\";\nimport { compileCode } from \"../common/compileCode\";\nimport {\n validateFieldParse,\n validateTypeConstraints,\n} from \"../schema/types/index.js\"\nimport { $, isNonEmptyString } from \"../common/index.js\"\n\nconst fieldParseError = (fieldName, value) => ({\n fields: [fieldName],\n message: `Could not parse field ${fieldName}:${value}`,\n})\n\nconst validateAllFieldParse = (record, model) =>\n $(model.fields, [\n map(f => ({ name: f.name, parseResult: validateFieldParse(f, record) })),\n reduce((errors, f) => {\n if (f.parseResult.success) return errors\n errors.push(fieldParseError(f.name, f.parseResult.value))\n return errors\n }, []),\n ])\n\nconst validateAllTypeConstraints = (record, model) => {\n const errors = []\n for (const field of model.fields) {\n $(validateTypeConstraints(field, record), [\n filter(isNonEmptyString),\n map(m => ({ message: m, fields: [field.name] })),\n each(e => errors.push(e)),\n ])\n }\n return errors\n}\n\nconst runRecordValidationRules = (record, model) => {\n const runValidationRule = rule => {\n const isValid = compileCode(rule.expressionWhenValid)\n const expressionContext = { record }\n return isValid(expressionContext)\n ? { valid: true }\n : {\n valid: false,\n fields: rule.invalidFields,\n message: rule.messageWhenInvalid,\n }\n }\n\n return $(model.validationRules, [\n map(runValidationRule),\n flatten,\n filter(r => r.valid === false),\n map(r => ({ fields: r.fields, message: r.message })),\n ])\n}\n\nexport const validateRecord = (schema, record) => {\n const model = schema.findModel(record._modelId)\n const fieldParseFails = validateAllFieldParse(record, model)\n\n // non parsing would cause further issues - exit here\n if (!isEmpty(fieldParseFails)) {\n return { isValid: false, errors: fieldParseFails }\n }\n\n const recordValidationRuleFails = runRecordValidationRules(record, model)\n const typeContraintFails = validateAllTypeConstraints(record, model)\n\n if (\n isEmpty(fieldParseFails) &&\n isEmpty(recordValidationRuleFails) &&\n isEmpty(typeContraintFails)\n ) {\n return { isValid: true, errors: [] }\n }\n\n return {\n isValid: false,\n errors: union(\n fieldParseFails,\n typeContraintFails,\n recordValidationRuleFails\n ),\n }\n}\n"],"file":"validateRecord.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/createActions.js.map b/packages/common/lib/schema/createActions.js.map index 2c0777b2d0..2362409748 100644 --- a/packages/common/lib/schema/createActions.js.map +++ b/packages/common/lib/schema/createActions.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schema/createActions.js"],"names":["createTrigger","actionName","eventName","optionsCreator","condition","createAction","name","behaviourSource","behaviourName","initialOptions"],"mappings":"iIAAO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,WAAO;AAClCC,IAAAA,UAAU,EAAE,EADsB;AAElCC,IAAAA,SAAS,EAAE,EAFuB;AAGlC;AACA;AACA;AACAC,IAAAA,cAAc,EAAE,EANkB;AAOlC;AACA;AACAC,IAAAA,SAAS,EAAE,EATuB,EAAP,EAAtB,C;;;AAYA,IAAMC,YAAY,GAAG,SAAfA,YAAe,WAAO;AACjCC,IAAAA,IAAI,EAAE,EAD2B;AAEjCC,IAAAA,eAAe,EAAE,EAFgB;AAGjC;AACAC,IAAAA,aAAa,EAAE,EAJkB;AAKjC;AACA;AACA;AACAC,IAAAA,cAAc,EAAE,EARiB,EAAP,EAArB,C","sourcesContent":["export const createTrigger = () => ({\r\n actionName: \"\",\r\n eventName: \"\",\r\n // function, has access to event context,\r\n // returns object that is used as parameter to action\r\n // only used if triggered by event\r\n optionsCreator: \"\",\r\n // action runs if true,\r\n // has access to event context\r\n condition: \"\",\r\n})\r\n\r\nexport const createAction = () => ({\r\n name: \"\",\r\n behaviourSource: \"\",\r\n // name of function in actionSource\r\n behaviourName: \"\",\r\n // parameter passed into behaviour.\r\n // any other parms passed at runtime e.g.\r\n // by trigger, or manually, will be merged into this\r\n initialOptions: {},\r\n})\r\n"],"file":"createActions.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schema/createActions.js"],"names":["createTrigger","actionName","eventName","optionsCreator","condition","createAction","name","behaviourSource","behaviourName","initialOptions"],"mappings":"iIAAO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,WAAO;AAClCC,IAAAA,UAAU,EAAE,EADsB;AAElCC,IAAAA,SAAS,EAAE,EAFuB;AAGlC;AACA;AACA;AACAC,IAAAA,cAAc,EAAE,EANkB;AAOlC;AACA;AACAC,IAAAA,SAAS,EAAE,EATuB,EAAP,EAAtB,C;;;AAYA,IAAMC,YAAY,GAAG,SAAfA,YAAe,WAAO;AACjCC,IAAAA,IAAI,EAAE,EAD2B;AAEjCC,IAAAA,eAAe,EAAE,EAFgB;AAGjC;AACAC,IAAAA,aAAa,EAAE,EAJkB;AAKjC;AACA;AACA;AACAC,IAAAA,cAAc,EAAE,EARiB,EAAP,EAArB,C","sourcesContent":["export const createTrigger = () => ({\n actionName: \"\",\n eventName: \"\",\n // function, has access to event context,\n // returns object that is used as parameter to action\n // only used if triggered by event\n optionsCreator: \"\",\n // action runs if true,\n // has access to event context\n condition: \"\",\n})\n\nexport const createAction = () => ({\n name: \"\",\n behaviourSource: \"\",\n // name of function in actionSource\n behaviourName: \"\",\n // parameter passed into behaviour.\n // any other parms passed at runtime e.g.\n // by trigger, or manually, will be merged into this\n initialOptions: {},\n})\n"],"file":"createActions.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/fields.js.map b/packages/common/lib/schema/fields.js.map index 968b44c38a..db27a134e4 100644 --- a/packages/common/lib/schema/fields.js.map +++ b/packages/common/lib/schema/fields.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schema/fields.js"],"names":["fieldErrors","AddFieldValidationFailed","allowedTypes","all","getNewField","type","id","name","typeOptions","label","getInitialValue","getUndefinedValue","fieldRules","allFields","f","t","typeOptionsRules","field","def","optName","optionDefinitions","keys","o","isValid","requirementDescription","validateField","everySingleField","validateAllFields","recordNode","fields","flatten","addField","recordTemplate","validationMessages","length","errors","m","error","BadRequestError","join","push"],"mappings":"uZAAA;AACA;;;;;;;AAOA;AACA;AACA;AACA;;AAEO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,wBAAwB,EAAE,wBADD,EAApB,C;;;AAIA,IAAMC,YAAY,GAAG,SAAfA,YAAe,WAAM,cAAKC,UAAL,CAAN,EAArB,C;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAAAC,IAAI,UAAK;AAClCC,IAAAA,EAAE,EAAE,wBAD8B;AAElCC,IAAAA,IAAI,EAAE,EAF4B,EAExB;AACVF,IAAAA,IAAI,EAAJA,IAHkC;AAIlCG,IAAAA,WAAW,EAAE,8BAAkBH,IAAlB,CAJqB;AAKlCI,IAAAA,KAAK,EAAE,EAL2B,EAKvB;AACXC,IAAAA,eAAe,EAAE,SANiB,EAMN;AAC5BC,IAAAA,iBAAiB,EAAE,SAPe,CAOJ;AAPI,GAAL,EAAxB,C;;AAUP,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,SAAS,UAAI;AAC9B,kCAAS,MAAT,EAAiB,uBAAjB,EAA0C,UAAAC,CAAC,UAAI,8BAAiBA,CAAC,CAACP,IAAnB,CAAJ,EAA3C,CAD8B;AAE9B,kCAAS,MAAT,EAAiB,uBAAjB,EAA0C,UAAAO,CAAC,UAAI,8BAAiBA,CAAC,CAACT,IAAnB,CAAJ,EAA3C,CAF8B;AAG9B,kCAAS,OAAT,EAAkB,wBAAlB,EAA4C,UAAAS,CAAC,UAAI,8BAAiBA,CAAC,CAACL,KAAnB,CAAJ,EAA7C,CAH8B;AAI9B,kCAAS,iBAAT,EAA4B,qCAA5B,EAAmE,UAAAK,CAAC;AAClE,oCAAiBA,CAAC,CA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AtB,CAA2BvB,KAA3B;AACD,CAdM,C","sourcesContent":["import { some, map, filter, keys, includes, countBy, flatten } from \"lodash/fp\"\r\nimport {\r\n isSomething,\r\n $,\r\n isNonEmptyString,\r\n isNothingOrEmpty,\r\n isNothing,\r\n} from \"../common\"\r\nimport { all, getDefaultOptions } from \"./types/index.js\"\r\nimport { applyRuleSet, makerule } from \"../common/validationCommon\"\r\nimport { BadRequestError } from \"../common/errors\"\r\nimport { generate } from \"shortid\"\r\n\r\nexport const fieldErrors = {\r\n AddFieldValidationFailed: \"Add field validation: \",\r\n}\r\n\r\nexport const allowedTypes = () => keys(all)\r\n\r\nexport const getNewField = type => ({\r\n id: generate(),\r\n name: \"\", // how field is referenced internally\r\n type,\r\n typeOptions: getDefaultOptions(type),\r\n label: \"\", // how field is displayed\r\n getInitialValue: \"default\", // function that gets value when initially created\r\n getUndefinedValue: \"default\", // function that gets value when field undefined on record\r\n})\r\n\r\nconst fieldRules = allFields => [\r\n makerule(\"name\", \"field name is not set\", f => isNonEmptyString(f.name)),\r\n makerule(\"type\", \"field type is not set\", f => isNonEmptyString(f.type)),\r\n makerule(\"label\", \"field label is not set\", f => isNonEmptyString(f.label)),\r\n makerule(\"getInitialValue\", \"getInitialValue function is not set\", f =>\r\n isNonEmptyString(f.getInitialValue)\r\n ),\r\n makerule(\"getUndefinedValue\", \"getUndefinedValue function is not set\", f =>\r\n isNonEmptyString(f.getUndefinedValue)\r\n ),\r\n makerule(\r\n \"name\",\r\n \"field name is duplicated\",\r\n f => isNothingOrEmpty(f.name) || countBy(\"name\")(allFields)[f.name] === 1\r\n ),\r\n makerule(\r\n \"type\",\r\n \"type is unknown\",\r\n f => isNothingOrEmpty(f.type) || some(t => f.type === t)(allowedTypes())\r\n ),\r\n]\r\n\r\nconst typeOptionsRules = field => {\r\n const type = all[field.type]\r\n if (isNothing(type)) return []\r\n\r\n const def = optName => type.optionDefinitions[optName]\r\n\r\n return $(field.typeOptions, [\r\n keys,\r\n filter(o => isSomething(def(o)) && isSomething(def(o).isValid)),\r\n map(o =>\r\n makerule(`typeOptions.${o}`, `${def(o).requirementDescription}`, field =>\r\n def(o).isValid(field.typeOptions[o])\r\n )\r\n ),\r\n ])\r\n}\r\n\r\nexport const validateField = allFields => field => {\r\n const everySingleField = includes(field)(allFields)\r\n ? allFields\r\n : [...allFields, field]\r\n return applyRuleSet([\r\n ...fieldRules(everySingleField),\r\n ...typeOptionsRules(field),\r\n ])(field)\r\n}\r\n\r\nexport const validateAllFields = recordNode =>\r\n $(recordNode.fields, [map(validateField(recordNode.fields)), flatten])\r\n\r\nexport const addField = (recordTemplate, field) => {\r\n if (isNothingOrEmpty(field.label)) {\r\n field.label = field.name\r\n }\r\n const validationMessages = validateField([...recordTemplate.fields, field])(\r\n field\r\n )\r\n if (validationMessages.length > 0) {\r\n const errors = map(m => m.error)(validationMessages)\r\n throw new BadRequestError(\r\n `${fieldErrors.AddFieldValidationFailed} ${errors.join(\", \")}`\r\n )\r\n }\r\n recordTemplate.fields.push(field)\r\n}\r\n"],"file":"fields.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schema/fields.js"],"names":["fieldErrors","AddFieldValidationFailed","allowedTypes","all","getNewField","type","id","name","typeOptions","label","getInitialValue","getUndefinedValue","fieldRules","allFields","f","t","typeOptionsRules","field","def","optName","optionDefinitions","keys","o","isValid","requirementDescription","validateField","everySingleField","validateAllFields","recordNode","fields","flatten","addField","recordTemplate","validationMessages","length","errors","m","error","BadRequestError","join","push"],"mappings":"uZAAA;AACA;;;;;;;AAOA;AACA;AACA;AACA;;AAEO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,wBAAwB,EAAE,wBADD,EAApB,C;;;AAIA,IAAMC,YAAY,GAAG,SAAfA,YAAe,WAAM,cAAKC,UAAL,CAAN,EAArB,C;;AAEA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAAAC,IAAI,UAAK;AAClCC,IAAAA,EAAE,EAAE,wBAD8B;AAElCC,IAAAA,IAAI,EAAE,EA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AAC,aAAIJ,aAAa,CAACG,UAAU,CAACC,MAAZ,CAAjB,CAAD,EAAwCC,WAAxC,CAArB,CADyC,GAApC,C;;AAGA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,cAAD,EAAiBf,KAAjB,EAA2B;AACjD,MAAI,8BAAiBA,KAAK,CAACR,KAAvB,CAAJ,EAAmC;AACjCQ,IAAAA,KAAK,CAACR,KAAN,GAAcQ,KAAK,CAACV,IAApB;AACD;AACD,MAAM0B,kBAAkB,GAAGR,aAAa,+CAAKO,cAAc,CAACH,MAApB,IAA4BZ,KAA5B,GAAb;AACzBA,EAAAA,KADyB,CAA3B;;AAGA,MAAIgB,kBAAkB,CAACC,MAAnB,GAA4B,CAAhC,EAAmC;AACjC,QAAMC,MAAM,GAAG,aAAI,UAAAC,CAAC,UAAIA,CAAC,CAACC,KAAN,EAAL,EAAkBJ,kBAAlB,CAAf;AACA,UAAM,IAAIK,uBAAJ;AACDtC,IAAAA,WAAW,CAACC,wBADX,cACuCkC,MAAM,CAACI,IAAP,CAAY,IAAZ,CADvC,EAAN;;AAGD;AACDP,EAAAA,cAAc,CAACH,MAAf,CAAsBW,IAAtB,CAA2BvB,KAA3B;AACD,CAdM,C","sourcesContent":["import { some, map, filter, keys, includes, countBy, flatten } from \"lodash/fp\"\nimport {\n isSomething,\n $,\n isNonEmptyString,\n isNothingOrEmpty,\n isNothing,\n} from \"../common\"\nimport { all, getDefaultOptions } from \"./types/index.js\"\nimport { applyRuleSet, makerule } from \"../common/validationCommon\"\nimport { BadRequestError } from \"../common/errors\"\nimport { generate } from \"shortid\"\n\nexport const fieldErrors = {\n AddFieldValidationFailed: \"Add field validation: \",\n}\n\nexport const allowedTypes = () => keys(all)\n\nexport const getNewField = type => ({\n id: generate(),\n name: \"\", // how field is referenced internally\n type,\n typeOptions: getDefaultOptions(type),\n label: \"\", // how field is displayed\n getInitialValue: \"default\", // function that gets value when initially created\n getUndefinedValue: \"default\", // function that gets value when field undefined on record\n})\n\nconst fieldRules = allFields => [\n makerule(\"name\", \"field name is not set\", f => isNonEmptyString(f.name)),\n makerule(\"type\", \"field type is not set\", f => isNonEmptyString(f.type)),\n makerule(\"label\", \"field label is not set\", f => isNonEmptyString(f.label)),\n makerule(\"getInitialValue\", \"getInitialValue function is not set\", f =>\n isNonEmptyString(f.getInitialValue)\n ),\n makerule(\"getUndefinedValue\", \"getUndefinedValue function is not set\", f =>\n isNonEmptyString(f.getUndefinedValue)\n ),\n makerule(\n \"name\",\n \"field name is duplicated\",\n f => isNothingOrEmpty(f.name) || countBy(\"name\")(allFields)[f.name] === 1\n ),\n makerule(\n \"type\",\n \"type is unknown\",\n f => isNothingOrEmpty(f.type) || some(t => f.type === t)(allowedTypes())\n ),\n]\n\nconst typeOptionsRules = field => {\n const type = all[field.type]\n if (isNothing(type)) return []\n\n const def = optName => type.optionDefinitions[optName]\n\n return $(field.typeOptions, [\n keys,\n filter(o => isSomething(def(o)) && isSomething(def(o).isValid)),\n map(o =>\n makerule(`typeOptions.${o}`, `${def(o).requirementDescription}`, field =>\n def(o).isValid(field.typeOptions[o])\n )\n ),\n ])\n}\n\nexport const validateField = allFields => field => {\n const everySingleField = includes(field)(allFields)\n ? allFields\n : [...allFields, field]\n return applyRuleSet([\n ...fieldRules(everySingleField),\n ...typeOptionsRules(field),\n ])(field)\n}\n\nexport const validateAllFields = recordNode =>\n $(recordNode.fields, [map(validateField(recordNode.fields)), flatten])\n\nexport const addField = (recordTemplate, field) => {\n if (isNothingOrEmpty(field.label)) {\n field.label = field.name\n }\n const validationMessages = validateField([...recordTemplate.fields, field])(\n field\n )\n if (validationMessages.length > 0) {\n const errors = map(m => m.error)(validationMessages)\n throw new BadRequestError(\n `${fieldErrors.AddFieldValidationFailed} ${errors.join(\", \")}`\n )\n }\n recordTemplate.fields.push(field)\n}\n"],"file":"fields.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/fullSchema.js.map b/packages/common/lib/schema/fullSchema.js.map index 2ed48241a5..5eece533a2 100644 --- a/packages/common/lib/schema/fullSchema.js.map +++ b/packages/common/lib/schema/fullSchema.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schema/fullSchema.js"],"names":["fullSchema","models","views","findModel","idOrName","find","m","id","name","toLowerCase","findView","findField","modelIdOrName","fieldName","model","fields","f","viewsForModel","modelId","filter","v"],"mappings":"uGAAO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,MAAD,EAASC,KAAT,EAAmB;AAC3C,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AACxBH,MAAAA,MAAM,CAACI,IAAP;AACE,gBAAAC,CAAC,UAAIA,CAAC,CAACC,EAAF,KAASH,QAAT,IAAqBE,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBL,QAAQ,CAACK,WAAT,EAAlD,EADH,CADwB,GAA1B;;;AAKA,MAAMC,QAAQ,GAAG,SAAXA,QAAW,CAAAN,QAAQ;AACvBF,MAAAA,KAAK,CAACG,IAAN;AACE,gBAAAC,CAAC,UAAIA,CAAC,CAACC,EAAF,KAASH,QAAT,IAAqBE,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBL,QAAQ,CAACK,WAAT,EAAlD,EADH,CADuB,GAAzB;;;AAKA,MAAME,SAAS,GAAG,SAAZA,SAAY,CAACC,aAAD,EAAgBC,SAAhB,EAA8B;AAC9C,QAAMC,KAAK,GAAGb,MAAM,CAACI,IAAP;AACZ,cAAAC,CAAC;AACCA,QAAAA,CAAC,CAACC,EAAF,KAASK,aAAT;AACAN,QAAAA,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBG,aAAa,CAACH,WAAd,EAF1B,GADW,CAAd;;AAKA,WAAOK,KAAK,CAACC,MAAN,CAAaV,IAAb;AACL,cAAAW,CAAC,UAAIA,CAAC,CAACR,IAAF,CAAOC,WAAP,OAAyBI,SAAS,CAACJ,WAAV,EAA7B,EADI,CAAP;;AAGD,GATD;;AAWA,MAAMQ,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,OAAO,UAAIhB,KAAK,CAACiB,MAAN,CAAa,UAAAC,CAAC,UAAIA,CAAC,CAACF,OAAF,KAAcA,OAAlB,EAAd,CAAJ,EAA7B;;AAEA,SAAO;AACLjB,IAAAA,MAAM,EAANA,MADK;AAELC,IAAAA,KAAK,EAALA,KAFK;AAGLC,IAAAA,SAAS,EAATA,SAHK;AAILQ,IAAAA,SAAS,EAATA,SAJK;AAKLD,IAAAA,QAAQ,EAARA,QALK;AAMLO,IAAAA,aAAa,EAAbA,aANK,EAAP;;AAQD,CAhCM,C","sourcesContent":["export const fullSchema = (models, views) => {\r\n const findModel = idOrName =>\r\n models.find(\r\n m => m.id === idOrName || m.name.toLowerCase() === idOrName.toLowerCase()\r\n )\r\n\r\n const findView = idOrName =>\r\n views.find(\r\n m => m.id === idOrName || m.name.toLowerCase() === idOrName.toLowerCase()\r\n )\r\n\r\n const findField = (modelIdOrName, fieldName) => {\r\n const model = models.find(\r\n m =>\r\n m.id === modelIdOrName ||\r\n m.name.toLowerCase() === modelIdOrName.toLowerCase()\r\n )\r\n return model.fields.find(\r\n f => f.name.toLowerCase() === fieldName.toLowerCase()\r\n )\r\n }\r\n\r\n const viewsForModel = modelId => views.filter(v => v.modelId === modelId)\r\n\r\n return {\r\n models,\r\n views,\r\n findModel,\r\n findField,\r\n findView,\r\n viewsForModel,\r\n }\r\n}\r\n"],"file":"fullSchema.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schema/fullSchema.js"],"names":["fullSchema","models","views","findModel","idOrName","find","m","id","name","toLowerCase","findView","findField","modelIdOrName","fieldName","model","fields","f","viewsForModel","modelId","filter","v"],"mappings":"uGAAO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,MAAD,EAASC,KAAT,EAAmB;AAC3C,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,QAAQ;AACxBH,MAAAA,MAAM,CAACI,IAAP;AACE,gBAAAC,CAAC,UAAIA,CAAC,CAACC,EAAF,KAASH,QAAT,IAAqBE,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBL,QAAQ,CAACK,WAAT,EAAlD,EADH,CADwB,GAA1B;;;AAKA,MAAMC,QAAQ,GAAG,SAAXA,QAAW,CAAAN,QAAQ;AACvBF,MAAAA,KAAK,CAACG,IAAN;AACE,gBAAAC,CAAC,UAAIA,CAAC,CAACC,EAAF,KAASH,QAAT,IAAqBE,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBL,QAAQ,CAACK,WAAT,EAAlD,EADH,CADuB,GAAzB;;;AAKA,MAAME,SAAS,GAAG,SAAZA,SAAY,CAACC,aAAD,EAAgBC,SAAhB,EAA8B;AAC9C,QAAMC,KAAK,GAAGb,MAAM,CAACI,IAAP;AACZ,cAAAC,CAAC;AACCA,QAAAA,CAAC,CAACC,EAAF,KAASK,aAAT;AACAN,QAAAA,CAAC,CAACE,IAAF,CAAOC,WAAP,OAAyBG,aAAa,CAACH,WAAd,EAF1B,GADW,CAAd;;AAKA,WAAOK,KAAK,CAACC,MAAN,CAAaV,IAAb;AACL,cAAAW,CAAC,UAAIA,CAAC,CAACR,IAAF,CAAOC,WAAP,OAAyBI,SAAS,CAACJ,WAAV,EAA7B,EADI,CAAP;;AAGD,GATD;;AAWA,MAAMQ,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,OAAO,UAAIhB,KAAK,CAACiB,MAAN,CAAa,UAAAC,CAAC,UAAIA,CAAC,CAACF,OAAF,KAAcA,OAAlB,EAAd,CAAJ,EAA7B;;AAEA,SAAO;AACLjB,IAAAA,MAAM,EAANA,MADK;AAELC,IAAAA,KAAK,EAALA,KAFK;AAGLC,IAAAA,SAAS,EAATA,SAHK;AAILQ,IAAAA,SAAS,EAATA,SAJK;AAKLD,IAAAA,QAAQ,EAARA,QALK;AAMLO,IAAAA,aAAa,EAAbA,aANK,EAAP;;AAQD,CAhCM,C","sourcesContent":["export const fullSchema = (models, views) => {\n const findModel = idOrName =>\n models.find(\n m => m.id === idOrName || m.name.toLowerCase() === idOrName.toLowerCase()\n )\n\n const findView = idOrName =>\n views.find(\n m => m.id === idOrName || m.name.toLowerCase() === idOrName.toLowerCase()\n )\n\n const findField = (modelIdOrName, fieldName) => {\n const model = models.find(\n m =>\n m.id === modelIdOrName ||\n m.name.toLowerCase() === modelIdOrName.toLowerCase()\n )\n return model.fields.find(\n f => f.name.toLowerCase() === fieldName.toLowerCase()\n )\n }\n\n const viewsForModel = modelId => views.filter(v => v.modelId === modelId)\n\n return {\n models,\n views,\n findModel,\n findField,\n findView,\n viewsForModel,\n }\n}\n"],"file":"fullSchema.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/models.js.map b/packages/common/lib/schema/models.js.map index 0ba5da05e8..372868c188 100644 --- a/packages/common/lib/schema/models.js.map +++ b/packages/common/lib/schema/models.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schema/models.js"],"names":["newModel","_id","name","type","key","schema","properties","required","canDeleteModel","models","modelId","errors","model","links","fields","filter","f","typeOptions","link","push","canDelete","length"],"mappings":"8HAAA,kC;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,WAAO;AAC7BC,IAAAA,GAAG,EAAE,wBADwB;AAE7BC,IAAAA,IAAI,EAAE,EAFuB;AAG7BC,IAAAA,IAAI,EAAE,OAHuB;AAI7BC,IAAAA,GAAG,EAAE,MAJwB;AAK7BC,IAAAA,MAAM,EAAE;AACNF,MAAAA,IAAI,EAAE,QADA;AAENG,MAAAA,UAAU,EAAE;AACVJ,QAAAA,IAAI,EAAE,EAAEC,IAAI,EAAE,QAAR,EADI,EAFN;;AAKNI,MAAAA,QAAQ,EAAE,CAAC,MAAD,CALJ,EALqB,EAAP,EAAjB;;;;AAcP;;;;;;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,CAACE,MAAN,CAAaC,MAAb;AACZ,gBAAAC,CAAC,UAAIA,CAAC,CAACb,IAAF,KAAW,MAAX,IAAqBa,CAAC,CAACC,WAAF,CAAcP,OAAd,KAA0BA,OAAnD,EADW,CAAd,CADwB;;;AAKPG,MAAAA,KALO,cAKxB,uDAAwB,KAAfK,IAAe;AACtBP,UAAAA,MAAM,CAACQ,IAAP;AACUP,UAAAA,KAAK,CAACV,IADhB,uDAC+DgB,IAAI,CAAChB,IADpE;;AAGD,SATuB;AAUzB,KAbgD;;AAejD,SAAO;AACLS,IAAAA,MAAM,EAANA,MADK;AAELS,IAAAA,SAAS,EAAET,MAAM,CAACU,MAAP,GAAgB,CAFtB,EAAP;;AAID,CAnBM,C","sourcesContent":["import { generate } from \"shortid\"\r\n\r\nexport const newModel = () => ({\r\n _id: generate(),\r\n name: \"\",\r\n type: \"model\",\r\n key: \"name\",\r\n schema: {\r\n type: \"object\",\r\n properties: {\r\n name: { type: \"string\" },\r\n },\r\n required: [\"name\"],\r\n },\r\n})\r\n\r\n/**\r\n *\r\n * @param {Array} models\r\n * @param {string} modelId\r\n * @returns {}\r\n */\r\nexport const canDeleteModel = (models, modelId) => {\r\n const errors = []\r\n\r\n for (let model of models) {\r\n const links = model.fields.filter(\r\n f => f.type === \"link\" && f.typeOptions.modelId === modelId\r\n )\r\n\r\n for (let link of links) {\r\n errors.push(\r\n `The \"${model.name}\" model links to this model, via field \"${link.name}\"`\r\n )\r\n }\r\n }\r\n\r\n return {\r\n errors,\r\n canDelete: errors.length > 0,\r\n }\r\n}\r\n"],"file":"models.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schema/models.js"],"names":["newModel","_id","name","type","key","schema","properties","required","canDeleteModel","models","modelId","errors","model","links","fields","filter","f","typeOptions","link","push","canDelete","length"],"mappings":"8HAAA,kC;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,WAAO;AAC7BC,IAAAA,GAAG,EAAE,wBADwB;AAE7BC,IAAAA,IAAI,EAAE,EAFuB;AAG7BC,IAAAA,IAAI,EAAE,OAHuB;AAI7BC,IAAAA,GAAG,EAAE,MAJwB;AAK7BC,IAAAA,MAAM,EAAE;AACNF,MAAAA,IAAI,EAAE,QADA;AAENG,MAAAA,UAAU,EAAE;AACVJ,QAAAA,IAAI,EAAE,EAAEC,IAAI,EAAE,QAAR,EADI,EAFN;;AAKNI,MAAAA,QAAQ,EAAE,CAAC,MAAD,CALJ,EALqB,EAAP,EAAjB;;;;AAcP;;;;;;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,CAACE,MAAN,CAAaC,MAAb;AACZ,gBAAAC,CAAC,UAAIA,CAAC,CAACb,IAAF,KAAW,MAAX,IAAqBa,CAAC,CAACC,WAAF,CAAcP,OAAd,KAA0BA,OAAnD,EADW,CAAd,CADwB;;;AAKPG,MAAAA,KALO,cAKxB,uDAAwB,KAAfK,IAAe;AACtBP,UAAAA,MAAM,CAACQ,IAAP;AACUP,UAAAA,KAAK,CAACV,IADhB,uDAC+DgB,IAAI,CAAChB,IADpE;;AAGD,SATuB;AAUzB,KAbgD;;AAejD,SAAO;AACLS,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 type: \"model\",\n key: \"name\",\n schema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n },\n required: [\"name\"],\n },\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"} \ No newline at end of file diff --git a/packages/common/lib/schema/types/datetime.js.map b/packages/common/lib/schema/types/datetime.js.map index bd3f1e0271..88fa78ccad 100644 --- a/packages/common/lib/schema/types/datetime.js.map +++ b/packages/common/lib/schema/types/datetime.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/schema/types/datetime.js"],"names":["isType","schema","anyOf","filter","s","type","format","length","fromSchema","toSchema"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM;AACZA,MAAAA,MAAM,CAACC,KAAP;AACAD,MAAAA,MAAM,CAACC,KAAP,CAAaC,MAAb,CAAoB,UAAAC,CAAC,UAAIA,CAAC,CAACC,IAAF,KAAW,QAAX,IAAuBD,CAAC,CAACE,MAAF,KAAa,WAAxC,EAArB;AACGC,MAAAA,MADH,GACY,CAHA,GADD;;AAMbC,EAAAA,UAAU,EAAE,oBAAAP,MAAM,UAAK;AACrBI,MAAAA,IAAI,EAAE,UADe;AAErB,iBAASJ,MAAM,WAFM,EAAL,EANL;;AAUbQ,EAAAA,QAAQ,EAAE,4BAAO;AACfP,MAAAA,KAAK,EAAE,CAAC,EAAEG,IAAI,EAAE,QAAR,EAAkBC,MAAM,EAAE,WAA1B,EAAD,EAA0C,EAAE,SAAO,EAAT,EAA1C,CADQ;AAEf,iBAAS,EAFM,EAAP,EAVG;;AAcb,aAAS,4BAAO;AACdD,MAAAA,IAAI,EAAE,UADQ;AAEd,iBAAS,EAFK,EAAP,EAdI,E","sourcesContent":["export default {\r\n isType: schema =>\r\n schema.anyOf &&\r\n schema.anyOf.filter(s => s.type === \"string\" && s.format === \"date-time\")\r\n .length > 0,\r\n\r\n fromSchema: schema => ({\r\n type: \"datetime\",\r\n default: schema.default,\r\n }),\r\n toSchema: () => ({\r\n anyOf: [{ type: \"string\", format: \"date-time\" }, { const: \"\" }],\r\n default: \"\",\r\n }),\r\n default: () => ({\r\n type: \"datetime\",\r\n default: \"\",\r\n }),\r\n}\r\n"],"file":"datetime.js"} \ No newline at end of file +{"version":3,"sources":["../../../src/schema/types/datetime.js"],"names":["isType","schema","anyOf","filter","s","type","format","length","fromSchema","toSchema"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM;AACZA,MAAAA,MAAM,CAACC,KAAP;AACAD,MAAAA,MAAM,CAACC,KAAP,CAAaC,MAAb,CAAoB,UAAAC,CAAC,UAAIA,CAAC,CAACC,IAAF,KAAW,QAAX,IAAuBD,CAAC,CAACE,MAAF,KAAa,WAAxC,EAArB;AACGC,MAAAA,MADH,GACY,CAHA,GADD;;AAMbC,EAAAA,UAAU,EAAE,oBAAAP,MAAM,UAAK;AACrBI,MAAAA,IAAI,EAAE,UADe;AAErB,iBAASJ,MAAM,WAFM,EAAL,EANL;;AAUbQ,EAAAA,QAAQ,EAAE,4BAAO;AACfP,MAAAA,KAAK,EAAE,CAAC,EAAEG,IAAI,EAAE,QAAR,EAAkBC,MAAM,EAAE,WAA1B,EAAD,EAA0C,EAAE,SAAO,EAAT,EAA1C,CADQ;AAEf,iBAAS,EAFM,EAAP,EAVG;;AAcb,aAAS,4BAAO;AACdD,MAAAA,IAAI,EAAE,UADQ;AAEd,iBAAS,EAFK,EAAP,EAdI,E","sourcesContent":["export default {\n isType: schema =>\n schema.anyOf &&\n schema.anyOf.filter(s => s.type === \"string\" && s.format === \"date-time\")\n .length > 0,\n\n fromSchema: schema => ({\n type: \"datetime\",\n default: schema.default,\n }),\n toSchema: () => ({\n anyOf: [{ type: \"string\", format: \"date-time\" }, { const: \"\" }],\n default: \"\",\n }),\n default: () => ({\n type: \"datetime\",\n default: \"\",\n }),\n}\n"],"file":"datetime.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/types/index.js.map b/packages/common/lib/schema/types/index.js.map index cfebb139f9..ea3fbbc665 100644 --- a/packages/common/lib/schema/types/index.js.map +++ b/packages/common/lib/schema/types/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/schema/types/index.js"],"names":["allTypes","datetime","link","number","select","text","listTypes","Object","keys","newField","name","type","field","required","fieldsToSchema","fields","filter","f","map","properties","reduce","sch","toSchema","schemaToFields","modelSchema","key","schema","isType","fromSchema","includes"],"mappings":"0SAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,QAAQ,GAAG;AACf,iCADe;AAEfC,EAAAA,QAAQ,EAARA,oBAFe;AAGfC,EAAAA,IAAI,EAAJA,gBAHe;AAIfC,EAAAA,MAAM,EAANA,kBAJe;AAKfC,EAAAA,MAAM,EAANA,kBALe;AAMfC,EAAAA,IAAI,EAAJA,gBANe,EAAjB;;;AASO,SAASC,SAAT,GAAqB;AAC1B,SAAOC,MAAM,CAACC,IAAP,CAAYR,QAAZ,CAAP;AACD;;AAEM,SAASS,QAAT,CAAkBC,IAAlB,EAAwBC,IAAxB,EAA8B;AACnC,MAAMC,KAAK,GAAGZ,QAAQ,CAACW,IAAD,CAAR,aAAd;AACAC,EAAAA,KAAK,CAACF,IAAN,GAAaA,IAAb;AACAE,EAAAA,KAAK,CAACC,QAAN,GAAiB,KAAjB;AACA,SAAOD,KAAP;AACD;;AAEM,SAASE,cAAT,CAAwBC,MAAxB,EAAgC;AACrC,MAAMF,QAAQ,GAAGE,MAAM,CAACC,MAAP,CAAc,UAAAC,CAAC,UAAIA,CAAC,CAACJ,QAAN,EAAf,EAA+BK,GAA/B,CAAmC,UAAAD,CAAC,UAAIA,CAAC,CAACP,IAAN,EAApC,CAAjB;;AAEA,SAAO;AACLC,IAAAA,IAAI,EAAE,QADD;AAELE,IAAAA,QAAQ,EAARA,QAFK;AAGLM,IAAAA,UAAU,EAAEJ,MAAM,CAACK,MAAP,CAAc,UAACC,GAAD,EAAMT,KAAN,EAAgB;AACxCS,MAAAA,GAAG,CAACT,KAAK,CAACF,IAAP,CAAH,GAAkBV,QAAQ,CAACY,KAAK,CAACD,IAAP,CAAR,CAAqBW,QAArB,CAA8BV,KAA9B,CAAlB;AACA,aAAOS,GAAP;AACD,KAHW,EAGT,EAHS,CAHP,EAAP;;AAQD;;AAEM,SAASE,cAAT,CAAwBC,WAAxB,EAAqC;AAC1C,SAAOjB,MAAM,CAACC,IAAP,CAAYgB,WAAW,CAACL,UAAxB,EAAoCD,GAApC,CAAwC,UAAAO,GAAG,EAAI;AACpD,QAAMC,MAAM,GAAGF,WAAW,CAACL,UAAZ,CAAuBM,GAAvB,CAAf;AACA,SAAK,IAAId,IAAT,IAAiBX,QAAjB,EAA2B;AACzB,UAAIA,QAAQ,CAACW,IAAD,CAAR,CAAegB,MAAf,CAAsBD,MAAtB,CAAJ,EAAmC;AACjC,YAAMd,KAAK,GAAGZ,QAAQ,CAACW,IAAD,CAAR,CAAeiB,UAAf,CAA0BF,MAA1B,CAAd;AACAd,QAAAA,KAAK,CAACC,QAAN,GAAiBW,WAAW,CAACX,QAAZ,CAAqBgB,QAArB,CAA8BJ,GAA9B,CAAjB;AACAb,QAAAA,KAAK,CAACF,IAAN,GAAae,GAAb;AACA,eAAOb,KAAP;AACD;AACF;AACF,GAVM,CAAP;AAWD","sourcesContent":["import boolean from \"./boolean\"\r\nimport datetime from \"./datetime\"\r\nimport link from \"./link\"\r\nimport number from \"./number\"\r\nimport select from \"./select\"\r\nimport text from \"./text\"\r\n\r\nconst allTypes = {\r\n boolean,\r\n datetime,\r\n link,\r\n number,\r\n select,\r\n text,\r\n}\r\n\r\nexport function listTypes() {\r\n return Object.keys(allTypes)\r\n}\r\n\r\nexport function newField(name, type) {\r\n const field = allTypes[type].default()\r\n field.name = name\r\n field.required = false\r\n return field\r\n}\r\n\r\nexport function fieldsToSchema(fields) {\r\n const required = fields.filter(f => f.required).map(f => f.name)\r\n\r\n return {\r\n type: \"object\",\r\n required,\r\n properties: fields.reduce((sch, field) => {\r\n sch[field.name] = allTypes[field.type].toSchema(field)\r\n return sch\r\n }, {}),\r\n }\r\n}\r\n\r\nexport function schemaToFields(modelSchema) {\r\n return Object.keys(modelSchema.properties).map(key => {\r\n const schema = modelSchema.properties[key]\r\n for (let type in allTypes) {\r\n if (allTypes[type].isType(schema)) {\r\n const field = allTypes[type].fromSchema(schema)\r\n field.required = modelSchema.required.includes(key)\r\n field.name = key\r\n return field\r\n }\r\n }\r\n })\r\n}\r\n"],"file":"index.js"} \ No newline at end of file +{"version":3,"sources":["../../../src/schema/types/index.js"],"names":["allTypes","datetime","link","number","select","text","listTypes","Object","keys","newField","name","type","field","required","fieldsToSchema","fields","filter","f","map","properties","reduce","sch","toSchema","schemaToFields","modelSchema","key","schema","isType","fromSchema","includes"],"mappings":"0SAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,QAAQ,GAAG;AACf,iCADe;AAEfC,EAAAA,QAAQ,EAARA,oBAFe;AAGfC,EAAAA,IAAI,EAAJA,gBAHe;AAIfC,EAAAA,MAAM,EAANA,kBAJe;AAKfC,EAAAA,MAAM,EAANA,kBALe;AAMfC,EAAAA,IAAI,EAAJA,gBANe,EAAjB;;;AASO,SAASC,SAAT,GAAqB;AAC1B,SAAOC,MAAM,CAACC,IAAP,CAAYR,QAAZ,CAAP;AACD;;AAEM,SAASS,QAAT,CAAkBC,IAAlB,EAAwBC,IAAxB,EAA8B;AACnC,MAAMC,KAAK,GAAGZ,QAAQ,CAACW,IAAD,CAAR,aAAd;AACAC,EAAAA,KAAK,CAACF,IAAN,GAAaA,IAAb;AACAE,EAAAA,KAAK,CAACC,QAAN,GAAiB,KAAjB;AACA,SAAOD,KAAP;AACD;;AAEM,SAASE,cAAT,CAAwBC,MAAxB,EAAgC;AACrC,MAAMF,QAAQ,GAAGE,MAAM,CAACC,MAAP,CAAc,UAAAC,CAAC,UAAIA,CAAC,CAACJ,QAAN,EAAf,EAA+BK,GAA/B,CAAmC,UAAAD,CAAC,UAAIA,CAAC,CAACP,IAAN,EAApC,CAAjB;;AAEA,SAAO;AACLC,IAAAA,IAAI,EAAE,QADD;AAELE,IAAAA,QAAQ,EAARA,QAFK;AAGLM,IAAAA,UAAU,EAAEJ,MAAM,CAACK,MAAP,CAAc,UAACC,GAAD,EAAMT,KAAN,EAAgB;AACxCS,MAAAA,GAAG,CAACT,KAAK,CAACF,IAAP,CAAH,GAAkBV,QAAQ,CAACY,KAAK,CAACD,IAAP,CAAR,CAAqBW,QAArB,CAA8BV,KAA9B,CAAlB;AACA,aAAOS,GAAP;AACD,KAHW,EAGT,EAHS,CAHP,EAAP;;AAQD;;AAEM,SAASE,cAAT,CAAwBC,WAAxB,EAAqC;AAC1C,SAAOjB,MAAM,CAACC,IAAP,CAAYgB,WAAW,CAACL,UAAxB,EAAoCD,GAApC,CAAwC,UAAAO,GAAG,EAAI;AACpD,QAAMC,MAAM,GAAGF,WAAW,CAACL,UAAZ,CAAuBM,GAAvB,CAAf;AACA,SAAK,IAAId,IAAT,IAAiBX,QAAjB,EAA2B;AACzB,UAAIA,QAAQ,CAACW,IAAD,CAAR,CAAegB,MAAf,CAAsBD,MAAtB,CAAJ,EAAmC;AACjC,YAAMd,KAAK,GAAGZ,QAAQ,CAACW,IAAD,CAAR,CAAeiB,UAAf,CAA0BF,MAA1B,CAAd;AACAd,QAAAA,KAAK,CAACC,QAAN,GAAiBW,WAAW,CAACX,QAAZ,CAAqBgB,QAArB,CAA8BJ,GAA9B,CAAjB;AACAb,QAAAA,KAAK,CAACF,IAAN,GAAae,GAAb;AACA,eAAOb,KAAP;AACD;AACF;AACF,GAVM,CAAP;AAWD","sourcesContent":["import boolean from \"./boolean\"\nimport datetime from \"./datetime\"\nimport link from \"./link\"\nimport number from \"./number\"\nimport select from \"./select\"\nimport text from \"./text\"\n\nconst allTypes = {\n boolean,\n datetime,\n link,\n number,\n select,\n text,\n}\n\nexport function listTypes() {\n return Object.keys(allTypes)\n}\n\nexport function newField(name, type) {\n const field = allTypes[type].default()\n field.name = name\n field.required = false\n return field\n}\n\nexport function fieldsToSchema(fields) {\n const required = fields.filter(f => f.required).map(f => f.name)\n\n return {\n type: \"object\",\n required,\n properties: fields.reduce((sch, field) => {\n sch[field.name] = allTypes[field.type].toSchema(field)\n return sch\n }, {}),\n }\n}\n\nexport function schemaToFields(modelSchema) {\n return Object.keys(modelSchema.properties).map(key => {\n const schema = modelSchema.properties[key]\n for (let type in allTypes) {\n if (allTypes[type].isType(schema)) {\n const field = allTypes[type].fromSchema(schema)\n field.required = modelSchema.required.includes(key)\n field.name = key\n return field\n }\n }\n })\n}\n"],"file":"index.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/types/link.js.map b/packages/common/lib/schema/types/link.js.map index b9930a2c18..285c2ef594 100644 --- a/packages/common/lib/schema/types/link.js.map +++ b/packages/common/lib/schema/types/link.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/schema/types/link.js"],"names":["isType","schema","type","properties","modelId","fromSchema","viewId","toSchema","field","_id","undefined","required"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM,UAAIA,MAAM,CAACC,IAAP,KAAgB,QAAhB,IAA4BD,MAAM,CAACE,UAAP,CAAkBC,OAAlD,EADD;;AAGbC,EAAAA,UAAU,EAAE,oBAAAJ,MAAM,UAAK;AACrBC,MAAAA,IAAI,EAAE,MADe;AAErBE,MAAAA,OAAO,EAAEH,MAAM,CAACE,UAAP,CAAkBC,OAAlB,SAFY;AAGrBE,MAAAA,MAAM,EAAEL,MAAM,CAACE,UAAP,CAAkBG,MAAlB,SAHa;AAIrB,iBAASL,MAAM,WAJM,EAAL,EAHL;;;AAUbM,EAAAA,QAAQ,EAAE,kBAAAC,KAAK,UAAK;AAClBN,MAAAA,IAAI,EAAE,QADY;AAElBC,MAAAA,UAAU,EAAE;AACVM,QAAAA,GAAG,EAAE,EAAEP,IAAI,EAAE,QAAR,EADK;AAEVI,QAAAA,MAAM,EAAEE,KAAK,CAACF,MAAN,GAAe,EAAE,SAAOE,KAAK,CAACF,MAAf,EAAf,GAAyCI,SAFvC;AAGVN,QAAAA,OAAO,EAAEI,KAAK,CAACJ,OAAN,GAAgB,EAAE,SAAOI,KAAK,CAACJ,OAAf,EAAhB,GAA2CM,SAH1C,EAFM;;AAOlBC,MAAAA,QAAQ,EAAE,CAAC,KAAD,CAPQ;AAQlB,iBAAS,EAAEF,GAAG,EAAE,EAAP,EARS,EAAL,EAVF;;;AAqBb,aAAS,4BAAO;AACdP,MAAAA,IAAI,EAAE,MADQ;AAEdE,MAAAA,OAAO,EAAE,IAFK;AAGdE,MAAAA,MAAM,EAAE,IAHM,EAAP,EArBI,E","sourcesContent":["export default {\r\n isType: schema => schema.type === \"object\" && schema.properties.modelId,\r\n\r\n fromSchema: schema => ({\r\n type: \"link\",\r\n modelId: schema.properties.modelId.const,\r\n viewId: schema.properties.viewId.const,\r\n default: schema.default,\r\n }),\r\n\r\n toSchema: field => ({\r\n type: \"object\",\r\n properties: {\r\n _id: { type: \"string\" },\r\n viewId: field.viewId ? { const: field.viewId } : undefined,\r\n modelId: field.modelId ? { const: field.modelId } : undefined,\r\n },\r\n required: [\"_id\"],\r\n default: { _id: \"\" },\r\n }),\r\n\r\n default: () => ({\r\n type: \"link\",\r\n modelId: null,\r\n viewId: null,\r\n }),\r\n}\r\n"],"file":"link.js"} \ No newline at end of file +{"version":3,"sources":["../../../src/schema/types/link.js"],"names":["isType","schema","type","properties","modelId","fromSchema","viewId","toSchema","field","_id","undefined","required"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM,UAAIA,MAAM,CAACC,IAAP,KAAgB,QAAhB,IAA4BD,MAAM,CAACE,UAAP,CAAkBC,OAAlD,EADD;;AAGbC,EAAAA,UAAU,EAAE,oBAAAJ,MAAM,UAAK;AACrBC,MAAAA,IAAI,EAAE,MADe;AAErBE,MAAAA,OAAO,EAAEH,MAAM,CAACE,UAAP,CAAkBC,OAAlB,SAFY;AAGrBE,MAAAA,MAAM,EAAEL,MAAM,CAACE,UAAP,CAAkBG,MAAlB,SAHa;AAIrB,iBAASL,MAAM,WAJM,EAAL,EAHL;;;AAUbM,EAAAA,QAAQ,EAAE,kBAAAC,KAAK,UAAK;AAClBN,MAAAA,IAAI,EAAE,QADY;AAElBC,MAAAA,UAAU,EAAE;AACVM,QAAAA,GAAG,EAAE,EAAEP,IAAI,EAAE,QAAR,EADK;AAEVI,QAAAA,MAAM,EAAEE,KAAK,CAACF,MAAN,GAAe,EAAE,SAAOE,KAAK,CAACF,MAAf,EAAf,GAAyCI,SAFvC;AAGVN,QAAAA,OAAO,EAAEI,KAAK,CAACJ,OAAN,GAAgB,EAAE,SAAOI,KAAK,CAACJ,OAAf,EAAhB,GAA2CM,SAH1C,EAFM;;AAOlBC,MAAAA,QAAQ,EAAE,CAAC,KAAD,CAPQ;AAQlB,iBAAS,EAAEF,GAAG,EAAE,EAAP,EARS,EAAL,EAVF;;;AAqBb,aAAS,4BAAO;AACdP,MAAAA,IAAI,EAAE,MADQ;AAEdE,MAAAA,OAAO,EAAE,IAFK;AAGdE,MAAAA,MAAM,EAAE,IAHM,EAAP,EArBI,E","sourcesContent":["export default {\n isType: schema => schema.type === \"object\" && schema.properties.modelId,\n\n fromSchema: schema => ({\n type: \"link\",\n modelId: schema.properties.modelId.const,\n viewId: schema.properties.viewId.const,\n default: schema.default,\n }),\n\n toSchema: field => ({\n type: \"object\",\n properties: {\n _id: { type: \"string\" },\n viewId: field.viewId ? { const: field.viewId } : undefined,\n modelId: field.modelId ? { const: field.modelId } : undefined,\n },\n required: [\"_id\"],\n default: { _id: \"\" },\n }),\n\n default: () => ({\n type: \"link\",\n modelId: null,\n viewId: null,\n }),\n}\n"],"file":"link.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/types/number.js.map b/packages/common/lib/schema/types/number.js.map index 1f8afe4adf..f9cd61350d 100644 --- a/packages/common/lib/schema/types/number.js.map +++ b/packages/common/lib/schema/types/number.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/schema/types/number.js"],"names":["isType","schema","type","fromSchema","toSchema","field","maximum","minimum","undefined"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM,UAAIA,MAAM,CAACC,IAAP,KAAgB,QAApB,EADD;AAEbC,EAAAA,UAAU,EAAE,oBAAAF,MAAM,UAAIA,MAAJ,EAFL;AAGbG,EAAAA,QAAQ,EAAE,kBAAAC,KAAK,UAAK;AAClBH,MAAAA,IAAI,EAAE,QADY;AAElBI,MAAAA,OAAO,EAAED,KAAK,CAACC,OAFG;AAGlBC,MAAAA,OAAO,EAAEF,KAAK,CAACE,OAHG;AAIlB,iBAASC,SAJS,EAAL,EAHF;;AASb,aAAS,4BAAO;AACdN,MAAAA,IAAI,EAAE,QADQ;AAEdI,MAAAA,OAAO,EAAE,IAFK;AAGdC,MAAAA,OAAO,EAAE,IAHK,EAAP,EATI,E","sourcesContent":["export default {\r\n isType: schema => schema.type === \"number\",\r\n fromSchema: schema => schema,\r\n toSchema: field => ({\r\n type: \"number\",\r\n maximum: field.maximum,\r\n minimum: field.minimum,\r\n default: undefined,\r\n }),\r\n default: () => ({\r\n type: \"number\",\r\n maximum: null,\r\n minimum: null,\r\n }),\r\n}\r\n"],"file":"number.js"} \ No newline at end of file +{"version":3,"sources":["../../../src/schema/types/number.js"],"names":["isType","schema","type","fromSchema","toSchema","field","maximum","minimum","undefined"],"mappings":"uHAAe;AACbA,EAAAA,MAAM,EAAE,gBAAAC,MAAM,UAAIA,MAAM,CAACC,IAAP,KAAgB,QAApB,EADD;AAEbC,EAAAA,UAAU,EAAE,oBAAAF,MAAM,UAAIA,MAAJ,EAFL;AAGbG,EAAAA,QAAQ,EAAE,kBAAAC,KAAK,UAAK;AAClBH,MAAAA,IAAI,EAAE,QADY;AAElBI,MAAAA,OAAO,EAAED,KAAK,CAACC,OAFG;AAGlBC,MAAAA,OAAO,EAAEF,KAAK,CAACE,OAHG;AAIlB,iBAASC,SAJS,EAAL,EAHF;;AASb,aAAS,4BAAO;AACdN,MAAAA,IAAI,EAAE,QADQ;AAEdI,MAAAA,OAAO,EAAE,IAFK;AAGdC,MAAAA,OAAO,EAAE,IAHK,EAAP,EATI,E","sourcesContent":["export default {\n isType: schema => schema.type === \"number\",\n fromSchema: schema => schema,\n toSchema: field => ({\n type: \"number\",\n maximum: field.maximum,\n minimum: field.minimum,\n default: undefined,\n }),\n default: () => ({\n type: \"number\",\n maximum: null,\n minimum: null,\n }),\n}\n"],"file":"number.js"} \ No newline at end of file diff --git a/packages/common/lib/schema/views.js.map b/packages/common/lib/schema/views.js.map index cbdb6f6798..07be3044e4 100644 --- a/packages/common/lib/schema/views.js.map +++ b/packages/common/lib/schema/views.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schema/views.js"],"names":["newView","modelId","id","name"],"mappings":"oGAAA;;AAEO,IAAMA,OAAO,GAAG,SAAVA,OAAU,QAACC,OAAD,uEAAW,IAAX,QAAqB;AAC1CC,IAAAA,EAAE,EAAE,wBADsC;AAE1CC,IAAAA,IAAI,EAAE,EAFoC;AAG1CF,IAAAA,OAAO,EAAPA,OAH0C,EAArB,EAAhB,C","sourcesContent":["import { generate } from \"shortid\"\r\n\r\nexport const newView = (modelId = null) => ({\r\n id: generate(),\r\n name: \"\",\r\n modelId,\r\n})\r\n"],"file":"views.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schema/views.js"],"names":["newView","modelId","id","name"],"mappings":"oGAAA;;AAEO,IAAMA,OAAO,GAAG,SAAVA,OAAU,QAACC,OAAD,uEAAW,IAAX,QAAqB;AAC1CC,IAAAA,EAAE,EAAE,wBADsC;AAE1CC,IAAAA,IAAI,EAAE,EAFoC;AAG1CF,IAAAA,OAAO,EAAPA,OAH0C,EAArB,EAAhB,C","sourcesContent":["import { generate } from \"shortid\"\n\nexport const newView = (modelId = null) => ({\n id: generate(),\n name: \"\",\n modelId,\n})\n"],"file":"views.js"} \ No newline at end of file diff --git a/packages/common/lib/schemaValidation/index.js.map b/packages/common/lib/schemaValidation/index.js.map index 1dfdf41881..009b82c4cf 100644 --- a/packages/common/lib/schemaValidation/index.js.map +++ b/packages/common/lib/schemaValidation/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/schemaValidation/index.js"],"names":["ajv","Ajv"],"mappings":"4LAAA;;AAEA,IAAMA,GAAG,GAAG,IAAIC,eAAJ,EAAZ,C;;AAEeD,G","sourcesContent":["import Ajv from \"ajv\";\r\n\r\nconst ajv = new Ajv();\r\n\r\nexport default ajv;"],"file":"index.js"} \ No newline at end of file +{"version":3,"sources":["../../src/schemaValidation/index.js"],"names":["ajv","Ajv"],"mappings":"4LAAA;;AAEA,IAAMA,GAAG,GAAG,IAAIC,eAAJ,EAAZ,C;;AAEeD,G","sourcesContent":["import Ajv from \"ajv\";\n\nconst ajv = new Ajv();\n\nexport default ajv;"],"file":"index.js"} \ No newline at end of file diff --git a/packages/server/middleware/controllers/auth.js b/packages/server/middleware/controllers/auth.js index 2edad7f06c..fe4c8fd9a1 100644 --- a/packages/server/middleware/controllers/auth.js +++ b/packages/server/middleware/controllers/auth.js @@ -19,7 +19,7 @@ exports.authenticate = async ctx => { // query couch for their username const db = new CouchDB(ctx.params.instanceId); - const dbUser = await db.query("database/by_username", { + const dbUser = await db.query("by_username", { include_docs: true, key: username }); diff --git a/packages/server/middleware/controllers/instance.js b/packages/server/middleware/controllers/instance.js index 557e565785..e5ae6ea95b 100644 --- a/packages/server/middleware/controllers/instance.js +++ b/packages/server/middleware/controllers/instance.js @@ -16,7 +16,7 @@ exports.create = async function(ctx) { by_type: { map: function(doc) { emit([doc.type], doc._id); - } + }.toString() } } }); diff --git a/packages/server/middleware/controllers/record.js b/packages/server/middleware/controllers/record.js index 5669227f0f..474f395191 100644 --- a/packages/server/middleware/controllers/record.js +++ b/packages/server/middleware/controllers/record.js @@ -1,5 +1,5 @@ -const CouchDB = require("../../db") -const { schemaValidator } = require("@budibase/common") +const CouchDB = require("../../db"); +const { schemaValidator } = require("../../../common"); exports.save = async function(ctx) { const db = new CouchDB(ctx.params.instanceId); @@ -46,7 +46,7 @@ exports.save = async function(ctx) { exports.fetch = async function(ctx) { const db = new CouchDB(ctx.params.instanceId) const response = await db.query( - `database/${ctx.params.viewName}`, + `database/${ctx.params.modelId}`, { include_docs: true }