@clickhouse/client 0.1.0 → 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 (120) hide show
  1. package/README.md +10 -6
  2. package/dist/client.d.ts +26 -128
  3. package/dist/client.js +39 -225
  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/node_base_connection.js +350 -0
  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 -35
  42. package/dist/connection/adapter/base_http_adapter.js +0 -302
  43. package/dist/connection/adapter/base_http_adapter.js.map +0 -1
  44. package/dist/connection/adapter/http_adapter.d.ts +0 -10
  45. package/dist/connection/adapter/http_adapter.js +0 -27
  46. package/dist/connection/adapter/http_adapter.js.map +0 -1
  47. package/dist/connection/adapter/http_search_params.d.ts +0 -11
  48. package/dist/connection/adapter/http_search_params.js +0 -42
  49. package/dist/connection/adapter/http_search_params.js.map +0 -1
  50. package/dist/connection/adapter/https_adapter.d.ts +0 -11
  51. package/dist/connection/adapter/https_adapter.js +0 -48
  52. package/dist/connection/adapter/https_adapter.js.map +0 -1
  53. package/dist/connection/adapter/index.d.ts +0 -2
  54. package/dist/connection/adapter/index.js +0 -8
  55. package/dist/connection/adapter/index.js.map +0 -1
  56. package/dist/connection/adapter/transform_url.d.ts +0 -5
  57. package/dist/connection/adapter/transform_url.js +0 -15
  58. package/dist/connection/adapter/transform_url.js.map +0 -1
  59. package/dist/connection/connection.d.ts +0 -58
  60. package/dist/connection/connection.js +0 -17
  61. package/dist/connection/connection.js.map +0 -1
  62. package/dist/data_formatter/format_query_params.d.ts +0 -1
  63. package/dist/data_formatter/format_query_params.js +0 -61
  64. package/dist/data_formatter/format_query_params.js.map +0 -1
  65. package/dist/data_formatter/format_query_settings.d.ts +0 -2
  66. package/dist/data_formatter/format_query_settings.js +0 -21
  67. package/dist/data_formatter/format_query_settings.js.map +0 -1
  68. package/dist/data_formatter/formatter.d.ts +0 -23
  69. package/dist/data_formatter/formatter.js +0 -96
  70. package/dist/data_formatter/formatter.js.map +0 -1
  71. package/dist/data_formatter/index.d.ts +0 -3
  72. package/dist/data_formatter/index.js +0 -23
  73. package/dist/data_formatter/index.js.map +0 -1
  74. package/dist/error/index.d.ts +0 -1
  75. package/dist/error/index.js +0 -18
  76. package/dist/error/index.js.map +0 -1
  77. package/dist/error/parse_error.d.ts +0 -12
  78. package/dist/error/parse_error.js +0 -39
  79. package/dist/error/parse_error.js.map +0 -1
  80. package/dist/logger.d.ts +0 -30
  81. package/dist/logger.js +0 -100
  82. package/dist/logger.js.map +0 -1
  83. package/dist/result.d.ts +0 -52
  84. package/dist/result.js.map +0 -1
  85. package/dist/schema/common.d.ts +0 -8
  86. package/dist/schema/common.js +0 -3
  87. package/dist/schema/common.js.map +0 -1
  88. package/dist/schema/engines.d.ts +0 -40
  89. package/dist/schema/engines.js +0 -61
  90. package/dist/schema/engines.js.map +0 -1
  91. package/dist/schema/index.d.ts +0 -7
  92. package/dist/schema/index.js +0 -24
  93. package/dist/schema/index.js.map +0 -1
  94. package/dist/schema/query_formatter.d.ts +0 -9
  95. package/dist/schema/query_formatter.js +0 -48
  96. package/dist/schema/query_formatter.js.map +0 -1
  97. package/dist/schema/result.d.ts +0 -13
  98. package/dist/schema/result.js +0 -3
  99. package/dist/schema/result.js.map +0 -1
  100. package/dist/schema/schema.d.ts +0 -6
  101. package/dist/schema/schema.js +0 -20
  102. package/dist/schema/schema.js.map +0 -1
  103. package/dist/schema/stream.d.ts +0 -11
  104. package/dist/schema/stream.js +0 -25
  105. package/dist/schema/stream.js.map +0 -1
  106. package/dist/schema/table.d.ts +0 -44
  107. package/dist/schema/table.js +0 -73
  108. package/dist/schema/table.js.map +0 -1
  109. package/dist/schema/types.d.ts +0 -201
  110. package/dist/schema/types.js +0 -268
  111. package/dist/schema/types.js.map +0 -1
  112. package/dist/schema/where.d.ts +0 -8
  113. package/dist/schema/where.js +0 -43
  114. package/dist/schema/where.js.map +0 -1
  115. package/dist/settings.d.ts +0 -1453
  116. package/dist/settings.js +0 -28
  117. package/dist/settings.js.map +0 -1
  118. package/dist/utils/string.d.ts +0 -1
  119. package/dist/utils/string.js +0 -9
  120. package/dist/utils/string.js.map +0 -1
