@duckcodeailabs/dql-core 0.1.4 → 0.3.0

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.
Files changed (42) hide show
  1. package/LICENSE +123 -0
  2. package/dist/semantic/index.d.ts +5 -0
  3. package/dist/semantic/index.d.ts.map +1 -1
  4. package/dist/semantic/index.js +3 -0
  5. package/dist/semantic/index.js.map +1 -1
  6. package/dist/semantic/providers/cubejs-provider.d.ts +11 -0
  7. package/dist/semantic/providers/cubejs-provider.d.ts.map +1 -0
  8. package/dist/semantic/providers/cubejs-provider.js +190 -0
  9. package/dist/semantic/providers/cubejs-provider.js.map +1 -0
  10. package/dist/semantic/providers/dbt-provider.d.ts +12 -0
  11. package/dist/semantic/providers/dbt-provider.d.ts.map +1 -0
  12. package/dist/semantic/providers/dbt-provider.js +233 -0
  13. package/dist/semantic/providers/dbt-provider.js.map +1 -0
  14. package/dist/semantic/providers/dql-provider.d.ts +11 -0
  15. package/dist/semantic/providers/dql-provider.d.ts.map +1 -0
  16. package/dist/semantic/providers/dql-provider.js +16 -0
  17. package/dist/semantic/providers/dql-provider.js.map +1 -0
  18. package/dist/semantic/providers/index.d.ts +3 -0
  19. package/dist/semantic/providers/index.d.ts.map +1 -0
  20. package/dist/semantic/providers/index.js +2 -0
  21. package/dist/semantic/providers/index.js.map +1 -0
  22. package/dist/semantic/providers/provider.d.ts +14 -0
  23. package/dist/semantic/providers/provider.d.ts.map +1 -0
  24. package/dist/semantic/providers/provider.js +2 -0
  25. package/dist/semantic/providers/provider.js.map +1 -0
  26. package/dist/semantic/providers/registry.d.ts +15 -0
  27. package/dist/semantic/providers/registry.d.ts.map +1 -0
  28. package/dist/semantic/providers/registry.js +51 -0
  29. package/dist/semantic/providers/registry.js.map +1 -0
  30. package/dist/semantic/semantic-layer.d.ts +5 -0
  31. package/dist/semantic/semantic-layer.d.ts.map +1 -1
  32. package/dist/semantic/semantic-layer.js +8 -14
  33. package/dist/semantic/semantic-layer.js.map +1 -1
  34. package/dist/semantic/sql-dialect.d.ts +37 -0
  35. package/dist/semantic/sql-dialect.d.ts.map +1 -0
  36. package/dist/semantic/sql-dialect.js +350 -0
  37. package/dist/semantic/sql-dialect.js.map +1 -0
  38. package/dist/semantic/yaml-loader.d.ts +26 -0
  39. package/dist/semantic/yaml-loader.d.ts.map +1 -0
  40. package/dist/semantic/yaml-loader.js +80 -0
  41. package/dist/semantic/yaml-loader.js.map +1 -0
  42. package/package.json +14 -11
