@tmlmobilidade/databases 20260616.1147.27 → 20260616.2238.2
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/dist/interfaces/apex/simplified/simplified-apex-banking-taps.d.ts +12 -3
- package/dist/interfaces/apex/simplified/simplified-apex-banking-taps.js +22 -17
- package/dist/interfaces/apex/simplified/simplified-apex-inspection-decisions.d.ts +11 -2
- package/dist/interfaces/apex/simplified/simplified-apex-inspection-decisions.js +15 -10
- package/dist/interfaces/apex/simplified/simplified-apex-inspections.d.ts +13 -4
- package/dist/interfaces/apex/simplified/simplified-apex-inspections.js +24 -19
- package/dist/interfaces/apex/simplified/simplified-apex-locations.d.ts +12 -3
- package/dist/interfaces/apex/simplified/simplified-apex-locations.js +18 -13
- package/dist/interfaces/apex/simplified/simplified-apex-refunds.d.ts +12 -3
- package/dist/interfaces/apex/simplified/simplified-apex-refunds.js +28 -23
- package/dist/interfaces/apex/simplified/simplified-apex-sales.d.ts +12 -3
- package/dist/interfaces/apex/simplified/simplified-apex-sales.js +28 -23
- package/dist/interfaces/apex/simplified/simplified-apex-validations.d.ts +18 -9
- package/dist/interfaces/apex/simplified/simplified-apex-validations.js +26 -21
- package/dist/interfaces/vehicle-events/simplified-vehicle-events.d.ts +3 -3
- package/dist/interfaces/vehicle-events/simplified-vehicle-events.js +1 -1
- package/dist/templates/clickhouse.d.ts +3 -8
- package/dist/templates/clickhouse.js +2 -16
- package/dist/types/clickhouse/column.d.ts +1 -9
- package/dist/types/clickhouse/data-types.d.ts +1 -1
- package/dist/types/clickhouse/table-engines.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexBankingTap } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexBankingTapsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexBankingTap> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexBankingTap>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -16,6 +19,9 @@ declare class SimplifiedApexBankingTapsNewClass extends ClickHouseInterfaceTempl
|
|
|
16
19
|
};
|
|
17
20
|
apex_version: string;
|
|
18
21
|
banking_token: string;
|
|
22
|
+
calendar_date: string & {
|
|
23
|
+
__brand: "CalendarDate";
|
|
24
|
+
};
|
|
19
25
|
card_brand: number;
|
|
20
26
|
card_pan: string;
|
|
21
27
|
device_id: string;
|
|
@@ -29,7 +35,10 @@ declare class SimplifiedApexBankingTapsNewClass extends ClickHouseInterfaceTempl
|
|
|
29
35
|
stop_id: string;
|
|
30
36
|
trip_id: string;
|
|
31
37
|
units_qty: number;
|
|
32
|
-
|
|
38
|
+
updated_at: number & {
|
|
39
|
+
__brand: "UnixTimestamp";
|
|
40
|
+
};
|
|
41
|
+
vehicle_id: number | null;
|
|
33
42
|
}>;
|
|
34
43
|
protected readonly tableName = "banking_taps";
|
|
35
44
|
/**
|
|
@@ -4,33 +4,38 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
10
|
banking_token: { type: 'String' },
|
|
11
|
-
|
|
11
|
+
calendar_date: { type: 'Date' },
|
|
12
|
+
card_brand: { type: 'UInt8' },
|
|
12
13
|
card_pan: { type: 'String' },
|
|
13
|
-
created_at: { type: '
|
|
14
|
-
device_id: { type: 'String' },
|
|
15
|
-
event_type: { type: '
|
|
14
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
15
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
16
|
+
event_type: { type: 'UInt8' },
|
|
16
17
|
is_ok: { type: 'Bool' },
|
|
17
18
|
is_ok_pcgi: { type: 'Bool' },
|
|
18
|
-
line_id: { type: 'String' },
|
|
19
|
-
mac_ase_counter_value: { type: '
|
|
20
|
-
mac_sam_serial_number: { type: '
|
|
21
|
-
pattern_id: { type: 'String' },
|
|
22
|
-
product_id: { type: 'String' },
|
|
23
|
-
received_at: { type: '
|
|
24
|
-
stop_id: { type: 'String' },
|
|
25
|
-
trip_id: { type: 'String' },
|
|
26
|
-
units_qty: { type: '
|
|
27
|
-
|
|
19
|
+
line_id: { type: 'LowCardinality(String)' },
|
|
20
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
21
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
22
|
+
pattern_id: { type: 'LowCardinality(String)' },
|
|
23
|
+
product_id: { type: 'LowCardinality(String)' },
|
|
24
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
25
|
+
stop_id: { type: 'LowCardinality(String)' },
|
|
26
|
+
trip_id: { type: 'Nullable(String)' },
|
|
27
|
+
units_qty: { type: 'Nullable(Int32)' },
|
|
28
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
29
|
+
vehicle_id: { type: 'LowCardinality(String)' },
|
|
28
30
|
};
|
|
29
31
|
/* * */
|
|
30
32
|
class SimplifiedApexBankingTapsNewClass extends ClickHouseInterfaceTemplate {
|
|
31
33
|
//
|
|
32
34
|
static _instance = null;
|
|
33
35
|
databaseName = 'simplified_apex';
|
|
36
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
37
|
+
orderBy = 'agency_id, created_at, _id';
|
|
38
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
34
39
|
schema = tableSchema;
|
|
35
40
|
tableName = 'banking_taps';
|
|
36
41
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexInspectionDecision } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexInspectionDecisionsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexInspectionDecision> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexInspectionDecision>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -15,10 +18,16 @@ declare class SimplifiedApexInspectionDecisionsNewClass extends ClickHouseInterf
|
|
|
15
18
|
__brand: "UnixTimestamp";
|
|
16
19
|
};
|
|
17
20
|
apex_version: string;
|
|
21
|
+
calendar_date: string & {
|
|
22
|
+
__brand: "CalendarDate";
|
|
23
|
+
};
|
|
18
24
|
device_id: string;
|
|
19
25
|
is_ok_pcgi: boolean;
|
|
20
26
|
mac_ase_counter_value: number;
|
|
21
27
|
mac_sam_serial_number: number;
|
|
28
|
+
updated_at: number & {
|
|
29
|
+
__brand: "UnixTimestamp";
|
|
30
|
+
};
|
|
22
31
|
final_control_status: number;
|
|
23
32
|
inspection_decision_id: string | null;
|
|
24
33
|
}>;
|
|
@@ -4,24 +4,29 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
calendar_date: { type: 'Date' },
|
|
11
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
12
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
13
|
+
final_control_status: { type: 'UInt8' },
|
|
14
|
+
inspection_decision_id: { type: 'Nullable(UUID)' },
|
|
14
15
|
is_ok: { type: 'Bool' },
|
|
15
16
|
is_ok_pcgi: { type: 'Bool' },
|
|
16
|
-
mac_ase_counter_value: { type: '
|
|
17
|
-
mac_sam_serial_number: { type: '
|
|
18
|
-
received_at: { type: '
|
|
17
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
18
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
19
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
20
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
19
21
|
};
|
|
20
22
|
/* * */
|
|
21
23
|
class SimplifiedApexInspectionDecisionsNewClass extends ClickHouseInterfaceTemplate {
|
|
22
24
|
//
|
|
23
25
|
static _instance = null;
|
|
24
26
|
databaseName = 'simplified_apex';
|
|
27
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
28
|
+
orderBy = 'agency_id, created_at, _id';
|
|
29
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
25
30
|
schema = tableSchema;
|
|
26
31
|
tableName = 'inspection_decisions';
|
|
27
32
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexInspection } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexInspection> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexInspection>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -15,6 +18,9 @@ declare class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTempl
|
|
|
15
18
|
__brand: "UnixTimestamp";
|
|
16
19
|
};
|
|
17
20
|
apex_version: string;
|
|
21
|
+
calendar_date: string & {
|
|
22
|
+
__brand: "CalendarDate";
|
|
23
|
+
};
|
|
18
24
|
device_id: string;
|
|
19
25
|
is_ok_pcgi: boolean;
|
|
20
26
|
line_id: string;
|
|
@@ -23,8 +29,11 @@ declare class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTempl
|
|
|
23
29
|
pattern_id: string;
|
|
24
30
|
product_id: string | null;
|
|
25
31
|
trip_id: string | null;
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
updated_at: number & {
|
|
33
|
+
__brand: "UnixTimestamp";
|
|
34
|
+
};
|
|
35
|
+
vehicle_id: number | null;
|
|
36
|
+
card_serial_number: bigint | null;
|
|
28
37
|
control_destination_stop_id: string;
|
|
29
38
|
control_origin_stop_id: string;
|
|
30
39
|
control_status: number;
|
|
@@ -4,33 +4,38 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
calendar_date: { type: 'Date' },
|
|
11
|
+
card_serial_number: { type: 'Nullable(UInt64)' },
|
|
12
|
+
control_destination_stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
13
|
+
control_origin_stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
14
|
+
control_status: { type: 'UInt8' },
|
|
15
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
16
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
17
|
+
environment_status: { type: 'UInt8' },
|
|
18
|
+
inspection_id: { type: 'Nullable(UUID)' },
|
|
18
19
|
is_ok: { type: 'Bool' },
|
|
19
20
|
is_ok_pcgi: { type: 'Bool' },
|
|
20
|
-
line_id: { type: 'String' },
|
|
21
|
-
mac_ase_counter_value: { type: '
|
|
22
|
-
mac_sam_serial_number: { type: '
|
|
23
|
-
pattern_id: { type: 'String' },
|
|
24
|
-
product_id: { type: 'String' },
|
|
25
|
-
received_at: { type: '
|
|
26
|
-
trip_id: { type: 'String' },
|
|
27
|
-
|
|
21
|
+
line_id: { type: 'Nullable(LowCardinality(String))' },
|
|
22
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
23
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
24
|
+
pattern_id: { type: 'Nullable(LowCardinality(String))' },
|
|
25
|
+
product_id: { type: 'Nullable(LowCardinality(String))' },
|
|
26
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
27
|
+
trip_id: { type: 'Nullable(String)' },
|
|
28
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
29
|
+
vehicle_id: { type: 'Nullable(LowCardinality(String))' },
|
|
28
30
|
};
|
|
29
31
|
/* * */
|
|
30
32
|
class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTemplate {
|
|
31
33
|
//
|
|
32
34
|
static _instance = null;
|
|
33
35
|
databaseName = 'simplified_apex';
|
|
36
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
37
|
+
orderBy = 'agency_id, created_at, _id';
|
|
38
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
34
39
|
schema = tableSchema;
|
|
35
40
|
tableName = 'inspections';
|
|
36
41
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexLocation } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexLocation> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexLocation>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -14,6 +17,9 @@ declare class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplat
|
|
|
14
17
|
__brand: "UnixTimestamp";
|
|
15
18
|
};
|
|
16
19
|
apex_version: string;
|
|
20
|
+
calendar_date: string & {
|
|
21
|
+
__brand: "CalendarDate";
|
|
22
|
+
};
|
|
17
23
|
device_id: string;
|
|
18
24
|
line_id: string;
|
|
19
25
|
mac_ase_counter_value: number;
|
|
@@ -21,7 +27,10 @@ declare class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplat
|
|
|
21
27
|
pattern_id: string;
|
|
22
28
|
stop_id: string;
|
|
23
29
|
trip_id: string | null;
|
|
24
|
-
|
|
30
|
+
updated_at: number & {
|
|
31
|
+
__brand: "UnixTimestamp";
|
|
32
|
+
};
|
|
33
|
+
vehicle_id: number | null;
|
|
25
34
|
}>;
|
|
26
35
|
protected readonly tableName = "locations";
|
|
27
36
|
/**
|
|
@@ -4,25 +4,30 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
calendar_date: { type: 'Date' },
|
|
11
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
12
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
13
|
+
line_id: { type: 'Nullable(LowCardinality(String))' },
|
|
14
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
15
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
16
|
+
pattern_id: { type: 'Nullable(LowCardinality(String))' },
|
|
17
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
18
|
+
stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
19
|
+
trip_id: { type: 'Nullable(String)' },
|
|
20
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
21
|
+
vehicle_id: { type: 'Nullable(LowCardinality(String))' },
|
|
20
22
|
};
|
|
21
23
|
/* * */
|
|
22
24
|
class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplate {
|
|
23
25
|
//
|
|
24
26
|
static _instance = null;
|
|
25
27
|
databaseName = 'simplified_apex';
|
|
28
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
29
|
+
orderBy = 'agency_id, created_at, _id';
|
|
30
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
26
31
|
schema = tableSchema;
|
|
27
32
|
tableName = 'locations';
|
|
28
33
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexOnBoardRefund } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexOnBoardRefund> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexOnBoardRefund>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -15,6 +18,9 @@ declare class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTe
|
|
|
15
18
|
};
|
|
16
19
|
price: number;
|
|
17
20
|
apex_version: string;
|
|
21
|
+
calendar_date: string & {
|
|
22
|
+
__brand: "CalendarDate";
|
|
23
|
+
};
|
|
18
24
|
device_id: string;
|
|
19
25
|
line_id: string | null;
|
|
20
26
|
mac_ase_counter_value: number;
|
|
@@ -22,8 +28,11 @@ declare class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTe
|
|
|
22
28
|
pattern_id: string | null;
|
|
23
29
|
stop_id: string | null;
|
|
24
30
|
trip_id: string | null;
|
|
31
|
+
updated_at: number & {
|
|
32
|
+
__brand: "UnixTimestamp";
|
|
33
|
+
};
|
|
25
34
|
vehicle_id: number | null;
|
|
26
|
-
card_serial_number:
|
|
35
|
+
card_serial_number: bigint | null;
|
|
27
36
|
block_id: string | null;
|
|
28
37
|
card_physical_type: number;
|
|
29
38
|
duty_id: string | null;
|
|
@@ -4,35 +4,40 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
block_id: { type: 'String' },
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
block_id: { type: 'Nullable(String)' },
|
|
11
|
+
calendar_date: { type: 'Date' },
|
|
12
|
+
card_physical_type: { type: 'UInt8' },
|
|
13
|
+
card_serial_number: { type: 'Nullable(UInt64)' },
|
|
14
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
15
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
16
|
+
duty_id: { type: 'Nullable(String)' },
|
|
17
|
+
line_id: { type: 'Nullable(LowCardinality(String))' },
|
|
18
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
19
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
20
|
+
on_board_sale_id: { type: 'Nullable(UUID)' },
|
|
21
|
+
pattern_id: { type: 'Nullable(LowCardinality(String))' },
|
|
22
|
+
payment_method: { type: 'UInt8' },
|
|
23
|
+
price: { type: 'Int32' },
|
|
24
|
+
product_long_id: { type: 'Nullable(LowCardinality(String))' },
|
|
25
|
+
product_quantity: { type: 'Int32' },
|
|
26
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
27
|
+
stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
28
|
+
trip_id: { type: 'Nullable(String)' },
|
|
29
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
30
|
+
validation_id: { type: 'Nullable(UUID)' },
|
|
31
|
+
vehicle_id: { type: 'Nullable(LowCardinality(String))' },
|
|
30
32
|
};
|
|
31
33
|
/* * */
|
|
32
34
|
class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTemplate {
|
|
33
35
|
//
|
|
34
36
|
static _instance = null;
|
|
35
37
|
databaseName = 'simplified_apex';
|
|
38
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
39
|
+
orderBy = 'agency_id, created_at, _id';
|
|
40
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
36
41
|
schema = tableSchema;
|
|
37
42
|
tableName = 'refunds';
|
|
38
43
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexOnBoardSale } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexOnBoardSale> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexOnBoardSale>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -15,6 +18,9 @@ declare class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemp
|
|
|
15
18
|
};
|
|
16
19
|
price: number;
|
|
17
20
|
apex_version: string;
|
|
21
|
+
calendar_date: string & {
|
|
22
|
+
__brand: "CalendarDate";
|
|
23
|
+
};
|
|
18
24
|
device_id: string;
|
|
19
25
|
line_id: string | null;
|
|
20
26
|
mac_ase_counter_value: number;
|
|
@@ -22,8 +28,11 @@ declare class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemp
|
|
|
22
28
|
pattern_id: string | null;
|
|
23
29
|
stop_id: string | null;
|
|
24
30
|
trip_id: string | null;
|
|
31
|
+
updated_at: number & {
|
|
32
|
+
__brand: "UnixTimestamp";
|
|
33
|
+
};
|
|
25
34
|
vehicle_id: number | null;
|
|
26
|
-
card_serial_number:
|
|
35
|
+
card_serial_number: bigint | null;
|
|
27
36
|
block_id: string | null;
|
|
28
37
|
card_physical_type: number;
|
|
29
38
|
duty_id: string | null;
|
|
@@ -4,36 +4,41 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
block_id: { type: 'String' },
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
block_id: { type: 'Nullable(String)' },
|
|
11
|
+
calendar_date: { type: 'Date' },
|
|
12
|
+
card_physical_type: { type: 'UInt8' },
|
|
13
|
+
card_serial_number: { type: 'Nullable(UInt64)' },
|
|
14
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
15
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
16
|
+
duty_id: { type: 'Nullable(String)' },
|
|
16
17
|
is_passenger: { type: 'Bool' },
|
|
17
|
-
line_id: { type: 'String' },
|
|
18
|
-
mac_ase_counter_value: { type: '
|
|
19
|
-
mac_sam_serial_number: { type: '
|
|
20
|
-
on_board_refund_id: { type: 'Nullable(
|
|
21
|
-
pattern_id: { type: 'String' },
|
|
22
|
-
payment_method: { type: '
|
|
23
|
-
price: { type: '
|
|
24
|
-
product_long_id: { type: 'String' },
|
|
25
|
-
product_quantity: { type: '
|
|
26
|
-
received_at: { type: '
|
|
27
|
-
stop_id: { type: 'String' },
|
|
28
|
-
trip_id: { type: 'String' },
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
line_id: { type: 'Nullable(LowCardinality(String))' },
|
|
19
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
20
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
21
|
+
on_board_refund_id: { type: 'Nullable(UUID)' },
|
|
22
|
+
pattern_id: { type: 'Nullable(LowCardinality(String))' },
|
|
23
|
+
payment_method: { type: 'UInt8' },
|
|
24
|
+
price: { type: 'Int32' },
|
|
25
|
+
product_long_id: { type: 'Nullable(LowCardinality(String))' },
|
|
26
|
+
product_quantity: { type: 'Int32' },
|
|
27
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
28
|
+
stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
29
|
+
trip_id: { type: 'Nullable(String)' },
|
|
30
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
31
|
+
validation_id: { type: 'Nullable(UUID)' },
|
|
32
|
+
vehicle_id: { type: 'Nullable(LowCardinality(String))' },
|
|
31
33
|
};
|
|
32
34
|
/* * */
|
|
33
35
|
class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemplate {
|
|
34
36
|
//
|
|
35
37
|
static _instance = null;
|
|
36
38
|
databaseName = 'simplified_apex';
|
|
39
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
40
|
+
orderBy = 'agency_id, created_at, _id';
|
|
41
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
37
42
|
schema = tableSchema;
|
|
38
43
|
tableName = 'sales';
|
|
39
44
|
/**
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../../../types/index.js';
|
|
3
3
|
import { type SimplifiedApexValidation } from '@tmlmobilidade/go-types-apex';
|
|
4
4
|
declare class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTemplate<SimplifiedApexValidation> {
|
|
5
5
|
private static _instance;
|
|
6
6
|
protected readonly databaseName = "simplified_apex";
|
|
7
|
-
protected readonly
|
|
7
|
+
protected readonly engine: ClickHouseTableEngine<SimplifiedApexValidation>;
|
|
8
|
+
protected readonly orderBy = "agency_id, created_at, _id";
|
|
9
|
+
protected readonly partitionBy = "toYYYYMM(created_at)";
|
|
10
|
+
protected readonly schema: ClickHouseTableSchema<{
|
|
8
11
|
_id: string;
|
|
9
12
|
agency_id: string;
|
|
10
13
|
created_at: number & {
|
|
@@ -15,24 +18,30 @@ declare class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTempl
|
|
|
15
18
|
__brand: "UnixTimestamp";
|
|
16
19
|
};
|
|
17
20
|
apex_version: string;
|
|
21
|
+
calendar_date: string & {
|
|
22
|
+
__brand: "CalendarDate";
|
|
23
|
+
};
|
|
18
24
|
device_id: string;
|
|
19
25
|
event_type: number;
|
|
20
26
|
is_ok_pcgi: boolean;
|
|
21
|
-
line_id: string;
|
|
27
|
+
line_id: string | null;
|
|
22
28
|
mac_ase_counter_value: number;
|
|
23
29
|
mac_sam_serial_number: number;
|
|
24
|
-
pattern_id: string;
|
|
25
|
-
product_id: string;
|
|
26
|
-
stop_id: string;
|
|
30
|
+
pattern_id: string | null;
|
|
31
|
+
product_id: string | null;
|
|
32
|
+
stop_id: string | null;
|
|
27
33
|
trip_id: string | null;
|
|
28
34
|
units_qty: number | null;
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
updated_at: number & {
|
|
36
|
+
__brand: "UnixTimestamp";
|
|
37
|
+
};
|
|
38
|
+
vehicle_id: number | null;
|
|
39
|
+
card_serial_number: bigint | null;
|
|
31
40
|
on_board_sale_id: string | null;
|
|
32
41
|
is_passenger: boolean;
|
|
33
42
|
on_board_refund_id: string | null;
|
|
34
43
|
category: "on_board_sale" | "prepaid" | "subscription" | null;
|
|
35
|
-
validation_status: 0 | 1 | 2 | 3 | 4 | 5 | 6 |
|
|
44
|
+
validation_status: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13";
|
|
36
45
|
}>;
|
|
37
46
|
protected readonly tableName = "validations";
|
|
38
47
|
/**
|
|
@@ -4,36 +4,41 @@ import { ClickHouseInterfaceTemplate } from '../../../templates/clickhouse.js';
|
|
|
4
4
|
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
const tableSchema = {
|
|
7
|
-
_id: {
|
|
8
|
-
agency_id: { type: 'String' },
|
|
9
|
-
apex_version: { type: 'String' },
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
_id: { type: 'UUID' },
|
|
8
|
+
agency_id: { type: 'LowCardinality(String)' },
|
|
9
|
+
apex_version: { type: 'LowCardinality(String)' },
|
|
10
|
+
calendar_date: { type: 'Date' },
|
|
11
|
+
card_serial_number: { type: 'Nullable(UInt64)' },
|
|
12
|
+
category: { type: 'LowCardinality(String)' },
|
|
13
|
+
created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
14
|
+
device_id: { type: 'LowCardinality(String)' },
|
|
15
|
+
event_type: { type: 'UInt8' },
|
|
15
16
|
is_ok: { type: 'Bool' },
|
|
16
17
|
is_ok_pcgi: { type: 'Bool' },
|
|
17
18
|
is_passenger: { type: 'Bool' },
|
|
18
|
-
line_id: { type: 'String' },
|
|
19
|
-
mac_ase_counter_value: { type: '
|
|
20
|
-
mac_sam_serial_number: { type: '
|
|
21
|
-
on_board_refund_id: { type: 'Nullable(
|
|
22
|
-
on_board_sale_id: { type: 'Nullable(
|
|
23
|
-
pattern_id: { type: 'String' },
|
|
24
|
-
product_id: { type: 'String' },
|
|
25
|
-
received_at: { type: '
|
|
26
|
-
stop_id: { type: 'String' },
|
|
27
|
-
trip_id: { type: 'String' },
|
|
28
|
-
units_qty: { type: 'Nullable(
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
line_id: { type: 'Nullable(LowCardinality(String))' },
|
|
20
|
+
mac_ase_counter_value: { type: 'UInt64' },
|
|
21
|
+
mac_sam_serial_number: { type: 'UInt64' },
|
|
22
|
+
on_board_refund_id: { type: 'Nullable(UUID)' },
|
|
23
|
+
on_board_sale_id: { type: 'Nullable(UUID)' },
|
|
24
|
+
pattern_id: { type: 'Nullable(LowCardinality(String))' },
|
|
25
|
+
product_id: { type: 'Nullable(LowCardinality(String))' },
|
|
26
|
+
received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
27
|
+
stop_id: { type: 'Nullable(LowCardinality(String))' },
|
|
28
|
+
trip_id: { type: 'Nullable(String)' },
|
|
29
|
+
units_qty: { type: 'Nullable(Int32)' },
|
|
30
|
+
updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
|
|
31
|
+
validation_status: { type: 'UInt8' },
|
|
32
|
+
vehicle_id: { type: 'Nullable(LowCardinality(String))' },
|
|
31
33
|
};
|
|
32
34
|
/* * */
|
|
33
35
|
class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTemplate {
|
|
34
36
|
//
|
|
35
37
|
static _instance = null;
|
|
36
38
|
databaseName = 'simplified_apex';
|
|
39
|
+
engine = 'ReplacingMergeTree(updated_at)';
|
|
40
|
+
orderBy = 'agency_id, created_at, _id';
|
|
41
|
+
partitionBy = 'toYYYYMM(created_at)';
|
|
37
42
|
schema = tableSchema;
|
|
38
43
|
tableName = 'validations';
|
|
39
44
|
/**
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* These are stored in ClickHouse for performance and scalability reasons.
|
|
4
4
|
**/
|
|
5
5
|
import { ClickHouseInterfaceTemplate } from '../../templates/clickhouse.js';
|
|
6
|
-
import { type
|
|
6
|
+
import { type ClickHouseTableSchema, ClickHouseTableEngine } from '../../types/index.js';
|
|
7
7
|
import { type SimplifiedVehicleEvent } from '@tmlmobilidade/types';
|
|
8
8
|
declare class SimplifiedVehicleEventsNewClass extends ClickHouseInterfaceTemplate<SimplifiedVehicleEvent> {
|
|
9
9
|
private static _instance;
|
|
10
10
|
readonly databaseName = "operation";
|
|
11
|
-
readonly engine: ClickHouseTableEngine
|
|
11
|
+
readonly engine: ClickHouseTableEngine<SimplifiedVehicleEvent>;
|
|
12
12
|
readonly orderBy = "(operational_date, trip_id, vehicle_id, agency_id, created_at)";
|
|
13
13
|
readonly partitionBy = "toYYYYMM(fromUnixTimestamp64Milli(created_at))";
|
|
14
14
|
readonly primaryKey = "(operational_date, trip_id, vehicle_id)";
|
|
15
|
-
readonly schema:
|
|
15
|
+
readonly schema: ClickHouseTableSchema<{
|
|
16
16
|
_id: string;
|
|
17
17
|
created_at: number & {
|
|
18
18
|
__brand: "UnixTimestamp";
|
|
@@ -33,7 +33,7 @@ class SimplifiedVehicleEventsNewClass extends ClickHouseInterfaceTemplate {
|
|
|
33
33
|
//
|
|
34
34
|
static _instance = null;
|
|
35
35
|
databaseName = 'operation';
|
|
36
|
-
engine = 'ReplacingMergeTree';
|
|
36
|
+
engine = 'ReplacingMergeTree(created_at)';
|
|
37
37
|
orderBy = '(operational_date, trip_id, vehicle_id, agency_id, created_at)';
|
|
38
38
|
partitionBy = 'toYYYYMM(fromUnixTimestamp64Milli(created_at))';
|
|
39
39
|
primaryKey = '(operational_date, trip_id, vehicle_id)';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ClickHouseTableEngine, type ClickHouseTableSchema } from '../types/index.js';
|
|
2
2
|
import { queryFromFile } from '../utils/clickhouse/query-from-file.js';
|
|
3
3
|
import { queryFromString } from '../utils/clickhouse/query-from-string.js';
|
|
4
4
|
import { type ClickHouseClient, type DataFormat } from '@clickhouse/client';
|
|
5
5
|
export declare abstract class ClickHouseInterfaceTemplate<T extends object> {
|
|
6
6
|
protected readonly abstract databaseName: string;
|
|
7
|
-
protected readonly abstract schema:
|
|
7
|
+
protected readonly abstract schema: ClickHouseTableSchema<T>;
|
|
8
8
|
protected readonly abstract tableName: string;
|
|
9
|
-
protected readonly engine: ClickHouseTableEngine
|
|
9
|
+
protected readonly engine: ClickHouseTableEngine<T>;
|
|
10
10
|
/**
|
|
11
11
|
* When `true` (default), `init()` runs `ensureDatabase()` + `ensureTable()` so
|
|
12
12
|
* the schema is created from this class. Set to `false` for tables whose schema
|
|
@@ -131,9 +131,4 @@ export declare abstract class ClickHouseInterfaceTemplate<T extends object> {
|
|
|
131
131
|
* @returns A promise that resolves when the table is ensured to exist.
|
|
132
132
|
*/
|
|
133
133
|
private ensureTable;
|
|
134
|
-
/**
|
|
135
|
-
* Constructs the appropriate engine string based on the provided engine type.
|
|
136
|
-
* @throws Will throw an error if an unsupported engine type is provided.
|
|
137
|
-
*/
|
|
138
|
-
private getEngineString;
|
|
139
134
|
}
|
|
@@ -7,7 +7,7 @@ import { ClickHouseError } from '@clickhouse/client';
|
|
|
7
7
|
import { Logger } from '@tmlmobilidade/logger';
|
|
8
8
|
/* * */
|
|
9
9
|
export class ClickHouseInterfaceTemplate {
|
|
10
|
-
engine = 'MergeTree';
|
|
10
|
+
engine = 'MergeTree()';
|
|
11
11
|
/**
|
|
12
12
|
* When `true` (default), `init()` runs `ensureDatabase()` + `ensureTable()` so
|
|
13
13
|
* the schema is created from this class. Set to `false` for tables whose schema
|
|
@@ -209,7 +209,7 @@ export class ClickHouseInterfaceTemplate {
|
|
|
209
209
|
const createTableQuery = `
|
|
210
210
|
CREATE TABLE IF NOT EXISTS "${this.databaseName}"."${this.tableName}" (
|
|
211
211
|
${Object.entries(this.schema).map(([key, column]) => `${key} ${column.type}`).join(', ')}
|
|
212
|
-
) ENGINE = ${this.
|
|
212
|
+
) ENGINE = ${this.engine}
|
|
213
213
|
${this.primaryKey ? `PRIMARY KEY (${this.primaryKey})` : ''}
|
|
214
214
|
${this.orderBy ? `ORDER BY (${this.orderBy})` : ''}
|
|
215
215
|
${this.partitionBy ? `PARTITION BY (${this.partitionBy})` : ''}
|
|
@@ -244,18 +244,4 @@ export class ClickHouseInterfaceTemplate {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Constructs the appropriate engine string based on the provided engine type.
|
|
249
|
-
* @throws Will throw an error if an unsupported engine type is provided.
|
|
250
|
-
*/
|
|
251
|
-
getEngineString() {
|
|
252
|
-
switch (this.engine) {
|
|
253
|
-
case 'MergeTree':
|
|
254
|
-
return `MergeTree()`;
|
|
255
|
-
case 'ReplacingMergeTree':
|
|
256
|
-
return `ReplacingMergeTree()`;
|
|
257
|
-
default:
|
|
258
|
-
throw new Error(`CLICKHOUSE [${this.databaseName}/${this.tableName}]: Unsupported engine type: ${this.engine}`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
247
|
}
|
|
@@ -6,8 +6,6 @@ import { type ClickHouseDataType } from './data-types.js';
|
|
|
6
6
|
export interface ClickHouseColumn {
|
|
7
7
|
/** Alias expression (computed on read) */
|
|
8
8
|
alias?: string;
|
|
9
|
-
/** Column codec for compression */
|
|
10
|
-
codec?: string;
|
|
11
9
|
/** Comment for the column */
|
|
12
10
|
comment?: string;
|
|
13
11
|
/** Default value expression */
|
|
@@ -18,16 +16,10 @@ export interface ClickHouseColumn {
|
|
|
18
16
|
indexGranularity?: number;
|
|
19
17
|
/** Type of skipping index. Default: 'minmax' */
|
|
20
18
|
indexType?: 'bloom_filter' | 'minmax' | 'ngrambf_v1' | 'set' | 'tokenbf_v1';
|
|
21
|
-
/** Use LowCardinality wrapper for low-cardinality strings */
|
|
22
|
-
lowCardinality?: boolean;
|
|
23
19
|
/** Materialized value expression (computed on insert) */
|
|
24
20
|
materialized?: string;
|
|
25
21
|
/** Whether the column can be null (wraps type in Nullable) */
|
|
26
22
|
nullable?: boolean;
|
|
27
|
-
/** Include this column in the ORDER BY clause (ClickHouse's primary index) */
|
|
28
|
-
primaryKey?: boolean;
|
|
29
|
-
/** Order of this column in the primary key (lower = first). Default: 0 */
|
|
30
|
-
primaryKeyOrder?: number;
|
|
31
23
|
/** TTL expression for this column */
|
|
32
24
|
ttl?: string;
|
|
33
25
|
/** The ClickHouse data type */
|
|
@@ -37,6 +29,6 @@ export interface ClickHouseColumn {
|
|
|
37
29
|
* A ClickHouse schema is a mapping of column names to their definitions (ClickHouseColumn).
|
|
38
30
|
* The generic type T represents the shape of the data, and the keys of T are used as column names.
|
|
39
31
|
*/
|
|
40
|
-
export type
|
|
32
|
+
export type ClickHouseTableSchema<T extends object> = {
|
|
41
33
|
[K in keyof T]: ClickHouseColumn;
|
|
42
34
|
};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Supported ClickHouse data types that
|
|
3
3
|
* can be used in ClickHouse table schemas.
|
|
4
4
|
*/
|
|
5
|
-
export type ClickHouseDataType = 'Bool' | '
|
|
5
|
+
export type ClickHouseDataType = 'Bool' | 'Date' | 'Float64' | 'Int32' | 'Int64' | 'String' | 'UInt8' | 'UInt64' | 'UUID' | `DateTime64(3, 'UTC') CODEC(Delta, ZSTD)` | `Enum8(${string})` | `LowCardinality(String)` | `Nullable(Float64)` | `Nullable(Int32)` | `Nullable(Int64)` | `Nullable(LowCardinality(String))` | `Nullable(String)` | `Nullable(UInt64)` | `Nullable(UUID)`;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Please avoid using other engines before consulting with the team
|
|
4
4
|
* as ClickHouse has many engines with different features and limitations.
|
|
5
5
|
*/
|
|
6
|
-
export type ClickHouseTableEngine = 'MergeTree' |
|
|
6
|
+
export type ClickHouseTableEngine<T extends object> = 'MergeTree()' | `ReplacingMergeTree(${Extract<keyof T, string>})`;
|