ueberdb2 4.0.17 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +4 -1
  2. package/.eslintignore +0 -2
  3. package/.eslintrc.cjs +0 -66
  4. package/.github/dependabot.yml +0 -11
  5. package/.github/workflows/npmpublish.yml +0 -134
  6. package/.travis.yml +0 -46
  7. package/CHANGELOG.md +0 -304
  8. package/CONTRIBUTING.md +0 -103
  9. package/SECURITY.md +0 -5
  10. package/databases/cassandra_db.ts +0 -265
  11. package/databases/couch_db.ts +0 -189
  12. package/databases/dirty_db.ts +0 -85
  13. package/databases/dirty_git_db.ts +0 -82
  14. package/databases/elasticsearch_db.ts +0 -257
  15. package/databases/memory_db.ts +0 -41
  16. package/databases/mock_db.ts +0 -43
  17. package/databases/mongodb_db.ts +0 -142
  18. package/databases/mssql_db.ts +0 -226
  19. package/databases/mysql_db.ts +0 -183
  20. package/databases/postgres_db.ts +0 -213
  21. package/databases/postgrespool_db.ts +0 -11
  22. package/databases/redis_db.ts +0 -129
  23. package/databases/rethink_db.ts +0 -114
  24. package/databases/sqlite_db.ts +0 -159
  25. package/docker-compose.yml +0 -44
  26. package/index.ts +0 -224
  27. package/lib/AbstractDatabase.ts +0 -79
  28. package/lib/CacheAndBufferLayer.ts +0 -665
  29. package/lib/logging.ts +0 -33
  30. package/test/lib/databases.ts +0 -73
  31. package/test/lib/mysql.sql +0 -84
  32. package/test/test.ts +0 -328
  33. package/test/test_bulk.ts +0 -69
  34. package/test/test_elasticsearch.ts +0 -128
  35. package/test/test_findKeys.ts +0 -41
  36. package/test/test_flush.ts +0 -55
  37. package/test/test_getSub.ts +0 -28
  38. package/test/test_lru.ts +0 -151
  39. package/test/test_memory.ts +0 -32
  40. package/test/test_metrics.ts +0 -734
  41. package/test/test_mysql.ts +0 -62
  42. package/test/test_postgres.ts +0 -16
  43. package/test/test_setSub.ts +0 -19
  44. package/test/test_tojson.ts +0 -34
