@clickhouse/client 0.1.1 → 0.2.0-beta1

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.
Files changed (119) hide show
  1. package/README.md +10 -6
  2. package/dist/client.d.ts +12 -141
  3. package/dist/client.js +39 -229
  4. package/dist/client.js.map +1 -1
  5. package/dist/connection/index.d.ts +3 -1
  6. package/dist/connection/index.js +3 -1
  7. package/dist/connection/index.js.map +1 -1
  8. package/dist/connection/node_base_connection.d.ts +50 -0
  9. package/dist/connection/{adapter/base_http_adapter.js → node_base_connection.js} +65 -111
  10. package/dist/connection/node_base_connection.js.map +1 -0
  11. package/dist/connection/node_http_connection.d.ts +11 -0
  12. package/dist/connection/node_http_connection.js +32 -0
  13. package/dist/connection/node_http_connection.js.map +1 -0
  14. package/dist/connection/node_https_connection.d.ts +12 -0
  15. package/dist/connection/node_https_connection.js +53 -0
  16. package/dist/connection/node_https_connection.js.map +1 -0
  17. package/dist/index.d.ts +4 -15
  18. package/dist/index.js +11 -9
  19. package/dist/index.js.map +1 -1
  20. package/dist/result_set.d.ts +13 -0
  21. package/dist/{result.js → result_set.js} +5 -32
  22. package/dist/result_set.js.map +1 -0
  23. package/dist/utils/encoder.d.ts +7 -0
  24. package/dist/utils/encoder.js +55 -0
  25. package/dist/utils/encoder.js.map +1 -0
  26. package/dist/utils/index.d.ts +3 -1
  27. package/dist/utils/index.js +3 -1
  28. package/dist/utils/index.js.map +1 -1
  29. package/dist/utils/process.js.map +1 -1
  30. package/dist/utils/stream.d.ts +1 -1
  31. package/dist/utils/stream.js.map +1 -1
  32. package/dist/utils/user_agent.js +1 -2
  33. package/dist/utils/user_agent.js.map +1 -1
  34. package/dist/version.d.ts +2 -2
  35. package/dist/version.js +2 -1
  36. package/dist/version.js.map +1 -1
  37. package/package.json +7 -48
  38. package/dist/clickhouse_types.d.ts +0 -24
  39. package/dist/clickhouse_types.js +0 -3
  40. package/dist/clickhouse_types.js.map +0 -1
  41. package/dist/connection/adapter/base_http_adapter.d.ts +0 -38
  42. package/dist/connection/adapter/base_http_adapter.js.map +0 -1
  43. package/dist/connection/adapter/http_adapter.d.ts +0 -10
  44. package/dist/connection/adapter/http_adapter.js +0 -27
  45. package/dist/connection/adapter/http_adapter.js.map +0 -1
  46. package/dist/connection/adapter/http_search_params.d.ts +0 -11
  47. package/dist/connection/adapter/http_search_params.js +0 -42
  48. package/dist/connection/adapter/http_search_params.js.map +0 -1
  49. package/dist/connection/adapter/https_adapter.d.ts +0 -11
  50. package/dist/connection/adapter/https_adapter.js +0 -48
  51. package/dist/connection/adapter/https_adapter.js.map +0 -1
  52. package/dist/connection/adapter/index.d.ts +0 -2
  53. package/dist/connection/adapter/index.js +0 -8
  54. package/dist/connection/adapter/index.js.map +0 -1
  55. package/dist/connection/adapter/transform_url.d.ts +0 -5
  56. package/dist/connection/adapter/transform_url.js +0 -15
  57. package/dist/connection/adapter/transform_url.js.map +0 -1
  58. package/dist/connection/connection.d.ts +0 -63
  59. package/dist/connection/connection.js +0 -17
  60. package/dist/connection/connection.js.map +0 -1
  61. package/dist/data_formatter/format_query_params.d.ts +0 -1
  62. package/dist/data_formatter/format_query_params.js +0 -61
  63. package/dist/data_formatter/format_query_params.js.map +0 -1
  64. package/dist/data_formatter/format_query_settings.d.ts +0 -2
  65. package/dist/data_formatter/format_query_settings.js +0 -21
  66. package/dist/data_formatter/format_query_settings.js.map +0 -1
  67. package/dist/data_formatter/formatter.d.ts +0 -23
  68. package/dist/data_formatter/formatter.js +0 -96
  69. package/dist/data_formatter/formatter.js.map +0 -1
  70. package/dist/data_formatter/index.d.ts +0 -3
  71. package/dist/data_formatter/index.js +0 -23
  72. package/dist/data_formatter/index.js.map +0 -1
  73. package/dist/error/index.d.ts +0 -1
  74. package/dist/error/index.js +0 -18
  75. package/dist/error/index.js.map +0 -1
  76. package/dist/error/parse_error.d.ts +0 -12
  77. package/dist/error/parse_error.js +0 -39
  78. package/dist/error/parse_error.js.map +0 -1
  79. package/dist/logger.d.ts +0 -33
  80. package/dist/logger.js +0 -108
  81. package/dist/logger.js.map +0 -1
  82. package/dist/result.d.ts +0 -52
  83. package/dist/result.js.map +0 -1
  84. package/dist/schema/common.d.ts +0 -8
  85. package/dist/schema/common.js +0 -3
  86. package/dist/schema/common.js.map +0 -1
  87. package/dist/schema/engines.d.ts +0 -40
  88. package/dist/schema/engines.js +0 -61
  89. package/dist/schema/engines.js.map +0 -1
  90. package/dist/schema/index.d.ts +0 -7
  91. package/dist/schema/index.js +0 -24
  92. package/dist/schema/index.js.map +0 -1
  93. package/dist/schema/query_formatter.d.ts +0 -9
  94. package/dist/schema/query_formatter.js +0 -48
  95. package/dist/schema/query_formatter.js.map +0 -1
  96. package/dist/schema/result.d.ts +0 -13
  97. package/dist/schema/result.js +0 -3
  98. package/dist/schema/result.js.map +0 -1
  99. package/dist/schema/schema.d.ts +0 -6
  100. package/dist/schema/schema.js +0 -20
  101. package/dist/schema/schema.js.map +0 -1
  102. package/dist/schema/stream.d.ts +0 -11
  103. package/dist/schema/stream.js +0 -25
  104. package/dist/schema/stream.js.map +0 -1
  105. package/dist/schema/table.d.ts +0 -44
  106. package/dist/schema/table.js +0 -73
  107. package/dist/schema/table.js.map +0 -1
  108. package/dist/schema/types.d.ts +0 -201
  109. package/dist/schema/types.js +0 -268
  110. package/dist/schema/types.js.map +0 -1
  111. package/dist/schema/where.d.ts +0 -8
  112. package/dist/schema/where.js +0 -43
  113. package/dist/schema/where.js.map +0 -1
  114. package/dist/settings.d.ts +0 -1453
  115. package/dist/settings.js +0 -28
  116. package/dist/settings.js.map +0 -1
  117. package/dist/utils/string.d.ts +0 -1
  118. package/dist/utils/string.js +0 -9
  119. package/dist/utils/string.js.map +0 -1
