biz9-logic 4.8.298 → 4.8.300

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='7.7.8'
1
+ VERSION='7.8.0'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -5,9 +5,6 @@ License GNU General Public License v3.0
5
5
  Description: BiZ9 Framework: Logic-JS
6
6
  */
7
7
  const moment = require('moment');
8
- const path = require('path');
9
- const { exec } = require('child_process');
10
- const sharp = require('sharp');
11
8
  const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main,get_new_full_item_main } = require('./main');
12
9
  const { Log,Str,DateTime,Num,Obj } = require('/home/think2/www/doqbox/biz9-framework/biz9-utility/code');
13
10
  class Message {
@@ -1899,144 +1896,15 @@ class App_Logic {
1899
1896
  return app;
1900
1897
  }
1901
1898
  }
1902
-
1903
1899
  class Image_Logic {
1904
1900
  static get_url = (host,image_filename,size) =>{
1905
1901
  return host+"/"+size + "_"+image_filename;
1906
1902
  }
1907
- static get_new_by_base64 = (base64) =>{
1908
- return DataItem.get_new(DataType.IMAGE,0,
1909
- {
1910
- mime_type:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Str.get_file_type_from_base64(base64).mimeType : 'image/jpeg',
1911
- extension:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Str.get_file_type_from_base64(base64).extension : 'jpeg',
1912
- image_filename:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Str.get_guid()+"."+Str.get_file_type_from_base64(base64).extension : 'not_found.jpeg',
1913
- buffer:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Buffer.from(base64.split(';base64,').pop(), 'base64') : null,
1914
- });
1915
- }
1916
- static get_cloud_flare_batch_token = (cloud_flare_account_id,cloud_flare_api_token) => {
1917
- return new Promise((callback) => {
1918
- let data_batch,error=null;
1919
- const url = "https://api.cloudflare.com/client/v4/accounts/"+cloud_flare_account_id+"/images/v1/batch_token";
1920
- const headers = {
1921
- "Accept": "application/json",
1922
- "Authorization": "Bearer " +cloud_flare_api_token
1923
- };
1924
- let curlCommand = `curl -s -H "Accept: ${headers.Accept}"`;
1925
- if (headers.Authorization) {
1926
- curlCommand += ` -H "Authorization: ${headers.Authorization}"`;
1927
- }
1928
- curlCommand += ` "${url}"`;
1929
- exec(curlCommand,async(err,stdout,stderr) => {
1930
- if (err) {
1931
- err = `1 Error executing curl command: ${error.message}`;
1932
- console.error(err);
1933
- error=Log.append(error,err);
1934
- return;
1935
- }
1936
- if (stderr) {
1937
- err = `2 Curl stderr: ${stderr}`;
1938
- console.error(err);
1939
- error=Log.append(error,err);
1940
- return;
1941
- }
1942
- try {
1943
- const jsonData =await JSON.parse(stdout);
1944
- data_batch = jsonData.result.token;
1945
- if(data_batch!== null){
1946
- callback([error,data_batch]);
1947
- }
1948
- } catch (parseError) {
1949
- console.error(`Error parsing JSON response: ${parseError.message}`);
1950
- console.log('Raw Response:', stdout);
1951
- callback([parseError,null]);
1952
- }
1953
- });
1954
- });
1955
- };
1956
- static post_cloud_flare_batch_image = (cloud_flare_api_token,batch_token,image_filename,item_file_path) => {
1957
- let error = null;
1958
- return new Promise((callback) => {
1959
- async.series([
1960
- async function(call){
1961
- const post_url = "https://batch.imagedelivery.net/images/v1";
1962
- const headers = {
1963
- "Accept": "application/json",
1964
- "Authorization": "Bearer " +batch_token
1965
- };
1966
- let curlCommand = `curl -s -H "Accept: ${headers.Accept}"`;
1967
- curlCommand += ` -H "Authorization: ${headers.Authorization}"`;
1968
- curlCommand += " -H X-Auth-Key: "+ cloud_flare_api_token;
1969
- curlCommand += " -F requireSignedURLs=false";
1970
- curlCommand += " -F id="+image_filename;
1971
- curlCommand += " -F file=@"+item_file_path;
1972
- curlCommand += ` "${post_url}"`;
1973
- exec(curlCommand, (err, stdout, stderr) => {
1974
- if (err) {
1975
- err = `Error executing curl command: ${err.message}`;
1976
- console.error(err);
1977
- error=Log.append(error,err);
1978
- }
1979
- if (stderr) {
1980
- err = `Curl stderr: ${stderr}`;
1981
- console.error(err);
1982
- error=Log.append(error,err);
1983
- }
1984
- try {
1985
- const jsonData = JSON.parse(stdout);
1986
- console.log('cool');
1987
- console.log(jsonData);
1988
- console.log('bean');
1989
- if(jsonData!== null){
1990
- callback([error,jsonData]);
1991
- }
1992
- } catch (parseError) {
1993
- console.error(`Error parsing JSON response: ${parseError.message}`);
1994
- console.log('Raw Response:', stdout);
1995
- error=Log.append(error,parseError);
1996
- callback([error,null]);
1997
- }
1998
- });
1999
- },
2000
- ])
2001
- });
2002
- };
2003
-
2004
- static post_write = (buffer,size,path_filename,is_square) => {
2005
- return new Promise((callback) => {
2006
- let data,error=null;
2007
- if(is_square){
2008
- sharp(buffer)
2009
- .resize(size)
2010
- .toFile(path_filename,(err, info) => {
2011
- if(err){
2012
- error=Log.append(error,'Error thumb saving file:');
2013
- console.error('Error thumb saving file:', err);
2014
- }
2015
- if(info!==null){
2016
- callback([error,true]);
2017
- }
2018
- });
2019
- }else{
2020
- sharp(buffer)
2021
- .resize(size,size,{fit:sharp.fit.fill,quality:100})
2022
- .toFile(path_filename,(err, info) => {
2023
- if(err){
2024
- error=Log.append(error,'Error thumb saving file:');
2025
- console.error('Error thumb saving file:', err);
2026
- }
2027
- if(info!==null){
2028
- callback([error,true]);
2029
- }
2030
- });
2031
- }
2032
- });
2033
-
2034
- }
2035
- static get_process_list = (upload_dir,image_filename) =>{
1903
+ static get_process_list = (upload_dir,image_filename) =>{
2036
1904
  return [
2037
1905
  {
2038
1906
  image_filename:FieldType.IMAGE_SIZE_THUMB+"_"+image_filename,
2039
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_THUMB+"_"+image_filename),
1907
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_THUMB+"_"+image_filename,
2040
1908
  size:250,
2041
1909
  is_square:false,
2042
1910
  post_file:false,
@@ -2044,7 +1912,7 @@ class Image_Logic {
2044
1912
  },
2045
1913
  {
2046
1914
  image_filename:FieldType.IMAGE_SIZE_MID+"_"+image_filename,
2047
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_MID+"_"+image_filename),
1915
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_MID+"_"+image_filename,
2048
1916
  size:720,
2049
1917
  is_square:false,
2050
1918
  post_file:false,
@@ -2052,7 +1920,7 @@ class Image_Logic {
2052
1920
  },
2053
1921
  {
2054
1922
  image_filename:FieldType.IMAGE_SIZE_LARGE+"_"+image_filename,
2055
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_LARGE+"_"+image_filename),
1923
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_LARGE+"_"+image_filename,
2056
1924
  size:1000,
2057
1925
  is_square:false,
2058
1926
  post_file:false,
@@ -2060,7 +1928,7 @@ class Image_Logic {
2060
1928
  },
2061
1929
  {
2062
1930
  image_filename:FieldType.IMAGE_SIZE_SQUARE_THUMB+"_"+image_filename,
2063
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_SQUARE_THUMB+"_"+image_filename),
1931
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_SQUARE_THUMB+"_"+image_filename,
2064
1932
  size:250,
2065
1933
  is_square:true,
2066
1934
  post_file:false,
@@ -2068,7 +1936,7 @@ class Image_Logic {
2068
1936
  },
2069
1937
  {
2070
1938
  image_filename:FieldType.IMAGE_SIZE_SQUARE_MID+"_"+image_filename,
2071
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_SQUARE_MID+"_"+image_filename),
1939
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_SQUARE_MID+"_"+image_filename,
2072
1940
  size:720,
2073
1941
  is_square:true,
2074
1942
  post_file:false,
@@ -2076,7 +1944,7 @@ class Image_Logic {
2076
1944
  },
2077
1945
  {
2078
1946
  image_filename:FieldType.IMAGE_SIZE_SQUARE_LARGE+"_"+image_filename,
2079
- path_filename:path.join(upload_dir,FieldType.IMAGE_SIZE_SQUARE_LARGE+"_"+image_filename),
1947
+ path_filename:upload_dir+"/"+FieldType.IMAGE_SIZE_SQUARE_LARGE+"_"+image_filename,
2080
1948
  size:1000,
2081
1949
  is_square:true,
2082
1950
  post_file:false,
@@ -2084,10 +1952,6 @@ class Image_Logic {
2084
1952
  },
2085
1953
  ];
2086
1954
  }
2087
- static get_process_square_list = (upload_dir,image_filename,path) =>{
2088
- return [
2089
- ];
2090
- }
2091
1955
  }
2092
1956
  module.exports = {
2093
1957
  App_Logic,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.8.298",
3
+ "version": "4.8.300",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
2
  const series = require('async-series');
3
- const {DataItem,DataType,Url,Obj,BiZ_Url,Cat,Stock,Schedule,Storage,Business,Product,Service,Event,Template,Page,Category,Review,Blog_Post,Faq_Logic,Category_Url,Blank_Url,Blank_Logic,Item_Logic,Service_Logic,Template_Logic,Page_Logic,Product_Logic,Event_Logic,Blog_Post_Logic,Content_Logic,Category_Logic,Team_Logic,Business_Logic,PageType,Sub_Item_Logic,Page_Url,Review_Logic,User_Logic,Field_Logic,Order_Logic,Cart_Logic,Faq_Url,App_Logic,FieldType,Product_Url,Gallery_Logic} = require('./index');
3
+ const {DataItem,DataType,Url,Obj,BiZ_Url,Cat,Stock,Schedule,Storage,Business,Product,Service,Event,Template,Page,Category,Review,Blog_Post,Faq_Logic,Category_Url,Blank_Url,Blank_Logic,Item_Logic,Service_Logic,Template_Logic,Page_Logic,Product_Logic,Event_Logic,Blog_Post_Logic,Content_Logic,Category_Logic,Team_Logic,Business_Logic,PageType,Sub_Item_Logic,Page_Url,Review_Logic,User_Logic,Field_Logic,Order_Logic,Cart_Logic,Faq_Url,App_Logic,FieldType,Product_Url,Gallery_Logic,Image_Logic} = require('./index');
4
4
  const {Log,Num} = require('biz9-utility');
5
5
  const {Scriptz}= require('biz9-scriptz');
6
6
 
@@ -36,17 +36,18 @@ describe("connect", () => {
36
36
  //console.log(gallery);
37
37
  //console.log('ITEM-END');
38
38
  console.log('cool');
39
- console.log(DataType.get_title(DataType.TEMPLATE,true));
39
+ console.log(Image_Logic.get_process_list('upload/photos','apple'));
40
+ //console.log(DataType.get_title(DataType.TEMPLATE,true));
40
41
  //console.log(FieldType.get_title(FieldType.USER_ROLE_ADMIN));
41
- console.log('bbbbbb');
42
- let page = Page_Logic.get_test();
42
+ //console.log('bbbbbb');
43
+ //let page = Page_Logic.get_test();
43
44
  //page[Item_Logic.get_field_value_title(FieldType.ITEM_FIELD_VALUE_TYPE_TEXT,1)] = 'apple';
44
45
  //page[Item_Logic.get_field_value_title(FieldType.ITEM_FIELD_VALUE_TYPE_LIST,1,1)] = 'cool';
45
46
  //page[Item_Logic.get_field_value_title('list',1,2)] = 'apple';
46
47
  //page[Item_Logic.get_field_value_title('list',1,3)] = 'sauce';
47
48
  //Log.w('page',page);
48
49
  //Log.w('text_1_value',Item_Logic.get_field_value_value(FieldType.ITEM_FIELD_VALUE_TYPE_TEXT,page,1));
49
- Log.w('list_1_value',Item_Logic.get_field_value_value(FieldType.ITEM_FIELD_VALUE_TYPE_LIST,page,1));
50
+ //Log.w('list_1_value',Item_Logic.get_field_value_value(FieldType.ITEM_FIELD_VALUE_TYPE_LIST,page,1));
50
51
 
51
52
 
52
53
  //console.log(Page_Logic.get_page_value_field_title('text',1));