@burdenoff/microfe-semanticfed 2026.1031.2 → 2026.1031.4
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/node_modules/clsx/dist/clsx.js +18 -0
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +1716 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
- package/dist/semanticfed/SemanticFedRoutes.js +24 -20
- package/dist/semanticfed/SemanticFedRoutes.js.map +1 -1
- package/dist/semanticfed/api/quotaRefusal.js +2 -1
- package/dist/semanticfed/api/quotaRefusal.js.map +1 -1
- package/dist/semanticfed/api/semanticfedGraphql.js +20 -11
- package/dist/semanticfed/api/semanticfedGraphql.js.map +1 -1
- package/dist/semanticfed/hooks/useLineage.js +62 -0
- package/dist/semanticfed/hooks/useLineage.js.map +1 -0
- package/dist/semanticfed/hooks/useSqlConsole.js +23 -20
- package/dist/semanticfed/hooks/useSqlConsole.js.map +1 -1
- package/dist/semanticfed/pages/LineagePage.js +441 -0
- package/dist/semanticfed/pages/LineagePage.js.map +1 -0
- package/dist/semanticfed/pages/QueryConsolePage.js +148 -148
- package/dist/semanticfed/pages/QueryConsolePage.js.map +1 -1
- package/dist/semanticfed/utils/cn.js +10 -0
- package/dist/semanticfed/utils/cn.js.map +1 -0
- package/package.json +1 -1
|
@@ -5,22 +5,31 @@ function i() {
|
|
|
5
5
|
let e = globalThis;
|
|
6
6
|
e.__graphqlFetchResponseCache?.clear(), e.__graphqlFetchPendingResponses?.clear(), e.__boffGraphQLResponseCache?.clear();
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var a = class extends Error {
|
|
9
|
+
code;
|
|
10
|
+
detail;
|
|
11
|
+
constructor(e, t, n) {
|
|
12
|
+
super(e), this.name = "SemRequestError", this.code = t, this.detail = n;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
async function o(o, s = {}, c) {
|
|
16
|
+
let l = await r({
|
|
10
17
|
gateway: "workspace",
|
|
11
|
-
baseUrl:
|
|
12
|
-
query:
|
|
13
|
-
variables:
|
|
18
|
+
baseUrl: c,
|
|
19
|
+
query: o,
|
|
20
|
+
variables: s,
|
|
14
21
|
workspaceToken: !0
|
|
15
22
|
});
|
|
16
|
-
if (
|
|
17
|
-
let r = n(
|
|
18
|
-
|
|
23
|
+
if (l.errors?.length) {
|
|
24
|
+
let r = n(l.errors);
|
|
25
|
+
if (r) throw t(r), new e(l.errors[0]?.message ?? "Plan limit reached", r);
|
|
26
|
+
let i = l.errors[0], o = i && typeof i == "object" && "extensions" in i && i.extensions ? i.extensions : {};
|
|
27
|
+
throw new a(i?.message ?? "GraphQL request failed", typeof o.code == "string" ? o.code : void 0, typeof o.technicalMessage == "string" ? o.technicalMessage : void 0);
|
|
19
28
|
}
|
|
20
|
-
if (!
|
|
21
|
-
return /^\s*mutation\b/.test(
|
|
29
|
+
if (!l.data) throw Error("GraphQL response did not include data");
|
|
30
|
+
return /^\s*mutation\b/.test(o) && i(), l.data;
|
|
22
31
|
}
|
|
23
32
|
//#endregion
|
|
24
|
-
export { a as semRequest };
|
|
33
|
+
export { a as SemRequestError, o as semRequest };
|
|
25
34
|
|
|
26
35
|
//# sourceMappingURL=semanticfedGraphql.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semanticfedGraphql.js","names":[],"sources":["../../../src/semanticfed/api/semanticfedGraphql.ts"],"sourcesContent":["/**\n * SemanticFed GraphQL transport.\n *\n * Every call goes to the workspace gateway with a workspace-scoped token,\n * both supplied by the host shell (`graphqlFetch({ gateway: 'workspace',\n * workspaceToken: true })`). Operations are inline documents whose fields\n * match the `wspace-semanticfed-svc` subgraph schema exactly.\n */\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { announceQuotaRefusal, findQuotaRefusal, SemQuotaError } from './quotaRefusal';\n\n/**\n * fe-libs `graphqlFetch` coalesces query responses in short-lived in-memory\n * caches. A read issued right after a write would otherwise return the\n * pre-mutation response, so every mutation clears those caches.\n */\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\nexport function clearGraphqlReadCaches(): void {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n}\n\nexport async function semRequest<TData>(\n query: string,\n variables: Record<string, unknown> = {},\n baseUrl?: string\n): Promise<TData> {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n // A plan-limit refusal (BOFF-3172) opens the shell's upgrade prompt and\n // throws a typed error, so callers can tell it apart from a failure.\n const refusal = findQuotaRefusal(response.errors);\n if (refusal) {\n announceQuotaRefusal(refusal);\n throw new SemQuotaError(response.errors[0]?.message ?? 'Plan limit reached', refusal);\n }\n
|
|
1
|
+
{"version":3,"file":"semanticfedGraphql.js","names":[],"sources":["../../../src/semanticfed/api/semanticfedGraphql.ts"],"sourcesContent":["/**\n * SemanticFed GraphQL transport.\n *\n * Every call goes to the workspace gateway with a workspace-scoped token,\n * both supplied by the host shell (`graphqlFetch({ gateway: 'workspace',\n * workspaceToken: true })`). Operations are inline documents whose fields\n * match the `wspace-semanticfed-svc` subgraph schema exactly.\n */\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { announceQuotaRefusal, findQuotaRefusal, SemQuotaError } from './quotaRefusal';\n\n/**\n * fe-libs `graphqlFetch` coalesces query responses in short-lived in-memory\n * caches. A read issued right after a write would otherwise return the\n * pre-mutation response, so every mutation clears those caches.\n */\ntype GraphqlReadCacheGlobals = {\n __graphqlFetchResponseCache?: { clear: () => void };\n __graphqlFetchPendingResponses?: { clear: () => void };\n __boffGraphQLResponseCache?: { clear: () => void };\n};\n\nexport function clearGraphqlReadCaches(): void {\n const g = globalThis as GraphqlReadCacheGlobals;\n g.__graphqlFetchResponseCache?.clear();\n g.__graphqlFetchPendingResponses?.clear();\n g.__boffGraphQLResponseCache?.clear();\n}\n\n/**\n * A GraphQL error returned by the gateway. `message` is the gateway's\n * user-facing text, which it generalises for client errors (\"Please check the\n * information and try again.\"); `detail` carries the service's own\n * explanation (`extensions.technicalMessage`), which surfaces such as the SQL\n * console show because it names the exact problem (BOFF-4271).\n */\nexport class SemRequestError extends Error {\n readonly code: string | undefined;\n readonly detail: string | undefined;\n\n constructor(message: string, code: string | undefined, detail: string | undefined) {\n super(message);\n this.name = 'SemRequestError';\n this.code = code;\n this.detail = detail;\n }\n}\n\nexport async function semRequest<TData>(\n query: string,\n variables: Record<string, unknown> = {},\n baseUrl?: string\n): Promise<TData> {\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (response.errors?.length) {\n // A plan-limit refusal (BOFF-3172) opens the shell's upgrade prompt and\n // throws a typed error, so callers can tell it apart from a failure.\n const refusal = findQuotaRefusal(response.errors);\n if (refusal) {\n announceQuotaRefusal(refusal);\n throw new SemQuotaError(response.errors[0]?.message ?? 'Plan limit reached', refusal);\n }\n const first = response.errors[0];\n const extensions: Record<string, unknown> =\n first && typeof first === 'object' && 'extensions' in first && first.extensions\n ? (first.extensions as Record<string, unknown>)\n : {};\n throw new SemRequestError(\n first?.message ?? 'GraphQL request failed',\n typeof extensions.code === 'string' ? extensions.code : undefined,\n typeof extensions.technicalMessage === 'string' ? extensions.technicalMessage : undefined\n );\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n if (/^\\s*mutation\\b/.test(query)) {\n clearGraphqlReadCaches();\n }\n return response.data;\n}\n"],"mappings":";;;AAuBA,SAAgB,IAA+B;CAC7C,IAAM,IAAI;AAGV,CAFA,EAAE,6BAA6B,OAAO,EACtC,EAAE,gCAAgC,OAAO,EACzC,EAAE,4BAA4B,OAAO;;AAUvC,IAAa,IAAb,cAAqC,MAAM;CACzC;CACA;CAEA,YAAY,GAAiB,GAA0B,GAA4B;AAIjF,EAHA,MAAM,EAAQ,EACd,KAAK,OAAO,mBACZ,KAAK,OAAO,GACZ,KAAK,SAAS;;;AAIlB,eAAsB,EACpB,GACA,IAAqC,EAAE,EACvC,GACgB;CAChB,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAEF,KAAI,EAAS,QAAQ,QAAQ;EAG3B,IAAM,IAAU,EAAiB,EAAS,OAAO;AACjD,MAAI,EAEF,OADA,EAAqB,EAAQ,EACvB,IAAI,EAAc,EAAS,OAAO,IAAI,WAAW,sBAAsB,EAAQ;EAEvF,IAAM,IAAQ,EAAS,OAAO,IACxB,IACJ,KAAS,OAAO,KAAU,YAAY,gBAAgB,KAAS,EAAM,aAChE,EAAM,aACP,EAAE;AACR,QAAM,IAAI,EACR,GAAO,WAAW,0BAClB,OAAO,EAAW,QAAS,WAAW,EAAW,OAAO,KAAA,GACxD,OAAO,EAAW,oBAAqB,WAAW,EAAW,mBAAmB,KAAA,EACjF;;AAEH,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAK1D,QAHI,iBAAiB,KAAK,EAAM,IAC9B,GAAwB,EAEnB,EAAS"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useSemanticFed as e } from "../providers/SemanticFedProvider.js";
|
|
2
|
+
import { SemRequestError as t, semRequest as n } from "../api/semanticfedGraphql.js";
|
|
3
|
+
import { useQuery as r } from "@tanstack/react-query";
|
|
4
|
+
//#region src/semanticfed/hooks/useLineage.ts
|
|
5
|
+
var i = [
|
|
6
|
+
"CONNECTOR",
|
|
7
|
+
"DATA_SOURCE",
|
|
8
|
+
"ENTITY",
|
|
9
|
+
"DIMENSION",
|
|
10
|
+
"METRIC",
|
|
11
|
+
"MODEL",
|
|
12
|
+
"QUERY"
|
|
13
|
+
];
|
|
14
|
+
function a(e) {
|
|
15
|
+
return !e.refId || !i.includes(e.kind) ? null : {
|
|
16
|
+
kind: e.kind,
|
|
17
|
+
id: e.refId
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var o = "query SemLineage(\n $rootKind: SemLineageRootKind\n $rootId: ID\n $direction: SemLineageDirection\n $depth: Int\n) {\n semLineage(rootKind: $rootKind, rootId: $rootId, direction: $direction, depth: $depth) {\n rootId\n direction\n truncated\n nodes {\n id\n kind\n refId\n label\n detail\n status\n parentId\n }\n edges {\n id\n kind\n from\n to\n detail\n observedAt\n }\n warnings {\n nodeId\n message\n }\n }\n}";
|
|
21
|
+
function s() {
|
|
22
|
+
let { apiGatewayUrl: t, workspaceId: i } = e();
|
|
23
|
+
return r({
|
|
24
|
+
queryKey: [
|
|
25
|
+
"semanticfed",
|
|
26
|
+
"lineage",
|
|
27
|
+
i ?? "no-workspace",
|
|
28
|
+
"workspace"
|
|
29
|
+
],
|
|
30
|
+
enabled: !!i,
|
|
31
|
+
queryFn: async () => (await n(o, {}, t)).semLineage
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function c(t, i, a) {
|
|
35
|
+
let { apiGatewayUrl: s, workspaceId: c } = e();
|
|
36
|
+
return r({
|
|
37
|
+
queryKey: [
|
|
38
|
+
"semanticfed",
|
|
39
|
+
"lineage",
|
|
40
|
+
c ?? "no-workspace",
|
|
41
|
+
"record",
|
|
42
|
+
t?.kind ?? null,
|
|
43
|
+
t?.id ?? null,
|
|
44
|
+
i,
|
|
45
|
+
a
|
|
46
|
+
],
|
|
47
|
+
enabled: !!(c && t),
|
|
48
|
+
queryFn: async () => (await n(o, {
|
|
49
|
+
rootKind: t?.kind,
|
|
50
|
+
rootId: t?.id,
|
|
51
|
+
direction: i,
|
|
52
|
+
depth: a
|
|
53
|
+
}, s)).semLineage
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function l(e) {
|
|
57
|
+
return e instanceof t && e.detail && e.code !== "INTERNAL_SERVER_ERROR" ? e.detail : e instanceof Error ? e.message : String(e);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { l as lineageErrorMessage, a as lineageRootFor, c as useSemRecordLineage, s as useSemWorkspaceLineage };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=useLineage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLineage.js","names":[],"sources":["../../../src/semanticfed/hooks/useLineage.ts"],"sourcesContent":["/**\n * Lineage hooks, wired to the `wspace-semanticfed-svc` lineage API\n * (BOFF-4279). `semLineage` computes end-to-end lineage on read from the\n * semantic layer: connector → data source → physical table → entity →\n * dimension / metric → saved query, plus model membership and the data\n * sources each query's latest successful run actually read.\n */\nimport { useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError, semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemLineageNodeKind =\n | 'CONNECTOR'\n | 'DATA_SOURCE'\n | 'TABLE'\n | 'ENTITY'\n | 'DIMENSION'\n | 'METRIC'\n | 'COLUMN'\n | 'MODEL'\n | 'QUERY';\n\nexport type SemLineageRootKind = Exclude<SemLineageNodeKind, 'TABLE' | 'COLUMN'>;\n\nexport type SemLineageEdgeKind =\n | 'PROVIDES'\n | 'HOSTS'\n | 'MAPS_TO'\n | 'DEFINES'\n | 'MEMBER_OF'\n | 'JOINS'\n | 'SERVES'\n | 'READ_BY'\n | 'EXECUTED_ON';\n\nexport type SemLineageDirection = 'UPSTREAM' | 'DOWNSTREAM' | 'BOTH';\n\nexport interface SemLineageNode {\n id: string;\n kind: SemLineageNodeKind;\n refId: string | null;\n label: string;\n detail: string | null;\n status: string | null;\n parentId: string | null;\n}\n\nexport interface SemLineageEdge {\n id: string;\n kind: SemLineageEdgeKind;\n from: string;\n to: string;\n detail: string | null;\n observedAt: string | null;\n}\n\nexport interface SemLineageWarning {\n nodeId: string | null;\n message: string;\n}\n\nexport interface SemLineageGraph {\n rootId: string | null;\n direction: SemLineageDirection;\n nodes: SemLineageNode[];\n edges: SemLineageEdge[];\n warnings: SemLineageWarning[];\n truncated: boolean;\n}\n\nexport interface SemLineageRoot {\n kind: SemLineageRootKind;\n id: string;\n}\n\nconst ROOT_KINDS: readonly SemLineageNodeKind[] = [\n 'CONNECTOR',\n 'DATA_SOURCE',\n 'ENTITY',\n 'DIMENSION',\n 'METRIC',\n 'MODEL',\n 'QUERY',\n];\n\n/** The traversal root for a node, or null for node kinds the API cannot start from. */\nexport function lineageRootFor(node: SemLineageNode): SemLineageRoot | null {\n if (!node.refId || !ROOT_KINDS.includes(node.kind)) return null;\n return { kind: node.kind as SemLineageRootKind, id: node.refId };\n}\n\nconst LINEAGE_QUERY = `query SemLineage(\n $rootKind: SemLineageRootKind\n $rootId: ID\n $direction: SemLineageDirection\n $depth: Int\n) {\n semLineage(rootKind: $rootKind, rootId: $rootId, direction: $direction, depth: $depth) {\n rootId\n direction\n truncated\n nodes {\n id\n kind\n refId\n label\n detail\n status\n parentId\n }\n edges {\n id\n kind\n from\n to\n detail\n observedAt\n }\n warnings {\n nodeId\n message\n }\n }\n}`;\n\n/** The whole-workspace lineage graph. */\nexport function useSemWorkspaceLineage() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'lineage', workspaceId ?? 'no-workspace', 'workspace'] as const,\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n {},\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The upstream / downstream lineage of one record; idle until a root is chosen. */\nexport function useSemRecordLineage(\n root: SemLineageRoot | null,\n direction: SemLineageDirection,\n depth: number | null\n) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: [\n 'semanticfed',\n 'lineage',\n workspaceId ?? 'no-workspace',\n 'record',\n root?.kind ?? null,\n root?.id ?? null,\n direction,\n depth,\n ] as const,\n enabled: Boolean(workspaceId && root),\n queryFn: async () => {\n const data = await semRequest<{ semLineage: SemLineageGraph }>(\n LINEAGE_QUERY,\n { rootKind: root?.kind, rootId: root?.id, direction, depth },\n apiGatewayUrl\n );\n return data.semLineage;\n },\n });\n}\n\n/** The text to show for a failed lineage request, preferring the service's own explanation. */\nexport function lineageErrorMessage(error: unknown): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return error.detail;\n }\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;;AA4EA,IAAM,IAA4C;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAGD,SAAgB,EAAe,GAA6C;AAE1E,QADI,CAAC,EAAK,SAAS,CAAC,EAAW,SAAS,EAAK,KAAK,GAAS,OACpD;EAAE,MAAM,EAAK;EAA4B,IAAI,EAAK;EAAO;;AAGlE,IAAM,IAAgB;AAmCtB,SAAgB,IAAyB;CACvC,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GAAC;GAAe;GAAW,KAAe;GAAgB;GAAY;EAChF,SAAS,EAAQ;EACjB,SAAS,aACM,MAAM,EACjB,GACA,EAAE,EACF,EACD,EACW;EAEf,CAAC;;AAIJ,SAAgB,EACd,GACA,GACA,GACA;CACA,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GACR;GACA;GACA,KAAe;GACf;GACA,GAAM,QAAQ;GACd,GAAM,MAAM;GACZ;GACA;GACD;EACD,SAAS,GAAQ,KAAe;EAChC,SAAS,aACM,MAAM,EACjB,GACA;GAAE,UAAU,GAAM;GAAM,QAAQ,GAAM;GAAI;GAAW;GAAO,EAC5D,EACD,EACW;EAEf,CAAC;;AAIJ,SAAgB,EAAoB,GAAwB;AAI1D,QAHI,aAAiB,KAAmB,EAAM,UAAU,EAAM,SAAS,0BAC9D,EAAM,SAER,aAAiB,QAAQ,EAAM,UAAU,OAAO,EAAM"}
|
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import { useSemanticFed as e } from "../providers/SemanticFedProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import { useMutation as
|
|
2
|
+
import { SemRequestError as t, semRequest as n } from "../api/semanticfedGraphql.js";
|
|
3
|
+
import { useMutation as r, useQuery as i } from "@tanstack/react-query";
|
|
4
4
|
//#region src/semanticfed/hooks/useSqlConsole.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
let { apiGatewayUrl:
|
|
8
|
-
return
|
|
5
|
+
var a = "query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}", o = "query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}", s = "mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}", c = 100;
|
|
6
|
+
function l() {
|
|
7
|
+
let { apiGatewayUrl: t, workspaceId: r } = e();
|
|
8
|
+
return i({
|
|
9
9
|
queryKey: [
|
|
10
10
|
"semanticfed",
|
|
11
11
|
"sql",
|
|
12
12
|
"models",
|
|
13
|
-
|
|
13
|
+
r ?? "no-workspace"
|
|
14
14
|
],
|
|
15
|
-
enabled: !!
|
|
16
|
-
queryFn: async () => (await
|
|
15
|
+
enabled: !!r,
|
|
16
|
+
queryFn: async () => (await n(a, { pagination: { limit: c } }, t)).semListModels.items
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let { apiGatewayUrl:
|
|
21
|
-
return
|
|
19
|
+
function u(t) {
|
|
20
|
+
let { apiGatewayUrl: r, workspaceId: a } = e();
|
|
21
|
+
return i({
|
|
22
22
|
queryKey: [
|
|
23
23
|
"semanticfed",
|
|
24
24
|
"sql",
|
|
25
25
|
"catalog",
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
a ?? "no-workspace",
|
|
27
|
+
t
|
|
28
28
|
],
|
|
29
|
-
enabled: !!(
|
|
30
|
-
queryFn: async () => (await
|
|
29
|
+
enabled: !!(a && t),
|
|
30
|
+
queryFn: async () => (await n(o, { modelId: t }, r)).semSqlCatalog
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
let { apiGatewayUrl:
|
|
35
|
-
return
|
|
33
|
+
function d() {
|
|
34
|
+
let { apiGatewayUrl: t } = e();
|
|
35
|
+
return r({ mutationFn: async (e) => (await n(s, { input: e }, t)).semExecuteSql });
|
|
36
|
+
}
|
|
37
|
+
function f(e) {
|
|
38
|
+
return e instanceof t && e.detail && e.code !== "INTERNAL_SERVER_ERROR" ? e.detail : e instanceof Error ? e.message : String(e);
|
|
36
39
|
}
|
|
37
40
|
//#endregion
|
|
38
|
-
export {
|
|
41
|
+
export { f as sqlErrorMessage, d as useSemExecuteSql, u as useSemSqlCatalog, l as useSemSqlModels };
|
|
39
42
|
|
|
40
43
|
//# sourceMappingURL=useSqlConsole.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSqlConsole.js","names":[],"sources":["../../../src/semanticfed/hooks/useSqlConsole.ts"],"sourcesContent":["/**\n * SQL console hooks, wired to the real `wspace-semanticfed-svc` SQL endpoint\n * (BOFF-4271): `semListModels` to pick a semantic model, `semSqlCatalog` for\n * the table/column browser and `semExecuteSql` to run a read-only SELECT\n * through the federated query engine with the caller's access policies.\n */\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemSqlDataType =\n | 'STRING'\n | 'INTEGER'\n | 'DECIMAL'\n | 'BOOLEAN'\n | 'DATE'\n | 'TIMESTAMP'\n | 'JSON'\n | 'GEO'\n | 'UNKNOWN';\n\nexport interface SemModelSummary {\n id: string;\n name: string;\n status: string;\n}\n\nexport interface SemSqlCatalogColumn {\n name: string;\n kind: 'DIMENSION' | 'METRIC';\n dataType: SemSqlDataType;\n aggregation: string | null;\n description: string | null;\n isPrimary: boolean;\n}\n\nexport interface SemSqlCatalogTable {\n name: string;\n kind: string;\n description: string | null;\n primaryKey: string | null;\n columns: SemSqlCatalogColumn[];\n}\n\nexport interface SemSqlCatalog {\n modelId: string;\n modelName: string;\n tables: SemSqlCatalogTable[];\n}\n\nexport interface SemSqlResultColumn {\n name: string;\n entity: string;\n field: string;\n aggregation: string | null;\n dataType: SemSqlDataType;\n masked: boolean;\n mask: string | null;\n}\n\nexport interface SemSqlResult {\n modelId: string;\n columns: SemSqlResultColumn[];\n rows: Array<Record<string, unknown>>;\n rowCount: number;\n truncated: boolean;\n durationMs: number;\n sourcesTouched: number;\n}\n\nexport interface SemExecuteSqlInput {\n sql: string;\n modelId: string;\n maxRows?: number;\n}\n\nconst LIST_MODELS_QUERY = `query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}`;\n\nconst SQL_CATALOG_QUERY = `query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}`;\n\nconst EXECUTE_SQL_MUTATION = `mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}`;\n\n/** Largest model list the console offers (the picker is not paginated). */\nconst MODEL_PICKER_LIMIT = 100;\n\nexport function useSemSqlModels() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'models', workspaceId ?? 'no-workspace'] as const,\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semListModels: { items: SemModelSummary[] } }>(\n LIST_MODELS_QUERY,\n { pagination: { limit: MODEL_PICKER_LIMIT } },\n apiGatewayUrl\n );\n return data.semListModels.items;\n },\n });\n}\n\nexport function useSemSqlCatalog(modelId: string | null) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'catalog', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: Boolean(workspaceId && modelId),\n queryFn: async () => {\n const data = await semRequest<{ semSqlCatalog: SemSqlCatalog }>(\n SQL_CATALOG_QUERY,\n { modelId },\n apiGatewayUrl\n );\n return data.semSqlCatalog;\n },\n });\n}\n\nexport function useSemExecuteSql() {\n const { apiGatewayUrl } = useSemanticFed();\n return useMutation({\n mutationFn: async (input: SemExecuteSqlInput) => {\n const data = await semRequest<{ semExecuteSql: SemSqlResult }>(\n EXECUTE_SQL_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semExecuteSql;\n },\n });\n}\n"],"mappings":";;;;AA6EA,IAAM,IAAoB,yKAUpB,IAAoB,wUAqBpB,IAAuB,qTAqBvB,IAAqB;AAE3B,SAAgB,IAAkB;CAChC,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAU,KAAe;GAAe;EACzE,SAAS,EAAQ;EACjB,SAAS,aACM,MAAM,EACjB,GACA,EAAE,YAAY,EAAE,OAAO,GAAoB,EAAE,EAC7C,EACD,EACW,cAAc;EAE7B,CAAC;;AAGJ,SAAgB,EAAiB,GAAwB;CACvD,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAW,KAAe;GAAgB;GAAQ;EACnF,SAAS,GAAQ,KAAe;EAChC,SAAS,aACM,MAAM,EACjB,GACA,EAAE,YAAS,EACX,EACD,EACW;EAEf,CAAC;;AAGJ,SAAgB,IAAmB;CACjC,IAAM,EAAE,qBAAkB,GAAgB;AAC1C,QAAO,EAAY,EACjB,YAAY,OAAO,OACJ,MAAM,EACjB,GACA,EAAE,UAAO,EACT,EACD,EACW,eAEf,CAAC"}
|
|
1
|
+
{"version":3,"file":"useSqlConsole.js","names":[],"sources":["../../../src/semanticfed/hooks/useSqlConsole.ts"],"sourcesContent":["/**\n * SQL console hooks, wired to the real `wspace-semanticfed-svc` SQL endpoint\n * (BOFF-4271): `semListModels` to pick a semantic model, `semSqlCatalog` for\n * the table/column browser and `semExecuteSql` to run a read-only SELECT\n * through the federated query engine with the caller's access policies.\n */\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { SemRequestError, semRequest } from '../api/semanticfedGraphql';\nimport { useSemanticFed } from '../providers/SemanticFedProvider';\n\nexport type SemSqlDataType =\n | 'STRING'\n | 'INTEGER'\n | 'DECIMAL'\n | 'BOOLEAN'\n | 'DATE'\n | 'TIMESTAMP'\n | 'JSON'\n | 'GEO'\n | 'UNKNOWN';\n\nexport interface SemModelSummary {\n id: string;\n name: string;\n status: string;\n}\n\nexport interface SemSqlCatalogColumn {\n name: string;\n kind: 'DIMENSION' | 'METRIC';\n dataType: SemSqlDataType;\n aggregation: string | null;\n description: string | null;\n isPrimary: boolean;\n}\n\nexport interface SemSqlCatalogTable {\n name: string;\n kind: string;\n description: string | null;\n primaryKey: string | null;\n columns: SemSqlCatalogColumn[];\n}\n\nexport interface SemSqlCatalog {\n modelId: string;\n modelName: string;\n tables: SemSqlCatalogTable[];\n}\n\nexport interface SemSqlResultColumn {\n name: string;\n entity: string;\n field: string;\n aggregation: string | null;\n dataType: SemSqlDataType;\n masked: boolean;\n mask: string | null;\n}\n\nexport interface SemSqlResult {\n modelId: string;\n columns: SemSqlResultColumn[];\n rows: Array<Record<string, unknown>>;\n rowCount: number;\n truncated: boolean;\n durationMs: number;\n sourcesTouched: number;\n}\n\nexport interface SemExecuteSqlInput {\n sql: string;\n modelId: string;\n maxRows?: number;\n}\n\nconst LIST_MODELS_QUERY = `query SemSqlConsoleModels($pagination: PaginationInput) {\n semListModels(pagination: $pagination) {\n items {\n id\n name\n status\n }\n }\n}`;\n\nconst SQL_CATALOG_QUERY = `query SemSqlCatalog($modelId: ID) {\n semSqlCatalog(modelId: $modelId) {\n modelId\n modelName\n tables {\n name\n kind\n description\n primaryKey\n columns {\n name\n kind\n dataType\n aggregation\n description\n isPrimary\n }\n }\n }\n}`;\n\nconst EXECUTE_SQL_MUTATION = `mutation SemExecuteSql($input: SemExecuteSqlInput!) {\n semExecuteSql(input: $input) {\n modelId\n columns {\n name\n entity\n field\n aggregation\n dataType\n masked\n mask\n }\n rows\n rowCount\n truncated\n durationMs\n sourcesTouched\n }\n}`;\n\n/** Largest model list the console offers (the picker is not paginated). */\nconst MODEL_PICKER_LIMIT = 100;\n\nexport function useSemSqlModels() {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'models', workspaceId ?? 'no-workspace'] as const,\n enabled: Boolean(workspaceId),\n queryFn: async () => {\n const data = await semRequest<{ semListModels: { items: SemModelSummary[] } }>(\n LIST_MODELS_QUERY,\n { pagination: { limit: MODEL_PICKER_LIMIT } },\n apiGatewayUrl\n );\n return data.semListModels.items;\n },\n });\n}\n\nexport function useSemSqlCatalog(modelId: string | null) {\n const { apiGatewayUrl, workspaceId } = useSemanticFed();\n return useQuery({\n queryKey: ['semanticfed', 'sql', 'catalog', workspaceId ?? 'no-workspace', modelId] as const,\n enabled: Boolean(workspaceId && modelId),\n queryFn: async () => {\n const data = await semRequest<{ semSqlCatalog: SemSqlCatalog }>(\n SQL_CATALOG_QUERY,\n { modelId },\n apiGatewayUrl\n );\n return data.semSqlCatalog;\n },\n });\n}\n\nexport function useSemExecuteSql() {\n const { apiGatewayUrl } = useSemanticFed();\n return useMutation({\n mutationFn: async (input: SemExecuteSqlInput) => {\n const data = await semRequest<{ semExecuteSql: SemSqlResult }>(\n EXECUTE_SQL_MUTATION,\n { input },\n apiGatewayUrl\n );\n return data.semExecuteSql;\n },\n });\n}\n\n/**\n * The text to show for a failed SQL statement. The gateway generalises client\n * errors, so the service's own explanation (syntax position, unknown column,\n * policy denial) is preferred whenever the service sent one.\n */\nexport function sqlErrorMessage(error: unknown): string {\n if (error instanceof SemRequestError && error.detail && error.code !== 'INTERNAL_SERVER_ERROR') {\n return error.detail;\n }\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;;AA6EA,IAAM,IAAoB,yKAUpB,IAAoB,wUAqBpB,IAAuB,qTAqBvB,IAAqB;AAE3B,SAAgB,IAAkB;CAChC,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAU,KAAe;GAAe;EACzE,SAAS,EAAQ;EACjB,SAAS,aACM,MAAM,EACjB,GACA,EAAE,YAAY,EAAE,OAAO,GAAoB,EAAE,EAC7C,EACD,EACW,cAAc;EAE7B,CAAC;;AAGJ,SAAgB,EAAiB,GAAwB;CACvD,IAAM,EAAE,kBAAe,mBAAgB,GAAgB;AACvD,QAAO,EAAS;EACd,UAAU;GAAC;GAAe;GAAO;GAAW,KAAe;GAAgB;GAAQ;EACnF,SAAS,GAAQ,KAAe;EAChC,SAAS,aACM,MAAM,EACjB,GACA,EAAE,YAAS,EACX,EACD,EACW;EAEf,CAAC;;AAGJ,SAAgB,IAAmB;CACjC,IAAM,EAAE,qBAAkB,GAAgB;AAC1C,QAAO,EAAY,EACjB,YAAY,OAAO,OACJ,MAAM,EACjB,GACA,EAAE,UAAO,EACT,EACD,EACW,eAEf,CAAC;;AAQJ,SAAgB,EAAgB,GAAwB;AAItD,QAHI,aAAiB,KAAmB,EAAM,UAAU,EAAM,SAAS,0BAC9D,EAAM,SAER,aAAiB,QAAQ,EAAM,UAAU,OAAO,EAAM"}
|