@@ -1,61 +0,0 @@
1
- "use strict";
2
- // See https://clickhouse.com/docs/en/engines/table-engines/
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.GraphiteMergeTree = exports.VersionedCollapsingMergeTree = exports.CollapsingMergeTree = exports.AggregatingMergeTree = exports.SummingMergeTree = exports.ReplacingMergeTree = exports.ReplicatedMergeTree = exports.MergeTree = void 0;
5
- const MergeTree = () => ({
6
- toString: () => `MergeTree()`,
7
- type: 'MergeTree',
8
- });
9
- exports.MergeTree = MergeTree;
10
- const ReplicatedMergeTree = ({ zoo_path, replica_name, ver, }) => ({
11
- toString: () => {
12
- const _ver = ver ? `, ${ver}` : '';
13
- return `ReplicatedMergeTree('${zoo_path}', '${replica_name}'${_ver})`;
14
- },
15
- type: 'ReplicatedMergeTree',
16
- });
17
- exports.ReplicatedMergeTree = ReplicatedMergeTree;
18
- const ReplacingMergeTree = (ver) => ({
19
- toString: () => {
20
- const _ver = ver ? `, ${ver}` : '';
21
- return `ReplacingMergeTree(${_ver})`;
22
- },
23
- type: 'ReplacingMergeTree',
24
- });
25
- exports.ReplacingMergeTree = ReplacingMergeTree;
26
- const SummingMergeTree = (columns) => ({
27
- toString: () => {
28
- return `SummingMergeTree(${(columns || []).join(', ')})`;
29
- },
30
- type: 'SummingMergeTree',
31
- });
32
- exports.SummingMergeTree = SummingMergeTree;
33
- const AggregatingMergeTree = () => ({
34
- toString: () => {
35
- return `AggregatingMergeTree()`;
36
- },
37
- type: 'AggregatingMergeTree',
38
- });
39
- exports.AggregatingMergeTree = AggregatingMergeTree;
40
- const CollapsingMergeTree = (sign) => ({
41
- toString: () => {
42
- return `CollapsingMergeTree(${sign})`;
43
- },
44
- type: 'CollapsingMergeTree',
45
- });
46
- exports.CollapsingMergeTree = CollapsingMergeTree;
47
- const VersionedCollapsingMergeTree = (sign, version) => ({
48
- toString: () => {
49
- return `VersionedCollapsingMergeTree(${sign}, ${version})`;
50
- },
51
- type: 'VersionedCollapsingMergeTree',
52
- });
53
- exports.VersionedCollapsingMergeTree = VersionedCollapsingMergeTree;
54
- const GraphiteMergeTree = (config_section) => ({
55
- toString: () => {
56
- return `CollapsingMergeTree(${config_section})`;
57
- },
58
- type: 'GraphiteMergeTree',
59
- });
60
- exports.GraphiteMergeTree = GraphiteMergeTree;
61
- //# sourceMappingURL=engines.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/schema/engines.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;AAerD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC;IAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,aAAa;IAC7B,IAAI,EAAE,WAAW;CAClB,CAAC,CAAA;AAHW,QAAA,SAAS,aAGpB;AASK,MAAM,mBAAmB,GAAG,CAAC,EAClC,QAAQ,EACR,YAAY,EACZ,GAAG,GAC2B,EAAE,EAAE,CAAC,CAAC;IACpC,QAAQ,EAAE,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAClC,OAAO,wBAAwB,QAAQ,OAAO,YAAY,IAAI,IAAI,GAAG,CAAA;IACvE,CAAC;IACD,IAAI,EAAE,qBAAqB;CAC5B,CAAC,CAAA;AAVW,QAAA,mBAAmB,uBAU9B;AAEK,MAAM,kBAAkB,GAAG,CAAC,GAAY,EAAE,EAAE,CAAC,CAAC;IACnD,QAAQ,EAAE,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAClC,OAAO,sBAAsB,IAAI,GAAG,CAAA;IACtC,CAAC;IACD,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAA;AANW,QAAA,kBAAkB,sBAM7B;AAEK,MAAM,gBAAgB,GAAG,CAAC,OAAkB,EAAE,EAAE,CAAC,CAAC;IACvD,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,oBAAoB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;IAC1D,CAAC;IACD,IAAI,EAAE,kBAAkB;CACzB,CAAC,CAAA;AALW,QAAA,gBAAgB,oBAK3B;AAEK,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC;IACzC,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,wBAAwB,CAAA;IACjC,CAAC;IACD,IAAI,EAAE,sBAAsB;CAC7B,CAAC,CAAA;AALW,QAAA,oBAAoB,wBAK/B;AAEK,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;IACpD,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,uBAAuB,IAAI,GAAG,CAAA;IACvC,CAAC;IACD,IAAI,EAAE,qBAAqB;CAC5B,CAAC,CAAA;AALW,QAAA,mBAAmB,uBAK9B;AAEK,MAAM,4BAA4B,GAAG,CAC1C,IAAY,EACZ,OAAe,EACf,EAAE,CAAC,CAAC;IACJ,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,gCAAgC,IAAI,KAAK,OAAO,GAAG,CAAA;IAC5D,CAAC;IACD,IAAI,EAAE,8BAA8B;CACrC,CAAC,CAAA;AARW,QAAA,4BAA4B,gCAQvC;AAEK,MAAM,iBAAiB,GAAG,CAAC,cAAsB,EAAE,EAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,uBAAuB,cAAc,GAAG,CAAA;IACjD,CAAC;IACD,IAAI,EAAE,mBAAmB;CAC1B,CAAC,CAAA;AALW,QAAA,iBAAiB,qBAK5B"}
@@ -1,7 +0,0 @@
1
- export * from './schema';
2
- export * from './types';
3
- export * from './table';
4
- export * from './engines';
5
- export * from './common';
6
- export * from './stream';
7
- export * from './where';
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./schema"), exports);
18
- __exportStar(require("./types"), exports);
19
- __exportStar(require("./table"), exports);
20
- __exportStar(require("./engines"), exports);
21
- __exportStar(require("./common"), exports);
22
- __exportStar(require("./stream"), exports);
23
- __exportStar(require("./where"), exports);
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,0CAAuB;AACvB,0CAAuB;AACvB,4CAAyB;AACzB,2CAAwB;AACxB,2CAAwB;AACxB,0CAAuB"}
@@ -1,9 +0,0 @@
1
- import type { Shape } from './common';
2
- import type { CreateTableOptions, TableOptions } from './index';
3
- import type { WhereExpr } from './where';
4
- import type { NonEmptyArray } from './common';
5
- export declare const QueryFormatter: {
6
- createTable: <S extends Shape>(tableOptions: TableOptions<S>, { engine: _engine, if_not_exists, on_cluster, order_by, partition_by, primary_key, settings: _settings, }: CreateTableOptions<S>) => string;
7
- select: <S_1 extends Shape>(tableOptions: TableOptions<S_1>, whereExpr?: WhereExpr<S_1> | undefined, columns?: NonEmptyArray<keyof S_1> | undefined, orderBy?: NonEmptyArray<[keyof S_1, "ASC" | "DESC"]> | undefined) => string;
8
- };
9
- export declare function getTableName<S extends Shape>({ database, name, }: TableOptions<S>): string;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTableName = exports.QueryFormatter = void 0;
4
- exports.QueryFormatter = {
5
- // See https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree/#table_engine-mergetree-creating-a-table
6
- createTable: (tableOptions, { engine: _engine, if_not_exists, on_cluster, order_by, partition_by, primary_key, settings: _settings, }) => {
7
- const ifNotExist = if_not_exists ? ' IF NOT EXISTS' : '';
8
- const tableName = getTableName(tableOptions);
9
- const onCluster = on_cluster ? ` ON CLUSTER '${on_cluster}'` : '';
10
- const columns = ` (${tableOptions.schema.toString()})`;
11
- const engine = ` ENGINE ${_engine}`;
12
- const orderBy = order_by ? ` ORDER BY (${order_by.join(', ')})` : '';
13
- const partitionBy = partition_by
14
- ? ` PARTITION BY (${partition_by.join(', ')})`
15
- : '';
16
- const primaryKey = primary_key
17
- ? ` PRIMARY KEY (${primary_key.join(', ')})`
18
- : '';
19
- const settings = _settings && Object.keys(_settings).length
20
- ? ' SETTINGS ' +
21
- Object.entries(_settings)
22
- .map(([key, value]) => {
23
- const v = typeof value === 'string' ? `'${value}'` : value;
24
- return `${key} = ${v}`;
25
- })
26
- .join(', ')
27
- : '';
28
- return (`CREATE TABLE${ifNotExist} ${tableName}${onCluster}${columns}${engine}` +
29
- `${orderBy}${partitionBy}${primaryKey}${settings}`);
30
- },
31
- // https://clickhouse.com/docs/en/sql-reference/statements/select/
32
- select: (tableOptions, whereExpr, columns, orderBy) => {
33
- const tableName = getTableName(tableOptions);
34
- const where = whereExpr ? ` WHERE ${whereExpr.toString()}` : '';
35
- const cols = columns ? columns.join(', ') : '*';
36
- const order = orderBy
37
- ? ` ORDER BY ${orderBy
38
- .map(([column, order]) => `${column.toString()} ${order}`)
39
- .join(', ')}`
40
- : '';
41
- return `SELECT ${cols} FROM ${tableName}${where}${order}`;
42
- },
43
- };
44
- function getTableName({ database, name, }) {
45
- return database !== undefined ? `${database}.${name}` : name;
46
- }
47
- exports.getTableName = getTableName;
48
- //# sourceMappingURL=query_formatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query_formatter.js","sourceRoot":"","sources":["../../src/schema/query_formatter.ts"],"names":[],"mappings":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,CAAC,CAAC,IAAI,CAAA;AAC9D,CAAC;AALD,oCAKC"}
@@ -1,13 +0,0 @@
1
- export interface SelectResult<T> {
2
- data: T[];
3
- statistics: {
4
- bytes_read: number;
5
- elapsed: number;
6
- rows_read: number;
7
- };
8
- rows: number;
9
- meta: {
10
- name: string;
11
- type: string;
12
- }[];
13
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=result.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/schema/result.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import type { Shape } from './common';
2
- export declare class Schema<S extends Shape> {
3
- readonly shape: S;
4
- constructor(shape: S);
5
- toString(delimiter?: string): string;
6
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Schema = void 0;
4
- class Schema {
5
- constructor(shape) {
6
- Object.defineProperty(this, "shape", {
7
- enumerable: true,
8
- configurable: true,
9
- writable: true,
10
- value: shape
11
- });
12
- }
13
- toString(delimiter) {
14
- return Object.entries(this.shape)
15
- .map(([column, type]) => `${column} ${type.toString()}`)
16
- .join(delimiter !== null && delimiter !== void 0 ? delimiter : ', ');
17
- }
18
- }
19
- exports.Schema = Schema;
20
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema/schema.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IACjB,YAA4B,KAAQ;;;;;mBAAR;;IAAW,CAAC;IAExC,QAAQ,CAAC,SAAkB;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;aACvD,IAAI,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AARD,wBAQC"}
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import Stream from 'stream';
3
- export interface SelectResult<T> {
4
- asyncGenerator(): AsyncGenerator<T, void>;
5
- json(): Promise<T[]>;
6
- }
7
- export declare class InsertStream<T> extends Stream.Readable {
8
- constructor();
9
- add(data: T): void;
10
- complete(): void;
11
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InsertStream = void 0;
7
- const stream_1 = __importDefault(require("stream"));
8
- class InsertStream extends stream_1.default.Readable {
9
- constructor() {
10
- super({
11
- objectMode: true,
12
- read() {
13
- // Avoid [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
14
- },
15
- });
16
- }
17
- add(data) {
18
- this.push(data);
19
- }
20
- complete() {
21
- this.push(null);
22
- }
23
- }
24
- exports.InsertStream = InsertStream;
25
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/schema/stream.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAO3B,MAAa,YAAgB,SAAQ,gBAAM,CAAC,QAAQ;IAClD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,IAAI;YAChB,IAAI;gBACF,4EAA4E;YAC9E,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IACD,GAAG,CAAC,IAAO;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IACD,QAAQ;QACN,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAfD,oCAeC"}
@@ -1,44 +0,0 @@
1
- /// <reference types="node" />
2
- import type { TableEngine } from './engines';
3
- import type { Schema } from './schema';
4
- import type { Infer, NonEmptyArray, Shape } from './common';
5
- import type { ClickHouseClient } from '../client';
6
- import type { WhereExpr } from './where';
7
- import type { InsertStream, SelectResult } from './stream';
8
- import type { ClickHouseSettings, MergeTreeSettings } from '../settings';
9
- import type Stream from 'stream';
10
- export interface TableOptions<S extends Shape> {
11
- name: string;
12
- schema: Schema<S>;
13
- database?: string;
14
- }
15
- export interface CreateTableOptions<S extends Shape> {
16
- engine: TableEngine;
17
- order_by: NonEmptyArray<keyof S>;
18
- if_not_exists?: boolean;
19
- on_cluster?: string;
20
- partition_by?: NonEmptyArray<keyof S>;
21
- primary_key?: NonEmptyArray<keyof S>;
22
- settings?: MergeTreeSettings;
23
- clickhouse_settings?: ClickHouseSettings;
24
- }
25
- export interface SelectOptions<S extends Shape> {
26
- columns?: NonEmptyArray<keyof S>;
27
- where?: WhereExpr<S>;
28
- order_by?: NonEmptyArray<[keyof S, 'ASC' | 'DESC']>;
29
- clickhouse_settings?: ClickHouseSettings;
30
- abort_controller?: AbortController;
31
- }
32
- export interface InsertOptions<S extends Shape> {
33
- values: Infer<S>[] | InsertStream<Infer<S>>;
34
- clickhouse_settings?: ClickHouseSettings;
35
- abort_controller?: AbortController;
36
- }
37
- export declare class Table<S extends Shape> {
38
- private readonly client;
39
- private readonly options;
40
- constructor(client: ClickHouseClient, options: TableOptions<S>);
41
- create(options: CreateTableOptions<S>): Promise<Stream.Readable>;
42
- insert({ abort_controller, clickhouse_settings, values, }: InsertOptions<S>): Promise<void>;
43
- select({ abort_controller, clickhouse_settings, columns, order_by, where, }?: SelectOptions<S>): Promise<SelectResult<Infer<S>>>;
44
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Table = void 0;
4
- const query_formatter_1 = require("./query_formatter");
5
- class Table {
6
- constructor(client, options) {
7
- Object.defineProperty(this, "client", {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value: client
12
- });
13
- Object.defineProperty(this, "options", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: options
18
- });
19
- }
20
- // TODO: better types
21
- async create(options) {
22
- const query = query_formatter_1.QueryFormatter.createTable(this.options, options);
23
- const { stream } = await this.client.exec({
24
- query,
25
- clickhouse_settings: options.clickhouse_settings,
26
- });
27
- return stream;
28
- }
29
- async insert({ abort_controller, clickhouse_settings, values, }) {
30
- await this.client.insert({
31
- clickhouse_settings,
32
- abort_signal: abort_controller === null || abort_controller === void 0 ? void 0 : abort_controller.signal,
33
- table: (0, query_formatter_1.getTableName)(this.options),
34
- format: 'JSONEachRow',
35
- values,
36
- });
37
- }
38
- async select({ abort_controller, clickhouse_settings, columns, order_by, where, } = {}) {
39
- const query = query_formatter_1.QueryFormatter.select(this.options, where, columns, order_by);
40
- const rs = await this.client.query({
41
- query,
42
- clickhouse_settings,
43
- abort_signal: abort_controller === null || abort_controller === void 0 ? void 0 : abort_controller.signal,
44
- format: 'JSONEachRow',
45
- });
46
- const stream = rs.stream();
47
- async function* asyncGenerator() {
48
- for await (const rows of stream) {
49
- for (const row of rows) {
50
- const value = row.json();
51
- yield value;
52
- }
53
- }
54
- }
55
- return {
56
- asyncGenerator,
57
- json: async () => {
58
- const result = [];
59
- for await (const value of asyncGenerator()) {
60
- if (Array.isArray(value)) {
61
- result.push(...value);
62
- }
63
- else {
64
- result.push(value);
65
- }
66
- }
67
- return result;
68
- },
69
- };
70
- }
71
- }
72
- exports.Table = Table;
73
- //# sourceMappingURL=table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/schema/table.ts"],"names":[],"mappings":";;;AAGA,uDAAgE;AA4ChE,MAAa,KAAK;IAChB,YACmB,MAAwB,EACxB,OAAwB;;;;;mBADxB;;;;;;mBACA;;IAChB,CAAC;IAEJ,qBAAqB;IACrB,KAAK,CAAC,MAAM,CAAC,OAA8B;QACzC,MAAM,KAAK,GAAG,gCAAc,CAAC,WAA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CAAA;oBACrC,MAAM,KAAiB,CAAA;iBACxB;aACF;QACH,CAAC;QAED,OAAO;YACL,cAAc;YACd,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,MAAM,MAAM,GAAG,EAAE,CAAA;gBACjB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,cAAc,EAAE,EAAE;oBAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;wBACxB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;qBACtB;yBAAM;wBACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;qBACnB;iBACF;gBACD,OAAO,MAAM,CAAA;YACf,CAAC;SACF,CAAA;IACH,CAAC;CACF;AAtED,sBAsEC"}
@@ -1,201 +0,0 @@
1
- type Int = UInt8 | UInt16 | UInt32 | UInt64 | UInt128 | UInt256;
2
- type UInt = Int8 | Int16 | Int32 | Int64 | Int128 | Int256;
3
- type Float = Float32 | Float64;
4
- export type Type = Int | UInt | Float | Bool | String | FixedString | Array<any> | Nullable<any> | Map<any, any> | UUID | Enum<any> | LowCardinality<any> | Date | Date32 | DateTime | DateTime64 | IPv4 | IPv6;
5
- export interface UInt8 {
6
- underlying: number;
7
- type: 'UInt8';
8
- }
9
- export declare const UInt8: UInt8;
10
- export interface UInt16 {
11
- type: 'UInt16';
12
- underlying: number;
13
- }
14
- export declare const UInt16: UInt16;
15
- export interface UInt32 {
16
- type: 'UInt32';
17
- underlying: number;
18
- }
19
- export declare const UInt32: UInt32;
20
- export interface UInt64 {
21
- underlying: string;
22
- type: 'UInt64';
23
- }
24
- /**
25
- * Uses string as the inferred type, since its max value
26
- * is greater than Number.MAX_SAFE_INTEGER
27
- *
28
- * Max UInt64: 18446744073709551615
29
- * Number.MAX_SAFE_INTEGER: 9007199254740991
30
- *
31
- * It can be cast to number
32
- * by disabling `output_format_json_quote_64bit_integers` CH setting
33
- */
34
- export declare const UInt64: UInt64;
35
- export interface UInt128 {
36
- type: 'UInt128';
37
- underlying: string;
38
- }
39
- /**
40
- * Uses string as the inferred type, since its max value
41
- * is greater than Number.MAX_SAFE_INTEGER
42
- */
43
- export declare const UInt128: UInt128;
44
- export interface UInt256 {
45
- type: 'UInt256';
46
- underlying: string;
47
- }
48
- /**
49
- * Uses string as the inferred type, since its max value
50
- * is greater than Number.MAX_SAFE_INTEGER
51
- */
52
- export declare const UInt256: UInt256;
53
- export interface Int8 {
54
- underlying: number;
55
- type: 'Int8';
56
- }
57
- export declare const Int8: Int8;
58
- export interface Int16 {
59
- type: 'Int16';
60
- underlying: number;
61
- }
62
- export declare const Int16: Int16;
63
- export interface Int32 {
64
- type: 'Int32';
65
- underlying: number;
66
- }
67
- export declare const Int32: Int32;
68
- export interface Int64 {
69
- underlying: string;
70
- type: 'Int64';
71
- }
72
- /**
73
- * Uses string as the inferred type, since its max value
74
- * is greater than Number.MAX_SAFE_INTEGER
75
- *
76
- * Max Int64: 9223372036854775807
77
- * Number.MAX_SAFE_INTEGER: 9007199254740991
78
- *
79
- * It could be cast to number
80
- * by disabling `output_format_json_quote_64bit_integers` CH setting
81
- */
82
- export declare const Int64: Int64;
83
- export interface Int128 {
84
- type: 'Int128';
85
- underlying: string;
86
- }
87
- /**
88
- * Uses string as the inferred type, since its max value
89
- * is greater than Number.MAX_SAFE_INTEGER
90
- */
91
- export declare const Int128: Int128;
92
- export interface Int256 {
93
- type: 'Int256';
94
- underlying: string;
95
- }
96
- /**
97
- * Uses string as the inferred type, since its max value
98
- * is greater than Number.MAX_SAFE_INTEGER
99
- */
100
- export declare const Int256: Int256;
101
- export interface Float32 {
102
- type: 'Float32';
103
- underlying: number;
104
- }
105
- export declare const Float32: Float32;
106
- export interface Float64 {
107
- type: 'Float64';
108
- underlying: number;
109
- }
110
- export declare const Float64: Float64;
111
- export interface Decimal {
112
- type: 'Decimal';
113
- underlying: number;
114
- }
115
- export declare const Decimal: ({ precision, scale, }: {
116
- precision: number;
117
- scale: number;
118
- }) => Decimal;
119
- export interface Bool {
120
- type: 'Bool';
121
- underlying: boolean;
122
- }
123
- export declare const Bool: Bool;
124
- export interface String {
125
- type: 'String';
126
- underlying: string;
127
- }
128
- export declare const String: String;
129
- export interface FixedString {
130
- type: 'FixedString';
131
- underlying: string;
132
- }
133
- export declare const FixedString: (bytes: number) => FixedString;
134
- export interface UUID {
135
- type: 'UUID';
136
- underlying: string;
137
- }
138
- export declare const UUID: UUID;
139
- type StandardEnum<T> = {
140
- [id: string]: T | string;
141
- [n: number]: string;
142
- };
143
- export interface Enum<T extends StandardEnum<unknown>> {
144
- type: 'Enum';
145
- underlying: keyof T;
146
- }
147
- export declare function Enum<T extends StandardEnum<unknown>>(enumVariable: T): Enum<T>;
148
- type LowCardinalityDataType = String | FixedString | UInt | Int | Float | Date | DateTime;
149
- export interface LowCardinality<T extends LowCardinalityDataType> {
150
- type: 'LowCardinality';
151
- underlying: T['underlying'];
152
- }
153
- export declare const LowCardinality: <T extends LowCardinalityDataType>(type: T) => LowCardinality<T>;
154
- export interface Array<T extends Type> {
155
- type: 'Array';
156
- underlying: globalThis.Array<T['underlying']>;
157
- }
158
- export declare const Array: <T extends Type>(inner: T) => Array<T>;
159
- type NullableType = Int | UInt | Float | Bool | String | FixedString | UUID | Decimal | Enum<any> | Date | DateTime | Date32 | IPv4 | IPv6;
160
- export interface Nullable<T extends NullableType> {
161
- type: 'Nullable';
162
- underlying: T['underlying'] | null;
163
- }
164
- export declare const Nullable: <T extends NullableType>(inner: T) => Nullable<T>;
165
- type MapKey = String | Int | UInt | FixedString | UUID | Enum<any> | Date | DateTime | Date32;
166
- export interface Map<K extends MapKey, V extends Type> {
167
- type: 'Map';
168
- underlying: Record<K['underlying'], V['underlying']>;
169
- }
170
- export declare const Map: <K extends MapKey, V extends Type>(k: K, v: V) => Map<K, V>;
171
- export interface Date {
172
- type: 'Date';
173
- underlying: string;
174
- }
175
- export declare const Date: Date;
176
- export interface Date32 {
177
- type: 'Date32';
178
- underlying: string;
179
- }
180
- export declare const Date32: Date32;
181
- export interface DateTime {
182
- type: 'DateTime';
183
- underlying: string;
184
- }
185
- export declare const DateTime: (timezone?: string) => DateTime;
186
- export interface DateTime64 {
187
- type: 'DateTime64';
188
- underlying: string;
189
- }
190
- export declare const DateTime64: (precision: number, timezone?: string) => DateTime64;
191
- export interface IPv4 {
192
- type: 'IPv4';
193
- underlying: string;
194
- }
195
- export declare const IPv4: IPv4;
196
- export interface IPv6 {
197
- type: 'IPv6';
198
- underlying: string;
199
- }
200
- export declare const IPv6: IPv6;
201
- export {};