Demo for query storing
Change-Id: I947bcac841992c3f6cfd01ab337c265b0d01cb70
diff --git a/node_modules/css-select-base-adapter/.gitattributes b/node_modules/css-select-base-adapter/.gitattributes
new file mode 100644
index 0000000..bdb0cab
--- /dev/null
+++ b/node_modules/css-select-base-adapter/.gitattributes
@@ -0,0 +1,17 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
diff --git a/node_modules/css-select-base-adapter/LICENSE b/node_modules/css-select-base-adapter/LICENSE
new file mode 100644
index 0000000..649145d
--- /dev/null
+++ b/node_modules/css-select-base-adapter/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Nik Coughlin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/node_modules/css-select-base-adapter/index.js b/node_modules/css-select-base-adapter/index.js
new file mode 100644
index 0000000..6394cbd
--- /dev/null
+++ b/node_modules/css-select-base-adapter/index.js
@@ -0,0 +1,131 @@
+'use strict'
+
+module.exports = adapterFactory;
+
+function adapterFactory(implementation){
+ ensureImplementation(implementation);
+
+ var adapter = {}
+
+ var baseAdapter = {
+ removeSubsets: function (nodes){
+ return removeSubsets(adapter, nodes);
+ },
+ existsOne: function(test, elems){
+ return existsOne(adapter, test, elems);
+ },
+ getSiblings: function(elem){
+ return getSiblings(adapter, elem);
+ },
+ hasAttrib: function(elem, name){
+ return hasAttrib(adapter, elem, name);
+ },
+ findOne: function(test, arr){
+ return findOne(adapter, test, arr);
+ },
+ findAll: function(test, elems){
+ return findAll(adapter, test, elems)
+ }
+ };
+
+ Object.assign(adapter, baseAdapter, implementation);
+
+ return adapter;
+}
+
+var expectImplemented = [
+ "isTag", "getAttributeValue", "getChildren", "getName", "getParent",
+ "getText"
+];
+
+function ensureImplementation(implementation){
+ if(!implementation) throw new TypeError("Expected implementation")
+
+ var notImplemented = expectImplemented.filter(function(fname){
+ return typeof implementation[fname] !== "function";
+ });
+
+ if(notImplemented.length){
+ var notList = "(" + notImplemented.join(", ") + ")";
+ var message = "Expected functions " + notList + " to be implemented";
+ throw new Error(message);
+ }
+}
+
+function removeSubsets(adapter, nodes){
+ var idx = nodes.length, node, ancestor, replace;
+
+ // Check if each node (or one of its ancestors) is already contained in the
+ // array.
+ while(--idx > -1){
+ node = ancestor = nodes[idx];
+
+ // Temporarily remove the node under consideration
+ nodes[idx] = null;
+ replace = true;
+
+ while(ancestor){
+ if(nodes.indexOf(ancestor) > -1){
+ replace = false;
+ nodes.splice(idx, 1);
+ break;
+ }
+ ancestor = adapter.getParent(ancestor)
+ }
+
+ // If the node has been found to be unique, re-insert it.
+ if(replace){
+ nodes[idx] = node;
+ }
+ }
+
+ return nodes;
+}
+
+function existsOne(adapter, test, elems){
+ return elems.some(function(elem){
+ return adapter.isTag(elem) ?
+ test(elem) || adapter.existsOne(test, adapter.getChildren(elem)) :
+ false;
+ });
+}
+
+function getSiblings(adapter, elem){
+ var parent = adapter.getParent(elem);
+ return parent && adapter.getChildren(parent);
+}
+
+
+function hasAttrib(adapter, elem, name){
+ return adapter.getAttributeValue(elem,name) !== undefined
+}
+
+function findOne(adapter, test, arr){
+ var elem = null;
+
+ for(var i = 0, l = arr.length; i < l && !elem; i++){
+ if(test(arr[i])){
+ elem = arr[i];
+ } else {
+ var childs = adapter.getChildren(arr[i]);
+ if(childs && childs.length > 0){
+ elem = adapter.findOne(test, childs);
+ }
+ }
+ }
+
+ return elem;
+}
+
+function findAll(adapter, test, elems){
+ var result = [];
+
+ for(var i = 0, j = elems.length; i < j; i++){
+ if(!adapter.isTag(elems[i])) continue;
+ if(test(elems[i])) result.push(elems[i]);
+ var childs = adapter.getChildren(elems[i]);
+ if(childs) result = result.concat(adapter.findAll(test, childs));
+ }
+
+ return result;
+}
diff --git a/node_modules/css-select-base-adapter/package.json b/node_modules/css-select-base-adapter/package.json
new file mode 100644
index 0000000..3f79bf2
--- /dev/null
+++ b/node_modules/css-select-base-adapter/package.json
@@ -0,0 +1,53 @@
+{
+ "_from": "css-select-base-adapter@^0.1.1",
+ "_id": "css-select-base-adapter@0.1.1",
+ "_inBundle": false,
+ "_integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==",
+ "_location": "/css-select-base-adapter",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "css-select-base-adapter@^0.1.1",
+ "name": "css-select-base-adapter",
+ "escapedName": "css-select-base-adapter",
+ "rawSpec": "^0.1.1",
+ "saveSpec": null,
+ "fetchSpec": "^0.1.1"
+ },
+ "_requiredBy": [
+ "/svgo"
+ ],
+ "_resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz",
+ "_shasum": "3b2ff4972cc362ab88561507a95408a1432135d7",
+ "_spec": "css-select-base-adapter@^0.1.1",
+ "_where": "C:\\Users\\marcr\\Desktop\\KorAp\\Git\\Kalamar\\node_modules\\svgo",
+ "author": {
+ "name": "Nik Coughlin",
+ "email": "nrkn.com@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/nrkn/css-select-base-adapter/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Provides some base functions needed by a css-select adapter so that you don't have to implement the whole thing.",
+ "homepage": "https://github.com/nrkn/css-select-base-adapter#readme",
+ "keywords": [
+ "css",
+ "select",
+ "adapter",
+ "css-select"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "css-select-base-adapter",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/nrkn/css-select-base-adapter.git"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "version": "0.1.1"
+}
diff --git a/node_modules/css-select-base-adapter/readme.md b/node_modules/css-select-base-adapter/readme.md
new file mode 100644
index 0000000..c742343
--- /dev/null
+++ b/node_modules/css-select-base-adapter/readme.md
@@ -0,0 +1,70 @@
+# css-select-base-adapter
+
+Provides some base functions needed by a
+[`css-select`](https://github.com/fb55/css-select) adapter so that you don't
+have to implement the whole thing.
+
+## usage
+
+`npm install css-select-base-adapter --save`
+
+```javascript
+var baseAdapter = require('css-select-base-adapter');
+
+var myAdapter = {
+ // your partial implementation here
+};
+
+// get an adapter with everything needed by css-select
+var adapter = baseAdapter(myAdapter);
+
+// use adapter with css-select...
+```
+
+## how it works
+
+An adapter for `css-select` requires the following functions to be implemented:
+
+```
+isTag, existsOne, getAttributeValue, getChildren, getName, getParent,
+getSiblings, getText, hasAttrib, removeSubsets, findAll, findOne
+```
+
+You can pass this module a more minimal implementation and it will return a full
+adapter that fills in any missing functions, provided that you implement at
+least:
+
+```
+isTag, getAttributeValue, getChildren, getName, getParent, getText
+```
+
+If you provide any of the other methods required of an adapter, the base adapter
+will use your implementation instead of its own.
+
+See the
+[`css-select` readme](https://github.com/fb55/css-select/blob/master/README.md)
+for more information on the required function signatures.
+
+## license
+
+MIT License
+
+Copyright (c) 2018 Nik Coughlin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/node_modules/css-select-base-adapter/test/data.js b/node_modules/css-select-base-adapter/test/data.js
new file mode 100644
index 0000000..c16dfd6
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/data.js
@@ -0,0 +1,34 @@
+'use strict'
+
+const walk = ( node, parent, cb ) => {
+ cb( node, parent )
+
+ if( Array.isArray( node.children ) )
+ node.children.forEach( child => walk( child, node, cb ) )
+}
+
+const data = {
+ name: 'div',
+ attribs: {
+ id: 'container',
+ class: 'message'
+ },
+ children: [
+ {
+ name: 'strong',
+ attribs: {
+ class: 'message'
+ },
+ children: [
+ { text: 'Hello' }
+ ]
+ },
+ { text: ', World!' }
+ ]
+}
+
+walk( data, null, ( node, parent ) => {
+ if( parent ) node.parent = parent
+})
+
+module.exports = [ data ]
diff --git a/node_modules/css-select-base-adapter/test/implementation.js b/node_modules/css-select-base-adapter/test/implementation.js
new file mode 100644
index 0000000..c88985b
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/implementation.js
@@ -0,0 +1,22 @@
+'use strict'
+
+const implementation = {
+ isTag: node => node !== undefined && 'name' in node,
+ getAttributeValue: ( elem, name ) => {
+ if( implementation.isTag( elem ) && elem.attribs ) return elem.attribs[ name ]
+ },
+ getChildren: node => node.children,
+ getName: elem => {
+ if( implementation.isTag( elem ) ) return elem.name
+ },
+ getParent: node => node.parent,
+ getText: node => node.children.map( child => {
+ if( child.text ) return child.text
+
+ if( implementation.isTag( child ) ) return implementation.getText( child )
+
+ return ''
+ }).join( '' )
+}
+
+module.exports = implementation
diff --git a/node_modules/css-select-base-adapter/test/index.js b/node_modules/css-select-base-adapter/test/index.js
new file mode 100644
index 0000000..fc73b3e
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/index.js
@@ -0,0 +1,103 @@
+'use strict'
+
+const assert = require( 'assert' )
+const data = require( './data' )
+const implementation = require( './implementation' )
+const baseAdapter = require( '../' )
+
+const adapter = baseAdapter( implementation )
+
+const getById = id => adapter.findOne(
+ node => adapter.getAttributeValue( node, 'id' ) === id,
+ data
+)
+
+const getByName = name => adapter.findAll(
+ node => adapter.getName( node ) === name,
+ data
+)
+
+const getByClass = className => adapter.findAll(
+ node => adapter.getAttributeValue( node, 'class' ) === className,
+ data
+)
+
+const existsName = name => adapter.existsOne(
+ node => adapter.getName( node ) === name,
+ data
+)
+
+const container = getById( 'container' )
+const strong = getByName( 'strong' )[ 0 ]
+const hello = strong.children[ 0 ]
+const world = container.children[ 1 ]
+
+describe( 'css-select-base-adapter', () => {
+ it( 'getAttributeValue', () => {
+ assert( container )
+ })
+
+ it( 'getName', () => {
+ assert( strong )
+ })
+
+ it( 'findOne', () => {
+ assert( container )
+ })
+
+ it( 'findAll', () => {
+ const messages = getByClass( 'message' )
+
+ assert.equal( messages.length, 2 )
+ assert.equal( messages[ 0 ], container )
+ assert.equal( messages[ 1 ], strong )
+ })
+
+ it( 'getParent', () => {
+ const parent = adapter.getParent( strong )
+
+ assert.equal( parent, container )
+ })
+
+ it( 'getSiblings', () => {
+ const siblings = adapter.getSiblings( strong )
+
+ assert.equal( siblings[ 0 ], strong )
+ assert.equal( siblings[ 1 ], world )
+ })
+
+ it( 'getChildren', () => {
+ const children = adapter.getChildren( container )
+
+ assert.equal( children[ 0 ], strong )
+ })
+
+ it( 'getText', () => {
+ const text = adapter.getText( container )
+
+ assert.equal( text, 'Hello, World!' )
+ })
+
+ it( 'isTag', () => {
+ assert( adapter.isTag( container ) )
+ assert( adapter.isTag( strong ) )
+ assert( !adapter.isTag( hello ) )
+ })
+
+ it( 'hasAttrib', () => {
+ assert( adapter.hasAttrib( container, 'id' ) )
+ assert( !adapter.hasAttrib( strong, 'id' ) )
+ })
+
+ it( 'existsOne', () => {
+ assert( existsName( 'strong' ) )
+ assert( !existsName( 'blink' ) )
+ })
+
+ it( 'removeSubsets', () => {
+ const removed = adapter.removeSubsets([ container, strong, container ])
+
+ assert.equal( removed.length, 1 )
+ assert.equal( removed[ 0 ], container )
+ })
+})