package/LICENSE ADDED
@@ -0,0 +1,123 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work.
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship.
41
+
42
+ "Contribution" shall mean any work of authorship, including the original version
43
+ of the Work and any modifications or additions to that Work or Derivative Works
44
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
45
+ by the copyright owner or by an individual or Legal Entity authorized to submit
46
+ on behalf of the copyright owner.
47
+
48
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
49
+ of whom a Contribution has been received by Licensor and subsequently
50
+ incorporated within the Work.
51
+
52
+ 2. Grant of Copyright License.
53
+
54
+ Subject to the terms and conditions of this License, each Contributor hereby
55
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
56
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
57
+ publicly display, publicly perform, sublicense, and distribute the Work and such
58
+ Derivative Works in Source or Object form.
59
+
60
+ 3. Grant of Patent License.
61
+
62
+ Subject to the terms and conditions of this License, each Contributor hereby
63
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
64
+ irrevocable patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution.
68
+
69
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
70
+ in any medium, with or without modifications, and in Source or Object form,
71
+ provided that You meet the following conditions:
72
+
73
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
74
+ this License; and
75
+
76
+ (b) You must cause any modified files to carry prominent notices stating that
77
+ You changed the files; and
78
+
79
+ (c) You must retain, in the Source form of any Derivative Works that You
80
+ distribute, all copyright, patent, trademark, and attribution notices from the
81
+ Source form of the Work, excluding those notices that do not pertain to any part
82
+ of the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
85
+ any Derivative Works that You distribute must include a readable copy of the
86
+ attribution notices contained within such NOTICE file, excluding those notices
87
+ that do not pertain to any part of the Derivative Works.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
92
+ for inclusion in the Work by You to the Licensor shall be under the terms and
93
+ conditions of this License, without any additional terms or conditions.
94
+
95
+ 6. Trademarks.
96
+
97
+ This License does not grant permission to use the trade names, trademarks,
98
+ service marks, or product names of the Licensor, except as required for
99
+ reasonable and customary use in describing the origin of the Work.
100
+
101
+ 7. Disclaimer of Warranty.
102
+
103
+ Unless required by applicable law or agreed to in writing, Licensor provides the
104
+ Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
105
+ express or implied, including, without limitation, any warranties or conditions
106
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
107
+ PURPOSE.
108
+
109
+ 8. Limitation of Liability.
110
+
111
+ In no event and under no legal theory, whether in tort (including negligence),
112
+ contract, or otherwise, unless required by applicable law, shall any Contributor
113
+ be liable to You for damages, including any direct, indirect, special,
114
+ incidental, or consequential damages of any character arising as a result of this
115
+ License or out of the use or inability to use the Work.
116
+
117
+ 9. Accepting Warranty or Additional Liability.
118
+
119
+ While redistributing the Work or Derivative Works thereof, You may choose to
120
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
121
+ other liability obligations and/or rights consistent with this License.
122
+
123
+ END OF TERMS AND CONDITIONS
@@ -1,4 +1,9 @@
1
1
  export { SemanticAnalyzer, analyze } from './analyzer.js';
2
2
  export { SemanticLayer, parseMetricDefinition, parseDimensionDefinition, parseHierarchyDefinition, parseBlockCompanionDefinition, parseCubeDefinition, } from './semantic-layer.js';
3
3
  export type { MetricDefinition, DimensionDefinition, HierarchyDefinition, BlockCompanionDefinition, HierarchyLevelDefinition, HierarchyDrillPathDefinition, HierarchyRollupType, SemanticLayerConfig, JoinDefinition, TimeDimensionDefinition, CubeDefinition, ComposeQueryOptions, ComposeQueryResult, } from './semantic-layer.js';
4
+ export { loadSemanticLayerFromDir, loadSemanticLayerFromConfig, } from './yaml-loader.js';
5
+ export { resolveSemanticLayer } from './providers/index.js';
6
+ export type { SemanticLayerProviderConfig } from './providers/index.js';
7
+ export { getDialect, listDialectDrivers } from './sql-dialect.js';
8
+ export type { SQLDialect } from './sql-dialect.js';
4
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,3 +1,6 @@
1
1
  export { SemanticAnalyzer, analyze } from './analyzer.js';
2
2
  export { SemanticLayer, parseMetricDefinition, parseDimensionDefinition, parseHierarchyDefinition, parseBlockCompanionDefinition, parseCubeDefinition, } from './semantic-layer.js';
