@devrev/meerkat-core 0.0.94 → 0.0.96

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/index.js CHANGED
@@ -51,6 +51,8 @@ const _getfinalbasesql = require("./get-final-base-sql/get-final-base-sql");
51
51
  const _getwrappedbasequerywithprojections = require("./get-wrapped-base-query-with-projections/get-wrapped-base-query-with-projections");
52
52
  _export_star._(require("./joins/joins"), exports);
53
53
  _export_star._(require("./member-formatters"), exports);
54
+ _export_star._(require("./resolution/resolution"), exports);
55
+ _export_star._(require("./resolution/types"), exports);
54
56
  const _cubetypes = require("./types/cube-types");
55
57
  _export_star._(require("./types/cube-types/index"), exports);
56
58
  _export_star._(require("./types/duckdb-serialization-types/index"), exports);
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../meerkat-core/src/index.ts"],"sourcesContent":["export * from './ast-builder/ast-builder';\nexport * from './ast-deserializer/ast-deserializer';\nexport * from './ast-serializer/ast-serializer';\nexport * from './ast-validator';\nexport { detectApplyContextParamsToBaseSQL } from './context-params/context-params-ast';\nexport * from './cube-measure-transformer/cube-measure-transformer';\nexport * from './cube-to-duckdb/cube-filter-to-duckdb';\nexport {\n applyFilterParamsToBaseSQL,\n detectAllFilterParamsFromSQL,\n getFilterParamsAST,\n} from './filter-params/filter-params-ast';\nexport { getFilterParamsSQL } from './get-filter-params-sql/get-filter-params-sql';\nexport { getFinalBaseSQL } from './get-final-base-sql/get-final-base-sql';\nexport { getWrappedBaseQueryWithProjections } from './get-wrapped-base-query-with-projections/get-wrapped-base-query-with-projections';\nexport * from './joins/joins';\nexport * from './member-formatters';\nexport { FilterType } from './types/cube-types';\nexport * from './types/cube-types/index';\nexport * from './types/duckdb-serialization-types/index';\nexport * from './types/utils';\nexport { BASE_TABLE_NAME } from './utils/base-ast';\nexport * from './utils/cube-to-table-schema';\nexport * from './utils/get-column-names-from-ast';\nexport * from './utils/get-possible-nodes';\nexport { meerkatPlaceholderReplacer } from './utils/meerkat-placeholder-replacer';\n"],"names":["BASE_TABLE_NAME","FilterType","applyFilterParamsToBaseSQL","detectAllFilterParamsFromSQL","detectApplyContextParamsToBaseSQL","getFilterParamsAST","getFilterParamsSQL","getFinalBaseSQL","getWrappedBaseQueryWithProjections","meerkatPlaceholderReplacer"],"mappings":";;;;;;;;IAqBSA,eAAe;eAAfA,wBAAe;;IAJfC,UAAU;eAAVA,qBAAU;;IATjBC,0BAA0B;eAA1BA,2CAA0B;;IAC1BC,4BAA4B;eAA5BA,6CAA4B;;IALrBC,iCAAiC;eAAjCA,mDAAiC;;IAMxCC,kBAAkB;eAAlBA,mCAAkB;;IAEXC,kBAAkB;eAAlBA,sCAAkB;;IAClBC,eAAe;eAAfA,gCAAe;;IACfC,kCAAkC;eAAlCA,sEAAkC;;IAWlCC,0BAA0B;eAA1BA,sDAA0B;;;;uBAzBrB;uBACA;uBACA;uBACA;kCACoC;uBACpC;uBACA;iCAKP;oCAC4B;iCACH;oDACmB;uBACrC;uBACA;2BACa;uBACb;uBACA;uBACA;yBACkB;uBAClB;uBACA;uBACA;4CAC6B"}
1
+ {"version":3,"sources":["../../meerkat-core/src/index.ts"],"sourcesContent":["export * from './ast-builder/ast-builder';\nexport * from './ast-deserializer/ast-deserializer';\nexport * from './ast-serializer/ast-serializer';\nexport * from './ast-validator';\nexport { detectApplyContextParamsToBaseSQL } from './context-params/context-params-ast';\nexport * from './cube-measure-transformer/cube-measure-transformer';\nexport * from './cube-to-duckdb/cube-filter-to-duckdb';\nexport {\n applyFilterParamsToBaseSQL,\n detectAllFilterParamsFromSQL,\n getFilterParamsAST,\n} from './filter-params/filter-params-ast';\nexport { getFilterParamsSQL } from './get-filter-params-sql/get-filter-params-sql';\nexport { getFinalBaseSQL } from './get-final-base-sql/get-final-base-sql';\nexport { getWrappedBaseQueryWithProjections } from './get-wrapped-base-query-with-projections/get-wrapped-base-query-with-projections';\nexport * from './joins/joins';\nexport * from './member-formatters';\nexport * from './resolution/resolution';\nexport * from './resolution/types';\nexport { FilterType } from './types/cube-types';\nexport * from './types/cube-types/index';\nexport * from './types/duckdb-serialization-types/index';\nexport * from './types/utils';\nexport { BASE_TABLE_NAME } from './utils/base-ast';\nexport * from './utils/cube-to-table-schema';\nexport * from './utils/get-column-names-from-ast';\nexport * from './utils/get-possible-nodes';\nexport { meerkatPlaceholderReplacer } from './utils/meerkat-placeholder-replacer';\n"],"names":["BASE_TABLE_NAME","FilterType","applyFilterParamsToBaseSQL","detectAllFilterParamsFromSQL","detectApplyContextParamsToBaseSQL","getFilterParamsAST","getFilterParamsSQL","getFinalBaseSQL","getWrappedBaseQueryWithProjections","meerkatPlaceholderReplacer"],"mappings":";;;;;;;;IAuBSA,eAAe;eAAfA,wBAAe;;IAJfC,UAAU;eAAVA,qBAAU;;IAXjBC,0BAA0B;eAA1BA,2CAA0B;;IAC1BC,4BAA4B;eAA5BA,6CAA4B;;IALrBC,iCAAiC;eAAjCA,mDAAiC;;IAMxCC,kBAAkB;eAAlBA,mCAAkB;;IAEXC,kBAAkB;eAAlBA,sCAAkB;;IAClBC,eAAe;eAAfA,gCAAe;;IACfC,kCAAkC;eAAlCA,sEAAkC;;IAalCC,0BAA0B;eAA1BA,sDAA0B;;;;uBA3BrB;uBACA;uBACA;uBACA;kCACoC;uBACpC;uBACA;iCAKP;oCAC4B;iCACH;oDACmB;uBACrC;uBACA;uBACA;uBACA;2BACa;uBACb;uBACA;uBACA;yBACkB;uBAClB;uBACA;uBACA;4CAC6B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/meerkat-core",
3
- "version": "0.0.94",
3
+ "version": "0.0.96",
4
4
  "dependencies": {
5
5
  "@swc/helpers": "~0.5.0"
6
6
  },
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ function _export(target, all) {
3
+ for(var name in all)Object.defineProperty(target, name, {
4
+ enumerable: true,
5
+ get: all[name]
6
+ });
7
+ }
8
+ _export(exports, {
9
+ createBaseTableSchema: function() {
10
+ return createBaseTableSchema;
11
+ },
12
+ generateResolutionJoinPaths: function() {
13
+ return generateResolutionJoinPaths;
14
+ },
15
+ generateResolutionSchemas: function() {
16
+ return generateResolutionSchemas;
17
+ },
18
+ generateResolvedDimensions: function() {
19
+ return generateResolvedDimensions;
20
+ }
21
+ });
22
+ const _splitintodatasourceandfields = require("../member-formatters/split-into-data-source-and-fields");
23
+ const _types = require("./types");
24
+ const resolveDimension = (dim, tableSchemas)=>{
25
+ const [tableName, columnName] = (0, _splitintodatasourceandfields.splitIntoDataSourceAndFields)(dim);
26
+ const tableSchema = tableSchemas.find((ts)=>ts.name === tableName);
27
+ if (!tableSchema) {
28
+ throw new Error(`Table schema not found for ${tableName}`);
29
+ }
30
+ const dimension = tableSchema.dimensions.find((d)=>d.name === columnName);
31
+ if (!dimension) {
32
+ throw new Error(`Dimension not found: ${dim}`);
33
+ }
34
+ return {
35
+ name: `${generateName(dim)}`,
36
+ sql: `${_types.BASE_DATA_SOURCE_NAME}.${generateName(dim)}`,
37
+ type: dimension.type
38
+ };
39
+ };
40
+ const resolveMeasure = (measure, tableSchemas)=>{
41
+ const [tableName, columnName] = (0, _splitintodatasourceandfields.splitIntoDataSourceAndFields)(measure);
42
+ const tableSchema = tableSchemas.find((ts)=>ts.name === tableName);
43
+ if (!tableSchema) {
44
+ throw new Error(`Table schema not found for ${tableName}`);
45
+ }
46
+ const measureSchema = tableSchema.measures.find((m)=>m.name === columnName);
47
+ if (!measureSchema) {
48
+ throw new Error(`Measure not found: ${measure}`);
49
+ }
50
+ return {
51
+ name: `${generateName(measure)}`,
52
+ sql: `${_types.BASE_DATA_SOURCE_NAME}.${generateName(measure)}`,
53
+ type: measureSchema.type
54
+ };
55
+ };
56
+ const createBaseTableSchema = (baseSql, tableSchemas, resolutionConfig, measures, dimensions)=>({
57
+ name: _types.BASE_DATA_SOURCE_NAME,
58
+ sql: baseSql,
59
+ measures: [],
60
+ dimensions: [
61
+ ...(dimensions || []).map((dim)=>resolveDimension(dim, tableSchemas)),
62
+ ...(measures || []).map((meas)=>resolveMeasure(meas, tableSchemas))
63
+ ],
64
+ joins: resolutionConfig.columnConfigs.map((config)=>({
65
+ sql: `${_types.BASE_DATA_SOURCE_NAME}.${generateName(config.name)} = ${generateName(config.name)}.${config.joinColumn}`
66
+ }))
67
+ });
68
+ const generateResolutionSchemas = (config)=>{
69
+ const resolutionSchemas = [];
70
+ config.columnConfigs.forEach((colConfig)=>{
71
+ const tableSchema = config.tableSchemas.find((ts)=>ts.name === colConfig.source);
72
+ if (!tableSchema) {
73
+ throw new Error(`Table schema not found for ${colConfig.source}`);
74
+ }
75
+ const baseName = generateName(colConfig.name);
76
+ // For each column that needs to be resolved, create a copy of the relevant table schema.
77
+ // We use the name of the column in the base query as the table schema name
78
+ // to avoid conflicts.
79
+ const resolutionSchema = {
80
+ name: baseName,
81
+ sql: tableSchema.sql,
82
+ measures: [],
83
+ dimensions: colConfig.resolutionColumns.map((col)=>{
84
+ const dimension = tableSchema.dimensions.find((d)=>d.name === col);
85
+ if (!dimension) {
86
+ throw new Error(`Dimension not found: ${col}`);
87
+ }
88
+ return {
89
+ name: col,
90
+ sql: `${baseName}.${col}`,
91
+ type: dimension.type
92
+ };
93
+ })
94
+ };
95
+ resolutionSchemas.push(resolutionSchema);
96
+ });
97
+ return resolutionSchemas;
98
+ };
99
+ const generateResolvedDimensions = (query, config)=>{
100
+ const resolvedDimensions = [
101
+ ...query.measures,
102
+ ...query.dimensions || []
103
+ ].flatMap((dimension)=>{
104
+ const resolution = config.columnConfigs.find((c)=>c.name === dimension);
105
+ if (!resolution) {
106
+ return [
107
+ `${_types.BASE_DATA_SOURCE_NAME}.${generateName(dimension)}`
108
+ ];
109
+ } else {
110
+ return resolution.resolutionColumns.map((col)=>`${generateName(dimension)}.${col}`);
111
+ }
112
+ });
113
+ return resolvedDimensions;
114
+ };
115
+ const generateResolutionJoinPaths = (resolutionConfig)=>{
116
+ return resolutionConfig.columnConfigs.map((config)=>[
117
+ {
118
+ left: _types.BASE_DATA_SOURCE_NAME,
119
+ right: generateName(config.name),
120
+ on: generateName(config.name)
121
+ }
122
+ ]);
123
+ };
124
+ // Generates a valid column name from a generic reference
125
+ // by replacing '.' with '__'.
126
+ const generateName = (columnName)=>columnName.replace('.', '__');
127
+
128
+ //# sourceMappingURL=resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../meerkat-core/src/resolution/resolution.ts"],"sourcesContent":["import { splitIntoDataSourceAndFields } from '../member-formatters/split-into-data-source-and-fields';\nimport { JoinPath, Member, Query } from '../types/cube-types/query';\nimport { TableSchema } from '../types/cube-types/table';\nimport { BASE_DATA_SOURCE_NAME, ResolutionConfig } from './types';\n\nconst resolveDimension = (dim: string, tableSchemas: TableSchema[]) => {\n const [tableName, columnName] = splitIntoDataSourceAndFields(dim);\n const tableSchema = tableSchemas.find((ts) => ts.name === tableName);\n if (!tableSchema) {\n throw new Error(`Table schema not found for ${tableName}`);\n }\n const dimension = tableSchema.dimensions.find((d) => d.name === columnName);\n if (!dimension) {\n throw new Error(`Dimension not found: ${dim}`);\n }\n\n return {\n name: `${generateName(dim)}`,\n sql: `${BASE_DATA_SOURCE_NAME}.${generateName(dim)}`,\n type: dimension.type,\n };\n};\n\nconst resolveMeasure = (measure: string, tableSchemas: TableSchema[]) => {\n const [tableName, columnName] = splitIntoDataSourceAndFields(measure);\n const tableSchema = tableSchemas.find((ts) => ts.name === tableName);\n if (!tableSchema) {\n throw new Error(`Table schema not found for ${tableName}`);\n }\n const measureSchema = tableSchema.measures.find((m) => m.name === columnName);\n if (!measureSchema) {\n throw new Error(`Measure not found: ${measure}`);\n }\n\n return {\n name: `${generateName(measure)}`,\n sql: `${BASE_DATA_SOURCE_NAME}.${generateName(measure)}`,\n type: measureSchema.type,\n };\n};\n\nexport const createBaseTableSchema = (\n baseSql: string,\n tableSchemas: TableSchema[],\n resolutionConfig: ResolutionConfig,\n measures: Member[],\n dimensions?: Member[]\n) => ({\n name: BASE_DATA_SOURCE_NAME,\n sql: baseSql,\n measures: [],\n dimensions: [\n ...(dimensions || []).map((dim) => resolveDimension(dim, tableSchemas)),\n ...(measures || []).map((meas) => resolveMeasure(meas, tableSchemas)),\n ],\n joins: resolutionConfig.columnConfigs.map((config) => ({\n sql: `${BASE_DATA_SOURCE_NAME}.${generateName(\n config.name\n )} = ${generateName(config.name)}.${config.joinColumn}`,\n })),\n});\n\nexport const generateResolutionSchemas = (config: ResolutionConfig) => {\n const resolutionSchemas: TableSchema[] = [];\n config.columnConfigs.forEach((colConfig) => {\n const tableSchema = config.tableSchemas.find(\n (ts) => ts.name === colConfig.source\n );\n if (!tableSchema) {\n throw new Error(`Table schema not found for ${colConfig.source}`);\n }\n\n const baseName = generateName(colConfig.name);\n\n // For each column that needs to be resolved, create a copy of the relevant table schema.\n // We use the name of the column in the base query as the table schema name\n // to avoid conflicts.\n const resolutionSchema: TableSchema = {\n name: baseName,\n sql: tableSchema.sql,\n measures: [],\n dimensions: colConfig.resolutionColumns.map((col) => {\n const dimension = tableSchema.dimensions.find((d) => d.name === col);\n if (!dimension) {\n throw new Error(`Dimension not found: ${col}`);\n }\n return {\n name: col,\n sql: `${baseName}.${col}`,\n type: dimension.type,\n };\n }),\n };\n\n resolutionSchemas.push(resolutionSchema);\n });\n\n return resolutionSchemas;\n};\n\nexport const generateResolvedDimensions = (\n query: Query,\n config: ResolutionConfig\n): Member[] => {\n const resolvedDimensions: Member[] = [\n ...query.measures,\n ...(query.dimensions || []),\n ].flatMap((dimension) => {\n const resolution = config.columnConfigs.find((c) => c.name === dimension);\n\n if (!resolution) {\n return [`${BASE_DATA_SOURCE_NAME}.${generateName(dimension)}`];\n } else {\n return resolution.resolutionColumns.map(\n (col) => `${generateName(dimension)}.${col}`\n );\n }\n });\n return resolvedDimensions;\n};\n\nexport const generateResolutionJoinPaths = (\n resolutionConfig: ResolutionConfig\n): JoinPath[] => {\n return resolutionConfig.columnConfigs.map((config) => [\n {\n left: BASE_DATA_SOURCE_NAME,\n right: generateName(config.name),\n on: generateName(config.name),\n },\n ]);\n};\n\n// Generates a valid column name from a generic reference\n// by replacing '.' with '__'.\nconst generateName = (columnName: string) => columnName.replace('.', '__');\n"],"names":["createBaseTableSchema","generateResolutionJoinPaths","generateResolutionSchemas","generateResolvedDimensions","resolveDimension","dim","tableSchemas","tableName","columnName","splitIntoDataSourceAndFields","tableSchema","find","ts","name","Error","dimension","dimensions","d","generateName","sql","BASE_DATA_SOURCE_NAME","type","resolveMeasure","measure","measureSchema","measures","m","baseSql","resolutionConfig","map","meas","joins","columnConfigs","config","joinColumn","resolutionSchemas","forEach","colConfig","source","baseName","resolutionSchema","resolutionColumns","col","push","query","resolvedDimensions","flatMap","resolution","c","left","right","on","replace"],"mappings":";;;;;;;;IAyCaA,qBAAqB;eAArBA;;IAgFAC,2BAA2B;eAA3BA;;IA3DAC,yBAAyB;eAAzBA;;IAsCAC,0BAA0B;eAA1BA;;;8CApGgC;uBAGW;AAExD,MAAMC,mBAAmB,CAACC,KAAaC;IACrC,MAAM,CAACC,WAAWC,WAAW,GAAGC,IAAAA,0DAA4B,EAACJ;IAC7D,MAAMK,cAAcJ,aAAaK,IAAI,CAAC,CAACC,KAAOA,GAAGC,IAAI,KAAKN;IAC1D,IAAI,CAACG,aAAa;QAChB,MAAM,IAAII,MAAM,CAAC,2BAA2B,EAAEP,UAAU,CAAC;IAC3D;IACA,MAAMQ,YAAYL,YAAYM,UAAU,CAACL,IAAI,CAAC,CAACM,IAAMA,EAAEJ,IAAI,KAAKL;IAChE,IAAI,CAACO,WAAW;QACd,MAAM,IAAID,MAAM,CAAC,qBAAqB,EAAET,IAAI,CAAC;IAC/C;IAEA,OAAO;QACLQ,MAAM,CAAC,EAAEK,aAAab,KAAK,CAAC;QAC5Bc,KAAK,CAAC,EAAEC,4BAAqB,CAAC,CAAC,EAAEF,aAAab,KAAK,CAAC;QACpDgB,MAAMN,UAAUM,IAAI;IACtB;AACF;AAEA,MAAMC,iBAA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AAWN,iBAAiB,CAACZ,GAAG,CACrC,CAACa,MAAQ,CAAC,EAAExB,aAAaH,WAAW,CAAC,EAAE2B,IAAI,CAAC;QAEhD;IACF;IACA,OAAOG;AACT;AAEO,MAAM5C,8BAA8B,CACzC2B;IAEA,OAAOA,iBAAiBI,aAAa,CAACH,GAAG,CAAC,CAACI,SAAW;YACpD;gBACEgB,MAAM7B,4BAAqB;gBAC3B8B,OAAOhC,aAAae,OAAOpB,IAAI;gBAC/BsC,IAAIjC,aAAae,OAAOpB,IAAI;YAC9B;SACD;AACH;AAEA,yDAAyD;AACzD,8BAA8B;AAC9B,MAAMK,eAAe,CAACV,aAAuBA,WAAW4C,OAAO,CAAC,KAAK"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "BASE_DATA_SOURCE_NAME", {
3
+ enumerable: true,
4
+ get: function() {
5
+ return BASE_DATA_SOURCE_NAME;
6
+ }
7
+ });
8
+ const BASE_DATA_SOURCE_NAME = '__base_query';
9
+
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../meerkat-core/src/resolution/types.ts"],"sourcesContent":["import { TableSchema } from '../types/cube-types/table';\n\nexport interface ResolutionColumnConfig {\n // Name of the column that needs resolution.\n // Should match a measure or dimension in the query.\n name: string;\n // Name of the data source to use for resolution.\n source: string;\n // Name of the column in the data source to join on.\n joinColumn: string;\n // Columns from the source table that should be included for resolution.\n resolutionColumns: string[];\n}\n\nexport interface ResolutionConfig {\n columnConfigs: ResolutionColumnConfig[];\n tableSchemas: TableSchema[];\n}\n\nexport const BASE_DATA_SOURCE_NAME = '__base_query';\n"],"names":["BASE_DATA_SOURCE_NAME"],"mappings":";+BAmBaA;;;eAAAA;;;AAAN,MAAMA,wBAAwB"}
package/src/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export { getFinalBaseSQL } from './get-final-base-sql/get-final-base-sql';
11
11
  export { getWrappedBaseQueryWithProjections } from './get-wrapped-base-query-with-projections/get-wrapped-base-query-with-projections';
12
12
  export * from './joins/joins';
13
13
  export * from './member-formatters';
14
+ export * from './resolution/resolution';
15
+ export * from './resolution/types';
14
16
  export { FilterType } from './types/cube-types';
15
17
  export * from './types/cube-types/index';
16
18
  export * from './types/duckdb-serialization-types/index';
@@ -0,0 +1,19 @@
1
+ import { JoinPath, Member, Query } from '../types/cube-types/query';
2
+ import { TableSchema } from '../types/cube-types/table';
3
+ import { ResolutionConfig } from './types';
4
+ export declare const createBaseTableSchema: (baseSql: string, tableSchemas: TableSchema[], resolutionConfig: ResolutionConfig, measures: Member[], dimensions?: Member[]) => {
5
+ name: string;
6
+ sql: string;
7
+ measures: never[];
8
+ dimensions: {
9
+ name: string;
10
+ sql: string;
11
+ type: import("../types/cube-types/table").DimensionType;
12
+ }[];
13
+ joins: {
14
+ sql: string;
15
+ }[];
16
+ };
17
+ export declare const generateResolutionSchemas: (config: ResolutionConfig) => TableSchema[];
18
+ export declare const generateResolvedDimensions: (query: Query, config: ResolutionConfig) => Member[];
19
+ export declare const generateResolutionJoinPaths: (resolutionConfig: ResolutionConfig) => JoinPath[];
@@ -0,0 +1,12 @@
1
+ import { TableSchema } from '../types/cube-types/table';
2
+ export interface ResolutionColumnConfig {
3
+ name: string;
4
+ source: string;
5
+ joinColumn: string;
6
+ resolutionColumns: string[];
7
+ }
8
+ export interface ResolutionConfig {
9
+ columnConfigs: ResolutionColumnConfig[];
10
+ tableSchemas: TableSchema[];
11
+ }
12
+ export declare const BASE_DATA_SOURCE_NAME = "__base_query";