jsharmony 1.16.2 → 1.18.0

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/AppSrvTask.js CHANGED
@@ -286,7 +286,7 @@ AppSrvTask.prototype.exec_sqltrans = function(model, command, params, options, c
286
286
  };
287
287
 
288
288
  AppSrvTask.prototype.exec_sql = function(model, command, params, options, command_cb){
289
- //sql (sql, db, into, foreach_row)
289
+ //sql (sql, db, into, foreach_row, fields)
290
290
 
291
291
  var _this = this;
292
292
 
@@ -774,7 +774,7 @@ AppSrvTask.prototype.getCSVSQLData = function(model, command, params, options, o
774
774
  };
775
775
 
776
776
  AppSrvTask.prototype.exec_write_csv = function(model, command, params, options, command_cb){
777
- //write_csv (path, db, data, sql, overwrite, headers)
777
+ //write_csv (path, db, data, sql, overwrite, fields, headers, csv_options)
778
778
  //handle data: {}, [], [[]], [{}]
779
779
  //can't have both data and sql
780
780
 
@@ -819,6 +819,7 @@ AppSrvTask.prototype.exec_write_csv = function(model, command, params, options,
819
819
  var columns = _.map(command.fields, function(field){ if(_.isString(field)) return field; return field.name; });
820
820
  if(!_.isEmpty(columns)) command.columns = columns;
821
821
  }
822
+ csv_options = _.extend(csv_options, (command.csv_options || {}));
822
823
  var csvwriter = csv.stringify(csv_options);
823
824
  csvwriter.on('error', function(err){
824
825
  if(hasError) return;
@@ -846,7 +847,7 @@ AppSrvTask.prototype.exec_write_csv = function(model, command, params, options,
846
847
  };
847
848
 
848
849
  AppSrvTask.prototype.exec_append_csv = function(model, command, params, options, command_cb){
849
- //append_csv (path, db, data, sql)
850
+ //append_csv (path, db, data, sql, fields, headers, csv_options)
850
851
 
851
852
  var _this = this;
852
853
 
@@ -888,6 +889,7 @@ AppSrvTask.prototype.exec_append_csv = function(model, command, params, options,
888
889
  var columns = _.map(command.fields, function(field){ if(_.isString(field)) return field; return field.name; });
889
890
  if(!_.isEmpty(columns)) command.columns = columns;
890
891
  }
892
+ csv_options = _.extend(csv_options, (command.csv_options || {}));
891
893
  var csvwriter = csv.stringify(csv_options);
892
894
  csvwriter.on('error', function(err){
893
895
  if(hasError) return;
@@ -1109,7 +1111,8 @@ AppSrvTask.prototype.exec_shell = function(model, command, params, options, comm
1109
1111
  };
1110
1112
 
1111
1113
  AppSrvTask.prototype.exec_email = function(model, command, params, options, command_cb){
1112
- //email (to, cc, bcc, subject, text, html, attachments)
1114
+ //email ( email: { to, cc, bcc, subject, text, html, attachments } )
1115
+ //email ( jsharmony_txt: { txt_attrib, to, cc, bcc, attachments } )
1113
1116
 
1114
1117
  var _this = this;
1115
1118
 
@@ -1758,7 +1758,7 @@ exports.ParseEntities = function () {
1758
1758
  ParseMultiLineProperties(model, ['js', 'jslib', 'sqlselect', 'sqldownloadselect', 'sqlrowcount', 'sqlinsert', 'sqlinsertencrypt', 'sqlupdate', 'sqldelete', 'sqlexec', 'sqlwhere', 'sqlgetinsertkeys', 'ongetfilename', 'oninit', 'onload', 'onloadimmediate', 'oninsert', 'onvalidate', 'onupdate', 'ondestroy', 'oncommit', 'onchange']);
1759
1759
  if (model.breadcrumbs) ParseMultiLineProperties(model.breadcrumbs, ['sql']);
1760
1760
  if (model.fields) _.each(model.fields, function (field) {
1761
- ParseMultiLineProperties(field, ['onchange', 'sqlselect', 'sqlupdate', 'sqlinsert', 'sqlwhere', 'sqlsort', 'sqlsearch', 'sqlsearchsound', 'value']);
1761
+ ParseMultiLineProperties(field, ['onclick','onchange', 'sqlselect', 'sqlupdate', 'sqlinsert', 'sqlwhere', 'sqlsort', 'sqlsearch', 'sqlsearchsound', 'value']);
1762
1762
  if (field.lov) ParseMultiLineProperties(field.lov, ['sql', 'sql2', 'sqlmp', 'sqlselect']);
1763
1763
  if (field.controlparams) ParseMultiLineProperties(field.controlparams, ['onpopup']);
1764
1764
  });
@@ -126,7 +126,7 @@ exports.ParseTaskCommand = function(model, command, params){
126
126
  parseChildCommands('read_file', 'foreach_line', 'line');
127
127
  }
128
128
  else if(command.exec == 'write_csv'){
129
- validateCommandProperties(['path','db','data','sql','headers','overwrite','fields']);
129
+ validateCommandProperties(['path','db','data','sql','headers','overwrite','fields','csv_options']);
130
130
  if(command.sql) command.sql = Helper.ParseMultiLine(command.sql);
131
131
  if(command.data){
132
132
  if(!_.isArray(command.data)) command.data = [command.data]; //{} => [{}]
@@ -134,7 +134,7 @@ exports.ParseTaskCommand = function(model, command, params){
134
134
  }
135
135
  }
136
136
  else if(command.exec == 'append_csv'){
137
- validateCommandProperties(['path','db','data','sql','headers','fields']);
137
+ validateCommandProperties(['path','db','data','sql','headers','fields','csv_options']);
138
138
  if(command.sql) command.sql = Helper.ParseMultiLine(command.sql);
139
139
  if(command.data){
140
140
  if(!_.isArray(command.data)) command.data = [command.data]; //{} => [{}]
@@ -26,7 +26,7 @@ module.exports = exports = {};
26
26
  exports.generateSQLObjects = function(table, options, callback){
27
27
  var _this = this;
28
28
 
29
- options = _.extend({ db: 'default', withData: false, maxDataCount: 5000, ignore_jsharmony_schema: true }, options);
29
+ options = _.extend({ db: 'default', withData: false, dataFilter: null, maxDataCount: 5000, ignore_jsharmony_schema: true }, options);
30
30
  if(!options.db) options.db = 'default';
31
31
  var db = this.jsh.DB[options.db];
32
32
  var rslt = {};
@@ -54,13 +54,15 @@ exports.generateSQLObjects = function(table, options, callback){
54
54
  //Get data
55
55
  function(generate_cb){
56
56
  if(!options.withData) return generate_cb();
57
- db.Scalar('','select count(*) from ' + tabledef.table_selector,[],{},function(err,datacnt){
57
+ var sqlWhere = '1=1';
58
+ if((options.dataFilter||'').trim()) sqlWhere = options.dataFilter;
59
+ db.Scalar('','select count(*) from ' + tabledef.table_selector + ' where '+sqlWhere,[],{},function(err,datacnt){
58
60
  if(err){ return generate_cb(err); }
59
61
  if(datacnt > options.maxDataCount){
60
62
  _this.jsh.Log.warning('Warning: Skipping data for table ' + tabledef.table_selector + ', exceeds max rowcount of ' + options.maxDataCount + ', has ' + datacnt + ' rows' );
61
63
  return generate_cb(null);
62
64
  }
63
- db.Recordset('','select * from ' + tabledef.table_selector,[],{},function(err,rslt){
65
+ db.Recordset('','select * from ' + tabledef.table_selector + ' where '+sqlWhere,[],{},function(err,rslt){
64
66
  if(err){ return generate_cb(err); }
65
67
  tabledef.data = rslt;
66
68
  return generate_cb(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsharmony",
3
- "version": "1.16.2",
3
+ "version": "1.18.0",
4
4
  "description": "Rapid Application Development (RAD) Platform for Node.js Database Application Development",
5
5
  "main": "index.js",
6
6
  "scripts": {