From 31974c0b0fdb7315485480bdd0b2948a02fb3ec9 Mon Sep 17 00:00:00 2001 From: Lucas Avila Date: Wed, 29 Jun 2022 20:25:00 -0300 Subject: [PATCH] format md --- .prettierrc | 4 - TODO.md | 16 +- docs/api/classes/compound.ts.md | 146 +++++++++++++++-- docs/api/classes/cte.ts.md | 16 +- docs/api/classes/joined.ts.md | 137 +++++++++++++--- docs/api/classes/select-statement.ts.md | 202 ++++++++++++++++++++---- docs/api/classes/table.ts.md | 115 ++++++++++++-- docs/api/index.ts.md | 120 ++++++++------ docs/api/safe-string.ts.md | 50 +++--- ex/src/copy-fix-docs-ts.ts | 8 +- ex/src/run-docs-eval.ts | 5 +- lib/.prettierrc | 4 +- 12 files changed, 642 insertions(+), 181 deletions(-) delete mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index cf15e9b..0000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "useTabs": false, - "tabWidth": 4 -} diff --git a/TODO.md b/TODO.md index 026b371..1716733 100644 --- a/TODO.md +++ b/TODO.md @@ -1,21 +1,21 @@ # Build -- [ ] copy from fp-ts +- [ ] copy from fp-ts # DOCS -- [ ] document clickhouse extensions +- [ ] document clickhouse extensions -- [ ] cte examples +- [ ] cte examples -- [ ] easy extension sql safe string, example boolean in CH +- [ ] easy extension sql safe string, example boolean in CH # Global -- [ ] CI specify node version +- [ ] CI specify node version -- [ ] check TODO +- [ ] check TODO -- [ ] istanbul ignore, can some be removed? +- [ ] istanbul ignore, can some be removed? -- [ ] eslint (no console, no skip) +- [ ] eslint (no console, no skip) diff --git a/docs/api/classes/compound.ts.md b/docs/api/classes/compound.ts.md index 4022e2e..0036545 100644 --- a/docs/api/classes/compound.ts.md +++ b/docs/api/classes/compound.ts.md @@ -4,7 +4,6 @@ nav_order: 1 parent: Classes layout: default grand_parent: Api - --- ## compound overview @@ -28,12 +27,12 @@ export declare class Compound { private constructor( /* @internal */ public __props: { - content: TableOrSubquery[] - qualifier: 'UNION' | 'UNION ALL' | 'INTERSECT' | 'EXCEPT' - orderBy: SafeString[] - limit: SafeString | number | null + content: TableOrSubquery[]; + qualifier: "UNION" | "UNION ALL" | "INTERSECT" | "EXCEPT"; + orderBy: SafeString[]; + limit: SafeString | number | null; } - ) + ); } ``` @@ -44,7 +43,11 @@ Added in v0.0.0 **Signature** ```ts -orderBy: (f: (fields: Record) => SafeString[] | SafeString) => Compound +orderBy: ( + f: ( + fields: Record + ) => SafeString[] | SafeString +) => Compound; ``` Added in v0.0.0 @@ -54,7 +57,7 @@ Added in v0.0.0 **Signature** ```ts -limit: (limit: SafeString | number) => Compound +limit: (limit: SafeString | number) => Compound; ``` Added in v0.0.0 @@ -64,7 +67,12 @@ Added in v0.0.0 **Signature** ```ts -select: (f: (fields: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +select: ( + f: ( + fields: Record & + NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 @@ -74,7 +82,7 @@ Added in v0.0.0 **Signature** ```ts -selectStar: () => SelectStatement +selectStar: () => SelectStatement; ``` Added in v0.0.0 @@ -84,7 +92,24 @@ Added in v0.0.0 **Signature** ```ts -joinTable: (thisCompoundAlias: Alias1, operator: string, table: Table) => JoinedFactory | Exclude | `${Alias1}.${Selection}` | `${Alias2}.${Selection2}`, Alias1 | Alias2, Extract, Extract> +joinTable: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisCompoundAlias: Alias1, + operator: string, + table: Table +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias1}.${Selection}` + | `${Alias2}.${Selection2}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -94,7 +119,22 @@ Added in v0.0.0 **Signature** ```ts -commaJoinTable: (thisSelectAlias: Alias1, table: Table) => Joined | Exclude | `${Alias1}.${Selection}` | `${Alias2}.${Selection2}`, Alias1 | Alias2, Extract> +commaJoinTable: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisSelectAlias: Alias1, + table: Table +) => + Joined< + | Exclude + | Exclude + | `${Alias1}.${Selection}` + | `${Alias2}.${Selection2}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -104,7 +144,26 @@ Added in v0.0.0 **Signature** ```ts -joinSelect: (thisCompoundAlias: Alias1, operator: string, selectAlias: Alias2, select: SelectStatement) => JoinedFactory | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract, Extract> +joinSelect: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisCompoundAlias: Alias1, + operator: string, + selectAlias: Alias2, + select: SelectStatement +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -114,7 +173,24 @@ Added in v0.0.0 **Signature** ```ts -commaJoinSelect: (thisCompoundAlias: Alias1, selectAlias: Alias2, select: SelectStatement) => Joined | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract> +commaJoinSelect: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisCompoundAlias: Alias1, + selectAlias: Alias2, + select: SelectStatement +) => + Joined< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -124,7 +200,26 @@ Added in v0.0.0 **Signature** ```ts -joinCompound: (thisCompoundAlias: Alias1, operator: string, compoundAlias: Alias2, compound: Compound) => JoinedFactory | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract, Extract> +joinCompound: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisCompoundAlias: Alias1, + operator: string, + compoundAlias: Alias2, + compound: Compound +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -134,7 +229,24 @@ Added in v0.0.0 **Signature** ```ts -commaJoinCompound: (thisCompoundAlias: Alias1, compoundAlias: Alias2, compound: Compound) => Joined | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract> +commaJoinCompound: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisCompoundAlias: Alias1, + compoundAlias: Alias2, + compound: Compound +) => + Joined< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -144,7 +256,7 @@ Added in v0.0.0 **Signature** ```ts -stringify: () => string +stringify: () => string; ``` Added in v0.0.0 diff --git a/docs/api/classes/cte.ts.md b/docs/api/classes/cte.ts.md index 2bd3864..097abc9 100644 --- a/docs/api/classes/cte.ts.md +++ b/docs/api/classes/cte.ts.md @@ -4,7 +4,6 @@ nav_order: 2 parent: Classes layout: default grand_parent: Api - --- ## cte overview @@ -22,11 +21,11 @@ export declare class CommonTableExpression { private constructor( /* @internal */ public __props: { - columns: string[] - alias: string - select: SelectStatement + columns: string[]; + alias: string; + select: SelectStatement; } - ) + ); } ``` @@ -37,7 +36,12 @@ Added in v0.0.0 **Signature** ```ts -select: (f: (f: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +select: ( + f: ( + f: Record & + NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 diff --git a/docs/api/classes/joined.ts.md b/docs/api/classes/joined.ts.md index 7e0c35f..7f3d629 100644 --- a/docs/api/classes/joined.ts.md +++ b/docs/api/classes/joined.ts.md @@ -4,7 +4,6 @@ nav_order: 3 parent: Classes layout: default grand_parent: Api - --- ## joined overview @@ -27,10 +26,10 @@ export declare class Joined { private constructor( /* @internal */ public __props: { - commaJoins: CommaJoin - properJoins: ProperJoin + commaJoins: CommaJoin; + properJoins: ProperJoin; } - ) + ); } ``` @@ -41,7 +40,11 @@ Added in v0.0.0 **Signature** ```ts -select: (f: (f: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +select: ( + f: ( + f: Record & NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 @@ -51,7 +54,7 @@ Added in v0.0.0 **Signature** ```ts -selectStar: () => SelectStatement +selectStar: () => SelectStatement; ``` Added in v0.0.0 @@ -61,7 +64,11 @@ Added in v0.0.0 **Signature** ```ts -selectStarOfAliases: (aliases: TheAliases[]) => SelectStatement, RemoveAliasFromSelection> +selectStarOfAliases: (aliases: TheAliases[]) => + SelectStatement< + RemoveAliasFromSelection, + RemoveAliasFromSelection + >; ``` Added in v0.0.0 @@ -71,7 +78,17 @@ Added in v0.0.0 **Signature** ```ts -commaJoinTable: (table: Table) => Joined | Exclude, Ambiguous> | Exclude | `${Alias2}.${Selection2}`, Aliases | Alias2, Ambiguous | Extract> +commaJoinTable: ( + table: Table +) => + Joined< + | Exclude + | Exclude, Ambiguous> + | Exclude + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Ambiguous | Extract + >; ``` Added in v0.0.0 @@ -81,7 +98,18 @@ Added in v0.0.0 **Signature** ```ts -joinTable: (operator: string, table: Table) => JoinedFactory | Exclude, Ambiguous> | `${Alias2}.${Selection2}`, Aliases | Alias2, Extract, Ambiguous | Extract> +joinTable: ( + operator: string, + table: Table +) => + JoinedFactory< + | Exclude + | Exclude, Ambiguous> + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Extract, + Ambiguous | Extract + >; ``` Added in v0.0.0 @@ -91,7 +119,21 @@ Added in v0.0.0 **Signature** ```ts -commaJoinSelect: (alias: Alias2, select: SelectStatement) => Joined | Exclude, Ambiguous> | `${Alias2}.${Selection2}`, Aliases | Alias2, Ambiguous | Extract> +commaJoinSelect: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + alias: Alias2, + select: SelectStatement +) => + Joined< + | Exclude + | Exclude, Ambiguous> + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Ambiguous | Extract + >; ``` Added in v0.0.0 @@ -101,7 +143,23 @@ Added in v0.0.0 **Signature** ```ts -joinSelect: (operator: string, alias: Alias2, table: SelectStatement) => JoinedFactory | Exclude, Ambiguous> | `${Alias2}.${Selection2}`, Aliases | Alias2, Ambiguous | Extract, Extract> +joinSelect: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + operator: string, + alias: Alias2, + table: SelectStatement +) => + JoinedFactory< + | Exclude + | Exclude, Ambiguous> + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Ambiguous | Extract, + Extract + >; ``` Added in v0.0.0 @@ -111,7 +169,21 @@ Added in v0.0.0 **Signature** ```ts -commaJoinCompound: (alias: Alias2, compound: Compound) => Joined | Exclude, Ambiguous> | `${Alias2}.${Selection2}`, Aliases | Alias2, Ambiguous | Extract> +commaJoinCompound: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + alias: Alias2, + compound: Compound +) => + Joined< + | Exclude + | Exclude, Ambiguous> + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Ambiguous | Extract + >; ``` Added in v0.0.0 @@ -121,7 +193,23 @@ Added in v0.0.0 **Signature** ```ts -joinCompound: (operator: string, alias: Alias2, compound: Compound) => JoinedFactory | Exclude, Ambiguous> | `${Alias2}.${Selection2}`, Aliases | Alias2, Ambiguous | Extract, Extract> +joinCompound: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + operator: string, + alias: Alias2, + compound: Compound +) => + JoinedFactory< + | Exclude + | Exclude, Ambiguous> + | `${Alias2}.${Selection2}`, + Aliases | Alias2, + Ambiguous | Extract, + Extract + >; ``` Added in v0.0.0 @@ -134,15 +222,20 @@ Allows the selection of the constraint to be done in another method call. **Signature** ```ts -export declare class JoinedFactory { +export declare class JoinedFactory< + Selection, + Aliases, + Ambiguous, + UsingPossibleKeys +> { private constructor( /* @internal */ public __props: { - commaJoins: CommaJoin - properJoins: ProperJoin - newProperJoin: Omit + commaJoins: CommaJoin; + properJoins: ProperJoin; + newProperJoin: Omit; } - ) + ); } ``` @@ -153,7 +246,7 @@ Added in v0.0.0 **Signature** ```ts -noConstraint: () => Joined +noConstraint: () => Joined; ``` Added in v0.0.0 @@ -163,7 +256,9 @@ Added in v0.0.0 **Signature** ```ts -on: (on: (fields: Record) => SafeString | SafeString[]) => Joined +on: ( + on: (fields: Record) => SafeString | SafeString[] +) => Joined; ``` Added in v0.0.0 @@ -173,7 +268,7 @@ Added in v0.0.0 **Signature** ```ts -using: (keys: UsingPossibleKeys[]) => Joined +using: (keys: UsingPossibleKeys[]) => Joined; ``` Added in v0.0.0 diff --git a/docs/api/classes/select-statement.ts.md b/docs/api/classes/select-statement.ts.md index 7000d4f..bd57e76 100644 --- a/docs/api/classes/select-statement.ts.md +++ b/docs/api/classes/select-statement.ts.md @@ -4,7 +4,6 @@ nav_order: 4 parent: Classes layout: default grand_parent: Api - --- ## select-statement overview @@ -28,19 +27,19 @@ export declare class SelectStatement { private constructor( /* @internal */ public __props: { - from: TableOrSubquery | null - selection: SelectionWrapperTypes - replace: ReplaceT - orderBy: SafeString[] - groupBy: SafeString[] - limit: SafeString | number | null - where: SafeString[] - prewhere: SafeString[] - having: SafeString[] - distinct: boolean - clickhouseWith: ClickhouseWith[] + from: TableOrSubquery | null; + selection: SelectionWrapperTypes; + replace: ReplaceT; + orderBy: SafeString[]; + groupBy: SafeString[]; + limit: SafeString | number | null; + where: SafeString[]; + prewhere: SafeString[]; + having: SafeString[]; + distinct: boolean; + clickhouseWith: ClickhouseWith[]; } - ) + ); } ``` @@ -53,7 +52,21 @@ Clickhouse specific syntax extensions. **Signature** ```ts -clickhouse: { with_: (it: Record>) => SelectStatement; prewhere: (f: (fields: Record) => SafeString[] | SafeString) => SelectStatement; replace: (f: (f: Record & NoSelectFieldsCompileError) => ReplaceT) => SelectStatement; } +clickhouse: { + with_: ( + it: Record> + ) => SelectStatement; + prewhere: ( + f: ( + fields: Record + ) => SafeString[] | SafeString + ) => SelectStatement; + replace: ( + f: ( + f: Record & NoSelectFieldsCompileError + ) => ReplaceT + ) => SelectStatement; +} ``` Added in v0.0.0 @@ -63,7 +76,12 @@ Added in v0.0.0 **Signature** ```ts -select: (f: (f: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +select: ( + f: ( + f: Record & + NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 @@ -73,7 +91,7 @@ Added in v0.0.0 **Signature** ```ts -selectStar: () => SelectStatement +selectStar: () => SelectStatement; ``` Added in v0.0.0 @@ -83,7 +101,7 @@ Added in v0.0.0 **Signature** ```ts -appendSelectStar: () => SelectStatement +appendSelectStar: () => SelectStatement; ``` Added in v0.0.0 @@ -93,7 +111,12 @@ Added in v0.0.0 **Signature** ```ts -appendSelect: (f: (f: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +appendSelect: ( + f: ( + f: Record & + NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 @@ -103,7 +126,11 @@ Added in v0.0.0 **Signature** ```ts -where: (f: (fields: Record) => SafeString[] | SafeString) => SelectStatement +where: ( + f: ( + fields: Record + ) => SafeString[] | SafeString +) => SelectStatement; ``` Added in v0.0.0 @@ -113,7 +140,11 @@ Added in v0.0.0 **Signature** ```ts -having: (f: (fields: Record) => SafeString[] | SafeString) => SelectStatement +having: ( + f: ( + fields: Record + ) => SafeString[] | SafeString +) => SelectStatement; ``` Added in v0.0.0 @@ -123,7 +154,7 @@ Added in v0.0.0 **Signature** ```ts -distinct: () => SelectStatement +distinct: () => SelectStatement; ``` Added in v0.0.0 @@ -133,7 +164,11 @@ Added in v0.0.0 **Signature** ```ts -orderBy: (f: (fields: Record) => SafeString[] | SafeString) => SelectStatement +orderBy: ( + f: ( + fields: Record + ) => SafeString[] | SafeString +) => SelectStatement; ``` Added in v0.0.0 @@ -143,7 +178,11 @@ Added in v0.0.0 **Signature** ```ts -groupBy: (f: (fields: Record) => SafeString[] | SafeString) => SelectStatement +groupBy: ( + f: ( + fields: Record + ) => SafeString[] | SafeString +) => SelectStatement; ``` Added in v0.0.0 @@ -153,7 +192,7 @@ Added in v0.0.0 **Signature** ```ts -limit: (limit: SafeString | number) => SelectStatement +limit: (limit: SafeString | number) => SelectStatement; ``` Added in v0.0.0 @@ -163,7 +202,21 @@ Added in v0.0.0 **Signature** ```ts -commaJoinTable: (thisQueryAlias: Alias1, table: Table) => Joined | Exclude | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract> +commaJoinTable: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisQueryAlias: Alias1, + table: Table +) => + Joined< + | Exclude + | Exclude + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -173,7 +226,24 @@ Added in v0.0.0 **Signature** ```ts -joinTable: (thisQueryAlias: Alias1, operator: string, table: Table) => JoinedFactory | Exclude | `${Alias1}.${Selection}` | `${Alias2}.${Selection2}`, Alias1 | Alias2, Extract, Extract> +joinTable: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisQueryAlias: Alias1, + operator: string, + table: Table +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias1}.${Selection}` + | `${Alias2}.${Selection2}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -183,7 +253,24 @@ Added in v0.0.0 **Signature** ```ts -commaJoinSelect: (thisSelectAlias: Alias1, selectAlias: Alias2, select: SelectStatement) => Joined | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract> +commaJoinSelect: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisSelectAlias: Alias1, + selectAlias: Alias2, + select: SelectStatement +) => + Joined< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -193,7 +280,26 @@ Added in v0.0.0 **Signature** ```ts -joinSelect: (thisSelectAlias: Alias1, operator: string, selectAlias: Alias2, select: SelectStatement) => JoinedFactory | Exclude | `${Alias2}.${Selection2}` | `${Alias1}.${Selection}`, Alias1 | Alias2, Extract, Extract> +joinSelect: < + Alias1 extends string, + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisSelectAlias: Alias1, + operator: string, + selectAlias: Alias2, + select: SelectStatement +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias2}.${Selection2}` + | `${Alias1}.${Selection}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -203,7 +309,23 @@ Added in v0.0.0 **Signature** ```ts -commaJoinCompound: (thisSelectAlias: Alias1, compoundAlias: Alias2, compound: Compound) => Joined | Exclude | `${Alias1}.${Selection}` | `${Alias2}.${Selection2}`, Alias1 | Alias2, Extract> +commaJoinCompound: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisSelectAlias: Alias1, + compoundAlias: Alias2, + compound: Compound +) => + Joined< + | Exclude + | Exclude + | `${Alias1}.${Selection}` + | `${Alias2}.${Selection2}`, + Alias1 | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -213,7 +335,25 @@ Added in v0.0.0 **Signature** ```ts -joinCompound: (thisSelectAlias: Alias1, operator: string, compoundAlias: Alias2, compound: Compound) => JoinedFactory | Exclude | `${Alias1}.${Selection}` | `${Alias2}.${Selection2}`, Alias1 | Alias2, Extract, Extract> +joinCompound: < + Alias1 extends string, + Selection2 extends string, + Alias2 extends string +>( + thisSelectAlias: Alias1, + operator: string, + compoundAlias: Alias2, + compound: Compound +) => + JoinedFactory< + | Exclude + | Exclude + | `${Alias1}.${Selection}` + | `${Alias2}.${Selection2}`, + Alias1 | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -223,7 +363,7 @@ Added in v0.0.0 **Signature** ```ts -stringify: () => string +stringify: () => string; ``` Added in v0.0.0 diff --git a/docs/api/classes/table.ts.md b/docs/api/classes/table.ts.md index 7076e3a..41aa4b6 100644 --- a/docs/api/classes/table.ts.md +++ b/docs/api/classes/table.ts.md @@ -4,7 +4,6 @@ nav_order: 5 parent: Classes layout: default grand_parent: Api - --- ## table overview @@ -32,12 +31,12 @@ export declare class Table { private constructor( /* @internal */ public __props: { - columns: string[] - alias: string - name: string - final: boolean + columns: string[]; + alias: string; + name: string; + final: boolean; } - ) + ); } ``` @@ -48,7 +47,9 @@ Added in v0.0.0 **Signature** ```ts -clickhouse: { final: () => Table; } +clickhouse: { + final: () => Table; +} ``` Added in v0.0.0 @@ -58,7 +59,12 @@ Added in v0.0.0 **Signature** ```ts -select: (f: (f: Record & NoSelectFieldsCompileError) => Record) => SelectStatement +select: ( + f: ( + f: Record & + NoSelectFieldsCompileError + ) => Record +) => SelectStatement; ``` Added in v0.0.0 @@ -68,7 +74,8 @@ Added in v0.0.0 **Signature** ```ts -selectStar: () => SelectStatement +selectStar: () => + SelectStatement; ``` Added in v0.0.0 @@ -78,7 +85,17 @@ Added in v0.0.0 **Signature** ```ts -commaJoinTable: (table: Table) => Joined<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract> +commaJoinTable: ( + table: Table +) => + Joined< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -88,7 +105,19 @@ Added in v0.0.0 **Signature** ```ts -joinTable: (operator: string, table: Table) => JoinedFactory<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract, Extract> +joinTable: ( + operator: string, + table: Table +) => + JoinedFactory< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -98,7 +127,22 @@ Added in v0.0.0 **Signature** ```ts -commaJoinSelect: (selectAlias: Alias2, select: SelectStatement) => Joined<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract> +commaJoinSelect: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + selectAlias: Alias2, + select: SelectStatement +) => + Joined< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -108,7 +152,24 @@ Added in v0.0.0 **Signature** ```ts -joinSelect: (selectAlias: Alias2, operator: string, select: SelectStatement) => JoinedFactory<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract, Extract> +joinSelect: < + Scope2 extends string, + Selection2 extends string, + Alias2 extends string +>( + selectAlias: Alias2, + operator: string, + select: SelectStatement +) => + JoinedFactory< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 @@ -118,7 +179,18 @@ Added in v0.0.0 **Signature** ```ts -commaJoinCompound: (compoundAlias: Alias2, compound: Compound) => Joined<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract> +commaJoinCompound: ( + compoundAlias: Alias2, + compound: Compound +) => + Joined< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract + >; ``` Added in v0.0.0 @@ -128,7 +200,20 @@ Added in v0.0.0 **Signature** ```ts -joinCompound: (compoundAlias: Alias2, operator: string, compound: Compound) => JoinedFactory<`${Alias}.${Selection}` | Exclude | Exclude | `${Alias2}.${Selection2}`, Alias | Alias2, Extract, Extract> +joinCompound: ( + compoundAlias: Alias2, + operator: string, + compound: Compound +) => + JoinedFactory< + | `${Alias}.${Selection}` + | Exclude + | Exclude + | `${Alias2}.${Selection2}`, + Alias | Alias2, + Extract, + Extract + >; ``` Added in v0.0.0 diff --git a/docs/api/index.ts.md b/docs/api/index.ts.md index 5ea21c5..09fb0e2 100644 --- a/docs/api/index.ts.md +++ b/docs/api/index.ts.md @@ -3,7 +3,6 @@ title: index.ts nav_order: 6 parent: Api layout: default - --- ## index overview @@ -21,24 +20,31 @@ Creates a compound query using 'UNION' **Signature** ```ts -export declare const union: , CS extends SelectStatement[]>( +export declare const union: < + C extends SelectStatement, + CS extends SelectStatement[] +>( content: [C, ...CS] ) => Compound< - | (C extends SelectStatement ? Selection : never) - | (CS[number] extends SelectStatement ? Selection : never), + | (C extends SelectStatement + ? Selection + : never) + | (CS[number] extends SelectStatement + ? Selection + : never), C extends SelectStatement ? Selection : never -> +>; ``` **Example** ```ts -import { fromNothing, sql, union } from 'sql-select-ts' -const q1 = fromNothing({ a: sql(123) }) -const q2 = fromNothing({ a: sql(456) }) +import { fromNothing, sql, union } from "sql-select-ts"; +const q1 = fromNothing({ a: sql(123) }); +const q2 = fromNothing({ a: sql(456) }); -const u = union([q1, q2]) -assert.strictEqual(u.stringify(), 'SELECT 123 AS `a` UNION SELECT 456 AS `a`') +const u = union([q1, q2]); +assert.strictEqual(u.stringify(), "SELECT 123 AS `a` UNION SELECT 456 AS `a`"); ``` Added in v0.0.0 @@ -50,24 +56,34 @@ Creates a compound query using 'UNION ALL' **Signature** ```ts -export declare const unionAll: , CS extends SelectStatement[]>( +export declare const unionAll: < + C extends SelectStatement, + CS extends SelectStatement[] +>( content: [C, ...CS] ) => Compound< - | (C extends SelectStatement ? Selection : never) - | (CS[number] extends SelectStatement ? Selection : never), + | (C extends SelectStatement + ? Selection + : never) + | (CS[number] extends SelectStatement + ? Selection + : never), C extends SelectStatement ? Selection : never -> +>; ``` **Example** ```ts -import { fromNothing, sql, unionAll } from 'sql-select-ts' -const q1 = fromNothing({ a: sql(123) }) -const q2 = fromNothing({ a: sql(456) }) +import { fromNothing, sql, unionAll } from "sql-select-ts"; +const q1 = fromNothing({ a: sql(123) }); +const q2 = fromNothing({ a: sql(456) }); -const u = unionAll([q1, q2]) -assert.strictEqual(u.stringify(), 'SELECT 123 AS `a` UNION ALL SELECT 456 AS `a`') +const u = unionAll([q1, q2]); +assert.strictEqual( + u.stringify(), + "SELECT 123 AS `a` UNION ALL SELECT 456 AS `a`" +); ``` Added in v0.0.0 @@ -83,15 +99,15 @@ Select data from no source. ```ts export declare const fromNothing: ( it: Record -) => SelectStatement +) => SelectStatement; ``` **Example** ```ts -import { fromNothing, sql } from 'sql-select-ts' -const q1 = fromNothing({ a: sql(123) }) -assert.strictEqual(q1.stringify(), 'SELECT 123 AS `a`') +import { fromNothing, sql } from "sql-select-ts"; +const q1 = fromNothing({ a: sql(123) }); +assert.strictEqual(q1.stringify(), "SELECT 123 AS `a`"); ``` Added in v0.0.0 @@ -107,18 +123,21 @@ export declare const table: ( columns: Selection[], alias: Alias, name?: string -) => Table +) => Table; ``` **Example** ```ts -import { table } from 'sql-select-ts' -const t1 = table(['id', 'name'], 'users') -assert.strictEqual(t1.selectStar().stringify(), 'SELECT * FROM `users`') +import { table } from "sql-select-ts"; +const t1 = table(["id", "name"], "users"); +assert.strictEqual(t1.selectStar().stringify(), "SELECT * FROM `users`"); -const t2 = table(['id', 'name'], 'alias', 'users') -assert.strictEqual(t2.selectStar().stringify(), 'SELECT * FROM `users` AS `alias`') +const t2 = table(["id", "name"], "alias", "users"); +assert.strictEqual( + t2.selectStar().stringify(), + "SELECT * FROM `users` AS `alias`" +); ``` Added in v0.0.0 @@ -134,7 +153,7 @@ export declare const with_: ( select: SelectStatement, alias: Alias, columns?: Selection[] -) => CommonTableExpression +) => CommonTableExpression; ``` Added in v0.0.0 @@ -148,7 +167,7 @@ A wrapper over a string, We assume that strings inside the wrapper are safe to w **Signature** ```ts -export declare const SafeString: SafeString +export declare const SafeString: SafeString; ``` Added in v0.0.0 @@ -162,16 +181,16 @@ Useful for embedding other SQL statements in your SQL query, or building helper **Signature** ```ts -export declare const castSafe: (content: string) => SafeString +export declare const castSafe: (content: string) => SafeString; ``` **Example** ```ts -import { castSafe, sql } from 'sql-select-ts' +import { castSafe, sql } from "sql-select-ts"; -assert.strictEqual(castSafe(";'abc'").content, ";'abc'") -assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''") +assert.strictEqual(castSafe(";'abc'").content, ";'abc'"); +assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''"); ``` Added in v0.0.0 @@ -183,15 +202,15 @@ Type guard to check if the value is a SafeString. **Signature** ```ts -export declare const isSafeString: (it: any) => it is SafeString +export declare const isSafeString: (it: any) => it is SafeString; ``` **Example** ```ts -import { isSafeString, sql } from 'sql-select-ts' +import { isSafeString, sql } from "sql-select-ts"; -assert.strictEqual(isSafeString(sql(123)), true) +assert.strictEqual(isSafeString(sql(123)), true); ``` Added in v0.0.0 @@ -205,22 +224,25 @@ Check in depth docs in the safe-string.ts module. **Signature** ```ts -export declare const sql: typeof _sql +export declare const sql: typeof _sql; ``` **Example** ```ts -import { fromNothing, sql } from 'sql-select-ts' -assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''") -assert.strictEqual(sql(123).content, '123') -assert.strictEqual(sql(null).content, 'NULL') -assert.strictEqual(sql`${123} + 456`.content, '123 + 456') -const name = 'A' -const names = ['A', 'B', 'C'] -assert.strictEqual(sql`${name} IN (${names})`.content, "'A' IN ('A', 'B', 'C')") -const q = fromNothing({ it: sql(123) }) -assert.strictEqual(sql`${name} IN ${q}`.content, "'A' IN (SELECT 123 AS `it`)") +import { fromNothing, sql } from "sql-select-ts"; +assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''"); +assert.strictEqual(sql(123).content, "123"); +assert.strictEqual(sql(null).content, "NULL"); +assert.strictEqual(sql`${123} + 456`.content, "123 + 456"); +const name = "A"; +const names = ["A", "B", "C"]; +assert.strictEqual( + sql`${name} IN (${names})`.content, + "'A' IN ('A', 'B', 'C')" +); +const q = fromNothing({ it: sql(123) }); +assert.strictEqual(sql`${name} IN ${q}`.content, "'A' IN (SELECT 123 AS `it`)"); ``` Added in v0.0.0 diff --git a/docs/api/safe-string.ts.md b/docs/api/safe-string.ts.md index fbdb0a6..664b8c4 100644 --- a/docs/api/safe-string.ts.md +++ b/docs/api/safe-string.ts.md @@ -3,7 +3,6 @@ title: safe-string.ts nav_order: 7 parent: Api layout: default - --- ## safe-string overview @@ -23,16 +22,16 @@ Useful for embedding other SQL statements in your SQL query, or building helper **Signature** ```ts -export declare const castSafe: (content: string) => SafeString +export declare const castSafe: (content: string) => SafeString; ``` **Example** ```ts -import { castSafe, sql } from 'sql-select-ts' +import { castSafe, sql } from "sql-select-ts"; -assert.strictEqual(castSafe(";'abc'").content, ";'abc'") -assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''") +assert.strictEqual(castSafe(";'abc'").content, ";'abc'"); +assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''"); ``` Added in v0.0.0 @@ -44,15 +43,15 @@ Type guard to check if the value is a SafeString. **Signature** ```ts -export declare const isSafeString: (it: any) => it is SafeString +export declare const isSafeString: (it: any) => it is SafeString; ``` **Example** ```ts -import { isSafeString, sql } from 'sql-select-ts' +import { isSafeString, sql } from "sql-select-ts"; -assert.strictEqual(isSafeString(sql(123)), true) +assert.strictEqual(isSafeString(sql(123)), true); ``` Added in v0.0.0 @@ -64,26 +63,29 @@ Safe-string builder. Works as a function or string template literal. **Signature** ```ts -export declare function sql(it: string | number | null): SafeString +export declare function sql(it: string | number | null): SafeString; export declare function sql( template: ReadonlyArray, ...args: (SqlSupportedTypes | readonly SqlSupportedTypes[])[] -): SafeString +): SafeString; ``` **Example** ```ts -import { fromNothing, sql } from 'sql-select-ts' -assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''") -assert.strictEqual(sql(123).content, '123') -assert.strictEqual(sql(null).content, 'NULL') -assert.strictEqual(sql`${123} + 456`.content, '123 + 456') -const name = 'A' -const names = ['A', 'B', 'C'] -assert.strictEqual(sql`${name} IN (${names})`.content, "'A' IN ('A', 'B', 'C')") -const q = fromNothing({ it: sql(123) }) -assert.strictEqual(sql`${name} IN ${q}`.content, "'A' IN (SELECT 123 AS `it`)") +import { fromNothing, sql } from "sql-select-ts"; +assert.strictEqual(sql(";'abc'").content, "';\\'abc\\''"); +assert.strictEqual(sql(123).content, "123"); +assert.strictEqual(sql(null).content, "NULL"); +assert.strictEqual(sql`${123} + 456`.content, "123 + 456"); +const name = "A"; +const names = ["A", "B", "C"]; +assert.strictEqual( + sql`${name} IN (${names})`.content, + "'A' IN ('A', 'B', 'C')" +); +const q = fromNothing({ it: sql(123) }); +assert.strictEqual(sql`${name} IN ${q}`.content, "'A' IN (SELECT 123 AS `it`)"); ``` Added in v0.0.0 @@ -98,9 +100,9 @@ Type used to represent a string that is safe to use in a SQL query. ```ts export type SafeString = { - _tag: typeof SafeStringURI - content: string -} + _tag: typeof SafeStringURI; + content: string; +}; ``` Added in v0.0.0 @@ -112,7 +114,7 @@ Tag used to discriminate a SafeString object. **Signature** ```ts -export declare const SafeStringURI: 'SafeString' +export declare const SafeStringURI: "SafeString"; ``` Added in v0.0.0 diff --git a/ex/src/copy-fix-docs-ts.ts b/ex/src/copy-fix-docs-ts.ts index 9d10e3e..34257fa 100644 --- a/ex/src/copy-fix-docs-ts.ts +++ b/ex/src/copy-fix-docs-ts.ts @@ -11,6 +11,7 @@ import type { Code } from "mdast"; import yaml from "js-yaml"; import { pipe } from "fp-ts/lib/function"; import * as O from "fp-ts/lib/Option"; +import * as prettier from "prettier"; const isYaml = (it: Parent): it is Code & Parent => it.type === "yaml"; @@ -60,7 +61,7 @@ const fixFrontmatter = }); }; -const process = async ( +const processRemark = async ( content: string, parent: string, grand_parent: string | null @@ -90,8 +91,9 @@ const copyFile = async ( if (src.endsWith(".ts.md") && dest.endsWith(".ts.md")) { const content = await fs.readFile(src, "utf-8"); - const processed = await process(content, parent, grand_parent); - await fs.writeFile(dest, processed); + const processed = await processRemark(content, parent, grand_parent); + const pretty = await prettier.format(processed, { filepath: "it.md" }); + await fs.writeFile(dest, pretty); } }; diff --git a/ex/src/run-docs-eval.ts b/ex/src/run-docs-eval.ts index fa655db..8422f24 100644 --- a/ex/src/run-docs-eval.ts +++ b/ex/src/run-docs-eval.ts @@ -291,7 +291,10 @@ const processFile = async ( return; } - await fs.writeFile(ouputFile, String(file)); + await fs.writeFile( + ouputFile, + prettier.format(String(file), { filepath: "it.md" }) + ); }; async function main() { const transpileOnly = argv.some((it) => it.includes("--transpileOnly")); diff --git a/lib/.prettierrc b/lib/.prettierrc index 9858f87..cf15e9b 100644 --- a/lib/.prettierrc +++ b/lib/.prettierrc @@ -1,4 +1,4 @@ { - "useTabs": false, - "tabWidth": 4 + "useTabs": false, + "tabWidth": 4 }