@@ -1,62 +0,0 @@
1
- import assert$0 from 'assert';
2
- import {databases} from './lib/databases';
3
- import * as mysql from '../databases/mysql_db';
4
- 'use strict';
5
- const assert = assert$0.strict;
6
- describe(__filename, () => {
7
- beforeEach(async function (this: any) {
8
- if (databases.mysql == null) return this.skip();
9
- });
10
- it('connect error is detected during init()', async () => {
11
- // Use an invalid TCP port to force a connection error.
12
- const db = new mysql.Database({...databases.mysql, port: 65536});
13
- // An error is expected; prevent it from being logged.
14
- db.logger = Object.setPrototypeOf({error() { }}, db.logger);
15
- await assert.rejects(db.init());
16
- });
17
- it('query after fatal error works', async () => {
18
- const db = new mysql.Database(databases.mysql);
19
- await db.init();
20
- // An error is expected; prevent it from being logged.
21
- db.logger = Object.setPrototypeOf({error() { }}, db.logger);
22
- // Sleep longer than the timeout to force a fatal error.
23
- await assert.rejects(db._query({sql: 'DO SLEEP(1);', timeout: 1}), {fatal: true});
24
- await assert.doesNotReject(db._query({sql: 'SELECT 1;'}));
25
- await db.close();
26
- });
27
- it('query times out', async () => {
28
- const db = new mysql.Database(databases.mysql);
29
- await db.init();
30
- // Timeout error messages are expected; prevent them from being logged.
31
- db.logger = Object.setPrototypeOf({error() { }}, db.logger);
32
- db.settings.queryTimeout = 100;
33
- await assert.doesNotReject(db._query({sql: 'DO SLEEP(0.090);'}));
34
- await assert.rejects(db._query({sql: 'DO SLEEP(0.110);'}));
35
- await db.close();
36
- });
37
- it('queries run concurrently and are queued when pool is busy', async () => {
38
- const connectionLimit = 10;
39
- // @ts-expect-error TS(2339): Property 'Database' does not exist on type 'typeof... Remove this comment to see the full error message
40
- const db = new mysql.Database({...databases.mysql, connectionLimit});
41
- await db.init();
42
- // Set the query duration high enough to avoid flakiness on slow machines but low enough to keep
43
- // the overall test duration short.
44
- const queryDuration = 100;
45
- db.settings.queryTimeout = queryDuration + 100;
46
- const enqueueQuery = () => db._query({sql: `DO SLEEP(${queryDuration / 1000});`});
47
- // Reduce test flakiness by using slow queries to warm up the pool's connections.
48
- await Promise.all([...Array(connectionLimit)].map(enqueueQuery));
49
- // Time how long it takes to run just under 2 * connectionLimit queries.
50
- const nQueries = 2 * connectionLimit - 1;
51
- const start = Date.now();
52
- await Promise.all([...Array(nQueries)].map(enqueueQuery));
53
- const duration = Date.now() - start;
54
- const wantDurationLower = Math.ceil(nQueries / connectionLimit) * queryDuration;
55
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
56
- assert(duration >= wantDurationLower, `took ${duration}ms, want >= ${wantDurationLower}ms`);
57
- const wantDurationUpper = wantDurationLower + queryDuration;
58
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
59
- assert(duration < wantDurationUpper, `took ${duration}ms, want < ${wantDurationUpper}ms`);
60
- await db.close();
61
- });
62
- });
@@ -1,16 +0,0 @@
1
- import {databases} from './lib/databases';
2
- import * as ueberdb from '../index';
3
- 'use strict';
4
- import {equal} from 'assert';
5
-
6
- describe(__filename, () => {
7
- it('connection string instead of settings object', async () => {
8
- const {user, password, host, database} = databases.postgres;
9
- console.log(`postgres://${user}:${password}@${host}/${database}`);
10
- const db = new ueberdb.Database('postgres', `postgres://${user}:${password}@${host}/${database}`);
11
- await db.init();
12
- await db.set('key', 'val');
13
- const val = await db.get('key') as string;
14
- equal(val, 'val');
15
- });
16
- });
@@ -1,19 +0,0 @@
1
- import assert$0 from 'assert';
2
- import * as ueberdb from '../index';
3
- 'use strict';
4
- const assert = assert$0.strict;
5
- describe(__filename, () => {
6
- let db: any;
7
- beforeEach(async () => {
8
- db = new ueberdb.Database('memory', {}, {});
9
- await db.init();
10
- });
11
- afterEach(async () => {
12
- if (db != null) await db.close();
13
- db = null;
14
- });
15
- it('setSub rejects __proto__', async () => {
16
- await db.set('k', {});
17
- await assert.rejects(db.setSub('k', ['__proto__'], 'v'));
18
- });
19
- });
@@ -1,34 +0,0 @@
1
- import assert$0 from 'assert';
2
- import * as ueberdb from '../index';
3
- 'use strict';
4
- const assert = assert$0.strict;
5
- describe(__filename, () => {
6
- let db: any = null;
7
- before(async () => {
8
- db = new ueberdb.Database('memory', {}, {});
9
- await db.init();
10
- });
11
- after(async () => {
12
- await db.close();
13
- });
14
- it('no .toJSON method', async () => {
15
- await db.set('key', {prop: 'value'});
16
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
17
- assert.deepEqual(await db.get('key'), {prop: 'value'});
18
- });
19
- it('direct', async () => {
20
- await db.set('key', {toJSON: (arg: any) => `toJSON ${arg}`});
21
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
22
- assert.equal(await db.get('key'), 'toJSON ');
23
- });
24
- it('object property', async () => {
25
- await db.set('key', {prop: {toJSON: (arg: any) => `toJSON ${arg}`}});
26
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
27
- assert.deepEqual(await db.get('key'), {prop: 'toJSON prop'});
28
- });
29
- it('array entry', async () => {
30
- await db.set('key', [{toJSON: (arg: any) => `toJSON ${arg}`}]);
31
- // @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
32
- assert.deepEqual(await db.get('key'), ['toJSON 0']);
33
- });
34
- });