biz9-logic 4.8.144 → 4.8.145

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.
Files changed (4) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +94 -139
  3. package/package.json +1 -1
  4. package/test.js +3 -0
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='6.2.4'
1
+ VERSION='6.2.5'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -45,10 +45,7 @@ class Item_Logic {
45
45
  static get_search = (data_type,filter,sort_by,page_current,page_size) => {
46
46
  return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
47
47
  }
48
- static get_note = () => {
49
- return "Note "+String(Number.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
50
- }
51
- static get_search_query(search){
48
+ static get_search_query(search){
52
49
  let url = "";
53
50
  if(search.data_type){
54
51
  url = url + "&data_type="+search.data_type;
@@ -218,92 +215,6 @@ class Page_Logic {
218
215
  return item_list;
219
216
  }
220
217
  }
221
- class Order_Logic {
222
- static get_order_id = () => {
223
- return FieldType.ORDER_ID + Number.get_id();
224
- }
225
- static get_test_order_item = (order_item_id,order_id,user_id,parent_data_type,parent_id,option) =>{
226
- option = Field_Logic.get_option(DataType.ORDER_ITEM,option?option:{generate_id:Str.check_is_null(order_item_id)? true : false });
227
- let order_item = DataItem.get_new(DataType.ORDER_ITEM,Number.get_guid(),Field_Logic.get_test("Order Item "+Number.get_id(),option));
228
- order_item.order_id = order_id;
229
- order_item.user_id = user_id;
230
- order_item.parent_data_type = parent_data_type;
231
- order_item.parent_id = parent_id;
232
- order_item.cost = Field_Logic.get_test_cost();
233
- if(option.get_order_sub_item){
234
- order_item.order_sub_item_list = [];
235
- for(let a = 0;a<option.order_sub_item_count;a++){
236
- order_item.order_sub_item_list.push(Order_Logic.get_test_order_sub_item(order_id,user_id,order_item.id,parent_data_type,parent_id,{get_value:true,get_order_sub_item:option.get_order_sub_item,order_sub_item_count:option.order_sub_item_count}));
237
- }
238
- }
239
- return order_item;
240
- };
241
- static get_test_order_sub_item = (order_id,user_id,order_item_id,parent_data_type,parent_id,option) =>{
242
- option = Field_Logic.get_option(DataType.ORDER_SUB_ITEM,option?option:{});
243
- let order_sub_item = DataItem.get_new(DataType.ORDER_SUB_ITEM,Number.get_guid(),Field_Logic.get_test("Order Sub Item "+Number.get_id(),option));
244
- order_sub_item.user_id = user_id;
245
- order_sub_item.order_id = order_id;
246
- order_sub_item.order_item_id = order_item_id;
247
- order_sub_item.parent_data_type = parent_data_type;
248
- order_sub_item.parent_id = parent_id;
249
- order_sub_item.cost = Field_Logic.get_test_cost();
250
- return order_sub_item;
251
- };
252
- static get_test_order_item = (order_id,user_id,parent_data_type,parent_id,option) =>{
253
- option = Field_Logic.get_option(DataType.ORDER_ITEM,option?option:{});
254
- let order_item = DataItem.get_new(DataType.ORDER_ITEM,Number.get_guid(),Field_Logic.get_test("Order Item "+Number.get_id(),option));
255
- order_item.order_id = order_id;
256
- order_item.user_id = user_id;
257
- order_item.parent_data_type = parent_data_type;
258
- order_item.parent_id = parent_id;
259
- order_item.cost = Field_Logic.get_test_cost();
260
- order_item.order_sub_item_list = [];
261
- if(option.get_order_sub_item){
262
- for(let a = 0;a<option.order_sub_item_count;a++){
263
- order_item.order_sub_item_list.push(Order_Logic.get_test_order_sub_item(order_id,user_id,order_item.id,parent_data_type,parent_id,{get_value:true,get_order_sub_item:option.get_order_sub_item,order_sub_item_count:option.order_sub_item_count}));
264
- }
265
- }
266
- return order_item;
267
- };
268
- static get_test_order_sub_item = (order_id,user_id,order_item_id,parent_data_type,parent_id,option) =>{
269
- option = Field_Logic.get_option(DataType.ORDER_SUB_ITEM,option?option:{});
270
- let order_sub_item = DataItem.get_new(DataType.ORDER_SUB_ITEM,Number.get_guid(),Field_Logic.get_test("Order Sub Item "+Number.get_id(),option));
271
- order_sub_item.user_id = user_id;
272
- order_sub_item.order_id = order_id;
273
- order_sub_item.order_item_id = order_item_id;
274
- order_sub_item.parent_data_type = parent_data_type;
275
- order_sub_item.parent_id = parent_id;
276
- order_sub_item.cost = Field_Logic.get_test_cost();
277
- return order_sub_item;
278
- };
279
- static get_test_list = (option) =>{
280
- option = Field_Logic.get_option(DataType.PRODUCT,option?option:{});
281
- let item_list = [];
282
- for(let a=0;a<option.product_count+1;a++){
283
- item_list.push(Product_Logic.get_test("Product "+String(parseInt(a+1)),option));
284
- }
285
- return item_list;
286
- }
287
- static get_test_list_by_category = (option) =>{
288
- option = Field_Logic.get_option(DataType.PRODUCT,option?option:{});
289
- let product_list = [];
290
- let category_list = Category_Logic.get_type_category_list(DataType.PRODUCT,option.category_count);
291
- let item_count = 0;
292
- for(let a=0;a<category_list.length;a++){
293
- for(let b=0;b<option.product_count;b++){
294
- item_count++;
295
- let product = Product_Logic.get_test("Product "+String(parseInt(b+1)),option);
296
- product.category = category_list[Number.get_id(category_list.length+1)].title;
297
- product_list.push(product);
298
- }
299
- }
300
- return [category_list,product_list]
301
- };
302
-
303
- //static get_product_order = (order,product_list,,parent_data_type,parent_id,option) =>{
304
- //return order_item;
305
- //};
306
- }
307
218
  class Cart_Logic {
308
219
  static get_cart_number = () => {
309
220
  return FieldType.CART_NUMBER + Number.get_id(99999);
@@ -517,8 +428,14 @@ class Blog_Post_Logic {
517
428
  [title,option] = Field_Logic.get_option_title(title,option);
518
429
  option = Field_Logic.get_option(DataType.BLOG_POST,option?option:{});
519
430
  let blog_post = DataItem.get_new(DataType.BLOG_POST,0,Field_Logic.get_test(title,option));
520
- blog_post.author="First Name "+ Number.get_id();
521
- blog_post.tag = "Tag "+ Number.get_id() + ", Tag "+Number.get_id() + ", Tag "+ Number.get_id();
431
+
432
+ if(!option.get_blank){
433
+ blog_post.author="First Name "+ Number.get_id();
434
+ blog_post.tag = "Tag "+ Number.get_id() + ", Tag "+Number.get_id() + ", Tag "+ Number.get_id();
435
+ }else{
436
+ blog_post.author="";
437
+ blog_post.tag = "";
438
+ }
522
439
  if(option.get_item){
523
440
  blog_post.items = Sub_Item_Logic.get_test_list(blog_post,blog_post,option);
524
441
  }
@@ -552,11 +469,8 @@ class Event_Logic {
552
469
  static get_test = (title,option) =>{
553
470
  [title,option] = Field_Logic.get_option_title(title,option);
554
471
  option = Field_Logic.get_option(DataType.EVENT,option?option:{});
555
- let event = DataItem.get_new_full_item(
556
- DataItem.get_new(DataType.EVENT,0),
557
- DataItem.get_new(DataType.EVENT,0),
558
- DataItem.get_new(DataType.EVENT,0),
559
- Field_Logic.get_test(title,option));
472
+ let event = DataItem.get_new(DataType.EVENT,0,Field_Logic.get_test(title,option));
473
+ if(!option.get_blank){
560
474
  event.cost = Field_Logic.get_test_cost();
561
475
  event.old_cost = Field_Logic.get_test_cost();
562
476
  event.date = String(String(Number.get_id(2030)) + "-" + String(Number.get_id(13)) + "-" + String(Number.get_id(30))).trim();
@@ -567,6 +481,18 @@ class Event_Logic {
567
481
  event.stock = String(Number.get_id(3-1));
568
482
  event.category ="Category " + String(Number.get_id());
569
483
  event.tag = "Tag "+ Number.get_id() + ", Tag "+Number.get_id() + ", Tag "+ Number.get_id();
484
+ }else{
485
+ event.cost = "";
486
+ event.old_cost = "";
487
+ event.date = "";
488
+ event.time = "";
489
+ event.website = "";
490
+ event.location = "";
491
+ event.meeting_link = "";
492
+ event.stock = "";
493
+ event.category ="";
494
+ event.tag = "";
495
+ }
570
496
  if(option.get_item){
571
497
  event.items = Sub_Item_Logic.get_test_list(event,event,option);
572
498
  }
@@ -597,6 +523,12 @@ class Event_Logic {
597
523
  };
598
524
  }
599
525
  class Field_Logic {
526
+ static get_test_cost(){
527
+ return String(Number.get_id(999)) + "." + String(Number.get_id(99));
528
+ }
529
+ static get_test_note = () => {
530
+ return "Note "+String(Number.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
531
+ }
600
532
  static get_test = (title,option) =>{
601
533
  option = !Obj.check_is_empty(option) ? option : {};
602
534
  let item = {};
@@ -616,7 +548,7 @@ class Field_Logic {
616
548
  setting_visible:"1",
617
549
  title_url:Str.get_title_url(title),
618
550
  sub_note:"Sub Note "+String(Number.get_id()),
619
- note:Item_Logic.get_note(),
551
+ note:Field_Logic.get_test_note(),
620
552
  view_count:0,
621
553
  id:0,
622
554
  date_create:new moment().toISOString(),
@@ -714,7 +646,6 @@ class Field_Logic {
714
646
  if(data_type==DataType.CART){
715
647
  option.category_title = option.category_title ? option.category_title : "";
716
648
  option.value_count = option.value_count ? option.value_count : 9;
717
- option.generate_id = option.generate_id ? option.generate_id : true;
718
649
  option.get_cart_item = option.get_cart_item ? option.get_cart_item : false;
719
650
  option.cart_item_count = option.cart_item_count ? option.cart_item_count : 5;
720
651
  option.get_cart_sub_item = option.get_cart_sub_item ? option.get_cart_sub_item : false;
@@ -768,9 +699,6 @@ class Field_Logic {
768
699
  }
769
700
  return [title,option];
770
701
  }
771
- static get_test_cost(){
772
- return String(Number.get_id(999)) + "." + String(Number.get_id(99));
773
- }
774
702
  static get_option_admin(req){
775
703
  let option = {};
776
704
  option.value_count = req.query.value_count ? req.query.value_count : 9;
@@ -1053,16 +981,19 @@ class Faq_Logic {
1053
981
  [title,option] = Field_Logic.get_option_title(title,option);
1054
982
  option = Field_Logic.get_option(DataType.FAQ,option?option:{});
1055
983
  option.get_value = false;
1056
- let faq = DataItem.get_new_full_item(
1057
- DataItem.get_new(DataType.FAQ,0),
1058
- DataItem.get_new(DataType.FAQ,0),
1059
- DataItem.get_new(DataType.FAQ,0),
1060
- Field_Logic.get_test(title,option));
984
+ let faq = DataItem.get_new(DataType.FAQ,0,Field_Logic.get_test(title,option));
1061
985
  for(let a=0;a<option.question_count+1;a++){
986
+ if(!option.get_blank){
1062
987
  let question_title = "FAQ Question " + String(parseInt(a+1));
1063
988
  let answer = "My answer "+ Number.get_id() + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
1064
989
  faq[Str.get_title_url(question_title).toLowerCase()] = answer;
1065
990
  faq['field_'+parseInt(a+1)] =question_title;
991
+ }else{
992
+ let question_title = "";
993
+ let answer = "";
994
+ faq[Str.get_title_url(question_title).toLowerCase()] = answer;
995
+ faq['field_'+parseInt(a+1)] =question_title;
996
+ }
1066
997
  }
1067
998
  return faq;
1068
999
  };
@@ -1133,17 +1064,21 @@ class Review_Logic {
1133
1064
  static get_test = (parent_data_type,parent_id,user_id,option) =>{
1134
1065
  option = Field_Logic.get_option(DataType.REVIEW,option?option:{});
1135
1066
  let review = DataItem.get_new(DataType.REVIEW,0);
1136
- if(option.generate_id){
1137
- review.id = Number.get_id();
1138
- }
1067
+ if(!option.get_blank){
1139
1068
  review.title = 'Title ' + Number.get_id();
1140
1069
  review.parent_data_type = parent_data_type;
1141
1070
  review.parent_id = parent_id;
1142
-
1143
1071
  review.rating = Number.get_id(6);
1144
1072
  review.user_id = user_id;
1145
- review.comment = "My comment "+ Item_Logic.get_note();
1146
-
1073
+ review.comment = "My comment "+ Field_Logic.get_test_note();
1074
+ }else{
1075
+ review.title = '';
1076
+ review.parent_data_type = parent_data_type;
1077
+ review.parent_id = parent_id;
1078
+ review.rating = 0;
1079
+ review.user_id = user_id;
1080
+ review.comment = "";
1081
+ }
1147
1082
  return review;
1148
1083
  };
1149
1084
  static get_test_list=(option)=>{
@@ -1170,13 +1105,14 @@ class Admin_Logic {
1170
1105
  [title,option] = Field_Logic.get_option_title(title,option);
1171
1106
  option = Field_Logic.get_option(DataType.ADMIN,option?option:{});
1172
1107
  let item = DataItem.get_new(DataType.ADMIN,0);
1173
- let admin = DataItem.get_new_full_item(
1174
- DataItem.get_new(DataType.ADMIN,Number.get_id()),
1175
- DataItem.get_new(DataType.ADMIN,0),
1176
- DataItem.get_new(DataType.ADMIN,0),
1177
- Field_Logic.get_test(title,option));
1178
- admin.email="ceo@admin"+Number.get_id()+".com";
1179
- admin.password="1234567";
1108
+ let admin = DataItem.get_new(DataType.ADMIN,0,Field_Logic.get_test(title,option));
1109
+ if(!option.get_blank){
1110
+ admin.email="ceo@admin"+Number.get_id()+".com";
1111
+ admin.password="1234567";
1112
+ }else{
1113
+ admin.email="";
1114
+ admin.password="";
1115
+ }
1180
1116
  return admin;
1181
1117
  };
1182
1118
  static get_full_address(admin){
@@ -1216,11 +1152,8 @@ class Business_Logic {
1216
1152
  let item = DataItem.get_new(DataType.BUSINESS,0);
1217
1153
  let city_list = ["Miami","Atlanta","Chicago","Seattle","New York City"];
1218
1154
  let state_list = ["Georgia","New York","Illinois","Washington","Flordia"];
1219
- let business = DataItem.get_new_full_item(
1220
- DataItem.get_new(DataType.BUSINESS,Number.get_id()),
1221
- DataItem.get_new(DataType.BUSINESS,0),
1222
- DataItem.get_new(DataType.BUSINESS,0),
1223
- Field_Logic.get_test(title,option));
1155
+ let business = DataItem.get_new(DataType.BUSINESS,0,Field_Logic.get_test(title,option));
1156
+ if(!option.get_blank){
1224
1157
  business.email="ceo@business"+Number.get_id()+".com";
1225
1158
  business.phone=Number.get_id(parseInt(777+100)) + "-" + Number.get_id(parseInt(777+100)) + "-"+Number.get_id(parseInt(7777+1000));
1226
1159
  business.address_1=Number.get_id(99)+" Main St.";
@@ -1233,6 +1166,20 @@ class Business_Logic {
1233
1166
  business.instagram="instagram_"+Number.get_id(9999);
1234
1167
  business.facebook="facebook_"+Number.get_id(9999);
1235
1168
  business.twitter="twitter_"+Number.get_id(9999);
1169
+ }else{
1170
+ business.email="";
1171
+ business.phone="";
1172
+ business.address_1="";
1173
+ business.address_2="";
1174
+ business.city="";
1175
+ business.state="";
1176
+ business.zip="";
1177
+ business.website="";
1178
+ business.youtube="";
1179
+ business.instagram="";
1180
+ business.facebook="";
1181
+ business.twitter="";
1182
+ }
1236
1183
  return business;
1237
1184
  };
1238
1185
  static get_full_address(business){
@@ -1578,11 +1525,7 @@ class Category_Logic {
1578
1525
  static get_test = (title,option) =>{
1579
1526
  title = (title) ? title : "Category 1";
1580
1527
  option = Field_Logic.get_option(DataType.CATEGORY,option?option:{});
1581
- let category = DataItem.get_new_full_item(
1582
- DataItem.get_new(DataType.CATEGORY,0),
1583
- DataItem.get_new(DataType.CATEGORY,0),
1584
- DataItem.get_new(DataType.CATEGORY,0),
1585
- Field_Logic.get_test(title,option));
1528
+ let category = DataItem.get_new(DataType.CATEGORY,0,Field_Logic.get_test(title,option));
1586
1529
  if(option.get_item){
1587
1530
  category.items = Sub_Item_Logic.get_test_list(category,category,option);
1588
1531
  }
@@ -1938,6 +1881,9 @@ class User_Logic {
1938
1881
  }
1939
1882
  return country_state_city;
1940
1883
  }
1884
+ static get_guest(){
1885
+ return DataItem.get_new(DataType.USER,Number.get_id(999),{is_guest:true,title:"Guest",country:"United States"});
1886
+ }
1941
1887
  static get_user(req){
1942
1888
  if(!req || !req.session.user){
1943
1889
  let user=DataItem.get_new(DataType.USER,Number.get_id(9999999),{is_guest:true});
@@ -1957,13 +1903,23 @@ class User_Logic {
1957
1903
  option = Field_Logic.get_option(DataType.USER,option?option:{});
1958
1904
  let user = DataItem.get_new(DataType.USER,0,
1959
1905
  Field_Logic.get_test(title,option));
1960
- user.first_name="First Name "+ Number.get_id();
1961
- user.last_name="First Name "+ Number.get_id();
1962
- user.email="email"+ Number.get_id() + "@email.com";
1963
- user.city="City"+ Number.get_id();
1964
- user.state="State"+ Number.get_id();
1965
- user.password="1234567";
1966
- user.country="United States";
1906
+ if(option.get_blank){
1907
+ user.first_name="";
1908
+ user.last_name="";
1909
+ user.email="";
1910
+ user.city="";
1911
+ user.state="";
1912
+ user.password="";
1913
+ user.country="";
1914
+ }else{
1915
+ user.first_name="First Name "+ Number.get_id();
1916
+ user.last_name="First Name "+ Number.get_id();
1917
+ user.email="email"+ Number.get_id() + "@email.com";
1918
+ user.city="City"+ Number.get_id();
1919
+ user.state="State"+ Number.get_id();
1920
+ user.password="1234567";
1921
+ user.country="United States";
1922
+ }
1967
1923
  return user;
1968
1924
  };
1969
1925
  static get_test_list = (option) =>{
@@ -1988,7 +1944,7 @@ class Sub_Item_Logic {
1988
1944
  title:item_title,
1989
1945
  title_url:Str.get_title_url(item_title),
1990
1946
  sub_note:"Sub Note "+String(Number.get_id()),
1991
- note:Item_Logic.get_note()
1947
+ note:Field_Logic.get_test_note()
1992
1948
  }
1993
1949
  );
1994
1950
  if(option.get_value){
@@ -2066,7 +2022,6 @@ module.exports = {
2066
2022
  Review_Logic,
2067
2023
  Review_Url,
2068
2024
  Order_Url,
2069
- Order_Logic,
2070
2025
  Service_Logic,
2071
2026
  Service_Url,
2072
2027
  Social,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.8.144",
3
+ "version": "4.8.145",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -103,6 +103,7 @@ describe("connect", () => {
103
103
  //let user_list = User_Logic.get_test_list();
104
104
  //Log.w('user',user);
105
105
  //Log.w('user_list',user_list);
106
+ Log.w('guest',User_Logic.get_guest());
106
107
  /* --USER--END */
107
108
 
108
109
  /* --SEARCH--START */
@@ -360,12 +361,14 @@ describe("connect", () => {
360
361
 
361
362
 
362
363
  /* --REVIEW--START */
364
+ /*
363
365
  let parent_data_type = DataType.PRODUCT;
364
366
  let parent_id = Number.get_id();
365
367
  let user = User_Logic.get_test({generate_id:false});
366
368
  let product_review = Review_Logic.get_test(parent_data_type,parent_id,user.id);
367
369
  let review = Review_Logic.get_new(parent_data_type,parent_id,user,product_review);
368
370
  Log.w('review',review);
371
+ */
369
372
  //Log.w("Review",Review_Logic.get_new(parent_data_type,parent_id,user_id));
370
373
  //Log.w("Review",Review_Logic.get_test({generate_id:true}));
371
374
  //Log.w("Review List",Review_Logic.get_test_list({generate_id:true,review_count:3}));