@sankhyalabs/sankhyablocks 1.1.22 → 1.1.23
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/dist/cjs/snk-application.cjs.entry.js +1197 -1190
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +16 -9
- package/dist/components/snk-application.js +1197 -1190
- package/dist/esm/snk-application.entry.js +1197 -1190
- package/dist/sankhyablocks/{p-fe95f2c4.entry.js → p-f3bdd8c3.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -0
- package/package.json +1 -1
|
@@ -45,7 +45,7 @@ import{r as t,c as e,h as n}from"./p-5fa264b9.js";class i{constructor(t){this._m
|
|
|
45
45
|
value
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
}`)}getDataUnit(t,e){const n=new F(`dd://${t}/${e}`);return n.metadataLoader=t=>this.loadMetadata(t),n.dataLoader=(t,e,n)=>this.loadData(t,e,n),n.saveLoader=(t,e)=>this.saveData(t,e),n.removeLoader=(t,e)=>this.removeRecords(t,e),n}loadMetadata(t){return new Promise(((e,n)=>{mt.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var n;const i={name:t.name,label:t.name,fields:[]};null===(n=t.fields)||void 0===n||n.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.properties.forEach((t=>e[t.name]=t.value))),i.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(i)})).catch((t=>{n(t)}))}))}loadData(t,e,n){return new Promise(((i,r)=>{mt.get().callGraphQL({values:{dataunit:t.name,sort:e,filters:n},query:this.templateByQuery.get("fetchData")}).then((e=>{const n=[];e.data.records.forEach((e=>{const i={__record__id__:e.id};e.fields.forEach((({name:e,value:n})=>{i[e]=t.valueFromString(e,n)})),n.push(i)})),i(n)})).catch((t=>{r(t)}))}))}saveData(t,e){const n=e.map((t=>{const{dataUnit:e,record:n,updatingFields:i,operation:r}=t;return{dataUnit:e,updatingFields:Object.entries(i).map((([t,e])=>
|
|
48
|
+
}`)}getDataUnit(t,e){const n=new F(`dd://${t}/${e}`);return n.metadataLoader=t=>this.loadMetadata(t),n.dataLoader=(t,e,n)=>this.loadData(t,e,n),n.saveLoader=(t,e)=>this.saveData(t,e),n.removeLoader=(t,e)=>this.removeRecords(t,e),n}loadMetadata(t){return new Promise(((e,n)=>{mt.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var n;const i={name:t.name,label:t.name,fields:[]};null===(n=t.fields)||void 0===n||n.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.properties.forEach((t=>e[t.name]=t.value))),i.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),e(i)})).catch((t=>{n(t)}))}))}loadData(t,e,n){return new Promise(((i,r)=>{mt.get().callGraphQL({values:{dataunit:t.name,sort:e,filters:n},query:this.templateByQuery.get("fetchData")}).then((e=>{const n=[];e.data.records.forEach((e=>{const i={__record__id__:e.id};e.fields.forEach((({name:e,value:n})=>{i[e]=t.valueFromString(e,n)})),n.push(i)})),i(n)})).catch((t=>{r(t)}))}))}saveData(t,e){const n=e.map((t=>{const{dataUnit:e,record:n,updatingFields:i,operation:r}=t;return{dataUnit:e,updatingFields:Object.entries(i).map((([t,e])=>({fieldName:t,value:this.formatValueToServer(e)}))),operation:r,recordId:n.__record__id__}}));return new Promise(((e,i)=>{mt.get().callGraphQL({values:{changes:n},query:this.templateByQuery.get("saveData")}).then((n=>{const i=[];null==n||n.forEach((e=>{const n={__record__id__:e.id};e.oldId&&(n.__old__id__=e.oldId),e.fields.forEach((({name:e,value:i})=>{n[e]=t.valueFromString(e,i)})),i.push(n)})),e(i)})).catch((t=>{i(t)}))}))}formatValueToServer(t){if(void 0===t)return t;try{if(t instanceof Date)return t.toString();t=JSON.stringify(t)}catch(e){t=t.toString()}return t}removeRecords(t,e){const n=e.map((e=>({dataUnit:t.name,operation:A.DELETE,recordId:e})));return new Promise(((t,i)=>{mt.get().callGraphQL({values:{changes:n},query:this.templateByQuery.get("saveData")}).then((()=>{t(e)})).catch((t=>{i(t)}))}))}}class wt{static openAppActivity(t,e){var n;null===(n=window.workspace)||void 0===n||n.openAppActivity(t,e)}}wt.resourceID=window.workspace.resourceID;class gt{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchParam",pt.gql`query($name: String!) {
|
|
49
49
|
$queryAlias$: fetchResource(name: $name){
|
|
50
50
|
name
|
|
51
51
|
resource
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as a,b as t}from"./p-5fa264b9.js";(()=>{const t=import.meta.url,r={};return""!==t&&(r.resourcesUrl=new URL(".",t).href),a(r)})().then((a=>t([["p-
|
|
1
|
+
import{p as a,b as t}from"./p-5fa264b9.js";(()=>{const t=import.meta.url,r={};return""!==t&&(r.resourcesUrl=new URL(".",t).href),a(r)})().then((a=>t([["p-f3bdd8c3",[[2,"snk-application",{getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],temOpcional:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getResourceID:[64],alert:[64],error:[64],confirm:[64],info:[64],loadFormConfig:[64]}]]]],a)));
|