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.0.0-rc.3 to 1.0.0-rc.4

3

.build/column.d.ts
import { InternalExpression } from './expression';
import { Token } from './tokens';
import { Table } from './table';
export interface ColumnDefinition<DataType, IsNotNull extends boolean, HasDefault extends boolean> {

@@ -10,3 +9,3 @@ notNull(): ColumnDefinition<DataType, true, HasDefault>;

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

@@ -13,0 +12,0 @@ export declare const makeColumnDefinition: <DataType, IsNotNull extends boolean, HasDefault extends boolean>(dataType: string) => ColumnDefinition<DataType, IsNotNull, HasDefault>;

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

const tokens_1 = require("./tokens");
// import type { Table } from './table';
const snake_case_1 = require("./naming/snake-case");

@@ -8,0 +9,0 @@ exports.makeColumnDefinition = (dataType) => {

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

export declare type QueryExecutorFn = (query: string, parameters: any[]) => Promise<{
rows: any[];
affectedRowsCount: number;
}>;
import { QueryExecutorFn } from "./types";
export declare const defineDb: (queryExecutor: QueryExecutorFn) => {

@@ -6,0 +3,0 @@ select: import("./select").SelectFn;

import { Token } from './tokens';
import type { GetReturning, ResultType } from './types';
import type { GetReturning, QueryExecutorFn, ResultType } from './types';
import type { Condition } from './condition';
import { Query } from './query';
import type { QueryExecutorFn } from './db';
import type { ResultSet } from './result-set';

@@ -7,0 +6,0 @@ import type { Table } from './table';

import { Condition } from "./condition";
import { Token } from "./tokens";
import { SelectQuery } from "./select";
import { Query } from "./query";
export interface NamedExpression<Name, DataType, IsNotNull extends boolean> extends InternalExpression<Name, DataType, IsNotNull> {

@@ -14,3 +14,3 @@ as<NewName extends string>(name: NewName): NamedExpression<NewName, DataType, IsNotNull>;

nullsLast(): Expression<DataType, IsNotNull>;
in(array: DataType[] | Expression<DataType, IsNotNull> | SelectQuery<any>): Condition;
in(array: DataType[] | Expression<DataType, IsNotNull> | Query<any>): Condition;
plus(value: DataType | Expression<DataType, IsNotNull>): Expression<DataType, IsNotNull>;

@@ -17,0 +17,0 @@ minus(value: DataType | Expression<DataType, IsNotNull>): Expression<DataType, IsNotNull>;

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

const tokens_1 = require("./tokens");
const query_1 = require("./query");
exports.makeNamedExpression = (tokenFactory) => exports.makeExpression(tokenFactory);

@@ -66,3 +67,3 @@ exports.makeExpression = (tokenFactory) => {

const tokens = tokenFactory('EXCLUDE');
if ('toTokens' in array) {
if (array && ('toTokens' in array || array instanceof query_1.Query)) {
return condition_1.makeCondition([...tokens, new tokens_1.StringToken(`IN`), new tokens_1.GroupToken(array.toTokens())]);

@@ -69,0 +70,0 @@ }

import { Token } from './tokens';
import { GetReturning, PickByValue, ResultType } from './types';
import { GetReturning, PickByValue, QueryExecutorFn, ResultType } from './types';
import { SelectFn } from './select';

@@ -9,3 +9,2 @@ import { Column } from './column';

import { Query } from './query';
import { QueryExecutorFn } from './db';
import { ResultSet } from './result-set';

@@ -12,0 +11,0 @@ import { Table } from './table';

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

import { Token } from "./tokens";
export declare abstract class Query<Returning> {
private _queryBrand;
/** @internal */
abstract toTokens(): Token[];
}
"use strict";
// This is used so we can capture the Returning of every different query type without having to
// specify every query seperately. The private property is used to simulate a nominal type so only
Object.defineProperty(exports, "__esModule", { value: true });
exports.Query = void 0;
// This is used so we can capture the Returning of every different query type without having to
// specify every query seperately. The private property is used to simulate a nominal type so only
// this class is captured when doing a conditional type check (through T extends Query<infer Returning>).

@@ -7,0 +7,0 @@ class Query {

import type { Column } from './column';
import { DeleteQuery } from './delete';
import { InsertQuery } from './insert';
import type { NamedExpression } from './expression';
import { Query } from "./query";
import { SelectQuery } from './select';
import { UpdateQuery } from './update';
export declare class GetDataType<Type, IsNull> {

@@ -8,4 +12,10 @@ private _;

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 Query<infer Returning> ? {
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 NamedExpression<any, infer D, infer IsNotNull> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<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 NamedExpression<any, infer D, infer IsNotNull> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<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 NamedExpression<any, infer D, infer IsNotNull> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<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 NamedExpression<any, infer D, infer IsNotNull> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : never;

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

import { Query } from './query';
import { QueryExecutorFn } from './db';
import { QueryExecutorFn } from './types';
import { ResultSet } from './result-set';

@@ -26,3 +26,3 @@ import { Table } from './table';

export declare class SelectQuery<Columns extends {
[column: string]: Selectable;
[column: string]: any;
}> extends Query<Columns> {

@@ -29,0 +29,0 @@ private readonly queryExecutor;

@@ -11,1 +11,5 @@ export declare type ResultType = 'ROWS' | 'AFFECTED_COUNT';

}
export declare type QueryExecutorFn = (query: string, parameters: any[]) => Promise<{
rows: any[];
affectedRowsCount: number;
}>;
import { Token } from './tokens';
import { GetReturning, ResultType } from './types';
import { GetReturning, QueryExecutorFn, ResultType } from './types';
import { Column } from './column';

@@ -7,3 +7,2 @@ import { Condition } from './condition';

import { Query } from './query';
import { QueryExecutorFn } from './db';
import { ResultSet } from './result-set';

@@ -10,0 +9,0 @@ import { Table } from './table';

{
"name": "@ff00ff/mammoth",
"license": "MIT",
"version": "1.0.0-rc.3",
"version": "1.0.0-rc.4",
"main": "./.build/index.js",

@@ -27,3 +27,3 @@ "types": "./.build/index.d.ts",

"ts-jest": "^26.4.0",
"typescript": "^4.0.2"
"typescript": "^4.0.3"
},

@@ -33,3 +33,4 @@ "scripts": {

"prebuild": "rm -rf .build && rm -rf coverage",
"build": "tsc"
"build": "tsc",
"prepublishOnly": "npm run build && npm test"
},

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

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