@devmoods/express-extras 0.40.0 → 0.40.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.
@@ -1,4 +1,6 @@
1
- import pg, { escapeIdentifier, escapeLiteral, type PoolClient, type PoolConfig, type QueryResult, type QueryResultRow } from 'pg';
1
+ import pg, { type PoolClient, type PoolConfig, type QueryResult, type QueryResultRow } from 'pg';
2
+ export declare const escapePostgresIdentifier: typeof pg.escapeIdentifier;
3
+ export declare const escapePostgresLiteral: typeof pg.escapeLiteral;
2
4
  export interface PostgresOptions extends PoolConfig {
3
5
  onError?: (error: Error, client: any) => void;
4
6
  url?: PoolConfig['connectionString'];
@@ -71,4 +73,4 @@ export declare const sql: {
71
73
  declare function spreadUpdate(data: Record<string, any>): SQLStatement;
72
74
  declare function spreadInsert<TData extends Record<string, any>>(data: TData | TData[]): SQLStatement;
73
75
  export declare function joinStatements(statements: SQLStatement[], separator: string): SQLStatement;
74
- export { escapeIdentifier, escapeLiteral };
76
+ export {};
package/dist/postgres.js CHANGED
@@ -1,5 +1,7 @@
1
- import pg, { escapeIdentifier, escapeLiteral, } from 'pg';
1
+ import pg, {} from 'pg';
2
2
  import { readEnv } from './utils.js';
3
+ export const escapePostgresIdentifier = pg.escapeIdentifier;
4
+ export const escapePostgresLiteral = pg.escapeLiteral;
3
5
  export class DoesNotExistError extends Error {
4
6
  constructor(message) {
5
7
  super(message);
@@ -225,7 +227,7 @@ function spreadInsert(data) {
225
227
  }
226
228
  const statement = sql `(`;
227
229
  statement.append(Object.keys(rows[0])
228
- .map((k) => escapeIdentifier(k))
230
+ .map((k) => escapePostgresIdentifier(k))
229
231
  .join(', '));
230
232
  statement.append(sql `) VALUES `);
231
233
  const toInsert = [];
@@ -243,7 +245,7 @@ function spreadInsert(data) {
243
245
  * Inject an identifier into the template string
244
246
  */
245
247
  sql.identifier = (name) => {
246
- return { name: escapeIdentifier(name), raw: true };
248
+ return { name: escapePostgresIdentifier(name), raw: true };
247
249
  };
248
250
  /**
249
251
  * Inject a raw value into the template string
@@ -255,7 +257,7 @@ sql.raw = (name) => {
255
257
  * Inject a literal value into the template string
256
258
  */
257
259
  sql.literal = (name) => {
258
- return { name: escapeLiteral(name), raw: true };
260
+ return { name: escapePostgresLiteral(name), raw: true };
259
261
  };
260
262
  sql.spreadUpdate = spreadUpdate;
261
263
  sql.spreadInsert = spreadInsert;
@@ -270,4 +272,3 @@ export function joinStatements(statements, separator) {
270
272
  }
271
273
  return statement;
272
274
  }
273
- export { escapeIdentifier, escapeLiteral };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devmoods/express-extras",
3
- "version": "0.40.0",
3
+ "version": "0.40.1",
4
4
  "description": "Kubernetes-ready utilities for rapid Node.js application development",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",