@nearform/sql
Advanced tools
Comparing version 1.10.4 to 1.10.5
{ | ||
"name": "@nearform/sql", | ||
"version": "1.10.4", | ||
"version": "1.10.5", | ||
"description": "SQL injection protection module", | ||
@@ -5,0 +5,0 @@ "main": "./SQL.js", |
36
SQL.d.ts
@@ -47,2 +47,26 @@ /** A tagged template containing strings and values */ | ||
/** | ||
* A function that accepts an array of objects and a mapper function | ||
* It returns a clean SQL format using the object properties defined in the mapper function | ||
* @param array the items to be mapped over | ||
* @param mapFunc a function to transform the items in `array` before being added to the SqlStatement | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3])}` | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3], x => x ** 2)}` | ||
*/ | ||
map<T>(array: T[], mapFunc?: (item: T) => unknown): SqlStatement | ||
/** | ||
* A function that accepts an array of objects and a mapper function | ||
* It returns a clean SQL format using the object properties defined in the mapper function | ||
* @param array the items to be mapped over | ||
* @param mapFunc a function to transform the items in `array` before being added to the SqlStatement | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3])}` | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3], x => x ** 2)}` | ||
*/ | ||
static map<T>(array: T[], mapFunc?: (item: T) => unknown): SqlStatement | ||
/** Returns a formatted but unsafe statement of strings and values, useful for debugging */ | ||
@@ -89,2 +113,14 @@ get debug(): string | ||
/** | ||
* A function that accepts an array of objects and a mapper function | ||
* It returns a clean SQL format using the object properties defined in the mapper function | ||
* @param array the items to be mapped over | ||
* @param mapFunc a function to transform the items in `array` before being added to the SqlStatement | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3])}` | ||
* @example | ||
* SQL`SELECT ${SQL.map([1,2,3], x => x ** 2)}` | ||
*/ | ||
export function map<T>(array: T[], mapFunc?: (item: T) => unknown): SqlStatement | ||
export function unsafe<T>(value: T): { value: T } | ||
@@ -91,0 +127,0 @@ export function quoteIdent(value: string): { value: string } |
import SQL from '.' | ||
import { glue, SqlStatement } from '.' | ||
import { glue, map, SqlStatement } from '.' | ||
import { expectType, expectError } from 'tsd' | ||
@@ -11,2 +11,6 @@ | ||
expectType<SQL.SqlStatement>(SQL.glue([SQL`SELECT`, SQL`1`], ' ')) | ||
expectType<SQL.SqlStatement>(SQL.map([1,2,3])) | ||
expectType<SQL.SqlStatement>(SQL.map([1,2,3], x => x**2)) | ||
expectType<SQL.SqlStatement>(map([1,2,3])) | ||
expectType<SQL.SqlStatement>(map([1,2,3], x => x**2)) | ||
expectType<string>(SQL`SELECT 1`.debug) | ||
@@ -13,0 +17,0 @@ expectType<string>(SQL`SELECT 1`.sql) |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
60684
1212
3