selectstar
Advanced tools
Comparing version 0.1.2 to 1.0.0
@@ -1,4 +0,4 @@ | ||
export interface SqlQueryObject { | ||
export interface SqlQueryObject<I extends any = any> { | ||
text: string; | ||
values: unknown[]; | ||
values: I[]; | ||
} | ||
@@ -41,3 +41,3 @@ declare const $$BOX$$: unique symbol; | ||
type: "list"; | ||
items: readonly SqlTemplateStringParams[]; | ||
items: readonly SqlLiteralParams[]; | ||
separator: string; | ||
@@ -88,3 +88,3 @@ }>; | ||
*/ | ||
export declare function list(items: readonly SqlTemplateStringParams[], separator?: string): List; | ||
export declare function list(items: readonly SqlLiteralParams[], separator?: string): List; | ||
declare type Unsafe = Box<{ | ||
@@ -120,5 +120,11 @@ type: "unsafe"; | ||
export declare function unsafe(value: unknown): Unsafe; | ||
/** | ||
* Does a very cheap "best attempt" at reformatting multiple lines of SQL into | ||
* something that has as little leading space as possible. | ||
* | ||
* @param sql | ||
*/ | ||
export declare function format(sql: string): string; | ||
export declare type Template = (subsql: typeof sql) => SqlQueryObject; | ||
declare type SqlTemplateStringParams = string | number | Identifier | List | Unsafe | Template; | ||
export declare type Template<I extends any = any> = (subsql: typeof sql) => SqlQueryObject<I>; | ||
export declare type SqlLiteralParams = Identifier | List | Unsafe | Template; | ||
/** | ||
@@ -132,3 +138,3 @@ * Using a template literal, generate a query with arguments that can be passed | ||
*/ | ||
export declare function sql(fragments: TemplateStringsArray, ...args: SqlTemplateStringParams[]): SqlQueryObject; | ||
export declare function sql<I extends any = any>(fragments: TemplateStringsArray, ...args: (I | SqlLiteralParams)[]): SqlQueryObject<I>; | ||
/** | ||
@@ -141,3 +147,3 @@ * Generate a template that can be used in a query generated by the sql function | ||
*/ | ||
export declare function template(fragments: TemplateStringsArray, ...args: SqlTemplateStringParams[]): Template; | ||
export declare function template<I extends any = any>(fragments: TemplateStringsArray, ...args: (I | SqlLiteralParams)[]): Template<I>; | ||
export {}; |
@@ -211,2 +211,8 @@ "use strict"; | ||
} | ||
/** | ||
* Does a very cheap "best attempt" at reformatting multiple lines of SQL into | ||
* something that has as little leading space as possible. | ||
* | ||
* @param sql | ||
*/ | ||
function format(sql) { | ||
@@ -213,0 +219,0 @@ const pieces = sql.split("\n").filter((p) => !p.match(/^\s*$/)); |
{ | ||
"name": "selectstar", | ||
"version": "0.1.2", | ||
"version": "1.0.0", | ||
"description": "Generate safe SQL statements with tagged literals", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
25136
428
1