semanticdb-v2 2.0.0-alpha.1 → 2.0.0-alpha.10
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 +346 -46
- package/dist/cache/index.d.ts +2 -1
- package/dist/cache/manager.d.ts +5 -0
- package/dist/cache/registry.d.ts +14 -0
- package/dist/cache/types.d.ts +17 -0
- package/dist/close.d.ts +1 -0
- package/dist/compatibility/index.d.ts +2 -2
- package/dist/compatibility/logicform.d.ts +1 -7
- package/dist/compiler/compile-cte.d.ts +17 -2
- package/dist/compiler/index.d.ts +2 -1
- package/dist/compiler/shorten-sql.d.ts +1 -1
- package/dist/errors.d.ts +3 -0
- package/dist/executor/compatibility.d.ts +13 -0
- package/dist/executor/components.d.ts +8 -3
- package/dist/executor/connection-registry.d.ts +1 -12
- package/dist/executor/execute-query.d.ts +8 -2
- package/dist/executor/federated-execution.d.ts +38 -0
- package/dist/executor/fetch-entities.d.ts +7 -1
- package/dist/executor/index.d.ts +1 -1
- package/dist/executor/result-hydrator/types.d.ts +2 -0
- package/dist/executor/row-identity.d.ts +2 -1
- package/dist/executor/total.d.ts +11 -0
- package/dist/executor/types.d.ts +64 -19
- 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 +16 -16
- package/dist/logicform-types.d.ts +56 -36
- package/dist/normalizer/core.d.ts +16 -2
- 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 +6 -0
- package/dist/operators/builtins/constant.d.ts +2 -0
- package/dist/operators/builtins/period-name.d.ts +2 -1
- package/dist/operators/builtins/period-value.d.ts +2 -0
- package/dist/operators/builtins/query-expression.d.ts +3 -0
- package/dist/operators/builtins/scalar-extremum.d.ts +3 -0
- package/dist/operators/index.d.ts +2 -1
- package/dist/operators/registry.d.ts +5 -3
- package/dist/operators/resolve.d.ts +3 -0
- package/dist/operators/types.d.ts +102 -49
- package/dist/physical/clickhouse-provider.d.ts +29 -2
- package/dist/physical/connection-registry.d.ts +13 -0
- package/dist/physical/connection.d.ts +57 -15
- package/dist/physical/dameng-provider.d.ts +66 -0
- package/dist/physical/databricks-provider.d.ts +88 -0
- package/dist/physical/db-connector.d.ts +23 -0
- package/dist/physical/display-query.d.ts +3 -0
- package/dist/physical/doris-provider.d.ts +7 -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 +24 -9
- package/dist/physical/load-driver.d.ts +1 -0
- package/dist/physical/maxcompute-provider.d.ts +44 -0
- package/dist/physical/mysql-protocol-provider.d.ts +27 -7
- package/dist/physical/mysql-provider.d.ts +2 -1
- package/dist/physical/oracle-provider.d.ts +21 -4
- package/dist/physical/postgresql-provider.d.ts +25 -4
- package/dist/physical/provider.d.ts +66 -2
- package/dist/physical/snowflake-provider.d.ts +20 -3
- package/dist/physical/sqlserver-provider.d.ts +69 -0
- package/dist/physical/starrocks-provider.d.ts +7 -1
- package/dist/physical/table-description.d.ts +5 -0
- package/dist/physical/table-discovery.d.ts +10 -0
- 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/semantics/registry.d.ts +2 -1
- package/dist/planner/types.d.ts +94 -14
- 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 +20 -2
- 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 +4 -5
- package/dist/plugins/observation/periods.d.ts +18 -0
- package/dist/{planner/semantics → plugins}/observation/rule.d.ts +1 -1
- package/dist/plugins/observation/types.d.ts +3 -0
- 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/entity-identity.d.ts +1 -1
- 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 +4 -1
- package/dist/schema-mappings/registry.d.ts +6 -3
- package/dist/schema-mappings/types.d.ts +52 -8
- package/dist/schema-mappings/yiask.d.ts +26 -0
- package/dist/semantic-types/builtins/tag.d.ts +2 -0
- 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 +22 -10
- package/dist/semantic-types/validate-resolved-schema.d.ts +2 -5
- package/dist/semanticdb.esm.js +5 -0
- package/dist/semanticdb.js +5 -0
- package/package.json +49 -17
- package/dist/cache/expiry.js +0 -1
- package/dist/cache/identity.js +0 -1
- package/dist/cache/redis-query-cache.js +0 -1
- package/dist/cache/serialization.js +0 -1
- package/dist/calendar/constants.d.ts +0 -7
- package/dist/calendar/constants.js +0 -1
- package/dist/calendar/index.d.ts +0 -6
- package/dist/calendar/provider-relation-store.d.ts +0 -9
- package/dist/calendar/provider-relation-store.js +0 -1
- package/dist/calendar/resolver.d.ts +0 -10
- package/dist/calendar/resolver.js +0 -1
- package/dist/calendar/system-schemas.d.ts +0 -3
- package/dist/calendar/system-schemas.js +0 -1
- package/dist/calendar/types.d.ts +0 -31
- package/dist/compatibility/logicform.js +0 -1
- package/dist/compiler/compile-cte.js +0 -1
- package/dist/compiler/compile-plan.js +0 -1
- package/dist/compiler/shorten-sql.js +0 -2
- package/dist/custom-functions/custom-functions.d.ts +0 -6
- package/dist/custom-functions/custom-functions.js +0 -1
- package/dist/custom-functions/index.d.ts +0 -3
- package/dist/custom-functions/operator-adapter.d.ts +0 -12
- package/dist/custom-functions/operator-adapter.js +0 -1
- package/dist/custom-functions/types.d.ts +0 -62
- package/dist/errors.js +0 -1
- package/dist/executor/compatibility.js +0 -1
- package/dist/executor/components.js +0 -1
- package/dist/executor/connection-registry.js +0 -1
- package/dist/executor/evaluate.js +0 -1
- package/dist/executor/execute-query.js +0 -1
- package/dist/executor/execute.js +0 -1
- package/dist/executor/fetch-entities.js +0 -1
- package/dist/executor/result-hydrator/entity-loader.js +0 -1
- package/dist/executor/result-hydrator/format-values.js +0 -1
- package/dist/executor/result-hydrator/hydrate-result.js +0 -1
- package/dist/executor/result-hydrator/missing-entity.js +0 -1
- package/dist/executor/result-hydrator/populate-entities.js +0 -1
- package/dist/executor/row-identity.js +0 -1
- package/dist/index.js +0 -1
- package/dist/logicform-types.js +0 -1
- package/dist/normalizer/core.js +0 -1
- package/dist/normalizer/default-pred-name.js +0 -1
- package/dist/normalizer/entity-id.js +0 -1
- package/dist/normalizer/groupby.js +0 -1
- package/dist/normalizer/normalize-logicform.js +0 -1
- package/dist/normalizer/pagination.js +0 -1
- package/dist/normalizer/pred-query-name.js +0 -1
- package/dist/normalizer/preds.js +0 -1
- package/dist/normalizer/query.js +0 -1
- package/dist/normalizer/version.js +0 -1
- package/dist/operators/builtins/abs.js +0 -1
- package/dist/operators/builtins/accumulate.js +0 -1
- package/dist/operators/builtins/add.js +0 -1
- package/dist/operators/builtins/arithmetic.js +0 -1
- package/dist/operators/builtins/average-per-period.js +0 -1
- package/dist/operators/builtins/avg.js +0 -1
- package/dist/operators/builtins/case.js +0 -1
- package/dist/operators/builtins/concat.js +0 -1
- package/dist/operators/builtins/count-distinct.js +0 -1
- package/dist/operators/builtins/count.js +0 -1
- package/dist/operators/builtins/date-bucket.js +0 -1
- package/dist/operators/builtins/divide.js +0 -1
- package/dist/operators/builtins/index.js +0 -1
- package/dist/operators/builtins/max.js +0 -1
- package/dist/operators/builtins/min.js +0 -1
- package/dist/operators/builtins/multiply.js +0 -1
- package/dist/operators/builtins/newly.js +0 -1
- package/dist/operators/builtins/period-boundary.js +0 -1
- package/dist/operators/builtins/period-difference.js +0 -1
- package/dist/operators/builtins/period-growth.js +0 -1
- package/dist/operators/builtins/period-name.js +0 -1
- package/dist/operators/builtins/period-shift.js +0 -1
- package/dist/operators/builtins/rank.js +0 -1
- package/dist/operators/builtins/row-number.js +0 -1
- package/dist/operators/builtins/share-of-total.js +0 -1
- package/dist/operators/builtins/sql.js +0 -1
- package/dist/operators/builtins/substring.js +0 -1
- package/dist/operators/builtins/subtract.js +0 -1
- package/dist/operators/builtins/sum.js +0 -1
- package/dist/operators/builtins/time-range.js +0 -1
- package/dist/operators/groupby.js +0 -1
- package/dist/operators/index.js +0 -1
- package/dist/operators/registry.js +0 -1
- package/dist/operators/sql-expression.js +0 -1
- package/dist/permissions/permissions.js +0 -1
- package/dist/physical/clickhouse-provider.js +0 -1
- package/dist/physical/connection.js +0 -1
- package/dist/physical/display-query.js +0 -1
- package/dist/physical/doris-provider.js +0 -1
- package/dist/physical/mysql-compatible-sql.js +0 -1
- package/dist/physical/mysql-protocol-provider.js +0 -1
- package/dist/physical/mysql-provider.js +0 -1
- package/dist/physical/oracle-provider.js +0 -1
- package/dist/physical/postgresql-provider.js +0 -1
- package/dist/physical/snowflake-provider.js +0 -1
- package/dist/physical/starrocks-provider.js +0 -1
- package/dist/planner/build-lineage.js +0 -1
- package/dist/planner/create-logical-plan.js +0 -1
- package/dist/planner/select-schema-mapping.js +0 -1
- package/dist/planner/semantics/lifecycle/classification.d.ts +0 -7
- package/dist/planner/semantics/lifecycle/classification.js +0 -1
- 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/query-policy.js +0 -1
- package/dist/planner/semantics/lifecycle/rule.d.ts +0 -2
- package/dist/planner/semantics/lifecycle/rule.js +0 -1
- package/dist/planner/semantics/observation/classification.js +0 -1
- package/dist/planner/semantics/observation/index.d.ts +0 -4
- package/dist/planner/semantics/observation/operator-policy.js +0 -1
- package/dist/planner/semantics/observation/rule.js +0 -1
- package/dist/planner/semantics/observation/types.d.ts +0 -3
- package/dist/planner/semantics/registry-defaults.js +0 -1
- package/dist/planner/semantics/registry.js +0 -1
- package/dist/planner/types.js +0 -1
- package/dist/plugins/hierarchy/compatibility.js +0 -1
- package/dist/plugins/hierarchy/entity-identity.js +0 -1
- package/dist/plugins/hierarchy/index.js +0 -1
- package/dist/plugins/hierarchy/operator.js +0 -1
- package/dist/plugins/hierarchy/resolve-schema.js +0 -1
- package/dist/plugins/index.js +0 -1
- package/dist/schema/entity-identity.js +0 -1
- package/dist/schema/resolve-property-path.js +0 -1
- package/dist/schema/schema-registry.js +0 -1
- package/dist/schema-mappings/freshness.js +0 -1
- package/dist/schema-mappings/registry.js +0 -1
- package/dist/semantic-types/builtins/boolean.js +0 -1
- package/dist/semantic-types/builtins/category.js +0 -1
- package/dist/semantic-types/builtins/currency.js +0 -1
- package/dist/semantic-types/builtins/date.js +0 -1
- package/dist/semantic-types/builtins/duration.js +0 -1
- package/dist/semantic-types/builtins/end-date.d.ts +0 -2
- package/dist/semantic-types/builtins/end-date.js +0 -1
- package/dist/semantic-types/builtins/entity.js +0 -1
- package/dist/semantic-types/builtins/file.js +0 -1
- package/dist/semantic-types/builtins/human-name.js +0 -1
- package/dist/semantic-types/builtins/id.js +0 -1
- package/dist/semantic-types/builtins/image.js +0 -1
- package/dist/semantic-types/builtins/index.js +0 -1
- package/dist/semantic-types/builtins/int.js +0 -1
- package/dist/semantic-types/builtins/name.js +0 -1
- package/dist/semantic-types/builtins/number.js +0 -1
- package/dist/semantic-types/builtins/object.js +0 -1
- package/dist/semantic-types/builtins/order.js +0 -1
- package/dist/semantic-types/builtins/percentage.js +0 -1
- package/dist/semantic-types/builtins/start-date.d.ts +0 -2
- package/dist/semantic-types/builtins/start-date.js +0 -1
- package/dist/semantic-types/builtins/string.js +0 -1
- package/dist/semantic-types/builtins/timestamp.js +0 -1
- package/dist/semantic-types/index.js +0 -1
- package/dist/semantic-types/primal-types/date.js +0 -1
- package/dist/semantic-types/primal-types/index.js +0 -1
- package/dist/semantic-types/registry.js +0 -1
- package/dist/semantic-types/resolve-schema.js +0 -1
- package/dist/semantic-types/validate-resolved-schema.js +0 -1
- package/dist/utils/clone.js +0 -1
- /package/dist/operators/builtins/{period-boundary.d.ts → period-boundary-expression.d.ts} +0 -0
|
@@ -2,18 +2,32 @@ 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
|
-
readonly
|
|
18
|
+
readonly requestTimeWatermark?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty, requestedUpperBound: Date) => Promise<Date | undefined>;
|
|
19
|
+
readonly requestAutoCaseBounds?: (schema: ResolvedSemanticSchema, reference: string, query: LogicformType['query']) => Promise<{
|
|
20
|
+
readonly min: number;
|
|
21
|
+
readonly max: number;
|
|
22
|
+
readonly count: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly empty: true;
|
|
25
|
+
}>;
|
|
26
|
+
/** Internal root query used to resolve automatic `$case` boundaries. */
|
|
27
|
+
readonly autoCaseQuery?: LogicformType['query'];
|
|
14
28
|
readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
|
|
15
29
|
readonly canProjectProperty?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => boolean;
|
|
16
30
|
/** Internal recursion hook installed by normalizeLogicform. */
|
|
17
31
|
readonly normalizeNestedLogicform?: (logicform: LogicformType) => Promise<LogicformType>;
|
|
18
32
|
}
|
|
19
|
-
export declare const
|
|
33
|
+
export declare const resolveFormSchema: (logicform: LogicformType, currentSchema: ResolvedSemanticSchema, options: NormalizeLogicformOptions) => ResolvedSemanticSchema;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogicformType } from '../logicform-types';
|
|
2
|
+
import type { ResolvedSemanticSchema } from '../semantic-types/index';
|
|
3
|
+
import type { NormalizeLogicformOptions } from './core';
|
|
4
|
+
export declare const inferPropertyResolvePath: (rootSchema: ResolvedSemanticSchema, reference: string, targetSchema: ResolvedSemanticSchema, resolveSchema?: (schemaId: string) => ResolvedSemanticSchema) => string | undefined;
|
|
5
|
+
/** Adds cross-Schema aliases after both legacy and v2 forms share normalization. */
|
|
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,
|
|
6
|
+
export type { OperatorDefinition, OperatorDefaultNameContext, OperatorExecutionContext, 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;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { OperatorDefinition, OperatorPeriodEvaluationContext } from './types';
|
|
1
|
+
import type { OperatorDefinition, OperatorExecutionContext, OperatorPeriodEvaluationContext } from './types';
|
|
2
2
|
export declare class OperatorRegistry {
|
|
3
3
|
#private;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
readonly executionContext: OperatorExecutionContext;
|
|
5
|
+
constructor(definitions?: readonly OperatorDefinition[], executionContext?: OperatorExecutionContext);
|
|
6
|
+
withExecutionContext(executionContext: OperatorExecutionContext): OperatorRegistry;
|
|
7
|
+
register(input: OperatorDefinition): this;
|
|
6
8
|
get(name: string): OperatorDefinition;
|
|
7
9
|
requiresPerPeriodEvaluation(name: string, context: OperatorPeriodEvaluationContext): boolean;
|
|
8
10
|
has(name: string): boolean;
|
|
@@ -1,7 +1,17 @@
|
|
|
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';
|
|
6
|
+
/** Immutable data shared by all Operator hooks during one LogicForm execution. */
|
|
7
|
+
export interface OperatorExecutionContext {
|
|
8
|
+
/** Complete rows from the unique Schema marked with `is_calendar`. */
|
|
9
|
+
readonly calendar?: readonly Readonly<DataRow>[];
|
|
10
|
+
}
|
|
11
|
+
interface OperatorHookContext {
|
|
12
|
+
/** Always supplied by the executor; optional for direct unit-level hook invocation. */
|
|
13
|
+
readonly executionContext?: OperatorExecutionContext;
|
|
14
|
+
}
|
|
5
15
|
export interface OperatorSqlCapabilities {
|
|
6
16
|
/** Produce a dialect-specific aggregate function around an expression. */
|
|
7
17
|
aggregateFunction(name: string, expression?: string): string;
|
|
@@ -9,18 +19,25 @@ export interface OperatorSqlCapabilities {
|
|
|
9
19
|
quoteIdentifier(identifier: string): string;
|
|
10
20
|
concat(expressions: readonly string[]): string;
|
|
11
21
|
substring(expression: string, start: number, length: number): string;
|
|
22
|
+
stringLength(expression: string): string;
|
|
23
|
+
datePart(expression: string, part: 'second' | 'minute' | 'hour' | 'weekday' | 'day' | 'week' | 'month' | 'quarter' | 'year'): string;
|
|
12
24
|
dateBucket(expression: string, granularity: TimeGranularity): string;
|
|
25
|
+
dateShift(expression: string, granularity: TimeGranularity, offset: number): string;
|
|
26
|
+
/** Render a period boundary directly when the dialect has a concise native form. */
|
|
27
|
+
datePeriodBoundary?(expression: string, granularity: TimeGranularity, boundary: 'start' | 'end'): string;
|
|
28
|
+
/** Render a NULL-ignoring scalar extremum using a dialect-native expression. */
|
|
29
|
+
scalarExtremum?(operator: 'least' | 'greatest', expressions: readonly string[]): string;
|
|
13
30
|
/** Bind a literal as a SQL parameter. */
|
|
14
|
-
value(value: unknown): string;
|
|
31
|
+
value(value: unknown, type?: string): string;
|
|
15
32
|
/** Compile a field-local LogicForm condition against an expression. */
|
|
16
33
|
condition(expression: string, condition: unknown): string;
|
|
17
34
|
}
|
|
18
35
|
/** Context passed to an operator that pushes its computation into SQL. */
|
|
19
|
-
export interface OperatorSqlContext {
|
|
36
|
+
export interface OperatorSqlContext extends OperatorHookContext {
|
|
20
37
|
readonly sql: OperatorSqlCapabilities;
|
|
21
38
|
/** SQL for the nested input expression, when this operator has one. */
|
|
22
39
|
readonly expression?: string;
|
|
23
|
-
/** SQL expressions produced by a multi-input
|
|
40
|
+
/** SQL expressions produced by a multi-input pred. */
|
|
24
41
|
readonly expressions?: readonly string[];
|
|
25
42
|
/** Quoted physical column for a leaf-property operator. */
|
|
26
43
|
readonly column?: string;
|
|
@@ -28,7 +45,7 @@ export interface OperatorSqlContext {
|
|
|
28
45
|
readonly args: Readonly<Record<string, unknown>>;
|
|
29
46
|
}
|
|
30
47
|
/** Context passed to an operator evaluated after the provider returns rows. */
|
|
31
|
-
export interface OperatorEvaluateContext {
|
|
48
|
+
export interface OperatorEvaluateContext extends OperatorHookContext {
|
|
32
49
|
/** Value produced by the nested expression, or undefined for a propertyless operator. */
|
|
33
50
|
readonly input: unknown;
|
|
34
51
|
/** Operator-specific LogicForm arguments. */
|
|
@@ -40,6 +57,8 @@ export interface ResultProperty {
|
|
|
40
57
|
readonly type: string;
|
|
41
58
|
readonly primal_type: PrimalType;
|
|
42
59
|
readonly isArray: boolean;
|
|
60
|
+
/** Description inherited from the source Property or supplied by the operator. */
|
|
61
|
+
readonly description?: string;
|
|
43
62
|
/** Referenced Schema for object-valued result columns. */
|
|
44
63
|
readonly ref?: string;
|
|
45
64
|
readonly granularity?: TimeGranularity;
|
|
@@ -47,8 +66,11 @@ export interface ResultProperty {
|
|
|
47
66
|
/** Runtime temporal semantics for this output column, when applicable. */
|
|
48
67
|
readonly temporal?: ResultPropertyTemporalMetadata;
|
|
49
68
|
}
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
/** Plugin-owned result temporal metadata extends this interface by key. */
|
|
70
|
+
export interface ResultPropertyTemporalMetadataExtensions {
|
|
71
|
+
}
|
|
72
|
+
export type ResultPropertyTemporalMetadata = {
|
|
73
|
+
readonly kind: 'period-boundary' | 'period-shift' | 'date-bucket';
|
|
52
74
|
readonly boundary?: 'start' | 'end';
|
|
53
75
|
readonly sourceProperty?: string;
|
|
54
76
|
readonly requestedRange?: {
|
|
@@ -68,39 +90,41 @@ export interface ResultPropertyTemporalMetadata {
|
|
|
68
90
|
readonly group: Readonly<Record<string, unknown>>;
|
|
69
91
|
readonly date: string;
|
|
70
92
|
}[];
|
|
71
|
-
}
|
|
72
|
-
export interface OperatorOutputPropertyContext {
|
|
93
|
+
} | ResultPropertyTemporalMetadataExtensions[keyof ResultPropertyTemporalMetadataExtensions];
|
|
94
|
+
export interface OperatorOutputPropertyContext extends OperatorHookContext {
|
|
73
95
|
/** Final alias assigned to this operator's single output column. */
|
|
74
96
|
readonly name: string;
|
|
75
97
|
/** Original Schema property when the operator starts from a physical property. */
|
|
76
98
|
readonly property?: ResolvedSemanticProperty;
|
|
77
99
|
/** Semantic metadata produced by a nested expression. */
|
|
78
100
|
readonly inputProperty?: ResultProperty;
|
|
79
|
-
/** Semantic metadata produced by
|
|
80
|
-
readonly
|
|
101
|
+
/** Semantic metadata produced by a multi-input pred. */
|
|
102
|
+
readonly inputProperties?: readonly ResultProperty[];
|
|
81
103
|
/** Operator-specific LogicForm arguments. */
|
|
82
104
|
readonly args: Readonly<Record<string, unknown>>;
|
|
83
105
|
}
|
|
84
106
|
/** Context used by operators whose value must be evaluated per time bucket. */
|
|
85
|
-
export interface OperatorPeriodEvaluationContext {
|
|
107
|
+
export interface OperatorPeriodEvaluationContext extends OperatorHookContext {
|
|
86
108
|
readonly logicform: LogicformType;
|
|
87
109
|
readonly pred: PredItemType;
|
|
88
110
|
readonly schema: ResolvedSemanticSchema;
|
|
89
111
|
readonly inputProperty?: ResolvedSemanticProperty;
|
|
90
112
|
}
|
|
91
|
-
export interface OperatorDefaultNameContext {
|
|
92
|
-
/** Name produced by the direct pred
|
|
113
|
+
export interface OperatorDefaultNameContext extends OperatorHookContext {
|
|
114
|
+
/** Name produced by the direct pred inputs or localized row label. */
|
|
93
115
|
readonly operandName: string;
|
|
94
116
|
/** Name of a direct or nested pred input. */
|
|
95
117
|
readonly inputName?: string;
|
|
96
|
-
/** Names of
|
|
97
|
-
readonly
|
|
118
|
+
/** Names of multi-input pred values. */
|
|
119
|
+
readonly inputNames: readonly string[];
|
|
98
120
|
/** Operator-specific LogicForm arguments. */
|
|
99
121
|
readonly args: Readonly<Record<string, unknown>>;
|
|
100
|
-
/** Requested locale
|
|
122
|
+
/** Requested locale for generated names. */
|
|
101
123
|
readonly locale: string;
|
|
124
|
+
/** Translate a stable message key using the requested locale. */
|
|
125
|
+
readonly t?: LocaleTranslate;
|
|
102
126
|
}
|
|
103
|
-
export interface OperatorPlanInputContext {
|
|
127
|
+
export interface OperatorPlanInputContext extends OperatorHookContext {
|
|
104
128
|
/** Canonical property or relation reference supplied as this operator's direct pred. */
|
|
105
129
|
readonly reference: string;
|
|
106
130
|
readonly args: Readonly<Record<string, unknown>>;
|
|
@@ -113,46 +137,55 @@ export interface OperatorPlannedInput {
|
|
|
113
137
|
/** Provider-independent arguments resolved from semantic metadata. */
|
|
114
138
|
readonly args: Readonly<Record<string, unknown>>;
|
|
115
139
|
}
|
|
116
|
-
export interface OperatorNormalizePredContext {
|
|
140
|
+
export interface OperatorNormalizePredContext extends OperatorHookContext {
|
|
117
141
|
readonly pred: PredItemType;
|
|
118
142
|
readonly schema: ResolvedSemanticSchema;
|
|
119
143
|
}
|
|
120
|
-
export interface OperatorPlanExpressionContext {
|
|
144
|
+
export interface OperatorPlanExpressionContext extends OperatorHookContext {
|
|
121
145
|
readonly pred: PredItemType;
|
|
122
146
|
readonly input?: Expression;
|
|
123
147
|
readonly inputProperty?: ResultProperty;
|
|
124
|
-
readonly
|
|
148
|
+
readonly inputs: readonly Expression[];
|
|
125
149
|
readonly args: Readonly<Record<string, unknown>>;
|
|
126
150
|
readonly resolveKey: (reference: string) => Expression;
|
|
127
151
|
readonly getOperator: (name: string) => OperatorDefinition;
|
|
128
152
|
readonly planQuery: (query: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>>;
|
|
129
153
|
}
|
|
130
|
-
export interface
|
|
154
|
+
export interface OperatorPeriodBoundaryPolicyContext extends OperatorHookContext {
|
|
131
155
|
readonly pred: PredItemType;
|
|
132
156
|
}
|
|
133
|
-
export interface
|
|
157
|
+
export interface OperatorPeriodBoundaryPolicy {
|
|
134
158
|
readonly boundary: 'start' | 'end';
|
|
135
159
|
readonly implicit: boolean;
|
|
136
160
|
}
|
|
137
|
-
export interface OperatorValidatePlanContext {
|
|
161
|
+
export interface OperatorValidatePlanContext extends OperatorHookContext {
|
|
138
162
|
readonly pred: PredItemType;
|
|
139
163
|
readonly groupByNames: readonly string[];
|
|
140
164
|
readonly resolveGroupName: (reference: string) => string | undefined;
|
|
141
165
|
readonly getOperator: (name: string) => OperatorDefinition;
|
|
142
166
|
}
|
|
143
|
-
export interface
|
|
167
|
+
export interface OperatorValidateGroupbyContext extends OperatorHookContext {
|
|
168
|
+
readonly pred: PredItemType;
|
|
169
|
+
}
|
|
170
|
+
export interface OperatorRewriteLogicformContext extends OperatorHookContext {
|
|
144
171
|
readonly logicform: LogicformType;
|
|
145
172
|
readonly schema: ResolvedSemanticSchema;
|
|
173
|
+
/** Resolve operator metadata while rewriting nested expressions. */
|
|
174
|
+
readonly getOperator?: (name: string) => OperatorDefinition;
|
|
146
175
|
}
|
|
147
|
-
export interface OperatorComponentContext {
|
|
148
|
-
/**
|
|
176
|
+
export interface OperatorComponentContext extends OperatorHookContext {
|
|
177
|
+
/** Normalized input LogicForm; having, sort, limit, limitBy, and page stay on the merged result. */
|
|
149
178
|
readonly logicform: LogicformType;
|
|
150
|
-
/** Caller-authored normalized
|
|
179
|
+
/** Caller-authored normalized input before executor row policies, with result operations removed. */
|
|
151
180
|
readonly sourceLogicform?: LogicformType;
|
|
152
181
|
/** The operator projection for which the component is being built. */
|
|
153
182
|
readonly pred: PredItemType;
|
|
154
183
|
/** Final output alias assigned by the planner. */
|
|
155
184
|
readonly outputName: string;
|
|
185
|
+
/** Requested locale for child component names. */
|
|
186
|
+
readonly locale: string;
|
|
187
|
+
/** Translate a stable message key using the requested locale. */
|
|
188
|
+
readonly t: LocaleTranslate;
|
|
156
189
|
readonly schema: ResolvedSemanticSchema;
|
|
157
190
|
/** Resolve Schemas referenced by object relation paths used by this component. */
|
|
158
191
|
readonly resolveSchema: (schemaId: string) => ResolvedSemanticSchema;
|
|
@@ -173,31 +206,30 @@ export interface OperatorQueryComponent {
|
|
|
173
206
|
/** SQL-side transformations that align this component's group keys with the base component. */
|
|
174
207
|
readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
|
|
175
208
|
}
|
|
176
|
-
export interface
|
|
177
|
-
|
|
178
|
-
readonly quoteIdentifier: (identifier: string) => string;
|
|
179
|
-
}
|
|
180
|
-
export interface OperatorCteComponent {
|
|
209
|
+
export interface OperatorComponentQuery {
|
|
210
|
+
/** Final result-column name for this child component. */
|
|
181
211
|
readonly name: string;
|
|
182
|
-
readonly
|
|
183
|
-
|
|
212
|
+
readonly logicform: LogicformType;
|
|
213
|
+
readonly prepare?: boolean;
|
|
214
|
+
readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
|
|
215
|
+
readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
|
|
216
|
+
/**
|
|
217
|
+
* Group output names used to join this component back to the first component.
|
|
218
|
+
* When omitted, the compiler joins on the groupby outputs shared by both components.
|
|
219
|
+
*/
|
|
184
220
|
readonly joinKeys?: readonly string[];
|
|
185
221
|
}
|
|
186
|
-
export interface
|
|
187
|
-
readonly
|
|
188
|
-
|
|
189
|
-
readonly
|
|
190
|
-
readonly toSQL: (context: OperatorCteSqlContext) => string;
|
|
191
|
-
readonly exposeComponents?: boolean;
|
|
222
|
+
export interface OperatorComponentCalculation {
|
|
223
|
+
readonly components: readonly OperatorComponentQuery[];
|
|
224
|
+
/** Provider-independent formula referring to component names. */
|
|
225
|
+
readonly expression: string;
|
|
192
226
|
}
|
|
193
227
|
export interface OperatorJavaScriptCalculation {
|
|
194
228
|
readonly kind: 'js';
|
|
195
|
-
readonly components: readonly
|
|
196
|
-
readonly outputName: string;
|
|
229
|
+
readonly components: readonly OperatorComponentQuery[];
|
|
197
230
|
readonly mergeRow: (values: DataRow) => unknown;
|
|
198
|
-
readonly exposeComponents?: boolean;
|
|
199
231
|
}
|
|
200
|
-
export type OperatorExecutionComponent = OperatorQueryComponent |
|
|
232
|
+
export type OperatorExecutionComponent = OperatorQueryComponent | OperatorComponentCalculation | OperatorJavaScriptCalculation;
|
|
201
233
|
/**
|
|
202
234
|
* Extension contract for one LogicForm operator.
|
|
203
235
|
*
|
|
@@ -207,10 +239,25 @@ export type OperatorExecutionComponent = OperatorQueryComponent | OperatorCteCal
|
|
|
207
239
|
* `getOutputProperty` to describe the resulting one-column logical schema.
|
|
208
240
|
*/
|
|
209
241
|
interface OperatorDefinitionBase {
|
|
210
|
-
/** Public registry key,
|
|
242
|
+
/** Public registry key. Built-in operators commonly use a `$` prefix, but it is not required. */
|
|
211
243
|
readonly name: string;
|
|
244
|
+
/** Description of the computed metric, exposed on its result Property. */
|
|
245
|
+
readonly description?: string;
|
|
212
246
|
/** Produce the normalized output name when the PredItem does not declare one. */
|
|
213
247
|
readonly defaultName: (context: OperatorDefaultNameContext) => string;
|
|
248
|
+
/** Translation key for the generated name. Defaults to `operator.${name}`. */
|
|
249
|
+
readonly defaultNameKey?: string | ((context: OperatorDefaultNameContext) => string);
|
|
250
|
+
/** defaultName already used the translator and must not be translated a second time. */
|
|
251
|
+
readonly defaultNameIsLocalized?: boolean;
|
|
252
|
+
/** A grouped physical source may safely apply this operator again to stored partial results. */
|
|
253
|
+
readonly supportsGroupedSourceRollup?: boolean;
|
|
254
|
+
/** This computed operator preserves a grouped physical source's dimension semantics. */
|
|
255
|
+
readonly supportsGroupedSourceGroupby?: boolean;
|
|
256
|
+
/** Requested time grain of a grouped dimension, when this is a time grouping operator. */
|
|
257
|
+
readonly groupedSourceTimeGranularity?: (context: {
|
|
258
|
+
readonly pred: PredItemType;
|
|
259
|
+
readonly property: ResolvedSemanticProperty;
|
|
260
|
+
}) => TimeGranularity | undefined;
|
|
214
261
|
/** Logical property names read in addition to the direct input property. */
|
|
215
262
|
readonly dependencies?: readonly string[];
|
|
216
263
|
/** Set to false for operators such as `$count` that do not require a property. */
|
|
@@ -223,11 +270,17 @@ interface OperatorDefinitionBase {
|
|
|
223
270
|
readonly normalizePred?: (context: OperatorNormalizePredContext) => PredItemType;
|
|
224
271
|
/** Build a provider-independent expression for operators with custom planning semantics. */
|
|
225
272
|
readonly planExpression?: (context: OperatorPlanExpressionContext) => Expression | undefined;
|
|
226
|
-
/**
|
|
227
|
-
readonly
|
|
273
|
+
/** Describe how this operator selects a value at a generated period boundary. */
|
|
274
|
+
readonly periodBoundaryPolicy?: (context: OperatorPeriodBoundaryPolicyContext) => OperatorPeriodBoundaryPolicy | undefined;
|
|
228
275
|
/** Validate this operator against the completed group key set. */
|
|
229
276
|
readonly validatePlan?: (context: OperatorValidatePlanContext) => void;
|
|
230
|
-
/**
|
|
277
|
+
/** Validate semantics that apply only when this Operator is used as a group key. */
|
|
278
|
+
readonly validateGroupby?: (context: OperatorValidateGroupbyContext) => void;
|
|
279
|
+
/** The logical planner may fully lower a component, so no executor child query is needed. */
|
|
280
|
+
readonly skipComponentExecution?: (context: OperatorHookContext & {
|
|
281
|
+
readonly plan: LogicalPlan;
|
|
282
|
+
}) => boolean;
|
|
283
|
+
/** Expand high-level operator semantics into ordinary nested LogicForm objects before planning. */
|
|
231
284
|
readonly rewriteLogicform?: (context: OperatorRewriteLogicformContext) => LogicformType | undefined;
|
|
232
285
|
/** Whether this operator requires one evaluation per time bucket. */
|
|
233
286
|
readonly requiresPerPeriodEvaluation?: (context: OperatorPeriodEvaluationContext) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreComputeProvider, DataRow, ProviderExecutionRequest } from './provider';
|
|
1
|
+
import type { CoreComputeProvider, DatePart, DataRow, ProviderExecutionRequest, SQLResult, DatabaseTable, TableListRequest, DescribeTableRequest, TableDescription } from './provider';
|
|
2
2
|
interface ClickHouseResultLike {
|
|
3
3
|
json<T>(): Promise<T>;
|
|
4
4
|
}
|
|
@@ -9,18 +9,37 @@ export interface ClickHouseClientLike {
|
|
|
9
9
|
query_params: Readonly<Record<string, unknown>>;
|
|
10
10
|
abort_signal?: AbortSignal;
|
|
11
11
|
}): Promise<ClickHouseResultLike>;
|
|
12
|
+
/** Native SDK exec does not append a FORMAT clause to commands. */
|
|
13
|
+
exec?(options: {
|
|
14
|
+
query: string;
|
|
15
|
+
query_params: Readonly<Record<string, unknown>>;
|
|
16
|
+
clickhouse_settings: {
|
|
17
|
+
readonly default_format: 'JSONEachRow';
|
|
18
|
+
};
|
|
19
|
+
abort_signal?: AbortSignal;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
readonly stream: AsyncIterable<string | Buffer>;
|
|
22
|
+
}>;
|
|
12
23
|
close(): Promise<void>;
|
|
13
24
|
}
|
|
14
25
|
export interface ClickHouseProviderOptions {
|
|
26
|
+
/** Full HTTP endpoint. Takes precedence over host and port. */
|
|
15
27
|
readonly url?: string;
|
|
28
|
+
/** Host-style connection fields accepted by the shared datasource contract. */
|
|
29
|
+
readonly host?: string;
|
|
30
|
+
readonly port?: number;
|
|
16
31
|
readonly username?: string;
|
|
32
|
+
/** Alias used by the shared datasource contract. username takes precedence. */
|
|
33
|
+
readonly user?: string;
|
|
17
34
|
readonly password?: string;
|
|
18
35
|
readonly database?: string;
|
|
19
36
|
readonly client?: ClickHouseClientLike;
|
|
20
37
|
}
|
|
21
38
|
export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
39
|
+
#private;
|
|
22
40
|
readonly kind: "clickhouse";
|
|
23
|
-
|
|
41
|
+
readonly supportsRecursiveCte = true;
|
|
42
|
+
readonly recursiveCteUnion: "UNION ALL";
|
|
24
43
|
constructor(options?: ClickHouseProviderOptions);
|
|
25
44
|
quoteIdentifier(identifier: string): string;
|
|
26
45
|
tableAlias(expression: string, alias: string): string;
|
|
@@ -28,10 +47,15 @@ export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
|
28
47
|
parameter(index: number, value: unknown): string;
|
|
29
48
|
displayQuery(sql: string, parameters: readonly unknown[]): string;
|
|
30
49
|
dateBucket(expression: string, level: string): string;
|
|
50
|
+
datePart(expression: string, part: DatePart): string;
|
|
31
51
|
dateShift(expression: string, granularity: string, offset: number): string;
|
|
52
|
+
castValue(expression: string, type: string): string;
|
|
53
|
+
scalarExtremum(operator: 'least' | 'greatest', expressions: readonly string[]): string;
|
|
32
54
|
aggregateFunction(name: string, expression?: string): string;
|
|
55
|
+
stringify(expression: string): string;
|
|
33
56
|
concat(expressions: readonly string[]): string;
|
|
34
57
|
substring(expression: string, start: number, length: number): string;
|
|
58
|
+
stringLength(expression: string): string;
|
|
35
59
|
regex(expression: string, pattern: string, options?: string): string;
|
|
36
60
|
arrayContains(arrayExpression: string, valueExpression: string): string;
|
|
37
61
|
expandArray(arrayExpression: string, alias: string, column: string): {
|
|
@@ -39,6 +63,9 @@ export declare class ClickHouseProvider implements CoreComputeProvider {
|
|
|
39
63
|
valueExpression: string;
|
|
40
64
|
};
|
|
41
65
|
execute(request: ProviderExecutionRequest): Promise<DataRow[]>;
|
|
66
|
+
getTableList(request: TableListRequest): Promise<DatabaseTable[]>;
|
|
67
|
+
describeTable(request: DescribeTableRequest): Promise<TableDescription>;
|
|
68
|
+
runSQL(request: ProviderExecutionRequest): Promise<SQLResult>;
|
|
42
69
|
close(): Promise<void>;
|
|
43
70
|
}
|
|
44
71
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DatabaseConnection, ProviderRegistry } from './connection';
|
|
2
|
+
import type { CoreComputeProvider } from './provider';
|
|
3
|
+
type ProviderFactory = (connection: DatabaseConnection) => CoreComputeProvider;
|
|
4
|
+
export declare class ConnectionRegistry {
|
|
5
|
+
#private;
|
|
6
|
+
private readonly create;
|
|
7
|
+
constructor(create?: ProviderFactory);
|
|
8
|
+
get(connection: DatabaseConnection): CoreComputeProvider;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const getConnectionProvider: (connection: DatabaseConnection, providers?: ProviderRegistry) => CoreComputeProvider;
|
|
12
|
+
export declare const closeConnections: () => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -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 {};
|