biz9-logic 2.0.7 → 3.0.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/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='2.0.7'
1
+ VERSION='3.0.1'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -5,58 +5,48 @@ License GNU General Public License v3.0
5
5
  Description: BiZ9 Framework: Logic-JS
6
6
  */
7
7
  const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main,get_title_url_main } = require('./main');
8
- const { get_biz9_config }= require('biz9-scriptz');
9
- const biz9_config_file = get_biz9_config();
10
- class Item {
11
- static get_new = (data_type,id) => {
8
+ class Logic {
9
+ static get_new_item = (data_type,id) => {
12
10
  return get_new_item_main(data_type,id);
13
11
  };
14
- static get_biz = (biz9_config,item,options)=>{
12
+ static get_biz_item = (biz9_config,item,options)=>{
15
13
  return get_biz_item_main(biz9_config,item,options);
16
14
  }
17
- }
18
- class Cloud {
19
- static get_url = (action_url)=>{
20
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
15
+ static get_url = (biz9_config,action_url,params)=>{
16
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,params);
21
17
  }
22
- static get_url_action_connect = () => {
18
+ static get_url_action_connect = (biz9_config) => {
23
19
  let action_url= "main/test/connect/";
24
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
20
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
25
21
  };
26
- static get_url_action_update_item = (data_type,id) => {
22
+ static get_url_action_update_item = (biz9_config,data_type,id) => {
27
23
  let action_url= "main/crud/update/"+data_type + "/" + id;
28
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
24
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
29
25
  };
30
- static get_url_action_get_item = (data_type,id) => {
26
+ static get_url_action_get_item = (biz9_config,data_type,id) => {
31
27
  let action_url= "main/crud/get/"+data_type + "/" + id;
32
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
28
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
33
29
  };
34
- static get_url_action_delete_item = (data_type,id) => {
30
+ static get_url_action_delete_item = (biz9_config,data_type,id) => {
35
31
  let action_url= "main/crud/delete/"+data_type + "/" + id;
36
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
32
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
37
33
  };
38
- static get_url_action_get_list = (data_type) => {
34
+ static get_url_action_get_list = (biz9_config,data_type) => {
39
35
  let action_url= "main/crud/get_list/"+data_type;
40
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
36
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
41
37
  };
42
- static get_url_action_delete_list = (data_type) => {
38
+ static get_url_action_delete_list = (biz9_config,data_type) => {
43
39
  let action_url= "main/crud/delete_list/"+data_type;
44
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
40
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
45
41
  };
46
- static get_url_action_update_list = (data_type) => {
42
+ static get_url_action_update_list = (biz9_config,data_type) => {
47
43
  let action_url= "main/crud/update_list/"+data_type;
48
- return get_cloud_url_main(biz9_config_file.APP_TITLE_ID,biz9_config_file.CLOUD_URL,biz9_config_file.CLOUD_PORT_ID,action_url);
44
+ return get_cloud_url_main(biz9_config.APP_TITLE_ID,biz9_config.URL,action_url,null);
49
45
  };
50
- static get_filter_obj = (data_type,filter,sort_by,page_current,page_size)=>{
46
+ static get_filter_obj = (biz9_config,data_type,filter,sort_by,page_current,page_size)=>{
51
47
  return get_cloud_filter_obj_main(data_type,filter,sort_by,page_current,page_size);
52
48
  }
53
- }
54
- const get_data_config = (biz9_config,query) => {
55
- return get_data_config_main(biz9_config,query);
56
49
  };
57
50
  module.exports = {
58
- biz9_config_file,
59
- Cloud,
60
- Item,
61
- get_data_config,
51
+ Logic
62
52
  };
package/main.js CHANGED
@@ -7,6 +7,8 @@ Description: BiZ9 Framework: Logic - Main
7
7
 
8
8
  const moment = require('moment');
9
9
  const { DateTime } = require('biz9-utility');
10
+ const fs = require('fs');
11
+ const biz9_config_local=__dirname+"/../../"+"biz9_config";
10
12
 
11
13
  const get_cloud_filter_obj_main = (data_type,filter,sort_by,page_current,page_size) => {
12
14
  return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
@@ -18,15 +20,12 @@ const get_new_item_main = (data_type,id) => {
18
20
  }
19
21
  return {data_type:data_type,id:id};
20
22
  }
21
- const get_cloud_url_main = (app_title_id,domain_url,port_id,action_url) =>{
22
- var app_title_id_url='?app_title_id='+app_title_id;
23
- return domain_url+":"+port_id+"/"+action_url+app_title_id_url;
24
- }
25
- const get_data_config_main = (biz9_config,query) =>{
26
- if(biz9_config.SERVICE_HOST_TYPE == 'multiple'){
27
- biz9_config.APP_TITLE_ID=query.app_title_id;
23
+ const get_cloud_url_main = (app_title_id,domain_url,action_url,params) =>{
24
+ if(!params){
25
+ params='';
28
26
  }
29
- return biz9_config;
27
+ var app_title_id_url='?app_title_id='+app_title_id;
28
+ return domain_url+"/"+action_url+app_title_id_url + params;
30
29
  }
31
30
  const get_biz_item_main=(biz9_config,item,options) =>{
32
31
  //option
@@ -120,7 +119,6 @@ module.exports = {
120
119
  get_new_item_main,
121
120
  get_cloud_url_main,
122
121
  get_cloud_filter_obj_main,
123
- get_data_config_main,
124
122
  get_title_url_main,
125
123
  get_biz_item_main
126
124
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "2.0.7",
3
+ "version": "3.0.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -9,11 +9,9 @@
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
11
  "async-series": "^0.0.1",
12
- "biz9-scriptz": "^5.2.19",
13
- "biz9-utility": "^2.0.14",
14
- "i": "^0.3.7",
15
- "jest": "^29.7.0",
16
- "npm": "^11.1.0"
12
+ "biz9-scriptz": "^5.5.3",
13
+ "biz9-utility": "^2.0.24",
14
+ "jest": "^29.7.0"
17
15
  },
18
16
  "repository": {
19
17
  "type": "git",
package/test.js CHANGED
@@ -1,7 +1,8 @@
1
+ const path = require('path');
1
2
  const series = require('async-series');
3
+ const {Logic} = require('./');
2
4
  const {Log,Test} = require('biz9-utility');
3
- const { Item, Cloud }= require('./');
4
- const { get_biz9_config }= require('biz9-scriptz');
5
+ const { Scriptz }= require('biz9-scriptz');
5
6
 
6
7
  /* --- TEST CONFIG START --- */
7
8
  //const ID='0';
@@ -9,7 +10,7 @@ const ID='f23c2372-df8e-4c09-a919-677fe32ba0bb';
9
10
  const APP_TITLE_ID='cool_bean';
10
11
  const DATA_TYPE='dt_blank';
11
12
  const PORT_ID="1901";
12
- const CLOUD_URL="http://localhost:"+PORT_ID;
13
+ const URL="http://localhost:"+PORT_ID;
13
14
  const biz9_config ={
14
15
  SERVICE_HOST_TYPE:'multiple',
15
16
  APP_TITLE_ID:APP_TITLE_ID,
@@ -25,81 +26,93 @@ const biz9_config ={
25
26
  };
26
27
  /* --- TEST DATA CONFIG END --- */
27
28
 
28
-
29
29
  describe("connect", () => {
30
30
  it("_connect", () => {
31
31
  series([
32
32
  function(call) {
33
33
  console.log('GET-BIZ9-CONFIG-FILE-START');
34
- let biz9_config = get_biz9_config();
35
- console.log(biz9_config);
34
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
35
+ Log.w('APP_TITLE_ID',biz9_config.APP_TITLE_ID);
36
+ Log.w('APP_TITLE',biz9_config.TITLE);
37
+ Log.w('URL',biz9_config.URL);
36
38
  console.log('GET-BIZ9-CONFIG-FILE-SUCCESS');
37
39
  call()
38
40
  },
41
+ function(call) {
42
+ console.log('GET-URL-START');
43
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
44
+ let action_url = 'test_get_url_action';
45
+ let params = '&myparam1=p1&myparam2=p2'
46
+ let cloud_url = Logic.get_url(biz9_config,action_url,params);
47
+ Log.w('connect_url',cloud_url);
48
+ console.log('GET-URL-SUCCESS');
49
+ call()
50
+ },
39
51
  function(call) {
40
52
  console.log('CONNECT-START');
41
- let cloud_url = Cloud.get_url_action_connect();
53
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
54
+ let cloud_url = Logic.get_url_action_connect(biz9_config);
42
55
  Log.w('connect_url',cloud_url);
43
56
  console.log('CONNECT-SUCCESS');
44
57
  call()
45
58
  },
46
59
  function(call) {
47
60
  console.log('GET_URL-ACTION-UPDATE-ITEM-START');
61
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
48
62
  let data_type = 'dt_blank';
49
63
  let id = 0;
50
- let cloud_url = Cloud.get_url_action_update_item(data_type,id);
64
+ let cloud_url = Logic.get_url_action_update_item(biz9_config,data_type,id);
51
65
  Log.w('get_url_action_update_item',cloud_url);
52
66
  console.log('GET_URL-ACTION-UPDATE-ITEM-SUCCESS');
53
67
  call()
54
68
  },
55
-
56
69
  function(call) {
57
70
  console.log('GET_URL-ACTION-GET-ITEM-START');
71
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
58
72
  let data_type = 'dt_blank';
59
73
  let id = 0;
60
- let cloud_url = Cloud.get_url_action_get_item(data_type,id);
74
+ let cloud_url = Logic.get_url_action_get_item(biz9_config,data_type,id);
61
75
  Log.w('get_url_action_get_item',cloud_url);
62
76
  console.log('GET_URL-ACTION-GET-ITEM-SUCCESS');
63
77
  call()
64
78
  },
65
-
66
79
  function(call) {
67
80
  console.log('GET_URL-ACTION-DELETE-ITEM-START');
81
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
68
82
  let data_type = 'dt_blank';
69
83
  let id = 0;
70
- let cloud_url = Cloud.get_url_action_delete_item(data_type,id);
84
+ let cloud_url = Logic.get_url_action_delete_item(biz9_config,data_type,id);
71
85
  Log.w('get_url_action_delete_item',cloud_url);
72
86
  console.log('GET_URL-ACTION-DELETE-ITEM-SUCCESS');
73
87
  call()
74
88
  },
75
-
76
89
  function(call) {
77
90
  console.log('GET_URL-ACTION-GET-LIST-ITEM-START');
91
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
78
92
  let data_type = 'dt_blank';
79
- let cloud_url = Cloud.get_url_action_get_list(data_type);
93
+ let cloud_url = Logic.get_url_action_get_list(biz9_config,data_type);
80
94
  Log.w('get_url_action_get_list_item',cloud_url);
81
95
  console.log('GET_URL-ACTION-GET-LIST-ITEM-SUCCESS');
82
96
  call()
83
97
  },
84
-
85
98
  function(call) {
86
99
  console.log('GET_URL-ACTION-DELETE-LIST-ITEM-START');
100
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
87
101
  let data_type = 'dt_blank';
88
- let cloud_url = Cloud.get_url_action_delete_list(data_type);
102
+ let cloud_url = Logic.get_url_action_delete_list(biz9_config,data_type);
89
103
  Log.w('get_url_action_delete_list_item',cloud_url);
90
104
  console.log('GET_URL-ACTION-DELETE-LIST-ITEM-SUCCESS');
91
105
  call()
92
106
  },
93
-
94
107
  function(call) {
95
108
  console.log('GET_URL-ACTION-UPDATE-LIST-ITEM-START');
109
+ let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
96
110
  let data_type = 'dt_blank';
97
- let cloud_url = Cloud.get_url_action_delete_list(data_type);
111
+ let cloud_url = Logic.get_url_action_delete_list(biz9_config,data_type);
98
112
  Log.w('get_url_action_delete_list_item',cloud_url);
99
113
  console.log('GET_URL-ACTION-UPDATE-LIST-ITEM-SUCCESS');
100
114
  call()
101
115
  },
102
-
103
116
  function(call) {
104
117
  console.log('GET_FILTER-OBJECT-START');
105
118
  let data_type = 'dt_blank';
@@ -107,14 +120,14 @@ describe("connect", () => {
107
120
  let sort_by = {title:-1};
108
121
  let page_current = 0;
109
122
  let page_size = 15;
110
- let filter_obj = Cloud.get_filter_obj(data_type,filter,sort_by,page_current,page_size);
123
+ let filter_obj = Logic.get_filter_obj(data_type,filter,sort_by,page_current,page_size);
111
124
  Log.w('get_url_action_filter_obj',filter_obj);
112
125
  console.log('GET_FILTER-OBJECT-SUCCESS');
113
126
  call()
114
127
  },
115
128
  function(call) {
116
129
  console.log('GET-NEW-ITEM-START');
117
- var new_item = Item.get_new(DATA_TYPE,0);
130
+ var new_item = Logic.get_new_item(DATA_TYPE,0);
118
131
  console.log(new_item);
119
132
  console.log('GET-NEW-ITEM-SUCCESS');
120
133
  call()
@@ -129,7 +142,7 @@ describe("connect", () => {
129
142
  item_test.value_2 = 'my_value_2';
130
143
  item_test.field_3 = 'my_field_3';
131
144
  item_test.value_3 = 'my_value_3';
132
- let item_biz = Item.get_biz(biz9_config,item_test,{get_photo:true,get_date:true,get_count:true,get_biz_map:true});
145
+ let item_biz = Logic.get_biz_item(biz9_config,item_test,{get_photo:true,get_date:true,get_count:true,get_biz_map:true});
133
146
  console.log(item_biz);
134
147
  console.log('SET-ITEM-BIZ-SUCCESS');
135
148
  call();