declapract-typescript-ehmpathy 0.43.2 → 0.43.3
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/dist/practices/config/best-practice/src/utils/config/getConfig.ts +1 -1
- package/dist/practices/errors/bad-practices/error-fns/package.json +5 -0
- package/dist/practices/errors/bad-practices/error-fns/package.json.declapract.ts +23 -0
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/getDatabaseConnection.ts +5 -5
- package/dist/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseTransaction.ts +1 -1
- package/dist/practices/tests/best-practice/jest.acceptance.config.ts +1 -1
- package/dist/practices/tests/best-practice/jest.integration.config.ts +1 -1
- package/dist/practices/tests/best-practice/jest.unit.config.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import ConfigCache from 'config-with-paramstore';
|
|
3
3
|
|
|
4
4
|
import { getEnvironment } from '../environment';
|
|
5
|
-
import {
|
|
5
|
+
import type { Config } from './Config';
|
|
6
6
|
|
|
7
7
|
export const configInstance = new ConfigCache();
|
|
8
8
|
export const getConfig = async (): Promise<Config> =>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import { FileCheckType, FileFixFunction } from 'declapract';
|
|
3
|
+
|
|
4
|
+
export const check = FileCheckType.CONTAINS;
|
|
5
|
+
|
|
6
|
+
export const fix: FileFixFunction = (contents) => {
|
|
7
|
+
if (!contents) return { contents }; // do nothing if no contents
|
|
8
|
+
const packageJSON = JSON.parse(contents);
|
|
9
|
+
const updatedPackageJSON = {
|
|
10
|
+
...packageJSON,
|
|
11
|
+
dependencies: {
|
|
12
|
+
...packageJSON.dependencies,
|
|
13
|
+
'@ehmpathy/error-fns': undefined,
|
|
14
|
+
},
|
|
15
|
+
devDependencies: {
|
|
16
|
+
...packageJSON.devDependencies,
|
|
17
|
+
'@ehmpathy/error-fns': undefined,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
contents: JSON.stringify(updatedPackageJSON, null, 2),
|
|
22
|
+
};
|
|
23
|
+
};
|
package/dist/practices/persist-with-rds/best-practice/src/utils/database/getDatabaseConnection.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HelpfulError, UnexpectedCodePathError } from 'helpful-errors';
|
|
2
|
-
import pg, { Client, QueryResult, QueryResultRow } from 'pg';
|
|
2
|
+
import pg, { Client, type QueryResult, type QueryResultRow } from 'pg';
|
|
3
3
|
|
|
4
4
|
import { getConfig } from '../config/getConfig';
|
|
5
5
|
import { getEnvironment } from '../environment';
|
|
@@ -11,7 +11,7 @@ pg.types.setTypeParser(1700, (value) => parseFloat(value)); // cast numerics to
|
|
|
11
11
|
export interface DatabaseConnection {
|
|
12
12
|
query: <Row extends QueryResultRow>(args: {
|
|
13
13
|
sql: string;
|
|
14
|
-
values?:
|
|
14
|
+
values?: unknown[];
|
|
15
15
|
}) => Promise<QueryResult<Row>>;
|
|
16
16
|
end: () => Promise<void>;
|
|
17
17
|
}
|
|
@@ -23,7 +23,7 @@ export class DatabaseQueryError extends HelpfulError {
|
|
|
23
23
|
caught,
|
|
24
24
|
}: {
|
|
25
25
|
sql: string;
|
|
26
|
-
values?:
|
|
26
|
+
values?: unknown[];
|
|
27
27
|
caught: Error;
|
|
28
28
|
}) {
|
|
29
29
|
const message = `
|
|
@@ -70,14 +70,14 @@ export const getDatabaseConnection = async (): Promise<DatabaseConnection> => {
|
|
|
70
70
|
await client.connect();
|
|
71
71
|
await client.query(`SET search_path TO ${target.schema}, public;`); // https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-
|
|
72
72
|
const dbConnection = {
|
|
73
|
-
query: ({ sql, values }: { sql: string; values?:
|
|
73
|
+
query: ({ sql, values }: { sql: string; values?: unknown[] }) =>
|
|
74
74
|
client.query(sql, values),
|
|
75
75
|
end: () => client.end(),
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// declare our interface
|
|
79
79
|
return {
|
|
80
|
-
query: (args: { sql: string; values?:
|
|
80
|
+
query: (args: { sql: string; values?: unknown[] }) =>
|
|
81
81
|
dbConnection.query(args).catch((error) => {
|
|
82
82
|
throw new DatabaseQueryError({
|
|
83
83
|
sql: args.sql,
|
|
@@ -21,7 +21,7 @@ const config: Config = {
|
|
|
21
21
|
// here's an example of how to ignore esm module transformation, when needed
|
|
22
22
|
// 'node_modules/(?!(@octokit|universal-user-agent|before-after-hook)/)',
|
|
23
23
|
],
|
|
24
|
-
testMatch: ['**/*.acceptance.test.ts'],
|
|
24
|
+
testMatch: ['**/*.acceptance.test.ts', '!**/.yalc/**'],
|
|
25
25
|
setupFilesAfterEnv: ['./jest.acceptance.env.ts'],
|
|
26
26
|
|
|
27
27
|
// use 50% of threads to leave headroom for other processes
|
|
@@ -21,7 +21,7 @@ const config: Config = {
|
|
|
21
21
|
// here's an example of how to ignore esm module transformation, when needed
|
|
22
22
|
// 'node_modules/(?!(@octokit|universal-user-agent|before-after-hook)/)',
|
|
23
23
|
],
|
|
24
|
-
testMatch: ['**/*.integration.test.ts'],
|
|
24
|
+
testMatch: ['**/*.integration.test.ts', '!**/.yalc/**'],
|
|
25
25
|
setupFilesAfterEnv: ['./jest.integration.env.ts'],
|
|
26
26
|
|
|
27
27
|
// use 50% of threads to leave headroom for other processes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
|
-
"version": "0.43.
|
|
5
|
+
"version": "0.43.3",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|