🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@cubejs-backend/shared

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cubejs-backend/shared - npm Package Compare versions

Comparing version

to
1.3.24

@@ -5,2 +5,3 @@ export interface FileContent {

readOnly?: boolean;
isModule?: boolean;
}

@@ -7,0 +8,0 @@ export interface SchemaFileRepository {

@@ -11,2 +11,16 @@ import type { unitOfTime } from 'moment-timezone';

type ParsedInterval = Partial<Record<unitOfTime.DurationConstructor, number>>;
export type DimensionToCompareGranularity = {
dimension: string;
expressionName?: string;
granularityObj?: {
minGranularity(): string;
};
};
/**
* Actually dimensions type is (BaseDimension|BaseTimeDimension)[], but can not ref due to cyclic dependencies refs.
*/
export declare function findMinGranularityDimension(id: string, dimensions: DimensionToCompareGranularity[]): {
index: number;
dimension: DimensionToCompareGranularity | undefined;
} | null;
export declare const TIME_SERIES: Record<string, (range: DateRange, timestampPrecision: number) => QueryDateRange[]>;

@@ -13,0 +27,0 @@ /**

@@ -6,6 +6,50 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.reformatInIsoLocal = exports.addSecondsToLocalTimestamp = exports.parseUtcIntoLocalDate = exports.utcToLocalTimeZone = exports.localTimestampToUtc = exports.BUILD_RANGE_END_LOCAL = exports.BUILD_RANGE_START_LOCAL = exports.TO_PARTITION_RANGE = exports.FROM_PARTITION_RANGE = exports.isPredefinedGranularity = exports.timeSeries = exports.timeSeriesFromCustomInterval = exports.parsedSqlIntervalToDuration = exports.alignToOrigin = exports.subtractInterval = exports.addInterval = exports.parseSqlInterval = exports.TIME_SERIES = void 0;
exports.reformatInIsoLocal = exports.addSecondsToLocalTimestamp = exports.parseUtcIntoLocalDate = exports.utcToLocalTimeZone = exports.localTimestampToUtc = exports.BUILD_RANGE_END_LOCAL = exports.BUILD_RANGE_START_LOCAL = exports.TO_PARTITION_RANGE = exports.FROM_PARTITION_RANGE = exports.isPredefinedGranularity = exports.timeSeries = exports.timeSeriesFromCustomInterval = exports.parsedSqlIntervalToDuration = exports.alignToOrigin = exports.subtractInterval = exports.addInterval = exports.parseSqlInterval = exports.TIME_SERIES = exports.findMinGranularityDimension = void 0;
const moment_timezone_1 = __importDefault(require("moment-timezone"));
const moment_range_1 = require("moment-range");
const moment = (0, moment_range_1.extendMoment)(moment_timezone_1.default);
const GRANULARITY_LEVELS = {
second: 1,
minute: 2,
hour: 3,
day: 4,
week: 5,
month: 6,
quarter: 7,
year: 8,
MAX: 1000,
};
/**
* Actually dimensions type is (BaseDimension|BaseTimeDimension)[], but can not ref due to cyclic dependencies refs.
*/
function findMinGranularityDimension(id, dimensions) {
const equalIgnoreCase = (a, b) => (typeof a === 'string' && typeof b === 'string' && a.toUpperCase() === b.toUpperCase());
let minGranularity = GRANULARITY_LEVELS.MAX;
let index = -1;
let minGranularityIndex = -1;
let field;
let minGranularityField;
dimensions.forEach((d, i) => {
if (equalIgnoreCase(d.dimension, id) || equalIgnoreCase(d.expressionName, id)) {
field = d;
index = i;
if ('granularityObj' in d && d.granularityObj) {
const gr = GRANULARITY_LEVELS[d.granularityObj?.minGranularity()];
if (gr < minGranularity) {
minGranularityIndex = i;
minGranularityField = d;
minGranularity = gr;
}
}
}
});
if (minGranularityIndex > -1) {
return { index: minGranularityIndex, dimension: minGranularityField };
}
if (index > -1) {
return { index, dimension: field };
}
return null;
}
exports.findMinGranularityDimension = findMinGranularityDimension;
exports.TIME_SERIES = {

@@ -12,0 +56,0 @@ day: (range, digits) => Array.from(range.snapTo('day').by('day'))

{
"name": "@cubejs-backend/shared",
"version": "1.3.23",
"version": "1.3.24",
"description": "Shared code for Cube.js backend packages",

@@ -25,3 +25,3 @@ "main": "dist/src/index.js",

"devDependencies": {
"@cubejs-backend/linter": "1.3.23",
"@cubejs-backend/linter": "1.3.24",
"@types/bytes": "^3.1.5",

@@ -64,3 +64,3 @@ "@types/cli-progress": "^3.9.1",

},
"gitHead": "dd7d234a351b16d072f6bf0434152e1b948f9e41"
"gitHead": "12458db217546d20e681b03e94c931288ca001db"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet