alasql 2.1.0 → 2.1.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alasql",
3
3
  "description": "Use SQL to select and filter javascript data - including relational joins and search in nested objects (JSON). Export to and import from Excel and CSV",
4
- "version": "2.1.0",
4
+ "version": "2.1.2",
5
5
  "author": "Andrey Gershun <agershun@gmail.com>",
6
6
  "contributors": [
7
7
  "Mathias Wulff <m@rawu.dk>"
@@ -14,14 +14,14 @@
14
14
  "typings": "dist/alasql.d.ts",
15
15
  "scripts": {
16
16
  "test": "gulp && yarn test-only",
17
- "test-ci": "(yarn test-format || 1) && yarn test",
17
+ "test-ci": "(yarn test-format || 1) && yarn test && yarn install-g && alasql 'select 1 as Succes'",
18
18
  "test-only": "mocha ./test --reporter dot",
19
19
  "test-browser": "node test/browserTestRunner.js 7387",
20
20
  "test-cover": "# istanbul cover -x 'lib/zt/zt.js' --dir test/coverage _mocha",
21
21
  "build": "yarn format && gulp",
22
22
  "build-jison": "gulp --jison && gulp",
23
23
  "build-watch": "gulp watch",
24
- "uptodate": "yarn-check -u --skip-unused",
24
+ "install-g": "yarn build && npm uninstall alasql -g && npm install -g .",
25
25
  "release": "yarn version #f='/tmp/alasql.tmp' && curl https://raw.githubusercontent.com/wiki/agershun/alasql/How-to-release.md > $f && sh $f ; rm $f",
26
26
  "jison": "npx jison-gho ./src/alasqlparser.jison -o ./src/alasqlparser.js",
27
27
  "fmt": "yarn pretty-commit --write",
@@ -52,10 +52,10 @@
52
52
  "dependencies": {
53
53
  "dom-storage": "^2.1.0",
54
54
  "es6-promise": "^4.2.6",
55
- "lodash": "4.17.21",
56
- "request": "2.88.2",
57
- "xlsx": "^0.18.5",
58
- "yargs": "^17.4.1"
55
+ "lodash": "^4.17.21",
56
+ "request": "^2.88.2",
57
+ "xlsx": "^0.18",
58
+ "yargs": "^16"
59
59
  },
60
60
  "devDependencies": {
61
61
  "blueimp-md5": "2.19.0",
@@ -78,11 +78,11 @@
78
78
  "prettier": "2.7.1",
79
79
  "strftime": "0.10.1",
80
80
  "tabletop": "1.6.3",
81
- "uglify-js": "3.17.2"
81
+ "uglify-js": "3.17.3"
82
82
  },
83
83
  "resolutions": {
84
84
  "got": "^12.0.0",
85
- "axios": "^0.27.0",
85
+ "axios": "^1.0.0",
86
86
  "marked": "^4.0.10",
87
87
  "underscore": "^1.12.1",
88
88
  "glob-parent": "^6.0.0",
@@ -99,8 +99,7 @@
99
99
  "url": "https://github.com/agershun/alasql/issues"
100
100
  },
101
101
  "bin": {
102
- "alasql": "./bin/alasql-cli.js",
103
- "alaserver": "./bin/alaserver.js"
102
+ "alasql": "./bin/alasql-cli.js"
104
103
  },
105
104
  "homepage": "https://github.com/agershun/alasql",
106
105
  "keywords": [
@@ -1,18 +0,0 @@
1
- // Plugin sample
2
-
3
- var yy = alasql.yy;
4
-
5
- yy.Echo = function (params) { return yy.extend(this, params); }
6
- yy.Echo.prototype.toString = function() {
7
- var s = 'TEST '+this.expr.toString();
8
- return s;
9
- }
10
-
11
- yy.Echo.prototype.execute = function (databaseid, params, cb) {
12
- // var self = this;
13
- // console.log(76336,this.expr.toJS());
14
- var fn = new Function('params, alasql','return '+this.expr.toJS());
15
- var res = fn(params, alasql);
16
- if(cb) res = cb(res);
17
- return res;
18
- }
@@ -1,40 +0,0 @@
1
- // Prolog plugin
2
-
3
- var yy = alasql.yy;
4
-
5
- yy.Term = function (params) { return yy.extend(this, params); }
6
- yy.Term.prototype.toString = function() {
7
- var s = this.termid;
8
- if(this.args && this.args.length > 0) {
9
- s += '('+this.args.map(function(arg){
10
- return arg.toString();
11
- })+')';
12
- }
13
- return s;
14
- };
15
-
16
- yy.AddRule = function (params) { return yy.extend(this, params); }
17
- yy.AddRule.prototype.toString = function() {
18
- var s = '';
19
- if(this.left) s += this.left.toString();
20
- s += ':-';
21
- s += this.right.map(function(r){return r.toString()}).join(',');
22
- return s;
23
- };
24
-
25
- yy.AddRule.prototype.execute = function (databaseid, params, cb) {
26
- // var self = this;
27
- // console.log(this.expr.toJS());
28
- // var fn = new Function('params, alasql','return '+this.expr.toJS());
29
- // var res = fn(params, alasql);
30
- var res = 1;
31
- var objects = alasql.databases[databaseid].objects;
32
- var rule = {};
33
- if(!this.left) {
34
- this.right.forEach(function(term){
35
- rule.$class = term.termid;
36
- });
37
- }
38
- if(cb) res = cb(res);
39
- return res;
40
- };
@@ -1,245 +0,0 @@
1
- //! AlaSQL v0.4.11-develop-977878caundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
2
- /*
3
- @module alasql
4
- @version 0.4.11-develop-977878caundefined
5
-
6
- AlaSQL - JavaScript SQL database
7
- © 2014-2016 Andrey Gershun & Mathias Rangel Wulff
8
-
9
- @license
10
- The MIT License (MIT)
11
-
12
- Copyright 2014-2016 Andrey Gershun (agershun@gmail.com) & Mathias Rangel Wulff (m@rawu.dk)
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- The above copyright notice and this permission notice shall be included in all
22
- copies or substantial portions of the Software.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- SOFTWARE.
31
- */
32
-
33
- /*
34
- //
35
- // AlaSQL Workker
36
- // Date: 13.04.2014
37
- // (c) 2014-2015, Andrey Gershun
38
- //
39
- */
40
- (function (root, factory) {
41
- if (typeof define === 'function' && define.amd) {
42
- define([], factory);
43
- } else if (typeof exports === 'object') {
44
- module.exports = factory();
45
- } else {
46
- root.alasql = factory();
47
- }
48
- }(this, function () {
49
-
50
- /**
51
- Main procedure for worker
52
- @function
53
- @param {string} sql SQL statement
54
- @param {object} params List of parameters (can be omitted)
55
- @param {callback} cb Callback function
56
- @return {object} Query result
57
- */
58
- function alasql(sql,params,cb){
59
-
60
- params = params||[];
61
-
62
- // Avoid setting params if not needed even with callback
63
- if(typeof params === 'function'){
64
- scope = cb;
65
- cb = params;
66
- params = [];
67
- }
68
-
69
- if(typeof params !== 'object'){
70
- params = [params];
71
- }
72
-
73
- // Increase last request id
74
- var id = alasql.lastid++;
75
- // Save callback
76
- alasql.buffer[id] = cb;
77
- // Send a message to worker
78
- alasql.webworker.postMessage({id:id,sql:sql,params:params});
79
- }
80
-
81
-
82
- alasql.options = {};
83
- alasql.options.progress = function(){};
84
-
85
- isArray = function(obj){
86
- return "[object Array]"===Object.prototype.toString.call(obj);
87
- }
88
-
89
- alasql.promise = function() {
90
- throw new Error('Please include a Promise/A+ library');
91
- }
92
-
93
- // From src/18promise.js
94
- if(typeof Promise !== "undefined"){
95
- var promiseExec = function(sql, params, counterStep, counterTotal){
96
- return new Promise(function(resolve, reject){
97
- alasql(sql, params, function(data,err) {
98
- if(err) {
99
- reject(err);
100
- } else {
101
- if (counterStep && counterTotal && alasql.options.progress !== false) {
102
- alasql.options.progress(counterStep, counterTotal);
103
- }
104
- resolve(data);
105
- }
106
- });
107
- });
108
- }
109
-
110
- var promiseAll = function(sqlParamsArray){
111
- if(sqlParamsArray.length<1){
112
- return ;
113
- }
114
-
115
- var active, sql, params;
116
-
117
- var execArray = [];
118
-
119
- for (var i = 0; i < sqlParamsArray.length; i++) {
120
- active = sqlParamsArray[i];
121
-
122
- if(typeof active === 'string'){
123
- active = [active];
124
- }
125
-
126
- if(!isArray(active) || active.length<1 || 2<active.length){
127
- throw new Error('Error in .promise parameter');
128
- }
129
-
130
- sql = active[0];
131
- params = active[1]||undefined;
132
-
133
- execArray.push(promiseExec(sql, params, i, sqlParamsArray.length));
134
- }
135
-
136
- return Promise.all(execArray);
137
- }
138
-
139
- alasql.promise = function(sql, params) {
140
- if(typeof Promise === "undefined"){
141
- throw new Error('Please include a Promise/A+ library');
142
- }
143
-
144
- if(typeof sql === 'string'){
145
- return promiseExec(sql, params);
146
- }
147
-
148
- if(!isArray(sql) || sql.length<1 || typeof params !== "undefined"){
149
- throw new Error('Error in .promise parameters');
150
- }
151
- return promiseAll(sql);
152
- };
153
-
154
- }
155
-
156
-
157
- alasql = alasql || false;
158
-
159
- if (!alasql) {
160
- throw new Error('alasql was not found');
161
- }
162
-
163
- alasql.worker = function() {
164
- throw new Error('Can find webworker in this enviroment');
165
- };
166
-
167
- if (typeof Worker !== 'undefined') {
168
- alasql.worker = function(path, paths, cb) {
169
- // var path;
170
- if (path === true) {
171
- path = undefined;
172
- }
173
-
174
- if (typeof path === 'undefined') {
175
- var sc = document.getElementsByTagName('script');
176
- for (var i = 0; i < sc.length; i++) {
177
- if (sc[i].src.substr(-16).toLowerCase() === 'alasql-worker.js') {
178
- path = sc[i].src.substr(0, sc[i].src.length - 16) + 'alasql.js';
179
- break;
180
- } else if (sc[i].src.substr(-20).toLowerCase() === 'alasql-worker.min.js') {
181
- path = sc[i].src.substr(0, sc[i].src.length - 20) + 'alasql.min.js';
182
- break;
183
- } else if (sc[i].src.substr(-9).toLowerCase() === 'alasql.js') {
184
- path = sc[i].src;
185
- break;
186
- } else if (sc[i].src.substr(-13).toLowerCase() === 'alasql.min.js') {
187
- path = sc[i].src.substr(0, sc[i].src.length - 13) + 'alasql.min.js';
188
- break;
189
- }
190
- }
191
- }
192
-
193
- if (typeof path === 'undefined') {
194
- throw new Error('Path to alasql.js is not specified');
195
- } else if (path !== false) {
196
- var js = "importScripts('";
197
- js += path;
198
- js +=
199
- "');self.onmessage = function(event) {" +
200
- 'alasql(event.data.sql,event.data.params, function(data){' +
201
- 'postMessage({id:event.data.id, data:data});});}';
202
-
203
- var blob = new Blob([js], {type: 'text/plain'});
204
- alasql.webworker = new Worker(URL.createObjectURL(blob));
205
-
206
- alasql.webworker.onmessage = function(event) {
207
- var id = event.data.id;
208
-
209
- alasql.buffer[id](event.data.data);
210
- delete alasql.buffer[id];
211
- };
212
-
213
- alasql.webworker.onerror = function(e) {
214
- throw e;
215
- };
216
-
217
- if (arguments.length > 1) {
218
- var sql =
219
- 'REQUIRE ' +
220
- paths
221
- .map(function(p) {
222
- return '"' + p + '"';
223
- })
224
- .join(',');
225
- alasql(sql, [], cb);
226
- }
227
- } else if (path === false) {
228
- delete alasql.webworker;
229
- return;
230
- }
231
- };
232
- }
233
-
234
-
235
- /* WebWorker */
236
- /** @type {number} */
237
- alasql.lastid = 0;
238
-
239
- /** @type {object} */
240
- alasql.buffer = {};
241
-
242
- alasql.worker();
243
-
244
- return alasql;
245
- }));
@@ -1,2 +0,0 @@
1
- //! AlaSQL v0.4.11-develop-977878caundefined | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
2
- !function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function r(e,t,o){t=t||[],"function"==typeof t&&(scope=o,o=t,t=[]),"object"!=typeof t&&(t=[t]);var n=r.lastid++;r.buffer[n]=o,r.webworker.postMessage({id:n,sql:e,params:t})}if(r.options={},r.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},r.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise){var e=function(e,t,o,n){return new Promise(function(s,i){r(e,t,function(e,t){t?i(t):(o&&n&&!1!==r.options.progress&&r.options.progress(o,n),s(e))})})},t=function(r){if(!(r.length<1)){for(var t,o,n,s=[],i=0;i<r.length;i++){if(t=r[i],"string"==typeof t&&(t=[t]),!isArray(t)||t.length<1||2<t.length)throw new Error("Error in .promise parameter");o=t[0],n=t[1]||void 0,s.push(e(o,n,i,r.length))}return Promise.all(s)}};r.promise=function(r,o){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return e(r,o);if(!isArray(r)||r.length<1||void 0!==o)throw new Error("Error in .promise parameters");return t(r)}}if(!(r=r||!1))throw new Error("alasql was not found");return r.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(r.worker=function(e,t,o){if(!0===e&&(e=void 0),void 0===e)for(var n=document.getElementsByTagName("script"),s=0;s<n.length;s++){if("alasql-worker.js"===n[s].src.substr(-16).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===n[s].src.substr(-20).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-20)+"alasql.min.js";break}if("alasql.js"===n[s].src.substr(-9).toLowerCase()){e=n[s].src;break}if("alasql.min.js"===n[s].src.substr(-13).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-13)+"alasql.min.js";break}}if(void 0===e)throw new Error("Path to alasql.js is not specified");if(!1!==e){var i="importScripts('";i+=e,i+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}";var a=new Blob([i],{type:"text/plain"});if(r.webworker=new Worker(URL.createObjectURL(a)),r.webworker.onmessage=function(e){var t=e.data.id;r.buffer[t](e.data.data),delete r.buffer[t]},r.webworker.onerror=function(r){throw r},arguments.length>1){r("REQUIRE "+t.map(function(r){return'"'+r+'"'}).join(","),[],o)}}else if(!1===e)return void delete r.webworker}),r.lastid=0,r.buffer={},r.worker(),r});
@@ -1,84 +0,0 @@
1
- // Project: https://github.com/agershun/alasql
2
-
3
- import * as xlsx from "xlsx";
4
-
5
- declare namespace alaSQLSpace {
6
- interface AlaSQLCallback {
7
- (data?: any, err?: Error): void;
8
- }
9
-
10
- interface AlaSQLOptions {
11
- errorlog: boolean;
12
- valueof: boolean;
13
- dropifnotexists: boolean; // drop database in any case
14
- datetimeformat: string; // how to handle DATE and DATETIME types
15
- casesensitive: boolean; // table and column names are case sensitive and converted to lower-case
16
- logtarget: string; // target for log. Values: 'console', 'output', 'id' of html tag
17
- logprompt: boolean; // print SQL at log
18
- modifier: any; // values: RECORDSET, VALUE, ROW, COLUMN, MATRIX, TEXTSTRING, INDEX
19
- columnlookup: number; // how many rows to lookup to define columns
20
- autovertex: boolean; // create vertex if not found
21
- usedbo: boolean; // use dbo as current database (for partial T-SQL comaptibility)
22
- autocommit: boolean; // the AUTOCOMMIT ON | OFF
23
- cache: boolean; // use cache
24
- nocount: boolean; // for SET NOCOUNT OFF
25
- nan: boolean; // check for NaN and convert it to undefined
26
- angularjs: boolean;
27
- tsql: boolean;
28
- mysql: boolean;
29
- postgres: boolean;
30
- oracle: boolean;
31
- sqlite: boolean;
32
- orientdb: boolean;
33
- }
34
-
35
- // compiled Statement
36
- interface AlaSQLStatement {
37
- (params?: any, cb?: AlaSQLCallback, scope?: any): any;
38
- }
39
-
40
- // abstract Syntax Tree
41
- interface AlaSQLAST {
42
- compile(databaseid: string): AlaSQLStatement;
43
- }
44
-
45
- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
46
- interface Thenable<T> {
47
- then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
48
- then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
49
- catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
50
- }
51
-
52
- // see https://github.com/agershun/alasql/wiki/User%20Defined%20Functions
53
- interface userDefinedFunction {
54
- (x: any): any;
55
- }
56
- interface userDefinedFunctionLookUp {
57
- [x: string]: userDefinedFunction;
58
- }
59
- // see https://github.com/agershun/alasql/wiki/User%20Defined%20Functions
60
- interface userAggregator {
61
- (value: any, accumulator: any, stage: number): any;
62
- }
63
- interface userAggregatorLookUp {
64
- [x: string]: userAggregator;
65
- }
66
-
67
- interface AlaSQL {
68
- options: AlaSQLOptions;
69
- error: Error;
70
- (sql: any, params?: any, cb?: AlaSQLCallback, scope?: any): any;
71
- parse(sql: any): AlaSQLAST;
72
- promise(sql: any, params?: any): Thenable<any>;
73
- fn: userDefinedFunctionLookUp;
74
- aggr: userAggregatorLookUp;
75
- autoval(tablename: string, colname: string, getNext?:boolean): number;
76
- yy:{};
77
- setXLSX(xlsxlib: typeof xlsx): void;
78
- }
79
- }
80
-
81
- declare var alasql: alaSQLSpace.AlaSQL;
82
- declare module 'alasql' {
83
- export = alasql;
84
- }