Commit 1a384386 by Guillaume Royer

feat(jio): support node.js

1 parent 4cf72701
......@@ -7,4 +7,3 @@
node_modules/*
lint
package-lock.json
*
!dist/jio-latest-node.js
!dist/jio-latest.js
!README.md
!COPYING
!package.json
......@@ -151,7 +151,8 @@ ${JIOVERSION}: ${EXTERNALDIR}/URI.js \
${SRCDIR}/jio.storage/indexeddbstorage.js \
${SRCDIR}/jio.storage/cryptstorage.js \
${SRCDIR}/jio.storage/fbstorage.js \
${SRCDIR}/jio.storage/cloudooostorage.js
${SRCDIR}/jio.storage/cloudooostorage.js \
${SRCDIR}/jio.storage/mappingstorage.js
@mkdir -p $(@D)
cat $^ > $@
......@@ -163,13 +164,7 @@ ${JIONODELATEST}: ${JIONODEVERSION}
cp $< $@
${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
${EXTERNALDIR}/rsvp-2.0.4.js \
${EXTERNALDIR}/moment.js \
${EXTERNALDIR}/URI.js \
${EXTERNALDIR}/uritemplate.js \
${EXTERNALDIR}/rusha.js \
${SRCDIR}/node/jio-external.js \
${EXTERNALDIR}/xhr2.js \
${SRCDIR}/queries/parser-begin.js \
${SRCDIR}/queries/build/parser.js \
${SRCDIR}/queries/parser-end.js \
......@@ -190,6 +185,7 @@ ${JIONODEVERSION}: ${SRCDIR}/node/jio-start.js \
${SRCDIR}/jio.storage/drivetojiomapping.js \
${SRCDIR}/jio.storage/documentstorage.js \
${SRCDIR}/jio.storage/fbstorage.js \
${SRCDIR}/jio.storage/mappingstorage.js \
${SRCDIR}/node/jio-end.js
@mkdir -p $(@D)
cat $^ > $@
......
This diff could not be displayed because it is too large.
{
"name": "jio",
"version": "v3.35.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"form-data": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "1.0.6",
"mime-types": "^2.1.12"
}
},
"mime-db": {
"version": "1.35.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz",
"integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg=="
},
"mime-types": {
"version": "2.1.19",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz",
"integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==",
"requires": {
"mime-db": "~1.35.0"
}
},
"moment": {
"version": "2.21.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.21.0.tgz",
"integrity": "sha512-TCZ36BjURTeFTM/CwRcViQlfkMvL1/vFISuNLO5GkcVm1+QHfbSiNqZuWeMFjj1/3+uAjXswgRk30j1kkLYJBQ=="
},
"rsvp": {
"version": "git+https://lab.nexedi.com/nexedi/rsvp.js.git#cde40f5c0eab3167964423cc6030fac080ea46c4",
"from": "git+https://lab.nexedi.com/nexedi/rsvp.js.git"
},
"rusha": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/rusha/-/rusha-0.8.2.tgz",
"integrity": "sha1-BfMZbfN7FmvAgNsbvWnITWT6HB8="
},
"urijs": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.1.tgz",
"integrity": "sha512-xVrGVi94ueCJNrBSTjWqjvtgvl3cyOTThp2zaMaFNGp3F542TR6sM3f2o8RqZl+AwteClSVmoCyt0ka4RjQOQg=="
},
"uritemplate": {
"version": "git+https://lab.nexedi.com/nexedi/uritemplate-js.git#69c0af3da5299ac216a0d437fac6dd621ccf9af8",
"from": "git+https://lab.nexedi.com/nexedi/uritemplate-js.git"
},
"xhr2": {
"version": "git+https://github.com/clearroad/node-xhr2.git#5f8895ab8962c6b6664f4f2b88db0eac001d54e0",
"from": "git+https://github.com/clearroad/node-xhr2.git",
"requires": {
"form-data": "^2.3.2"
}
}
}
}
......@@ -20,6 +20,15 @@
"output",
"cloud"
],
"dependencies": {
"form-data": "^2.3.2",
"moment": "^2.21.0",
"rsvp": "git+https://lab.nexedi.com/nexedi/rsvp.js.git",
"rusha": "0.8.2",
"urijs": "^1.19.1",
"uritemplate": "git+https://lab.nexedi.com/nexedi/uritemplate-js.git",
"xhr2": "git+https://github.com/clearroad/node-xhr2.git"
},
"engines": {
"npm": ">=1.3"
}
......
......@@ -546,7 +546,8 @@
query,
property,
select_list = [],
sort_on = [];
sort_on = [],
queryOptions = {};
function mapQuery(one_query) {
var j, query_list = [], key, sub_query;
......@@ -622,14 +623,21 @@
if (query !== undefined) {
query = Query.objectToSearchText(query);
}
return this._sub_storage.allDocs(
{
query: query,
select_list: select_list,
sort_on: sort_on,
limit: option.limit
}
)
if (query) {
queryOptions.query = query;
}
if (select_list) {
queryOptions.select_list = select_list;
}
if (sort_on) {
queryOptions.sort_on = sort_on;
}
if (option.limit) {
queryOptions.limit = option.limit;
}
return this._sub_storage.allDocs(queryOptions)
.push(function (result) {
var sub_doc, map_info = storage._map_id || ["equalSubId"];
for (i = 0; i < result.data.total_rows; i += 1) {
......
......@@ -128,7 +128,7 @@
});
};
window.Blob = Blob;//window.Blob || Blob;
window.Blob = window.Blob || Blob;
function FileReader() {
EventTarget.call(this);
......
module = node_module;
jIO.node_env = window;
module.exports = jIO;
} ({}));
\ No newline at end of file
module.exports = window;
}({}));
var RSVP = window.RSVP,
moment = global.moment,
UriTemplate = window.UriTemplate,
Rusha = window.Rusha;
var RSVP = require('rsvp'),
moment = require('moment'),
Rusha = require('rusha'),
XMLHttpRequest = require('xhr2'),
FormData = require('form-data'),
URI = require('urijs'),
UriTemplate = require('uritemplate'),
process = require('process');
// Allow xhr2 to export XMLHttpRequest
module = {};
window.RSVP = window.RSVP || RSVP;
window.moment = moment;
window.FormData = window.FormData || FormData;
window.XMLHttpRequest = window.XMLHttpRequest || XMLHttpRequest;
(function (define, exports) {
var navigator = null,
window = {},
node_module = module;
module = undefined;
(function (window) {
var navigator = {};
......@@ -17,29 +17,10 @@
* See COPYING file for full licensing terms.
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*global window */
(function (window, jIO, Blob, RSVP) {
(function (jIO, Blob, RSVP) {
"use strict";
var FormData,
originalAjax;
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
// Using_XMLHttpRequest#Submitting_forms_and_uploading_files
FormData = function FormData() {
this.boundary = "---------------------------" + Date.now().toString(16);
this.body = '';
};
FormData.prototype.append = function (name, value, filename) {
this.body += '--' + this.boundary +
'\r\nContent-Disposition: form-data; name="' + name;
if (filename !== undefined) {
this.body += '"; filename="' + filename;
}
this.body += '"\r\n\r\n' + value + '\r\n';
};
window.FormData = FormData;
var originalAjax;
function convertToBlob(promise, convert) {
if (!convert) {
......@@ -63,7 +44,6 @@
return evt;
});
}
originalAjax = jIO.util.ajax;
jIO.util.ajax = function ajax(param) {
var result,
......@@ -84,30 +64,13 @@
param.data = evt.target.result;
return originalAjax(param);
});
} else if (param.data instanceof FormData) {
// Implement minimal FormData for erp5storage
if (!param.hasOwnProperty('headers')) {
param.headers = {};
} else {
// Copy the param dict document (no need for deep copy) to
// allow tests to check them
param.headers = Object.assign({}, param.headers);
}
param.headers["Content-Type"] = "multipart\/form-data; boundary=" +
param.data.boundary;
param.data.body += '--' + param.data.boundary + '--\r\n';
param.data = param.data.body;
result = originalAjax(param);
} else {
result = originalAjax(param);
}
return convertToBlob(result, need_convertion);
};
}(window, window.jIO, window.Blob, window.RSVP));
}(window.jIO, window.Blob, window.RSVP));
// Define a global variable to allow storages to access jIO
var jIO = window.jIO,
FormData = window.FormData,
jiodate = window.jiodate;
......@@ -332,7 +332,7 @@
}
}
if (option.sort_on) {
if (option.sort_on && option.sort_on.length) {
sortOn(option.sort_on, item_list, this._key_schema);
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!