@gudhub/core 1.1.48 → 1.1.49

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.
@@ -16,6 +16,7 @@ export class DocumentManager {
16
16
  }
17
17
 
18
18
  createDocument(documentObject) {
19
+ this.emitDocumentInsert(documentObject);
19
20
  return this.req.post({
20
21
  url: "/api/new/document/insert-one",
21
22
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
@@ -24,7 +25,7 @@ export class DocumentManager {
24
25
  }
25
26
 
26
27
  emitDocumentInsert(data) {
27
- this.pipeService.emit("gh_document_insert_one", { app_id: data.app_id, item_id: data.item_id, element_id: data.element_id });
28
+ this.pipeService.emit("gh_document_insert_one", { app_id: data.app_id, item_id: data.item_id, element_id: data.element_id }, JSON.parse(data.data));
28
29
  }
29
30
 
30
31
  getDocument(documentAddress) {
@@ -171,8 +171,8 @@ export class Utils {
171
171
  return this.ItemsSelection.isItemSelected(appId, itemId);
172
172
  }
173
173
 
174
- jsonConstructor(scheme, item, variables){
175
- return compiler(scheme, item, this, variables)
174
+ jsonConstructor(scheme, item, variables, appId){
175
+ return compiler(scheme, item, this, variables, appId)
176
176
  }
177
177
 
178
178
  fileInstallerHelper(appId, items, elementId) {
@@ -1,15 +1,15 @@
1
1
 
2
- export function compiler(scheme, item, util, variables) {
3
- async function schemeCompiler(scheme, item, app) {
2
+ export function compiler(scheme, item, util, variables, appId) {
3
+ async function schemeCompiler(scheme, item, appId) {
4
4
  let value = null;
5
5
  if (scheme.type === "array") {
6
6
  // get properties value for array childs for each application item
7
7
  if (Number(scheme.is_static)) {
8
8
  value = new Array(
9
- await getChildsPropertiesObject(scheme.childs, item, app)
9
+ await getChildsPropertiesObject(scheme.childs, item, appId)
10
10
  );
11
11
  } else {
12
- value = await getArrayOfItemsWithProperties(scheme, item, app);
12
+ value = await getArrayOfItemsWithProperties(scheme, item, appId);
13
13
  }
14
14
  }
15
15
 
@@ -18,12 +18,12 @@ export function compiler(scheme, item, util, variables) {
18
18
  if (Number(scheme.current_item)) {
19
19
  value = await getItemWithProperties(scheme, item);
20
20
  } else {
21
- value = await getChildsPropertiesObject(scheme.childs, item, app);
21
+ value = await getChildsPropertiesObject(scheme.childs, item, appId);
22
22
  }
23
23
  }
24
24
  if (scheme.type === "property") {
25
25
  // get properties value
26
- value = await getFieldValue(scheme, item, app);
26
+ value = await getFieldValue(scheme, item, appId);
27
27
  }
28
28
 
29
29
  return { [scheme.property_name]: value };
@@ -69,7 +69,7 @@ export function compiler(scheme, item, util, variables) {
69
69
  }
70
70
 
71
71
  const arrayOfItemsWithProperties = filteredItems.map(async (item) => {
72
- return getChildsPropertiesObject(scheme.childs, item, app);
72
+ return getChildsPropertiesObject(scheme.childs, item, app.app_id);
73
73
  });
74
74
  return Promise.all(arrayOfItemsWithProperties);
75
75
  }
@@ -78,13 +78,13 @@ export function compiler(scheme, item, util, variables) {
78
78
  const app = await util.gudhub.getApp(scheme.app_id);
79
79
  const items = app.items_list || [];
80
80
 
81
- return getChildsPropertiesObject(scheme.childs, item || items[0], app);
81
+ return getChildsPropertiesObject(scheme.childs, item || items[0], app.app_id);
82
82
  }
83
83
 
84
84
  /* Get properties value for object childs in scheme. */
85
- async function getChildsPropertiesObject(properties, item, app) {
85
+ async function getChildsPropertiesObject(properties, item, appId) {
86
86
  const propertiesArray = await properties.map(async (child) => {
87
- return schemeCompiler(child, item, app);
87
+ return schemeCompiler(child, item, appId);
88
88
  });
89
89
  const resolvedPropertiesArray = await Promise.all(propertiesArray);
90
90
  return resolvedPropertiesArray.reduce((acc, object) => {
@@ -93,20 +93,20 @@ export function compiler(scheme, item, util, variables) {
93
93
  }
94
94
 
95
95
  /* Get property value based on interpretation value */
96
- async function getFieldValue(scheme, item, app) {
96
+ async function getFieldValue(scheme, item, appId) {
97
97
  switch (scheme.property_type) {
98
98
  case "static":
99
99
  return scheme.static_field_value;
100
100
  case "variable":
101
101
  switch (scheme.variable_type) {
102
102
  case "app_id":
103
- return app.app_id;
103
+ return appId;
104
104
  // case "user_id":
105
105
  // resolve(storage.getUser().user_id);
106
106
  // break;
107
107
  case "current_item":
108
108
  default:
109
- return `${app.app_id}.${item.item_id}`;
109
+ return `${appId}.${item.item_id}`;
110
110
  }
111
111
 
112
112
  case "field_id":
@@ -114,21 +114,21 @@ export function compiler(scheme, item, util, variables) {
114
114
 
115
115
  case "function":
116
116
  if(typeof scheme.function === 'function') {
117
- let result = scheme.function(item, app, ...scheme.args);
117
+ let result = scheme.function(item, appId, ...scheme.args);
118
118
  return result;
119
119
  } else {
120
- const func = new Function('item, app', 'return (async ' + scheme.function + ')(item, app)');
121
- let result = await func(item, app);
120
+ const func = new Function('item, appId', 'return (async ' + scheme.function + ')(item, appId)');
121
+ let result = await func(item, appId);
122
122
  return result;
123
123
  }
124
124
 
125
125
  case "field_value":
126
126
  default:
127
127
  if (Boolean(Number(scheme.interpretation))) {
128
- let interpretatedValue = await util.gudhub.getInterpretationById(Number(app.app_id), Number(item.item_id), Number(scheme.field_id), 'value');
128
+ let interpretatedValue = await util.gudhub.getInterpretationById(Number(appId), Number(item.item_id), Number(scheme.field_id), 'value');
129
129
  return interpretatedValue;
130
130
  } else {
131
- let value = await util.gudhub.getFieldValue(Number(app.app_id), Number(item.item_id), Number(scheme.field_id))
131
+ let value = await util.gudhub.getFieldValue(Number(appId), Number(item.item_id), Number(scheme.field_id))
132
132
  return value;
133
133
  }
134
134
  }
@@ -149,17 +149,17 @@ export function compiler(scheme, item, util, variables) {
149
149
  async function filterItems(
150
150
  filtersList = [],
151
151
  itemsList = [],
152
- app = {},
152
+ appId = '',
153
153
  item = {}
154
154
  ) {
155
155
  return filtersList.length ? getFilteredItems(
156
156
  filtersList,
157
- app.app_id,
158
- app.app_id,
157
+ appId,
158
+ appId,
159
159
  item.item_id,
160
160
  itemsList
161
161
  ) : [...itemsList ];
162
162
  }
163
163
 
164
- return schemeCompiler(scheme, item);
164
+ return schemeCompiler(scheme, item, appId);
165
165
  }
package/GUDHUB/gudhub.js CHANGED
@@ -254,8 +254,8 @@ export class GudHub {
254
254
  return this.util.makeNestedList(arr, id, parent_id, children_property, priority_property);
255
255
  }
256
256
 
257
- jsonConstructor(scheme, items, variables){
258
- return this.util.jsonConstructor(scheme, items, variables)
257
+ jsonConstructor(scheme, items, variables, appId){
258
+ return this.util.jsonConstructor(scheme, items, variables, appId)
259
259
  }
260
260
 
261
261
  //************************* APP PROCESSOR ****************************//
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {