biz9-logic 4.8.299 → 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.
Files changed (3) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +1 -131
  3. package/package.json +1 -1
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='7.7.9'
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,8 +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 { exec } = require('child_process');
9
- const sharp = require('sharp');
10
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');
11
9
  const { Log,Str,DateTime,Num,Obj } = require('/home/think2/www/doqbox/biz9-framework/biz9-utility/code');
12
10
  class Message {
@@ -1898,139 +1896,11 @@ class App_Logic {
1898
1896
  return app;
1899
1897
  }
1900
1898
  }
1901
-
1902
1899
  class Image_Logic {
1903
1900
  static get_url = (host,image_filename,size) =>{
1904
1901
  return host+"/"+size + "_"+image_filename;
1905
1902
  }
1906
- static get_new_by_base64 = (base64) =>{
1907
- return DataItem.get_new(DataType.IMAGE,0,
1908
- {
1909
- mime_type:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Str.get_file_type_from_base64(base64).mimeType : 'image/jpeg',
1910
- extension:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Str.get_file_type_from_base64(base64).extension : 'jpeg',
1911
- 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',
1912
- buffer:!Str.check_is_null(Str.get_file_type_from_base64(base64)) ? Buffer.from(base64.split(';base64,').pop(), 'base64') : null,
1913
- });
1914
- }
1915
- static get_cloud_flare_batch_token = (cloud_flare_account_id,cloud_flare_api_token) => {
1916
- return new Promise((callback) => {
1917
- let data_batch,error=null;
1918
- const url = "https://api.cloudflare.com/client/v4/accounts/"+cloud_flare_account_id+"/images/v1/batch_token";
1919
- const headers = {
1920
- "Accept": "application/json",
1921
- "Authorization": "Bearer " +cloud_flare_api_token
1922
- };
1923
- let curlCommand = `curl -s -H "Accept: ${headers.Accept}"`;
1924
- if (headers.Authorization) {
1925
- curlCommand += ` -H "Authorization: ${headers.Authorization}"`;
1926
- }
1927
- curlCommand += ` "${url}"`;
1928
- exec(curlCommand,async(err,stdout,stderr) => {
1929
- if (err) {
1930
- err = `1 Error executing curl command: ${error.message}`;
1931
- console.error(err);
1932
- error=Log.append(error,err);
1933
- return;
1934
- }
1935
- if (stderr) {
1936
- err = `2 Curl stderr: ${stderr}`;
1937
- console.error(err);
1938
- error=Log.append(error,err);
1939
- return;
1940
- }
1941
- try {
1942
- const jsonData =await JSON.parse(stdout);
1943
- data_batch = jsonData.result.token;
1944
- if(data_batch!== null){
1945
- callback([error,data_batch]);
1946
- }
1947
- } catch (parseError) {
1948
- console.error(`Error parsing JSON response: ${parseError.message}`);
1949
- console.log('Raw Response:', stdout);
1950
- callback([parseError,null]);
1951
- }
1952
- });
1953
- });
1954
- };
1955
- static post_cloud_flare_batch_image = (cloud_flare_api_token,batch_token,image_filename,item_file_path) => {
1956
- let error = null;
1957
- return new Promise((callback) => {
1958
- async.series([
1959
- async function(call){
1960
- const post_url = "https://batch.imagedelivery.net/images/v1";
1961
- const headers = {
1962
- "Accept": "application/json",
1963
- "Authorization": "Bearer " +batch_token
1964
- };
1965
- let curlCommand = `curl -s -H "Accept: ${headers.Accept}"`;
1966
- curlCommand += ` -H "Authorization: ${headers.Authorization}"`;
1967
- curlCommand += " -H X-Auth-Key: "+ cloud_flare_api_token;
1968
- curlCommand += " -F requireSignedURLs=false";
1969
- curlCommand += " -F id="+image_filename;
1970
- curlCommand += " -F file=@"+item_file_path;
1971
- curlCommand += ` "${post_url}"`;
1972
- exec(curlCommand, (err, stdout, stderr) => {
1973
- if (err) {
1974
- err = `Error executing curl command: ${err.message}`;
1975
- console.error(err);
1976
- error=Log.append(error,err);
1977
- }
1978
- if (stderr) {
1979
- err = `Curl stderr: ${stderr}`;
1980
- console.error(err);
1981
- error=Log.append(error,err);
1982
- }
1983
- try {
1984
- const jsonData = JSON.parse(stdout);
1985
- console.log('cool');
1986
- console.log(jsonData);
1987
- console.log('bean');
1988
- if(jsonData!== null){
1989
- callback([error,jsonData]);
1990
- }
1991
- } catch (parseError) {
1992
- console.error(`Error parsing JSON response: ${parseError.message}`);
1993
- console.log('Raw Response:', stdout);
1994
- error=Log.append(error,parseError);
1995
- callback([error,null]);
1996
- }
1997
- });
1998
- },
1999
- ])
2000
- });
2001
- };
2002
-
2003
- static post_write = (buffer,size,path_filename,is_square) => {
2004
- return new Promise((callback) => {
2005
- let data,error=null;
2006
- if(is_square){
2007
- sharp(buffer)
2008
- .resize(size)
2009
- .toFile(path_filename,(err, info) => {
2010
- if(err){
2011
- error=Log.append(error,'Error thumb saving file:');
2012
- console.error('Error thumb saving file:', err);
2013
- }
2014
- if(info!==null){
2015
- callback([error,true]);
2016
- }
2017
- });
2018
- }else{
2019
- sharp(buffer)
2020
- .resize(size,size,{fit:sharp.fit.fill,quality:100})
2021
- .toFile(path_filename,(err, info) => {
2022
- if(err){
2023
- error=Log.append(error,'Error thumb saving file:');
2024
- console.error('Error thumb saving file:', err);
2025
- }
2026
- if(info!==null){
2027
- callback([error,true]);
2028
- }
2029
- });
2030
- }
2031
- });
2032
- }
2033
- static get_process_list = (upload_dir,image_filename) =>{
1903
+ static get_process_list = (upload_dir,image_filename) =>{
2034
1904
  return [
2035
1905
  {
2036
1906
  image_filename:FieldType.IMAGE_SIZE_THUMB+"_"+image_filename,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.8.299",
3
+ "version": "4.8.300",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"