Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ff00ff/mammoth

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ff00ff/mammoth - npm Package Compare versions

Comparing version 1.3.0 to 2.0.0-beta.1

.build/naming/all-reserved-keywords.d.ts

2

.build/column.d.ts

@@ -21,3 +21,3 @@ import { Expression } from './expression';

unique(): ColumnDefinition<DataType, IsNotNull, HasDefault>;
references<T extends TableDefinition<any>, ColumnName extends T extends TableDefinition<infer Columns> ? keyof Columns : never>(table: T, columnName: ColumnName): ColumnDefinition<DataType, IsNotNull, HasDefault>;
references<T extends TableDefinition<any>, ColumnName extends T extends TableDefinition<infer Columns> ? keyof Columns extends string ? keyof Columns : never : never>(table: T, columnName: ColumnName): ColumnDefinition<DataType, IsNotNull, HasDefault>;
referencesSelf(columnName: string): ColumnDefinition<DataType, IsNotNull, HasDefault>;

@@ -24,0 +24,0 @@ }

@@ -104,3 +104,3 @@ "use strict";

}
return [initialToken, new tokens_1.StringToken(naming_1.wrapQuotes(alias))];
return [initialToken, new tokens_1.StringToken(naming_1.wrapQuotes(alias, true))];
};

@@ -107,0 +107,0 @@ if (includeAlias) {

@@ -9,8 +9,19 @@ import * as sqlFunctions from './sql-functions';

import { Table } from './TableType';
export declare const defineDb: <TableDefinitions extends {
declare type NullType = 'UNDEFINED' | 'NULL';
export interface DbConfiguration {
NullType: NullType;
}
export interface DefaultDbConfiguration extends DbConfiguration {
NullType: 'UNDEFINED';
}
export declare const defineDb: <Config extends DbConfiguration, TableDefinitions extends {
[key: string]: TableDefinition<any>;
}>(tableDefinitions: TableDefinitions, queryExecutor: QueryExecutorFn) => {
raw<DataType = unknown, IsNotNull extends boolean = true, Name extends string = never>(strings: TemplateStringsArray, ...parameters: any[]): import("./expression").Expression<DataType, IsNotNull, Name>;
}>(tableDefinitions: TableDefinitions, queryExecutor: QueryExecutorFn, config?: Config | undefined) => {
raw<DataType, IsNotNull extends boolean = false, Name extends string = "?column?">(strings: TemplateStringsArray, ...parameters: any[]): import("./expression").Expression<DataType, IsNotNull, Name>;
star(): sqlFunctions.Star;
star<T extends unknown>(table: T): T extends Table<any, infer Columns> ? import("./column").ColumnSet<Columns> : never;
toSql(query: import("./query").Query<any>): {
text: string;
parameters: any[];
};
Star: typeof sqlFunctions.Star;

@@ -36,6 +47,6 @@ stringAgg: (expression: import("./expression").Expression<string, boolean, any>, delimiter: string, ...orderBy: import("./expression").Expression<any, any, any>[]) => import("./expression").Expression<string, false, "stringAgg">;

now: () => import("./expression").Expression<Date, true, "now">;
exists: (expression: import("./query").Query<any> | import("./expression").Expression<any, any, any>) => import("./expression").DefaultExpression<boolean, true>;
andNotExists: (expression: import("./query").Query<any> | import("./expression").Expression<any, any, any>) => import("./expression").DefaultExpression<boolean, true>;
andExists: (expression: import("./query").Query<any> | import("./expression").Expression<any, any, any>) => import("./expression").DefaultExpression<boolean, true>;
notExists: (expression: import("./query").Query<any> | import("./expression").Expression<any, any, any>) => import("./expression").DefaultExpression<boolean, true>;
exists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
andNotExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
andExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
notExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
coalesce: <DataType_5>(...expressions: (DataType_5 | import("./expression").Expression<DataType_5, boolean, any>)[]) => import("./expression").Expression<DataType_5, true, "coalesce">;

@@ -50,7 +61,11 @@ /** @internal */

}[];
select: SelectFn;
insertInto: <T_6 extends unknown>(table: T_6, columnNames?: (T_6 extends Table<any, infer Columns_1> ? (keyof Columns_1)[] : never) | undefined) => T_6 extends TableDefinition<any> ? never : InsertIntoResult<T_6, T_6 extends Table<any, infer Columns_2> ? { [K_1 in keyof import("./types").PickByValue<{ [K in keyof Columns_2]: Columns_2[K] extends Column<any, any, any, infer IsNotNull_1, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull_1 : never; }, true>]: Columns_2[K_1] extends Column<any, any, infer DataType_6, any, any, any> ? DataType_6 : never; } & { [K_3 in keyof import("./types").PickByValue<{ [K_2 in keyof Columns_2]: Columns_2[K_2] extends Column<any, any, any, boolean, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : false : never; }, false>]?: (Columns_2[K_3] extends Column<any, any, infer DataType_7, any, any, any> ? DataType_7 | undefined : never) | undefined; } : never>;
select: SelectFn<Config>;
insertInto: <T_6 extends unknown>(table: T_6, columnNames?: (T_6 extends Table<any, infer Columns_1> ? (keyof Columns_1)[] : never) | undefined) => T_6 extends TableDefinition<any> ? never : InsertIntoResult<Config, T_6, T_6 extends Table<any, infer Columns_2> ? { [K_1 in keyof import("./types").PickByValue<{ [K in keyof Columns_2]: Columns_2[K] extends Column<any, any, any, infer IsNotNull_1, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull_1 : never; }, true>]: Columns_2[K_1] extends Column<any, any, infer DataType_6, boolean, any, any> ? DataType_6 | import("./expression").Expression<DataType_6, boolean, string> | import("./query").Query<{
[key: string]: DataType_6 | import("./expression").Expression<DataType_6, boolean, string>;
}> : never; } & { [K_3 in keyof import("./types").PickByValue<{ [K_2 in keyof Columns_2]: Columns_2[K_2] extends Column<any, any, any, infer IsNotNull_2, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_2 : never; }, false>]?: (Columns_2[K_3] extends Column<any, any, infer DataType_7, boolean, any, any> ? DataType_7 | import("./expression").Expression<DataType_7, boolean, string> | import("./query").Query<{
[key: string]: DataType_7 | import("./expression").Expression<DataType_7, boolean, string>;
}> | undefined : never) | undefined; } : never>;
deleteFrom: <T_7 extends unknown>(table: T_7) => T_7 extends TableDefinition<any> ? never : import("./delete").DeleteQuery<T_7, number, T_7 extends Table<any, infer Columns_3> ? Columns_3 : never>;
update: <T_8 extends unknown>(table: T_8) => {
set(values: T_8 extends Table<any, infer Columns_4> ? { [K_4 in keyof Columns_4]?: (Columns_4[K_4] extends Column<any, any, infer DataType_8, infer IsNotNull_2, any, any> ? IsNotNull_2 extends true ? DataType_8 | import("./expression").Expression<DataType_8, boolean, any> : DataType_8 | import("./expression").Expression<DataType_8 | undefined, boolean, any> | undefined : never) | undefined; } : never): import("./update").UpdateQuery<T_8, number, T_8 extends Table<any, infer Columns_5> ? Columns_5 : never>;
set(values: T_8 extends Table<any, infer Columns_4> ? { [K_4 in keyof Columns_4]?: (Columns_4[K_4] extends Column<any, any, infer DataType_8, infer IsNotNull_3, any, any> ? IsNotNull_3 extends true ? DataType_8 | import("./expression").Expression<DataType_8, boolean, any> : DataType_8 | import("./expression").Expression<DataType_8 | undefined, boolean, any> | undefined : never) | undefined; } : never): import("./update").UpdateQuery<T_8, number, T_8 extends Table<any, infer Columns_5> ? Columns_5 : never>;
};

@@ -60,2 +75,3 @@ with: import("./with").WithFn;

case: () => CaseStatement<never>;
} & { [TableName in keyof TableDefinitions]: TableDefinitions[TableName] extends TableDefinition<infer ColumnDefinitions> ? Table<TableName, { [K_5 in keyof ColumnDefinitions]: K_5 extends string ? Column<K_5, TableName, ColumnDefinitions[K_5] extends ColumnDefinition<infer DataType_9, any, any> ? DataType_9 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, infer IsNotNull_3, any> ? IsNotNull_3 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, any, infer HasDefault_2> ? HasDefault_2 : never, undefined> : never; }> : never; };
} & { [TableName in keyof TableDefinitions]: TableDefinitions[TableName] extends TableDefinition<infer ColumnDefinitions> ? Table<TableName, { [K_5 in keyof ColumnDefinitions]: K_5 extends string ? Column<K_5, TableName, ColumnDefinitions[K_5] extends ColumnDefinition<infer DataType_9, any, any> ? DataType_9 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, infer IsNotNull_4, any> ? IsNotNull_4 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, any, infer HasDefault_2> ? HasDefault_2 : never, undefined> : never; }> : never; };
export {};

@@ -40,3 +40,3 @@ "use strict";

};
const defineDb = (tableDefinitions, queryExecutor) => {
const defineDb = (tableDefinitions, queryExecutor, config) => {
return {

@@ -43,0 +43,0 @@ /** @internal */

@@ -8,3 +8,4 @@ import { Token } from './tokens';

import type { TableDefinition } from './table';
export declare const makeDeleteFrom: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : DeleteQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
import type { DbConfiguration } from './db';
export declare const makeDeleteFrom: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : DeleteQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
export declare class DeleteQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {

@@ -11,0 +12,0 @@ private readonly queryExecutor;

@@ -12,2 +12,3 @@ import { Token } from './tokens';

import { UpdateQuery } from './update';
import type { DbConfiguration } from './db';
export declare class InsertQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {

@@ -43,12 +44,16 @@ private readonly queryExecutor;

}
export interface InsertIntoResult<T extends Table<any, any>, Row = T extends Table<any, infer Columns> ? {
export interface InsertIntoResult<Config extends DbConfiguration, T extends Table<any, any>, Row = T extends Table<any, infer Columns> ? {
[K in keyof PickByValue<{
[K in keyof Columns]: Columns[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, true>]: Columns[K] extends Column<any, any, infer DataType, any, any, any> ? DataType : never;
}, true>]: Columns[K] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> | Expression<DataType, boolean, string> : never;
} & {
[K in keyof PickByValue<{
[K in keyof Columns]: Columns[K] extends Column<any, any, any, boolean, infer HasDefault, any> ? HasDefault extends true ? false : false : never;
}, false>]?: Columns[K] extends Column<any, any, infer DataType, any, any, any> ? DataType | undefined : never;
[K in keyof Columns]: Columns[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, false>]?: Columns[K] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> | Expression<DataType, boolean, string> | undefined : never;
} : never> {
select: SelectFn;
select: SelectFn<Config>;
deleteFrom<DeleteTable extends Table<any, any>>(deleteTable: DeleteTable): DeleteQuery<DeleteTable, number>;

@@ -63,2 +68,6 @@ update<UpdateTable extends Table<any, any>>(updateTable: UpdateTable): {

}
export declare const makeInsertInto: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T, columnNames?: (T extends Table<any, infer Columns> ? (keyof Columns)[] : never) | undefined) => T extends TableDefinition<any> ? never : InsertIntoResult<T, T extends Table<any, infer Columns_1> ? { [K_1 in keyof PickByValue<{ [K in keyof Columns_1]: Columns_1[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never; }, true>]: Columns_1[K_1] extends Column<any, any, infer DataType, any, any, any> ? DataType : never; } & { [K_3 in keyof PickByValue<{ [K_2 in keyof Columns_1]: Columns_1[K_2] extends Column<any, any, any, boolean, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : false : never; }, false>]?: (Columns_1[K_3] extends Column<any, any, infer DataType_1, any, any, any> ? DataType_1 | undefined : never) | undefined; } : never>;
export declare const makeInsertInto: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T, columnNames?: (T extends Table<any, infer Columns> ? (keyof Columns)[] : never) | undefined) => T extends TableDefinition<any> ? never : InsertIntoResult<Config, T, T extends Table<any, infer Columns_1> ? { [K_1 in keyof PickByValue<{ [K in keyof Columns_1]: Columns_1[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never; }, true>]: Columns_1[K_1] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Expression<DataType, boolean, string> | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> : never; } & { [K_3 in keyof PickByValue<{ [K_2 in keyof Columns_1]: Columns_1[K_2] extends Column<any, any, any, infer IsNotNull_1, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_1 : never; }, false>]?: (Columns_1[K_3] extends Column<any, any, infer DataType_1, boolean, any, any> ? DataType_1 | Expression<DataType_1, boolean, string> | Query<{
[key: string]: DataType_1 | Expression<DataType_1, boolean, string>;
}> | undefined : never) | undefined; } : never>;

@@ -100,6 +100,8 @@ "use strict";

return new tokens_1.EmptyToken();
return new tokens_1.GroupToken([new tokens_1.SeparatorToken(',', columnNames.map((columnName) => {
return new tokens_1.GroupToken([
new tokens_1.SeparatorToken(',', columnNames.map((columnName) => {
const column = this.table[columnName];
return new tokens_1.StringToken(column.getSnakeCaseName());
}))]);
})),
]);
}

@@ -244,3 +246,3 @@ onConflict(...columnNames) {

typeof value.toTokens === `function`) {
return new tokens_1.CollectionToken(value.toTokens());
return new tokens_1.GroupToken([new tokens_1.CollectionToken(value.toTokens())]);
}

@@ -247,0 +249,0 @@ else {

@@ -1,2 +0,2 @@

export declare const wrapQuotes: (string: string) => string;
export declare const wrapQuotes: (string: string, extended?: boolean | undefined) => string;
export declare const toSnakeCase: (string: string) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSnakeCase = exports.wrapQuotes = void 0;
const all_reserved_keywords_1 = require("./all-reserved-keywords");
const reserved_keywords_1 = require("./reserved-keywords");
const wrapQuotes = (string) => {
const wrapQuotes = (string, extended) => {
const isCamelCase = string.match(/[A-Z]/);
const isReserved = reserved_keywords_1.reservedKeywords.has(string);
const isReserved = reserved_keywords_1.reservedKeywords.has(string) || (extended && all_reserved_keywords_1.allReservedKeywords.has(string));
const shouldWrap = isReserved || isCamelCase;

@@ -9,0 +10,0 @@ return shouldWrap ? `"${string}"` : string;

@@ -9,11 +9,12 @@ import type { Column } from './column';

import { UpdateQuery } from './update';
export declare type ResultSetDataType<Type, IsNotNull> = IsNotNull extends true ? Type : Type | undefined;
export declare type ResultSet<T extends Query<any>, Test extends boolean> = T extends SelectQuery<infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
import type { DbConfiguration, DefaultDbConfiguration } from './db';
export declare type ResultSetDataType<Config extends DbConfiguration, Type, IsNotNull> = IsNotNull extends true ? Type : Config['NullType'] extends 'NULL' ? Type | null : Type | undefined;
export declare type ResultSet<T extends Query<any>, Test extends boolean> = T extends SelectQuery<infer Config, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends DeleteQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<DefaultDbConfiguration, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<DefaultDbConfiguration, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends UpdateQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<DefaultDbConfiguration, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<DefaultDbConfiguration, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends InsertQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<DefaultDbConfiguration, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<DefaultDbConfiguration, D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<DefaultDbConfiguration, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : never;

@@ -11,2 +11,3 @@ import { Token } from './tokens';

import { TableDefinition } from './table';
import type { DbConfiguration } from './db';
export { SelectFn };

@@ -25,10 +26,10 @@ declare type JoinType = 'left-join' | 'left-side-of-right-join' | 'full-join';

};
declare type Join<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<ExistingColumns & Omit<GetColumns<JoinTable>, keyof ExistingColumns>, true> : SelectQuery<ExistingColumns, false> : never;
declare type Join<Query extends SelectQuery<DbConfiguration, any, boolean>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, ExistingColumns & Omit<GetColumns<JoinTable>, keyof ExistingColumns>, true> : SelectQuery<Config, ExistingColumns, false> : never;
declare type GetColumns<From extends Table<any, any> | FromItem<any>> = From extends Table<any, infer Columns> ? Columns : From extends FromItem<infer Q> ? Q extends Query<infer Returning> ? Returning : never : never;
declare type LeftJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<ExistingColumns & AddJoinType<GetColumns<JoinTable>, 'left-join'>> : SelectQuery<AddLeftJoin<ExistingColumns, JoinTable>> : never;
declare type RightJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<AddJoinType<ExistingColumns, 'left-side-of-right-join'> & GetColumns<JoinTable>> : SelectQuery<AddRightJoin<ExistingColumns, JoinTable>> : never;
declare type FullJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<AddJoinType<ExistingColumns & GetColumns<JoinTable>, 'full-join'>> : SelectQuery<AddJoinType<ExistingColumns, 'full-join'>> : never;
export declare class SelectQuery<Columns extends {
declare type LeftJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, ExistingColumns & AddJoinType<GetColumns<JoinTable>, 'left-join'>> : SelectQuery<Config, AddLeftJoin<ExistingColumns, JoinTable>> : never;
declare type RightJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, AddJoinType<ExistingColumns, 'left-side-of-right-join'> & GetColumns<JoinTable>> : SelectQuery<Config, AddRightJoin<ExistingColumns, JoinTable>> : never;
declare type FullJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, AddJoinType<ExistingColumns & GetColumns<JoinTable>, 'full-join'>> : SelectQuery<Config, AddJoinType<ExistingColumns, 'full-join'>> : never;
export declare class SelectQuery<Config extends DbConfiguration, Columns extends {
[column: string]: any;
}, IncludesStar = false> extends Query<Columns> {
} = object, IncludesStar = false> extends Query<Columns> {
private readonly queryExecutor;

@@ -40,33 +41,32 @@ private readonly returningKeys;

constructor(queryExecutor: QueryExecutorFn, returningKeys: string[], includesStar: boolean, tokens: Token[]);
then<Result1, Result2 = never>(onFulfilled?: ((value: ResultSet<SelectQuery<Columns>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
then<Result1, Result2 = never>(onFulfilled?: ((value: ResultSet<SelectQuery<Config, Columns>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
private newSelectQuery;
from<T extends Table<any, any>>(fromItem: T): T extends TableDefinition<any> ? never : Join<SelectQuery<Columns, IncludesStar>, T>;
private getTableStringToken;
join<T extends Table<any, any>>(table: T): Join<SelectQuery<Columns, IncludesStar>, T>;
innerJoin<JoinTable extends Table<string, any>>(table: JoinTable): Join<SelectQuery<Columns, IncludesStar>, JoinTable>;
leftOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
leftJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
rightOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
rightJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
fullOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
fullJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
crossJoin<JoinTable extends Table<any, any>>(table: Table<any, any>): Join<SelectQuery<Columns, IncludesStar>, JoinTable>;
forUpdate(): SelectQuery<Columns>;
forNoKeyUpdate(): SelectQuery<Columns>;
forShare(): SelectQuery<Columns>;
forKeyShare(): SelectQuery<Columns>;
on(joinCondition: Expression<boolean, boolean, string>): SelectQuery<Columns, IncludesStar>;
using(...columns: Column<any, any, any, any, any, any>[]): SelectQuery<Columns>;
where(condition: Expression<boolean, boolean, string>): SelectQuery<Columns>;
groupBy(...expressions: Expression<any, any, any>[]): SelectQuery<Columns>;
having(...conditions: Expression<boolean, boolean, string>[]): SelectQuery<Columns>;
window(): SelectQuery<Columns>;
orderBy(...expressions: Expression<any, any, any>[]): SelectQuery<Columns>;
limit(limit: number | 'ALL'): SelectQuery<Columns>;
offset(start: number): SelectQuery<Columns>;
fetch(count: number): SelectQuery<Columns>;
of(table: Table<any, any>): SelectQuery<Columns>;
nowait(): SelectQuery<Columns>;
skipLocked(): SelectQuery<Columns>;
from<T extends Table<any, any>>(fromItem: T): T extends TableDefinition<any> ? never : Join<SelectQuery<Config, Columns, IncludesStar>, T>;
join<T extends Table<any, any>>(table: T): Join<SelectQuery<Config, Columns, IncludesStar>, T>;
innerJoin<JoinTable extends Table<string, any>>(table: JoinTable): Join<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
leftOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
leftJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
rightOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
rightJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
fullOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
fullJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
crossJoin<JoinTable extends Table<any, any>>(table: Table<any, any>): Join<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
forUpdate(): SelectQuery<Config, Columns>;
forNoKeyUpdate(): SelectQuery<Config, Columns>;
forShare(): SelectQuery<Config, Columns>;
forKeyShare(): SelectQuery<Config, Columns>;
on(joinCondition: Expression<boolean, boolean, string>): SelectQuery<Config, Columns, IncludesStar>;
using(...columns: Column<any, any, any, any, any, any>[]): SelectQuery<Config, Columns>;
where(condition: Expression<boolean, boolean, string>): SelectQuery<Config, Columns>;
groupBy(...expressions: Expression<any, any, any>[]): SelectQuery<Config, Columns>;
having(...conditions: Expression<boolean, boolean, string>[]): SelectQuery<Config, Columns>;
window(): SelectQuery<Config, Columns>;
orderBy(...expressions: Expression<any, any, any>[]): SelectQuery<Config, Columns>;
limit(limit: number | 'ALL'): SelectQuery<Config, Columns>;
offset(start: number): SelectQuery<Config, Columns>;
fetch(count: number): SelectQuery<Config, Columns>;
of(table: Table<any, any>): SelectQuery<Config, Columns>;
nowait(): SelectQuery<Config, Columns>;
skipLocked(): SelectQuery<Config, Columns>;
}
export declare const makeSelect: (queryExecutor: QueryExecutorFn, initialTokens?: Token[] | undefined) => SelectFn;
export declare const makeSelect: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn, initialTokens?: Token[] | undefined) => SelectFn<Config>;

@@ -7,3 +7,2 @@ "use strict";

const sql_functions_1 = require("./sql-functions");
const naming_1 = require("./naming");
// https://www.postgresql.org/docs/12/sql-select.html

@@ -40,37 +39,31 @@ class SelectQuery extends query_1.Query {

const table = fromItem;
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FROM`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FROM`), new tokens_1.TableToken(table)], table);
}
getTableStringToken(table) {
if (table.getOriginalName()) {
return new tokens_1.StringToken(`${naming_1.wrapQuotes(table.getOriginalName())} ${naming_1.wrapQuotes(table.getName())}`);
}
return new tokens_1.StringToken(naming_1.wrapQuotes(table.getName()));
}
join(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`JOIN`), new tokens_1.TableToken(table)], table);
}
innerJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`INNER JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`INNER JOIN`), new tokens_1.TableToken(table)], table);
}
leftOuterJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`LEFT OUTER JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`LEFT OUTER JOIN`), new tokens_1.TableToken(table)], table);
}
leftJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`LEFT JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`LEFT JOIN`), new tokens_1.TableToken(table)], table);
}
rightOuterJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`RIGHT OUTER JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`RIGHT OUTER JOIN`), new tokens_1.TableToken(table)], table);
}
rightJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`RIGHT JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`RIGHT JOIN`), new tokens_1.TableToken(table)], table);
}
fullOuterJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FULL OUTER JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FULL OUTER JOIN`), new tokens_1.TableToken(table)], table);
}
fullJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FULL JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`FULL JOIN`), new tokens_1.TableToken(table)], table);
}
// This doesn't go with an ON or USING afterwards
crossJoin(table) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`CROSS JOIN`), this.getTableStringToken(table)], table);
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`CROSS JOIN`), new tokens_1.TableToken(table)], table);
}