@@ -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 {};
@@ -1,268 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/ban-types */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.IPv6 = exports.IPv4 = exports.DateTime64 = exports.DateTime = exports.Date32 = exports.Date = exports.Map = exports.Nullable = exports.Array = exports.LowCardinality = exports.Enum = exports.UUID = exports.FixedString = exports.String = exports.Bool = exports.Decimal = exports.Float64 = exports.Float32 = exports.Int256 = exports.Int128 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.UInt256 = exports.UInt128 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = void 0;
5
- exports.UInt8 = {
6
- type: 'UInt8',
7
- toString() {
8
- return 'UInt8';
9
- },
10
- };
11
- exports.UInt16 = {
12
- type: 'UInt16',
13
- toString() {
14
- return 'UInt16';
15
- },
16
- };
17
- exports.UInt32 = {
18
- type: 'UInt32',
19
- toString() {
20
- return 'UInt32';
21
- },
22
- };
23
- /**
24
- * Uses string as the inferred type, since its max value
25
- * is greater than Number.MAX_SAFE_INTEGER
26
- *
27
- * Max UInt64: 18446744073709551615
28
- * Number.MAX_SAFE_INTEGER: 9007199254740991
29
- *
30
- * It can be cast to number
31
- * by disabling `output_format_json_quote_64bit_integers` CH setting
32
- */
33
- exports.UInt64 = {
34
- type: 'UInt64',
35
- toString() {
36
- return 'UInt64';
37
- },
38
- };
39
- /**
40
- * Uses string as the inferred type, since its max value
41
- * is greater than Number.MAX_SAFE_INTEGER
42
- */
43
- exports.UInt128 = {
44
- type: 'UInt128',
45
- toString() {
46
- return 'UInt128';
47
- },
48
- };
49
- /**
50
- * Uses string as the inferred type, since its max value
51
- * is greater than Number.MAX_SAFE_INTEGER
52
- */
53
- exports.UInt256 = {
54
- type: 'UInt256',
55
- toString() {
56
- return 'UInt256';
57
- },
58
- };
59
- exports.Int8 = {
60
- type: 'Int8',
61
- toString() {
62
- return 'Int8';
63
- },
64
- };
65
- exports.Int16 = {
66
- type: 'Int16',
67
- toString() {
68
- return 'Int16';
69
- },
70
- };
71
- exports.Int32 = {
72
- type: 'Int32',
73
- toString() {
74
- return 'Int32';
75
- },
76
- };
77
- /**
78
- * Uses string as the inferred type, since its max value
79
- * is greater than Number.MAX_SAFE_INTEGER
80
- *
81
- * Max Int64: 9223372036854775807
82
- * Number.MAX_SAFE_INTEGER: 9007199254740991
83
- *
84
- * It could be cast to number
85
- * by disabling `output_format_json_quote_64bit_integers` CH setting
86
- */
87
- exports.Int64 = {
88
- type: 'Int64',
89
- toString() {
90
- return 'Int64';
91
- },
92
- };
93
- /**
94
- * Uses string as the inferred type, since its max value
95
- * is greater than Number.MAX_SAFE_INTEGER
96
- */
97
- exports.Int128 = {
98
- type: 'Int128',
99
- toString() {
100
- return 'Int128';
101
- },
102
- };
103
- /**
104
- * Uses string as the inferred type, since its max value
105
- * is greater than Number.MAX_SAFE_INTEGER
106
- */
107
- exports.Int256 = {
108
- type: 'Int256',
109
- toString() {
110
- return 'Int256';
111
- },
112
- };
113
- exports.Float32 = {
114
- type: 'Float32',
115
- toString() {
116
- return 'Float32';
117
- },
118
- };
119
- exports.Float64 = {
120
- type: 'Float64',
121
- toString() {
122
- return 'Float64';
123
- },
124
- };
125
- const Decimal = ({ precision, scale, }) => ({
126
- type: 'Decimal',
127
- toString() {
128
- if (scale < 0) {
129
- throw new Error(`Invalid Decimal scale. Valid range: [ 0 : P ], got ${scale}`);
130
- }
131
- if (precision > 0 && precision < 10) {
132
- return `Decimal32(${scale})`;
133
- }
134
- if (precision > 10 && precision < 19) {
135
- return `Decimal64(${scale})`;
136
- }
137
- if (precision > 19 && precision < 39) {
138
- return `Decimal128(${scale})`;
139
- }
140
- if (precision > 19 && precision < 39) {
141
- return `Decimal128(${scale})`;
142
- }
143
- if (precision > 39 && precision < 77) {
144
- return `Decimal256(${scale})`;
145
- }
146
- throw Error(`Unsupported Decimal precision. Valid range: [ 1 : 18 ], got ${precision}`);
147
- },
148
- });
149
- exports.Decimal = Decimal;
150
- exports.Bool = {
151
- type: 'Bool',
152
- toString() {
153
- return 'Bool';
154
- },
155
- };
156
- exports.String = {
157
- type: 'String',
158
- toString() {
159
- return 'String';
160
- },
161
- };
162
- const FixedString = (bytes) => ({
163
- type: 'FixedString',
164
- toString() {
165
- return `FixedString(${bytes})`;
166
- },
167
- });
168
- exports.FixedString = FixedString;
169
- exports.UUID = {
170
- type: 'UUID',
171
- toString() {
172
- return 'UUID';
173
- },
174
- };
175
- // https://github.com/microsoft/TypeScript/issues/30611#issuecomment-479087883
176
- // Currently limited to only string enums
177
- function Enum(enumVariable) {
178
- return {
179
- type: 'Enum',
180
- toString() {
181
- return `Enum(${Object.keys(enumVariable)
182
- .map((k) => `'${k}'`)
183
- .join(', ')})`;
184
- },
185
- };
186
- }
187
- exports.Enum = Enum;
188
- const LowCardinality = (type) => ({
189
- type: 'LowCardinality',
190
- toString() {
191
- return `LowCardinality(${type})`;
192
- },
193
- });
194
- exports.LowCardinality = LowCardinality;
195
- const Array = (inner) => ({
196
- type: 'Array',
197
- toString() {
198
- return `Array(${inner.toString()})`;
199
- },
200
- });
201
- exports.Array = Array;
202
- const Nullable = (inner) => ({
203
- type: 'Nullable',
204
- toString() {
205
- return `Nullable(${inner.toString()})`;
206
- },
207
- });
208
- exports.Nullable = Nullable;
209
- const Map = (k, v) => ({
210
- type: 'Map',
211
- toString() {
212
- return `Map(${k.toString()}, ${v.toString()})`;
213
- },
214
- });
215
- exports.Map = Map;
216
- exports.Date = {
217
- type: 'Date',
218
- toString() {
219
- return 'Date';
220
- },
221
- };
222
- exports.Date32 = {
223
- type: 'Date32',
224
- toString() {
225
- return 'Date32';
226
- },
227
- };
228
- const DateTime = (timezone) => ({
229
- type: 'DateTime',
230
- toString() {
231
- const tz = timezone ? ` (${timezone})` : '';
232
- return `DateTime${tz}`;
233
- },
234
- });
235
- exports.DateTime = DateTime;
236
- const DateTime64 = (precision, timezone) => ({
237
- type: 'DateTime64',
238
- toString() {
239
- const tz = timezone ? `, ${timezone}` : '';
240
- return `DateTime64(${precision}${tz})`;
241
- },
242
- });
243
- exports.DateTime64 = DateTime64;
244
- exports.IPv4 = {
245
- type: 'IPv4',
246
- toString() {
247
- return 'IPv4';
248
- },
249
- };
250
- exports.IPv6 = {
251
- type: 'IPv6',
252
- toString() {
253
- return 'IPv6';
254
- },
255
- };
256
- // TODO: Tuple is disabled for now. Figure out type derivation in this case
257
- // export interface Tuple<T extends Type> = {
258
- // type: 'Tuple'
259
- // // underlying: globalThis.Array<T['underlying']>
260
- // }
261
- // export const Tuple = <T extends Type>(...inner: T[]) =>
262
- // ({
263
- // type: 'Tuple',
264
- // toString(): string {
265
- // return `Tuple(${inner.join(', ')})`
266
- // },
267
- // } as Tuple<T>)
268
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":";AAAA,iDAAiD;;;AA+CpC,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,QAAQ;QACN,OAAO,OAAO,CAAA;IAChB,CAAC;CACO,CAAA;AAKG,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,QAAQ;QACN,OAAO,QAAQ,CAAA;IACjB,CAAC;CACQ,CAAA;AAKE,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,QAAQ;QACN,OAAO,QAAQ,CAAA;IACjB,CAAC;CACQ,CAAA;AAKX;;;;;;;;;GASG;AACU,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,QAAQ;QACN,OAAO,QAAQ,CAAA;IACjB,CAAC;CACQ,CAAA;AAKX;;;GAGG;AACU,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,QAAQ;QACN,OAAO,SAAS,CAAA;IAClB,CAAC;CACS,CAAA;AAKZ;;;GAGG;AACU,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,QAAQ;QACN,OAAO,SAAS,CAAA;IAClB,CAAC;CACS,CAAA;AAMC,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,QAAQ;QACN,OAAO,MAAM,CAAA;IACf,CAAC;CACM,CAAA;AAKI,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,QAAQ;QACN,OAAO,OAAO,CAAA;IAChB,CAAC;CACO,CAAA;AAKG,QAAA,KAAK,GAAG;IACnB,IAAI,EAA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,GAAG,CAAC,SAAiB,EAAE,QAAiB,EAAE,EAAE,CACjE,CAAC;IACC,IAAI,EAAE,YAAY;IAClB,QAAQ;QACN,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAC1C,OAAO,cAAc,SAAS,GAAG,EAAE,GAAG,CAAA;IACxC,CAAC;CACa,CAAA,CAAA;AAPL,QAAA,UAAU,cAOL;AAML,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,QAAQ;QACN,OAAO,MAAM,CAAA;IACf,CAAC;CACM,CAAA;AAMI,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,QAAQ;QACN,OAAO,MAAM,CAAA;IACf,CAAC;CACM,CAAA;AAET,2EAA2E;AAE3E,6CAA6C;AAC7C,kBAAkB;AAClB,qDAAqD;AACrD,IAAI;AACJ,0DAA0D;AAC1D,OAAO;AACP,qBAAqB;AACrB,2BAA2B;AAC3B,4CAA4C;AAC5C,SAAS;AACT,mBAAmB"}
@@ -1,8 +0,0 @@
1
- import type { NonEmptyArray, Shape } from './common';
2
- export interface WhereExpr<S extends Shape> {
3
- toString(): string;
4
- type: 'And' | 'Or' | 'Eq' | 'Le' | 'Lte' | 'Gt' | 'Gte';
5
- }
6
- export declare function Eq<S extends Shape, F extends keyof S>(field: F, value: S[F]['underlying']): WhereExpr<S>;
7
- export declare function And<S extends Shape>(...expr: NonEmptyArray<WhereExpr<S>>): WhereExpr<S>;
8
- export declare function Or<S extends Shape>(...expr: NonEmptyArray<WhereExpr<S>>): WhereExpr<S>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Or = exports.And = exports.Eq = void 0;
4
- function Eq(field, value) {
5
- return {
6
- toString() {
7
- return `(${String(field)} == ${formatValue(value)})`;
8
- },
9
- type: 'Eq',
10
- };
11
- }
12
- exports.Eq = Eq;
13
- function And(...expr) {
14
- return {
15
- toString() {
16
- return `(${expr.join(' AND ')})`;
17
- },
18
- type: 'And',
19
- };
20
- }
21
- exports.And = And;
22
- function Or(...expr) {
23
- return {
24
- toString() {
25
- return `(${expr.join(' OR ')})`;
26
- },
27
- type: 'Or',
28
- };
29
- }
30
- exports.Or = Or;
31
- function formatValue(value) {
32
- if (value === null || value === undefined) {
33
- return 'NULL';
34
- }
35
- if (typeof value === 'string') {
36
- return `'${value}'`;
37
- }
38
- if (globalThis.Array.isArray(value)) {
39
- return `[${value.join(', ')}]`;
40
- }
41
- return value.toString();
42
- }
43
- //# sourceMappingURL=where.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"where.js","sourceRoot":"","sources":["../../src/schema/where.ts"],"names":[],"mappings":";;;AAQA,SAAgB,EAAE,CAChB,KAAQ,EACR,KAAyB;IAEzB,OAAO;QACL,QAAQ;YACN,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAA;QACtD,CAAC;QACD,IAAI,EAAE,IAAI;KACX,CAAA;AACH,CAAC;AAVD,gBAUC;AACD,SAAgB,GAAG,CACjB,GAAG,IAAiC;IAEpC,OAAO;QACL,QAAQ;YACN,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAA;QAClC,CAAC;QACD,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AATD,kBASC;AACD,SAAgB,EAAE,CAChB,GAAG,IAAiC;IAEpC,OAAO;QACL,QAAQ;YACN,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;QACjC,CAAC;QACD,IAAI,EAAE,IAAI;KACX,CAAA;AACH,CAAC;AATD,gBASC;AAED,SAAS,WAAW,CAAC,KAAU;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,MAAM,CAAA;KACd;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,IAAI,KAAK,GAAG,CAAA;KACpB;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;KAC/B;IACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;AACzB,CAAC"}