This repository was archived by the owner on Jun 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
329 additions
and
219 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,15 @@ | |
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"lib/**/*" | ||
"lib/**/*", | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "jest", | ||
"tslint": "tslint -p tsconfig.json" | ||
"dtslint": "dtslint --onlyTestTsNext" | ||
}, | ||
"keywords": [], | ||
"author": "Michał Miszczyszyn <[email protected]> (https://typeofweb.com/)", | ||
|
@@ -28,11 +30,12 @@ | |
"typescript": "3.5.3" | ||
}, | ||
"dependencies": { | ||
"dtslint": "0.9.0", | ||
"ramda": "0.26.1" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run tslint && pretty-quick --staged" | ||
"pre-commit": "npm run dtslint && pretty-quick --staged" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// tslint:disable:no-magic-numbers | ||
import pipe from 'ramda/es/pipe'; | ||
import { Column, ColumnMetaData, from, Model, Op, select, where } from './index'; | ||
|
||
type User = Model & { | ||
columns: { | ||
id: Column<'user.id', ColumnMetaData<User, 'TINYINT'>>; | ||
age: Column<'user.age', ColumnMetaData<User, 'TEXT'>>; | ||
}; | ||
}; | ||
|
||
const USER = { | ||
name: 'user', | ||
columns: { | ||
age: { type: 'TEXT', notNull: true }, | ||
id: { type: 'TINYINT', notNull: true }, | ||
}, | ||
} as User; | ||
|
||
type Invoice = Model & { | ||
columns: { | ||
id: Column<'invoice.id', ColumnMetaData<Invoice, 'TINYINT'>>; | ||
age: Column<'invoice.age', ColumnMetaData<Invoice, 'TEXT'>>; | ||
}; | ||
}; | ||
|
||
const INVOICE = { | ||
name: 'invoice', | ||
columns: { | ||
id: { type: 'TINYINT', notNull: true }, | ||
age: { type: 'TEXT', notNull: true }, | ||
}, | ||
} as Invoice; | ||
|
||
// $ExpectType () => Query<User, never, never, string> | ||
const r1 = from(USER); | ||
|
||
// $ExpectType <K2 extends string, ExistingColumns extends Column<K2, ColumnMetaData<User, any>>>(q: Query<User, ExistingColumns, never, string>) => Query<User, Column<"user.id", ColumnMetaData<User, any>> | ExistingColumns, never, string> | ||
const r12 = select(USER.columns.id); | ||
|
||
// $ExpectType Query<User, Column<"user.id", ColumnMetaData<User, any>>, never, string> | ||
const r2 = select(USER.columns.id)(from(USER)()); | ||
|
||
// $ExpectType Query<User, Column<"user.age", ColumnMetaData<User, any>>, never, string> | ||
const r2b = select(USER.columns.age)(from(USER)()); | ||
|
||
// $ExpectType Query<User, Column<"user.id", ColumnMetaData<User, any>> | Column<"user.age", ColumnMetaData<User, any>>, never, string> | ||
const r3 = select(USER.columns.age)(select(USER.columns.id)(from(USER)())); | ||
|
||
// $ExpectType () => Query<User, Column<"user.id", ColumnMetaData<User, any>> | Column<"user.age", ColumnMetaData<User, any>>, never, string> | ||
const execute1 = pipe( | ||
from(USER), | ||
select(USER.columns.id), | ||
select(USER.columns.age), | ||
); | ||
|
||
// $ExpectType () => Query<Invoice, Column<"invoice.id", ColumnMetaData<Invoice, any>> | Column<"invoice.age", ColumnMetaData<Invoice, any>>, never, string> | ||
const execute2 = pipe( | ||
from(INVOICE), | ||
select(INVOICE.columns.id), | ||
select(INVOICE.columns.age), | ||
); | ||
|
||
// $ExpectType () => Query<User, Column<string, Column<"user.id", ColumnMetaData<User, any>> | Column<"user.age", ColumnMetaData<User, any>>>, never, string> | ||
const execute3 = pipe( | ||
from(USER), | ||
select(USER.columns.id), | ||
select(USER.columns.age), | ||
where([USER.columns.id, Op.$eq, 12]), | ||
); |
Oops, something went wrong.