react-semaphor 0.1.328 → 0.1.330
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/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +211 -72
- package/dist/types/analytics-protocol.d.ts +76 -1
- package/dist/types/dashboard-authoring.d.ts +2 -1
- package/dist/types/data-app-builder.d.ts +2 -1
- package/dist/types/data-app-sdk.d.ts +2 -1
- package/dist/types/main.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../chunks/validators-odlRJblR.js");function s(e){return typeof e=="string"?e.trim().toLowerCase():""}function g(e){return String(e.column_name||e.name||e.qualifiedFieldName||"")}function y(e){return Array.from(new Set([e.column_name,e.name,e.qualifiedFieldName,e.alias].filter(a=>typeof a=="string"&&a.trim().length>0).map(a=>a.trim())))}function u(e){const a=s(e);return a?a.includes("int")||a.includes("numeric")||a.includes("decimal")||a.includes("double")||a.includes("float")||a.includes("number")||a.includes("real")||a.includes("money")?"number":a.includes("timestamp")||a.includes("datetime")||a==="time"||a.startsWith("time ")?"datetime":a.includes("date")?"date":a.includes("bool")?"boolean":"string":"unknown"}function h(e){const a=u(e);return a==="date"||a==="datetime"}function m(e){return h(e.dataType||e.data_type)}function p(e){const a=v(e);return a==="id"||a==="row_id"}function d(e){const a=v(e);return p(e)||a.endsWith("_id")||a.endsWith("_key")||a.endsWith("_number")}function v(e){return s(g(e)||e.name||e.alias).replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function f(e,a={}){const t=s(e.role);return t==="metric"||t==="measure"?!a.excludeIdentifiers||!d(e):t==="groupby"||t==="dimension"||t==="date"||t==="id"?!1:u(e.dataType||e.data_type)==="number"&&(!a.excludeIdentifiers||!d(e))}function A(e){return!f(e)&&!m(e)}function S(e){return[e.column_name,e.name,e.label,e.alias,e.qualifiedFieldName].filter(a=>typeof a=="string"&&a.trim().length>0).map(a=>s(a).replace(/[^a-z0-9]+/g," ")).join(" ")}function c(e,a){return a.some(t=>{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(^|\\s)${i}(\\s|$)`,"i").test(e)})}function T(e){const a=S(e);if(a)return c(a,["pct","percent","percentage","rate","ratio","share","conversion","retention","churn","growth","margin rate","margin pct","margin percent","margin percentage"])?{type:"percent",minimumFractionDigits:0,maximumFractionDigits:1,percentValueMode:"fraction"}:c(a,["revenue","sales","profit","arr","mrr","gmv","amount","price","cost","spend","expense","budget","income","value","booking","bookings"])?{type:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:1,compact:!0}:c(a,["count","quantity","orders","order","users","customers","tickets","units","sessions","visits","items","rows"])?{type:"number",minimumFractionDigits:0,maximumFractionDigits:0,compact:!0}:{type:"number",minimumFractionDigits:0,maximumFractionDigits:1,compact:!0}}function k(e){const a=new Set,t=new Set,i=new Set;for(const o of e){if(p(o))continue;const l=y(o);if(l.length!==0){if(m(o)){l.forEach(r=>t.add(r));continue}if(f(o,{excludeIdentifiers:!0})){l.forEach(r=>a.add(r));continue}l.forEach(r=>i.add(r))}}return{validMetricCandidates:Array.from(a).sort(),validDateCandidates:Array.from(t).sort(),validDimensionCandidates:Array.from(i).sort()}}function D(e,a={}){const t=F(e),i={connectionId:a.connectionId,connectionType:e,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return t.includes("postgres")?{...i,prefixLevels:["schema","table"],dialect:"postgres"}:t.includes("mysql")?{...i,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:t.includes("mssql")||t.includes("sqlserver")?{...i,dialect:"mssql",supportsFilterClause:!1}:t.includes("redshift")?{...i,prefixLevels:["schema","table"],dialect:"redshift"}:t.includes("snowflake")?{...i,dialect:"snowflake"}:t.includes("clickhouse")?{connectionId:a.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:t==="s3"||t==="api"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:t==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:t==="googlesheets"||t==="fileupload"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:t==="s3tables"?{...i,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:t==="bigquery"?{...i,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:i}function I(e){const a=F(e);switch(a){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return a;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";case"semantic":return"semantic";default:return"unknown"}}function q(e){return e.capabilities.prefixLevels.every(a=>!!C(e.source,a))}function _(e){const a=e.quoteIdentifier??N;return e.capabilities.prefixLevels.map(t=>C(e.source,t)).filter(t=>!!t).map(t=>a(t,e.capabilities.dialect)).join(".")}function C(e,a){return a==="database"?e.databaseName:a==="schema"?e.schemaName:e.tableName}function N(e,a){return a==="mysql"||a==="bigquery"||a==="clickhouse"||a==="duckdb"?`\`${e.replace(/`/g,"``")}\``:a==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function F(e){if(typeof e!="string")return"";const a=[];for(const t of e.trim().toLowerCase())x(t)&&a.push(t);return a.join("")}function x(e){const a=e.charCodeAt(0);return a>=48&&a<=57||a>=97&&a<=122}const n={kind:"semantic",domainId:"domain_sales",datasetName:"orders",connectionId:"conn_sales",label:"Orders"},L={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:n,metric:"revenue",comparison:{kind:"previous_period"},limit:1},revenueTrend:{version:1,kind:"records",id:"revenue-trend",label:"Revenue trend",source:n,fields:[{name:"order_date",role:"date",dataType:"date",label:"Order Date"}],measures:["revenue"],dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"month",limit:100},topCustomersRecords:{version:1,kind:"records",id:"top-customers",label:"Top customers",source:n,fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"segment",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}],measures:["revenue"],orderBy:{field:"revenue",direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",source:n,field:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:n,metric:"revenue",dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"physical",connectionId:"conn_sales",databaseName:"warehouse",schemaName:"public",tableName:"orders",dialect:"postgres"},sql:"SELECT customer_name, SUM(revenue) AS revenue FROM public.orders GROUP BY customer_name ORDER BY revenue DESC LIMIT 20",limit:20,rationale:"Ranking is SQL-natural because it requires ordering grouped aggregate rows.",fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}]}};exports.validateSemaphorAnalyticsIntent=b.validateSemaphorAnalyticsIntent;exports.validateSemaphorDashboardIntent=b.validateSemaphorDashboardIntent;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=L;exports.buildAnalyticsCatalogFieldSummary=k;exports.buildSemaphorQualifiedSourcePath=_;exports.getAnalyticsCatalogFieldCandidates=y;exports.getAnalyticsCatalogFieldName=g;exports.getSemaphorConnectionCapabilities=D;exports.inferAnalyticsMetricFormat=T;exports.isAnalyticsCatalogDateField=m;exports.isAnalyticsCatalogDimensionField=A;exports.isAnalyticsCatalogMetricField=f;exports.isAnalyticsDateLikeDataType=h;exports.isAnalyticsMetricIdentifierField=d;exports.isAnalyticsTechnicalIdentifierField=p;exports.normalizeAnalyticsCatalogDataType=u;exports.normalizeAnalyticsCatalogName=s;exports.normalizeSemaphorDialect=I;exports.semaphorSourceHasRequiredCoordinates=q;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { v as
|
|
2
|
-
function
|
|
1
|
+
import { v as R, a as z } from "../chunks/validators-DDAweCzB.js";
|
|
2
|
+
function c(e) {
|
|
3
3
|
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function h(e) {
|
|
6
6
|
return String(e.column_name || e.name || e.qualifiedFieldName || "");
|
|
7
7
|
}
|
|
8
8
|
function v(e) {
|
|
@@ -14,45 +14,45 @@ function v(e) {
|
|
|
14
14
|
e.qualifiedFieldName,
|
|
15
15
|
e.alias
|
|
16
16
|
].filter(
|
|
17
|
-
(
|
|
18
|
-
).map((
|
|
17
|
+
(t) => typeof t == "string" && t.trim().length > 0
|
|
18
|
+
).map((t) => t.trim())
|
|
19
19
|
)
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return
|
|
22
|
+
function d(e) {
|
|
23
|
+
const t = c(e);
|
|
24
|
+
return t ? t.includes("int") || t.includes("numeric") || t.includes("decimal") || t.includes("double") || t.includes("float") || t.includes("number") || t.includes("real") || t.includes("money") ? "number" : t.includes("timestamp") || t.includes("datetime") || t === "time" || t.startsWith("time ") ? "datetime" : t.includes("date") ? "date" : t.includes("bool") ? "boolean" : "string" : "unknown";
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
return
|
|
26
|
+
function C(e) {
|
|
27
|
+
const t = d(e);
|
|
28
|
+
return t === "date" || t === "datetime";
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function m(e) {
|
|
31
|
+
return C(e.dataType || e.data_type);
|
|
32
32
|
}
|
|
33
33
|
function p(e) {
|
|
34
|
-
const
|
|
35
|
-
return
|
|
34
|
+
const t = f(e);
|
|
35
|
+
return t === "id" || t === "row_id";
|
|
36
36
|
}
|
|
37
37
|
function u(e) {
|
|
38
|
-
const
|
|
39
|
-
return p(e) ||
|
|
38
|
+
const t = f(e);
|
|
39
|
+
return p(e) || t.endsWith("_id") || t.endsWith("_key") || t.endsWith("_number");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
|
|
41
|
+
function f(e) {
|
|
42
|
+
return c(
|
|
43
|
+
h(e) || e.name || e.alias
|
|
44
44
|
).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return
|
|
46
|
+
function b(e, t = {}) {
|
|
47
|
+
const a = c(e.role);
|
|
48
|
+
return a === "metric" || a === "measure" ? !t.excludeIdentifiers || !u(e) : a === "groupby" || a === "dimension" || a === "date" || a === "id" ? !1 : d(
|
|
49
49
|
e.dataType || e.data_type
|
|
50
|
-
) === "number" && (!
|
|
50
|
+
) === "number" && (!t.excludeIdentifiers || !u(e));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return !
|
|
52
|
+
function q(e) {
|
|
53
|
+
return !b(e) && !m(e);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function k(e) {
|
|
56
56
|
return [
|
|
57
57
|
e.column_name,
|
|
58
58
|
e.name,
|
|
@@ -60,21 +60,21 @@ function T(e) {
|
|
|
60
60
|
e.alias,
|
|
61
61
|
e.qualifiedFieldName
|
|
62
62
|
].filter(
|
|
63
|
-
(
|
|
63
|
+
(t) => typeof t == "string" && t.trim().length > 0
|
|
64
64
|
).map(
|
|
65
|
-
(
|
|
65
|
+
(t) => c(t).replace(/[^a-z0-9]+/g, " ")
|
|
66
66
|
).join(" ");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
70
|
-
const
|
|
71
|
-
return new RegExp(`(^|\\s)${
|
|
68
|
+
function l(e, t) {
|
|
69
|
+
return t.some((a) => {
|
|
70
|
+
const r = a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
71
|
+
return new RegExp(`(^|\\s)${r}(\\s|$)`, "i").test(e);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
74
|
+
function D(e) {
|
|
75
|
+
const t = k(e);
|
|
76
|
+
if (t)
|
|
77
|
+
return l(t, [
|
|
78
78
|
"pct",
|
|
79
79
|
"percent",
|
|
80
80
|
"percentage",
|
|
@@ -94,7 +94,7 @@ function F(e) {
|
|
|
94
94
|
minimumFractionDigits: 0,
|
|
95
95
|
maximumFractionDigits: 1,
|
|
96
96
|
percentValueMode: "fraction"
|
|
97
|
-
} :
|
|
97
|
+
} : l(t, [
|
|
98
98
|
"revenue",
|
|
99
99
|
"sales",
|
|
100
100
|
"profit",
|
|
@@ -117,7 +117,7 @@ function F(e) {
|
|
|
117
117
|
minimumFractionDigits: 0,
|
|
118
118
|
maximumFractionDigits: 1,
|
|
119
119
|
compact: !0
|
|
120
|
-
} :
|
|
120
|
+
} : l(t, [
|
|
121
121
|
"count",
|
|
122
122
|
"quantity",
|
|
123
123
|
"orders",
|
|
@@ -142,43 +142,178 @@ function F(e) {
|
|
|
142
142
|
compact: !0
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
const
|
|
147
|
-
for (const
|
|
148
|
-
if (p(
|
|
145
|
+
function I(e) {
|
|
146
|
+
const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
147
|
+
for (const s of e) {
|
|
148
|
+
if (p(s))
|
|
149
149
|
continue;
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
if (
|
|
153
|
-
|
|
150
|
+
const o = v(s);
|
|
151
|
+
if (o.length !== 0) {
|
|
152
|
+
if (m(s)) {
|
|
153
|
+
o.forEach((i) => a.add(i));
|
|
154
154
|
continue;
|
|
155
155
|
}
|
|
156
|
-
if (
|
|
157
|
-
|
|
156
|
+
if (b(s, { excludeIdentifiers: !0 })) {
|
|
157
|
+
o.forEach((i) => t.add(i));
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
o.forEach((i) => r.add(i));
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
return {
|
|
164
|
-
validMetricCandidates: Array.from(
|
|
165
|
-
validDateCandidates: Array.from(
|
|
166
|
-
validDimensionCandidates: Array.from(
|
|
164
|
+
validMetricCandidates: Array.from(t).sort(),
|
|
165
|
+
validDateCandidates: Array.from(a).sort(),
|
|
166
|
+
validDimensionCandidates: Array.from(r).sort()
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
function S(e, t = {}) {
|
|
170
|
+
const a = y(e), r = {
|
|
171
|
+
connectionId: t.connectionId,
|
|
172
|
+
connectionType: e,
|
|
173
|
+
path: ["database", "schema", "table"],
|
|
174
|
+
labels: {
|
|
175
|
+
database: "Database",
|
|
176
|
+
schema: "Schema",
|
|
177
|
+
table: "Table"
|
|
178
|
+
},
|
|
179
|
+
prefixLevels: ["database", "schema", "table"],
|
|
180
|
+
dialect: "postgres",
|
|
181
|
+
supportsFilterClause: !0
|
|
182
|
+
};
|
|
183
|
+
return a.includes("postgres") ? {
|
|
184
|
+
...r,
|
|
185
|
+
prefixLevels: ["schema", "table"],
|
|
186
|
+
dialect: "postgres"
|
|
187
|
+
} : a.includes("mysql") ? {
|
|
188
|
+
...r,
|
|
189
|
+
prefixLevels: ["database", "table"],
|
|
190
|
+
dialect: "mysql",
|
|
191
|
+
supportsFilterClause: !1
|
|
192
|
+
} : a.includes("mssql") || a.includes("sqlserver") ? {
|
|
193
|
+
...r,
|
|
194
|
+
dialect: "mssql",
|
|
195
|
+
supportsFilterClause: !1
|
|
196
|
+
} : a.includes("redshift") ? {
|
|
197
|
+
...r,
|
|
198
|
+
prefixLevels: ["schema", "table"],
|
|
199
|
+
dialect: "redshift"
|
|
200
|
+
} : a.includes("snowflake") ? {
|
|
201
|
+
...r,
|
|
202
|
+
dialect: "snowflake"
|
|
203
|
+
} : a.includes("clickhouse") ? {
|
|
204
|
+
connectionId: t.connectionId,
|
|
205
|
+
connectionType: e,
|
|
206
|
+
path: ["database", "table"],
|
|
207
|
+
labels: {
|
|
208
|
+
database: "Database",
|
|
209
|
+
table: "Table"
|
|
210
|
+
},
|
|
211
|
+
prefixLevels: ["database", "table"],
|
|
212
|
+
dialect: "clickhouse",
|
|
213
|
+
supportsFilterClause: !1
|
|
214
|
+
} : a === "s3" || a === "api" ? {
|
|
215
|
+
connectionId: t.connectionId,
|
|
216
|
+
connectionType: e,
|
|
217
|
+
path: ["table"],
|
|
218
|
+
labels: {
|
|
219
|
+
table: a === "api" ? "API Table" : "File Table"
|
|
220
|
+
},
|
|
221
|
+
prefixLevels: ["table"],
|
|
222
|
+
dialect: "duckdb",
|
|
223
|
+
supportsFilterClause: !0
|
|
224
|
+
} : a === "googlesheets" || a === "fileupload" ? {
|
|
225
|
+
connectionId: t.connectionId,
|
|
226
|
+
connectionType: e,
|
|
227
|
+
path: ["table"],
|
|
228
|
+
labels: {
|
|
229
|
+
table: "Table"
|
|
230
|
+
},
|
|
231
|
+
prefixLevels: ["table"],
|
|
232
|
+
dialect: "postgres",
|
|
233
|
+
supportsFilterClause: !0
|
|
234
|
+
} : a === "s3tables" ? {
|
|
235
|
+
...r,
|
|
236
|
+
labels: {
|
|
237
|
+
database: "Database",
|
|
238
|
+
schema: "Namespace",
|
|
239
|
+
table: "Table"
|
|
240
|
+
},
|
|
241
|
+
dialect: "duckdb"
|
|
242
|
+
} : a === "bigquery" ? {
|
|
243
|
+
...r,
|
|
244
|
+
labels: {
|
|
245
|
+
database: "Project",
|
|
246
|
+
schema: "Dataset",
|
|
247
|
+
table: "Table"
|
|
248
|
+
},
|
|
249
|
+
prefixLevels: ["schema", "table"],
|
|
250
|
+
dialect: "bigquery",
|
|
251
|
+
supportsFilterClause: !1
|
|
252
|
+
} : r;
|
|
253
|
+
}
|
|
254
|
+
function _(e) {
|
|
255
|
+
const t = y(e);
|
|
256
|
+
switch (t) {
|
|
257
|
+
case "mysql":
|
|
258
|
+
case "bigquery":
|
|
259
|
+
case "redshift":
|
|
260
|
+
case "snowflake":
|
|
261
|
+
case "clickhouse":
|
|
262
|
+
case "duckdb":
|
|
263
|
+
case "sqlite":
|
|
264
|
+
return t;
|
|
265
|
+
case "mssql":
|
|
266
|
+
case "sqlserver":
|
|
267
|
+
return "mssql";
|
|
268
|
+
case "postgres":
|
|
269
|
+
case "postgresql":
|
|
270
|
+
return "postgres";
|
|
271
|
+
case "semantic":
|
|
272
|
+
return "semantic";
|
|
273
|
+
default:
|
|
274
|
+
return "unknown";
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function A(e) {
|
|
278
|
+
return e.capabilities.prefixLevels.every(
|
|
279
|
+
(t) => !!g(e.source, t)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function x(e) {
|
|
283
|
+
const t = e.quoteIdentifier ?? F;
|
|
284
|
+
return e.capabilities.prefixLevels.map((a) => g(e.source, a)).filter((a) => !!a).map((a) => t(a, e.capabilities.dialect)).join(".");
|
|
285
|
+
}
|
|
286
|
+
function g(e, t) {
|
|
287
|
+
return t === "database" ? e.databaseName : t === "schema" ? e.schemaName : e.tableName;
|
|
288
|
+
}
|
|
289
|
+
function F(e, t) {
|
|
290
|
+
return t === "mysql" || t === "bigquery" || t === "clickhouse" || t === "duckdb" ? `\`${e.replace(/`/g, "``")}\`` : t === "mssql" ? `[${e.replace(/]/g, "]]")}]` : `"${e.replace(/"/g, '""')}"`;
|
|
291
|
+
}
|
|
292
|
+
function y(e) {
|
|
293
|
+
if (typeof e != "string")
|
|
294
|
+
return "";
|
|
295
|
+
const t = [];
|
|
296
|
+
for (const a of e.trim().toLowerCase())
|
|
297
|
+
T(a) && t.push(a);
|
|
298
|
+
return t.join("");
|
|
299
|
+
}
|
|
300
|
+
function T(e) {
|
|
301
|
+
const t = e.charCodeAt(0);
|
|
302
|
+
return t >= 48 && t <= 57 || t >= 97 && t <= 122;
|
|
303
|
+
}
|
|
304
|
+
const n = {
|
|
170
305
|
kind: "semantic",
|
|
171
306
|
domainId: "domain_sales",
|
|
172
307
|
datasetName: "orders",
|
|
173
308
|
connectionId: "conn_sales",
|
|
174
309
|
label: "Orders"
|
|
175
|
-
},
|
|
310
|
+
}, w = {
|
|
176
311
|
revenueKpi: {
|
|
177
312
|
version: 1,
|
|
178
313
|
kind: "metric",
|
|
179
314
|
id: "revenue-kpi",
|
|
180
315
|
label: "Revenue",
|
|
181
|
-
source:
|
|
316
|
+
source: n,
|
|
182
317
|
metric: "revenue",
|
|
183
318
|
comparison: { kind: "previous_period" },
|
|
184
319
|
limit: 1
|
|
@@ -188,7 +323,7 @@ const a = {
|
|
|
188
323
|
kind: "records",
|
|
189
324
|
id: "revenue-trend",
|
|
190
325
|
label: "Revenue trend",
|
|
191
|
-
source:
|
|
326
|
+
source: n,
|
|
192
327
|
fields: [
|
|
193
328
|
{ name: "order_date", role: "date", dataType: "date", label: "Order Date" }
|
|
194
329
|
],
|
|
@@ -202,7 +337,7 @@ const a = {
|
|
|
202
337
|
kind: "records",
|
|
203
338
|
id: "top-customers",
|
|
204
339
|
label: "Top customers",
|
|
205
|
-
source:
|
|
340
|
+
source: n,
|
|
206
341
|
fields: [
|
|
207
342
|
{ name: "customer_name", role: "dimension", dataType: "string" },
|
|
208
343
|
{ name: "segment", role: "dimension", dataType: "string" },
|
|
@@ -217,7 +352,7 @@ const a = {
|
|
|
217
352
|
kind: "inputOptions",
|
|
218
353
|
id: "region-options",
|
|
219
354
|
label: "Region options",
|
|
220
|
-
source:
|
|
355
|
+
source: n,
|
|
221
356
|
field: { name: "region", role: "dimension", dataType: "string" },
|
|
222
357
|
limit: 100
|
|
223
358
|
},
|
|
@@ -226,7 +361,7 @@ const a = {
|
|
|
226
361
|
kind: "metric",
|
|
227
362
|
id: "revenue-previous-period",
|
|
228
363
|
label: "Revenue previous period comparison",
|
|
229
|
-
source:
|
|
364
|
+
source: n,
|
|
230
365
|
metric: "revenue",
|
|
231
366
|
dateField: { name: "order_date", role: "date", dataType: "date" },
|
|
232
367
|
timeGrain: "week",
|
|
@@ -256,19 +391,23 @@ const a = {
|
|
|
256
391
|
}
|
|
257
392
|
};
|
|
258
393
|
export {
|
|
259
|
-
|
|
260
|
-
|
|
394
|
+
w as SEMAPHOR_ANALYTICS_INTENT_FIXTURES,
|
|
395
|
+
I as buildAnalyticsCatalogFieldSummary,
|
|
396
|
+
x as buildSemaphorQualifiedSourcePath,
|
|
261
397
|
v as getAnalyticsCatalogFieldCandidates,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
b as
|
|
398
|
+
h as getAnalyticsCatalogFieldName,
|
|
399
|
+
S as getSemaphorConnectionCapabilities,
|
|
400
|
+
D as inferAnalyticsMetricFormat,
|
|
401
|
+
m as isAnalyticsCatalogDateField,
|
|
402
|
+
q as isAnalyticsCatalogDimensionField,
|
|
403
|
+
b as isAnalyticsCatalogMetricField,
|
|
404
|
+
C as isAnalyticsDateLikeDataType,
|
|
268
405
|
u as isAnalyticsMetricIdentifierField,
|
|
269
406
|
p as isAnalyticsTechnicalIdentifierField,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
407
|
+
d as normalizeAnalyticsCatalogDataType,
|
|
408
|
+
c as normalizeAnalyticsCatalogName,
|
|
409
|
+
_ as normalizeSemaphorDialect,
|
|
410
|
+
A as semaphorSourceHasRequiredCoordinates,
|
|
411
|
+
R as validateSemaphorAnalyticsIntent,
|
|
412
|
+
z as validateSemaphorDashboardIntent
|
|
274
413
|
};
|
|
@@ -48,10 +48,20 @@ export declare type AnalyticsMetricFormat = {
|
|
|
48
48
|
|
|
49
49
|
export declare function buildAnalyticsCatalogFieldSummary(fields: AnalyticsCatalogField[]): AnalyticsCatalogFieldSummary;
|
|
50
50
|
|
|
51
|
+
export declare function buildSemaphorQualifiedSourcePath(input: {
|
|
52
|
+
capabilities: Pick<SemaphorConnectionCapabilities, 'prefixLevels' | 'dialect'>;
|
|
53
|
+
source: SemaphorSourceCoordinateInput;
|
|
54
|
+
quoteIdentifier?: (value: string, dialect: SemaphorDialect) => string;
|
|
55
|
+
}): string;
|
|
56
|
+
|
|
51
57
|
export declare function getAnalyticsCatalogFieldCandidates(field: AnalyticsCatalogField): string[];
|
|
52
58
|
|
|
53
59
|
export declare function getAnalyticsCatalogFieldName(field: AnalyticsCatalogField): string;
|
|
54
60
|
|
|
61
|
+
export declare function getSemaphorConnectionCapabilities(connectionType: string | undefined, options?: {
|
|
62
|
+
connectionId?: string;
|
|
63
|
+
}): SemaphorConnectionCapabilities;
|
|
64
|
+
|
|
55
65
|
export declare function inferAnalyticsMetricFormat(field: AnalyticsCatalogField): AnalyticsMetricFormat | undefined;
|
|
56
66
|
|
|
57
67
|
export declare function isAnalyticsCatalogDateField(field: AnalyticsCatalogField): boolean;
|
|
@@ -72,6 +82,8 @@ export declare function normalizeAnalyticsCatalogDataType(value: unknown): Analy
|
|
|
72
82
|
|
|
73
83
|
export declare function normalizeAnalyticsCatalogName(value: unknown): string;
|
|
74
84
|
|
|
85
|
+
export declare function normalizeSemaphorDialect(input: string | undefined): SemaphorDialect;
|
|
86
|
+
|
|
75
87
|
export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
76
88
|
revenueKpi: {
|
|
77
89
|
version: 1;
|
|
@@ -217,6 +229,18 @@ export declare const SEMAPHOR_ANALYTICS_INTENT_FIXTURES: {
|
|
|
217
229
|
};
|
|
218
230
|
};
|
|
219
231
|
|
|
232
|
+
export declare type SemaphorAnalyticsExecutionResult = {
|
|
233
|
+
intentId?: string;
|
|
234
|
+
queryId?: string;
|
|
235
|
+
status: SemaphorAnalyticsExecutionStatus;
|
|
236
|
+
result?: SemaphorAnalyticsResult;
|
|
237
|
+
validation: SemaphorAnalyticsValidationResult;
|
|
238
|
+
missingFields?: string[];
|
|
239
|
+
warnings?: string[];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export declare type SemaphorAnalyticsExecutionStatus = 'answered' | 'partial' | 'failed';
|
|
243
|
+
|
|
220
244
|
export declare type SemaphorAnalyticsFieldRole = 'metric' | 'dateField' | 'dimension' | 'input' | 'source' | 'sql';
|
|
221
245
|
|
|
222
246
|
export declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent;
|
|
@@ -260,6 +284,43 @@ export declare type SemaphorAnalyticsValidationResult = {
|
|
|
260
284
|
repairHints: SemaphorAnalyticsRepairHint[];
|
|
261
285
|
};
|
|
262
286
|
|
|
287
|
+
export declare type SemaphorCompiledQuery = {
|
|
288
|
+
kind: 'config';
|
|
289
|
+
queryId: string;
|
|
290
|
+
source: SemaphorSourceRef;
|
|
291
|
+
cardType: string;
|
|
292
|
+
connectionId: string;
|
|
293
|
+
cardConfig: unknown;
|
|
294
|
+
cardDataSource: unknown;
|
|
295
|
+
activeFilters?: unknown[];
|
|
296
|
+
rowLimit: number;
|
|
297
|
+
analyticsIntent?: SemaphorAnalyticsIntent;
|
|
298
|
+
} | {
|
|
299
|
+
kind: 'sql';
|
|
300
|
+
queryId: string;
|
|
301
|
+
source: Extract<SemaphorSourceRef, {
|
|
302
|
+
kind: 'physical' | 'sql';
|
|
303
|
+
}>;
|
|
304
|
+
connectionId: string;
|
|
305
|
+
dialect: SemaphorDialect;
|
|
306
|
+
sql: string;
|
|
307
|
+
parameters?: Record<string, unknown>;
|
|
308
|
+
pythonCode?: string;
|
|
309
|
+
activeFilters?: unknown[];
|
|
310
|
+
rowLimit: number;
|
|
311
|
+
analyticsIntent?: SemaphorAnalyticsIntent;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export declare type SemaphorConnectionCapabilities = {
|
|
315
|
+
connectionId?: string;
|
|
316
|
+
connectionType?: string;
|
|
317
|
+
dialect: SemaphorDialect;
|
|
318
|
+
path: SemaphorSourceLevel[];
|
|
319
|
+
labels: Partial<Record<SemaphorSourceLevel, string>>;
|
|
320
|
+
prefixLevels: SemaphorSourceLevel[];
|
|
321
|
+
supportsFilterClause: boolean;
|
|
322
|
+
};
|
|
323
|
+
|
|
263
324
|
export declare type SemaphorDashboardIntent = {
|
|
264
325
|
version: SemaphorProtocolVersion;
|
|
265
326
|
kind: 'dashboard';
|
|
@@ -285,7 +346,7 @@ export declare type SemaphorDashboardViewIntent = {
|
|
|
285
346
|
text?: string;
|
|
286
347
|
};
|
|
287
348
|
|
|
288
|
-
export declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'snowflake' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
349
|
+
export declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
289
350
|
|
|
290
351
|
export declare type SemaphorExperienceIntent = SemaphorDashboardIntent;
|
|
291
352
|
|
|
@@ -416,6 +477,19 @@ export declare type SemaphorRecordsResult = SemaphorAnalyticsResultBase & {
|
|
|
416
477
|
records: Array<Record<string, unknown>>;
|
|
417
478
|
};
|
|
418
479
|
|
|
480
|
+
export declare type SemaphorSourceCoordinateInput = {
|
|
481
|
+
databaseName?: string;
|
|
482
|
+
schemaName?: string;
|
|
483
|
+
tableName?: string;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
export declare function semaphorSourceHasRequiredCoordinates(input: {
|
|
487
|
+
capabilities: Pick<SemaphorConnectionCapabilities, 'prefixLevels'>;
|
|
488
|
+
source: SemaphorSourceCoordinateInput;
|
|
489
|
+
}): boolean;
|
|
490
|
+
|
|
491
|
+
export declare type SemaphorSourceLevel = 'database' | 'schema' | 'table';
|
|
492
|
+
|
|
419
493
|
export declare type SemaphorSourceRef = {
|
|
420
494
|
kind: 'semantic';
|
|
421
495
|
domainId: string;
|
|
@@ -426,6 +500,7 @@ export declare type SemaphorSourceRef = {
|
|
|
426
500
|
} | {
|
|
427
501
|
kind: 'physical';
|
|
428
502
|
connectionId: string;
|
|
503
|
+
connectionType?: string;
|
|
429
504
|
tableName: string;
|
|
430
505
|
databaseName?: string;
|
|
431
506
|
schemaName?: string;
|
|
@@ -1854,7 +1854,7 @@ declare type SemaphorDashboardViewIntent = {
|
|
|
1854
1854
|
text?: string;
|
|
1855
1855
|
};
|
|
1856
1856
|
|
|
1857
|
-
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'snowflake' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
1857
|
+
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
1858
1858
|
|
|
1859
1859
|
declare type SemaphorFieldRef = {
|
|
1860
1860
|
name: string;
|
|
@@ -1955,6 +1955,7 @@ declare type SemaphorSourceRef = {
|
|
|
1955
1955
|
} | {
|
|
1956
1956
|
kind: 'physical';
|
|
1957
1957
|
connectionId: string;
|
|
1958
|
+
connectionType?: string;
|
|
1958
1959
|
tableName: string;
|
|
1959
1960
|
databaseName?: string;
|
|
1960
1961
|
schemaName?: string;
|
|
@@ -482,7 +482,7 @@ export declare type ReasoningEffort = 'low' | 'medium' | 'high';
|
|
|
482
482
|
|
|
483
483
|
declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent;
|
|
484
484
|
|
|
485
|
-
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'snowflake' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
485
|
+
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
486
486
|
|
|
487
487
|
declare type SemaphorFieldRef = {
|
|
488
488
|
name: string;
|
|
@@ -559,6 +559,7 @@ declare type SemaphorSourceRef = {
|
|
|
559
559
|
} | {
|
|
560
560
|
kind: 'physical';
|
|
561
561
|
connectionId: string;
|
|
562
|
+
connectionType?: string;
|
|
562
563
|
tableName: string;
|
|
563
564
|
databaseName?: string;
|
|
564
565
|
schemaName?: string;
|
|
@@ -246,7 +246,7 @@ declare type SemaphorDataAppWindowRuntime = {
|
|
|
246
246
|
};
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'snowflake' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
249
|
+
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
250
250
|
|
|
251
251
|
declare type SemaphorFieldRef = {
|
|
252
252
|
name: string;
|
|
@@ -323,6 +323,7 @@ declare type SemaphorSourceRef = {
|
|
|
323
323
|
} | {
|
|
324
324
|
kind: 'physical';
|
|
325
325
|
connectionId: string;
|
|
326
|
+
connectionType?: string;
|
|
326
327
|
tableName: string;
|
|
327
328
|
databaseName?: string;
|
|
328
329
|
schemaName?: string;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4421,7 +4421,7 @@ export declare const SemaphorContextProvider: ({ children, dashboardProps, }: {
|
|
|
4421
4421
|
dashboardProps: DashboardProps;
|
|
4422
4422
|
}) => JSX.Element;
|
|
4423
4423
|
|
|
4424
|
-
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'snowflake' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
4424
|
+
declare type SemaphorDialect = 'semantic' | 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
|
|
4425
4425
|
|
|
4426
4426
|
declare type SemaphorFieldRef = {
|
|
4427
4427
|
name: string;
|
|
@@ -4502,6 +4502,7 @@ declare type SemaphorSourceRef = {
|
|
|
4502
4502
|
} | {
|
|
4503
4503
|
kind: 'physical';
|
|
4504
4504
|
connectionId: string;
|
|
4505
|
+
connectionType?: string;
|
|
4505
4506
|
tableName: string;
|
|
4506
4507
|
databaseName?: string;
|
|
4507
4508
|
schemaName?: string;
|