3
+ export { loadSemanticLayerFromDir, loadSemanticLayerFromConfig, } from './yaml-loader.js';
4
+ export { resolveSemanticLayer } from './providers/index.js';
5
+ export { getDialect, listDialectDrivers } from './sql-dialect.js';
3
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/semantic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAgB7B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Cube.js semantic layer provider.
3
+ * Reads Cube.js YAML schema format and maps cubes to DQL SemanticLayer definitions.
4
+ */
5
+ import { SemanticLayer } from '../semantic-layer.js';
6
+ import type { SemanticLayerProvider, SemanticLayerProviderConfig } from './provider.js';
7
+ export declare class CubejsProvider implements SemanticLayerProvider {
8
+ readonly name = "cubejs";
9
+ load(config: SemanticLayerProviderConfig, projectRoot: string): SemanticLayer;
10
+ }
11
+ //# sourceMappingURL=cubejs-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubejs-provider.d.ts","sourceRoot":"","sources":["../../../src/semantic/providers/cubejs-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAkExF,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,QAAQ,CAAC,IAAI,YAAY;IAEzB,IAAI,CAAC,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa;CAyC9E"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Cube.js semantic layer provider.
3
+ * Reads Cube.js YAML schema format and maps cubes to DQL SemanticLayer definitions.
4
+ */
5
+ import { readFileSync, readdirSync, existsSync, statSync } from 'node:fs';
6
+ import { join, extname } from 'node:path';
7
+ import * as yaml from 'js-yaml';
8
+ import { SemanticLayer, } from '../semantic-layer.js';
9
+ /** Map Cube.js measure types to DQL metric types. */
10
+ const MEASURE_TYPE_MAP = {
11
+ count: 'count',
12
+ count_distinct: 'count_distinct',
13
+ countDistinct: 'count_distinct',
14
+ sum: 'sum',
15
+ avg: 'avg',
16
+ min: 'min',
17
+ max: 'max',
18
+ number: 'custom',
19
+ };
20
+ /** Map Cube.js dimension types to DQL dimension types. */
21
+ const DIM_TYPE_MAP = {
22
+ string: 'string',
23
+ number: 'number',
24
+ boolean: 'boolean',
25
+ time: 'date',
26
+ geo: 'string',
27
+ };
28
+ /** Map Cube.js relationship types to DQL join types. */
29
+ const JOIN_TYPE_MAP = {
30
+ one_to_one: 'inner',
31
+ one_to_many: 'left',
32
+ many_to_one: 'left',
33
+ many_to_many: 'full',
34
+ // Also support camelCase variants
35
+ oneToOne: 'inner',
36
+ oneToMany: 'left',
37
+ manyToOne: 'left',
38
+ manyToMany: 'full',
39
+ };
40
+ export class CubejsProvider {
41
+ name = 'cubejs';
42
+ load(config, projectRoot) {
43
+ const layer = new SemanticLayer();
44
+ const cubeRoot = config.projectPath
45
+ ? join(projectRoot, config.projectPath)
46
+ : projectRoot;
47
+ // Cube.js stores schemas in model/ or schema/ directory
48
+ let schemaDir;
49
+ for (const candidate of ['model', 'schema']) {
50
+ const candidatePath = join(cubeRoot, candidate);
51
+ if (existsSync(candidatePath)) {
52
+ schemaDir = candidatePath;
53
+ break;
54
+ }
55
+ }
56
+ if (!schemaDir)
57
+ return layer;
58
+ const yamlFiles = collectYamlFiles(schemaDir);
59
+ for (const filePath of yamlFiles) {
60
+ try {
61
+ const content = readFileSync(filePath, 'utf-8');
62
+ const doc = yaml.load(content);
63
+ if (!doc || typeof doc !== 'object')
64
+ continue;
65
+ if (Array.isArray(doc.cubes)) {
66
+ for (const rawCube of doc.cubes) {
67
+ if (rawCube && typeof rawCube === 'object') {
68
+ const cube = convertCube(rawCube);
69
+ layer.addCube(cube);
70
+ }
71
+ }
72
+ }
73
+ }
74
+ catch {
75
+ // Skip malformed YAML files
76
+ }
77
+ }
78
+ return layer;
79
+ }
80
+ }
81
+ /** Recursively collect all .yml/.yaml files in a directory. */
82
+ function collectYamlFiles(dir) {
83
+ const results = [];
84
+ if (!existsSync(dir))
85
+ return results;
86
+ for (const entry of readdirSync(dir)) {
87
+ const fullPath = join(dir, entry);
88
+ try {
89
+ const stat = statSync(fullPath);
90
+ if (stat.isDirectory()) {
91
+ results.push(...collectYamlFiles(fullPath));
92
+ }
93
+ else if (stat.isFile()) {
94
+ const ext = extname(entry).toLowerCase();
95
+ if (ext === '.yml' || ext === '.yaml') {
96
+ results.push(fullPath);
97
+ }
98
+ }
99
+ }
100
+ catch {
101
+ // Skip inaccessible entries
102
+ }
103
+ }
104
+ return results;
105
+ }
106
+ /** Convert a Cube.js cube definition to a DQL CubeDefinition. */
107
+ function convertCube(raw) {
108
+ const cubeName = raw.name;
109
+ const tableName = raw.sql_table ?? raw.sqlTable ?? cubeName;
110
+ const measures = (raw.measures ?? []).map((m) => {
111
+ const aggType = MEASURE_TYPE_MAP[m.type] ?? 'custom';
112
+ const sqlExpr = m.sql ?? m.name;
113
+ return {
114
+ name: m.name,
115
+ label: m.title ?? m.name,
116
+ description: m.description ?? '',
117
+ domain: '',
118
+ sql: buildAggSql(aggType, sqlExpr),
119
+ type: aggType,
120
+ table: tableName,
121
+ };
122
+ });
123
+ const dimensions = [];
124
+ const timeDimensions = [];
125
+ for (const dim of raw.dimensions ?? []) {
126
+ const dqlType = DIM_TYPE_MAP[dim.type] ?? 'string';
127
+ const sqlExpr = dim.sql ?? dim.name;
128
+ if (dim.type === 'time') {
129
+ timeDimensions.push({
130
+ name: dim.name,
131
+ label: dim.title ?? dim.name,
132
+ description: dim.description ?? '',
133
+ sql: sqlExpr,
134
+ type: 'date',
135
+ table: tableName,
136
+ granularities: ['day', 'week', 'month', 'quarter', 'year'],
137
+ primaryTime: Boolean(dim.primary_key ?? dim.primaryKey),
138
+ });
139
+ }
140
+ else {
141
+ dimensions.push({
142
+ name: dim.name,
143
+ label: dim.title ?? dim.name,
144
+ description: dim.description ?? '',
145
+ sql: sqlExpr,
146
+ type: dqlType,
147
+ table: tableName,
148
+ });
149
+ }
150
+ }
151
+ // Convert joins, replacing Cube.js template variables
152
+ const joins = (raw.joins ?? []).map((j) => {
153
+ // Replace {CUBE} with the current cube name and {OtherCube} with the join target
154
+ let resolvedSql = j.sql
155
+ .replace(/\{CUBE\}/g, tableName)
156
+ .replace(new RegExp(`\\{${j.name}\\}`, 'g'), j.name);
157
+ return {
158
+ name: j.name,
159
+ left: cubeName,
160
+ right: j.name,
161
+ type: JOIN_TYPE_MAP[j.relationship] ?? 'left',
162
+ sql: resolvedSql,
163
+ };
164
+ });
165
+ return {
166
+ name: cubeName,
167
+ label: raw.title ?? cubeName,
168
+ description: raw.description ?? '',
169
+ sql: raw.sql ?? `SELECT * FROM ${tableName}`,
170
+ table: tableName,
171
+ domain: '',
172
+ measures,
173
+ dimensions,
174
+ timeDimensions,
175
+ joins,
176
+ };
177
+ }
178
+ /** Build an aggregate SQL expression. */
179
+ function buildAggSql(aggType, expr) {
180
+ switch (aggType) {
181
+ case 'sum': return `SUM(${expr})`;
182
+ case 'count': return `COUNT(${expr})`;
183
+ case 'count_distinct': return `COUNT(DISTINCT ${expr})`;
184
+ case 'avg': return `AVG(${expr})`;
185
+ case 'min': return `MIN(${expr})`;
186
+ case 'max': return `MAX(${expr})`;
187
+ default: return expr;
188
+ }
189
+ }
190
+ //# sourceMappingURL=cubejs-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubejs-provider.js","sourceRoot":"","sources":["../../../src/semantic/providers/cubejs-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,aAAa,GAMd,MAAM,sBAAsB,CAAC;AAG9B,qDAAqD;AACrD,MAAM,gBAAgB,GAA6C;IACjE,KAAK,EAAE,OAAO;IACd,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;IAC/B,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,YAAY,GAAgD;IAChE,MAAM,EAAE,QAAQ;I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;YACd,KAAK,EAAE,CAAC,CAAC,IAAI;YACb,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,MAAM;YAC7C,GAAG,EAAE,WAAW;SACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,QAAQ;QAC5B,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE;QAClC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,iBAAiB,SAAS,EAAE;QAC5C,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,EAAE;QACV,QAAQ;QACR,UAAU;QACV,cAAc;QACd,KAAK;KACN,CAAC;AACJ,CAAC;AAED,yCAAyC;AACzC,SAAS,WAAW,CAAC,OAAiC,EAAE,IAAY;IAClE,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,KAAK,CAAC,CAAC,OAAO,OAAO,IAAI,GAAG,CAAC;QAClC,KAAK,OAAO,CAAC,CAAC,OAAO,SAAS,IAAI,GAAG,CAAC;QACtC,KAAK,gBAAgB,CAAC,CAAC,OAAO,kBAAkB,IAAI,GAAG,CAAC;QACxD,KAAK,KAAK,CAAC,CAAC,OAAO,OAAO,IAAI,GAAG,CAAC;QAClC,KAAK,KAAK,CAAC,CAAC,OAAO,OAAO,IAAI,GAAG,CAAC;QAClC,KAAK,KAAK,CAAC,CAAC,OAAO,OAAO,IAAI,GAAG,CAAC;QAClC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * dbt semantic layer provider.
3
+ * Reads dbt's native YAML format (semantic_models + metrics) and maps
4
+ * them to DQL SemanticLayer definitions.
5
+ */
6
+ import { SemanticLayer } from '../semantic-layer.js';
7
+ import type { SemanticLayerProvider, SemanticLayerProviderConfig } from './provider.js';
8
+ export declare class DbtProvider implements SemanticLayerProvider {
9
+ readonly name = "dbt";
10
+ load(config: SemanticLayerProviderConfig, projectRoot: string): SemanticLayer;
11
+ }
12
+ //# sourceMappingURL=dbt-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dbt-provider.d.ts","sourceRoot":"","sources":["../../../src/semantic/providers/dbt-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAuDxF,qBAAa,WAAY,YAAW,qBAAqB;IACvD,QAAQ,CAAC,IAAI,SAAS;IAEtB,IAAI,CAAC,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa;CAyE9E"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * dbt semantic layer provider.
3
+ * Reads dbt's native YAML format (semantic_models + metrics) and maps
4
+ * them to DQL SemanticLayer definitions.
5
+ */
6
+ import { readFileSync, readdirSync, existsSync, statSync } from 'node:fs';
7
+ import { join, extname } from 'node:path';
8
+ import * as yaml from 'js-yaml';
9
+ import { SemanticLayer, } from '../semantic-layer.js';
10
+ /** Map dbt aggregation types to DQL metric types. */
11
+ const AGG_TYPE_MAP = {
12
+ sum: 'sum',
13
+ count: 'count',
14
+ count_distinct: 'count_distinct',
15
+ average: 'avg',
16
+ avg: 'avg',
17
+ min: 'min',
18
+ max: 'max',
19
+ };
20
+ /** Map dbt dimension types to DQL dimension types. */
21
+ const DIM_TYPE_MAP = {
22
+ categorical: 'string',
23
+ time: 'date',
24
+ boolean: 'boolean',
25
+ number: 'number',
26
+ };
27
+ export class DbtProvider {
28
+ name = 'dbt';
29
+ load(config, projectRoot) {
30
+ const layer = new SemanticLayer();
31
+ const dbtRoot = config.projectPath
32
+ ? join(projectRoot, config.projectPath)
33
+ : projectRoot;
34
+ const modelsDir = join(dbtRoot, 'models');
35
+ if (!existsSync(modelsDir))
36
+ return layer;
37
+ // Collect all YAML files recursively
38
+ const yamlFiles = collectYamlFiles(modelsDir);
39
+ // First pass: collect all semantic models so we can resolve measure references
40
+ const allModels = [];
41
+ const allDbtMetrics = [];
42
+ for (const filePath of yamlFiles) {
43
+ try {
44
+ const content = readFileSync(filePath, 'utf-8');
45
+ const doc = yaml.load(content);
46
+ if (!doc || typeof doc !== 'object')
47
+ continue;
48
+ if (Array.isArray(doc.semantic_models)) {
49
+ for (const model of doc.semantic_models) {
50
+ if (model && typeof model === 'object') {
51
+ allModels.push(model);
52
+ }
53
+ }
54
+ }
55
+ if (Array.isArray(doc.metrics)) {
56
+ for (const metric of doc.metrics) {
57
+ if (metric && typeof metric === 'object') {
58
+ allDbtMetrics.push(metric);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ catch {
64
+ // Skip malformed YAML files
65
+ }
66
+ }
67
+ // Build a measure lookup: measure_name -> { sql, agg, model_name }
68
+ const measureLookup = new Map();
69
+ for (const model of allModels) {
70
+ const tableName = resolveTableName(model);
71
+ for (const measure of model.measures ?? []) {
72
+ measureLookup.set(measure.name, {
73
+ sql: measure.expr ?? measure.name,
74
+ agg: measure.agg,
75
+ modelName: model.name,
76
+ table: tableName,
77
+ });
78
+ }
79
+ }
80
+ // Convert each semantic model into a DQL CubeDefinition
81
+ for (const model of allModels) {
82
+ const cube = convertSemanticModel(model);
83
+ layer.addCube(cube);
84
+ }
85
+ // Convert dbt metrics (resolve measure references)
86
+ for (const dbtMetric of allDbtMetrics) {
87
+ const metric = convertDbtMetric(dbtMetric, measureLookup);
88
+ if (metric) {
89
+ layer.addMetric(metric);
90
+ }
91
+ }
92
+ return layer;
93
+ }
94
+ }
95
+ /** Recursively collect all .yml/.yaml files in a directory. */
96
+ function collectYamlFiles(dir) {
97
+ const results = [];
98
+ if (!existsSync(dir))
99
+ return results;
100
+ for (const entry of readdirSync(dir)) {
101
+ const fullPath = join(dir, entry);
102
+ try {
103
+ const stat = statSync(fullPath);
104
+ if (stat.isDirectory()) {
105
+ results.push(...collectYamlFiles(fullPath));
106
+ }
107
+ else if (stat.isFile()) {
108
+ const ext = extname(entry).toLowerCase();
109
+ if (ext === '.yml' || ext === '.yaml') {
110
+ results.push(fullPath);
111
+ }
112
+ }
113
+ }
114
+ catch {
115
+ // Skip inaccessible entries
116
+ }
117
+ }
118
+ return results;
119
+ }
120
+ /** Extract a table name from a dbt semantic model. */
121
+ function resolveTableName(model) {
122
+ if (model.model) {
123
+ // dbt model refs look like "ref('stg_orders')" - extract the model name
124
+ const match = model.model.match(/ref\(['"](.+?)['"]\)/);
125
+ if (match)
126
+ return match[1];
127
+ return model.model;
128
+ }
129
+ return model.name;
130
+ }
131
+ /** Convert a dbt semantic model to a DQL CubeDefinition. */
132
+ function convertSemanticModel(model) {
133
+ const tableName = resolveTableName(model);
134
+ const measures = (model.measures ?? []).map((m) => ({
135
+ name: m.name,
136
+ label: m.name,
137
+ description: m.description ?? '',
138
+ domain: '',
139
+ sql: buildAggSql(m.agg, m.expr ?? m.name),
140
+ type: AGG_TYPE_MAP[m.agg] ?? 'custom',
141
+ table: tableName,
142
+ }));
143
+ const dimensions = [];
144
+ const timeDimensions = [];
145
+ for (const dim of model.dimensions ?? []) {
146
+ const dqlType = DIM_TYPE_MAP[dim.type] ?? 'string';
147
+ const sqlExpr = dim.expr ?? dim.name;
148
+ if (dim.type === 'time') {
149
+ const granularity = dim.type_params?.time_granularity ?? 'day';
150
+ const validGranularities = ['day', 'week', 'month', 'quarter', 'year'];
151
+ const defaultGrans = ['day', 'week', 'month', 'quarter', 'year'];
152
+ const isPrimary = model.defaults?.agg_time_dimension === dim.name;
153
+ timeDimensions.push({
154
+ name: dim.name,
155
+ label: dim.name,
156
+ description: '',
157
+ sql: sqlExpr,
158
+ type: 'date',
159
+ table: tableName,
160
+ granularities: defaultGrans,
161
+ primaryTime: isPrimary,
162
+ });
163
+ }
164
+ else {
165
+ dimensions.push({
166
+ name: dim.name,
167
+ label: dim.name,
168
+ description: '',
169
+ sql: sqlExpr,
170
+ type: dqlType,
171
+ table: tableName,
172
+ });
173
+ }
174
+ }
175
+ // Convert entities with foreign type to joins
176
+ const joins = [];
177
+ for (const entity of model.entities ?? []) {
178
+ if (entity.type === 'foreign') {
179
+ joins.push({
180
+ name: entity.name,
181
+ left: model.name,
182
+ right: entity.name,
183
+ type: 'left',
184
+ sql: `\${left}.${entity.expr ?? entity.name} = \${right}.${entity.name}`,
185
+ });
186
+ }
187
+ }
188
+ return {
189
+ name: model.name,
190
+ label: model.name,
191
+ description: '',
192
+ sql: `SELECT * FROM ${tableName}`,
193
+ table: tableName,
194
+ domain: '',
195
+ measures,
196
+ dimensions,
197
+ timeDimensions,
198
+ joins,
199
+ defaultTimeDimension: model.defaults?.agg_time_dimension,
200
+ };
201
+ }
202
+ /** Build an aggregate SQL expression from a dbt agg type and expression. */
203
+ function buildAggSql(agg, expr) {
204
+ switch (agg) {
205
+ case 'sum': return `SUM(${expr})`;
206
+ case 'count': return `COUNT(${expr})`;
207
+ case 'count_distinct': return `COUNT(DISTINCT ${expr})`;
208
+ case 'average':
209
+ case 'avg': return `AVG(${expr})`;
210
+ case 'min': return `MIN(${expr})`;
211
+ case 'max': return `MAX(${expr})`;
212
+ default: return expr;
213
+ }
214
+ }
215
+ /** Convert a dbt metric definition to a DQL MetricDefinition. */
216
+ function convertDbtMetric(dbtMetric, measureLookup) {
217
+ const measureName = dbtMetric.type_params?.measure;
218
+ if (!measureName)
219
+ return null;
220
+ const measureInfo = measureLookup.get(measureName);
221
+ if (!measureInfo)
222
+ return null;
223
+ return {
224
+ name: dbtMetric.name,
225
+ label: dbtMetric.label ?? dbtMetric.name,
226
+ description: dbtMetric.description ?? '',
227
+ domain: '',
228
+ sql: buildAggSql(measureInfo.agg, measureInfo.sql),
229
+ type: AGG_TYPE_MAP[measureInfo.agg] ?? 'custom',
230
+ table: measureInfo.table,
231
+ };
232
+ }
233
+ //# sourceMappingURL=dbt-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3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I,GAAG,CAAC;QAClC,KAAK,KAAK,CAAC,CAAC,OAAO,OAAO,IAAI,GAAG,CAAC;QAClC,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC;IACvB,CAAC;AACH,CAAC;AAED,iEAAiE;AACjE,SAAS,gBAAgB,CACvB,SAAoB,EACpB,aAA0F;IAE1F,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC;IACnD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAE9B,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAE9B,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI;QACxC,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,EAAE;QACxC,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC;QAClD,IAAI,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,QAAQ;QAC/C,KAAK,EAAE,WAAW,CAAC,KAAK;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * DQL Native semantic layer provider.
3
+ * Reads from the project's semantic-layer/ directory using the existing YAML loader.
4
+ */
5
+ import type { SemanticLayerProvider, SemanticLayerProviderConfig } from './provider.js';
6
+ import type { SemanticLayer } from '../semantic-layer.js';
7
+ export declare class DqlProvider implements SemanticLayerProvider {
8
+ readonly name = "dql";
9
+ load(config: SemanticLayerProviderConfig, projectRoot: string): SemanticLayer;
10
+ }
11
+ //# sourceMappingURL=dql-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dql-provider.d.ts","sourceRoot":"","sources":["../../../src/semantic/providers/dql-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,WAAY,YAAW,qBAAqB;IACvD,QAAQ,CAAC,IAAI,SAAS;IAEtB,IAAI,CAAC,MAAM,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa;CAM9E"}