@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.
@@ -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])=>{if(e)try{e=JSON.stringify(e)}catch(t){e=e.toString()}return{fieldName:t,value: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)}))}))}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!) {
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-fe95f2c4",[[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)));
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)));
@@ -7,5 +7,6 @@ export default class DataUnitFetcher {
7
7
  private loadMetadata;
8
8
  private loadData;
9
9
  private saveData;
10
+ private formatValueToServer;
10
11
  private removeRecords;
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",