From 904b986e223b9c13a730867754a05cb151b2bdc0 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sun, 1 Dec 2019 03:34:25 +0100 Subject: [PATCH] Adding batch support --- package-lock.json | 1840 +++----------------------------------- package.json | 22 +- src/connection.ts | 22 +- src/database/database.ts | 275 ++++-- src/database/lock.ts | 1 + src/database/query.ts | 602 +++++++------ src/database/session.ts | 3 +- src/web/v1/index.ts | 2 +- 8 files changed, 637 insertions(+), 2130 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6de0bd6..1baaa85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,30 +1,30 @@ { "name": "@hibas123/realtimedb", - "version": "2.0.0-beta.4", + "version": "2.0.0-beta.8", "lockfileVersion": 1, "requires": true, "dependencies": { "@hibas123/logging": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@hibas123/logging/-/logging-2.1.1.tgz", - "integrity": "sha512-cQTmXe3P2t+yDph+nyRtCIapN+dnM+7oIx8ujOqp7LD0SIDzfhN1lbRKAVvVUB47K8CJvmpOQuEZUXVaU/QF2w==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@hibas123/logging/-/logging-2.1.2.tgz", + "integrity": "sha512-U3DcLa+CCfE5wflrYcCiMGfzTVPsRpgfbTIa34i6LBdyAjSYCvDhPKH5ERfB07sMarOKmkQ0EC2Nrx9UHJD+Hw==", "requires": { - "@hibas123/utils": "^2.1.0" + "@hibas123/utils": "^2.1.1" } }, "@hibas123/nodelogging": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@hibas123/nodelogging/-/nodelogging-2.1.1.tgz", - "integrity": "sha512-WiOXmqi2A6EvVSxI9zCISE/aK5TuFeosQvmPbC1BOqIb5Sn6eWsezwGX+BZvUN83aUx/a0dBXT3o+ZcMicORZQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@hibas123/nodelogging/-/nodelogging-2.1.2.tgz", + "integrity": "sha512-QoPr9pny7JJ6X5gHBvEztn1a0DYisNaHQZuG0Rzg4OeiHmsK/QDUgSkDpzmUemb0gD/wgW0um3Ht7KBsOAdY5A==", "requires": { - "@hibas123/logging": "^2.1.1", + "@hibas123/logging": "^2.1.2", "@hibas123/utils": "^2.1.1" } }, "@hibas123/utils": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.1.1.tgz", - "integrity": "sha512-A5yQfPsG+B5Vg6TsfJPqRi0tbjfobsTEoiTSFS+r+FFGStTL+B29zN5XI7D1RafL+dveKhblqSZ1Pi1YtEMAVw==" + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.2.3.tgz", + "integrity": "sha512-yAywWMDbt5fmid9E7IRXeCazdbwfC339LhRFIryXab0FqlQzUrm8ggdJaSzWXYC7m3ijdekSezlBno/vOL/L2Q==" }, "@types/abstract-leveldown": { "version": "5.0.1", @@ -98,9 +98,9 @@ } }, "@types/express-serve-static-core": { - "version": "4.16.11", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.11.tgz", - "integrity": "sha512-K8d2M5t3tBQimkyaYTXxtHYyoJPUEhy2/omVRnTAKw5FEdT+Ft6lTaTOpoJdHeG+mIwQXXtqiTcYZ6IR8LTzjQ==", + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.0.tgz", + "integrity": "sha512-Xnub7w57uvcBqFdIGoRg1KhNOeEj0vB6ykUM7uFWyxvbdE89GFyqgmUcanAriMr4YOxNFZBAWkfcWIb4WBPt3g==", "dev": true, "requires": { "@types/node": "*", @@ -138,9 +138,9 @@ "dev": true }, "@types/koa": { - "version": "2.0.51", - "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.0.51.tgz", - "integrity": "sha512-L5e/l6Z+SR9Jk6HM0wNYdkvWhSUBOvi+7Q5Uwn7kE/VmBXX7NIxARMigARWAyXAtXiv5Ry1P2HmebolFdvuIVg==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.11.0.tgz", + "integrity": "sha512-Hgx/1/rVlJvqYBrdeCsS7PDiR2qbxlMt1RnmNWD4Uxi5FF9nwkYqIldo7urjc+dfNpk+2NRGcnAYd4L5xEhCcQ==", "dev": true, "requires": { "@types/accepts": "*", @@ -152,9 +152,9 @@ } }, "@types/koa-compose": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@types/koa-compose/-/koa-compose-3.2.4.tgz", - "integrity": "sha512-ioou0rxkuWL+yBQYsHUQAzRTfVxAg8Y2VfMftU+Y3RA03/MzuFL0x/M2sXXj3PkfnENbHsjeHR1aMdezLYpTeA==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/@types/koa-compose/-/koa-compose-3.2.5.tgz", + "integrity": "sha512-B8nG/OoE1ORZqCkBVsup/AKcvjdgoHnfi4pZMn5UwAPCbhk/96xyv284eBYW8JlQbQ7zDmnpFr68I/40mFoIBQ==", "dev": true, "requires": { "@types/koa": "*" @@ -170,9 +170,9 @@ } }, "@types/leveldown": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/leveldown/-/leveldown-4.0.1.tgz", - "integrity": "sha512-hrna4yd/zAFkbM/Svic5FPPaPhBiNH4F3hM8eaTtpGI1T5ZT3j1FUO7U/Cd7s93ysEH5J6lP2ZbWGV6SqwimqQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/leveldown/-/leveldown-4.0.2.tgz", + "integrity": "sha512-VW6QbUnPb5yLbUBcXEh93lFNphyxkBul7Ae41OCgROd76WfLM3qzAbuzErx1LtsTqwcNlbavTr9rWXHCiGVF8A==", "dev": true, "requires": { "@types/abstract-leveldown": "*", @@ -205,9 +205,9 @@ } }, "@types/node": { - "version": "12.12.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.5.tgz", - "integrity": "sha512-KEjODidV4XYUlJBF3XdjSH5FWoMCtO0utnhtdLf1AgeuZLOrRbvmU/gaRCVg7ZaQDjVf3l84egiY0mRNe5xE4A==" + "version": "12.12.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz", + "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==" }, "@types/range-parser": { "version": "1.2.3", @@ -226,9 +226,9 @@ } }, "@types/ws": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.3.tgz", - "integrity": "sha512-yBTM0P05Tx9iXGq00BbJPo37ox68R5vaGTXivs6RGh/BQ6QP5zqZDGWdAO6JbRE/iR1l80xeGAwCQS2nMV9S/w==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.4.tgz", + "integrity": "sha512-PpPrX7SZW9re6+Ha8ojZG4Se8AZXgf0GK6zmfqEuCsY49LFDNXO3SByp44X3dFEqtB73lkCDAdUazhAjVPiNwg==", "dev": true, "requires": { "@types/node": "*" @@ -289,143 +289,35 @@ "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" }, "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", "dev": true, "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" } }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true - }, "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "base64-js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" }, "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", "dev": true }, "boxen": { @@ -462,32 +354,12 @@ } }, "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "fill-range": "^7.0.1" } }, "buffer": { @@ -509,23 +381,6 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, "cache-content-type": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", @@ -570,23 +425,19 @@ } }, "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", "dev": true, "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" } }, "ci-info": { @@ -595,29 +446,6 @@ "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==", "dev": true }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "cli-boxes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", @@ -657,16 +485,6 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -688,12 +506,6 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "optional": true }, - "component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -760,18 +572,6 @@ } } }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "create-error-class": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", @@ -827,12 +627,6 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", @@ -865,47 +659,6 @@ } } }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -1016,157 +769,13 @@ "strip-eof": "^1.0.0" } }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } + "to-regex-range": "^5.0.1" } }, "find-up": { @@ -1178,578 +787,22 @@ "locate-path": "^3.0.0" } }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, "formidable": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==" }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "^0.2.2" - } - }, "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", "dev": true, - "optional": true, - "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true, - "optional": true - }, - "minipass": { - "version": "2.3.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.7.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "4.4.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "yallist": { - "version": "3.0.3", - "bundled": true, - "dev": true, - "optional": true - } - } + "optional": true }, "get-caller-file": { "version": "1.0.3", @@ -1766,31 +819,13 @@ "pump": "^3.0.0" } }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", "dev": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } + "is-glob": "^4.0.1" } }, "global-dirs": { @@ -1836,9 +871,9 @@ "dev": true }, "handlebars": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz", - "integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", "requires": { "neo-async": "^2.6.0", "optimist": "^0.6.1", @@ -1859,38 +894,6 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "hosted-git-info": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", @@ -1971,26 +974,6 @@ "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -1998,20 +981,14 @@ "dev": true }, "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, "requires": { - "binary-extensions": "^1.0.0" + "binary-extensions": "^2.0.0" } }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, "is-ci": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", @@ -2021,51 +998,6 @@ "ci-info": "^1.5.0" } }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2109,24 +1041,10 @@ "dev": true }, "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true }, "is-obj": { "version": "1.0.1", @@ -2143,15 +1061,6 @@ "path-is-inside": "^1.0.1" } }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, "is-redirect": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", @@ -2170,30 +1079,12 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -2251,12 +1142,6 @@ "tsscmp": "1.0.6" } }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, "koa": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/koa/-/koa-2.11.0.tgz", @@ -2523,21 +1408,6 @@ "p-defer": "^1.0.0" } }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -2559,27 +1429,6 @@ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -2614,62 +1463,15 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "dev": true, - "optional": true - }, "nanoid": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.6.tgz", - "integrity": "sha512-2NDzpiuEy3+H0AVtdt8LoFi7PnqkOnIzYmJQp7xsEU6VexLluHQwKREuiz57XaQC5006seIadPrIZJhyS2n7aw==" - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.7.tgz", + "integrity": "sha512-fmS3qwDldm4bE01HCIRqNk+f255CNjnAoeV3Zzzv0KemObHKqYgirVaZA9DtKcjogicWjYcHkJs4D5A8CjnuVQ==" }, "napi-macros": { "version": "2.0.0", @@ -2698,12 +1500,12 @@ "integrity": "sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==" }, "nodemon": { - "version": "1.19.4", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.19.4.tgz", - "integrity": "sha512-VGPaqQBNk193lrJFotBU8nvWZPqEZY2eIzymy2jjY0fJ9qIsxA0sxQ8ATPl0gZC645gijYEc1jtZvpS8QWzJGQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.1.tgz", + "integrity": "sha512-UC6FVhNLXjbbV4UzaXA3wUdbEkUZzLGgMGzmxvWAex5nzib/jhcSHVFlQODdbuUHq8SnnZ4/EABBAbC3RplvPg==", "dev": true, "requires": { - "chokidar": "^2.1.8", + "chokidar": "^3.2.2", "debug": "^3.2.6", "ignore-by-default": "^1.0.1", "minimatch": "^3.0.4", @@ -2768,55 +1570,6 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "^3.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -2935,30 +1688,12 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", "dev": true }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, "path-is-inside": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", @@ -2992,18 +1727,18 @@ } } }, + "picomatch": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz", + "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==", + "dev": true + }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, "prepend-http": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", @@ -3015,12 +1750,6 @@ "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz", "integrity": "sha512-hjGrh+P926p4R4WbaB6OckyRtO0F0/lQBiT+0gnxjV+5kjPBrfVBFCsCLbMqVQeydvIoouYTCmmEURiH3R1Bdg==" }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -3087,40 +1816,13 @@ "pify": "^3.0.0" } }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - } - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" + "picomatch": "^2.0.4" } }, "registry-auth-token": { @@ -3142,24 +1844,6 @@ "rc": "^1.0.1" } }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3181,18 +1865,6 @@ "path-parse": "^1.0.6" } }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, "rxjs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", @@ -3207,15 +1879,6 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "~0.1.10" - } - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -3241,29 +1904,6 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, "setprototypeof": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", @@ -3290,147 +1930,6 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "^2.1.1", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, "spawn-command": { "version": "0.0.2-1", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", @@ -3469,36 +1968,6 @@ "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -3609,46 +2078,13 @@ "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", "dev": true }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" + "is-number": "^7.0.0" } }, "toidentifier": { @@ -3692,15 +2128,15 @@ } }, "typescript": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz", - "integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==", + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "dev": true }, "uglify-js": { - "version": "3.6.7", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.7.tgz", - "integrity": "sha512-4sXQDzmdnoXiO+xvmTzQsfIiwrjUCSA95rSP4SEd8tDb51W2TiDOlL76Hl+Kw0Ie42PSItCW8/t6pBNCF2R48A==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.1.tgz", + "integrity": "sha512-pnOF7jY82wdIhATVn87uUY/FHU+MDUdPLkmGFvGoclQmeu229eTkbG5gjGGBi3R7UuYYSEeYXY/TTY5j2aym2g==", "optional": true, "requires": { "commander": "~2.20.3", @@ -3735,18 +2171,6 @@ } } }, - "union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -3761,58 +2185,12 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, "unzip-response": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", "dev": true }, - "upath": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "dev": true - }, "update-notifier": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.5.0.tgz", @@ -3836,12 +2214,6 @@ "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.1.tgz", "integrity": "sha512-xVrGVi94ueCJNrBSTjWqjvtgvl3cyOTThp2zaMaFNGp3F542TR6sM3f2o8RqZl+AwteClSVmoCyt0ka4RjQOQg==" }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, "url-parse-lax": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", @@ -3851,12 +2223,6 @@ "prepend-http": "^1.0.1" } }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 2072a36..de11746 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/realtimedb", - "version": "2.0.0-beta.8", + "version": "2.0.0-beta.9", "description": "", "main": "lib/index.js", "private": true, @@ -18,29 +18,29 @@ "devDependencies": { "@types/dotenv": "^8.2.0", "@types/jsonwebtoken": "^8.3.5", - "@types/koa": "^2.0.51", + "@types/koa": "^2.11.0", "@types/koa-router": "^7.0.42", - "@types/leveldown": "^4.0.1", + "@types/leveldown": "^4.0.2", "@types/levelup": "^3.1.1", "@types/nanoid": "^2.1.0", - "@types/node": "^12.12.5", - "@types/ws": "^6.0.3", + "@types/node": "^12.12.14", + "@types/ws": "^6.0.4", "concurrently": "^5.0.0", - "nodemon": "^1.19.4", - "typescript": "^3.6.4" + "nodemon": "^2.0.1", + "typescript": "^3.7.2" }, "dependencies": { - "@hibas123/nodelogging": "^2.1.1", - "@hibas123/utils": "^2.1.1", + "@hibas123/nodelogging": "^2.1.2", + "@hibas123/utils": "^2.2.3", "dotenv": "^8.2.0", - "handlebars": "^4.5.1", + "handlebars": "^4.5.3", "jsonwebtoken": "^8.5.1", "koa": "^2.11.0", "koa-body": "^4.1.1", "koa-router": "^7.4.0", "leveldown": "^5.4.1", "levelup": "^4.3.2", - "nanoid": "^2.1.6", + "nanoid": "^2.1.7", "what-the-pack": "^2.0.3", "ws": "^7.2.0" } diff --git a/src/connection.ts b/src/connection.ts index f72b3e2..61bb36f 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -1,8 +1,8 @@ import Logging from "@hibas123/nodelogging"; import { IncomingMessage, Server } from "http"; import * as WebSocket from "ws"; -import { DatabaseManager, IQuery, ITypedQuery } from "./database/database"; -import { CollectionQuery, DocumentQuery } from "./database/query"; +import { DatabaseManager } from "./database/database"; +import { CollectionQuery, DocumentQuery, IQuery, ITypedQuery } from "./database/query"; import Session from "./database/session"; import { verifyJWT } from "./helper/jwt"; import nanoid = require("nanoid"); @@ -61,14 +61,22 @@ export class ConnectionManager { } const answer = (id: string, data: any, error: boolean = false) => { + if (error) + Logging.error(error as any); socket.send(JSON.stringify({ ns: "message", data: { id, error, data } })); } const handler = new Map void)>(); - handler.set("v2", async ({ id, query }: { id: string, query: IQuery }) => db.run(query, session) + handler.set("v2", async ({ id, query }) => db.run(Array.isArray(query) ? query : [query], session) .then(res => answer(id, res)) - .catch(err => answer(id, undefined, err))); + .catch(err => answer(id, undefined, err)) + ); + + // handler.set("bulk", async ({ id, query }) => db.run(query, session) + // .then(res => answer(id, res)) + // .catch(err => answer(id, undefined, err)) + // ); const SnapshotMap = new Map(); @@ -106,10 +114,8 @@ export class ConnectionManager { socket.on("close", () => { Logging.log(`${session.id} has disconnected!`); - session.queries.forEach((query: DocumentQuery | CollectionQuery) => { - query.unsubscribe(); - }) - session.queries.clear(); + session.subscriptions.forEach(unsubscribe => unsubscribe()); + session.subscriptions.clear(); socket.removeAllListeners(); }) } diff --git a/src/database/database.ts b/src/database/database.ts index d362c56..6fc1baa 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -1,29 +1,18 @@ import { Rules } from "./rules"; import Settings from "../settings"; -import getLevelDB, { LevelDB, deleteLevelDB } from "../storage"; +import getLevelDB, { LevelDB, deleteLevelDB, resNull } from "../storage"; import DocumentLock from "./lock"; -import { DocumentQuery, CollectionQuery, Query, QueryError } from "./query"; +import { DocumentQuery, CollectionQuery, Query, QueryError, ITypedQuery, IQuery } from "./query"; import Logging from "@hibas123/nodelogging"; import Session from "./session"; -import nanoid = require("nanoid"); +import nanoid = require("nanoid/generate"); +import { Observable } from "@hibas123/utils"; -type IWriteQueries = "set" | "update" | "delete" | "add"; -type ICollectionQueries = "get" | "add" | "keys" | "delete-collection" | "list"; -type IDocumentQueries = "get" | "set" | "update" | "delete"; - -export interface ITypedQuery { - path: string[]; - type: T; - data?: any; - options?: any; -} - -interface ITransaction { - queries: ITypedQuery[]; -} - -export type IQuery = ITypedQuery; +const ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +// interface ITransaction { +// queries: ITypedQuery[]; +// } export class DatabaseManager { static databases = new Map(); @@ -66,12 +55,17 @@ export type ChangeTypes = "added" | "modified" | "deleted"; export type Change = { data: any; document: string; + collection: string; type: ChangeTypes; sender: string; } export class Database { + public static getKey(collectionid: string, documentid?: string) { + return `${collectionid || ""}/${documentid || ""}`; + } + private level = getLevelDB(this.name); get data() { @@ -84,10 +78,15 @@ export class Database { public rules: Rules; - public locks = new DocumentLock() + private locks = new DocumentLock() public collectionLocks = new DocumentLock() - public changes = new Map void>>(); + public changeListener = new Map void>>(); + public collectionChangeListener = new Observable<{ + key: string; + id: string; + type: "create" | "delete" + }>(); toJSON() { return { @@ -124,14 +123,71 @@ export class Database { this.publickey = key; } + public async resolve(path: string[], create = false): Promise<{ collection: string, document: string, collectionKey: string }> { + path = [...path]; // Create modifiable copy + let collectionID: string = undefined; + let documentKey = path.length % 2 === 0 ? path.pop() : undefined; + let key = path.join("/"); - getQuery(path: string[], session: Session, type: "document" | "collection" | "any") { - if (type === "document") - return new DocumentQuery(this, path, session); - else if (type === "collection") - return new CollectionQuery(this, path, session); - else - return new Query(this, path, session); + const lock = await this.collectionLocks.lock(key); + + try { + collectionID = await this.collections.get(key).then(r => r.toString()).catch(resNull); + if (!collectionID && create) { + collectionID = nanoid(ALPHABET, 32); + await this.collections.put(key, collectionID); + setImmediate(() => { + this.collectionChangeListener.send({ + id: collectionID, + key, + type: "create" + }) + }) + } + } finally { + lock(); + } + + return { + collection: collectionID, + document: documentKey, + collectionKey: key + }; + } + + private sendChanges(changes: Change[]) { + let col = new Map>(); + changes.forEach(change => { + let e = col.get(change.collection); + if (!e) { + e = new Map() + col.set(change.collection, e); + } + + let d = e.get(change.document); + if (!d) { + d = []; + e.set(change.document, d); + } + + d.push(change); + }) + + setImmediate(() => { + for (let [collection, documents] of col.entries()) { + let collectionChanges = []; + for (let [document, documentChanges] of documents.entries()) { + let s = this.changeListener.get(Database.getKey(collection, document)); + if (s) + s.forEach(e => setImmediate(() => e(documentChanges))); + + collectionChanges.push(...documentChanges); + } + let s = this.changeListener.get(Database.getKey(collection)) + if (s) + s.forEach(e => setImmediate(() => e(collectionChanges))) + } + }) } private validate(query: ITypedQuery) { @@ -146,80 +202,121 @@ export class Database { throw inv; } - async run(query: IQuery, session: Session) { - this.validate(query); - const isCollection = query.path.length % 2 === 1; - if (isCollection) { - const q = new CollectionQuery(this, query.path, session); - let type = query.type as ICollectionQueries; - switch (type) { - case "add": - return q.add(query.data); - case "get": - const limit = (query.options || {}).limit; - if (limit) - q.limit = limit; - const where = (query.options || {}).where; - if (where) - q.where = where; - return q.get(); - case "keys": - return q.keys(); - case "list": - return q.collections(); - case "delete-collection": - return q.deleteCollection(); - default: - return Promise.reject(new Error("Invalid query!")); - } - } else { - const q = new DocumentQuery(this, query.path, session); - let type = query.type as IDocumentQueries; - switch (type) { - case "get": - return q.get(); - case "set": - return q.set(query.data, query.options || {}); - case "update": - return q.update(query.data); - case "delete": - return q.delete(); - default: - return Promise.reject(new Error("Invalid query!")); + async run(queries: IQuery[], session: Session) { + let resolve: { path: string[], create: boolean, resolved?: [string, string, string] }[] = []; + + const addToResolve = (path: string[], create?: boolean) => { + let entry = resolve.find(e => { //TODO: Find may be slow... + if (e.path.length !== path.length) + return false; + for (let i = 0; i < e.path.length; i++) { + if (e.path[i] !== path[i]) + return false; + } + return true; + }) + + if (!entry) { + entry = { + path, + create + } + resolve.push(entry); } + + entry.create = entry.create || create; + + return entry; } + + const isBatch = queries.length > 1; + let parsed = queries.map(rawQuery => { + this.validate(rawQuery); + const isCollection = rawQuery.path.length % 2 === 1; + + let query = isCollection + ? new CollectionQuery(this, session, rawQuery) + : new DocumentQuery(this, session, rawQuery); + + if (isBatch && !query.batchCompatible) + throw new Error("There are queries that are not batch compatible!"); + + let path = addToResolve(rawQuery.path, query.createCollection); + if (query.additionalLock) + addToResolve(query.additionalLock); + + return { + path, + query + }; + }); + + resolve = resolve.sort((a, b) => a.path.length - b.path.length); + + let locks: (() => void)[] = []; + for (let e of resolve) { + let { collection, document, collectionKey } = await this.resolve(e.path, e.create); + e.resolved = [collection, document, collectionKey]; + + locks.push( + await this.locks.lock(collection, document) + ); + } + + let result = []; + try { + let batch = this.data.batch(); + let changes: Change[] = []; + for (let e of parsed) { + result.push( + await e.query.run(e.path.resolved[0], e.path.resolved[1], batch, e.path.resolved[2]) + ); + changes.push(...e.query.changes); + } + if (batch.length > 0) + await batch.write(); + + this.sendChanges(changes); + } finally { + locks.forEach(lock => lock()); + } + + if (isBatch) + return result; + else + return result[0] } - async snapshot(query: ITypedQuery<"snapshot">, session: Session, onchange: (change: any) => void) { - this.validate(query); + async snapshot(rawQuery: ITypedQuery<"snapshot">, session: Session, onchange: (change: any) => void) { + Logging.debug("Snaphot request:", rawQuery.path); + this.validate(rawQuery); - const isCollection = query.path.length % 2 === 1; - let q: DocumentQuery | CollectionQuery; - if (isCollection) { - q = new CollectionQuery(this, query.path, session); - const limit = (query.options || {}).limit; - if (limit) - q.limit = limit; - const where = (query.options || {}).where; - if (where) - q.where = where; - } else { - q = new DocumentQuery(this, query.path, session); - } + if (rawQuery.type !== "snapshot") + throw new Error("Invalid query type!"); - const id = nanoid(16); - session.queries.set(id, q); + const isCollection = rawQuery.path.length % 2 === 1; + let query = isCollection + ? new CollectionQuery(this, session, rawQuery, true) + : new DocumentQuery(this, session, rawQuery, true); + + const { + unsubscribe, + value + } = await query.snapshot(onchange); + + const id = nanoid(ALPHABET, 16); + session.subscriptions.set(id, unsubscribe); return { id, - snaphot: await q.snapshot(onchange) + snaphot: value }; } async unsubscribe(id: string, session: Session) { - let query: CollectionQuery | DocumentQuery = session.queries.get(id) as any; + let query = session.subscriptions.get(id); if (query) { - query.unsubscribe(); - session.queries.delete(id); + query(); + session.subscriptions.delete(id); } } diff --git a/src/database/lock.ts b/src/database/lock.ts index 2f53dc0..dfe5e44 100644 --- a/src/database/lock.ts +++ b/src/database/lock.ts @@ -8,6 +8,7 @@ export default class DocumentLock { } async lock(collection: string = "", document: string = "") { + //TODO: Check collection locks let key = collection + "/" + document; let l = this.locks.get(key); if (l) diff --git a/src/database/query.ts b/src/database/query.ts index fe29589..89d2811 100644 --- a/src/database/query.ts +++ b/src/database/query.ts @@ -4,6 +4,20 @@ import nanoid = require("nanoid/generate"); import Logging from "@hibas123/nodelogging"; import * as MSGPack from "what-the-pack"; import Session from "./session"; +import { LevelUpChain } from "levelup"; + +export type IWriteQueries = "set" | "update" | "delete" | "add"; +export type ICollectionQueries = "get" | "add" | "keys" | "delete-collection" | "list"; +export type IDocumentQueries = "get" | "set" | "update" | "delete"; + +export interface ITypedQuery { + path: string[]; + type: T; + data?: any; + options?: any; +} + +export type IQuery = ITypedQuery; export const MP = MSGPack.initialize(2 ** 20); @@ -11,7 +25,22 @@ const ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz const { encode, decode } = MP; -export class Query { +type Runner = (collection: string, document: string, batch: LevelUpChain, collectionKey: string) => any; + +interface IPreparedQuery { + createCollection: boolean; + needDocument: boolean; + batchCompatible: boolean; + runner: Runner; + additionalLock?: string[]; +} + +interface DocRes { + id: string; + data: any; +} + +export abstract class Query { /** * Returns true if the path only contains valid characters and false if it doesn't * @param path Path to be checked @@ -20,48 +49,37 @@ export class Query { return path.every(e => (e.match(/[^a-zA-Z0-9_\-\<\>]/g) || []).length === 0); } - constructor(protected database: Database, protected path: string[], protected session: Session) { - if (path.length > 10) { + public changes: Change[] = []; + + public readonly createCollection: boolean; + public readonly needDocument: boolean; + public readonly batchCompatible: boolean; + public readonly additionalLock?: string[]; + private readonly _runner: Runner; + + constructor(protected database: Database, protected session: Session, protected query: IQuery, snapshot = false) { + if (query.path.length > 10) { throw new QueryError("Path is to long. Path is only allowed to be 10 Layers deep!"); } - if (!this.validatePath(path)) { + if (!this.validatePath(query.path)) { throw new QueryError("Path can only contain a-z A-Z 0-9 '-' '-' '<' and '>' "); } - } - - protected async resolve(path: string[], create = false): Promise<{ collection: string, document: string, collectionKey: string }> { - path = [...path]; // Create modifiable copy - let collectionID: string = undefined; - let documentKey = path.length % 2 === 0 ? path.pop() : undefined; - let key = path.join("/"); - - const lock = await this.database.collectionLocks.lock(key); - - try { - collectionID = await this.database.collections.get(key).then(r => r.toString()).catch(resNull); - if (!collectionID && create) { - collectionID = nanoid(ALPHABET, 32); - await this.database.collections.put(key, collectionID); - } - } finally { - lock(); + if (!snapshot) { + let data = this.prepare(query); + this.createCollection = data.createCollection; + this.needDocument = data.needDocument; + this.batchCompatible = data.batchCompatible; + this.additionalLock = data.additionalLock; + this._runner = data.runner; } - - return { - collection: collectionID, - document: documentKey, - collectionKey: key - }; } - protected getKey(collection: string, document?: string) { - return `${collection || ""}/${document || ""}`; - } + protected abstract prepare(query: IQuery): IPreparedQuery; protected getDoc(collection: string, document: string) { return this.database.data - .get(this.getKey(collection, document), { asBuffer: true }) + .get(Database.getKey(collection, document), { asBuffer: true }) .then(res => decode(res as Buffer)).catch(resNull); } @@ -69,22 +87,90 @@ export class Query { let change: Change = { type, document, + collection, data, sender: this.session.id } - let s = this.database.changes.get(this.getKey(collection, document)) - - if (s) - s.forEach(e => setImmediate(() => e(change))) - s = this.database.changes.get(this.getKey(collection)) - if (s) - s.forEach(e => setImmediate(() => e(change))) - + this.changes.push(change); } - protected static getConstructorParams(query: Query): [Database, string[], Session] { - return [query.database, query.path, query.session]; + protected static getConstructorParams(query: Query): [Database, Session, IQuery] { + return [query.database, query.session, query.query]; + } + + protected abstract checkChange(change: Change): boolean; + protected abstract firstSend(collection: string, document: string): Promise; + + public run(collection: string, document: string, batch: LevelUpChain, collectionKey: string) { + return this._runner.call(this, collection, document, batch, collectionKey); + } + + public async snapshot(onChange: (change: (DocRes & { type: ChangeTypes })[]) => void) { + const receivedChanges = (changes: Change[]) => { + let res = changes.filter(change => this.checkChange(change)).map(change => { + return { + id: change.document, + data: change.data, + type: change.type + } + }) + if (res.length > 0) + onChange(res); + }; + + const unsub = this.database.collectionChangeListener.subscribe(change => { + if (change.key === collectionKey) { + if (change.type === "create") + addSubscriber(change.id); + else + removeSubscriber(); // Send delete for all elements (Don't know how to do this...) + } + }) + + + let { collection, document, collectionKey } = await this.database.resolve(this.query.path) + let oldKey: string = undefined; + + const removeSubscriber = () => { + if (!oldKey) + return; + let s = this.database.changeListener.get(oldKey); + if (s) { + s.delete(receivedChanges); + if (s.size <= 0) + this.database.changeListener.delete(oldKey); + } + oldKey = undefined; + } + + const addSubscriber = (collection: string) => { + let key = Database.getKey(collection, document); + if (oldKey !== key) { + if (oldKey !== undefined) + removeSubscriber(); + + let s = this.database.changeListener.get(key); + if (!s) { + s = new Set(); + this.database.changeListener.set(key, s); + } + + s.add(receivedChanges); + } + } + + if (collection) { + addSubscriber(collection); + } + + return { + unsubscribe: () => { + unsub(); + removeSubscriber(); + }, + value: await this.firstSend(collection, document) + } } } @@ -95,185 +181,140 @@ interface UpdateData { } } export class DocumentQuery extends Query { - constructor(database: Database, path: string[], session: Session) { - super(database, path, session); - this.onChange = this.onChange.bind(this); + prepare(query: IQuery): IPreparedQuery { + let type = query.type as IDocumentQueries; + switch (type) { + case "get": + return { + batchCompatible: false, + createCollection: false, + needDocument: false, + runner: this.get + } + case "set": + return { + batchCompatible: true, + createCollection: true, + needDocument: true, + runner: this.set + } + case "update": + return { + batchCompatible: true, + createCollection: true, + needDocument: true, + runner: this.update + } + case "delete": + return { + batchCompatible: true, + createCollection: false, + needDocument: true, + runner: this.delete + } + default: + throw new Error("Invalid query type: " + type); + } } - public async get() { - let { collection, document } = await this.resolve(this.path); - + private async get(collection: string, document: string) { if (!collection || !document) { return null; } - return this.getDoc(collection, document) + return this.getDoc(collection, document); } - public async set(data: any, { merge = false }) { + private async set(collection: string, document: string, batch?: LevelUpChain) { + const { data, options } = this.query; if (data === null) - return this.delete(); - let { collection, document } = await this.resolve(this.path, true); - if (!collection) { - throw new QueryError("There must be a collection!") - } + return this.delete(collection, document, batch); - if (!document) { - throw new QueryError("There must be a document key!") - } - - const lock = await this.database.locks.lock(collection, document); let isNew = !(await this.getDoc(collection, document)) - - return this.database.data - .put(this.getKey(collection, document), encode(data)) - .then(() => this.sendChange(collection, document, isNew ? "added" : "modified", data)) - .finally(() => lock()) + batch.put(Database.getKey(collection, document), encode(data)) + this.sendChange(collection, document, isNew ? "added" : "modified", data) } - public async update(updateData: UpdateData) { - let { collection, document } = await this.resolve(this.path, true); - if (!collection) { - throw new QueryError("There must be a collection!") - } - - if (!document) { - throw new QueryError("There must be a document key!") - } - - // Logging.debug(updateData); - - const lock = await this.database.locks.lock(collection, document); - try { - let data = await this.getDoc(collection, document); - let isNew = false - if (!data) { - isNew = true; - data = {}; - } - - for (let path in updateData) { - const toUpdate = updateData[path]; - let d = data; - let parts = path.split("."); - while (parts.length > 1) { - let seg = parts.shift(); - if (!data[seg]) - data[seg] = {} - d = data[seg]; - } - - const last = parts[0]; - - // Logging.debug(parts, last, d) - - switch (toUpdate.type) { - case "value": - d[last] = toUpdate.value; - break; - case "increment": - if (d[last] === undefined || d[last] === null) - d[last] = toUpdate.value; - else if (typeof d[last] !== "number") { - throw new QueryError("Field is no number!"); - } else { - d[last] += toUpdate.value; - } - break; - case "timestamp": - d[last] = new Date().valueOf(); - break; - case "push": - if (d[last] === undefined || d[last] === null) - d[last] = [toUpdate.value]; - else if (Array.isArray(d[last])) { - d[last].push(toUpdate.value); - } else { - throw new QueryError("Field is not array!"); - } - break; - default: - throw new QueryError("Invalid update type: " + toUpdate.type); - } - } - - this.database.data - .put(this.getKey(collection, document), encode(data)) - .then(() => this.sendChange(collection, document, isNew ? "added" : "modified", data)) - } finally { - lock(); - } - //TODO: Implement - } - - public async delete() { - let { collection, document } = await this.resolve(this.path); - - if (!collection) { - throw new QueryError("There must be a collection!") - } - - if (!document) { - throw new QueryError("There must be a document key!") - } - - const lock = await this.database.locks.lock(collection, document); - - return await this.database.data - .del(`${collection}/${document}`) - .then(() => this.sendChange(collection, document, "deleted", null)) - .finally(() => lock()) - } - - - - private subscription: { - key: string, - onChange: (change: DocRes & { type: ChangeTypes }) => void - }; - - async snapshot(onChange: (change: DocRes & { type: ChangeTypes }) => void) { - if (this.subscription) - throw new QueryError("This query is already subscribed!"); - let { collection, document } = await this.resolve(this.path); + private async update(collection: string, document: string, batch?: LevelUpChain) { + const updateData: UpdateData = this.query.data; let data = await this.getDoc(collection, document); - let key = this.getKey(collection, document); - this.subscription = { - key, - onChange - } - let s = this.database.changes.get(key); - if (!s) { - s = new Set(); - this.database.changes.set(key, s); + let isNew = false + if (!data) { + isNew = true; + data = {}; } - s.add(this.onChange); + for (let path in updateData) { + const toUpdate = updateData[path]; + let d = data; + let parts = path.split("."); + while (parts.length > 1) { + let seg = parts.shift(); + if (!data[seg]) + data[seg] = {} + d = data[seg]; + } - return data; + const last = parts[0]; + + switch (toUpdate.type) { + case "value": + d[last] = toUpdate.value; + break; + case "increment": + if (d[last] === undefined || d[last] === null) + d[last] = toUpdate.value; + else if (typeof d[last] !== "number") { + throw new QueryError("Field is no number!"); + } else { + d[last] += toUpdate.value; + } + break; + case "timestamp": + d[last] = new Date().valueOf(); + break; + case "push": + if (d[last] === undefined || d[last] === null) + d[last] = [toUpdate.value]; + else if (Array.isArray(d[last])) { + d[last].push(toUpdate.value); + } else { + throw new QueryError("Field is not array!"); + } + break; + default: + throw new QueryError("Invalid update type: " + toUpdate.type); + } + } + + if (batch) { + batch.put(Database.getKey(collection, document), encode(data)) + } else { + await this.database.data + .put(Database.getKey(collection, document), encode(data)) + } + + this.sendChange(collection, document, isNew ? "added" : "modified", data) } - onChange(change: Change) { - // if(change.sender === this.sender) - // return - this.subscription.onChange({ - id: change.document, - data: change.data, - type: change.type - }) + private async delete(collection: string, document: string, batch?: LevelUpChain) { + if (batch) { + batch.del(Database.getKey(collection, document)) + } else { + await this.database.data.del(Database.getKey(collection, document)); + } + + this.sendChange(collection, document, "deleted", null) } - unsubscribe() { - if (!this.subscription) - return; - let s = this.database.changes.get(this.subscription.key); - s.delete(this.onChange); - if (s.size <= 0) - this.database.changes.delete(this.subscription.key); + checkChange(change: Change) { + return true; + } - this.subscription = undefined; + firstSend(collection: string, document: string) { + return this.get(collection, document); } public static fromQuery(query: Query) { @@ -302,15 +343,61 @@ type IQueryWhereArray = [FieldPath, WhereFilterOp, any]; type IQueryWhere = IQueryWhereArray | IQueryWhereVerbose; -interface DocRes { - id: string; - data: any; -} - export class CollectionQuery extends Query { - constructor(database: Database, path: string[], session: Session) { - super(database, path, session); - this.onChange = this.onChange.bind(this); + private _addId: string; + + + prepare(query): IPreparedQuery { + switch (query.type as ICollectionQueries) { + case "add": + this._addId = nanoid(ALPHABET, 32) + return { + batchCompatible: true, + createCollection: true, + needDocument: false, + runner: this.add, + additionalLock: [...query.path, this._addId] + } + case "get": + const limit = (query.options || {}).limit; + if (limit) + this.limit = limit; + const where = (query.options || {}).where; + if (where) + this.where = where; + + return { + batchCompatible: false, + createCollection: false, + needDocument: false, + runner: this.get + } + case "keys": + return { + batchCompatible: false, + createCollection: false, + needDocument: false, + runner: this.keys + } + case "list": + return { + batchCompatible: false, + createCollection: false, + needDocument: false, + runner: this.keys + } + case "delete-collection": + return { + batchCompatible: false, + createCollection: false, + needDocument: false, + runner: this.deleteCollection + } + // run = () => q.deleteCollection(); + // break; + default: + throw new Error("Invalid query!"); + } } @@ -338,15 +425,19 @@ export class CollectionQuery extends Query { public limit: number = -1; - public async add(value: any) { - let id = nanoid(ALPHABET, 32); - let q = new DocumentQuery(this.database, [...this.path, id], this.session); - await q.set(value, {}); - return id; + public async add(collection: string, document: string, batch: LevelUpChain, collectionKey: string) { + let q = new DocumentQuery(this.database, this.session, { + type: "set", + path: this.additionalLock, + data: this.query.data, + options: this.query.options + }); + await q.run(collection, this._addId, batch, collectionKey); + return this._addId; } private getStreamOptions(collection: string) { - let gt = Buffer.from(this.getKey(collection) + " "); + let gt = Buffer.from(Database.getKey(collection) + " "); gt[gt.length - 1] = 0; let lt = Buffer.alloc(gt.length); @@ -359,10 +450,7 @@ export class CollectionQuery extends Query { } } - public async keys() { - let { collection, document } = await this.resolve(this.path); - if (document) - throw new QueryError("Keys only works on collections!"); + public async keys(collection: string) { if (!collection) return [] @@ -382,7 +470,7 @@ export class CollectionQuery extends Query { }); } - private getFieldValue(data: any, path: FieldPath) { + private _getFieldValue(data: any, path: FieldPath) { let parts = path.split("."); let d = data; while (parts.length > 0) { @@ -395,10 +483,10 @@ export class CollectionQuery extends Query { return d; } - private fitsWhere(data: any): boolean { + private _fitsWhere(data: any): boolean { if (this._where.length > 0) { return this._where.every(([fieldPath, opStr, value]) => { - let val = this.getFieldValue(data, fieldPath); + let val = this._getFieldValue(data, fieldPath); switch (opStr) { case "<": return val < value; @@ -430,10 +518,7 @@ export class CollectionQuery extends Query { return true; } - async get() { - let { collection, document } = await this.resolve(this.path); - if (document) - throw new QueryError("Keys only works on collections!"); + async get(collection: string) { if (!collection) return []; @@ -464,7 +549,7 @@ export class CollectionQuery extends Query { const id = s[1]; let data = decode(value); - if (this.fitsWhere(data)) { + if (this._fitsWhere(data)) { if (this.limit < 0 || values.length < this.limit) { values.push({ id, @@ -486,59 +571,14 @@ export class CollectionQuery extends Query { }) } - private subscription: { - key: string, - onChange: (change: (DocRes & { type: ChangeTypes })[]) => void - }; - - async snapshot(onChange: (change: (DocRes & { type: ChangeTypes })[]) => void) { - if (this.subscription) - throw new QueryError("This query is already subscribed!"); - let { collection, document } = await this.resolve(this.path, true); - - let data = await this.get(); - - let key = this.getKey(collection, document); - this.subscription = { - key, - onChange - } - let s = this.database.changes.get(key); - if (!s) { - s = new Set(); - this.database.changes.set(key, s); - } - - s.add(this.onChange); - - return data; + checkChange(change: Change) { + return this._fitsWhere(change.data); } - onChange(change: Change) { - // if(change.sender === this.sender) - // return - - if (this.fitsWhere(change.data)) { - this.subscription.onChange([{ - id: change.document, - data: change.data, - type: change.type - }]) - } + firstSend(collection: string) { + return this.get(collection) } - unsubscribe() { - if (!this.subscription) - return; - let s = this.database.changes.get(this.subscription.key); - s.delete(this.onChange); - if (s.size <= 0) - this.database.changes.delete(this.subscription.key); - - this.subscription = undefined; - } - - public async collections() { if (!this.session.root) throw new QueryError("No Permission!"); @@ -552,29 +592,27 @@ export class CollectionQuery extends Query { }); } - public async deleteCollection() { + public async deleteCollection(collection: string, document: string, _b: LevelUpChain, collectionKey: string) { if (!this.session.root) throw new QueryError("No Permission!"); - const { collection, document, collectionKey } = await this.resolve(this.path); - - if (document) { - throw new QueryError("There can be no document defined on this operation"); - } - //TODO: Lock whole collection! - let batch = this.database.data.batch(); try { if (collection) { - let documents = await this.keys(); + let documents = await this.keys(collection); // Logging.debug("To delete:", documents) for (let document of documents) { - batch.del(this.getKey(collection, document)); + batch.del(Database.getKey(collection, document)); } await batch.write(); batch = undefined; await this.database.collections.del(collectionKey); + this.database.collectionChangeListener.send({ + id: collection, + key: collectionKey, + type: "delete" + }); } } finally { if (batch) diff --git a/src/database/session.ts b/src/database/session.ts index 92ecb7d..cb0431b 100644 --- a/src/database/session.ts +++ b/src/database/session.ts @@ -1,4 +1,3 @@ -import { Query } from "./query"; export default class Session { constructor(private _sessionid: string) { } @@ -8,5 +7,5 @@ export default class Session { root: boolean = false; uid: string = undefined; - queries = new Map(); + subscriptions = new Map void)>(); } \ No newline at end of file diff --git a/src/web/v1/index.ts b/src/web/v1/index.ts index c66cad6..7668736 100644 --- a/src/web/v1/index.ts +++ b/src/web/v1/index.ts @@ -49,7 +49,7 @@ V1.post("/db/:database/query", async ctx => { } } - ctx.body = await db.run(query, session).catch(err => { + ctx.body = await db.run([query], session).catch(err => { if (err instanceof QueryError) { throw new BadRequestError(err.message); }