From 36afc1783d4962b9be1a3428c7910667278a2674 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:35:24 +0100 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=99=88=20Remove=20`package-lock.json`?= =?UTF-8?q?=20from=20`git`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consistent with other ShareDB repos, and makes sure we run the build against the latest dependencies possible. --- .gitignore | 1 + package-lock.json | 418 ---------------------------------------------- 2 files changed, 1 insertion(+), 418 deletions(-) delete mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index befd0c3..5513963 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +package-lock.json # VS Code .vscode/ diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index c6d02fd..0000000 --- a/package-lock.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "name": "sharedb-postgres", - "version": "4.1.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "sharedb-postgres", - "version": "4.1.0", - "license": "MIT", - "dependencies": { - "pg": "^8.5.1", - "pg-pool": "^3.2.1", - "sharedb": "^1.6.0" - } - }, - "node_modules/arraydiff": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/arraydiff/-/arraydiff-0.1.3.tgz", - "integrity": "sha1-hqVDbXty8b3aX9bXTock5C+Dzk0=" - }, - "node_modules/async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dependencies": { - "lodash": "^4.17.14" - } - }, - "node_modules/buffer-writer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", - "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "node_modules/hat": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", - "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=" - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "node_modules/ot-json0": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ot-json0/-/ot-json0-1.1.0.tgz", - "integrity": "sha512-wf5fci7GGpMYRDnbbdIFQymvhsbFACMHtxjivQo5KgvAHlxekyfJ9aPsRr6YfFQthQkk4bmsl5yESrZwC/oMYQ==" - }, - "node_modules/packet-reader": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", - "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" - }, - "node_modules/pg": { - "version": "8.5.1", - "resolved": "https://registry.npmjs.org/pg/-/pg-8.5.1.tgz", - "integrity": "sha512-9wm3yX9lCfjvA98ybCyw2pADUivyNWT/yIP4ZcDVpMN0og70BUWYEGXPCTAQdGTAqnytfRADb7NERrY1qxhIqw==", - "dependencies": { - "buffer-writer": "2.0.0", - "packet-reader": "1.0.0", - "pg-connection-string": "^2.4.0", - "pg-pool": "^3.2.2", - "pg-protocol": "^1.4.0", - "pg-types": "^2.1.0", - "pgpass": "1.x" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" - }, - "node_modules/pg-int8": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", - "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/pg-pool": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.1.tgz", - "integrity": "sha512-BQDPWUeKenVrMMDN9opfns/kZo4lxmSWhIqo+cSAF7+lfi9ZclQbr9vfnlNaPr8wYF3UYjm5X0yPAhbcgqNOdA==" - }, - "node_modules/pg-protocol": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.4.0.tgz", - "integrity": "sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA==" - }, - "node_modules/pg-types": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", - "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", - "dependencies": { - "pg-int8": "1.0.1", - "postgres-array": "~2.0.0", - "postgres-bytea": "~1.0.0", - "postgres-date": "~1.0.4", - "postgres-interval": "^1.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/pg/node_modules/pg-pool": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz", - "integrity": "sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA==" - }, - "node_modules/pgpass": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.4.tgz", - "integrity": "sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w==", - "dependencies": { - "split2": "^3.1.1" - } - }, - "node_modules/postgres-array": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", - "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/postgres-bytea": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", - "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/postgres-date": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", - "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/postgres-interval": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", - "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", - "dependencies": { - "xtend": "^4.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "node_modules/sharedb": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/sharedb/-/sharedb-1.6.0.tgz", - "integrity": "sha512-N6jhmh408OrZQA7V9Eb1R1vfnJe4zoBjB932L/Z2U4jBZ1F8VTHneMntgVmDfjqkAIWN16TVpxMbcycuLxcDpQ==", - "dependencies": { - "arraydiff": "^0.1.1", - "async": "^2.6.3", - "fast-deep-equal": "^2.0.1", - "hat": "0.0.3", - "ot-json0": "^1.0.1" - } - }, - "node_modules/split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dependencies": { - "readable-stream": "^3.0.0" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "engines": { - "node": ">=0.4" - } - } - }, - "dependencies": { - "arraydiff": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/arraydiff/-/arraydiff-0.1.3.tgz", - "integrity": "sha1-hqVDbXty8b3aX9bXTock5C+Dzk0=" - }, - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "requires": { - "lodash": "^4.17.14" - } - }, - "buffer-writer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", - "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "hat": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", - "integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo=" - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, - "ot-json0": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ot-json0/-/ot-json0-1.1.0.tgz", - "integrity": "sha512-wf5fci7GGpMYRDnbbdIFQymvhsbFACMHtxjivQo5KgvAHlxekyfJ9aPsRr6YfFQthQkk4bmsl5yESrZwC/oMYQ==" - }, - "packet-reader": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", - "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" - }, - "pg": { - "version": "8.5.1", - "resolved": "https://registry.npmjs.org/pg/-/pg-8.5.1.tgz", - "integrity": "sha512-9wm3yX9lCfjvA98ybCyw2pADUivyNWT/yIP4ZcDVpMN0og70BUWYEGXPCTAQdGTAqnytfRADb7NERrY1qxhIqw==", - "requires": { - "buffer-writer": "2.0.0", - "packet-reader": "1.0.0", - "pg-connection-string": "^2.4.0", - "pg-pool": "^3.2.2", - "pg-protocol": "^1.4.0", - "pg-types": "^2.1.0", - "pgpass": "1.x" - }, - "dependencies": { - "pg-pool": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz", - "integrity": "sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA==" - } - } - }, - "pg-connection-string": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz", - "integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ==" - }, - "pg-int8": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", - "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" - }, - "pg-pool": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.1.tgz", - "integrity": "sha512-BQDPWUeKenVrMMDN9opfns/kZo4lxmSWhIqo+cSAF7+lfi9ZclQbr9vfnlNaPr8wYF3UYjm5X0yPAhbcgqNOdA==" - }, - "pg-protocol": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.4.0.tgz", - "integrity": "sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA==" - }, - "pg-types": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", - "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", - "requires": { - "pg-int8": "1.0.1", - "postgres-array": "~2.0.0", - "postgres-bytea": "~1.0.0", - "postgres-date": "~1.0.4", - "postgres-interval": "^1.1.0" - } - }, - "pgpass": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.4.tgz", - "integrity": "sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w==", - "requires": { - "split2": "^3.1.1" - } - }, - "postgres-array": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", - "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==" - }, - "postgres-bytea": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", - "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" - }, - "postgres-date": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", - "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==" - }, - "postgres-interval": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", - "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", - "requires": { - "xtend": "^4.0.0" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "sharedb": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/sharedb/-/sharedb-1.6.0.tgz", - "integrity": "sha512-N6jhmh408OrZQA7V9Eb1R1vfnJe4zoBjB932L/Z2U4jBZ1F8VTHneMntgVmDfjqkAIWN16TVpxMbcycuLxcDpQ==", - "requires": { - "arraydiff": "^0.1.1", - "async": "^2.6.3", - "fast-deep-equal": "^2.0.1", - "hat": "0.0.3", - "ot-json0": "^1.0.1" - } - }, - "split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "requires": { - "readable-stream": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "requires": { - "safe-buffer": "~5.2.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" - } - } -} From aabcda46c8e953397b62da70c4c6bb610b68aa8a Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:41:42 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=92=A5=20Comply=20with=20`sharedb`=20?= =?UTF-8?q?spec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a **BREAKING** change that: - adds tests against the [upstream `sharedb` DB test suite][1] - adds a CI build for the tests against current Node.js and Postgres versions - breaks the API to conform to the upstream tests, including adding metadata support The breaks are: - Dropping non-null constraints on `snapshots.doc_type` and `snapshots.data` (to allow `Doc`s to be deleted) - Adding a new `snapshots.metadata` `json` column - Respecting `options.metadata` and `fields.$submit`, which were previously ignored on `getOps()`, and useless on `getSnapshot()` (which didn't store metadata) - `snapshot.m` is now `undefined` if not present, or `null` if unrequested (inline with the spec) On top of this it also makes some bugfixes to conform to the spec: - Ignore unique key validations when committing, since this may happen during concurrent commits - `JSON.stringify()` JSON fields, which [break][2] if passed a raw array - Default `from = 0` if unset in `getOps()` [1]: https://github.com/share/sharedb/blob/7abe65049add9b58e1df638aa34e7ca2c0a1fcfa/test/db.js#L25 [2]: https://github.com/brianc/node-postgres/issues/442 --- .github/workflows/test.yml | 56 ++++++++++++ .mocharc.js | 5 ++ index.js | 179 +++++++++++++++---------------------- index.spec.js | 37 ++++++++ package.json | 12 ++- structure.sql | 14 +++ test/setup.js | 10 +++ 7 files changed, 205 insertions(+), 108 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 .mocharc.js create mode 100644 index.spec.js create mode 100644 test/setup.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4b37cd3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: Test + +on: + push: + branches: + - main + - setup-ci # TODO: Remove + pull_request: + branches: + - main + +jobs: + test: + name: Node.js ${{ matrix.node }} + PostgreSQL ${{ matrix.postgres }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: + - 16 + - 18 + - 20 + postgres: + - 13 + - 14 + - 15 + - 16 + services: + postgres: + image: postgres:${{ matrix.postgres }} + env: + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install + run: npm install + - name: Test + run: npm test + env: + PGUSER: postgres + PGPASSWORD: postgres + PGDATABASE: postgres diff --git a/.mocharc.js b/.mocharc.js new file mode 100644 index 0000000..510722e --- /dev/null +++ b/.mocharc.js @@ -0,0 +1,5 @@ +module.exports = { + timeout: 5_000, + file: './test/setup.js', + spec: '**/*.spec.js', +}; diff --git a/index.js b/index.js index 251efe2..1b0f0a2 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,8 @@ var DB = require('sharedb').DB; var pg = require('pg'); +const PG_UNIQUE_VIOLATION = '23505'; + // Postgres-backed ShareDB database function PostgresDB(options) { @@ -9,24 +11,32 @@ function PostgresDB(options) { this.closed = false; - this.pg_config = options; - this.pool = new pg.Pool(options); + this._pool = new pg.Pool(options); }; module.exports = PostgresDB; PostgresDB.prototype = Object.create(DB.prototype); -PostgresDB.prototype.close = function(callback) { - this.closed = true; - this.pool.end(); - - if (callback) callback(); +PostgresDB.prototype.close = async function(callback) { + let error; + try { + if (!this.closed) { + this.closed = true; + await this._pool.end(); + } + } catch (err) { + error = err; + } + + // FIXME: Don't swallow errors. Emit 'error' event? + if (callback) callback(error); }; // Persists an op and snapshot if it is for the next version. Calls back with // callback(err, succeeded) -PostgresDB.prototype.commit = function(collection, id, op, snapshot, options, callback) { +PostgresDB.prototype.commit = async function(collection, id, op, snapshot, options, callback) { + try { /* * op: CreateOp { * src: '24545654654646', @@ -37,34 +47,28 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, options, ca * } * snapshot: PostgresSnapshot */ - this.pool.connect((err, client, done) => { - if (err) { - done(client); - callback(err); - return; - } /* - * This query uses common table expression to upsert the snapshot table + * This query uses common table expression to upsert the snapshot table * (iff the new version is exactly 1 more than the latest table or if * the document id does not exists) * - * It will then insert into the ops table if it is exactly 1 more than the + * It will then insert into the ops table if it is exactly 1 more than the * latest table or it the first operation and iff the previous insert into * the snapshot table is successful. * * This result of this query the version of the newly inserted operation * If either the ops or the snapshot insert fails then 0 rows are returned * - * If 0 zeros are return then the callback must return false + * If 0 zeros are return then the callback must return false * * Casting is required as postgres thinks that collection and doc_id are - * not varchar - */ + * not varchar + */ const query = { name: 'sdb-commit-op-and-snap', text: `WITH snapshot_id AS ( - INSERT INTO snapshots (collection, doc_id, doc_type, version, data) - SELECT $1::varchar collection, $2::varchar doc_id, $4 doc_type, $3 v, $5 d + INSERT INTO snapshots (collection, doc_id, version, doc_type, data, metadata) + SELECT $1::varchar collection, $2::varchar doc_id, $3 v, $4 doc_type, $5 d, $6 m WHERE $3 = ( SELECT version+1 v FROM snapshots @@ -76,11 +80,11 @@ PostgresDB.prototype.commit = function(collection, id, op, snapshot, options, ca WHERE collection = $1 AND doc_id = $2 FOR UPDATE ) - ON CONFLICT (collection, doc_id) DO UPDATE SET version = $3, data = $5, doc_type = $4 + ON CONFLICT (collection, doc_id) DO UPDATE SET version = $3, data = $5, doc_type = $4, metadata = $5 RETURNING version ) INSERT INTO ops (collection, doc_id, version, operation) -SELECT $1::varchar collection, $2::varchar doc_id, $3 v, $6 operation +SELECT $1::varchar collection, $2::varchar doc_id, $3 v, $7 operation WHERE ( $3 = ( SELECT max(version)+1 @@ -93,66 +97,47 @@ WHERE ( ) ) AND EXISTS (SELECT 1 FROM snapshot_id) RETURNING version`, - values: [collection,id,snapshot.v, snapshot.type, snapshot.data,op] + values: [collection, id, snapshot.v, snapshot.type, JSON.stringify(snapshot.data), JSON.stringify(snapshot.m), JSON.stringify(op)] } - client.query(query, (err, res) => { - if (err) { - callback(err) - } else if(res.rows.length === 0) { - done(client); - callback(null,false) - } - else { - done(client); - callback(null,true) - } - }) - - }) + const result = await this._pool.query(query); + const success = result.rowCount > 0; + callback(null, success); + } catch (error) { + // Return non-success instead of duplicate key error, since this is + // expected to occur during simultaneous creates on the same id + if (error.code === PG_UNIQUE_VIOLATION) callback(null, false); + else callback(error); + } }; // Get the named document from the database. The callback is called with (err, // snapshot). A snapshot with a version of zero is returned if the docuemnt // has never been created in the database. -PostgresDB.prototype.getSnapshot = function(collection, id, fields, options, callback) { - this.pool.connect(function(err, client, done) { - if (err) { - done(client); - callback(err); - return; - } - client.query( - 'SELECT version, data, doc_type FROM snapshots WHERE collection = $1 AND doc_id = $2 LIMIT 1', +PostgresDB.prototype.getSnapshot = async function(collection, id, fields, options, callback) { + fields ||= {}; + options ||= {}; + const wantsMetadata = fields.$submit || options.metadata; + try { + const result = await this._pool.query( + 'SELECT version, data, doc_type, metadata FROM snapshots WHERE collection = $1 AND doc_id = $2 LIMIT 1', [collection, id], - function(err, res) { - done(); - if (err) { - callback(err); - return; - } - if (res.rows.length) { - var row = res.rows[0] - var snapshot = new PostgresSnapshot( - id, - row.version, - row.doc_type, - row.data, - undefined // TODO: metadata - ) - callback(null, snapshot); - } else { - var snapshot = new PostgresSnapshot( - id, - 0, - null, - undefined, - undefined - ) - callback(null, snapshot); - } - } - ) - }) + ); + + var row = result.rows[0] + const snapshot = { + id, + v: row?.version || 0, + type: row?.doc_type || null, + data: row?.data || undefined, + m: wantsMetadata ? + // Postgres returns null but ShareDB expects undefined + (row?.metadata || undefined) : + null, + }; + callback(null, snapshot); + } catch (error) { + callback(error); + } }; // Get operations between [from, to) noninclusively. (Ie, the range should @@ -164,37 +149,21 @@ PostgresDB.prototype.getSnapshot = function(collection, id, fields, options, cal // The version will be inferred from the parameters if it is missing. // // Callback should be called as callback(error, [list of ops]); -PostgresDB.prototype.getOps = function(collection, id, from, to, options, callback) { - this.pool.connect(function(err, client, done) { - if (err) { - done(client); - callback(err); - return; - } - +PostgresDB.prototype.getOps = async function(collection, id, from, to, options, callback) { + from ||= 0; + options ||= {}; + const wantsMetadata = options.metadata; + try { var cmd = 'SELECT version, operation FROM ops WHERE collection = $1 AND doc_id = $2 AND version > $3 '; var params = [collection, id, from]; if(to || to == 0) { cmd += ' AND version <= $4'; params.push(to)} cmd += ' order by version'; - client.query( cmd, params, - function(err, res) { - done(); - if (err) { - callback(err); - return; - } - callback(null, res.rows.map(function(row) { - return row.operation; - })); - } - ) - }) + const result = await this._pool.query(cmd, params); + callback(null, result.rows.map(({operation}) => { + if (!wantsMetadata) delete operation.m; + return operation; + })); + } catch (error) { + callback(error); + } }; - -function PostgresSnapshot(id, version, type, data, meta) { - this.id = id; - this.v = version; - this.type = type; - this.data = data; - this.m = meta; -} diff --git a/index.spec.js b/index.spec.js new file mode 100644 index 0000000..b21888c --- /dev/null +++ b/index.spec.js @@ -0,0 +1,37 @@ +const PostgresDB = require('.'); +const {Pool} = require('pg'); +const fs = require('node:fs'); + +const DB_NAME = 'sharedbtest'; + +function create(callback) { + var db = new PostgresDB({database: DB_NAME}); + callback(null, db); +}; + +describe('PostgresDB', function() { + let pool; + let client; + + beforeEach(async () => { + pool = new Pool({database: 'postgres'}); + client = await pool.connect(); + await client.query(`DROP DATABASE IF EXISTS ${DB_NAME}`); + await client.query(`CREATE DATABASE ${DB_NAME}`); + + const testPool = new Pool({database: DB_NAME}); + const testClient = await testPool.connect(); + const structure = fs.readFileSync('./structure.sql', 'utf8'); + await testClient.query(structure); + await testClient.release(true); + await testPool.end(); + }); + + afterEach(async function() { + await client.query(`DROP DATABASE IF EXISTS ${DB_NAME}`); + await client.release(true); + await pool.end(); + }); + + require('sharedb/test/db')({create: create}); +}); diff --git a/package.json b/package.json index 2c9e6d7..1584dbe 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "PostgreSQL adapter for ShareDB. forked from share/sharedb-postgres", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "mocha" }, "author": "Jeremy Apthorp ", "license": "MIT", @@ -19,8 +19,14 @@ "url": "https://github.com/share/sharedb-postgres" }, "dependencies": { - "pg": "^8.5.1", - "pg-pool": "^3.2.1", + "pg": "^8.12.0", "sharedb": "^1.6.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0" + }, + "devDependencies": { + "chai": "^4.4.1", + "mocha": "^10.4.0", + "ot-json1": "^1.0.2", + "rich-text": "^4.1.0", + "sinon": "^18.0.0" } } diff --git a/structure.sql b/structure.sql index c071b4e..fe1c932 100644 --- a/structure.sql +++ b/structure.sql @@ -26,3 +26,17 @@ ALTER TABLE snapshots ALTER COLUMN data SET DATA TYPE jsonb USING data::jsonb; + + +-- v5.0.0 -- + +ALTER TABLE snapshots + ALTER column doc_type + DROP NOT NULL; + +ALTER TABLE snapshots + ALTER column data + DROP NOT NULL; + +ALTER TABLE snapshots + ADD metadata jsonb; diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..0dfcb5a --- /dev/null +++ b/test/setup.js @@ -0,0 +1,10 @@ +var logger = require('sharedb/lib/logger'); + +if (process.env.LOGGING !== 'true') { + // Silence the logger for tests by setting all its methods to no-ops + logger.setMethods({ + info: function() {}, + warn: function() {}, + error: function() {} + }); +} From 166bb8f0f18732c651780c347e6af34a38479a5a Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:17:04 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=80=EF=B8=8F=20R?= =?UTF-8?q?emove=20test=20CI=20branch=20trigger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b37cd3..88d12aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - setup-ci # TODO: Remove pull_request: branches: - main From 58ee94586a4bc9d4ea628cf18db4e5e36fa018ea Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:17:12 +0100 Subject: [PATCH 4/6] 5.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1584dbe..3459416 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sharedb-postgres", - "version": "4.1.0", + "version": "5.0.0", "description": "PostgreSQL adapter for ShareDB. forked from share/sharedb-postgres", "main": "index.js", "scripts": { From e7c2d878bcbf00b2bf5f97a200356a9a5f481878 Mon Sep 17 00:00:00 2001 From: cuihom <1036633142@qq.com> Date: Fri, 18 Oct 2024 16:38:27 +0800 Subject: [PATCH 5/6] Update index.js When updating the snapshot table, the metadata field was mistakenly updated to the data field --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1b0f0a2..0a093b1 100644 --- a/index.js +++ b/index.js @@ -80,7 +80,7 @@ PostgresDB.prototype.commit = async function(collection, id, op, snapshot, optio WHERE collection = $1 AND doc_id = $2 FOR UPDATE ) - ON CONFLICT (collection, doc_id) DO UPDATE SET version = $3, data = $5, doc_type = $4, metadata = $5 + ON CONFLICT (collection, doc_id) DO UPDATE SET version = $3, data = $5, doc_type = $4, metadata = $6 RETURNING version ) INSERT INTO ops (collection, doc_id, version, operation) From f98498aec295ca2cc847d0752541311f0a4dcc2f Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:39:36 +0100 Subject: [PATCH 6/6] 5.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3459416..f83872a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sharedb-postgres", - "version": "5.0.0", + "version": "5.0.1", "description": "PostgreSQL adapter for ShareDB. forked from share/sharedb-postgres", "main": "index.js", "scripts": {