UNPKG

@finos/legend-graph

Version:
134 lines 4.23 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { guaranteeNonNullable, isString, uuid } from '@finos/legend-shared'; // Core export var BuilderType; (function (BuilderType) { BuilderType["CLASS_BUILDER"] = "classBuilder"; BuilderType["TDS_BUILDER"] = "tdsBuilder"; BuilderType["JSON_BUILDER"] = "json"; })(BuilderType || (BuilderType = {})); export var ExecutionActivityType; (function (ExecutionActivityType) { ExecutionActivityType["RELATIONAL"] = "relational"; ExecutionActivityType["RELATIONAL_EXECUTION_ACTIVITY"] = "RelationalExecutionActivity"; ExecutionActivityType["AGGREGATION_AWARE_ACTIVITY"] = "aggregationAware"; })(ExecutionActivityType || (ExecutionActivityType = {})); // TODO: Refactor to use external format (https://github.com/finos/legend-studio/issues/732) export var EXECUTION_SERIALIZATION_FORMAT; (function (EXECUTION_SERIALIZATION_FORMAT) { EXECUTION_SERIALIZATION_FORMAT["CSV"] = "CSV"; })(EXECUTION_SERIALIZATION_FORMAT || (EXECUTION_SERIALIZATION_FORMAT = {})); export class ResultBuilder { _type; constructor(type) { this._type = type; } } // ------------------------------------------ Execution Activities ----------------------------------------------- export class ExecutionActivities { } export class RelationalExecutionActivities extends ExecutionActivities { sql; comment; constructor(sql) { super(); this.sql = sql; } } export class AggregationAwareActivities extends ExecutionActivities { rewrittenQuery; } export class UnknownExecutionActivities extends ExecutionActivities { values; constructor(content) { super(); this.values = content; } } export class ExecutionResult { builder; activities; } // ------------------------------------------ Model ----------------------------------------------- export class JsonBuilder { _type = BuilderType.JSON_BUILDER; } export class JsonExecutionResult extends ExecutionResult { values; } export class RawExecutionResult extends ExecutionResult { value; constructor(content) { super(); this.value = content; } } // ------------------------------------------ TDS ----------------------------------------------- /** * TODO?: maybe we converge to use TDSColumn * * Since here, we're building out the result builder config, we don't need * to fully resolve all the references, hence we have this simplified version of TDSColumn */ export class INTERNAL__TDSColumn { name; type; relationalType; doc; } export class TDSBuilder extends ResultBuilder { columns = []; constructor() { super(BuilderType.TDS_BUILDER); } } export class TDSRow { values = []; } export class TabularDataSet { columns = []; rows = []; } export class TDSExecutionResult extends ExecutionResult { _UUID = uuid(); builder = new TDSBuilder(); result = new TabularDataSet(); } export class ClassBuilder extends ResultBuilder { _type = BuilderType.CLASS_BUILDER; } export class ClassExecutionResult extends ExecutionResult { builder = new ClassBuilder(BuilderType.CLASS_BUILDER); objects; } export const getTDSRowRankByColumnInAsc = (a, b, colIndex) => { const a1 = a.values[colIndex]; const b1 = b.values[colIndex]; if (a1 === null || a1 === undefined) { return -1; } if (b1 === null || b1 === undefined) { return 1; } if (isString(a1) && isString(b1)) { return a1.localeCompare(b1); } else { return Number(guaranteeNonNullable(a1)) - Number(guaranteeNonNullable(b1)); } }; //# sourceMappingURL=ExecutionResult.js.map