@hypequery/clickhouse 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,6 @@
10
10
  [![GitHub stars](https://img.shields.io/github/stars/lukejreilly/hypequery)](https://github.com/lukejreilly/hypequery/stargazers)
11
11
  </div>
12
12
 
13
- > **Note:** This package is published on npm as `@hypequery/core`. The unscoped package `hypequery-core` is unrelated and should not be used.
14
13
 
15
14
  ## Overview
16
15
 
@@ -28,21 +27,25 @@ hypequery is a typescript-first query builder for ClickHouse designed specifical
28
27
 
29
28
  ## Installation
30
29
 
30
+ ### npm
31
31
  ```bash
32
- # npm
33
- npm install @hypequery/core
32
+ npm install @hypequery/clickhouse
33
+ ```
34
34
 
35
- # yarn
36
- yarn add @hypequery/core
35
+ ### yarn
36
+ ```bash
37
+ yarn add @hypequery/clickhouse
38
+ ```
37
39
 
38
- # pnpm
39
- pnpm add @hypequery/core
40
+ ### pnpm
41
+ ```bash
42
+ pnpm add @hypequery/clickhouse
40
43
  ```
41
44
 
42
45
  ## Quick Start
43
46
 
44
47
  ```typescript
45
- import { createQueryBuilder } from '@hypequery/core';
48
+ import { createQueryBuilder } from '@hypequery/clickhouse';
46
49
  import type { Schema } from './generated-schema';
47
50
 
48
51
  // Initialize the query builder
@@ -69,7 +72,7 @@ hypequery provides a CLI tool to generate TypeScript types from your ClickHouse
69
72
 
70
73
  ```bash
71
74
  # Install globally (optional)
72
- npm install -g @hypequery/core
75
+ npm install -g @hypequery/clickhouse
73
76
 
74
77
  # Generate schema types
75
78
  npx hypequery-generate --host your-clickhouse-host --database your-database
@@ -78,7 +81,7 @@ npx hypequery-generate --host your-clickhouse-host --database your-database
78
81
  This creates a `generated-schema.ts` file that you can import in your application:
79
82
 
80
83
  ```typescript
81
- import { createQueryBuilder } from '@hypequery/core';
84
+ import { createQueryBuilder } from '@hypequery/clickhouse';
82
85
  import type { IntrospectedSchema } from './generated-schema';
83
86
 
84
87
  const db = createQueryBuilder<IntrospectedSchema>({
@@ -108,7 +111,7 @@ db.table('trips').select(['non_existent_column']); // TypeScript error
108
111
  Implement interactive dashboards with cross-filtering support:
109
112
 
110
113
  ```typescript
111
- import { CrossFilter } from '@hypequery/core';
114
+ import { CrossFilter } from '@hypequery/clickhouse';
112
115
 
113
116
  // Create a filter
114
117
  const filter = new CrossFilter()
@@ -226,8 +229,8 @@ const db = createQueryBuilder<Schema>({
226
229
 
227
230
  hypequery follows semantic versioning and provides multiple release channels:
228
231
 
229
- - **Latest**: Stable releases (`npm install @hypequery/core`)
230
- - **Beta**: Pre-release versions (`npm install @hypequery/core@beta`)
232
+ - **Latest**: Stable releases (`npm install @hypequery/clickhouse`)
233
+ - **Beta**: Pre-release versions (`npm install @hypequery/clickhouse@beta`)
231
234
 
232
235
  ## Documentation
233
236
 
@@ -32,14 +32,18 @@ export declare function rawAs(sql: string, alias: string): AliasedExpression;
32
32
  * @returns SQL expression or aliased expression
33
33
  */
34
34
  export declare function toDateTime(field: string, alias?: string): SqlExpression | AliasedExpression;
35
+ export interface FormatDateTimeOptions {
36
+ timezone?: string;
37
+ alias?: string;
38
+ }
35
39
  /**
36
40
  * Formats a DateTime value using the specified format
37
41
  * @param field The field or expression to format
38
42
  * @param format The date format string
39
- * @param alias Optional alias for the result
43
+ * @param options Optional configuration including timezone and alias
40
44
  * @returns SQL expression or aliased expression
41
45
  */
42
- export declare function formatDateTime(field: string, format: string, alias?: string): SqlExpression | AliasedExpression;
46
+ export declare function formatDateTime(field: string, format: string, options?: FormatDateTimeOptions): SqlExpression | AliasedExpression;
43
47
  /**
44
48
  * Truncates a date/time value to the start of the specified interval
45
49
  * @param field The field to truncate
@@ -1 +1 @@
1
- {"version":3,"file":"sql-expressions.d.ts","sourceRoot":"","sources":["../../../src/core/utils/sql-expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAA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AAa;IACtD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAK9C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAMnE;AAID;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,iBAAiB,CAI3F;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,qBAA0B,GAClC,aAAa,GAAG,iBAAiB,CAYnC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,iBAAiB,CAIpH;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,iBAAiB,CAK7K"}
@@ -38,13 +38,17 @@ export function toDateTime(field, alias) {
38
38
  * Formats a DateTime value using the specified format
39
39
  * @param field The field or expression to format
40
40
  * @param format The date format string
41
- * @param alias Optional alias for the result
41
+ * @param options Optional configuration including timezone and alias
42
42
  * @returns SQL expression or aliased expression
43
43
  */
44
- export function formatDateTime(field, format, alias) {
45
- return alias
46
- ? rawAs(`formatDateTime(${field}, '${format}')`, alias)
47
- : raw(`formatDateTime(${field}, '${format}')`);
44
+ export function formatDateTime(field, format, options = {}) {
45
+ const { timezone, alias } = options;
46
+ let sql = `formatDateTime(${field}, '${format}'`;
47
+ if (timezone) {
48
+ sql += `, '${timezone}'`;
49
+ }
50
+ sql += ')';
51
+ return alias ? rawAs(sql, alias) : raw(sql);
48
52
  }
49
53
  /**
50
54
  * Truncates a date/time value to the start of the specified interval
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { TableSchema, QueryConfig, ColumnType, WhereExpression, GroupByExpr
5
5
  export type { JoinPath, JoinPathOptions } from './core/join-relationships.js';
6
6
  export { CrossFilter } from './core/cross-filter.js';
7
7
  export { logger } from './core/utils/logger.js';
8
- export { raw, rawAs, toDateTime, formatDateTime, toStartOfInterval, datePart } from './core/utils/sql-expressions.js';
8
+ export { raw, rawAs, toDateTime, formatDateTime, toStartOfInterval, datePart, FormatDateTimeOptions } from './core/utils/sql-expressions.js';
9
9
  export type { SqlExpression, AliasedExpression } from './core/utils/sql-expressions.js';
10
10
  //# sourceMappingURL=index.d.ts.map
11
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACtB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,iCAAiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/clickhouse",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "ClickHouse typescript query builder",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",