semanticdb-v2 2.0.0-alpha.4 → 2.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -17
- package/dist/cache/redis-query-cache.esm.js +1 -1
- package/dist/cache/redis-query-cache.js +1 -1
- package/dist/cache/types.d.ts +2 -0
- package/dist/compiler/compile-cte.d.ts +1 -1
- package/dist/errors.d.ts +2 -1
- package/dist/executor/components.d.ts +8 -3
- package/dist/executor/connection-registry.d.ts +2 -2
- package/dist/executor/execute-query.d.ts +6 -1
- package/dist/executor/federated-execution.d.ts +37 -0
- package/dist/executor/fetch-entities.d.ts +5 -1
- package/dist/executor/result-hydrator/types.d.ts +2 -0
- package/dist/executor/total.d.ts +11 -0
- package/dist/executor/types.d.ts +41 -6
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/locales/en-US.d.ts +2 -0
- package/dist/i18n/locales/zh-CN.d.ts +2 -0
- package/dist/i18n/registry.d.ts +13 -0
- package/dist/i18n/types.d.ts +9 -0
- package/dist/index.d.ts +11 -8
- package/dist/logicform-types.d.ts +44 -12
- package/dist/normalizer/core.d.ts +5 -0
- package/dist/normalizer/default-pred-name.d.ts +2 -0
- package/dist/normalizer/index.d.ts +1 -0
- package/dist/normalizer/pred-expression.d.ts +6 -0
- package/dist/normalizer/property-resolve.d.ts +1 -0
- package/dist/operators/builtins/period-name.d.ts +2 -1
- package/dist/operators/builtins/query-expression.d.ts +3 -0
- package/dist/operators/index.d.ts +2 -1
- package/dist/operators/registry.d.ts +1 -1
- package/dist/operators/resolve.d.ts +3 -0
- package/dist/operators/types.d.ts +55 -15
- package/dist/physical/clickhouse-provider.d.ts +14 -2
- package/dist/physical/connection.d.ts +57 -15
- package/dist/physical/dameng-provider.d.ts +61 -0
- package/dist/physical/databricks-provider.d.ts +83 -0
- package/dist/physical/display-query.d.ts +3 -0
- package/dist/physical/doris-provider.d.ts +2 -1
- package/dist/physical/duckdb-coordinator-provider.d.ts +37 -0
- package/dist/physical/gbase-provider.d.ts +11 -0
- package/dist/physical/index.d.ts +21 -9
- package/dist/physical/load-driver.d.ts +1 -0
- package/dist/physical/maxcompute-provider.d.ts +37 -0
- package/dist/physical/mysql-protocol-provider.d.ts +21 -6
- package/dist/physical/mysql-provider.d.ts +2 -1
- package/dist/physical/oracle-provider.d.ts +15 -4
- package/dist/physical/postgresql-provider.d.ts +18 -4
- package/dist/physical/provider.d.ts +16 -1
- package/dist/physical/snowflake-provider.d.ts +15 -3
- package/dist/physical/sqlserver-provider.d.ts +65 -0
- package/dist/physical/starrocks-provider.d.ts +2 -1
- package/dist/planner/build-lineage.d.ts +1 -1
- package/dist/planner/create-logical-plan.d.ts +7 -0
- package/dist/planner/index.d.ts +4 -2
- package/dist/planner/mapping-granularity.d.ts +7 -0
- package/dist/planner/rewrite-nested-components.d.ts +8 -0
- package/dist/planner/select-schema-mapping.d.ts +16 -2
- package/dist/planner/semantics/index.d.ts +0 -3
- package/dist/planner/semantics/periods.d.ts +13 -0
- package/dist/planner/semantics/registry-defaults.d.ts +2 -1
- package/dist/planner/types.d.ts +80 -12
- package/dist/plugins/hierarchy/index.d.ts +1 -1
- package/dist/plugins/hierarchy/mapping-granularity.d.ts +4 -0
- package/dist/plugins/hierarchy/types.d.ts +17 -0
- package/dist/plugins/index.d.ts +10 -1
- package/dist/{planner/semantics → plugins}/observation/classification.d.ts +1 -1
- package/dist/plugins/observation/index.d.ts +17 -0
- package/dist/{planner/semantics → plugins}/observation/operator-policy.d.ts +2 -3
- package/dist/plugins/observation/periods.d.ts +18 -0
- package/dist/{planner/semantics → plugins}/observation/rule.d.ts +1 -1
- package/dist/{planner/semantics → plugins}/observation/types.d.ts +1 -1
- package/dist/plugins/property-hierarchy/index.d.ts +11 -0
- package/dist/plugins/recursive/index.d.ts +26 -0
- package/dist/plugins/temporal/index.d.ts +13 -0
- package/dist/plugins/types.d.ts +165 -1
- package/dist/plugins/validity/classification.d.ts +5 -0
- package/dist/plugins/validity/index.d.ts +15 -0
- package/dist/plugins/validity/periods.d.ts +15 -0
- package/dist/plugins/validity/query-policy.d.ts +3 -0
- package/dist/plugins/validity/rule.d.ts +2 -0
- package/dist/plugins/validity/semantic-types.d.ts +3 -0
- package/dist/schema/dependent-projection.d.ts +8 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema-mappings/freshness.d.ts +1 -1
- package/dist/schema-mappings/granularity.d.ts +5 -0
- package/dist/schema-mappings/index.d.ts +2 -1
- package/dist/schema-mappings/registry.d.ts +5 -3
- package/dist/schema-mappings/types.d.ts +43 -0
- package/dist/schema-mappings/yiask.d.ts +6 -2
- package/dist/semantic-types/index.d.ts +5 -3
- package/dist/semantic-types/registry.d.ts +2 -0
- package/dist/semantic-types/resolve-schema.d.ts +1 -1
- package/dist/semantic-types/types.d.ts +6 -13
- package/dist/semantic-types/validate-resolved-schema.d.ts +2 -5
- package/dist/semanticdb.esm.js +4 -3
- package/dist/semanticdb.js +4 -3
- package/package.json +47 -5
- package/dist/planner/semantics/lifecycle/classification.d.ts +0 -7
- package/dist/planner/semantics/lifecycle/index.d.ts +0 -3
- package/dist/planner/semantics/lifecycle/query-policy.d.ts +0 -3
- package/dist/planner/semantics/lifecycle/rule.d.ts +0 -2
- package/dist/planner/semantics/observation/index.d.ts +0 -4
- package/dist/semantic-types/builtins/end-date.d.ts +0 -2
- package/dist/semantic-types/builtins/start-date.d.ts +0 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LocaleDefinition, LocaleInput, LocaleTranslate } from './types';
|
|
2
|
+
export declare class LocaleRegistry {
|
|
3
|
+
private readonly definitions;
|
|
4
|
+
private readonly i18n;
|
|
5
|
+
constructor(locales?: LocaleInput);
|
|
6
|
+
register(locales: LocaleInput | undefined): this;
|
|
7
|
+
resolve(locale?: string): LocaleDefinition;
|
|
8
|
+
has(locale: string): boolean;
|
|
9
|
+
translate(locale: string, key: string, fallback?: string, values?: Readonly<Record<string, unknown>>): string;
|
|
10
|
+
translator(locale?: string): LocaleTranslate;
|
|
11
|
+
}
|
|
12
|
+
export declare const createLocaleRegistry: (locales?: LocaleInput) => LocaleRegistry;
|
|
13
|
+
export declare const defaultLocaleRegistry: LocaleRegistry;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A locale file consumed by SemanticDB's naming and error messages. */
|
|
2
|
+
export interface LocaleDefinition {
|
|
3
|
+
/** BCP-47 locale tag, for example `zh-CN` or `en-US`. */
|
|
4
|
+
readonly locale: string;
|
|
5
|
+
/** Translation messages keyed by a stable SemanticDB message key. */
|
|
6
|
+
readonly messages: Readonly<Record<string, string>>;
|
|
7
|
+
}
|
|
8
|
+
export type LocaleInput = LocaleDefinition | readonly LocaleDefinition[];
|
|
9
|
+
export type LocaleTranslate = (key: string, fallback?: string, values?: Readonly<Record<string, unknown>>) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
export { createLocaleRegistry, defaultLocaleRegistry, LocaleRegistry, enUS, zhCN, } from './i18n/index';
|
|
2
|
+
export type { LocaleDefinition, LocaleInput, LocaleTranslate } from './i18n/index';
|
|
1
3
|
export declare const Logicform: Readonly<{
|
|
2
4
|
execute: (inputLogicform: import("./logicform-types").LogicformType, inputOptions: import(".").ExecuteOptions) => Promise<import(".").ExecuteResult>;
|
|
3
5
|
close: () => Promise<void>;
|
|
4
6
|
}>;
|
|
5
7
|
export { SemanticDBError } from './errors';
|
|
6
8
|
export { builtinSemanticTypes, createSemanticTypeRegistry, resolveSchema, SemanticTypeRegistry, validateResolvedSchema, } from './semantic-types/index';
|
|
7
|
-
export { builtinOperators, createOperatorRegistry, OperatorRegistry, } from './operators/index';
|
|
8
|
-
export type { LegacySchemaPluginContext, SchemaMetadataPlugin, SemanticDBPlugin, } from './plugins/index';
|
|
9
|
+
export { builtinOperators, createOperatorRegistry, OperatorRegistry, resolveOperator, } from './operators/index';
|
|
10
|
+
export type { LegacySchemaPluginContext, MappingGranularityContext, MappingGranularityPlugin, OutputHandlerContext, OutputHandlerDefinition, IntervalSemanticProperties, IntervalSemanticsDefinition, PlannerPeriodDefinition, PlannerPeriodEvaluation, RelationSemanticsDefinition, RelationTemporalPlan, TimeWatermarkLogicformContext, PropertyMetadataPlugin, QueryOperatorCompileContext, QueryOperatorAuthorizeContext, QueryOperatorDefinition, QueryOperatorNormalizeContext, QueryOperatorPhysicalSource, QueryOperatorPlanContext, QueryOperatorPlanResult, SchemaMetadataPlugin, SchemaMappingPlugin, SemanticDBPlugin, } from './plugins/index';
|
|
9
11
|
export { SchemaMappingRegistry, fromYiAskSchemaMapping, } from './schema-mappings/index';
|
|
10
|
-
export type { AbsoluteDateValue, CompareOperator, CalendarDateValue, DateTimeValue, DateValue, EntityIdType, ExpressionItemType, LogicformType, PublicLogicformType, PeriodShiftTime, PredItemType, QueryLogicalOperand,
|
|
12
|
+
export type { AbsoluteDateValue, CompareOperator, DatePartQueryComparison, DatePartQueryOperand, CalendarDateValue, DateTimeValue, DateValue, EntityIdType, ExpressionItemType, LogicformType, NumericQueryComparison, NumericQueryOperand, PublicLogicformType, PeriodShiftTime, PredItemType, QueryLogicalOperand, QueryExpressionType, RelationQueryType, QueryType, QueryValueType, QueryValueTypeWithCompareOperator, RelativeDateValue, RepresentationType, } from './logicform-types';
|
|
13
|
+
export type { RecursiveQueryType } from './plugins/index';
|
|
11
14
|
export { CALENDAR_DATES_TABLE, CALENDAR_RELATIONS_TABLE, CALENDAR_SYSTEM_SCHEMA_IDS, calendarSystemSchemas, ProviderCalendarRelationStore, resolveCalendarPeriod, resolveCalendarPeriodFromStore, selectCalendarDates, } from './calendar/index';
|
|
12
15
|
export type { CalendarAlignment, CalendarComparison, CalendarDateRow, CalendarRelation, CalendarRelationRow, ResolvedCalendarPeriod, } from './calendar/index';
|
|
13
16
|
export type { CalendarRelationStore } from './calendar/index';
|
|
14
|
-
export type { PrimalType, PropertySqlDefinition, ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, SemanticTypeResultContext, SemanticTypeResultProperty,
|
|
15
|
-
export type {
|
|
16
|
-
export
|
|
17
|
-
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorPlanInputContext, OperatorPlannedInput, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, } from './operators/index';
|
|
18
|
-
export type { SchemaMappingDefinition, SchemaMappingItem, SchemaMappingPredDefinition, SchemaMappingPredMatch, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
|
|
17
|
+
export type { PrimalType, PropertyHierarchyDefinition, PropertySqlDefinition, ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, SemanticTypeResultContext, SemanticTypeResultProperty, TimeGranularity, TimeWatermarkPolicy, } from './semantic-types/index';
|
|
18
|
+
export type { DataRow, SqlParameters, BuiltinDatabaseConnection, DatabaseConnection, DatabaseConnectionBase, DatabaseConnectionExtensions, ProviderDefinition, ProviderKind, ProviderKindExtensions, } from './physical/index';
|
|
19
|
+
export { ProviderRegistry } from './physical/index';
|
|
20
|
+
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorPlanInputContext, OperatorPlannedInput, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './operators/index';
|
|
21
|
+
export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingPredDefinition, SchemaMappingPredMatch, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
|
|
19
22
|
export type { QueryCache, QueryCacheExecutionOptions, QueryCacheIdentity, QueryCacheWriteOptions, } from './cache/index';
|
|
20
23
|
export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlType, PartialExecuteResult, ProgressCallback, } from './executor/index';
|
|
21
24
|
export type { ColumnPermissions, Permissions, SchemaPermissions, } from './permissions/index';
|
|
@@ -36,14 +36,9 @@ export type PeriodShiftTime = RelativeDateValue | AbsoluteDateValue;
|
|
|
36
36
|
export type DateValue = string | RelativeDateValue | AbsoluteDateValue | CalendarDateValue;
|
|
37
37
|
/** Stable entity identity. Numeric IDs must be safe integers. */
|
|
38
38
|
export type EntityIdType = string | number;
|
|
39
|
-
export type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$contains' | '$
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
readonly root?: QueryValueType;
|
|
43
|
-
readonly roots?: QueryValueType[];
|
|
44
|
-
readonly includeSelf?: boolean;
|
|
45
|
-
readonly idProperty?: string;
|
|
46
|
-
readonly parentProperty?: string;
|
|
39
|
+
export type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$contains' | '$startsWith' | '$length' | '$and' | '$or' | '$second' | '$minute' | '$hour' | '$weekday' | '$day' | '$week' | '$month' | '$quarter' | '$year' | Extract<keyof QueryOperatorExtensions, string>;
|
|
40
|
+
/** Module-augmentation seam for plugin-owned field Query Operators. */
|
|
41
|
+
export interface QueryOperatorExtensions {
|
|
47
42
|
}
|
|
48
43
|
export type QueryValueType = null | string | number | boolean | DateValue | RelationQueryType | LogicformType | string[] | number[] | boolean[] | DateValue[] | RelationQueryType[] | LogicformType[];
|
|
49
44
|
/** A query scoped through an object relation. Version is inherited from the parent LogicForm. */
|
|
@@ -55,6 +50,26 @@ export interface RelationQueryType {
|
|
|
55
50
|
readonly entity_id?: EntityIdType;
|
|
56
51
|
}
|
|
57
52
|
export type QueryLogicalOperand = QueryValueType | QueryValueTypeWithCompareOperator;
|
|
53
|
+
/** Apply a scalar pred expression, then test its result against a condition. */
|
|
54
|
+
export interface QueryExpressionType {
|
|
55
|
+
readonly pred: PredItemType;
|
|
56
|
+
readonly condition: QueryLogicalOperand;
|
|
57
|
+
}
|
|
58
|
+
export type NumericQueryOperand = number | number[] | NumericQueryComparison;
|
|
59
|
+
export type NumericQueryComparison = Partial<{
|
|
60
|
+
$eq: number;
|
|
61
|
+
$gt: number;
|
|
62
|
+
$gte: number;
|
|
63
|
+
$lt: number;
|
|
64
|
+
$lte: number;
|
|
65
|
+
$ne: number;
|
|
66
|
+
$in: number[];
|
|
67
|
+
$nin: number[];
|
|
68
|
+
$and: NumericQueryOperand[];
|
|
69
|
+
$or: NumericQueryOperand[];
|
|
70
|
+
}>;
|
|
71
|
+
export type DatePartQueryOperand = NumericQueryOperand;
|
|
72
|
+
export type DatePartQueryComparison = NumericQueryComparison;
|
|
58
73
|
export type QueryValueTypeWithCompareOperator = Partial<{
|
|
59
74
|
$eq: QueryValueType;
|
|
60
75
|
$gt: QueryValueType;
|
|
@@ -67,18 +82,32 @@ export type QueryValueTypeWithCompareOperator = Partial<{
|
|
|
67
82
|
$exists: QueryValueType;
|
|
68
83
|
$regex: QueryValueType;
|
|
69
84
|
$contains: QueryValueType;
|
|
85
|
+
$startsWith: string;
|
|
86
|
+
$length: NumericQueryOperand;
|
|
87
|
+
$second: DatePartQueryOperand;
|
|
88
|
+
$minute: DatePartQueryOperand;
|
|
89
|
+
$hour: DatePartQueryOperand;
|
|
90
|
+
/** ISO weekday: Monday=1 through Sunday=7. */
|
|
91
|
+
$weekday: DatePartQueryOperand;
|
|
92
|
+
/** Day of month. */
|
|
93
|
+
$day: DatePartQueryOperand;
|
|
94
|
+
/** ISO week of year. */
|
|
95
|
+
$week: DatePartQueryOperand;
|
|
96
|
+
$month: DatePartQueryOperand;
|
|
97
|
+
$quarter: DatePartQueryOperand;
|
|
98
|
+
$year: DatePartQueryOperand;
|
|
70
99
|
args?: {
|
|
71
100
|
readonly options?: string;
|
|
72
101
|
};
|
|
73
|
-
$recursive: QueryValueType | RecursiveQueryType;
|
|
74
102
|
$and: QueryLogicalOperand[];
|
|
75
103
|
$or: QueryLogicalOperand[];
|
|
76
|
-
}> & {
|
|
104
|
+
}> & Partial<QueryOperatorExtensions> & {
|
|
77
105
|
readonly schema?: never;
|
|
78
106
|
};
|
|
79
|
-
export type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryType[] | undefined> & {
|
|
107
|
+
export type QueryType = Record<string, QueryValueType | QueryValueTypeWithCompareOperator | QueryExpressionType | QueryType[] | undefined> & {
|
|
80
108
|
readonly $and?: QueryType[];
|
|
81
109
|
readonly $or?: QueryType[];
|
|
110
|
+
readonly $expr?: QueryExpressionType;
|
|
82
111
|
};
|
|
83
112
|
export interface ExpressionItemType {
|
|
84
113
|
operator?: string;
|
|
@@ -92,7 +121,10 @@ export interface PredItemType extends ExpressionItemType {
|
|
|
92
121
|
pred?: string | PredItemType | (string | PredItemType)[];
|
|
93
122
|
query?: QueryType;
|
|
94
123
|
}
|
|
95
|
-
|
|
124
|
+
/** Module-augmentation seam for plugin-owned output types. */
|
|
125
|
+
export interface LogicformOutputExtensions {
|
|
126
|
+
}
|
|
127
|
+
export type LogicformOutputTypeValue = 'url' | 'data' | 'export' | 'sql' | 'sqlComponents' | Extract<keyof LogicformOutputExtensions, string>;
|
|
96
128
|
export interface LogicformOutputType {
|
|
97
129
|
type: LogicformOutputTypeValue;
|
|
98
130
|
filename?: string;
|
|
@@ -2,12 +2,17 @@ import type { LogicformType } from '../logicform-types';
|
|
|
2
2
|
import type { OperatorRegistry } from '../operators/index';
|
|
3
3
|
import type { ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeRegistry } from '../semantic-types/index';
|
|
4
4
|
import type { SemanticDBPlugin } from '../plugins/index';
|
|
5
|
+
import type { LocaleInput, LocaleRegistry } from '../i18n/index';
|
|
5
6
|
export interface NormalizeLogicformOptions {
|
|
6
7
|
readonly semanticTypes: SemanticTypeRegistry;
|
|
7
8
|
readonly operators?: OperatorRegistry;
|
|
8
9
|
readonly plugins?: readonly SemanticDBPlugin[];
|
|
9
10
|
/** Locale used for generated human-readable PredItem names. Defaults to zh-CN. */
|
|
10
11
|
readonly locale?: string;
|
|
12
|
+
/** Additional or overriding locale files used for generated names. */
|
|
13
|
+
readonly locales?: LocaleInput;
|
|
14
|
+
/** Internal registry shared by recursive normalization calls. */
|
|
15
|
+
readonly localeRegistry?: LocaleRegistry;
|
|
11
16
|
readonly now?: Date;
|
|
12
17
|
readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
|
|
13
18
|
readonly requestTimeWatermark?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty, requestedUpperBound: Date) => Promise<Date | undefined>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { PredItemType } from '../logicform-types';
|
|
2
2
|
import type { OperatorRegistry } from '../operators/index';
|
|
3
|
+
import { type LocaleRegistry } from '../i18n/index';
|
|
3
4
|
export interface DefaultPredNameOptions {
|
|
4
5
|
readonly locale?: string;
|
|
6
|
+
readonly localeRegistry?: LocaleRegistry;
|
|
5
7
|
}
|
|
6
8
|
export declare const defaultPredName: (pred: PredItemType, operators: OperatorRegistry, options?: DefaultPredNameOptions) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogicformType, PredItemType } from '../logicform-types';
|
|
2
|
+
import type { ResolvedSemanticSchema } from '../semantic-types/index';
|
|
3
|
+
import type { NormalizeLogicformOptions } from './core';
|
|
4
|
+
type NormalizePredQuery = (query: LogicformType['query'], schema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => Promise<LogicformType['query']>;
|
|
5
|
+
export declare const normalizePredExpression: (pred: PredItemType, schema: ResolvedSemanticSchema, options: NormalizeLogicformOptions, normalizePredQuery: NormalizePredQuery) => Promise<PredItemType>;
|
|
6
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LogicformType } from '../logicform-types';
|
|
2
2
|
import type { ResolvedSemanticSchema } from '../semantic-types/index';
|
|
3
3
|
import type { NormalizeLogicformOptions } from './core';
|
|
4
|
+
export declare const inferPropertyResolvePath: (rootSchema: ResolvedSemanticSchema, reference: string, targetSchema: ResolvedSemanticSchema, resolveSchema?: (schemaId: string) => ResolvedSemanticSchema) => string | undefined;
|
|
4
5
|
/** Adds cross-Schema aliases after both legacy and v2 forms share normalization. */
|
|
5
6
|
export declare const normalizePropertyResolve: (logicform: LogicformType, rootSchema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => LogicformType;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { LocaleTranslate } from '../../i18n/index';
|
|
2
|
+
export declare const periodComparisonName: (args: Readonly<Record<string, unknown>>, locale: string, t?: LocaleTranslate) => string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { SemanticDBPlugin } from '../plugins/index';
|
|
2
2
|
import { OperatorRegistry } from './registry';
|
|
3
3
|
export { OperatorRegistry } from './registry';
|
|
4
|
+
export { resolveOperator } from './resolve';
|
|
4
5
|
export { bindTrustedSqlExpression } from './sql-expression';
|
|
5
|
-
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext,
|
|
6
|
+
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorComponentContext, OperatorComponentCalculation, OperatorComponentQuery, OperatorExecutionComponent, OperatorGroupKeyShift, OperatorJavaScriptCalculation, OperatorQueryComponent, OperatorEvaluateContext, OperatorOutputPropertyContext, OperatorPeriodBoundaryPolicy, OperatorPeriodBoundaryPolicyContext, OperatorNormalizePredContext, OperatorPlanExpressionContext, OperatorPeriodEvaluationContext, OperatorPlanInputContext, OperatorPlannedInput, OperatorRewriteLogicformContext, OperatorValidatePlanContext, OperatorSqlCapabilities, OperatorSqlContext, ResultProperty, ResultPropertyTemporalMetadata, ResultPropertyTemporalMetadataExtensions, } from './types';
|
|
6
7
|
export declare const builtinOperators: readonly import("./types").OperatorDefinition[];
|
|
7
8
|
export declare const createOperatorRegistry: (plugins?: readonly SemanticDBPlugin[]) => OperatorRegistry;
|
|
@@ -2,7 +2,7 @@ import type { OperatorDefinition, OperatorPeriodEvaluationContext } from './type
|
|
|
2
2
|
export declare class OperatorRegistry {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(definitions?: readonly OperatorDefinition[]);
|
|
5
|
-
register(
|
|
5
|
+
register(input: OperatorDefinition): this;
|
|
6
6
|
get(name: string): OperatorDefinition;
|
|
7
7
|
requiresPerPeriodEvaluation(name: string, context: OperatorPeriodEvaluationContext): boolean;
|
|
8
8
|
has(name: string): boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, TimeGranularity, ComparableCategoryDefinition } from '../semantic-types/index';
|
|
2
2
|
import type { LogicformType, PredItemType } from '../logicform-types';
|
|
3
3
|
import type { DataRow } from '../physical/index';
|
|
4
|
-
import type { Expression } from '../planner/index';
|
|
4
|
+
import type { Expression, LogicalPlan } from '../planner/index';
|
|
5
|
+
import type { LocaleTranslate } from '../i18n/index';
|
|
5
6
|
export interface OperatorSqlCapabilities {
|
|
6
7
|
/** Produce a dialect-specific aggregate function around an expression. */
|
|
7
8
|
aggregateFunction(name: string, expression?: string): string;
|
|
@@ -9,12 +10,16 @@ export interface OperatorSqlCapabilities {
|
|
|
9
10
|
quoteIdentifier(identifier: string): string;
|
|
10
11
|
concat(expressions: readonly string[]): string;
|
|
11
12
|
substring(expression: string, start: number, length: number): string;
|
|
13
|
+
stringLength(expression: string): string;
|
|
14
|
+
datePart(expression: string, part: 'second' | 'minute' | 'hour' | 'weekday' | 'day' | 'week' | 'month' | 'quarter' | 'year'): string;
|
|
12
15
|
dateBucket(expression: string, granularity: TimeGranularity): string;
|
|
13
16
|
dateShift(expression: string, granularity: TimeGranularity, offset: number): string;
|
|
14
17
|
/** Render a period boundary directly when the dialect has a concise native form. */
|
|
15
18
|
datePeriodBoundary?(expression: string, granularity: TimeGranularity, boundary: 'start' | 'end'): string;
|
|
19
|
+
/** Render a NULL-ignoring scalar extremum using a dialect-native expression. */
|
|
20
|
+
scalarExtremum?(operator: 'least' | 'greatest', expressions: readonly string[]): string;
|
|
16
21
|
/** Bind a literal as a SQL parameter. */
|
|
17
|
-
value(value: unknown): string;
|
|
22
|
+
value(value: unknown, type?: string): string;
|
|
18
23
|
/** Compile a field-local LogicForm condition against an expression. */
|
|
19
24
|
condition(expression: string, condition: unknown): string;
|
|
20
25
|
}
|
|
@@ -43,6 +48,8 @@ export interface ResultProperty {
|
|
|
43
48
|
readonly type: string;
|
|
44
49
|
readonly primal_type: PrimalType;
|
|
45
50
|
readonly isArray: boolean;
|
|
51
|
+
/** Description inherited from the source Property or supplied by the operator. */
|
|
52
|
+
readonly description?: string;
|
|
46
53
|
/** Referenced Schema for object-valued result columns. */
|
|
47
54
|
readonly ref?: string;
|
|
48
55
|
readonly granularity?: TimeGranularity;
|
|
@@ -50,8 +57,11 @@ export interface ResultProperty {
|
|
|
50
57
|
/** Runtime temporal semantics for this output column, when applicable. */
|
|
51
58
|
readonly temporal?: ResultPropertyTemporalMetadata;
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
/** Plugin-owned result temporal metadata extends this interface by key. */
|
|
61
|
+
export interface ResultPropertyTemporalMetadataExtensions {
|
|
62
|
+
}
|
|
63
|
+
export type ResultPropertyTemporalMetadata = {
|
|
64
|
+
readonly kind: 'period-boundary' | 'period-shift' | 'date-bucket';
|
|
55
65
|
readonly boundary?: 'start' | 'end';
|
|
56
66
|
readonly sourceProperty?: string;
|
|
57
67
|
readonly requestedRange?: {
|
|
@@ -71,7 +81,7 @@ export interface ResultPropertyTemporalMetadata {
|
|
|
71
81
|
readonly group: Readonly<Record<string, unknown>>;
|
|
72
82
|
readonly date: string;
|
|
73
83
|
}[];
|
|
74
|
-
}
|
|
84
|
+
} | ResultPropertyTemporalMetadataExtensions[keyof ResultPropertyTemporalMetadataExtensions];
|
|
75
85
|
export interface OperatorOutputPropertyContext {
|
|
76
86
|
/** Final alias assigned to this operator's single output column. */
|
|
77
87
|
readonly name: string;
|
|
@@ -100,8 +110,10 @@ export interface OperatorDefaultNameContext {
|
|
|
100
110
|
readonly inputNames: readonly string[];
|
|
101
111
|
/** Operator-specific LogicForm arguments. */
|
|
102
112
|
readonly args: Readonly<Record<string, unknown>>;
|
|
103
|
-
/** Requested locale
|
|
113
|
+
/** Requested locale for generated names. */
|
|
104
114
|
readonly locale: string;
|
|
115
|
+
/** Translate a stable message key using the requested locale. */
|
|
116
|
+
readonly t?: LocaleTranslate;
|
|
105
117
|
}
|
|
106
118
|
export interface OperatorPlanInputContext {
|
|
107
119
|
/** Canonical property or relation reference supplied as this operator's direct pred. */
|
|
@@ -130,10 +142,10 @@ export interface OperatorPlanExpressionContext {
|
|
|
130
142
|
readonly getOperator: (name: string) => OperatorDefinition;
|
|
131
143
|
readonly planQuery: (query: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
|
|
132
144
|
}
|
|
133
|
-
export interface
|
|
145
|
+
export interface OperatorPeriodBoundaryPolicyContext {
|
|
134
146
|
readonly pred: PredItemType;
|
|
135
147
|
}
|
|
136
|
-
export interface
|
|
148
|
+
export interface OperatorPeriodBoundaryPolicy {
|
|
137
149
|
readonly boundary: 'start' | 'end';
|
|
138
150
|
readonly implicit: boolean;
|
|
139
151
|
}
|
|
@@ -143,6 +155,9 @@ export interface OperatorValidatePlanContext {
|
|
|
143
155
|
readonly resolveGroupName: (reference: string) => string | undefined;
|
|
144
156
|
readonly getOperator: (name: string) => OperatorDefinition;
|
|
145
157
|
}
|
|
158
|
+
export interface OperatorValidateGroupbyContext {
|
|
159
|
+
readonly pred: PredItemType;
|
|
160
|
+
}
|
|
146
161
|
export interface OperatorRewriteLogicformContext {
|
|
147
162
|
readonly logicform: LogicformType;
|
|
148
163
|
readonly schema: ResolvedSemanticSchema;
|
|
@@ -158,6 +173,10 @@ export interface OperatorComponentContext {
|
|
|
158
173
|
readonly pred: PredItemType;
|
|
159
174
|
/** Final output alias assigned by the planner. */
|
|
160
175
|
readonly outputName: string;
|
|
176
|
+
/** Requested locale for child component names. */
|
|
177
|
+
readonly locale: string;
|
|
178
|
+
/** Translate a stable message key using the requested locale. */
|
|
179
|
+
readonly t: LocaleTranslate;
|
|
161
180
|
readonly schema: ResolvedSemanticSchema;
|
|
162
181
|
/** Resolve Schemas referenced by object relation paths used by this component. */
|
|
163
182
|
readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
|
|
@@ -179,27 +198,27 @@ export interface OperatorQueryComponent {
|
|
|
179
198
|
readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
|
|
180
199
|
}
|
|
181
200
|
export interface OperatorComponentQuery {
|
|
201
|
+
/** Final result-column name for this child component. */
|
|
182
202
|
readonly name: string;
|
|
183
203
|
readonly logicform: LogicformType;
|
|
184
204
|
readonly prepare?: boolean;
|
|
185
205
|
readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
|
|
186
206
|
readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
|
|
187
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* Group output names used to join this component back to the first component.
|
|
209
|
+
* When omitted, the compiler joins on the groupby outputs shared by both components.
|
|
210
|
+
*/
|
|
188
211
|
readonly joinKeys?: readonly string[];
|
|
189
212
|
}
|
|
190
213
|
export interface OperatorComponentCalculation {
|
|
191
214
|
readonly components: readonly OperatorComponentQuery[];
|
|
192
215
|
/** Provider-independent formula referring to component names. */
|
|
193
216
|
readonly expression: string;
|
|
194
|
-
readonly outputName?: string;
|
|
195
|
-
readonly exposeComponents?: boolean;
|
|
196
217
|
}
|
|
197
218
|
export interface OperatorJavaScriptCalculation {
|
|
198
219
|
readonly kind: 'js';
|
|
199
220
|
readonly components: readonly OperatorComponentQuery[];
|
|
200
|
-
readonly outputName: string;
|
|
201
221
|
readonly mergeRow: (values: DataRow) => unknown;
|
|
202
|
-
readonly exposeComponents?: boolean;
|
|
203
222
|
}
|
|
204
223
|
export type OperatorExecutionComponent = OperatorQueryComponent | OperatorComponentCalculation | OperatorJavaScriptCalculation;
|
|
205
224
|
/**
|
|
@@ -213,8 +232,23 @@ export type OperatorExecutionComponent = OperatorQueryComponent | OperatorCompon
|
|
|
213
232
|
interface OperatorDefinitionBase {
|
|
214
233
|
/** Public registry key. Built-in operators commonly use a `$` prefix, but it is not required. */
|
|
215
234
|
readonly name: string;
|
|
235
|
+
/** Description of the computed metric, exposed on its result Property. */
|
|
236
|
+
readonly description?: string;
|
|
216
237
|
/** Produce the normalized output name when the PredItem does not declare one. */
|
|
217
238
|
readonly defaultName: (context: OperatorDefaultNameContext) => string;
|
|
239
|
+
/** Translation key for the generated name. Defaults to `operator.${name}`. */
|
|
240
|
+
readonly defaultNameKey?: string | ((context: OperatorDefaultNameContext) => string);
|
|
241
|
+
/** defaultName already used the translator and must not be translated a second time. */
|
|
242
|
+
readonly defaultNameIsLocalized?: boolean;
|
|
243
|
+
/** A grouped physical source may safely apply this operator again to stored partial results. */
|
|
244
|
+
readonly supportsGroupedSourceRollup?: boolean;
|
|
245
|
+
/** This computed operator preserves a grouped physical source's dimension semantics. */
|
|
246
|
+
readonly supportsGroupedSourceGroupby?: boolean;
|
|
247
|
+
/** Requested time grain of a grouped dimension, when this is a time grouping operator. */
|
|
248
|
+
readonly groupedSourceTimeGranularity?: (context: {
|
|
249
|
+
readonly pred: PredItemType;
|
|
250
|
+
readonly property: ResolvedSemanticProperty;
|
|
251
|
+
}) => TimeGranularity | undefined;
|
|
218
252
|
/** Logical property names read in addition to the direct input property. */
|
|
219
253
|
readonly dependencies?: readonly string[];
|
|
220
254
|
/** Set to false for operators such as `$count` that do not require a property. */
|
|
@@ -227,10 +261,16 @@ interface OperatorDefinitionBase {
|
|
|
227
261
|
readonly normalizePred?: (context: OperatorNormalizePredContext) => PredItemType;
|
|
228
262
|
/** Build a provider-independent expression for operators with custom planning semantics. */
|
|
229
263
|
readonly planExpression?: (context: OperatorPlanExpressionContext) => Expression | undefined;
|
|
230
|
-
/**
|
|
231
|
-
readonly
|
|
264
|
+
/** Describe how this operator selects a value at a generated period boundary. */
|
|
265
|
+
readonly periodBoundaryPolicy?: (context: OperatorPeriodBoundaryPolicyContext) => OperatorPeriodBoundaryPolicy | undefined;
|
|
232
266
|
/** Validate this operator against the completed group key set. */
|
|
233
267
|
readonly validatePlan?: (context: OperatorValidatePlanContext) => void;
|
|
268
|
+
/** Validate semantics that apply only when this Operator is used as a group key. */
|
|
269
|
+
readonly validateGroupby?: (context: OperatorValidateGroupbyContext) => void;
|
|
270
|
+
/** The logical planner may fully lower a component, so no executor child query is needed. */
|
|
271
|
+
readonly skipComponentExecution?: (context: {
|
|
272
|
+
readonly plan: LogicalPlan;
|
|
273
|
+
}) => boolean;
|
|
234
274
|
/** Expand high-level operator semantics into ordinary nested LogicForm objects before planning. */
|
|
235
275
|
readonly rewriteLogicform?: (context: OperatorRewriteLogicformContext) => LogicformType | undefined;
|
|
236
276
|
/** Whether this operator requires one evaluation per time bucket. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
2
2
|
interface ClickHouseResultLike {
|
|
3
3
|
json<T>(): Promise<T>;
|
|
4
4
|
}
|
|
@@ -12,15 +12,23 @@ export interface ClickHouseClientLike {
|
|
|
12
12
|
close(): Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export interface ClickHouseProviderOptions {
|
|
15
|
+
/** Full HTTP endpoint. Takes precedence over host and port. */
|
|
15
16
|
readonly url?: string;
|
|
17
|
+
/** Host-style connection fields accepted by the shared datasource contract. */
|
|
18
|
+
readonly host?: string;
|
|
19
|
+
readonly port?: number;
|
|
16
20
|
readonly username?: string;
|
|
21
|
+
/** Alias used by the shared datasource contract. username takes precedence. */
|
|
22
|
+
readonly user?: string;
|
|
17
23
|
readonly password?: string;
|
|
18
24
|
readonly database?: string;
|
|
19
25
|
readonly client?: ClickHouseClientLike;
|
|
20
26
|
}
|
|
21
27
|
export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
28
|
+
#private;
|
|
22
29
|
readonly kind: "clickhouse";
|
|
23
|
-
|
|
30
|
+
readonly supportsRecursiveCte = true;
|
|
31
|
+
readonly recursiveCteUnion: "UNION ALL";
|
|
24
32
|
constructor(options?: ClickHouseProviderOptions);
|
|
25
33
|
quoteIdentifier(identifier: string): string;
|
|
26
34
|
tableAlias(expression: string, alias: string): string;
|
|
@@ -28,11 +36,15 @@ export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
|
28
36
|
parameter(index: number, value: unknown): string;
|
|
29
37
|
displayQuery(sql: string, parameters: readonly unknown[]): string;
|
|
30
38
|
dateBucket(expression: string, level: string): string;
|
|
39
|
+
datePart(expression: string, part: DatePart): string;
|
|
31
40
|
dateShift(expression: string, granularity: string, offset: number): string;
|
|
41
|
+
castValue(expression: string, type: string): string;
|
|
42
|
+
scalarExtremum(operator: 'least' | 'greatest', expressions: readonly string[]): string;
|
|
32
43
|
aggregateFunction(name: string, expression?: string): string;
|
|
33
44
|
stringify(expression: string): string;
|
|
34
45
|
concat(expressions: readonly string[]): string;
|
|
35
46
|
substring(expression: string, start: number, length: number): string;
|
|
47
|
+
stringLength(expression: string): string;
|
|
36
48
|
regex(expression: string, pattern: string, options?: string): string;
|
|
37
49
|
arrayContains(arrayExpression: string, valueExpression: string): string;
|
|
38
50
|
expandArray(arrayExpression: string, alias: string, column: string): {
|
|
@@ -1,32 +1,74 @@
|
|
|
1
1
|
import type { CoreComputeProvider } from './provider';
|
|
2
2
|
import type { ClickHouseProviderOptions } from './clickhouse-provider';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import type { DatabricksConnectionOptions } from './databricks-provider';
|
|
4
|
+
import type { DamengConnectionOptions } from './dameng-provider';
|
|
5
|
+
import type { DorisConnectionOptions } from './doris-provider';
|
|
6
|
+
import type { GBaseConnectionOptions } from './gbase-provider';
|
|
7
|
+
import type { MaxComputeConnectionOptions } from './maxcompute-provider';
|
|
8
|
+
import type { MySQLConnectionOptions } from './mysql-provider';
|
|
9
|
+
import type { OracleConnectionOptions } from './oracle-provider';
|
|
10
|
+
import type { PostgreSQLConnectionOptions } from './postgresql-provider';
|
|
11
|
+
import type { SnowflakeConnectionOptions } from './snowflake-provider';
|
|
12
|
+
import type { SQLServerConnectionOptions } from './sqlserver-provider';
|
|
13
|
+
import type { StarRocksConnectionOptions } from './starrocks-provider';
|
|
14
|
+
export interface DatabaseConnectionBase {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly kind: string;
|
|
17
|
+
}
|
|
18
|
+
/** Module-augmentation seam for application-owned connection kinds. */
|
|
19
|
+
export interface DatabaseConnectionExtensions {
|
|
20
|
+
}
|
|
21
|
+
export type BuiltinDatabaseConnection = ({
|
|
11
22
|
readonly id: string;
|
|
12
23
|
readonly kind: 'mysql';
|
|
13
|
-
} &
|
|
24
|
+
} & MySQLConnectionOptions) | ({
|
|
14
25
|
readonly id: string;
|
|
15
26
|
readonly kind: 'doris';
|
|
16
|
-
} &
|
|
27
|
+
} & DorisConnectionOptions) | ({
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly kind: 'gbase';
|
|
30
|
+
} & GBaseConnectionOptions) | ({
|
|
17
31
|
readonly id: string;
|
|
18
32
|
readonly kind: 'starrocks';
|
|
19
|
-
} &
|
|
33
|
+
} & StarRocksConnectionOptions) | ({
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly kind: 'maxcompute';
|
|
36
|
+
} & MaxComputeConnectionOptions) | ({
|
|
20
37
|
readonly id: string;
|
|
21
38
|
readonly kind: 'postgresql';
|
|
22
|
-
} &
|
|
39
|
+
} & PostgreSQLConnectionOptions) | ({
|
|
23
40
|
readonly id: string;
|
|
24
41
|
readonly kind: 'clickhouse';
|
|
25
42
|
} & Omit<ClickHouseProviderOptions, 'client'>) | ({
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly kind: 'databricks';
|
|
45
|
+
} & DatabricksConnectionOptions) | ({
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly kind: 'dameng';
|
|
48
|
+
} & DamengConnectionOptions) | ({
|
|
26
49
|
readonly id: string;
|
|
27
50
|
readonly kind: 'snowflake';
|
|
28
|
-
} &
|
|
51
|
+
} & SnowflakeConnectionOptions) | ({
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly kind: 'sqlserver';
|
|
54
|
+
} & SQLServerConnectionOptions) | ({
|
|
29
55
|
readonly id: string;
|
|
30
56
|
readonly kind: 'oracle';
|
|
31
|
-
} &
|
|
32
|
-
|
|
57
|
+
} & OracleConnectionOptions);
|
|
58
|
+
type ExtendedDatabaseConnection = DatabaseConnectionExtensions[keyof DatabaseConnectionExtensions];
|
|
59
|
+
export type DatabaseConnection = BuiltinDatabaseConnection | ExtendedDatabaseConnection;
|
|
60
|
+
export interface ProviderDefinition<Connection extends DatabaseConnectionBase = DatabaseConnectionBase> {
|
|
61
|
+
readonly kind: Connection['kind'];
|
|
62
|
+
readonly create: (connection: Connection) => CoreComputeProvider;
|
|
63
|
+
}
|
|
64
|
+
export declare const builtinProviderDefinitions: readonly ProviderDefinition[];
|
|
65
|
+
export declare class ProviderRegistry {
|
|
66
|
+
#private;
|
|
67
|
+
constructor(definitions?: readonly ProviderDefinition[]);
|
|
68
|
+
register<Connection extends DatabaseConnectionBase>(definition: ProviderDefinition<Connection>): this;
|
|
69
|
+
create(connection: DatabaseConnectionBase): CoreComputeProvider;
|
|
70
|
+
has(kind: string): boolean;
|
|
71
|
+
}
|
|
72
|
+
export declare const defaultProviderRegistry: ProviderRegistry;
|
|
73
|
+
export declare const createProvider: (connection: DatabaseConnection, providers?: ProviderRegistry) => CoreComputeProvider;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest } from './provider';
|
|
2
|
+
type DamengBind = string | number | Date | Buffer | null;
|
|
3
|
+
export interface DamengConnectionOptions {
|
|
4
|
+
readonly connectString?: string;
|
|
5
|
+
readonly host?: string;
|
|
6
|
+
readonly port?: number;
|
|
7
|
+
readonly user?: string;
|
|
8
|
+
readonly password?: string;
|
|
9
|
+
readonly schema?: string;
|
|
10
|
+
readonly poolMin?: number;
|
|
11
|
+
readonly poolMax?: number;
|
|
12
|
+
readonly poolTimeout?: number;
|
|
13
|
+
readonly [option: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface DamengConnectionLike {
|
|
16
|
+
execute(sql: string, binds: DamengBind[], options: {
|
|
17
|
+
readonly outFormat: number;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
readonly rows?: unknown[];
|
|
20
|
+
}>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface DamengPoolLike {
|
|
24
|
+
getConnection(): Promise<DamengConnectionLike>;
|
|
25
|
+
close(drainTime?: number): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export interface DamengDriverLike {
|
|
28
|
+
createPool(options: DamengPoolOptions): Promise<DamengPoolLike>;
|
|
29
|
+
}
|
|
30
|
+
export interface DamengPoolOptions extends Omit<DamengConnectionOptions, 'host' | 'port'> {
|
|
31
|
+
readonly connectString: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DamengProviderOptions {
|
|
34
|
+
readonly connection?: DamengConnectionOptions;
|
|
35
|
+
readonly pool?: DamengPoolLike;
|
|
36
|
+
readonly driver?: DamengDriverLike;
|
|
37
|
+
}
|
|
38
|
+
export declare const damengPoolOptions: (options: DamengConnectionOptions) => DamengPoolOptions;
|
|
39
|
+
export declare class DamengProvider implements CoreComputeProvider {
|
|
40
|
+
#private;
|
|
41
|
+
readonly kind: "dameng";
|
|
42
|
+
readonly supportsHavingAlias = false;
|
|
43
|
+
constructor(options?: DamengProviderOptions);
|
|
44
|
+
quoteIdentifier(identifier: string): string;
|
|
45
|
+
tableAlias(expression: string, alias: string): string;
|
|
46
|
+
paginate(sql: string, pageSize: number, offset: number): string;
|
|
47
|
+
parameter(index: number, value: unknown): string;
|
|
48
|
+
displayQuery(sql: string, parameters: readonly unknown[]): string;
|
|
49
|
+
dateBucket(expression: string, level: string): string;
|
|
50
|
+
datePart(expression: string, part: DatePart): string;
|
|
51
|
+
dateShift(expression: string, granularity: string, offset: number): string;
|
|
52
|
+
aggregateFunction(name: string, expression?: string): string;
|
|
53
|
+
stringify(expression: string): string;
|
|
54
|
+
concat(expressions: readonly string[]): string;
|
|
55
|
+
substring(expression: string, start: number, length: number): string;
|
|
56
|
+
stringLength(expression: string): string;
|
|
57
|
+
regex(expression: string, pattern: string, options?: string): string;
|
|
58
|
+
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
59
|
+
close(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export {};
|