isotropy-ast-analyzer-keyvaluedb
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -10,31 +10,31 @@ "use strict"; | ||
analyzeImportDeclaration: function analyzeImportDeclaration(babelPath, state) { | ||
// Incorrect config | ||
if (!state.opts.projects) return false; | ||
return !state.opts.projects ? false : function () { | ||
var dbProject = state.opts.projects.find(function (project) { | ||
var projectDir = project.dir.startsWith("./") ? project.dir : "./" + project.dir; | ||
var absolutePath = _path2.default.resolve(projectDir) + "/"; | ||
return state.file.opts.filename.startsWith(absolutePath); | ||
}); | ||
var dbProject = state.opts.projects.find(function (project) { | ||
var projectDir = project.dir.startsWith("./") ? project.dir : "./" + project.dir; | ||
var absolutePath = _path2.default.resolve(projectDir) + "/"; | ||
return state.file.opts.filename.startsWith(absolutePath); | ||
}); | ||
// Not a db project | ||
return !dbProject ? false : function () { | ||
var moduleName = babelPath.get("source").node.value; | ||
var resolvedName = _path2.default.resolve(_path2.default.dirname(state.file.opts.filename), moduleName); | ||
// Not a db project | ||
if (!dbProject) return false; | ||
var module = dbProject.modules.find(function (m) { | ||
var sourceDir = m.source.startsWith("./") ? m.source : "./" + m.source; | ||
var absolutePath = _path2.default.resolve(sourceDir); | ||
return absolutePath === resolvedName; | ||
}); | ||
var moduleName = babelPath.get("source").node.value; | ||
var resolvedName = _path2.default.resolve(_path2.default.dirname(state.file.opts.filename), moduleName); | ||
var dbModule = dbProject.modules.find(function (m) { | ||
var sourceDir = m.source.startsWith("./") ? m.source : "./" + m.source; | ||
var absolutePath = _path2.default.resolve(sourceDir); | ||
return absolutePath === resolvedName; | ||
}); | ||
if (!dbModule) return false; | ||
var specifier = babelPath.get("specifiers.0").node.local.name; | ||
analysisState.importBindings = analysisState.importBindings.concat({ | ||
module: dbModule.databases, | ||
binding: babelPath.scope.bindings[specifier] | ||
}); | ||
return true; | ||
return !module ? false : function () { | ||
var specifier = babelPath.get("specifiers.0").node.local.name; | ||
var binding = babelPath.scope.bindings[specifier]; | ||
analysisState.importBindings = analysisState.importBindings.concat({ | ||
module: module, | ||
binding: binding | ||
}); | ||
return true; | ||
}(); | ||
}(); | ||
}(); | ||
} | ||
@@ -41,0 +41,0 @@ }; |
@@ -9,23 +9,5 @@ "use strict"; | ||
return { | ||
/* | ||
Ending with a method call | ||
eg: | ||
myDb.todos.filter() | ||
myDb.todos.filter().filter() | ||
myDb.todos.map().filter() | ||
myDb.todos.map().slice() | ||
myDb.todos.sort() | ||
*/ | ||
analyzeCallExpression: function analyzeCallExpression(path, state) { | ||
return (0, _makeAnalyzer2.default)([ | ||
// schemas.map, schemas.slice, schemas.sort, | ||
schemas.get, schemas.readCallError], path, state, analysisState); | ||
return (0, _makeAnalyzer2.default)([schemas.get], path, state, analysisState); | ||
}, | ||
/* | ||
Ending with a member expression | ||
eg: | ||
myDb.todos | ||
myDb.todos.filter().length | ||
*/ | ||
analyzeMemberExpression: function analyzeMemberExpression(path, state) { | ||
@@ -32,0 +14,0 @@ return (0, _makeAnalyzer2.default)([schemas.count, schemas.collection, schemas.readMemberError], path, state, analysisState); |
@@ -9,11 +9,4 @@ "use strict"; | ||
return { | ||
/* | ||
A database write; which is an assignment expression | ||
eg: | ||
myDb.todos = myDb.todos.concat({ title, assignee }); | ||
*/ | ||
analyzeAssignmentExpression: function analyzeAssignmentExpression(path, state) { | ||
return (0, _makeAnalyzer2.default)([schemas.put, | ||
// , schemas.update, | ||
schemas.del, schemas.writeError], path, state, analysisState); | ||
return (0, _makeAnalyzer2.default)([schemas.put, schemas.del], path, state, analysisState); | ||
} | ||
@@ -20,0 +13,0 @@ }; |
@@ -8,3 +8,3 @@ "use strict"; | ||
exports.default = function (state, analysisState) { | ||
return (0, _composite2.default)({ | ||
return (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "MemberExpression", | ||
@@ -23,10 +23,9 @@ object: (0, _chimpanzee.wrap)((0, _.root)(state, analysisState), { | ||
return function (result) { | ||
var module = result.value.root.module.find(function (m) { | ||
return m.name === result.value.collection; | ||
}); | ||
return result instanceof _chimpanzee.Match ? module.connStr ? (0, _dbStatements.createCollection)({ | ||
identifier: result.value.root.identifier, | ||
module: module.connStr, | ||
collection: result.value.collection | ||
}) : new Skip("Incorrect configuration. Could not resolve DB Connection String.") : result; | ||
return result instanceof _chimpanzee.Match ? function () { | ||
var database = result.value.root.databases[result.value.collection]; | ||
return database ? { | ||
identifier: result.value.root.identifier, | ||
database: database | ||
} : new Error("Could not find configuration for key value database " + result.value.collection + "."); | ||
}() : result; | ||
}; | ||
@@ -40,11 +39,5 @@ }; | ||
var _dbStatements = require("../db-statements"); | ||
var _ = require("./"); | ||
var _composite = require("../chimpanzee-utils/composite"); | ||
var _composite2 = _interopRequireDefault(_composite); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _isotropyAnalyzerUtils = require("isotropy-analyzer-utils"); | ||
//# sourceMappingURL=collection.js.map |
@@ -7,7 +7,9 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports.default = function (state, analysisState) { | ||
return (0, _composite2.default)({ | ||
return (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "AssignmentExpression", | ||
operator: "=", | ||
left: (0, _chimpanzeeUtils.source)([_.collection])(state, analysisState), | ||
left: (0, _isotropyAnalyzerUtils.source)([_.collection])(state, analysisState), | ||
right: { | ||
@@ -17,3 +19,3 @@ type: "CallExpression", | ||
type: "MemberExpression", | ||
object: (0, _chimpanzeeUtils.source)([_.collection])(state, analysisState), | ||
object: (0, _isotropyAnalyzerUtils.source)([_.collection])(state, analysisState), | ||
property: { | ||
@@ -26,19 +28,17 @@ type: "Identifier", | ||
type: "ArrowFunctionExpression", | ||
params: [{ | ||
type: "Identifier", | ||
name: (0, _chimpanzee.capture)("dataAccessor1") | ||
}], | ||
body: unaryExp | ||
body: { | ||
type: "UnaryExpression", | ||
operator: "!", | ||
argument: binaryExpression | ||
} | ||
}] | ||
} | ||
}, { | ||
build: function build(obj) { | ||
return function (context) { | ||
build: function build() { | ||
return function () { | ||
return function (result) { | ||
return result instanceof _chimpanzee.Match ? function () { | ||
var data = result.value.arguments[0]; | ||
return _ramda2.default.equals(result.value.left, result.value.object) ? _ramda2.default.equals(data.params[0].dataAccessor1, data.dataAccessor2) ? (0, _dbStatements.del)(result.value.left, { | ||
keyNode: result.value.arguments[0].key | ||
}) : new _chimpanzee.Skip("Incorrect access variable.") : new _chimpanzee.Skip("The result of the concat() must be assigned to the same collection."); | ||
}() : result; | ||
return result instanceof _chimpanzee.Match ? _extends({}, result.value.object, { | ||
operation: "del", | ||
key: result.value.arguments[0].argument | ||
}) : result; | ||
}; | ||
@@ -50,40 +50,27 @@ }; | ||
var _chimpanzeeUtils = require("../chimpanzee-utils"); | ||
var _chimpanzee = require("chimpanzee"); | ||
var _ = require("./"); | ||
var _chimpanzee = require("chimpanzee"); | ||
var _isotropyAnalyzerUtils = require("isotropy-analyzer-utils"); | ||
var _composite = require("../chimpanzee-utils/composite"); | ||
var _composite2 = _interopRequireDefault(_composite); | ||
var _ramda = require("ramda"); | ||
var _ramda2 = _interopRequireDefault(_ramda); | ||
var _dbStatements = require("../db-statements"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var unaryExp = { | ||
type: "UnaryExpression", | ||
operator: "!", | ||
argument: { | ||
type: "BinaryExpression", | ||
left: { | ||
type: "MemberExpression", | ||
object: { | ||
type: "Identifier", | ||
name: (0, _chimpanzee.capture)("dataAccessor2") | ||
}, | ||
property: { | ||
type: "Identifier", | ||
name: "key" | ||
} | ||
}, | ||
operator: "===", | ||
right: (0, _chimpanzee.capture)("key") | ||
} | ||
}; | ||
var binaryExpression = (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "BinaryExpression", | ||
left: (0, _chimpanzee.wrap)(function (obj) { | ||
return function () { | ||
return _isotropyAnalyzerUtils.arrowFunctions.isMemberExpressionDefinedOnParameter(obj) ? new _chimpanzee.Match(obj) : new _chimpanzee.Error("Expression must be defined on the arrow function parameter."); | ||
}; | ||
}, { selector: "path" }), | ||
operator: "===", | ||
right: (0, _chimpanzee.capture)("key") | ||
}, { | ||
build: function build(obj) { | ||
return function () { | ||
return function (result) { | ||
return result.value.key; | ||
}; | ||
}; | ||
}, | ||
selector: "path" | ||
}); | ||
//# sourceMappingURL=del.js.map |
@@ -7,8 +7,10 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports.default = function (state, analysisState) { | ||
return (0, _composite2.default)({ | ||
return (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "CallExpression", | ||
callee: { | ||
type: "MemberExpression", | ||
object: (0, _chimpanzeeUtils.source)([_.collection])(state, analysisState), | ||
object: (0, _isotropyAnalyzerUtils.source)([_.collection])(state, analysisState), | ||
property: { | ||
@@ -21,7 +23,3 @@ type: "Identifier", | ||
type: "ArrowFunctionExpression", | ||
params: [{ | ||
type: "Identifier", | ||
name: (0, _chimpanzee.capture)("dataAccessor1") | ||
}], | ||
body: binaryExp | ||
body: binaryExpression | ||
}] | ||
@@ -32,6 +30,6 @@ }, { | ||
return function (result) { | ||
return result instanceof _chimpanzee.Match ? function () { | ||
var data = result.value.arguments[0]; | ||
return data.params[0].dataAccessor1 === data.dataAccessor2 ? (0, _dbStatements.get)(result.value.object, { keyNode: data.key }) : new _chimpanzee.Skip("The data access variables do not match"); | ||
}() : new _chimpanzee.Skip("Not get"); | ||
return result instanceof _chimpanzee.Match ? _extends({}, result.value.object, { | ||
operation: "get", | ||
key: result.value.arguments[0].body | ||
}) : result; | ||
}; | ||
@@ -45,30 +43,25 @@ }; | ||
var _chimpanzeeUtils = require("../chimpanzee-utils"); | ||
var _ = require("./"); | ||
var _dbStatements = require("../db-statements"); | ||
var _isotropyAnalyzerUtils = require("isotropy-analyzer-utils"); | ||
var _composite = require("../chimpanzee-utils/composite"); | ||
var _composite2 = _interopRequireDefault(_composite); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var binaryExp = { | ||
var binaryExpression = (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "BinaryExpression", | ||
left: { | ||
type: "MemberExpression", | ||
object: { | ||
type: "Identifier", | ||
name: (0, _chimpanzee.capture)("dataAccessor2") | ||
}, | ||
property: { | ||
type: "Identifier", | ||
name: "key" | ||
} | ||
}, | ||
left: (0, _chimpanzee.wrap)(function (obj) { | ||
return function () { | ||
return _isotropyAnalyzerUtils.arrowFunctions.isMemberExpressionDefinedOnParameter(obj) ? new _chimpanzee.Match(obj) : new _chimpanzee.Error("Expression must be defined on the arrow function parameter."); | ||
}; | ||
}, { selector: "path" }), | ||
operator: "===", | ||
right: (0, _chimpanzee.capture)("key") | ||
}; | ||
}, { | ||
build: function build(obj) { | ||
return function () { | ||
return function (result) { | ||
return result.value.key; | ||
}; | ||
}; | ||
}, | ||
selector: "path" | ||
}); | ||
//# sourceMappingURL=get.js.map |
@@ -7,20 +7,2 @@ "use strict"; | ||
var _collection = require("./collection"); | ||
Object.defineProperty(exports, "collection", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_collection).default; | ||
} | ||
}); | ||
var _count = require("./count"); | ||
Object.defineProperty(exports, "count", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_count).default; | ||
} | ||
}); | ||
var _del = require("./del"); | ||
@@ -62,39 +44,12 @@ | ||
var _update = require("./update"); | ||
var _collection = require("./collection"); | ||
Object.defineProperty(exports, "update", { | ||
Object.defineProperty(exports, "collection", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_update).default; | ||
return _interopRequireDefault(_collection).default; | ||
} | ||
}); | ||
var _readCallError = require("./read-call-error"); | ||
Object.defineProperty(exports, "readCallError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_readCallError).default; | ||
} | ||
}); | ||
var _readMemberError = require("./read-member-error"); | ||
Object.defineProperty(exports, "readMemberError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_readMemberError).default; | ||
} | ||
}); | ||
var _writeError = require("./write-error"); | ||
Object.defineProperty(exports, "writeError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_writeError).default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
@@ -7,7 +7,9 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports.default = function (state, analysisState) { | ||
return (0, _composite2.default)({ | ||
return (0, _isotropyAnalyzerUtils.composite)({ | ||
type: "AssignmentExpression", | ||
operator: "=", | ||
left: (0, _chimpanzeeUtils.source)([_.collection])(state, analysisState), | ||
left: (0, _isotropyAnalyzerUtils.source)([_.collection])(state, analysisState), | ||
right: { | ||
@@ -17,3 +19,3 @@ type: "CallExpression", | ||
type: "MemberExpression", | ||
object: (0, _chimpanzeeUtils.source)([_.collection])(state, analysisState), | ||
object: (0, _isotropyAnalyzerUtils.source)([_.collection])(state, analysisState), | ||
property: { | ||
@@ -24,20 +26,3 @@ type: "Identifier", | ||
}, | ||
arguments: [{ | ||
type: (0, _chimpanzee.capture)(), | ||
properties: [{ | ||
type: "ObjectProperty", | ||
key: { | ||
type: "Identifier", | ||
name: "key" | ||
}, | ||
value: (0, _chimpanzee.capture)("key") | ||
}, { | ||
type: "ObjectProperty", | ||
key: { | ||
type: "Identifier", | ||
name: "value" | ||
}, | ||
value: (0, _chimpanzee.capture)("value") | ||
}] | ||
}] | ||
arguments: (0, _chimpanzee.capture)() | ||
} | ||
@@ -48,8 +33,6 @@ }, { | ||
return function (result) { | ||
return result instanceof _chimpanzee.Match ? function () { | ||
return _ramda2.default.equals(result.value.left, result.value.object) ? result.value.arguments[0].type === "ObjectExpression" ? (0, _dbStatements.put)(result.value.left, { | ||
keyNode: result.value.arguments[0].properties[0].key, | ||
valueNode: result.value.arguments[0].properties[1].value | ||
}) : new _chimpanzee.Skip("You can only put objects inside an Isotropy-Redis store.") : new _chimpanzee.Skip("The result of the concat() must be assigned to the same collection."); | ||
}() : result; | ||
return result instanceof _chimpanzee.Match ? _extends({}, result.value.object, { | ||
operation: "put", | ||
items: result.value.arguments | ||
}) : result; | ||
}; | ||
@@ -61,8 +44,2 @@ }; | ||
var _chimpanzeeUtils = require("../chimpanzee-utils"); | ||
var _astCleaner = require("../tools/ast-cleaner.js"); | ||
var _astCleaner2 = _interopRequireDefault(_astCleaner); | ||
var _ = require("./"); | ||
@@ -72,13 +49,3 @@ | ||
var _composite = require("../chimpanzee-utils/composite"); | ||
var _composite2 = _interopRequireDefault(_composite); | ||
var _ramda = require("ramda"); | ||
var _ramda2 = _interopRequireDefault(_ramda); | ||
var _dbStatements = require("../db-statements"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _isotropyAnalyzerUtils = require("isotropy-analyzer-utils"); | ||
//# sourceMappingURL=put.js.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.default = function (state, analysisState) { | ||
var identifier = function identifier(path, key, parents, parentKeys) { | ||
@@ -17,3 +16,6 @@ return function (context) { | ||
}); | ||
return importBinding && importBinding.binding.referencePaths.includes(path) ? new _chimpanzee.Match({ identifier: path.node.name, module: importBinding.module }, env) : new _chimpanzee.Skip("Did not match any known database modules.", env); | ||
return importBinding && importBinding.binding.referencePaths.includes(path) ? new _chimpanzee.Match({ | ||
identifier: path.node.name, | ||
databases: importBinding.module.databases | ||
}, env) : new _chimpanzee.Skip("Did not match any known database modules.", env); | ||
}() : new _chimpanzee.Skip("Root node is not an Identifier", env); | ||
@@ -20,0 +22,0 @@ }; |
{ | ||
"name": "isotropy-ast-analyzer-keyvaluedb", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Isotropy Team<isotropy@agilehead.com>", | ||
@@ -10,2 +10,3 @@ "contributors": [ | ||
"scripts": { | ||
"build": "./build.sh", | ||
"test": "mocha dist/test/test.js", | ||
@@ -16,3 +17,4 @@ "debug": "mocha dist/test/test.js --debug-brk" | ||
"dependencies": { | ||
"chimpanzee": "0.0.50", | ||
"chimpanzee": "^0.0.60", | ||
"isotropy-analyzer-utils": "^0.0.1", | ||
"lazily": "^0.0.17", | ||
@@ -29,2 +31,3 @@ "ramda": "^0.23.0" | ||
"babel-preset-stage-2": "^6.22.0", | ||
"isotropy-plugin-dev-utils": "^0.0.6", | ||
"mocha": "*", | ||
@@ -31,0 +34,0 @@ "should": "*", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
90554
4
11
39
542
+ Addedchimpanzee@0.0.60(transitive)
+ Addedisotropy-analyzer-utils@0.0.1(transitive)
- Removedchimpanzee@0.0.50(transitive)
Updatedchimpanzee@^0.0.60