@jsonui/core 0.0.12 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/cjs/index.js +14600 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/index.d.ts +13 -0
- package/dist/{stock → cjs/types/stock}/Stock.d.ts +27 -27
- package/dist/cjs/types/stock/Stock.test.d.ts +1 -0
- package/dist/{stock → cjs/types/stock}/appRootFunctions.d.ts +7 -7
- package/dist/{stock → cjs/types/stock}/functions.d.ts +7 -7
- package/dist/{stock → cjs/types/stock}/validation.d.ts +7 -7
- package/dist/{store → cjs/types/store}/persistConfig.d.ts +8 -8
- package/dist/{store → cjs/types/store}/reducers.d.ts +4 -4
- package/dist/{store → cjs/types/store}/root/actions.d.ts +10 -10
- package/dist/{store → cjs/types/store}/root/reducer.d.ts +4 -4
- package/dist/cjs/types/store/root/reducer.test.d.ts +1 -0
- package/dist/cjs/types/store/root/selector.test.d.ts +1 -0
- package/dist/{store → cjs/types/store}/root/selectors.d.ts +11 -11
- package/dist/{util → cjs/types/utils}/I18n.d.ts +27 -27
- package/dist/cjs/types/utils/I18n.test.d.ts +1 -0
- package/dist/{utils → cjs/types/utils}/constants.d.ts +23 -19
- package/dist/{utils → cjs/types/utils}/contextHandler.d.ts +4 -4
- package/dist/{util → cjs/types/utils}/jsonRefResolver.d.ts +2 -2
- package/dist/{utils → cjs/types/utils}/types.d.ts +27 -27
- package/dist/cjs/types/utils/util.d.ts +18 -0
- package/dist/cjs/types/utils/util.test.d.ts +1 -0
- package/dist/{wrapper → cjs/types/wrapper}/wrapperUtil.d.ts +15 -15
- package/dist/esm/index.js +14600 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/index.d.ts +13 -0
- package/dist/esm/types/stock/Stock.d.ts +27 -0
- package/dist/esm/types/stock/Stock.test.d.ts +1 -0
- package/dist/esm/types/stock/appRootFunctions.d.ts +7 -0
- package/dist/esm/types/stock/functions.d.ts +7 -0
- package/dist/esm/types/stock/validation.d.ts +7 -0
- package/dist/esm/types/store/persistConfig.d.ts +8 -0
- package/dist/esm/types/store/reducers.d.ts +4 -0
- package/dist/esm/types/store/root/actions.d.ts +10 -0
- package/dist/esm/types/store/root/reducer.d.ts +4 -0
- package/dist/esm/types/store/root/reducer.test.d.ts +1 -0
- package/dist/esm/types/store/root/selector.test.d.ts +1 -0
- package/dist/esm/types/store/root/selectors.d.ts +11 -0
- package/dist/{utils → esm/types/utils}/I18n.d.ts +27 -27
- package/dist/esm/types/utils/I18n.test.d.ts +1 -0
- package/dist/{util → esm/types/utils}/constants.d.ts +23 -19
- package/dist/esm/types/utils/contextHandler.d.ts +4 -0
- package/dist/{utils → esm/types/utils}/jsonRefResolver.d.ts +2 -2
- package/dist/{util → esm/types/utils}/types.d.ts +27 -27
- package/dist/esm/types/utils/util.d.ts +18 -0
- package/dist/esm/types/utils/util.test.d.ts +1 -0
- package/dist/esm/types/wrapper/wrapperUtil.d.ts +15 -0
- package/dist/index.d.ts +273 -14
- package/package.json +23 -9
- package/.eslintrc.json +0 -52
- package/.prettierrc +0 -6
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.module.mjs +0 -2
- package/dist/index.module.mjs.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/store/renderers/actions.d.ts +0 -10
- package/dist/store/renderers/reducer.d.ts +0 -2
- package/dist/store/renderers/selectors.d.ts +0 -5
- package/dist/util/contextHandler.d.ts +0 -3
- package/dist/util/util.d.ts +0 -22
- package/dist/utils/util.d.ts +0 -23
- package/src/index.ts +0 -30
- package/src/stock/Stock.ts +0 -75
- package/src/stock/appRootFunctions.ts +0 -15
- package/src/stock/functions.ts +0 -25
- package/src/stock/validation.ts +0 -30
- package/src/store/persistConfig.ts +0 -20
- package/src/store/reducers.ts +0 -6
- package/src/store/root/actions.ts +0 -12
- package/src/store/root/reducer.ts +0 -71
- package/src/store/root/selectors.ts +0 -61
- package/src/typings/key-value-replace.d.ts +0 -8
- package/src/utils/I18n.ts +0 -99
- package/src/utils/constants.ts +0 -21
- package/src/utils/contextHandler.ts +0 -5
- package/src/utils/jsonRefResolver.ts +0 -88
- package/src/utils/types.ts +0 -35
- package/src/utils/util.ts +0 -144
- package/src/wrapper/wrapperUtil.tsx +0 -138
- package/tsconfig.json +0 -5
package/dist/index.umd.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("lodash/orderBy"),require("traverse"),require("jsonpointer"),require("lodash/cloneDeep"),require("lodash/drop"),require("lodash/findIndex"),require("lodash/pull"),require("lodash/compact"),require("lodash/findLastIndex"),require("lodash/unset"),require("lodash/uniq"),require("lodash/defaultsDeep"),require("ajv"),require("key-value-replace"),require("redux-persist"),require("lodash/pick"),require("redux"),require("immer")):"function"==typeof define&&define.amd?define(["exports","react","lodash/orderBy","traverse","jsonpointer","lodash/cloneDeep","lodash/drop","lodash/findIndex","lodash/pull","lodash/compact","lodash/findLastIndex","lodash/unset","lodash/uniq","lodash/defaultsDeep","ajv","key-value-replace","redux-persist","lodash/pick","redux","immer"],t):t((e||self).core={},e.react,e.orderBy,e.traverse,e.jsonpointer,e.cloneDeep,e.drop,e.findIndex,e.pull,e.compact,e.findLastIndex,e.unset,e.uniq,e.defaultsDeep,e.ajv,e.keyValueReplace,e.reduxPersist,e.pick,e.redux,e.immer)}(this,function(e,t,r,n,i,o,a,s,u,l,c,f,h,d,p,v,g,y,m,P){function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=/*#__PURE__*/E(t),j=/*#__PURE__*/E(r),x=/*#__PURE__*/E(n),b=/*#__PURE__*/E(i),k=/*#__PURE__*/E(o),S=/*#__PURE__*/E(a),A=/*#__PURE__*/E(s),R=/*#__PURE__*/E(u),T=/*#__PURE__*/E(l),O=/*#__PURE__*/E(c),I=/*#__PURE__*/E(f),$=/*#__PURE__*/E(h),q=/*#__PURE__*/E(d),C=/*#__PURE__*/E(p),D=/*#__PURE__*/E(v),L=/*#__PURE__*/E(y),N=/*#__PURE__*/E(P);function W(){return W=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},W.apply(this,arguments)}function F(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}function M(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var w="/",K=".error",H="$modifier",Y="$action",B=["data"],G=["set","get"],U=["string","number","boolean","null"],V="$children",z={__proto__:null,SEPARATOR:w,STORE_ERROR_POSTFIX:K,PATH_MODIFIERS_KEY:"$pathModifiers",MODIFIER_KEY:H,ACTION_KEY:Y,PERSIST_STORAGE_KEY:"$persistStores",PERSIST_STORAGE_NAMES:B,REF_ASSETS:"$assetsRef",REF_LOCALES:"$locales",REF_VALIDATES:"$validations",STYLE_WEB_NAME:"styleWeb",STYLE_RN_NAME:"styleRN",REDUX_FUNCTIONS:G,PATHNAME:"path",SIMPLE_DATA_TYPES:U,V_CHILDREN_NAME:V,V_COMP_NAME:"$comp",ITEM_OF_ARRAY:"item",PAGINATION_ITEM_PER_PAGE:1},Z=function(e,t){if(null==e||null==t||"string"!=typeof t)return null;if(t===w)return e;try{return b.default.get(e,t.startsWith(w)?t:"/"+t)}catch(e){return null}},J=function(e,t,r){if(null!=e&&null!=t&&"string"==typeof t)if(t!==w&&""!==t)try{b.default.set(e,t.startsWith(w)?t:"/"+t,r)}catch(e){}else e=r},X=function(e){return"/"+e.join("/")};function Q(e){return e&&"object"==typeof e&&!Array.isArray(e)}var ee=function(e){var t=e.split(w);t&&t.length>1&&""===t[t.length-1]&&t.pop();var r=O.default(t,function(e){return""===e});r>0&&(t=S.default(t,r)),t=R.default(t,".");var n=0,i=-1;do{n+=1,-1!==(i=A.default(t,function(e){return".."===e}))&&(I.default(t,"["+i+"]"),I.default(t,"["+(i-1)+"]"),t=T.default(t))}while(-1!==i&&n<100);return t.join(w)},te=function(e){return"number"==typeof e},re={__proto__:null,jsonPointerGet:Z,jsonPointerSet:J,getCleanedTopic:function(e){return!e||"string"!=typeof e||0===e.length||e.length>1024?null:e.replace(/[^0-9a-zA-Z]/g,"-")},pathArrayToPathString:function(e){return e.map(function(e,t){return Number.isInteger(e)?"["+e+"]":(t>0?".":"")+e}).join("")},pathArrayToJsonPointer:X,isObject:Q,mergeDeep:function e(t){var r=[].slice.call(arguments,1);if(!r.length)return t;var n=r.shift();if(Q(t)&&Q(n))for(var i in n){var o,a;Q(n[i])?(t[i]||Object.assign(t,((o={})[i]={},o)),e(t[i],n[i])):Object.assign(t,((a={})[i]=n[i],a))}return e.apply(void 0,[t].concat(r))},mergePath:function(e,t){if(!t||"object"!=typeof t)return e;var r=k.default(e);return Object.entries(t).forEach(function(e){b.default.set(r,e[0],e[1])}),r},changeRelativePath:ee,getStyleForWeb:function(e,t){return void 0===e&&(e={}),"View"===t?function(e){var t=e.parentComp,r=W({display:"flex",flexDirection:"column"},e.style,e.styleWeb);return r&&r.borderWidth&&!r.borderStyle&&(r.borderStyle="solid"),r&&r.flex&&(t&&t.style&&t.style.flex&&t.style.flex<1?(r.height="100%",r.width="100%"):r.height||(r.height=100*r.flex+"%")),r}(e):W({},e.style,e.styleWeb)},noChildren:function(e){return["Image"].includes(e)},isNumber:te},ne=["parentComp"],ie=["parentComp"],oe=function(e,t){var r=[],n=F(e,ne);x.default(n).forEach(function(e){!e||!e.$action||this.path.length>1&&this.path.includes(V)||r.push({path:this.path,level:this.level})}),j.default(r,["level"],["desc"]).forEach(function(r){try{var n=x.default(e).get(r.path),i=n[Y],o=F(n,[Y].map(M));return x.default(e).set(r.path,function(){try{var r=arguments;return Promise.resolve(t.callFunction(i,o,e,[].slice.call(r))).then(function(){})}catch(e){return Promise.reject(e)}}),Promise.resolve()}catch(e){return Promise.reject(e)}})},ae=function(e,t){var r=[],n=F(e,ie);x.default(n).forEach(function(e){!e||!e.$modifier||G.includes(e.$modifier)||this.path.length>1&&this.path.includes(V)||r.push({path:this.path,level:this.level})}),j.default(r,["level"],["desc"]).forEach(function(r){try{var n=x.default(e).get(r.path),i=n[H],o=F(n,[H].map(M));return x.default(e).set(r.path,t.callFunction(i,o,e)),Promise.resolve()}catch(e){return Promise.reject(e)}})},se=function(e,t){var r,n=W({},U.includes(typeof e)?{}:e,((r={parentComp:t}).$comp=U.includes(typeof e)||null==e?"_PrimitiveProp":e.$comp,r.$children=U.includes(typeof e)||null==e?e:e.$children,r));for(var i in n)void 0===n[i]&&delete n[i];return n},ue=function(e,t,r){var n=F(e,["parentComp",V].map(M));return e&&Array.isArray(t)?t.map(function(e,t){/*#__PURE__*/return _.default.createElement(r,W({key:t},se(e,n)))}):/*#__PURE__*/_.default.createElement(r,se(t,n))},le={__proto__:null,actionBuilder:oe,modifierBuilder:ae,pathModifierBuilder:function(e,t){var r=W({},e.currentPaths),n=!1;return t&&0!==Object.keys(t).length&&Object.keys(t).forEach(function(e){if(e&&t[e]&&null!=t[e].path){var i,o,a=t[e].path,s=r[e];n=!0,r[e]=!(""+a).startsWith(w)&&s&&s.path?((i={}).path=ee(""+s.path+w+a),i):((o={}).path=a,o),r[e]&&!(""+r[e].path).startsWith(w)&&(r[e].path="/"+r[e].path)}}),n?{currentPaths:r}:void 0},getWrapperProps:se,getRootWrapperProps:function(e,t){var r=W({},e);return ae(r,t),oe(r,t),r.isList&&(r.$children=function(e){var t=e.page,r=void 0===t?0:t,n=e.listLength,i=void 0===n?0:n,o=e.itemPerPage,a=void 0===o?1:o,s=e.listItem,u=e.$pathModifiers,l=[];if(te(r)&&te(i)&&te(a)&&u)for(var c=(r=r>=0?r:0)*(a=a>=0?a:0)<=(i=i>=0?i:0)?r*a:0,f=u[Object.keys(u)[0]],h=c;h<i&&h<c+a;h++){var d,p;l.push(W({},s,((p={}).$pathModifiers=W({},u,((d={})[Object.keys(u)[0]]=W({},f,{path:h}),d)),p)))}return l}(r)),r},getChildrensForRoot:ue,generateChildren:function(e,t){return"_PrimitiveProp"!==e.$comp?ue(e,e.$children,t.Wrapper):e.$children}},ce=function(e){return!(!e||"string"!=typeof e)&&/^[A-Za-z]*:\/\//.test(e)},fe=function(e){var t=e.split(w);t=R.default(t,".");var r=0,n=-1;do{r+=1,-1!==(n=A.default(t,function(e){return".."===e}))&&(I.default(t,"["+n+"]"),I.default(t,"["+(n-1)+"]"),t=T.default(t))}while(-1!==n&&r<100);return t.join(w)},he={__proto__:null,collectJsonKeys:function(e,t){var r=[];x.default(t).forEach(function(t){t&&t[e]&&this&&!this.circular&&r.push(t[e])});var n={};return $.default(T.default(r)).forEach(function(e){return q.default(n,e)}),n},getRefs:function(e,t,r){void 0===r&&(r="");var n=[];return x.default(t).forEach(function(t){if(t&&t[e]&&this&&!this.circular){var i,o=t[e];if((s=o)&&"string"==typeof s&&!ce(s)&&s.startsWith(w)){var a=function(e){if(e&&"string"==typeof e){var t=e.match(/^([A-Za-z]*:\/\/[^/]*)(\/|)/);if(t)return t[1]+"/"}return null}(r);i=fe(""+a+o)}else i=function(e){return!!e&&"string"==typeof e&&!ce(e)&&!e.startsWith(w)}(o)?fe(""+r+o):o;t[e]=i,n.push(i)}var s}),$.default(T.default(n))}},de={$id:"http://example.com/schemas/schema.json",type:"object",additionalProperties:{type:"object",properties:{translation:{type:"object",additionalProperties:{type:"string"},propertyNames:{type:"string"},minProperties:1},additionalProperties:!1}},propertyNames:{pattern:"^[A-Za-z0-9_-]*$",type:"string"},minProperties:1},pe=t.createContext(null),ve=t.createContext({}),ge=["parentComp"],ye=function(e,t,r){var n=t.store,i=t.path,o=t.isError,a=void 0!==o&&o,s=function(e){return e.root}(e);if(n&&i){var u=r&&r[n]&&r[n].path?ee(""+r[n].path+w+i):i;return function(e,t,r){return Z(e[t],r)}(s,""+n+(a?K:""),u)}return null},me="DATA_UPDATE",Pe="PURGE",Ee={getStateValue:function(e,t,r,n){var i=(void 0===t?{}:t).currentPaths,o=e.store,a=e.path,s=n.reduxStore.getState();return ye(s,{store:o,path:a},i)},get:function(e,t,r,n){var i=(void 0===t?{}:t).currentPaths,o=e.store,a=e.path,s=n.reduxStore.getState();return ye(s,{store:o,path:a},i)},set:function(e,t,r,n){var i;n.reduxStore.dispatch((i=W({},e,{value:e&&void 0!==e.value?e.value:r[0],currentPaths:t.currentPaths,stock:n}),{type:me,payload:i}))}},_e={key:"main",whitelist:["root"],transforms:[g.createTransform(function(e,t){return"root"!==t?e:L.default(e,B)},function(e,t){return"root"!==t?e:L.default(e,B)})]},je=function(e){return e.replace(/\./g,w)},xe={data:{}},be=m.combineReducers({root:function(e,t){switch(void 0===e&&(e=xe),t.type){case me:var r=t.payload,n=r.store,i=r.path,o=r.value,a=r.jsonataDef,s=r.currentPaths,u=r.stock;if(n&&i){var l=""+n,c=ee(s&&s[l]&&s[l].path?""+s[l].path+w+i:i),f="/"+l+c;return N.default(e,function(e){if(a)try{var t=require("jsonata")(a).evaluate(o);J(e,f,t)}catch(t){console.error("jsonata error",t,a),J(e,f,o)}else J(e,f,o);!function(e,t,r,n){null!=e&&e.validations&&e.validations.forEach(function(e){if(e.store===r&&(""+n).startsWith(e.path)&&e.schema){var i=Z(t,"/"+r+e.path),o=function(e,t,r){var n,i,o=new C.default({allErrors:!0}).compile(e),a=o(r);return{store:""+t+K,valid:a,value:a?null:(n=o.errors,i={},n&&n.forEach(function(e){b.default.set(i,"required"===e.keyword?je(e.instancePath+"."+e.params.missingProperty)+"/-":je(e.instancePath)+"/-",e.message)}),i)}}(e.schema,r,i);J(t,"/"+o.store+e.path,o.value)}})}(u,e,n,c)})}return e;case Pe:return xe;default:return e}}}),ke={deletePersistDataStore:function(e,t,r,n){try{return n.reduxStore.dispatch({type:Pe,payload:null}),Promise.resolve(n.callFunction("reloadApp",{})).then(function(){})}catch(e){return Promise.reject(e)}}};e.I18n=function(e){var t=this,r=e.language,n=void 0===r?"en":r,i=e.resources,o=e.nonExistsHandler,a=e.keyPrefix,s=void 0===a?"{{":a,u=e.keyPostfix,l=void 0===u?"}}":u;this.language=void 0,this.languages=void 0,this.resources=void 0,this.keyPrefix=void 0,this.keyPostfix=void 0,this.nonExistsHandler=void 0,this.availableLanguageKey=void 0,this.getLocales=function(){return(t.language.includes("-")?t.language.split("-"):t.language.split("_")||[])[0]},this.t=function(e,r,n){if(!t.resources||!t.resources&&!t.language&&!n||!t.resources[""+(t.availableLanguageKey||n)])return e;var i=t.resources[""+(t.availableLanguageKey||n)].translation[e];return i?r?D.default(i,r,[t.keyPrefix,t.keyPostfix]):i:(t.nonExistsHandler&&"function"==typeof t.nonExistsHandler&&t.nonExistsHandler(e),e)},this.language=n,this.nonExistsHandler=o,this.keyPrefix=s,this.keyPostfix=l,(new C.default).compile(de)(i)&&(this.resources=i),this.languages=Object.keys(i),this.languages&&this.languages.includes(this.language)?this.availableLanguageKey=this.language:this.languages&&this.languages.includes(this.getLocales())&&(this.availableLanguageKey=this.getLocales())},e.PathModifierContext=ve,e.Stock=function(e,t,r){var n=this;this.stock=void 0,this.Wrapper=void 0,this.reduxStore=void 0,this.validations=void 0,this.init=function(e){var t=e.functions;n.stock.components=W({},n.stock.components,e.components),n.stock.functions=W({},n.stock.functions,t)},this.registerComponent=function(e,t){e&&"string"==typeof e&&e.length>0&&!(e in n.stock.components)&&(n.stock.components[e]=t)},this.registerFunction=function(e,t){e&&"string"==typeof e&&e.length>0&&!(e in n.stock.functions)&&(n.stock.functions[e]=t)},this.callFunction=function(e,t,r,i){return t&&e&&e in n.stock.functions?n.stock.functions[e](t,r,i,n):null},this.getComponent=function(e){return e&&e in n.stock.components?n.stock.components[e]:n.stock.components._Undefined},this.stock={components:{},functions:{}},this.Wrapper=t,this.validations=[],this.reduxStore=r,this.init(e)},e.StockContext=pe,e.appRootFunctions=ke,e.constants=z,e.genAllStateProps=function(e,t){var r=t.currentPaths,n={},i=[],o=F(t,ge);return x.default(o).forEach(function(e){!e||!e.$modifier||"get"!==e.$modifier||this.path.length>1&&this.path.includes(V)||i.push({path:this.path,level:this.level})}),j.default(i,["level"],["desc"]).forEach(function(i){try{var o=x.default(t).get(i.path),a=o[H],s=F(o,[H].map(M));if("get"===a&&s.store&&s.path){var u=ye(e,s,r);if(s.jsonataDef)try{u=require("jsonata")(s.jsonataDef).evaluate(u)}catch(e){console.error("jsonata error",e,s.jsonataDef)}n[X(i.path)]=u}return Promise.resolve()}catch(e){return Promise.reject(e)}}),n},e.jsonRefResolver=he,e.persistConfig=_e,e.stockFunctions=Ee,e.storeReducers=be,e.util=re,e.wrapperUtil=le});
|
|
2
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/utils/constants.ts","../src/utils/util.ts","../src/wrapper/wrapperUtil.tsx","../src/utils/jsonRefResolver.ts","../src/utils/I18n.ts","../src/utils/contextHandler.ts","../src/store/root/selectors.ts","../src/store/root/actions.ts","../src/stock/functions.ts","../src/store/persistConfig.ts","../src/stock/validation.ts","../src/store/root/reducer.ts","../src/store/reducers.ts","../src/stock/appRootFunctions.ts","../src/stock/Stock.ts"],"sourcesContent":["export const SEPARATOR = '/'\nexport const STORE_ERROR_POSTFIX = '.error'\n\nexport const PATH_MODIFIERS_KEY = '$pathModifiers'\nexport const MODIFIER_KEY = '$modifier'\nexport const ACTION_KEY = '$action'\nexport const PERSIST_STORAGE_KEY = '$persistStores'\nexport const PERSIST_STORAGE_NAMES = ['data']\nexport const REF_ASSETS = '$assetsRef'\nexport const REF_LOCALES = '$locales'\nexport const REF_VALIDATES = '$validations'\nexport const STYLE_WEB_NAME = 'styleWeb'\nexport const STYLE_RN_NAME = 'styleRN'\nexport const REDUX_FUNCTIONS = ['set', 'get']\n\nexport const PATHNAME = 'path'\nexport const SIMPLE_DATA_TYPES = ['string', 'number', 'boolean', 'null']\nexport const V_CHILDREN_NAME = '$children'\nexport const V_COMP_NAME = '$comp'\nexport const ITEM_OF_ARRAY = 'item'\nexport const PAGINATION_ITEM_PER_PAGE = 1\n","import jsonpointer from 'jsonpointer'\nimport cloneDeep from 'lodash/cloneDeep'\nimport drop from 'lodash/drop'\nimport findIndex from 'lodash/findIndex'\nimport pull from 'lodash/pull'\nimport compact from 'lodash/compact'\nimport findLastIndex from 'lodash/findLastIndex'\nimport unset from 'lodash/unset'\nimport * as c from './constants'\nimport { PropsType } from './types'\n\nexport const jsonPointerGet = (json: any, path?: string) => {\n if (json === null || json === undefined || path === null || path === undefined || typeof path !== 'string') return null\n if (path === c.SEPARATOR /* || path === '' same effect */) return json\n try {\n return jsonpointer.get(json, path.startsWith(c.SEPARATOR) ? path : `${c.SEPARATOR}${path}`)\n } catch (e) {\n return null\n }\n}\n\nexport const jsonPointerSet = (json: any, path?: string, value?: any) => {\n if (json === null || json === undefined || path === null || path === undefined || typeof path !== 'string') return\n if (path === c.SEPARATOR || path === '') {\n // eslint-disable-next-line no-param-reassign\n json = value\n return\n }\n try {\n jsonpointer.set(json, path.startsWith(c.SEPARATOR) ? path : `${c.SEPARATOR}${path}`, value)\n // eslint-disable-next-line no-empty\n } catch (e) {}\n}\n\nexport const getCleanedTopic = (text: string | any) => {\n if (!text || typeof text !== 'string' || text.length === 0 || text.length > 1024) {\n return null\n }\n return text.replace(/[^0-9a-zA-Z]/g, '-')\n}\n\nexport const pathArrayToPathString = (array: string[]) => array.map((i, index) => (Number.isInteger(i) ? `[${i}]` : `${index > 0 ? '.' : ''}${i}`)).join('')\n\nexport const pathArrayToJsonPointer = (array: string[]) => `/${array.join('/')}`\n\n/**\n * Simple object check.\n * @param item\n * @returns {boolean}\n */\nexport function isObject(item: any) {\n return item && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport function mergeDeep(target: any, ...sources: any): any {\n if (!sources.length) return target\n const source = sources.shift()\n\n if (isObject(target) && isObject(source)) {\n // eslint-disable-next-line no-restricted-syntax\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} })\n mergeDeep(target[key], source[key])\n } else {\n Object.assign(target, { [key]: source[key] })\n }\n }\n }\n\n return mergeDeep(target, ...sources)\n}\n\nexport const mergePath = (target: any, newState: any) => {\n if (!newState || typeof newState !== 'object') return target\n const newTarget = cloneDeep(target)\n Object.entries(newState).forEach(([key, value]) => {\n jsonpointer.set(newTarget, key, value)\n })\n return newTarget\n}\n\n// eslint-disable-next-line import/prefer-default-export\nexport const changeRelativePath = (path: string) => {\n let pathArray = path.split(c.SEPARATOR)\n if (pathArray && pathArray.length > 1 && pathArray[pathArray.length - 1] === '') {\n pathArray.pop()\n }\n const absolutepathIndex = findLastIndex(pathArray, (i) => i === '')\n if (absolutepathIndex > 0) {\n pathArray = drop(pathArray, absolutepathIndex)\n }\n pathArray = pull(pathArray, '.')\n let count = 0\n let relativepathIndex = -1\n do {\n count += 1\n relativepathIndex = findIndex(pathArray, (i) => i === '..')\n if (relativepathIndex !== -1) {\n unset(pathArray, `[${relativepathIndex}]`)\n unset(pathArray, `[${relativepathIndex - 1}]`)\n pathArray = compact(pathArray)\n }\n } while (relativepathIndex !== -1 && count < 100)\n return pathArray.join(c.SEPARATOR)\n}\n\n// changeRelativePath('111/22222/3333/./anything/../../start')\n\nconst genStyle = (props: PropsType) => {\n const { parentComp } = props\n const style = { display: 'flex', flexDirection: 'column', ...(props.style as any), ...(props[c.STYLE_WEB_NAME] as any) }\n\n if (style && style.borderWidth && !style.borderStyle) {\n style.borderStyle = 'solid'\n }\n if (style && style.flex) {\n if (\n parentComp &&\n (parentComp as any).style &&\n (parentComp as any).style.flex &&\n (parentComp as any).style.flex < 1\n // if smaller or larger, noesn't matter\n ) {\n style.height = `100%`\n style.width = `100%`\n } else if (!style.height) {\n style.height = `${style.flex * 100}%`\n }\n }\n return style\n}\nexport const getStyleForWeb = (props: PropsType = {}, component: string) =>\n component === 'View' ? genStyle(props) : { ...(props.style as any), ...(props[c.STYLE_WEB_NAME] as any) }\n\n// TODO it have to be configurable\nexport const noChildren = (component: string) => ['Image'].includes(component)\n\nexport const isNumber = (a: any) => typeof a === 'number'\n","import React from 'react'\nimport orderBy from 'lodash/orderBy'\nimport traverse from 'traverse'\nimport * as c from 'utils/constants'\nimport * as util from 'utils/util'\nimport Stock from 'stock/Stock'\nimport { PathModifiersType, PathModifierType, PathsType, PropsType, WrapperType } from '../utils/types'\n\nexport const actionBuilder = (props: PropsType, stock: InstanceType<typeof Stock>) => {\n const paths: PathsType = []\n const { parentComp, ...propsNew } = props\n // eslint-disable-next-line func-names\n traverse(propsNew).forEach(function (x) {\n if (\n !!x &&\n !!x[c.ACTION_KEY] &&\n // && !c.REDUX_FUNCTIONS.includes(x[c.ACTION_KEY])\n !(this.path.length > 1 && this.path.includes(c.V_CHILDREN_NAME))\n ) {\n paths.push({ path: this.path, level: this.level })\n }\n })\n orderBy(paths, ['level'], ['desc']).forEach(async (i) => {\n const { [c.ACTION_KEY]: functionName, ...functionParams } = traverse(props).get(i.path)\n traverse(props).set(i.path, async (...callerArgs: any[]) => {\n await stock.callFunction(functionName, functionParams, props, callerArgs)\n })\n })\n}\n\nexport const modifierBuilder = (props: PropsType, stock: InstanceType<typeof Stock>) => {\n const paths: PathsType = []\n const { parentComp, ...propsNew } = props\n // eslint-disable-next-line func-names\n traverse(propsNew).forEach(function (x) {\n if (!!x && !!x[c.MODIFIER_KEY] && !c.REDUX_FUNCTIONS.includes(x[c.MODIFIER_KEY]) && !(this.path.length > 1 && this.path.includes(c.V_CHILDREN_NAME))) {\n paths.push({ path: this.path, level: this.level })\n }\n })\n orderBy(paths, ['level'], ['desc']).forEach(async (i) => {\n const { [c.MODIFIER_KEY]: functionName, ...functionParams } = traverse(props).get(i.path)\n traverse(props).set(i.path, stock.callFunction(functionName, functionParams, props))\n })\n}\n\nexport const pathModifierBuilder = (props: PropsType, pathModifier: PathModifiersType) => {\n const currentPaths: PathModifiersType = { ...(props.currentPaths as PathModifiersType) }\n let modified = false\n if (pathModifier && Object.keys(pathModifier).length !== 0) {\n Object.keys(pathModifier).forEach((key: string) => {\n if (!!key && !!pathModifier[key] && pathModifier[key][c.PATHNAME] !== undefined && pathModifier[key][c.PATHNAME] !== null) {\n const path = pathModifier[key][c.PATHNAME]\n const parent = currentPaths[key]\n modified = true\n if (`${path}`.startsWith(c.SEPARATOR) || !(parent && parent[c.PATHNAME])) {\n currentPaths[key] = { [c.PATHNAME]: path }\n } else {\n currentPaths[key] = { [c.PATHNAME]: util.changeRelativePath(`${parent[c.PATHNAME]}${c.SEPARATOR}${path}`) }\n }\n if (!!currentPaths[key] && !`${currentPaths[key][c.PATHNAME]}`.startsWith(c.SEPARATOR)) {\n currentPaths[key][c.PATHNAME] = `${c.SEPARATOR}${currentPaths[key][c.PATHNAME]}`\n }\n }\n })\n }\n return modified ? { currentPaths } : undefined\n}\n\nexport const getWrapperProps = (props: PropsType, parentComp?: any) => {\n const res: PropsType = {\n ...(c.SIMPLE_DATA_TYPES.includes(typeof props) ? {} : props),\n parentComp,\n [c.V_COMP_NAME]: c.SIMPLE_DATA_TYPES.includes(typeof props) || props === undefined || props === null ? '_PrimitiveProp' : props[c.V_COMP_NAME],\n [c.V_CHILDREN_NAME]: c.SIMPLE_DATA_TYPES.includes(typeof props) || props === undefined || props === null ? props : props[c.V_CHILDREN_NAME],\n }\n // eslint-disable-next-line no-restricted-syntax\n for (const i in res) if (typeof res[i] === 'undefined') delete res[i]\n return res\n}\n\nconst genChildenFromListItem = (props: PropsType) => {\n let { page = 0, listLength = 0, itemPerPage = c.PAGINATION_ITEM_PER_PAGE } = props as { page?: number; listLength?: number; itemPerPage?: number }\n const { listItem } = props\n const pathModifiers: PathModifiersType = props[c.PATH_MODIFIERS_KEY] as PathModifiersType\n const children: PropsType[] = []\n if (util.isNumber(page) && util.isNumber(listLength) && util.isNumber(itemPerPage) && pathModifiers) {\n page = page >= 0 ? page : 0\n itemPerPage = itemPerPage >= 0 ? itemPerPage : 0\n listLength = listLength >= 0 ? listLength : 0\n const offset = page * itemPerPage <= listLength ? page * itemPerPage : 0\n const itemkey: string = Object.keys(pathModifiers)[0]\n const firstItem: PathModifierType = pathModifiers[itemkey]\n // eslint-disable-next-line no-plusplus\n for (let i = offset; i < listLength && i < offset + itemPerPage; i++) {\n children.push({\n ...(listItem as PropsType),\n [c.PATH_MODIFIERS_KEY]: {\n ...(pathModifiers as PathModifiersType),\n [Object.keys(pathModifiers)[0]]: {\n ...(firstItem as PathModifierType),\n path: i,\n },\n } as PathModifiersType,\n })\n }\n }\n return children\n}\n\nexport const getRootWrapperProps = (props: PropsType, stock: InstanceType<typeof Stock>) => {\n const newProps = {\n ...props,\n // if the children generation move to wrapper, the redux genAllStateProps doesn't wortk properly. why?\n }\n modifierBuilder(newProps, stock)\n actionBuilder(newProps, stock)\n if (newProps.isList) {\n newProps[c.V_CHILDREN_NAME] = genChildenFromListItem(newProps)\n }\n\n return newProps\n}\n\nexport const getChildrensForRoot = (props: PropsType, children: any, Wrapper: WrapperType) => {\n const { parentComp, [c.V_CHILDREN_NAME]: _notused, ...newParentComp } = props\n // eslint-disable-next-line no-nested-ternary\n return !!props && Array.isArray(children) ? (\n children.map((childrenItem, index) => {\n // eslint-disable-next-line react/no-array-index-key\n return <Wrapper key={index} {...getWrapperProps(childrenItem, newParentComp)} />\n })\n ) : (\n <Wrapper {...getWrapperProps(children, newParentComp)} />\n )\n}\n\nexport const generateChildren = (props: PropsType, { Wrapper }: InstanceType<typeof Stock>) =>\n props[c.V_COMP_NAME] !== '_PrimitiveProp' ? getChildrensForRoot(props, props[c.V_CHILDREN_NAME], Wrapper as WrapperType) : props[c.V_CHILDREN_NAME]\n","import traverse from 'traverse'\nimport uniq from 'lodash/uniq'\nimport compact from 'lodash/compact'\nimport unset from 'lodash/unset'\nimport findIndex from 'lodash/findIndex'\nimport pull from 'lodash/pull'\nimport defaultsDeep from 'lodash/defaultsDeep'\nimport * as c from './constants'\n\nexport const collectJsonKeys = (refConst: string, json: any) => {\n const refs: any[] = []\n // eslint-disable-next-line func-names\n traverse(json).forEach(function (x) {\n if (x && x[refConst] && !!this && !this.circular) {\n refs.push(x[refConst])\n }\n })\n const res = {}\n uniq(compact(refs)).forEach((i) => defaultsDeep(res, i))\n return res\n}\n\nconst isFullPath = (path?: string) => {\n if (!!path && typeof path === 'string') {\n const regex = /^[A-Za-z]*:\\/\\//\n return regex.test(path)\n }\n return false\n}\n\nconst isRelativePath = (path?: string) => !!path && typeof path === 'string' && !isFullPath(path) && !path.startsWith(c.SEPARATOR) // if not full and not start with /\n\nconst isRootPath = (path?: string) => !!path && typeof path === 'string' && !isFullPath(path) && path.startsWith(c.SEPARATOR) // if not full and start with /\n\nconst changeRelativePath = (path: string) => {\n let pathArray = path.split(c.SEPARATOR)\n pathArray = pull(pathArray, '.') // remove all ./\n let count = 0\n let relativepathIndex = -1\n do {\n count += 1\n relativepathIndex = findIndex(pathArray, (i) => i === '..')\n if (relativepathIndex !== -1) {\n unset(pathArray, `[${relativepathIndex}]`)\n unset(pathArray, `[${relativepathIndex - 1}]`)\n pathArray = compact(pathArray)\n }\n } while (relativepathIndex !== -1 && count < 100)\n return pathArray.join(c.SEPARATOR)\n}\n\n// TODO: just workaround, not works with http://localhost for example\nconst getRoot = (url3?: string) => {\n if (!!url3 && typeof url3 === 'string') {\n const regex = /^([A-Za-z]*:\\/\\/[^/]*)(\\/|)/\n const found = url3.match(regex)\n if (found) {\n return `${found[1]}/`\n }\n }\n return null\n}\n\n// console.error('test',isFullPath('asdasd://'))\nexport const getRefs = (refConst: string, json: any, projectPath = '') => {\n const refs: any[] = []\n // eslint-disable-next-line func-names\n traverse(json).forEach(function (x) {\n if (x && x[refConst] && !!this && !this.circular) {\n const ref = x[refConst]\n let absolutePath\n // TODO: If the projectPath is absolute, will be wrong\n if (isRootPath(ref)) {\n const root = getRoot(projectPath)\n absolutePath = changeRelativePath(`${root}${ref}`)\n } else if (isRelativePath(ref)) {\n absolutePath = changeRelativePath(`${projectPath}${ref}`)\n } else {\n absolutePath = ref\n }\n // eslint-disable-next-line no-param-reassign\n x[refConst] = absolutePath\n refs.push(absolutePath)\n }\n })\n // console.warn(refs);\n return uniq(compact(refs))\n}\n","import Ajv from 'ajv'\nimport keyValueReplace from 'key-value-replace'\n\ninterface I18nResources {\n [key: string]: {\n translation: {\n [key: string]: string\n }\n }\n}\n\ninterface I18nProps {\n language?: string\n resources?: I18nResources\n keyPrefix?: string\n keyPostfix?: string\n nonExistsHandler?: (key: string) => void\n}\nconst I18nSchema = {\n $id: 'http://example.com/schemas/schema.json',\n type: 'object',\n additionalProperties: {\n type: 'object',\n properties: {\n translation: {\n type: 'object',\n additionalProperties: {\n type: 'string',\n },\n propertyNames: {\n type: 'string',\n },\n minProperties: 1,\n },\n additionalProperties: false,\n },\n },\n propertyNames: {\n pattern: '^[A-Za-z0-9_-]*$',\n type: 'string',\n },\n minProperties: 1,\n}\n\nexport default class I18n {\n language: string\n\n languages: string[]\n\n resources?: I18nResources\n\n keyPrefix?: string\n\n keyPostfix?: string\n\n nonExistsHandler?: (key: string) => void\n\n availableLanguageKey?: string\n\n // eslint-disable-next-line consistent-this\n constructor({ language = 'en', resources, nonExistsHandler, keyPrefix = '{{', keyPostfix = '}}' }: I18nProps) {\n this.language = language\n this.nonExistsHandler = nonExistsHandler\n this.keyPrefix = keyPrefix\n this.keyPostfix = keyPostfix\n\n const ajv = new Ajv()\n const validate = ajv.compile(I18nSchema)\n const isValid = validate(resources)\n if (isValid) {\n this.resources = resources\n }\n this.languages = Object.keys(resources as any)\n if (this.languages && this.languages.includes(this.language)) {\n this.availableLanguageKey = this.language\n } else if (this.languages && this.languages.includes(this.getLocales())) {\n this.availableLanguageKey = this.getLocales()\n }\n }\n\n getLocales = () => (this.language.includes('-') ? this.language.split('-') : this.language.split('_') || [])[0]\n\n t = (key: string, options?: any, language?: string | null) => {\n if (!this.resources || (!this.resources && !this.language && !language) || !this.resources[`${this.availableLanguageKey || language}`]) {\n return key\n }\n const value = this.resources[`${this.availableLanguageKey || language}`].translation[key]\n if (!value) {\n if (this.nonExistsHandler && typeof this.nonExistsHandler === 'function') {\n this.nonExistsHandler(key)\n }\n return key\n }\n if (options) {\n return keyValueReplace(value, options, [this.keyPrefix, this.keyPostfix])\n }\n return value\n }\n}\n","import { createContext } from 'react'\nimport Stock from 'stock/Stock'\n\nexport const StockContext = createContext<typeof Stock | null>(null)\nexport const PathModifierContext = createContext({})\n","import traverse from 'traverse'\nimport orderBy from 'lodash/orderBy'\nimport * as c from '../../utils/constants'\nimport * as util from '../../utils/util'\nimport { PathModifiersType, PathType, PropsType } from '../../utils/types'\nimport { RootStateType } from './reducer'\n\nexport const getState = (state: any): RootStateType => state.root\n\nexport const getValue = (state: any, store: string, path: string) => util.jsonPointerGet(state[store], path)\n\nexport interface ReduxPathType {\n store: string\n path: string\n isError?: boolean\n}\n\nexport const getStateValue = (globalState: any, { store, path, isError = false }: ReduxPathType, currentPaths: PathModifiersType) => {\n const state = getState(globalState)\n\n if (store && path) {\n const convertedPath =\n currentPaths && currentPaths[store] && currentPaths[store].path ? util.changeRelativePath(`${currentPaths[store].path}${c.SEPARATOR}${path}`) : path\n\n return getValue(state, `${store}${isError ? c.STORE_ERROR_POSTFIX : ''}`, convertedPath)\n }\n return null\n}\n\nexport const genAllStateProps = (globalState: any, props: PropsType) => {\n const { currentPaths } = props\n const result: PropsType = {}\n const paths: PathType[] = []\n const { parentComp, ...propsNew } = props\n // eslint-disable-next-line func-names\n traverse(propsNew).forEach(function (x) {\n if (!!x && !!x[c.MODIFIER_KEY] && x[c.MODIFIER_KEY] === 'get' && !(this.path.length > 1 && this.path.includes(c.V_CHILDREN_NAME))) {\n paths.push({ path: this.path, level: this.level })\n }\n })\n orderBy(paths, ['level'], ['desc']).forEach(async (i) => {\n const { [c.MODIFIER_KEY]: functionName, ...functionParams } = traverse(props).get(i.path)\n if (functionName === 'get' && functionParams.store && functionParams.path) {\n let value = getStateValue(globalState, functionParams, currentPaths as PathModifiersType)\n if (functionParams.jsonataDef) {\n try {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsonata = require('jsonata')\n const expression = jsonata(functionParams.jsonataDef)\n value = expression.evaluate(value)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('jsonata error', error, functionParams.jsonataDef)\n }\n }\n // traverse(result).set(i.path, value)\n result[util.pathArrayToJsonPointer(i.path)] = value\n }\n })\n return result\n}\n","export const DATA_UPDATE = 'DATA_UPDATE'\nexport const PURGE = 'PURGE'\n\nexport const set = (payload: any) => ({\n type: DATA_UPDATE,\n payload,\n})\n\nexport const purge = (payload: any) => ({\n type: PURGE,\n payload,\n})\n","import { getStateValue as getStateValueSelector } from '../store/root/selectors'\nimport { set as setAction } from '../store/root/actions'\nimport { JsonUIFunctionType } from './appRootFunctions'\nimport { PathModifiersType } from '../utils/types'\n\nconst getStateValue: JsonUIFunctionType = (attr, { currentPaths } = {}, callerArgs, stock) => {\n const { store, path } = attr\n const state = stock.reduxStore.getState()\n return getStateValueSelector(state, { store, path }, currentPaths as PathModifiersType)\n}\nconst get: JsonUIFunctionType = (attr, { currentPaths } = {}, callerArgs, stock) => {\n const { store, path } = attr\n const state = stock.reduxStore.getState()\n return getStateValueSelector(state, { store, path }, currentPaths as PathModifiersType)\n}\nconst set: JsonUIFunctionType = (attr, props, callerArgs, stock) => {\n stock.reduxStore.dispatch(\n setAction({ ...attr, value: attr && attr.value !== undefined ? attr.value : callerArgs[0], currentPaths: props.currentPaths, stock })\n )\n}\nexport default {\n getStateValue,\n get,\n set,\n}\n","import { createTransform } from 'redux-persist'\nimport pick from 'lodash/pick'\nimport * as c from '../utils/constants'\n\nconst SetTransform = createTransform(\n (inboundState, key) => {\n if (key !== 'root') return inboundState\n return pick(inboundState, c.PERSIST_STORAGE_NAMES)\n },\n (outboundState, key) => {\n if (key !== 'root') return outboundState\n return pick(outboundState, c.PERSIST_STORAGE_NAMES)\n }\n)\n\nexport default {\n key: 'main',\n whitelist: ['root'],\n transforms: [SetTransform],\n}\n","import Ajv, { ErrorObject, JSONSchemaType } from 'ajv'\nimport jsonpointer from 'jsonpointer'\nimport * as c from '../utils/constants'\n\nconst pathConverter = (path: string) => path.replace(/\\./g, c.SEPARATOR)\n\nexport const errorConverter = (errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined) => {\n const res = {}\n if (errors) {\n errors.forEach((i) => {\n if (i.keyword === 'required') {\n jsonpointer.set(res, `${pathConverter(`${i.instancePath}.${i.params.missingProperty}`)}/-`, i.message)\n } else {\n jsonpointer.set(res, `${pathConverter(i.instancePath)}/-`, i.message)\n }\n })\n }\n return res\n}\n\nexport const validateJSON = (schema: any, store: string, data: any) => {\n const ajv = new Ajv({ allErrors: true })\n const validate = ajv.compile(schema as JSONSchemaType<any>)\n const valid = validate(data)\n return {\n store: `${store}${c.STORE_ERROR_POSTFIX}`,\n valid,\n value: valid ? null : errorConverter(validate.errors),\n }\n}\n","import produce from 'immer'\nimport { AnyAction } from 'redux'\nimport { ValidationType } from '../../utils/types'\nimport * as c from '../../utils/constants'\nimport * as util from '../../utils/util'\nimport { validateJSON } from '../../stock/validation'\nimport { DATA_UPDATE, PURGE } from './actions'\nimport Stock from '../../stock/Stock'\n\nexport type RootStateType = any\n\nconst initialState: RootStateType = {\n data: {},\n}\nconst validateNewState = (stock: InstanceType<typeof Stock>, newState: RootStateType, actionStore: string, actionPath: string) => {\n if (stock?.validations) {\n stock.validations.forEach((validateItem: ValidationType) => {\n if (validateItem.store === actionStore && `${actionPath}`.startsWith(validateItem.path)) {\n if (validateItem.schema) {\n const stateToBeValidated = util.jsonPointerGet(newState, `${c.SEPARATOR}${actionStore}${validateItem.path}`)\n const errors = validateJSON(validateItem.schema, actionStore, stateToBeValidated)\n // console.log('matched validator', `${c.SEPARATOR}${errors.store}${validateItem.path}`, errors)\n util.jsonPointerSet(newState, `${c.SEPARATOR}${errors.store}${validateItem.path}`, errors.value)\n }\n }\n })\n }\n}\nconst reducer = (state = initialState, action: AnyAction) => {\n switch (action.type) {\n case DATA_UPDATE: {\n const { store, path, value, jsonataDef, currentPaths, stock } = action.payload\n if (store && path) {\n const storekey = `${store}`\n const convertedPath =\n currentPaths && currentPaths[storekey] && currentPaths[storekey].path\n ? util.changeRelativePath(`${currentPaths[storekey].path}${c.SEPARATOR}${path}`)\n : util.changeRelativePath(path)\n const absolutePathWithStoreKey = `${c.SEPARATOR}${storekey}${convertedPath}`\n const newState = produce(state, (draft: RootStateType) => {\n if (jsonataDef) {\n try {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsonata = require('jsonata')\n const expression = jsonata(jsonataDef)\n const newValue = expression.evaluate(value)\n util.jsonPointerSet(draft, absolutePathWithStoreKey, newValue)\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('jsonata error', error, jsonataDef)\n util.jsonPointerSet(draft, absolutePathWithStoreKey, value)\n }\n } else {\n util.jsonPointerSet(draft, absolutePathWithStoreKey, value)\n }\n // if validatior has match, need to validate it synchronously\n validateNewState(stock, draft, store, convertedPath)\n })\n return newState\n }\n return state\n }\n case PURGE: {\n return initialState\n }\n default:\n return state\n }\n}\n\nexport default reducer\n","import { combineReducers } from 'redux'\nimport root from './root/reducer'\n\nconst rootReducer = combineReducers({ root })\n\nexport default rootReducer\n","import { purge } from '../store/root/actions'\n\nexport type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any\n\nexport interface JsonUIFunctions {\n [key: string]: JsonUIFunctionType\n}\nexport const deletePersistDataStore: JsonUIFunctionType = async (attr, props, callerArgs, stock) => {\n stock.reduxStore.dispatch(purge(null))\n await stock.callFunction('reloadApp', {})\n}\n\nconst appRootFunctions: JsonUIFunctions = { deletePersistDataStore }\n\nexport default appRootFunctions\n","import React from 'react'\nimport { JsonUIFunctions, JsonUIFunctionType } from './appRootFunctions'\n\ninterface JsonUIComponentsType {\n [key: string]: React.ReactNode\n}\n\ninterface NewStockType {\n components: JsonUIComponentsType\n functions: JsonUIFunctions\n}\n\ntype InitType = (prop: NewStockType) => void\ntype RegisterFunctionType = (key: string, value: JsonUIFunctionType) => void\ntype RegisterComponentType = (key: string, value: React.ReactNode) => void\ntype CallFunctionType = (name: string, attr?: any, props?: any, callerArgs?: any) => void\ntype GetComponentType = (componentName: string) => React.ReactNode\n\nexport default class Stock {\n stock: NewStockType\n\n Wrapper: React.ReactNode\n\n reduxStore: any\n\n validations: any\n\n constructor(newStock: NewStockType, Wrapper: React.ReactNode, reduxStore: any) {\n this.stock = {\n components: {} as JsonUIComponentsType,\n functions: {} as JsonUIFunctions,\n }\n this.Wrapper = Wrapper\n this.validations = []\n this.reduxStore = reduxStore\n this.init(newStock)\n }\n\n init: InitType = ({ components, functions }) => {\n this.stock.components = {\n ...this.stock.components,\n ...components,\n }\n this.stock.functions = {\n ...this.stock.functions,\n ...functions,\n }\n }\n\n registerComponent: RegisterComponentType = (key, value) => {\n if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.components)) {\n this.stock.components[key] = value\n }\n }\n\n registerFunction: RegisterFunctionType = (key, value) => {\n if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.functions)) {\n this.stock.functions[key] = value\n }\n }\n\n callFunction: CallFunctionType = (name, attr, props, callerArgs) => {\n if (!!attr && !!name && name in this.stock.functions) {\n const result = this.stock.functions[name](attr, props, callerArgs, this)\n return result\n }\n return null\n }\n\n getComponent: GetComponentType = (componentName) =>\n !!componentName && componentName in this.stock.components\n ? this.stock.components[componentName]\n : // eslint-disable-next-line no-underscore-dangle\n this.stock.components._Undefined\n}\n"],"names":["SEPARATOR","STORE_ERROR_POSTFIX","MODIFIER_KEY","ACTION_KEY","PERSIST_STORAGE_NAMES","REDUX_FUNCTIONS","SIMPLE_DATA_TYPES","V_CHILDREN_NAME","jsonPointerGet","json","path","c","jsonpointer","get","startsWith","e","jsonPointerSet","value","set","pathArrayToJsonPointer","array","join","isObject","item","Array","isArray","changeRelativePath","pathArray","split","length","pop","absolutepathIndex","findLastIndex","i","drop","pull","count","relativepathIndex","findIndex","unset","compact","isNumber","a","text","replace","map","index","Number","isInteger","mergeDeep","target","sources","source","shift","key","Object","assign","newState","newTarget","cloneDeep","entries","forEach","props","component","parentComp","style","display","flexDirection","borderWidth","borderStyle","flex","height","width","genStyle","includes","actionBuilder","stock","paths","propsNew","traverse","x","this","push","level","orderBy","functionName","functionParams","callFunction","modifierBuilder","getWrapperProps","res","getChildrensForRoot","children","Wrapper","newParentComp","childrenItem","React","pathModifier","currentPaths","modified","keys","parent","util","undefined","newProps","isList","page","listLength","itemPerPage","listItem","pathModifiers","offset","firstItem","genChildenFromListItem","isFullPath","test","refConst","refs","circular","uniq","defaultsDeep","projectPath","absolutePath","ref","root","url3","found","match","getRoot","isRelativePath","I18nSchema","$id","type","additionalProperties","properties","translation","propertyNames","minProperties","pattern","StockContext","createContext","PathModifierContext","getStateValue","globalState","store","isError","state","getState","convertedPath","getValue","DATA_UPDATE","PURGE","attr","callerArgs","reduxStore","getStateValueSelector","payload","dispatch","whitelist","transforms","createTransform","inboundState","pick","outboundState","pathConverter","initialState","data","rootReducer","combineReducers","action","jsonataDef","storekey","absolutePathWithStoreKey","produce","draft","newValue","require","jsonata","evaluate","error","console","actionStore","actionPath","validations","validateItem","schema","stateToBeValidated","errors","validate","Ajv","allErrors","compile","valid","keyword","instancePath","params","missingProperty","message","validateJSON","validateNewState","appRootFunctions","deletePersistDataStore","language","resources","nonExistsHandler","keyPrefix","keyPostfix","languages","availableLanguageKey","getLocales","_this","t","options","keyValueReplace","newStock","init","functions","components","registerComponent","registerFunction","name","getComponent","componentName","_Undefined","result"],"mappings":"wsEAAaA,EA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AWK,GAEtBZ,EAAKtI,MAAM6I,WAAWM,YA7C1B9I,KAAKL,MAAQ,CACX6I,WAAY,GACZD,UAAW,IAEbvI,KAAKY,QAAUA,EACfZ,KAAKsG,YAAc,GACnBtG,KAAKyE,WAAaA,EAClBzE,KAAKsI,KAAKD,6ERNkB,SAACvE,EAAkBjF,GACjD,IAAQoC,EAAiBpC,EAAjBoC,aACF8H,EAAoB,GACpBnJ,EAAoB,GACHC,IAAahB,MA0BpC,OAxBAiB,UAASD,GAAUjB,QAAQ,SAAUmB,IAC7BA,IAAOA,EAAC,WAA0C,QAAtBA,EAAC,WAAgCC,KAAKvE,KAAKmB,OAAS,GAAKoD,KAAKvE,KAAKgE,SAAS/D,IAC5GkE,EAAMK,KAAK,CAAExE,KAAMuE,KAAKvE,KAAMyE,MAAOF,KAAKE,UAG9CC,UAAQP,EAAO,CAAC,SAAU,CAAC,SAAShB,iBAAe5B,OACjD,MAA8D8C,UAASjB,GAAOjD,IAAIoB,EAAEvB,MAA1D2E,IAAjB1E,GAAkC2E,OAAlC3E,WACT,GAAqB,QAAjB0E,GAA0BC,EAAe0D,OAAS1D,EAAe5E,KAAM,CACzE,IAAIO,EAAQ6H,GAAcC,EAAazD,EAAgBY,GACvD,GAAIZ,EAAeoF,WACjB,IAIEzJ,EAFgB+J,QAAQ,UACLC,CAAQ3F,EAAeoF,YACvBQ,SAASjK,GAC5B,MAAOkK,GAEPC,QAAQD,MAAM,gBAAiBA,EAAO7F,EAAeoF,YAIzDsD,EAAO1H,EAA4BrE,EAAEvB,OAASO,2BAhBlD,qCAmBO+M"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const SET_RENDERER: "SET_RENDERER";
|
|
2
|
-
export const DELETE_RENDERER: "DELETE_RENDERER";
|
|
3
|
-
export function setRenderer(payload: any): {
|
|
4
|
-
type: string;
|
|
5
|
-
payload: any;
|
|
6
|
-
};
|
|
7
|
-
export function deleteRenderer(payload: any): {
|
|
8
|
-
type: string;
|
|
9
|
-
payload: any;
|
|
10
|
-
};
|
package/dist/util/util.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { PropsType } from './types';
|
|
2
|
-
export declare const jsonPointerGet: (json: any, path?: string | undefined) => any;
|
|
3
|
-
export declare const jsonPointerSet: (json: any, path?: string | undefined, value?: any) => void;
|
|
4
|
-
export declare const getCleanedTopic: (text: string | any) => string | null;
|
|
5
|
-
export declare const pathArrayToPathString: (array: string[]) => string;
|
|
6
|
-
export declare const pathArrayToJsonPointer: (array: string[]) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Simple object check.
|
|
9
|
-
* @param item
|
|
10
|
-
* @returns {boolean}
|
|
11
|
-
*/
|
|
12
|
-
export declare function isObject(item: any): any;
|
|
13
|
-
/**
|
|
14
|
-
* Deep merge two objects.
|
|
15
|
-
* @param target
|
|
16
|
-
* @param ...sources
|
|
17
|
-
*/
|
|
18
|
-
export declare function mergeDeep(target: any, ...sources: any): any;
|
|
19
|
-
export declare const mergePath: (target: any, newState: any) => any;
|
|
20
|
-
export declare const changeRelativePath: (path: string) => string;
|
|
21
|
-
export declare const getStyleForWeb: (props: PropsType | undefined, component: string) => any;
|
|
22
|
-
export declare const noChildren: (component: string) => boolean;
|
package/dist/utils/util.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PropsType } from './types';
|
|
2
|
-
export declare const jsonPointerGet: (json: any, path?: string | undefined) => any;
|
|
3
|
-
export declare const jsonPointerSet: (json: any, path?: string | undefined, value?: any) => void;
|
|
4
|
-
export declare const getCleanedTopic: (text: string | any) => string | null;
|
|
5
|
-
export declare const pathArrayToPathString: (array: string[]) => string;
|
|
6
|
-
export declare const pathArrayToJsonPointer: (array: string[]) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Simple object check.
|
|
9
|
-
* @param item
|
|
10
|
-
* @returns {boolean}
|
|
11
|
-
*/
|
|
12
|
-
export declare function isObject(item: any): any;
|
|
13
|
-
/**
|
|
14
|
-
* Deep merge two objects.
|
|
15
|
-
* @param target
|
|
16
|
-
* @param ...sources
|
|
17
|
-
*/
|
|
18
|
-
export declare function mergeDeep(target: any, ...sources: any): any;
|
|
19
|
-
export declare const mergePath: (target: any, newState: any) => any;
|
|
20
|
-
export declare const changeRelativePath: (path: string) => string;
|
|
21
|
-
export declare const getStyleForWeb: (props: PropsType | undefined, component: string) => any;
|
|
22
|
-
export declare const noChildren: (component: string) => boolean;
|
|
23
|
-
export declare const isNumber: (a: any) => boolean;
|
package/src/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Stock from './stock/Stock'
|
|
2
|
-
import * as wrapperUtil from './wrapper/wrapperUtil'
|
|
3
|
-
import * as constants from './utils/constants'
|
|
4
|
-
import * as jsonRefResolver from './utils/jsonRefResolver'
|
|
5
|
-
import * as util from './utils/util'
|
|
6
|
-
import I18n from './utils/I18n'
|
|
7
|
-
import { StockContext, PathModifierContext } from './utils/contextHandler'
|
|
8
|
-
import { genAllStateProps } from './store/root/selectors'
|
|
9
|
-
import stockFunctions from './stock/functions'
|
|
10
|
-
import persistConfig from './store/persistConfig'
|
|
11
|
-
import storeReducers from './store/reducers'
|
|
12
|
-
import appRootFunctions from './stock/appRootFunctions'
|
|
13
|
-
|
|
14
|
-
export * from './utils/types'
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
Stock,
|
|
18
|
-
I18n,
|
|
19
|
-
wrapperUtil,
|
|
20
|
-
util,
|
|
21
|
-
constants,
|
|
22
|
-
jsonRefResolver,
|
|
23
|
-
StockContext,
|
|
24
|
-
PathModifierContext,
|
|
25
|
-
appRootFunctions,
|
|
26
|
-
genAllStateProps,
|
|
27
|
-
stockFunctions,
|
|
28
|
-
persistConfig,
|
|
29
|
-
storeReducers,
|
|
30
|
-
}
|
package/src/stock/Stock.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { JsonUIFunctions, JsonUIFunctionType } from './appRootFunctions'
|
|
3
|
-
|
|
4
|
-
interface JsonUIComponentsType {
|
|
5
|
-
[key: string]: React.ReactNode
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface NewStockType {
|
|
9
|
-
components: JsonUIComponentsType
|
|
10
|
-
functions: JsonUIFunctions
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type InitType = (prop: NewStockType) => void
|
|
14
|
-
type RegisterFunctionType = (key: string, value: JsonUIFunctionType) => void
|
|
15
|
-
type RegisterComponentType = (key: string, value: React.ReactNode) => void
|
|
16
|
-
type CallFunctionType = (name: string, attr?: any, props?: any, callerArgs?: any) => void
|
|
17
|
-
type GetComponentType = (componentName: string) => React.ReactNode
|
|
18
|
-
|
|
19
|
-
export default class Stock {
|
|
20
|
-
stock: NewStockType
|
|
21
|
-
|
|
22
|
-
Wrapper: React.ReactNode
|
|
23
|
-
|
|
24
|
-
reduxStore: any
|
|
25
|
-
|
|
26
|
-
validations: any
|
|
27
|
-
|
|
28
|
-
constructor(newStock: NewStockType, Wrapper: React.ReactNode, reduxStore: any) {
|
|
29
|
-
this.stock = {
|
|
30
|
-
components: {} as JsonUIComponentsType,
|
|
31
|
-
functions: {} as JsonUIFunctions,
|
|
32
|
-
}
|
|
33
|
-
this.Wrapper = Wrapper
|
|
34
|
-
this.validations = []
|
|
35
|
-
this.reduxStore = reduxStore
|
|
36
|
-
this.init(newStock)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
init: InitType = ({ components, functions }) => {
|
|
40
|
-
this.stock.components = {
|
|
41
|
-
...this.stock.components,
|
|
42
|
-
...components,
|
|
43
|
-
}
|
|
44
|
-
this.stock.functions = {
|
|
45
|
-
...this.stock.functions,
|
|
46
|
-
...functions,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
registerComponent: RegisterComponentType = (key, value) => {
|
|
51
|
-
if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.components)) {
|
|
52
|
-
this.stock.components[key] = value
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
registerFunction: RegisterFunctionType = (key, value) => {
|
|
57
|
-
if (!!key && typeof key === 'string' && key.length > 0 && !(key in this.stock.functions)) {
|
|
58
|
-
this.stock.functions[key] = value
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
callFunction: CallFunctionType = (name, attr, props, callerArgs) => {
|
|
63
|
-
if (!!attr && !!name && name in this.stock.functions) {
|
|
64
|
-
const result = this.stock.functions[name](attr, props, callerArgs, this)
|
|
65
|
-
return result
|
|
66
|
-
}
|
|
67
|
-
return null
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getComponent: GetComponentType = (componentName) =>
|
|
71
|
-
!!componentName && componentName in this.stock.components
|
|
72
|
-
? this.stock.components[componentName]
|
|
73
|
-
: // eslint-disable-next-line no-underscore-dangle
|
|
74
|
-
this.stock.components._Undefined
|
|
75
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { purge } from '../store/root/actions'
|
|
2
|
-
|
|
3
|
-
export type JsonUIFunctionType = (attr: any, props: any, callerArgs: any, stock: any) => Promise<void> | void | any
|
|
4
|
-
|
|
5
|
-
export interface JsonUIFunctions {
|
|
6
|
-
[key: string]: JsonUIFunctionType
|
|
7
|
-
}
|
|
8
|
-
export const deletePersistDataStore: JsonUIFunctionType = async (attr, props, callerArgs, stock) => {
|
|
9
|
-
stock.reduxStore.dispatch(purge(null))
|
|
10
|
-
await stock.callFunction('reloadApp', {})
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const appRootFunctions: JsonUIFunctions = { deletePersistDataStore }
|
|
14
|
-
|
|
15
|
-
export default appRootFunctions
|
package/src/stock/functions.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getStateValue as getStateValueSelector } from '../store/root/selectors'
|
|
2
|
-
import { set as setAction } from '../store/root/actions'
|
|
3
|
-
import { JsonUIFunctionType } from './appRootFunctions'
|
|
4
|
-
import { PathModifiersType } from '../utils/types'
|
|
5
|
-
|
|
6
|
-
const getStateValue: JsonUIFunctionType = (attr, { currentPaths } = {}, callerArgs, stock) => {
|
|
7
|
-
const { store, path } = attr
|
|
8
|
-
const state = stock.reduxStore.getState()
|
|
9
|
-
return getStateValueSelector(state, { store, path }, currentPaths as PathModifiersType)
|
|
10
|
-
}
|
|
11
|
-
const get: JsonUIFunctionType = (attr, { currentPaths } = {}, callerArgs, stock) => {
|
|
12
|
-
const { store, path } = attr
|
|
13
|
-
const state = stock.reduxStore.getState()
|
|
14
|
-
return getStateValueSelector(state, { store, path }, currentPaths as PathModifiersType)
|
|
15
|
-
}
|
|
16
|
-
const set: JsonUIFunctionType = (attr, props, callerArgs, stock) => {
|
|
17
|
-
stock.reduxStore.dispatch(
|
|
18
|
-
setAction({ ...attr, value: attr && attr.value !== undefined ? attr.value : callerArgs[0], currentPaths: props.currentPaths, stock })
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
export default {
|
|
22
|
-
getStateValue,
|
|
23
|
-
get,
|
|
24
|
-
set,
|
|
25
|
-
}
|
package/src/stock/validation.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Ajv, { ErrorObject, JSONSchemaType } from 'ajv'
|
|
2
|
-
import jsonpointer from 'jsonpointer'
|
|
3
|
-
import * as c from '../utils/constants'
|
|
4
|
-
|
|
5
|
-
const pathConverter = (path: string) => path.replace(/\./g, c.SEPARATOR)
|
|
6
|
-
|
|
7
|
-
export const errorConverter = (errors: ErrorObject<string, Record<string, any>, unknown>[] | null | undefined) => {
|
|
8
|
-
const res = {}
|
|
9
|
-
if (errors) {
|
|
10
|
-
errors.forEach((i) => {
|
|
11
|
-
if (i.keyword === 'required') {
|
|
12
|
-
jsonpointer.set(res, `${pathConverter(`${i.instancePath}.${i.params.missingProperty}`)}/-`, i.message)
|
|
13
|
-
} else {
|
|
14
|
-
jsonpointer.set(res, `${pathConverter(i.instancePath)}/-`, i.message)
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
return res
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const validateJSON = (schema: any, store: string, data: any) => {
|
|
22
|
-
const ajv = new Ajv({ allErrors: true })
|
|
23
|
-
const validate = ajv.compile(schema as JSONSchemaType<any>)
|
|
24
|
-
const valid = validate(data)
|
|
25
|
-
return {
|
|
26
|
-
store: `${store}${c.STORE_ERROR_POSTFIX}`,
|
|
27
|
-
valid,
|
|
28
|
-
value: valid ? null : errorConverter(validate.errors),
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createTransform } from 'redux-persist'
|
|
2
|
-
import pick from 'lodash/pick'
|
|
3
|
-
import * as c from '../utils/constants'
|
|
4
|
-
|
|
5
|
-
const SetTransform = createTransform(
|
|
6
|
-
(inboundState, key) => {
|
|
7
|
-
if (key !== 'root') return inboundState
|
|
8
|
-
return pick(inboundState, c.PERSIST_STORAGE_NAMES)
|
|
9
|
-
},
|
|
10
|
-
(outboundState, key) => {
|
|
11
|
-
if (key !== 'root') return outboundState
|
|
12
|
-
return pick(outboundState, c.PERSIST_STORAGE_NAMES)
|
|
13
|
-
}
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
key: 'main',
|
|
18
|
-
whitelist: ['root'],
|
|
19
|
-
transforms: [SetTransform],
|
|
20
|
-
}
|
package/src/store/reducers.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import produce from 'immer'
|
|
2
|
-
import { AnyAction } from 'redux'
|
|
3
|
-
import { ValidationType } from '../../utils/types'
|
|
4
|
-
import * as c from '../../utils/constants'
|
|
5
|
-
import * as util from '../../utils/util'
|
|
6
|
-
import { validateJSON } from '../../stock/validation'
|
|
7
|
-
import { DATA_UPDATE, PURGE } from './actions'
|
|
8
|
-
import Stock from '../../stock/Stock'
|
|
9
|
-
|
|
10
|
-
export type RootStateType = any
|
|
11
|
-
|
|
12
|
-
const initialState: RootStateType = {
|
|
13
|
-
data: {},
|
|
14
|
-
}
|
|
15
|
-
const validateNewState = (stock: InstanceType<typeof Stock>, newState: RootStateType, actionStore: string, actionPath: string) => {
|
|
16
|
-
if (stock?.validations) {
|
|
17
|
-
stock.validations.forEach((validateItem: ValidationType) => {
|
|
18
|
-
if (validateItem.store === actionStore && `${actionPath}`.startsWith(validateItem.path)) {
|
|
19
|
-
if (validateItem.schema) {
|
|
20
|
-
const stateToBeValidated = util.jsonPointerGet(newState, `${c.SEPARATOR}${actionStore}${validateItem.path}`)
|
|
21
|
-
const errors = validateJSON(validateItem.schema, actionStore, stateToBeValidated)
|
|
22
|
-
// console.log('matched validator', `${c.SEPARATOR}${errors.store}${validateItem.path}`, errors)
|
|
23
|
-
util.jsonPointerSet(newState, `${c.SEPARATOR}${errors.store}${validateItem.path}`, errors.value)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const reducer = (state = initialState, action: AnyAction) => {
|
|
30
|
-
switch (action.type) {
|
|
31
|
-
case DATA_UPDATE: {
|
|
32
|
-
const { store, path, value, jsonataDef, currentPaths, stock } = action.payload
|
|
33
|
-
if (store && path) {
|
|
34
|
-
const storekey = `${store}`
|
|
35
|
-
const convertedPath =
|
|
36
|
-
currentPaths && currentPaths[storekey] && currentPaths[storekey].path
|
|
37
|
-
? util.changeRelativePath(`${currentPaths[storekey].path}${c.SEPARATOR}${path}`)
|
|
38
|
-
: util.changeRelativePath(path)
|
|
39
|
-
const absolutePathWithStoreKey = `${c.SEPARATOR}${storekey}${convertedPath}`
|
|
40
|
-
const newState = produce(state, (draft: RootStateType) => {
|
|
41
|
-
if (jsonataDef) {
|
|
42
|
-
try {
|
|
43
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
44
|
-
const jsonata = require('jsonata')
|
|
45
|
-
const expression = jsonata(jsonataDef)
|
|
46
|
-
const newValue = expression.evaluate(value)
|
|
47
|
-
util.jsonPointerSet(draft, absolutePathWithStoreKey, newValue)
|
|
48
|
-
} catch (error) {
|
|
49
|
-
// eslint-disable-next-line no-console
|
|
50
|
-
console.error('jsonata error', error, jsonataDef)
|
|
51
|
-
util.jsonPointerSet(draft, absolutePathWithStoreKey, value)
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
util.jsonPointerSet(draft, absolutePathWithStoreKey, value)
|
|
55
|
-
}
|
|
56
|
-
// if validatior has match, need to validate it synchronously
|
|
57
|
-
validateNewState(stock, draft, store, convertedPath)
|
|
58
|
-
})
|
|
59
|
-
return newState
|
|
60
|
-
}
|
|
61
|
-
return state
|
|
62
|
-
}
|
|
63
|
-
case PURGE: {
|
|
64
|
-
return initialState
|
|
65
|
-
}
|
|
66
|
-
default:
|
|
67
|
-
return state
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default reducer
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import traverse from 'traverse'
|
|
2
|
-
import orderBy from 'lodash/orderBy'
|
|
3
|
-
import * as c from '../../utils/constants'
|
|
4
|
-
import * as util from '../../utils/util'
|
|
5
|
-
import { PathModifiersType, PathType, PropsType } from '../../utils/types'
|
|
6
|
-
import { RootStateType } from './reducer'
|
|
7
|
-
|
|
8
|
-
export const getState = (state: any): RootStateType => state.root
|
|
9
|
-
|
|
10
|
-
export const getValue = (state: any, store: string, path: string) => util.jsonPointerGet(state[store], path)
|
|
11
|
-
|
|
12
|
-
export interface ReduxPathType {
|
|
13
|
-
store: string
|
|
14
|
-
path: string
|
|
15
|
-
isError?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const getStateValue = (globalState: any, { store, path, isError = false }: ReduxPathType, currentPaths: PathModifiersType) => {
|
|
19
|
-
const state = getState(globalState)
|
|
20
|
-
|
|
21
|
-
if (store && path) {
|
|
22
|
-
const convertedPath =
|
|
23
|
-
currentPaths && currentPaths[store] && currentPaths[store].path ? util.changeRelativePath(`${currentPaths[store].path}${c.SEPARATOR}${path}`) : path
|
|
24
|
-
|
|
25
|
-
return getValue(state, `${store}${isError ? c.STORE_ERROR_POSTFIX : ''}`, convertedPath)
|
|
26
|
-
}
|
|
27
|
-
return null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const genAllStateProps = (globalState: any, props: PropsType) => {
|
|
31
|
-
const { currentPaths } = props
|
|
32
|
-
const result: PropsType = {}
|
|
33
|
-
const paths: PathType[] = []
|
|
34
|
-
const { parentComp, ...propsNew } = props
|
|
35
|
-
// eslint-disable-next-line func-names
|
|
36
|
-
traverse(propsNew).forEach(function (x) {
|
|
37
|
-
if (!!x && !!x[c.MODIFIER_KEY] && x[c.MODIFIER_KEY] === 'get' && !(this.path.length > 1 && this.path.includes(c.V_CHILDREN_NAME))) {
|
|
38
|
-
paths.push({ path: this.path, level: this.level })
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
orderBy(paths, ['level'], ['desc']).forEach(async (i) => {
|
|
42
|
-
const { [c.MODIFIER_KEY]: functionName, ...functionParams } = traverse(props).get(i.path)
|
|
43
|
-
if (functionName === 'get' && functionParams.store && functionParams.path) {
|
|
44
|
-
let value = getStateValue(globalState, functionParams, currentPaths as PathModifiersType)
|
|
45
|
-
if (functionParams.jsonataDef) {
|
|
46
|
-
try {
|
|
47
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
48
|
-
const jsonata = require('jsonata')
|
|
49
|
-
const expression = jsonata(functionParams.jsonataDef)
|
|
50
|
-
value = expression.evaluate(value)
|
|
51
|
-
} catch (error) {
|
|
52
|
-
// eslint-disable-next-line no-console
|
|
53
|
-
console.error('jsonata error', error, functionParams.jsonataDef)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// traverse(result).set(i.path, value)
|
|
57
|
-
result[util.pathArrayToJsonPointer(i.path)] = value
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
return result
|
|
61
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface KeyValues {
|
|
2
|
-
[key: string]: string | number | null | undefined | boolean
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
declare module 'key-value-replace' {
|
|
6
|
-
function functionProps(str: string, obj: KeyValues, delimiter?: [prefix?: string, postfix?: string]): string
|
|
7
|
-
export default functionProps
|
|
8
|
-
}
|