react-semaphor 0.1.386 → 0.1.388
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/DATA_APP_SDK.md +67 -0
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +260 -99
- package/dist/data-app-sdk/index.cjs +36 -2
- package/dist/data-app-sdk/index.js +1266 -1010
- package/dist/types/analytics-protocol.d.ts +121 -0
- package/dist/types/data-app-sdk.d.ts +6 -0
- package/package.json +1 -1
- package/src/data-app-sdk/README.md +67 -0
package/DATA_APP_SDK.md
CHANGED
|
@@ -8,6 +8,7 @@ these patterns over inspecting `dist/types` or SDK implementation files.
|
|
|
8
8
|
```tsx
|
|
9
9
|
import {
|
|
10
10
|
SemaphorDataAppProvider,
|
|
11
|
+
SemaphorDevtools,
|
|
11
12
|
semaphor,
|
|
12
13
|
useClearInvalidSemaphorInputValue,
|
|
13
14
|
useSemaphorInput,
|
|
@@ -23,6 +24,47 @@ import type {
|
|
|
23
24
|
} from "react-semaphor/data-app-sdk";
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
## Runtime Provider And DevTools
|
|
28
|
+
|
|
29
|
+
Generated local/dev apps should mount one root DevTools instance and enable the
|
|
30
|
+
debug bridge only outside production embeds.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
const runtimeToken = import.meta.env.VITE_SEMAPHOR_PROJECT_TOKEN;
|
|
34
|
+
const enableDevtools =
|
|
35
|
+
import.meta.env.DEV ||
|
|
36
|
+
(typeof window !== "undefined" && window.location.hostname === "localhost");
|
|
37
|
+
|
|
38
|
+
export function Root() {
|
|
39
|
+
return (
|
|
40
|
+
<SemaphorDataAppProvider
|
|
41
|
+
token={runtimeToken}
|
|
42
|
+
debug={enableDevtools ? { exposeWindowBridge: true } : false}
|
|
43
|
+
>
|
|
44
|
+
<App />
|
|
45
|
+
<SemaphorDevtools
|
|
46
|
+
initialIsOpen={false}
|
|
47
|
+
buttonPosition="bottom-right"
|
|
48
|
+
panelPosition="right"
|
|
49
|
+
/>
|
|
50
|
+
</SemaphorDataAppProvider>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Add hook-level debug source hints when they are cheap and non-repetitive:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
const result = useSemaphorQuery(revenueBySegment, {
|
|
59
|
+
debug: {
|
|
60
|
+
sourceHint: {
|
|
61
|
+
file: "src/views/RevenueBySegment.tsx",
|
|
62
|
+
component: "RevenueBySegment",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
26
68
|
## Source And Fields
|
|
27
69
|
|
|
28
70
|
```tsx
|
|
@@ -140,12 +182,37 @@ function SegmentFilter() {
|
|
|
140
182
|
});
|
|
141
183
|
|
|
142
184
|
useClearInvalidSemaphorInputValue(segmentHandle, optionsResult);
|
|
185
|
+
|
|
186
|
+
const selectedValue = Array.isArray(segmentHandle.value)
|
|
187
|
+
? String(segmentHandle.value[0] ?? "")
|
|
188
|
+
: "";
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<select
|
|
192
|
+
value={selectedValue}
|
|
193
|
+
onChange={(event) => {
|
|
194
|
+
const nextValue = event.target.value || null;
|
|
195
|
+
segmentHandle.setValue(nextValue ? [nextValue] : undefined);
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
<option value="">All segments</option>
|
|
199
|
+
{(optionsResult.options ?? []).map((option) => (
|
|
200
|
+
<option key={String(option.value)} value={String(option.value)}>
|
|
201
|
+
{option.label ?? String(option.value)}
|
|
202
|
+
</option>
|
|
203
|
+
))}
|
|
204
|
+
</select>
|
|
205
|
+
);
|
|
143
206
|
}
|
|
144
207
|
```
|
|
145
208
|
|
|
146
209
|
Pass the full options query result to `useClearInvalidSemaphorInputValue`.
|
|
147
210
|
Do not pass only `optionsResult.options`, because idle/loading results can also
|
|
148
211
|
expose an empty options array.
|
|
212
|
+
For shadcn/Base UI style selects, type the change callback as accepting
|
|
213
|
+
`string | null` and call `handle.clear()` or `handle.setValue(undefined)` for
|
|
214
|
+
the empty state. For multi-selects and date ranges, narrow `handle.value` with
|
|
215
|
+
`Array.isArray(...)` before indexing or displaying it.
|
|
149
216
|
|
|
150
217
|
## Shared Inputs With Source-Specific Bindings
|
|
151
218
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../chunks/operators-DrTQsJXv.js"),s=require("../chunks/validators-lWo8m0Q7.js"),o=require("../chunks/analyze-result-contract-CtXfp3nv.js"),i=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),l=require("../chunks/source-identity-C-xaeE_I.js");function m(e,a={}){const r=c(e),t={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 r.includes("postgres")?{...t,prefixLevels:["schema","table"],dialect:"postgres"}:r.includes("mysql")?{...t,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:r.includes("mssql")||r.includes("sqlserver")?{...t,dialect:"mssql",supportsFilterClause:!1}:r.includes("redshift")?{...t,prefixLevels:["schema","table"],dialect:"redshift"}:r.includes("snowflake")?{...t,dialect:"snowflake"}:r.includes("clickhouse")?{connectionId:a.connectionId,connectionType:e,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:r==="s3"||r==="api"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:r==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:r==="googlesheets"||r==="fileupload"?{connectionId:a.connectionId,connectionType:e,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:r==="s3tables"?{...t,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:r==="bigquery"?{...t,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:t}function p(e){const a=c(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";default:return"unknown"}}function b(e){return e.capabilities.prefixLevels.every(a=>!!u(e.source,a))}function h(e){const a=e.quoteIdentifier??f;return e.capabilities.prefixLevels.map(r=>u(e.source,r)).filter(r=>!!r).map(r=>a(r,e.capabilities.dialect)).join(".")}function u(e,a){return a==="database"?e.databaseName:a==="schema"?e.schemaName:e.tableName}function f(e,a){return a==="mysql"||a==="bigquery"||a==="clickhouse"||a==="duckdb"?`\`${e.replace(/`/g,"``")}\``:a==="mssql"?`[${e.replace(/]/g,"]]")}]`:`"${e.replace(/"/g,'""')}"`}function c(e){if(typeof e!="string")return"";const a=[];for(const r of e.trim().toLowerCase())y(r)&&a.push(r);return a.join("")}function y(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"},S={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:n,measures:[{name:"revenue",role:"measure"}],primaryMeasure:{name:"revenue",role:"measure"},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"},{name:"revenue",role:"measure",dataType:"number"}],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"}],orderBy:{field:{name:"revenue",role:"measure"},direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",inputId:"region",source:n,labelField:{name:"region",role:"dimension",dataType:"string"},valueField:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:n,measures:[{name:"revenue",role:"measure"}],primaryMeasure:{name:"revenue",role:"measure"},dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},inboundSupplierConcentration:{version:1,kind:"metric",id:"inbound-supplier-concentration",label:"Inbound supplier concentration",source:n,measures:[{name:"net_tons",role:"measure"},{name:"ticket_value",role:"measure"}],primaryMeasure:{name:"net_tons",role:"measure"},dateField:{name:"ticket_date",role:"date",dataType:"date"},timeWindow:{unit:"month",value:6,anchor:"latest_available"},dimensions:[{name:"supplier_id",role:"dimension",dataType:"number"}],filters:[{field:{name:"direction",role:"dimension",dataType:"string"},operator:"=",values:["Inbound"]}],limit:15},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"sql",connectionId:"conn_sales",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.normalizeSemaphorAnalyticsFilterOperator=d.normalizeSemaphorAnalyticsFilterOperator;exports.normalizeSemaphorInputOperator=d.normalizeSemaphorInputOperator;exports.parseSemaphorIsoTimeWindowBoundary=s.parseSemaphorIsoTimeWindowBoundary;exports.validateSemaphorAnalyticsIntent=s.validateSemaphorAnalyticsIntent;exports.validateSemaphorAnalyticsRecoveryPlan=s.validateSemaphorAnalyticsRecoveryPlan;exports.validateSemaphorDashboardIntent=s.validateSemaphorDashboardIntent;exports.validateSemaphorDerivedFieldDefinition=s.validateSemaphorDerivedFieldDefinition;exports.validateSemaphorOperationIntent=s.validateSemaphorOperationIntent;exports.validateSemaphorResultCalculation=s.validateSemaphorResultCalculation;exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=o.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT;exports.getSemaphorAnalyzeResultFieldNames=o.getSemaphorAnalyzeResultFieldNames;exports.isSemaphorAnalyzeResultFieldName=o.isSemaphorAnalyzeResultFieldName;exports.parseSemaphorAnalyzeResult=o.parseSemaphorAnalyzeResult;exports.buildAnalyticsCatalogFieldSummary=i.buildAnalyticsCatalogFieldSummary;exports.getAnalyticsCatalogFieldCandidates=i.getAnalyticsCatalogFieldCandidates;exports.getAnalyticsCatalogFieldName=i.getAnalyticsCatalogFieldName;exports.isAnalyticsCatalogDateField=i.isAnalyticsCatalogDateField;exports.isAnalyticsCatalogDimensionField=i.isAnalyticsCatalogDimensionField;exports.isAnalyticsCatalogMetricField=i.isAnalyticsCatalogMetricField;exports.isAnalyticsDateLikeDataType=i.isAnalyticsDateLikeDataType;exports.isAnalyticsMetricIdentifierField=i.isAnalyticsMetricIdentifierField;exports.isAnalyticsTechnicalIdentifierField=i.isAnalyticsTechnicalIdentifierField;exports.normalizeAnalyticsCatalogDataType=i.normalizeAnalyticsCatalogDataType;exports.normalizeAnalyticsCatalogName=i.normalizeAnalyticsCatalogName;exports.preferSemaphorFieldRefMetadata=l.preferSemaphorFieldRefMetadata;exports.preferSemaphorSourceMetadata=l.preferSemaphorSourceMetadata;exports.semaphorFieldRefsMatch=l.semaphorFieldRefsMatch;exports.semaphorSourceIdentityKey=l.semaphorSourceIdentityKey;exports.semaphorSourcesReferToSameDataset=l.semaphorSourcesReferToSameDataset;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=S;exports.buildSemaphorQualifiedSourcePath=h;exports.getSemaphorConnectionCapabilities=m;exports.normalizeSemaphorDialect=p;exports.semaphorSourceHasRequiredCoordinates=b;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../chunks/operators-DrTQsJXv.js"),d=require("../chunks/validators-lWo8m0Q7.js"),b=require("../chunks/analyze-result-contract-CtXfp3nv.js"),o=require("../chunks/catalog-field-grounding-Bnx-3tE0.js"),y=require("../chunks/source-identity-C-xaeE_I.js"),g="semaphor-data-app-codegen-summary/v1";function R(a){return v(a).ok}function v(a){const i=[];if(!a||typeof a!="object")return{ok:!1,issues:["Summary must be an object."]};const e=a;return e.schemaVersion!==g&&i.push(`schemaVersion must be ${g}.`),(typeof e.title!="string"||!e.title.trim())&&i.push("title is required."),Array.isArray(e.sources)||i.push("sources must be an array."),Array.isArray(e.inputs)||i.push("inputs must be an array."),Array.isArray(e.views)||i.push("views must be an array."),Array.isArray(e.filterContracts)||i.push("filterContracts must be an array."),(!e.implementationChecklist||typeof e.implementationChecklist!="object")&&i.push("implementationChecklist must be an object."),e.implementationChecklist&&typeof e.implementationChecklist=="object"&&i.push(...T(e.implementationChecklist)),Array.isArray(e.sources)&&e.sources.forEach((t,r)=>{i.push(...k(t,`sources.${r}`))}),Array.isArray(e.inputs)&&e.inputs.forEach((t,r)=>{i.push(...F(t,`inputs.${r}`))}),Array.isArray(e.views)&&e.views.forEach((t,r)=>{i.push(...$(t,`views.${r}`))}),Array.isArray(e.filterContracts)&&e.filterContracts.forEach((t,r)=>{i.push(...q(t,`filterContracts.${r}`))}),{ok:i.length===0,issues:i}}function k(a,i){const e=s(a);return e?typeof e.sourceKey=="string"&&e.sourceKey.trim()?[]:e.kind==="semantic"&&typeof e.domainId=="string"&&e.domainId.trim()&&(typeof e.datasetName=="string"&&e.datasetName.trim()||typeof e.datasetId=="string"&&e.datasetId.trim())?[]:e.kind==="physical"&&typeof e.tableName=="string"&&e.tableName.trim()&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:e.kind==="sql"&&typeof e.connectionId=="string"&&e.connectionId.trim()?[]:[`${i} must include sourceKey or a supported source identity.`]:[`${i} must be an object.`]}function T(a){const i=s(a);if(!i)return["implementationChecklist must be an object."];const e=[],t=["requiredDevtools","requiredInputOptions","filterScopeByInput","bindingsByView","validationCommands","browserSmokeChecks"];for(const n of t)n in i||e.push(`implementationChecklist.${n} is required.`);const r=s(i.requiredDevtools);return r?typeof r.mountRootDevtools!="boolean"&&e.push("implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."):e.push("implementationChecklist.requiredDevtools must be an object."),Array.isArray(i.requiredInputOptions)||e.push("implementationChecklist.requiredInputOptions must be an array."),Array.isArray(i.filterScopeByInput)||e.push("implementationChecklist.filterScopeByInput must be an array."),s(i.bindingsByView)||e.push("implementationChecklist.bindingsByView must be an object."),l(i.validationCommands)||e.push("implementationChecklist.validationCommands must be an array of strings."),l(i.browserSmokeChecks)||e.push("implementationChecklist.browserSmokeChecks must be an array of strings."),e}function F(a,i){const e=s(a);if(!e)return[`${i} must be an object.`];const t=[];return(typeof e.id!="string"||!e.id.trim())&&t.push(`${i}.id is required.`),e.fieldRef&&t.push(...m(e.fieldRef,`${i}.fieldRef`)),t.push(...S(e.optionQuery,`${i}.optionQuery`)),l(e.appliesToViewIds)||t.push(`${i}.appliesToViewIds must be an array of strings.`),e.bindings!==void 0&&!Array.isArray(e.bindings)&&t.push(`${i}.bindings must be an array.`),Array.isArray(e.bindings)&&e.bindings.forEach((r,n)=>{const p=s(r);if(!p){t.push(`${i}.bindings.${n} must be an object.`);return}l(p.appliesToViewIds)||t.push(`${i}.bindings.${n}.appliesToViewIds must be an array of strings.`),t.push(...m(p.fieldRef,`${i}.bindings.${n}.fieldRef`))}),t}function $(a,i){const e=s(a);if(!e)return[`${i} must be an object.`];const t=[];return(typeof e.id!="string"||!e.id.trim())&&t.push(`${i}.id is required.`),Array.isArray(e.fields)?(e.fields.forEach((r,n)=>{t.push(...m(r,`${i}.fields.${n}`))}),t):(_(e)||t.push(`${i}.fields must be an array.`),t)}function q(a,i){const e=s(a);if(!e)return[`${i} must be an object.`];const t=[];if(e.fieldRef&&t.push(...m(e.fieldRef,`${i}.fieldRef`)),(typeof e.inputId!="string"||!e.inputId.trim())&&t.push(`${i}.inputId is required.`),t.push(...S(e.optionQuery,`${i}.optionQuery`)),l(e.appliesToViewIds)||t.push(`${i}.appliesToViewIds must be an array of strings.`),l(e.notAppliedToViewIds)||t.push(`${i}.notAppliedToViewIds must be an array of strings.`),!Array.isArray(e.bindings))t.push(`${i}.bindings must be an array.`);else{const r=l(e.appliesToViewIds)?new Set(e.appliesToViewIds):void 0,n=l(e.notAppliedToViewIds)?new Set(e.notAppliedToViewIds):void 0;e.bindings.forEach((p,f)=>{const u=s(p);if(!u){t.push(`${i}.bindings.${f} must be an object.`);return}typeof u.viewId!="string"||!u.viewId?t.push(`${i}.bindings.${f}.viewId is required.`):(r&&!r.has(u.viewId)&&t.push(`${i}.bindings.${f}.viewId must be included in appliesToViewIds.`),n!=null&&n.has(u.viewId)&&t.push(`${i}.bindings.${f}.viewId must not be listed in notAppliedToViewIds.`)),t.push(...m(u.fieldRef,`${i}.bindings.${f}.fieldRef`))})}return t}function S(a,i){if(a===void 0)return[];const e=s(a);return e?[...h(e.valueFieldRef,`${i}.valueFieldRef`),...h(e.labelFieldRef,`${i}.labelFieldRef`),...h(e.filterFieldRef,`${i}.filterFieldRef`)]:[`${i} must be an object.`]}function _(a){const i=s(a.computation),e=s(a.visualSpec);return(i==null?void 0:i.kind)==="presentation_only"||a.visual==="text_block"||(e==null?void 0:e.visualType)==="text_block"}function h(a,i){return a===void 0?[]:m(a,i)}function m(a,i){const e=s(a);if(!e)return[`${i} must be an object.`];const t=[];return(typeof e.name!="string"||!e.name.trim())&&t.push(`${i}.name is required.`),!e.source&&typeof e.sourceKey!="string"&&t.push(`${i} must include source or sourceKey.`),t}function s(a){return a&&typeof a=="object"&&!Array.isArray(a)?a:void 0}function l(a){return Array.isArray(a)&&a.every(i=>typeof i=="string")}function w(a,i={}){const e=I(a),t={connectionId:i.connectionId,connectionType:a,path:["database","schema","table"],labels:{database:"Database",schema:"Schema",table:"Table"},prefixLevels:["database","schema","table"],dialect:"postgres",supportsFilterClause:!0};return e.includes("postgres")?{...t,prefixLevels:["schema","table"],dialect:"postgres"}:e.includes("mysql")?{...t,prefixLevels:["database","table"],dialect:"mysql",supportsFilterClause:!1}:e.includes("mssql")||e.includes("sqlserver")?{...t,dialect:"mssql",supportsFilterClause:!1}:e.includes("redshift")?{...t,prefixLevels:["schema","table"],dialect:"redshift"}:e.includes("snowflake")?{...t,dialect:"snowflake"}:e.includes("clickhouse")?{connectionId:i.connectionId,connectionType:a,path:["database","table"],labels:{database:"Database",table:"Table"},prefixLevels:["database","table"],dialect:"clickhouse",supportsFilterClause:!1}:e==="s3"||e==="api"?{connectionId:i.connectionId,connectionType:a,path:["table"],labels:{table:e==="api"?"API Table":"File Table"},prefixLevels:["table"],dialect:"duckdb",supportsFilterClause:!0}:e==="googlesheets"||e==="fileupload"?{connectionId:i.connectionId,connectionType:a,path:["table"],labels:{table:"Table"},prefixLevels:["table"],dialect:"postgres",supportsFilterClause:!0}:e==="s3tables"?{...t,labels:{database:"Database",schema:"Namespace",table:"Table"},dialect:"duckdb"}:e==="bigquery"?{...t,labels:{database:"Project",schema:"Dataset",table:"Table"},prefixLevels:["schema","table"],dialect:"bigquery",supportsFilterClause:!1}:t}function D(a){const i=I(a);switch(i){case"mysql":case"bigquery":case"redshift":case"snowflake":case"clickhouse":case"duckdb":case"sqlite":return i;case"mssql":case"sqlserver":return"mssql";case"postgres":case"postgresql":return"postgres";default:return"unknown"}}function E(a){return a.capabilities.prefixLevels.every(i=>!!C(a.source,i))}function N(a){const i=a.quoteIdentifier??O;return a.capabilities.prefixLevels.map(e=>C(a.source,e)).filter(e=>!!e).map(e=>i(e,a.capabilities.dialect)).join(".")}function C(a,i){return i==="database"?a.databaseName:i==="schema"?a.schemaName:a.tableName}function O(a,i){return i==="mysql"||i==="bigquery"||i==="clickhouse"||i==="duckdb"?`\`${a.replace(/`/g,"``")}\``:i==="mssql"?`[${a.replace(/]/g,"]]")}]`:`"${a.replace(/"/g,'""')}"`}function I(a){if(typeof a!="string")return"";const i=[];for(const e of a.trim().toLowerCase())M(e)&&i.push(e);return i.join("")}function M(a){const i=a.charCodeAt(0);return i>=48&&i<=57||i>=97&&i<=122}const c={kind:"semantic",domainId:"domain_sales",datasetName:"orders",connectionId:"conn_sales",label:"Orders"},L={revenueKpi:{version:1,kind:"metric",id:"revenue-kpi",label:"Revenue",source:c,measures:[{name:"revenue",role:"measure"}],primaryMeasure:{name:"revenue",role:"measure"},comparison:{kind:"previous_period"},limit:1},revenueTrend:{version:1,kind:"records",id:"revenue-trend",label:"Revenue trend",source:c,fields:[{name:"order_date",role:"date",dataType:"date",label:"Order Date"},{name:"revenue",role:"measure",dataType:"number"}],dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"month",limit:100},topCustomersRecords:{version:1,kind:"records",id:"top-customers",label:"Top customers",source:c,fields:[{name:"customer_name",role:"dimension",dataType:"string"},{name:"segment",role:"dimension",dataType:"string"},{name:"revenue",role:"measure",dataType:"number"}],orderBy:{field:{name:"revenue",role:"measure"},direction:"desc"},limit:20},regionInputOptions:{version:1,kind:"inputOptions",id:"region-options",label:"Region options",inputId:"region",source:c,labelField:{name:"region",role:"dimension",dataType:"string"},valueField:{name:"region",role:"dimension",dataType:"string"},limit:100},previousPeriodRevenueComparison:{version:1,kind:"metric",id:"revenue-previous-period",label:"Revenue previous period comparison",source:c,measures:[{name:"revenue",role:"measure"}],primaryMeasure:{name:"revenue",role:"measure"},dateField:{name:"order_date",role:"date",dataType:"date"},timeGrain:"week",comparison:{kind:"previous_period"},limit:100},inboundSupplierConcentration:{version:1,kind:"metric",id:"inbound-supplier-concentration",label:"Inbound supplier concentration",source:c,measures:[{name:"net_tons",role:"measure"},{name:"ticket_value",role:"measure"}],primaryMeasure:{name:"net_tons",role:"measure"},dateField:{name:"ticket_date",role:"date",dataType:"date"},timeWindow:{unit:"month",value:6,anchor:"latest_available"},dimensions:[{name:"supplier_id",role:"dimension",dataType:"number"}],filters:[{field:{name:"direction",role:"dimension",dataType:"string"},operator:"=",values:["Inbound"]}],limit:15},boundedSqlRanking:{version:1,kind:"sql",id:"top-customer-ranking-sql",label:"Top customer ranking SQL",source:{kind:"sql",connectionId:"conn_sales",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.normalizeSemaphorAnalyticsFilterOperator=A.normalizeSemaphorAnalyticsFilterOperator;exports.normalizeSemaphorInputOperator=A.normalizeSemaphorInputOperator;exports.parseSemaphorIsoTimeWindowBoundary=d.parseSemaphorIsoTimeWindowBoundary;exports.validateSemaphorAnalyticsIntent=d.validateSemaphorAnalyticsIntent;exports.validateSemaphorAnalyticsRecoveryPlan=d.validateSemaphorAnalyticsRecoveryPlan;exports.validateSemaphorDashboardIntent=d.validateSemaphorDashboardIntent;exports.validateSemaphorDerivedFieldDefinition=d.validateSemaphorDerivedFieldDefinition;exports.validateSemaphorOperationIntent=d.validateSemaphorOperationIntent;exports.validateSemaphorResultCalculation=d.validateSemaphorResultCalculation;exports.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT=b.SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT;exports.getSemaphorAnalyzeResultFieldNames=b.getSemaphorAnalyzeResultFieldNames;exports.isSemaphorAnalyzeResultFieldName=b.isSemaphorAnalyzeResultFieldName;exports.parseSemaphorAnalyzeResult=b.parseSemaphorAnalyzeResult;exports.buildAnalyticsCatalogFieldSummary=o.buildAnalyticsCatalogFieldSummary;exports.getAnalyticsCatalogFieldCandidates=o.getAnalyticsCatalogFieldCandidates;exports.getAnalyticsCatalogFieldName=o.getAnalyticsCatalogFieldName;exports.isAnalyticsCatalogDateField=o.isAnalyticsCatalogDateField;exports.isAnalyticsCatalogDimensionField=o.isAnalyticsCatalogDimensionField;exports.isAnalyticsCatalogMetricField=o.isAnalyticsCatalogMetricField;exports.isAnalyticsDateLikeDataType=o.isAnalyticsDateLikeDataType;exports.isAnalyticsMetricIdentifierField=o.isAnalyticsMetricIdentifierField;exports.isAnalyticsTechnicalIdentifierField=o.isAnalyticsTechnicalIdentifierField;exports.normalizeAnalyticsCatalogDataType=o.normalizeAnalyticsCatalogDataType;exports.normalizeAnalyticsCatalogName=o.normalizeAnalyticsCatalogName;exports.preferSemaphorFieldRefMetadata=y.preferSemaphorFieldRefMetadata;exports.preferSemaphorSourceMetadata=y.preferSemaphorSourceMetadata;exports.semaphorFieldRefsMatch=y.semaphorFieldRefsMatch;exports.semaphorSourceIdentityKey=y.semaphorSourceIdentityKey;exports.semaphorSourcesReferToSameDataset=y.semaphorSourcesReferToSameDataset;exports.SEMAPHOR_ANALYTICS_INTENT_FIXTURES=L;exports.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION=g;exports.buildSemaphorQualifiedSourcePath=N;exports.getSemaphorConnectionCapabilities=w;exports.isSemaphorDataAppCodegenSummary=R;exports.normalizeSemaphorDialect=D;exports.semaphorSourceHasRequiredCoordinates=E;exports.validateSemaphorDataAppCodegenSummary=v;
|
|
@@ -1,12 +1,170 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { p as
|
|
3
|
-
import { S as
|
|
4
|
-
import { j as
|
|
5
|
-
import { p as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { a as O, n as V } from "../chunks/operators-C8TxpM4C.js";
|
|
2
|
+
import { p as L, b as M, d as x, e as B, v as P, c as z, a as Q } from "../chunks/validators-CHPH6ORs.js";
|
|
3
|
+
import { S as H, g as U, i as Y, p as G } from "../chunks/analyze-result-contract-DuhlklhI.js";
|
|
4
|
+
import { j as X, a as Z, g as J, c as ee, h as ie, f as se, i as re, e as te, d as ae, b as ne, n as oe } from "../chunks/catalog-field-grounding-CJKAqtiC.js";
|
|
5
|
+
import { p as ue, c as de, s as ce, a as me, b as pe } from "../chunks/source-identity-CN4xiyKJ.js";
|
|
6
|
+
const f = "semaphor-data-app-codegen-summary/v1";
|
|
7
|
+
function T(s) {
|
|
8
|
+
return g(s).ok;
|
|
9
|
+
}
|
|
10
|
+
function g(s) {
|
|
11
|
+
const i = [];
|
|
12
|
+
if (!s || typeof s != "object")
|
|
13
|
+
return { ok: !1, issues: ["Summary must be an object."] };
|
|
14
|
+
const e = s;
|
|
15
|
+
return e.schemaVersion !== f && i.push(
|
|
16
|
+
`schemaVersion must be ${f}.`
|
|
17
|
+
), (typeof e.title != "string" || !e.title.trim()) && i.push("title is required."), Array.isArray(e.sources) || i.push("sources must be an array."), Array.isArray(e.inputs) || i.push("inputs must be an array."), Array.isArray(e.views) || i.push("views must be an array."), Array.isArray(e.filterContracts) || i.push("filterContracts must be an array."), (!e.implementationChecklist || typeof e.implementationChecklist != "object") && i.push("implementationChecklist must be an object."), e.implementationChecklist && typeof e.implementationChecklist == "object" && i.push(
|
|
18
|
+
...I(e.implementationChecklist)
|
|
19
|
+
), Array.isArray(e.sources) && e.sources.forEach((r, t) => {
|
|
20
|
+
i.push(...v(r, `sources.${t}`));
|
|
21
|
+
}), Array.isArray(e.inputs) && e.inputs.forEach((r, t) => {
|
|
22
|
+
i.push(...A(r, `inputs.${t}`));
|
|
23
|
+
}), Array.isArray(e.views) && e.views.forEach((r, t) => {
|
|
24
|
+
i.push(...C(r, `views.${t}`));
|
|
25
|
+
}), Array.isArray(e.filterContracts) && e.filterContracts.forEach((r, t) => {
|
|
26
|
+
i.push(
|
|
27
|
+
...k(r, `filterContracts.${t}`)
|
|
28
|
+
);
|
|
29
|
+
}), { ok: i.length === 0, issues: i };
|
|
30
|
+
}
|
|
31
|
+
function v(s, i) {
|
|
32
|
+
const e = a(s);
|
|
33
|
+
return e ? typeof e.sourceKey == "string" && e.sourceKey.trim() ? [] : e.kind === "semantic" && typeof e.domainId == "string" && e.domainId.trim() && (typeof e.datasetName == "string" && e.datasetName.trim() || typeof e.datasetId == "string" && e.datasetId.trim()) ? [] : e.kind === "physical" && typeof e.tableName == "string" && e.tableName.trim() && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : e.kind === "sql" && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : [`${i} must include sourceKey or a supported source identity.`] : [`${i} must be an object.`];
|
|
34
|
+
}
|
|
35
|
+
function I(s) {
|
|
36
|
+
const i = a(s);
|
|
37
|
+
if (!i)
|
|
38
|
+
return ["implementationChecklist must be an object."];
|
|
39
|
+
const e = [], r = [
|
|
40
|
+
"requiredDevtools",
|
|
41
|
+
"requiredInputOptions",
|
|
42
|
+
"filterScopeByInput",
|
|
43
|
+
"bindingsByView",
|
|
44
|
+
"validationCommands",
|
|
45
|
+
"browserSmokeChecks"
|
|
46
|
+
];
|
|
47
|
+
for (const n of r)
|
|
48
|
+
n in i || e.push(`implementationChecklist.${n} is required.`);
|
|
49
|
+
const t = a(i.requiredDevtools);
|
|
50
|
+
return t ? typeof t.mountRootDevtools != "boolean" && e.push(
|
|
51
|
+
"implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."
|
|
52
|
+
) : e.push("implementationChecklist.requiredDevtools must be an object."), Array.isArray(i.requiredInputOptions) || e.push(
|
|
53
|
+
"implementationChecklist.requiredInputOptions must be an array."
|
|
54
|
+
), Array.isArray(i.filterScopeByInput) || e.push("implementationChecklist.filterScopeByInput must be an array."), a(i.bindingsByView) || e.push("implementationChecklist.bindingsByView must be an object."), o(i.validationCommands) || e.push(
|
|
55
|
+
"implementationChecklist.validationCommands must be an array of strings."
|
|
56
|
+
), o(i.browserSmokeChecks) || e.push(
|
|
57
|
+
"implementationChecklist.browserSmokeChecks must be an array of strings."
|
|
58
|
+
), e;
|
|
59
|
+
}
|
|
60
|
+
function A(s, i) {
|
|
61
|
+
const e = a(s);
|
|
62
|
+
if (!e)
|
|
63
|
+
return [`${i} must be an object.`];
|
|
64
|
+
const r = [];
|
|
65
|
+
return (typeof e.id != "string" || !e.id.trim()) && r.push(`${i}.id is required.`), e.fieldRef && r.push(...d(e.fieldRef, `${i}.fieldRef`)), r.push(...b(e.optionQuery, `${i}.optionQuery`)), o(e.appliesToViewIds) || r.push(`${i}.appliesToViewIds must be an array of strings.`), e.bindings !== void 0 && !Array.isArray(e.bindings) && r.push(`${i}.bindings must be an array.`), Array.isArray(e.bindings) && e.bindings.forEach((t, n) => {
|
|
66
|
+
const c = a(t);
|
|
67
|
+
if (!c) {
|
|
68
|
+
r.push(`${i}.bindings.${n} must be an object.`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
o(c.appliesToViewIds) || r.push(
|
|
72
|
+
`${i}.bindings.${n}.appliesToViewIds must be an array of strings.`
|
|
73
|
+
), r.push(
|
|
74
|
+
...d(
|
|
75
|
+
c.fieldRef,
|
|
76
|
+
`${i}.bindings.${n}.fieldRef`
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
}), r;
|
|
80
|
+
}
|
|
81
|
+
function C(s, i) {
|
|
82
|
+
const e = a(s);
|
|
83
|
+
if (!e)
|
|
84
|
+
return [`${i} must be an object.`];
|
|
85
|
+
const r = [];
|
|
86
|
+
return (typeof e.id != "string" || !e.id.trim()) && r.push(`${i}.id is required.`), Array.isArray(e.fields) ? (e.fields.forEach((t, n) => {
|
|
87
|
+
r.push(...d(t, `${i}.fields.${n}`));
|
|
88
|
+
}), r) : (S(e) || r.push(`${i}.fields must be an array.`), r);
|
|
89
|
+
}
|
|
90
|
+
function k(s, i) {
|
|
91
|
+
const e = a(s);
|
|
92
|
+
if (!e)
|
|
93
|
+
return [`${i} must be an object.`];
|
|
94
|
+
const r = [];
|
|
95
|
+
if (e.fieldRef && r.push(
|
|
96
|
+
...d(e.fieldRef, `${i}.fieldRef`)
|
|
97
|
+
), (typeof e.inputId != "string" || !e.inputId.trim()) && r.push(`${i}.inputId is required.`), r.push(
|
|
98
|
+
...b(e.optionQuery, `${i}.optionQuery`)
|
|
99
|
+
), o(e.appliesToViewIds) || r.push(`${i}.appliesToViewIds must be an array of strings.`), o(e.notAppliedToViewIds) || r.push(`${i}.notAppliedToViewIds must be an array of strings.`), !Array.isArray(e.bindings))
|
|
100
|
+
r.push(`${i}.bindings must be an array.`);
|
|
101
|
+
else {
|
|
102
|
+
const t = o(e.appliesToViewIds) ? new Set(e.appliesToViewIds) : void 0, n = o(
|
|
103
|
+
e.notAppliedToViewIds
|
|
104
|
+
) ? new Set(e.notAppliedToViewIds) : void 0;
|
|
105
|
+
e.bindings.forEach((c, m) => {
|
|
106
|
+
const l = a(c);
|
|
107
|
+
if (!l) {
|
|
108
|
+
r.push(`${i}.bindings.${m} must be an object.`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
typeof l.viewId != "string" || !l.viewId ? r.push(`${i}.bindings.${m}.viewId is required.`) : (t && !t.has(l.viewId) && r.push(
|
|
112
|
+
`${i}.bindings.${m}.viewId must be included in appliesToViewIds.`
|
|
113
|
+
), n != null && n.has(l.viewId) && r.push(
|
|
114
|
+
`${i}.bindings.${m}.viewId must not be listed in notAppliedToViewIds.`
|
|
115
|
+
)), r.push(
|
|
116
|
+
...d(
|
|
117
|
+
l.fieldRef,
|
|
118
|
+
`${i}.bindings.${m}.fieldRef`
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return r;
|
|
124
|
+
}
|
|
125
|
+
function b(s, i) {
|
|
126
|
+
if (s === void 0)
|
|
127
|
+
return [];
|
|
128
|
+
const e = a(s);
|
|
129
|
+
return e ? [
|
|
130
|
+
...p(
|
|
131
|
+
e.valueFieldRef,
|
|
132
|
+
`${i}.valueFieldRef`
|
|
133
|
+
),
|
|
134
|
+
...p(
|
|
135
|
+
e.labelFieldRef,
|
|
136
|
+
`${i}.labelFieldRef`
|
|
137
|
+
),
|
|
138
|
+
...p(
|
|
139
|
+
e.filterFieldRef,
|
|
140
|
+
`${i}.filterFieldRef`
|
|
141
|
+
)
|
|
142
|
+
] : [`${i} must be an object.`];
|
|
143
|
+
}
|
|
144
|
+
function S(s) {
|
|
145
|
+
const i = a(s.computation), e = a(s.visualSpec);
|
|
146
|
+
return (i == null ? void 0 : i.kind) === "presentation_only" || s.visual === "text_block" || (e == null ? void 0 : e.visualType) === "text_block";
|
|
147
|
+
}
|
|
148
|
+
function p(s, i) {
|
|
149
|
+
return s === void 0 ? [] : d(s, i);
|
|
150
|
+
}
|
|
151
|
+
function d(s, i) {
|
|
152
|
+
const e = a(s);
|
|
153
|
+
if (!e)
|
|
154
|
+
return [`${i} must be an object.`];
|
|
155
|
+
const r = [];
|
|
156
|
+
return (typeof e.name != "string" || !e.name.trim()) && r.push(`${i}.name is required.`), !e.source && typeof e.sourceKey != "string" && r.push(`${i} must include source or sourceKey.`), r;
|
|
157
|
+
}
|
|
158
|
+
function a(s) {
|
|
159
|
+
return s && typeof s == "object" && !Array.isArray(s) ? s : void 0;
|
|
160
|
+
}
|
|
161
|
+
function o(s) {
|
|
162
|
+
return Array.isArray(s) && s.every((i) => typeof i == "string");
|
|
163
|
+
}
|
|
164
|
+
function w(s, i = {}) {
|
|
165
|
+
const e = h(s), r = {
|
|
166
|
+
connectionId: i.connectionId,
|
|
167
|
+
connectionType: s,
|
|
10
168
|
path: ["database", "schema", "table"],
|
|
11
169
|
labels: {
|
|
12
170
|
database: "Database",
|
|
@@ -17,29 +175,29 @@ function d(e, a = {}) {
|
|
|
17
175
|
dialect: "postgres",
|
|
18
176
|
supportsFilterClause: !0
|
|
19
177
|
};
|
|
20
|
-
return
|
|
21
|
-
...
|
|
178
|
+
return e.includes("postgres") ? {
|
|
179
|
+
...r,
|
|
22
180
|
prefixLevels: ["schema", "table"],
|
|
23
181
|
dialect: "postgres"
|
|
24
|
-
} :
|
|
25
|
-
...
|
|
182
|
+
} : e.includes("mysql") ? {
|
|
183
|
+
...r,
|
|
26
184
|
prefixLevels: ["database", "table"],
|
|
27
185
|
dialect: "mysql",
|
|
28
186
|
supportsFilterClause: !1
|
|
29
|
-
} :
|
|
30
|
-
...
|
|
187
|
+
} : e.includes("mssql") || e.includes("sqlserver") ? {
|
|
188
|
+
...r,
|
|
31
189
|
dialect: "mssql",
|
|
32
190
|
supportsFilterClause: !1
|
|
33
|
-
} :
|
|
34
|
-
...
|
|
191
|
+
} : e.includes("redshift") ? {
|
|
192
|
+
...r,
|
|
35
193
|
prefixLevels: ["schema", "table"],
|
|
36
194
|
dialect: "redshift"
|
|
37
|
-
} :
|
|
38
|
-
...
|
|
195
|
+
} : e.includes("snowflake") ? {
|
|
196
|
+
...r,
|
|
39
197
|
dialect: "snowflake"
|
|
40
|
-
} :
|
|
41
|
-
connectionId:
|
|
42
|
-
connectionType:
|
|
198
|
+
} : e.includes("clickhouse") ? {
|
|
199
|
+
connectionId: i.connectionId,
|
|
200
|
+
connectionType: s,
|
|
43
201
|
path: ["database", "table"],
|
|
44
202
|
labels: {
|
|
45
203
|
database: "Database",
|
|
@@ -48,19 +206,19 @@ function d(e, a = {}) {
|
|
|
48
206
|
prefixLevels: ["database", "table"],
|
|
49
207
|
dialect: "clickhouse",
|
|
50
208
|
supportsFilterClause: !1
|
|
51
|
-
} :
|
|
52
|
-
connectionId:
|
|
53
|
-
connectionType:
|
|
209
|
+
} : e === "s3" || e === "api" ? {
|
|
210
|
+
connectionId: i.connectionId,
|
|
211
|
+
connectionType: s,
|
|
54
212
|
path: ["table"],
|
|
55
213
|
labels: {
|
|
56
|
-
table:
|
|
214
|
+
table: e === "api" ? "API Table" : "File Table"
|
|
57
215
|
},
|
|
58
216
|
prefixLevels: ["table"],
|
|
59
217
|
dialect: "duckdb",
|
|
60
218
|
supportsFilterClause: !0
|
|
61
|
-
} :
|
|
62
|
-
connectionId:
|
|
63
|
-
connectionType:
|
|
219
|
+
} : e === "googlesheets" || e === "fileupload" ? {
|
|
220
|
+
connectionId: i.connectionId,
|
|
221
|
+
connectionType: s,
|
|
64
222
|
path: ["table"],
|
|
65
223
|
labels: {
|
|
66
224
|
table: "Table"
|
|
@@ -68,16 +226,16 @@ function d(e, a = {}) {
|
|
|
68
226
|
prefixLevels: ["table"],
|
|
69
227
|
dialect: "postgres",
|
|
70
228
|
supportsFilterClause: !0
|
|
71
|
-
} :
|
|
72
|
-
...
|
|
229
|
+
} : e === "s3tables" ? {
|
|
230
|
+
...r,
|
|
73
231
|
labels: {
|
|
74
232
|
database: "Database",
|
|
75
233
|
schema: "Namespace",
|
|
76
234
|
table: "Table"
|
|
77
235
|
},
|
|
78
236
|
dialect: "duckdb"
|
|
79
|
-
} :
|
|
80
|
-
...
|
|
237
|
+
} : e === "bigquery" ? {
|
|
238
|
+
...r,
|
|
81
239
|
labels: {
|
|
82
240
|
database: "Project",
|
|
83
241
|
schema: "Dataset",
|
|
@@ -86,11 +244,11 @@ function d(e, a = {}) {
|
|
|
86
244
|
prefixLevels: ["schema", "table"],
|
|
87
245
|
dialect: "bigquery",
|
|
88
246
|
supportsFilterClause: !1
|
|
89
|
-
} :
|
|
247
|
+
} : r;
|
|
90
248
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
switch (
|
|
249
|
+
function q(s) {
|
|
250
|
+
const i = h(s);
|
|
251
|
+
switch (i) {
|
|
94
252
|
case "mysql":
|
|
95
253
|
case "bigquery":
|
|
96
254
|
case "redshift":
|
|
@@ -98,7 +256,7 @@ function u(e) {
|
|
|
98
256
|
case "clickhouse":
|
|
99
257
|
case "duckdb":
|
|
100
258
|
case "sqlite":
|
|
101
|
-
return
|
|
259
|
+
return i;
|
|
102
260
|
case "mssql":
|
|
103
261
|
case "sqlserver":
|
|
104
262
|
return "mssql";
|
|
@@ -109,46 +267,46 @@ function u(e) {
|
|
|
109
267
|
return "unknown";
|
|
110
268
|
}
|
|
111
269
|
}
|
|
112
|
-
function
|
|
113
|
-
return
|
|
114
|
-
(
|
|
270
|
+
function F(s) {
|
|
271
|
+
return s.capabilities.prefixLevels.every(
|
|
272
|
+
(i) => !!y(s.source, i)
|
|
115
273
|
);
|
|
116
274
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
275
|
+
function _(s) {
|
|
276
|
+
const i = s.quoteIdentifier ?? R;
|
|
277
|
+
return s.capabilities.prefixLevels.map((e) => y(s.source, e)).filter((e) => !!e).map((e) => i(e, s.capabilities.dialect)).join(".");
|
|
120
278
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
279
|
+
function y(s, i) {
|
|
280
|
+
return i === "database" ? s.databaseName : i === "schema" ? s.schemaName : s.tableName;
|
|
123
281
|
}
|
|
124
|
-
function
|
|
125
|
-
return
|
|
282
|
+
function R(s, i) {
|
|
283
|
+
return i === "mysql" || i === "bigquery" || i === "clickhouse" || i === "duckdb" ? `\`${s.replace(/`/g, "``")}\`` : i === "mssql" ? `[${s.replace(/]/g, "]]")}]` : `"${s.replace(/"/g, '""')}"`;
|
|
126
284
|
}
|
|
127
|
-
function
|
|
128
|
-
if (typeof
|
|
285
|
+
function h(s) {
|
|
286
|
+
if (typeof s != "string")
|
|
129
287
|
return "";
|
|
130
|
-
const
|
|
131
|
-
for (const
|
|
132
|
-
|
|
133
|
-
return
|
|
288
|
+
const i = [];
|
|
289
|
+
for (const e of s.trim().toLowerCase())
|
|
290
|
+
$(e) && i.push(e);
|
|
291
|
+
return i.join("");
|
|
134
292
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
return
|
|
293
|
+
function $(s) {
|
|
294
|
+
const i = s.charCodeAt(0);
|
|
295
|
+
return i >= 48 && i <= 57 || i >= 97 && i <= 122;
|
|
138
296
|
}
|
|
139
|
-
const
|
|
297
|
+
const u = {
|
|
140
298
|
kind: "semantic",
|
|
141
299
|
domainId: "domain_sales",
|
|
142
300
|
datasetName: "orders",
|
|
143
301
|
connectionId: "conn_sales",
|
|
144
302
|
label: "Orders"
|
|
145
|
-
},
|
|
303
|
+
}, D = {
|
|
146
304
|
revenueKpi: {
|
|
147
305
|
version: 1,
|
|
148
306
|
kind: "metric",
|
|
149
307
|
id: "revenue-kpi",
|
|
150
308
|
label: "Revenue",
|
|
151
|
-
source:
|
|
309
|
+
source: u,
|
|
152
310
|
measures: [{ name: "revenue", role: "measure" }],
|
|
153
311
|
primaryMeasure: { name: "revenue", role: "measure" },
|
|
154
312
|
comparison: { kind: "previous_period" },
|
|
@@ -159,7 +317,7 @@ const i = {
|
|
|
159
317
|
kind: "records",
|
|
160
318
|
id: "revenue-trend",
|
|
161
319
|
label: "Revenue trend",
|
|
162
|
-
source:
|
|
320
|
+
source: u,
|
|
163
321
|
fields: [
|
|
164
322
|
{ name: "order_date", role: "date", dataType: "date", label: "Order Date" },
|
|
165
323
|
{ name: "revenue", role: "measure", dataType: "number" }
|
|
@@ -173,7 +331,7 @@ const i = {
|
|
|
173
331
|
kind: "records",
|
|
174
332
|
id: "top-customers",
|
|
175
333
|
label: "Top customers",
|
|
176
|
-
source:
|
|
334
|
+
source: u,
|
|
177
335
|
fields: [
|
|
178
336
|
{ name: "customer_name", role: "dimension", dataType: "string" },
|
|
179
337
|
{ name: "segment", role: "dimension", dataType: "string" },
|
|
@@ -188,7 +346,7 @@ const i = {
|
|
|
188
346
|
id: "region-options",
|
|
189
347
|
label: "Region options",
|
|
190
348
|
inputId: "region",
|
|
191
|
-
source:
|
|
349
|
+
source: u,
|
|
192
350
|
labelField: { name: "region", role: "dimension", dataType: "string" },
|
|
193
351
|
valueField: { name: "region", role: "dimension", dataType: "string" },
|
|
194
352
|
limit: 100
|
|
@@ -198,7 +356,7 @@ const i = {
|
|
|
198
356
|
kind: "metric",
|
|
199
357
|
id: "revenue-previous-period",
|
|
200
358
|
label: "Revenue previous period comparison",
|
|
201
|
-
source:
|
|
359
|
+
source: u,
|
|
202
360
|
measures: [{ name: "revenue", role: "measure" }],
|
|
203
361
|
primaryMeasure: { name: "revenue", role: "measure" },
|
|
204
362
|
dateField: { name: "order_date", role: "date", dataType: "date" },
|
|
@@ -211,7 +369,7 @@ const i = {
|
|
|
211
369
|
kind: "metric",
|
|
212
370
|
id: "inbound-supplier-concentration",
|
|
213
371
|
label: "Inbound supplier concentration",
|
|
214
|
-
source:
|
|
372
|
+
source: u,
|
|
215
373
|
measures: [
|
|
216
374
|
{ name: "net_tons", role: "measure" },
|
|
217
375
|
{ name: "ticket_value", role: "measure" }
|
|
@@ -249,38 +407,41 @@ const i = {
|
|
|
249
407
|
}
|
|
250
408
|
};
|
|
251
409
|
export {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
410
|
+
D as SEMAPHOR_ANALYTICS_INTENT_FIXTURES,
|
|
411
|
+
H as SEMAPHOR_ANALYZE_RESULT_FIELD_CONTRACT,
|
|
412
|
+
f as SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,
|
|
413
|
+
X as buildAnalyticsCatalogFieldSummary,
|
|
414
|
+
_ as buildSemaphorQualifiedSourcePath,
|
|
415
|
+
Z as getAnalyticsCatalogFieldCandidates,
|
|
416
|
+
J as getAnalyticsCatalogFieldName,
|
|
417
|
+
U as getSemaphorAnalyzeResultFieldNames,
|
|
418
|
+
w as getSemaphorConnectionCapabilities,
|
|
419
|
+
ee as isAnalyticsCatalogDateField,
|
|
420
|
+
ie as isAnalyticsCatalogDimensionField,
|
|
421
|
+
se as isAnalyticsCatalogMetricField,
|
|
422
|
+
re as isAnalyticsDateLikeDataType,
|
|
423
|
+
te as isAnalyticsMetricIdentifierField,
|
|
424
|
+
ae as isAnalyticsTechnicalIdentifierField,
|
|
425
|
+
Y as isSemaphorAnalyzeResultFieldName,
|
|
426
|
+
T as isSemaphorDataAppCodegenSummary,
|
|
427
|
+
ne as normalizeAnalyticsCatalogDataType,
|
|
428
|
+
oe as normalizeAnalyticsCatalogName,
|
|
429
|
+
O as normalizeSemaphorAnalyticsFilterOperator,
|
|
430
|
+
q as normalizeSemaphorDialect,
|
|
431
|
+
V as normalizeSemaphorInputOperator,
|
|
432
|
+
G as parseSemaphorAnalyzeResult,
|
|
433
|
+
L as parseSemaphorIsoTimeWindowBoundary,
|
|
434
|
+
ue as preferSemaphorFieldRefMetadata,
|
|
435
|
+
de as preferSemaphorSourceMetadata,
|
|
436
|
+
ce as semaphorFieldRefsMatch,
|
|
437
|
+
F as semaphorSourceHasRequiredCoordinates,
|
|
438
|
+
me as semaphorSourceIdentityKey,
|
|
439
|
+
pe as semaphorSourcesReferToSameDataset,
|
|
440
|
+
M as validateSemaphorAnalyticsIntent,
|
|
441
|
+
x as validateSemaphorAnalyticsRecoveryPlan,
|
|
442
|
+
B as validateSemaphorDashboardIntent,
|
|
443
|
+
g as validateSemaphorDataAppCodegenSummary,
|
|
444
|
+
P as validateSemaphorDerivedFieldDefinition,
|
|
445
|
+
z as validateSemaphorOperationIntent,
|
|
446
|
+
Q as validateSemaphorResultCalculation
|
|
286
447
|
};
|