@prairielearn/postgres 1.9.4 → 2.0.1
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.
- package/.mocharc.cjs +3 -0
- package/CHANGELOG.md +12 -0
- package/README.md +0 -4
- package/dist/default-pool.d.ts +2 -2
- package/dist/default-pool.js +61 -65
- package/dist/default-pool.js.map +1 -1
- package/dist/default-pool.test.js +11 -35
- package/dist/default-pool.test.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -25
- package/dist/index.js.map +1 -1
- package/dist/loader.js +9 -17
- package/dist/loader.js.map +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +51 -59
- package/dist/pool.js.map +1 -1
- package/dist/pool.test.js +64 -70
- package/dist/pool.test.js.map +1 -1
- package/dist/test-utils.js +6 -36
- package/dist/test-utils.js.map +1 -1
- package/package.json +12 -11
- package/src/default-pool.test.ts +4 -2
- package/src/default-pool.ts +1 -1
- package/src/index.ts +9 -5
- package/src/pool.test.ts +11 -11
- package/src/pool.ts +10 -9
- package/src/test-utils.ts +1 -1
package/.mocharc.cjs
ADDED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -59,10 +59,6 @@ const sql = sqldb.loadSqlEquiv(import.meta.url);
|
|
|
59
59
|
|
|
60
60
|
console.log(sql.select_user);
|
|
61
61
|
console.log(sql.select_course);
|
|
62
|
-
|
|
63
|
-
// Or, if you're working in a CommonJS file:
|
|
64
|
-
const sqldb = require('@prairielearn/postgres');
|
|
65
|
-
const sql = sqldb.loadSqlEquiv(__filename);
|
|
66
62
|
```
|
|
67
63
|
|
|
68
64
|
### Making queries
|
package/dist/default-pool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PostgresPool, type CursorIterator, type QueryParams } from './pool';
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { PostgresPool, type CursorIterator, type QueryParams } from './pool.js';
|
|
3
3
|
declare const defaultPool: PostgresPool;
|
|
4
4
|
export { defaultPool, type CursorIterator, type QueryParams };
|
|
5
5
|
export declare const init: (arg1: import("pg").PoolConfig, arg2: (error: Error, client: import("pg").PoolClient) => void, callback: (err: NodeJS.ErrnoException) => void) => void;
|
package/dist/default-pool.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.setRandomSearchSchemaAsync = exports.setRandomSearchSchema = exports.getSearchSchema = exports.setSearchSchema = exports.queryValidatedCursor = exports.queryCursor = exports.queryCursorWithClient = exports.callOptionalRow = exports.callRow = void 0;
|
|
5
|
-
const pool_1 = require("./pool");
|
|
6
|
-
const defaultPool = new pool_1.PostgresPool();
|
|
7
|
-
exports.defaultPool = defaultPool;
|
|
1
|
+
import { PostgresPool } from './pool.js';
|
|
2
|
+
const defaultPool = new PostgresPool();
|
|
3
|
+
export { defaultPool };
|
|
8
4
|
// We re-expose all functions from the default pool here to account for the
|
|
9
5
|
// default case of a shared global pool of clients. If someone want to create
|
|
10
6
|
// their own pool, we expose the `PostgresPool` class.
|
|
@@ -13,62 +9,62 @@ exports.defaultPool = defaultPool;
|
|
|
13
9
|
// that they'll be invoked with the correct `this` context, specifically when
|
|
14
10
|
// this module is imported as `import * as db from '...'` and that import is
|
|
15
11
|
// subsequently transformed by Babel to `interopRequireWildcard(...)`.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
12
|
+
export const init = defaultPool.init.bind(defaultPool);
|
|
13
|
+
export const initAsync = defaultPool.initAsync.bind(defaultPool);
|
|
14
|
+
export const close = defaultPool.close.bind(defaultPool);
|
|
15
|
+
export const closeAsync = defaultPool.closeAsync.bind(defaultPool);
|
|
16
|
+
export const getClientAsync = defaultPool.getClientAsync.bind(defaultPool);
|
|
17
|
+
export const getClient = defaultPool.getClient.bind(defaultPool);
|
|
18
|
+
export const queryWithClient = defaultPool.queryWithClient.bind(defaultPool);
|
|
19
|
+
export const queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);
|
|
20
|
+
export const queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);
|
|
21
|
+
export const queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);
|
|
22
|
+
export const queryWithClientZeroOrOneRow = defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);
|
|
23
|
+
export const queryWithClientZeroOrOneRowAsync = defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);
|
|
24
|
+
export const rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);
|
|
25
|
+
export const rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);
|
|
26
|
+
export const beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);
|
|
27
|
+
export const endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);
|
|
28
|
+
export const endTransaction = defaultPool.endTransaction.bind(defaultPool);
|
|
29
|
+
export const runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);
|
|
30
|
+
export const query = defaultPool.query.bind(defaultPool);
|
|
31
|
+
export const queryAsync = defaultPool.queryAsync.bind(defaultPool);
|
|
32
|
+
export const queryOneRow = defaultPool.queryOneRow.bind(defaultPool);
|
|
33
|
+
export const queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);
|
|
34
|
+
export const queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);
|
|
35
|
+
export const queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);
|
|
36
|
+
export const call = defaultPool.call.bind(defaultPool);
|
|
37
|
+
export const callAsync = defaultPool.callAsync.bind(defaultPool);
|
|
38
|
+
export const callOneRow = defaultPool.callOneRow.bind(defaultPool);
|
|
39
|
+
export const callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);
|
|
40
|
+
export const callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);
|
|
41
|
+
export const callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);
|
|
42
|
+
export const callWithClient = defaultPool.callWithClient.bind(defaultPool);
|
|
43
|
+
export const callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);
|
|
44
|
+
export const callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);
|
|
45
|
+
export const callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);
|
|
46
|
+
export const callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);
|
|
47
|
+
export const callWithClientZeroOrOneRowAsync = defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);
|
|
48
|
+
export const queryValidatedRows = defaultPool.queryValidatedRows.bind(defaultPool);
|
|
49
|
+
export const queryValidatedOneRow = defaultPool.queryValidatedOneRow.bind(defaultPool);
|
|
50
|
+
export const queryValidatedZeroOrOneRow = defaultPool.queryValidatedZeroOrOneRow.bind(defaultPool);
|
|
51
|
+
export const queryValidatedSingleColumnRows = defaultPool.queryValidatedSingleColumnRows.bind(defaultPool);
|
|
52
|
+
export const queryValidatedSingleColumnOneRow = defaultPool.queryValidatedSingleColumnOneRow.bind(defaultPool);
|
|
53
|
+
export const queryValidatedSingleColumnZeroOrOneRow = defaultPool.queryValidatedSingleColumnZeroOrOneRow.bind(defaultPool);
|
|
54
|
+
export const callValidatedRows = defaultPool.callValidatedRows.bind(defaultPool);
|
|
55
|
+
export const callValidatedOneRow = defaultPool.callValidatedOneRow.bind(defaultPool);
|
|
56
|
+
export const callValidatedZeroOrOneRow = defaultPool.callValidatedZeroOrOneRow.bind(defaultPool);
|
|
57
|
+
export const queryRows = defaultPool.queryRows.bind(defaultPool);
|
|
58
|
+
export const queryRow = defaultPool.queryRow.bind(defaultPool);
|
|
59
|
+
export const queryOptionalRow = defaultPool.queryOptionalRow.bind(defaultPool);
|
|
60
|
+
export const callRows = defaultPool.callRows.bind(defaultPool);
|
|
61
|
+
export const callRow = defaultPool.callRow.bind(defaultPool);
|
|
62
|
+
export const callOptionalRow = defaultPool.callOptionalRow.bind(defaultPool);
|
|
63
|
+
export const queryCursorWithClient = defaultPool.queryCursorWithClient.bind(defaultPool);
|
|
64
|
+
export const queryCursor = defaultPool.queryCursor.bind(defaultPool);
|
|
65
|
+
export const queryValidatedCursor = defaultPool.queryValidatedCursor.bind(defaultPool);
|
|
66
|
+
export const setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);
|
|
67
|
+
export const getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);
|
|
68
|
+
export const setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);
|
|
69
|
+
export const setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);
|
|
74
70
|
//# sourceMappingURL=default-pool.js.map
|
package/dist/default-pool.js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,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,CAAC,0BAA0B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { PostgresPool, type CursorIterator, type QueryParams } from './pool.js';\n\nconst defaultPool = new PostgresPool();\nexport { defaultPool, type CursorIterator, type QueryParams };\n\n// We re-expose all functions from the default pool here to account for the\n// default case of a shared global pool of clients. If someone want to create\n// their own pool, we expose the `PostgresPool` class.\n//\n// Note that we explicitly bind all functions to `defaultPool`. This ensures\n// that they'll be invoked with the correct `this` context, specifically when\n// this module is imported as `import * as db from '...'` and that import is\n// subsequently transformed by Babel to `interopRequireWildcard(...)`.\nexport const init = defaultPool.init.bind(defaultPool);\nexport const initAsync = defaultPool.initAsync.bind(defaultPool);\nexport const close = defaultPool.close.bind(defaultPool);\nexport const closeAsync = defaultPool.closeAsync.bind(defaultPool);\nexport const getClientAsync = defaultPool.getClientAsync.bind(defaultPool);\nexport const getClient = defaultPool.getClient.bind(defaultPool);\nexport const queryWithClient = defaultPool.queryWithClient.bind(defaultPool);\nexport const queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);\nexport const queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);\nexport const queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);\nexport const queryWithClientZeroOrOneRow =\n defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);\nexport const queryWithClientZeroOrOneRowAsync =\n defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);\nexport const rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);\nexport const rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);\nexport const beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);\nexport const endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);\nexport const endTransaction = defaultPool.endTransaction.bind(defaultPool);\nexport const runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);\nexport const query = defaultPool.query.bind(defaultPool);\nexport const queryAsync = defaultPool.queryAsync.bind(defaultPool);\nexport const queryOneRow = defaultPool.queryOneRow.bind(defaultPool);\nexport const queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);\nexport const queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);\nexport const queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);\nexport const call = defaultPool.call.bind(defaultPool);\nexport const callAsync = defaultPool.callAsync.bind(defaultPool);\nexport const callOneRow = defaultPool.callOneRow.bind(defaultPool);\nexport const callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);\nexport const callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);\nexport const callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);\nexport const callWithClient = defaultPool.callWithClient.bind(defaultPool);\nexport const callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);\nexport const callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);\nexport const callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);\nexport const callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);\nexport const callWithClientZeroOrOneRowAsync =\n defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);\nexport const queryValidatedRows = defaultPool.queryValidatedRows.bind(defaultPool);\nexport const queryValidatedOneRow = defaultPool.queryValidatedOneRow.bind(defaultPool);\nexport const queryValidatedZeroOrOneRow = defaultPool.queryValidatedZeroOrOneRow.bind(defaultPool);\nexport const queryValidatedSingleColumnRows =\n defaultPool.queryValidatedSingleColumnRows.bind(defaultPool);\nexport const queryValidatedSingleColumnOneRow =\n defaultPool.queryValidatedSingleColumnOneRow.bind(defaultPool);\nexport const queryValidatedSingleColumnZeroOrOneRow =\n defaultPool.queryValidatedSingleColumnZeroOrOneRow.bind(defaultPool);\nexport const callValidatedRows = defaultPool.callValidatedRows.bind(defaultPool);\nexport const callValidatedOneRow = defaultPool.callValidatedOneRow.bind(defaultPool);\nexport const callValidatedZeroOrOneRow = defaultPool.callValidatedZeroOrOneRow.bind(defaultPool);\nexport const queryRows = defaultPool.queryRows.bind(defaultPool);\nexport const queryRow = defaultPool.queryRow.bind(defaultPool);\nexport const queryOptionalRow = defaultPool.queryOptionalRow.bind(defaultPool);\nexport const callRows = defaultPool.callRows.bind(defaultPool);\nexport const callRow = defaultPool.callRow.bind(defaultPool);\nexport const callOptionalRow = defaultPool.callOptionalRow.bind(defaultPool);\nexport const queryCursorWithClient = defaultPool.queryCursorWithClient.bind(defaultPool);\nexport const queryCursor = defaultPool.queryCursor.bind(defaultPool);\nexport const queryValidatedCursor = defaultPool.queryValidatedCursor.bind(defaultPool);\nexport const setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);\nexport const getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);\nexport const setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);\nexport const setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);\n"]}
|
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const chai_1 = require("chai");
|
|
27
|
-
const pool_1 = require("./pool");
|
|
28
|
-
const pgPool = __importStar(require("./default-pool"));
|
|
1
|
+
import { assert } from 'chai';
|
|
2
|
+
import * as pgPool from './default-pool.js';
|
|
3
|
+
import { PostgresPool } from './pool.js';
|
|
29
4
|
/**
|
|
30
5
|
* Properties on {@link PostgresPool} that should not be available on the default
|
|
31
6
|
* pool's exports.
|
|
32
7
|
*/
|
|
33
8
|
const HIDDEN_PROPERTIES = new Set([
|
|
9
|
+
'constructor',
|
|
34
10
|
// Private members
|
|
35
11
|
'pool',
|
|
36
12
|
'alsClient',
|
|
@@ -45,29 +21,29 @@ const HIDDEN_PROPERTIES = new Set([
|
|
|
45
21
|
]);
|
|
46
22
|
describe('sqldb', () => {
|
|
47
23
|
it('exports the full PostgresPool interface', () => {
|
|
48
|
-
const pool = new
|
|
24
|
+
const pool = new PostgresPool();
|
|
49
25
|
Object.getOwnPropertyNames(pool)
|
|
50
26
|
.filter((n) => !HIDDEN_PROPERTIES.has(n))
|
|
51
27
|
.forEach((prop) => {
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
assert.property(pgPool, prop);
|
|
29
|
+
assert.ok(pgPool[prop]);
|
|
54
30
|
});
|
|
55
31
|
Object.getOwnPropertyNames(Object.getPrototypeOf(pool))
|
|
56
32
|
.filter((n) => !HIDDEN_PROPERTIES.has(n))
|
|
57
33
|
.forEach((prop) => {
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
assert.property(pgPool, prop);
|
|
35
|
+
assert.ok(pgPool[prop]);
|
|
60
36
|
});
|
|
61
37
|
});
|
|
62
38
|
it('should not have extra properties', () => {
|
|
63
|
-
const pool = new
|
|
39
|
+
const pool = new PostgresPool();
|
|
64
40
|
const knownProperties = [
|
|
65
41
|
...Object.getOwnPropertyNames(pool),
|
|
66
42
|
...Object.getOwnPropertyNames(Object.getPrototypeOf(pool)),
|
|
67
43
|
'PostgresPool',
|
|
68
44
|
];
|
|
69
45
|
Object.getOwnPropertyNames(pool).forEach((prop) => {
|
|
70
|
-
|
|
46
|
+
assert.include(knownProperties, prop);
|
|
71
47
|
});
|
|
72
48
|
});
|
|
73
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-pool.test.js","sourceRoot":"","sources":["../src/default-pool.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-pool.test.js","sourceRoot":"","sources":["../src/default-pool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,aAAa;IACb,kBAAkB;IAClB,MAAM;IACN,WAAW;IACX,cAAc;IACd,aAAa;IACb,8BAA8B;IAC9B,UAAU;IACV,YAAY;IACZ,WAAW;IACX,cAAc;IACd,YAAY;CACb,CAAC,CAAC;AAEH,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,IAAI,GAAG,IAAI,YAAY,EAAE,CAAC;QAEhC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACxC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,MAAM,CAAC,EAAE,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEL,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;aACpD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACxC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,MAAM,CAAC,EAAE,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAI,YAAY,EAAE,CAAC;QAEhC,MAAM,eAAe,GAAG;YACtB,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;YACnC,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC1D,cAAc;SACf,CAAC;QAEF,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAChD,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { assert } from 'chai';\n\nimport * as pgPool from './default-pool.js';\nimport { PostgresPool } from './pool.js';\n\n/**\n * Properties on {@link PostgresPool} that should not be available on the default\n * pool's exports.\n */\nconst HIDDEN_PROPERTIES = new Set([\n 'constructor',\n // Private members\n 'pool',\n 'alsClient',\n 'searchSchema',\n '_queryCount',\n 'queryValidatedCursorInternal',\n // Getters\n 'totalCount',\n 'idleCount',\n 'waitingCount',\n 'queryCount',\n]);\n\ndescribe('sqldb', () => {\n it('exports the full PostgresPool interface', () => {\n const pool = new PostgresPool();\n\n Object.getOwnPropertyNames(pool)\n .filter((n) => !HIDDEN_PROPERTIES.has(n))\n .forEach((prop) => {\n assert.property(pgPool, prop);\n assert.ok((pgPool as any)[prop]);\n });\n\n Object.getOwnPropertyNames(Object.getPrototypeOf(pool))\n .filter((n) => !HIDDEN_PROPERTIES.has(n))\n .forEach((prop) => {\n assert.property(pgPool, prop);\n assert.ok((pgPool as any)[prop]);\n });\n });\n\n it('should not have extra properties', () => {\n const pool = new PostgresPool();\n\n const knownProperties = [\n ...Object.getOwnPropertyNames(pool),\n ...Object.getOwnPropertyNames(Object.getPrototypeOf(pool)),\n 'PostgresPool',\n ];\n\n Object.getOwnPropertyNames(pool).forEach((prop) => {\n assert.include(knownProperties, prop);\n });\n });\n});\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PoolClient } from 'pg';
|
|
2
|
-
export { loadSql, loadSqlEquiv } from './loader';
|
|
3
|
-
export { PostgresPool } from './pool';
|
|
4
|
-
export * from './default-pool';
|
|
5
|
-
export { makePostgresTestUtils, PostgresTestUtils, PostgresTestUtilsOptions } from './test-utils';
|
|
1
|
+
export { type PoolClient } from 'pg';
|
|
2
|
+
export { loadSql, loadSqlEquiv } from './loader.js';
|
|
3
|
+
export { PostgresPool } from './pool.js';
|
|
4
|
+
export * from './default-pool.js';
|
|
5
|
+
export { makePostgresTestUtils, type PostgresTestUtils, type PostgresTestUtilsOptions, } from './test-utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.makePostgresTestUtils = exports.PostgresPool = exports.loadSqlEquiv = exports.loadSql = void 0;
|
|
18
|
-
var loader_1 = require("./loader");
|
|
19
|
-
Object.defineProperty(exports, "loadSql", { enumerable: true, get: function () { return loader_1.loadSql; } });
|
|
20
|
-
Object.defineProperty(exports, "loadSqlEquiv", { enumerable: true, get: function () { return loader_1.loadSqlEquiv; } });
|
|
21
|
-
var pool_1 = require("./pool");
|
|
22
|
-
Object.defineProperty(exports, "PostgresPool", { enumerable: true, get: function () { return pool_1.PostgresPool; } });
|
|
23
|
-
__exportStar(require("./default-pool"), exports);
|
|
24
|
-
var test_utils_1 = require("./test-utils");
|
|
25
|
-
Object.defineProperty(exports, "makePostgresTestUtils", { enumerable: true, get: function () { return test_utils_1.makePostgresTestUtils; } });
|
|
1
|
+
export { loadSql, loadSqlEquiv } from './loader.js';
|
|
2
|
+
export { PostgresPool } from './pool.js';
|
|
3
|
+
export * from './default-pool.js';
|
|
4
|
+
export { makePostgresTestUtils, } from './test-utils.js';
|
|
26
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EACL,qBAAqB,GAGtB,MAAM,iBAAiB,CAAC","sourcesContent":["export { type PoolClient } from 'pg';\n\nexport { loadSql, loadSqlEquiv } from './loader.js';\nexport { PostgresPool } from './pool.js';\n\nexport * from './default-pool.js';\n\nexport {\n makePostgresTestUtils,\n type PostgresTestUtils,\n type PostgresTestUtilsOptions,\n} from './test-utils.js';\n"]}
|
package/dist/loader.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadSqlEquiv = exports.loadSql = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const node_url_1 = __importDefault(require("node:url"));
|
|
10
|
-
function loadSql(filename) {
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import url from 'node:url';
|
|
4
|
+
export function loadSql(filename) {
|
|
11
5
|
const sql = {};
|
|
12
|
-
sql.all =
|
|
6
|
+
sql.all = fs.readFileSync(filename, 'utf8');
|
|
13
7
|
const lines = sql.all.split(/\r?\n/);
|
|
14
8
|
const blockRE = /^ *-- *BLOCK +([^ ]+) *$/;
|
|
15
9
|
let blockName = null;
|
|
@@ -27,18 +21,16 @@ function loadSql(filename) {
|
|
|
27
21
|
});
|
|
28
22
|
return sql;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
function loadSqlEquiv(filePathOrUrl) {
|
|
24
|
+
export function loadSqlEquiv(filePathOrUrl) {
|
|
32
25
|
let resolvedPath = filePathOrUrl;
|
|
33
26
|
// This allows for us to pass `import.meta.url` to this function in ES Modules
|
|
34
27
|
// environments where `__filename` is not available.
|
|
35
28
|
if (filePathOrUrl.startsWith('file://')) {
|
|
36
|
-
resolvedPath =
|
|
29
|
+
resolvedPath = url.fileURLToPath(filePathOrUrl);
|
|
37
30
|
}
|
|
38
|
-
const components =
|
|
31
|
+
const components = path.parse(resolvedPath);
|
|
39
32
|
components.ext = '.sql';
|
|
40
|
-
const sqlFilename =
|
|
33
|
+
const sqlFilename = path.join(components.dir, components.name) + components.ext;
|
|
41
34
|
return loadSql(sqlFilename);
|
|
42
35
|
}
|
|
43
|
-
exports.loadSqlEquiv = loadSqlEquiv;
|
|
44
36
|
//# sourceMappingURL=loader.js.map
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAI3B,MAAM,UAAU,OAAO,CAAC,QAAgB;IACtC,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,0BAA0B,CAAC;IAC3C,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,MAAM,EAAE,CAAC;YACX,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,GAAG,CAAC,SAAS,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,2BAA2B,SAAS,EAAE,CAAC,CAAC;YACvF,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC;aAAM,IAAI,SAAS,EAAE,CAAC;YACrB,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,IAAI,YAAY,GAAG,aAAa,CAAC;IAEjC,8EAA8E;IAC9E,oDAAoD;IACpD,IAAI,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,YAAY,GAAG,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC;IACxB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC;IAChF,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport url from 'node:url';\n\ntype SqlFile = Record<string, string>;\n\nexport function loadSql(filename: string): SqlFile {\n const sql: SqlFile = {};\n sql.all = fs.readFileSync(filename, 'utf8');\n const lines = sql.all.split(/\\r?\\n/);\n const blockRE = /^ *-- *BLOCK +([^ ]+) *$/;\n let blockName: string | null = null;\n lines.forEach((line) => {\n const result = blockRE.exec(line);\n if (result) {\n blockName = result[1];\n if (sql[blockName]) throw new Error(`${filename}: duplicate BLOCK name: ${blockName}`);\n sql[blockName] = line;\n } else if (blockName) {\n sql[blockName] += '\\n' + line;\n }\n });\n return sql;\n}\n\nexport function loadSqlEquiv(filePathOrUrl: string): SqlFile {\n let resolvedPath = filePathOrUrl;\n\n // This allows for us to pass `import.meta.url` to this function in ES Modules\n // environments where `__filename` is not available.\n if (filePathOrUrl.startsWith('file://')) {\n resolvedPath = url.fileURLToPath(filePathOrUrl);\n }\n\n const components = path.parse(resolvedPath);\n components.ext = '.sql';\n const sqlFilename = path.join(components.dir, components.name) + components.ext;\n return loadSql(sqlFilename);\n}\n"]}
|
package/dist/pool.d.ts
CHANGED