@@ -194,3 +187,5 @@ forUpdate() {

const includesStar = !!columns.find((column) => column instanceof sql_functions_1.Star);
const returningKeys = columns.map((column) => {
const returningKeys = columns
.filter((column) => !(column instanceof sql_functions_1.Star))
.map((column) => {
if (column instanceof query_1.Query) {

@@ -200,3 +195,3 @@ return column.getReturningKeys()[0];

if (!column) {
throw new Error(`No column ${columns}`);
throw new Error(`Column '${column}' not found in columns '${columns}'`);
}

@@ -203,0 +198,0 @@ return column.getName();

@@ -0,13 +1,15 @@

import { AllStarToken } from './tokens';
import { AnyNumber, Int8 } from './data-types';
import { StringToken } from './tokens';
import type { ColumnSet } from './column';
import { DefaultExpression, Expression } from './expression';
import { ColumnSet } from './column';
import { Query } from './query';
import { Table } from './TableType';
export declare class Star {
private readonly table?;
private _starBrand;
toTokens(): StringToken[];
constructor(table?: any);
toTokens(): AllStarToken[];
getName(): string;
}
export declare function raw<DataType = unknown, IsNotNull extends boolean = true, Name extends string = never>(strings: TemplateStringsArray, ...parameters: any[]): Expression<DataType, IsNotNull, Name>;
export declare function raw<DataType, IsNotNull extends boolean = false, Name extends string = '?column?'>(strings: TemplateStringsArray, ...parameters: any[]): Expression<DataType, IsNotNull, Name>;
export declare function star(): Star;

@@ -39,1 +41,5 @@ export declare function star<T extends Table<any, any>>(table: T): T extends Table<any, infer Columns> ? ColumnSet<Columns> : never;

export declare const coalesce: <DataType>(...expressions: (DataType | Expression<DataType, boolean, any>)[]) => Expression<DataType, true, "coalesce">;
export declare function toSql(query: Query<any>): {
text: string;
parameters: any[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.coalesce = exports.notExists = exports.andExists = exports.andNotExists = exports.exists = exports.now = exports.any = exports.group = exports.or = exports.and = exports.not = exports.xmlagg = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.arrayAgg = exports.every = exports.boolOr = exports.boolAnd = exports.bitOr = exports.bitAnd = exports.stringAgg = exports.star = exports.raw = exports.Star = void 0;
exports.toSql = exports.coalesce = exports.notExists = exports.andExists = exports.andNotExists = exports.exists = exports.now = exports.any = exports.group = exports.or = exports.and = exports.not = exports.xmlagg = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.arrayAgg = exports.every = exports.boolOr = exports.boolAnd = exports.bitOr = exports.bitAnd = exports.stringAgg = exports.star = exports.raw = exports.Star = void 0;
const tokens_1 = require("./tokens");
const expression_1 = require("./expression");
const naming_1 = require("./naming");
class Star {
constructor(table) {
this.table = table;
}
toTokens() {
return [new tokens_1.StringToken(`*`)];
if (this.table) {
return [new tokens_1.TableStarToken(this.table)];
}
return [new tokens_1.AllStarToken()];
}

@@ -29,3 +34,3 @@ getName() {

if (table) {
return new expression_1.Expression([new tokens_1.StringToken(`${naming_1.wrapQuotes(table.getName())}.*`)], '');
return new Star(table);
}

@@ -116,1 +121,9 @@ return new Star();

exports.coalesce = coalesce;
function toSql(query) {
const queryState = tokens_1.createQueryState(query.toTokens());
return {
text: queryState.text.join(` `),
parameters: queryState.parameters,
};
}
exports.toSql = toSql;
import { State, Token } from './token';
import type { Table } from '../TableType';
export declare class CollectionToken extends Token {
tokens: Token[];
constructor(tokens: Token[]);
reduce(state: State, numberOfParameters: number): State;
reduce(state: State, numberOfParameters: number, tables: Table<any, any>[]): State;
}

@@ -10,4 +10,4 @@ "use strict";

}
reduce(state, numberOfParameters) {
const tokensState = token_1.createQueryState(this.tokens, numberOfParameters);
reduce(state, numberOfParameters, tables) {
const tokensState = token_1.createQueryState(this.tokens, numberOfParameters, tables);
state.parameters.push(...tokensState.parameters);

@@ -14,0 +14,0 @@ state.text.push(...tokensState.text);

@@ -1,4 +0,4 @@

import { Token } from './token';
import { State, Token } from './token';
export declare class EmptyToken extends Token {
reduce(state: any): any;
reduce(state: State): State;
}

@@ -0,1 +1,2 @@

export * from './all-star-token';
export * from './collection-token';

@@ -7,2 +8,4 @@ export * from './empty-token';

export * from './string-token';
export * from './table-star-token';
export * from './table-token';
export * from './token';

@@ -13,2 +13,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./all-star-token"), exports);
__exportStar(require("./collection-token"), exports);

@@ -20,2 +21,4 @@ __exportStar(require("./empty-token"), exports);

__exportStar(require("./string-token"), exports);
__exportStar(require("./table-star-token"), exports);
__exportStar(require("./table-token"), exports);
__exportStar(require("./token"), exports);

@@ -1,6 +0,6 @@

import { Token } from './token';
import { State, Token } from './token';
export declare class ParameterToken extends Token {
parameter: any;
constructor(parameter: any);
reduce(state: any, numberOfParameters: number): any;
reduce(state: State, numberOfParameters: number): State;
}
import { State, Token } from './token';
import type { Table } from '../TableType';
export declare type Separator = ',';

@@ -7,3 +8,3 @@ export declare class SeparatorToken extends Token {

constructor(separator: Separator, tokens: Token[]);
reduce(state: State, numberOfParameters: number): State;
reduce(state: State, numberOfParameters: number, tables: Table<any, any>[]): State;
}

@@ -11,3 +11,3 @@ "use strict";

}
reduce(state, numberOfParameters) {
reduce(state, numberOfParameters, tables) {
const length = this.tokens.length;

@@ -17,3 +17,3 @@ let parameterIndex = numberOfParameters;

const last = index === length - 1;
const tokenState = token_1.createQueryState([token], parameterIndex);
const tokenState = token_1.createQueryState([token], parameterIndex, tables);
if (tokenState.text.length > 0) {

@@ -20,0 +20,0 @@ if (!last) {

@@ -1,6 +0,6 @@

import { Token } from './token';
import { State, Token } from './token';
export declare class StringToken extends Token {
string: string;
constructor(string: string);
reduce(state: any): any;
reduce(state: State): State;
}

@@ -0,3 +1,4 @@

import type { Table } from '../TableType';
export declare abstract class Token {
abstract reduce(state: any, numberOfParameters: number): any;
abstract reduce(state: any, numberOfParameters: number, tables: Table<any, any>[]): any;
}

@@ -8,2 +9,2 @@ export interface State {

}
export declare const createQueryState: (tokens: Token[], currentParameterIndex?: number) => State;
export declare const createQueryState: (tokens: Token[], currentParameterIndex?: number, existingTables?: any[] | undefined) => State;

@@ -7,3 +7,3 @@ "use strict";

exports.Token = Token;
const createQueryState = (tokens, currentParameterIndex = 0) => {
const createQueryState = (tokens, currentParameterIndex = 0, existingTables) => {
const initialState = {

@@ -13,4 +13,11 @@ text: [],

};
return tokens.reduce((tokenState, token) => token.reduce(tokenState, tokenState.parameters.length + currentParameterIndex), initialState);
// We look for every table or from item in the tokens so we pass that through the tokens.
const tables = [
...(existingTables !== null && existingTables !== void 0 ? existingTables : []),
...tokens
.filter((token) => 'getTable' in token)
.map((tableToken) => tableToken.getTable()),
];
return tokens.reduce((tokenState, token) => token.reduce(tokenState, tokenState.parameters.length + currentParameterIndex, tables), initialState);
};
exports.createQueryState = createQueryState;

@@ -6,3 +6,4 @@ import { QueryExecutorFn, ResultType } from './types';

import { TableDefinition } from './table';
export declare const makeTruncate: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : TruncateQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
import type { DbConfiguration } from './db';
export declare const makeTruncate: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : TruncateQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
export declare class TruncateQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {

@@ -9,0 +10,0 @@ private readonly queryExecutor;

@@ -8,2 +8,3 @@ import { Token } from './tokens';

import { Table } from './TableType';
import type { DbConfiguration } from './db';
export declare class UpdateQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {

@@ -32,4 +33,4 @@ private readonly queryExecutor;

}
export declare const makeUpdate: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => {
export declare const makeUpdate: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => {
set(values: T extends Table<any, infer Columns> ? { [K in keyof Columns]?: (Columns[K] extends Column<any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? DataType | Expression<DataType, boolean, any> : DataType | Expression<DataType | undefined, boolean, any> | undefined : never) | undefined; } : never): UpdateQuery<T, number, T extends Table<any, infer Columns_1> ? Columns_1 : never>;
};

@@ -5,2 +5,3 @@ import { GetDataType, QueryExecutorFn } from './types';

import { ResultSet } from './result-set';
import type { DbConfiguration } from './db';
export declare type FromItem<Q> = Q extends Query<any> ? FromItemQuery<Q> : Q extends (args: any) => infer R ? R extends Query<any> ? FromItemQuery<R> : never : never;

@@ -463,3 +464,3 @@ declare type FromItemQuery<Q, Result = Q extends Query<any> ? ResultSet<Q, true> : never> = {

}
export declare const makeWith: (queryExecutor: QueryExecutorFn) => WithFn;
export declare const makeWith: <Config extends DbConfiguration>(queryExecutor: QueryExecutorFn) => WithFn;
export {};
{
"name": "@ff00ff/mammoth",
"license": "MIT",
"version": "1.3.0",
"version": "2.0.0-beta.1",
"main": "./.build/index.js",

@@ -21,9 +21,9 @@ "types": "./.build/index.d.ts",

"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^15.12.4",
"@types/jest": "^26.0.24",
"@types/node": "^16.3.3",
"dts-jest": "^23.3.0",
"jest": "^26.6.3",
"prettier": "^2.3.1",
"prettier": "^2.3.2",
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
"typescript": "^4.3.5"
},

@@ -34,3 +34,3 @@ "scripts": {

"build": "tsc",
"prepublishOnly": "npm run build && npm test"
"_prepublishOnly": "npm run build && npm test"
},

@@ -37,0 +37,0 @@ "jest": {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc