react-semaphor 0.1.472 → 0.1.474

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +102 -94
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.js +4 -4
  6. package/dist/chunks/{analyze-result-contract-B3agc2XU.js → analyze-result-contract-C8s8EUL5.js} +1 -1
  7. package/dist/chunks/{common-types-g_1fKJLK.js → common-types-BLPy5_E0.js} +1 -1
  8. package/dist/chunks/{dashboard-briefing-launcher-Lw4gjW_M.js → dashboard-briefing-launcher-B0f28WrK.js} +9 -9
  9. package/dist/chunks/{dashboard-briefing-launcher-8vxGyexK.cjs → dashboard-briefing-launcher-BjCkA5vw.cjs} +1 -1
  10. package/dist/chunks/{dashboard-controls-BKR8g3M9.cjs → dashboard-controls-BRclCQEX.cjs} +1 -1
  11. package/dist/chunks/{dashboard-controls-CRgDlxdt.js → dashboard-controls-CMJqSLgo.js} +9 -9
  12. package/dist/chunks/{dashboard-filter-value-compatibility-ilbH2A31.js → dashboard-filter-value-compatibility-9W8Ckcle.js} +168 -158
  13. package/dist/chunks/dashboard-filter-value-compatibility-Co1dn9Bc.cjs +1 -0
  14. package/dist/chunks/{dashboard-input-contract-Vr_3ApfF.js → dashboard-input-contract-BrGdGFz0.js} +6 -6
  15. package/dist/chunks/{dashboard-json-BhhVg9mI.js → dashboard-json-1ohpjO_q.js} +7 -7
  16. package/dist/chunks/{dashboard-json-CUgAzrYq.cjs → dashboard-json-DmtGHdDq.cjs} +1 -1
  17. package/dist/chunks/{edit-dashboard-visual-DlQtYQOO.js → edit-dashboard-visual-D9oKtOo6.js} +12 -12
  18. package/dist/chunks/{edit-dashboard-visual-BxmanBVo.cjs → edit-dashboard-visual-DNqJHdHE.cjs} +1 -1
  19. package/dist/chunks/{editor-action-buttons-CRWacpxi.js → editor-action-buttons-C_B8Wzkf.js} +6 -6
  20. package/dist/chunks/{editor-action-buttons-DKcD0UQy.cjs → editor-action-buttons-DwI3FcSw.cjs} +1 -1
  21. package/dist/chunks/{index-xdqe-Zvd.cjs → index-B6zSYUN4.cjs} +167 -167
  22. package/dist/chunks/{index-0fmECZL2.js → index-DalKzjEZ.js} +31914 -31864
  23. package/dist/chunks/{index-oVXvCLH-.js → index-DsvIlrI-.js} +9 -9
  24. package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +1 -0
  25. package/dist/chunks/matrix-result-contract-BpzhImar.js +421 -0
  26. package/dist/chunks/{pivot-header-presentation-7XrwJYDm.js → pivot-header-presentation-Be3FyR0N.js} +2 -2
  27. package/dist/chunks/{pivot-result-identity-5v4hRVbc.js → pivot-result-identity-CIZXsI53.js} +1 -1
  28. package/dist/chunks/{pivot-result-lifecycle-O_roVguV.js → pivot-result-lifecycle-PxmbJWkm.js} +19 -19
  29. package/dist/chunks/{raw-temporal-contract-BEMf3avg.js → raw-temporal-contract-U8J9RlEH.js} +1 -1
  30. package/dist/chunks/{report-preferences-dialog-Dxt9XMpd.js → report-preferences-dialog-C9mJffNQ.js} +6 -6
  31. package/dist/chunks/{report-preferences-dialog-8KYKazoG.cjs → report-preferences-dialog-DGMd-eTT.cjs} +1 -1
  32. package/dist/chunks/{report-runtime-context-DnNbpkGo.js → report-runtime-context-DNbgCsko.js} +7 -7
  33. package/dist/chunks/{saved-temporal-bucket-format-CygnBDO2.js → saved-temporal-bucket-format-CHsXUPJI.js} +8 -8
  34. package/dist/chunks/source-entity-resolution-BDC-Qngk.cjs +1 -0
  35. package/dist/chunks/source-entity-resolution-ugN3sZUk.js +781 -0
  36. package/dist/chunks/{switch-CQN9Hzho.cjs → switch-B4eH4guz.cjs} +13 -13
  37. package/dist/chunks/{switch-n2yUNY8i.js → switch-D20CIzj6.js} +1460 -1455
  38. package/dist/chunks/{temporal-bucket-CUKJktCl.js → temporal-bucket-CtP7hKLa.js} +12 -12
  39. package/dist/chunks/{temporal-bucket-authoring-CZoJV2L6.js → temporal-bucket-authoring-DJ9kK2wD.js} +3 -3
  40. package/dist/chunks/{temporal-bucket-contract-Cno9TlYr.js → temporal-bucket-contract-CZl5D7FZ.js} +1 -1
  41. package/dist/chunks/{token-types-W3EHNW-D.js → token-types-DfDtCqlw.js} +1 -1
  42. package/dist/chunks/{update-policy-kRNJwwUV.js → update-policy-BybMiM61.js} +1 -1
  43. package/dist/chunks/{validators-B5t1s8oh.js → validators-D-T-2HOR.js} +50 -50
  44. package/dist/dashboard/index.cjs +1 -1
  45. package/dist/dashboard/index.js +2 -2
  46. package/dist/dashboard-authoring/index.cjs +3 -3
  47. package/dist/dashboard-authoring/index.js +355 -341
  48. package/dist/data-app-builder/index.cjs +1 -1
  49. package/dist/data-app-builder/index.js +2 -2
  50. package/dist/data-app-codegen/index.js +2 -2
  51. package/dist/data-app-codegen-node/index.js +3 -3
  52. package/dist/data-app-sdk/index.js +3 -3
  53. package/dist/data-app-sdk-adapters/index.js +2 -2
  54. package/dist/data-app-sdk-validation/index.js +9 -9
  55. package/dist/format-utils/index.js +10 -10
  56. package/dist/index.cjs +1 -1
  57. package/dist/index.js +14 -14
  58. package/dist/report-runtime-context/index.js +2 -2
  59. package/dist/surfboard/index.cjs +1 -1
  60. package/dist/surfboard/index.js +3 -3
  61. package/dist/types/analytics-protocol.d.ts +141 -0
  62. package/dist/types/index.js +4 -4
  63. package/dist/types/main.d.ts +7 -0
  64. package/package.json +1 -1
  65. package/dist/chunks/dashboard-filter-value-compatibility-Dmh-NaPK.cjs +0 -1
  66. package/dist/chunks/matrix-result-contract-DoU9diAh.js +0 -822
  67. package/dist/chunks/matrix-result-contract-SrzyG_KQ.cjs +0 -1
@@ -0,0 +1,781 @@
1
+ import { af as K } from "./validators-D-T-2HOR.js";
2
+ function p(e) {
3
+ const i = Y(e);
4
+ return i.length > 0 ? i.join(".") : void 0;
5
+ }
6
+ function Q(e) {
7
+ const i = p(
8
+ e.qualifiedName
9
+ ), t = (i == null ? void 0 : i.split(".")) || [];
10
+ if (t.length === 0) return {};
11
+ const a = {};
12
+ let s = t.length - 1;
13
+ for (let r = e.capabilities.prefixLevels.length - 1; r >= 0 && s >= 0; r -= 1, s -= 1)
14
+ X(
15
+ a,
16
+ e.capabilities.prefixLevels[r],
17
+ t[s]
18
+ );
19
+ return a;
20
+ }
21
+ function _(e) {
22
+ return !e.left.tableName || !e.right.tableName ? !1 : e.capabilities.prefixLevels.every((i) => {
23
+ const t = C(e.left, i), a = C(e.right, i);
24
+ return !t || !a || t === a;
25
+ });
26
+ }
27
+ function he(e) {
28
+ return e.capabilities.prefixLevels.every((i) => {
29
+ const t = C(e.requested, i);
30
+ return t ? C(e.allowed, i) === t : !0;
31
+ });
32
+ }
33
+ function U(e, i = {}) {
34
+ const t = j(e), a = {
35
+ connectionId: i.connectionId,
36
+ connectionType: e,
37
+ path: ["database", "schema", "table"],
38
+ labels: {
39
+ database: "Database",
40
+ schema: "Schema",
41
+ table: "Table"
42
+ },
43
+ prefixLevels: ["database", "schema", "table"],
44
+ dialect: "postgres",
45
+ supportsFilterClause: !0
46
+ };
47
+ return t.includes("postgres") ? {
48
+ ...a,
49
+ prefixLevels: ["schema", "table"],
50
+ dialect: "postgres"
51
+ } : t.includes("mysql") ? {
52
+ ...a,
53
+ prefixLevels: ["database", "table"],
54
+ dialect: "mysql",
55
+ supportsFilterClause: !1
56
+ } : t.includes("mssql") || t.includes("sqlserver") ? {
57
+ ...a,
58
+ dialect: "mssql",
59
+ supportsFilterClause: !1
60
+ } : t.includes("redshift") ? {
61
+ ...a,
62
+ prefixLevels: ["schema", "table"],
63
+ dialect: "redshift"
64
+ } : t.includes("snowflake") ? {
65
+ ...a,
66
+ dialect: "snowflake"
67
+ } : t.includes("clickhouse") ? {
68
+ connectionId: i.connectionId,
69
+ connectionType: e,
70
+ path: ["database", "table"],
71
+ labels: {
72
+ database: "Database",
73
+ table: "Table"
74
+ },
75
+ prefixLevels: ["database", "table"],
76
+ dialect: "clickhouse",
77
+ supportsFilterClause: !1
78
+ } : t === "s3" || t === "api" ? {
79
+ connectionId: i.connectionId,
80
+ connectionType: e,
81
+ path: ["table"],
82
+ labels: {
83
+ table: t === "api" ? "API Table" : "File Table"
84
+ },
85
+ prefixLevels: ["table"],
86
+ dialect: "duckdb",
87
+ supportsFilterClause: !0
88
+ } : t === "googlesheets" || t === "fileupload" ? {
89
+ connectionId: i.connectionId,
90
+ connectionType: e,
91
+ path: ["table"],
92
+ labels: {
93
+ table: "Table"
94
+ },
95
+ prefixLevels: ["table"],
96
+ dialect: "postgres",
97
+ supportsFilterClause: !0
98
+ } : t === "s3tables" ? {
99
+ ...a,
100
+ labels: {
101
+ database: "Database",
102
+ schema: "Namespace",
103
+ table: "Table"
104
+ },
105
+ dialect: "duckdb"
106
+ } : t === "bigquery" ? {
107
+ ...a,
108
+ labels: {
109
+ database: "Project",
110
+ schema: "Dataset",
111
+ table: "Table"
112
+ },
113
+ prefixLevels: ["schema", "table"],
114
+ dialect: "bigquery",
115
+ supportsFilterClause: !1
116
+ } : a;
117
+ }
118
+ function v(e, i = {}) {
119
+ return M(
120
+ e
121
+ ) ? U(e, i) : void 0;
122
+ }
123
+ function M(e) {
124
+ const i = j(e);
125
+ if (i.includes("postgres")) return "postgres";
126
+ if (i.includes("mysql")) return "mysql";
127
+ if (i.includes("mssql") || i.includes("sqlserver"))
128
+ return "mssql";
129
+ if (i.includes("redshift")) return "redshift";
130
+ if (i.includes("snowflake")) return "snowflake";
131
+ if (i.includes("clickhouse")) return "clickhouse";
132
+ if (i === "s3" || i === "api" || i === "googlesheets" || i === "fileupload" || i === "s3tables" || i === "bigquery")
133
+ return i;
134
+ }
135
+ function P(e) {
136
+ const i = j(e);
137
+ switch (i) {
138
+ case "mysql":
139
+ case "bigquery":
140
+ case "redshift":
141
+ case "snowflake":
142
+ case "clickhouse":
143
+ case "duckdb":
144
+ case "sqlite":
145
+ return i;
146
+ case "mssql":
147
+ case "sqlserver":
148
+ return "mssql";
149
+ case "postgres":
150
+ case "postgresql":
151
+ return "postgres";
152
+ default:
153
+ return "unknown";
154
+ }
155
+ }
156
+ function ye(e) {
157
+ return e.capabilities.prefixLevels.every(
158
+ (i) => !!C(e.source, i)
159
+ );
160
+ }
161
+ function pe(e) {
162
+ const i = e.quoteIdentifier ?? Z;
163
+ return e.capabilities.prefixLevels.map((t) => C(e.source, t)).filter((t) => !!t).map((t) => i(t, e.capabilities.dialect)).join(".");
164
+ }
165
+ function C(e, i) {
166
+ return i === "database" ? e.databaseName : i === "schema" ? e.schemaName : e.tableName;
167
+ }
168
+ function X(e, i, t) {
169
+ i === "database" ? e.databaseName = t : i === "schema" ? e.schemaName = t : e.tableName = t;
170
+ }
171
+ function Y(e) {
172
+ const i = e == null ? void 0 : e.trim();
173
+ if (!i) return [];
174
+ const t = i.split(".").map((a) => {
175
+ const s = a.trim();
176
+ return s.length >= 2 && s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : s;
177
+ });
178
+ return t.some((a) => !a) ? [] : t;
179
+ }
180
+ function Z(e, i) {
181
+ return i === "mysql" || i === "bigquery" || i === "clickhouse" || i === "duckdb" ? `\`${e.replace(/`/g, "``")}\`` : i === "mssql" ? `[${e.replace(/]/g, "]]")}]` : `"${e.replace(/"/g, '""')}"`;
182
+ }
183
+ function j(e) {
184
+ if (typeof e != "string")
185
+ return "";
186
+ const i = [];
187
+ for (const t of e.trim().toLowerCase())
188
+ ee(t) && i.push(t);
189
+ return i.join("");
190
+ }
191
+ function ee(e) {
192
+ const i = e.charCodeAt(0);
193
+ return i >= 48 && i <= 57 || i >= 97 && i <= 122;
194
+ }
195
+ function V(e) {
196
+ return e.prefixLevels.length === 1 && e.prefixLevels[0] === "table" ? ["table"] : Array.from(
197
+ /* @__PURE__ */ new Set([
198
+ "database",
199
+ ...e.prefixLevels
200
+ ])
201
+ );
202
+ }
203
+ function ve(e) {
204
+ const i = e.source.connectionType ? v(e.source.connectionType) : void 0, t = e.source.dialect ? P(e.source.dialect) : void 0, a = e.source.dialect && e.source.dialect !== "unknown" ? v(e.source.dialect) : void 0;
205
+ if (!e.capabilities && e.source.connectionType && e.source.dialect && e.source.dialect !== "unknown" && (!i || t === "unknown" || i.dialect !== t))
206
+ return { kind: "incompatible_capabilities" };
207
+ const s = e.capabilities || i || a;
208
+ if (!s) return { kind: "incompatible_capabilities" };
209
+ const r = V(s), o = {
210
+ ...r.includes("database") && e.source.databaseName ? { databaseName: e.source.databaseName } : {},
211
+ ...r.includes("schema") && e.source.schemaName ? { schemaName: e.source.schemaName } : {},
212
+ ...e.source.tableName ? { tableName: e.source.tableName } : {}
213
+ }, n = r.filter((d) => d === "database" ? !o.databaseName : d === "schema" ? !o.schemaName : !o.tableName);
214
+ return n.length > 0 ? { kind: "missing_coordinates", missing: n } : {
215
+ kind: "resolved",
216
+ coordinates: o
217
+ };
218
+ }
219
+ function f(e) {
220
+ return typeof e == "string" && e.trim() ? e.trim() : void 0;
221
+ }
222
+ function w(e) {
223
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
224
+ }
225
+ function O(e) {
226
+ const i = w(e);
227
+ return !i || !f(i.name) || i.type === "model" ? !1 : i.type === "dataset" ? i.datasetType === "physical" : !0;
228
+ }
229
+ function x(e) {
230
+ const i = w(e);
231
+ if (!i) return {};
232
+ const t = f(i.table) || f(i.name);
233
+ return {
234
+ ...f(i.database) ? { databaseName: f(i.database) } : {},
235
+ ...f(i.schema) ? { schemaName: f(i.schema) } : {},
236
+ ...t ? { tableName: t } : {}
237
+ };
238
+ }
239
+ function ie(e) {
240
+ if (se(e)) return { kind: "malformed" };
241
+ const i = e.entities.filter(O), t = te(e), a = ae({
242
+ entities: i,
243
+ connectionType: e.connectionType,
244
+ dialect: e.dialect,
245
+ capabilities: e.capabilities
246
+ });
247
+ if (!a) return { kind: "incompatible_capabilities" };
248
+ const { capabilities: s } = a, r = oe({
249
+ hints: e.qualifiedHints || [],
250
+ coordinateHint: e.coordinateHint,
251
+ capabilityAuthority: a
252
+ });
253
+ if (r.kind !== "valid")
254
+ return { kind: r.kind };
255
+ const o = r.coordinates, n = o ? i.filter(
256
+ (c) => _({
257
+ left: W(
258
+ x(c),
259
+ s
260
+ ),
261
+ right: o,
262
+ capabilities: s
263
+ })
264
+ ) : i;
265
+ if (o && n.length === 0)
266
+ return {
267
+ kind: "not_found",
268
+ basis: "qualified",
269
+ coordinates: o,
270
+ capabilityAuthority: a
271
+ };
272
+ if (o && n.length === 1) {
273
+ const c = n[0], u = E(
274
+ a,
275
+ c
276
+ );
277
+ return {
278
+ kind: "resolved",
279
+ basis: "qualified",
280
+ entity: c,
281
+ coordinates: de(
282
+ x(c),
283
+ o,
284
+ u
285
+ ),
286
+ capabilityAuthority: u
287
+ };
288
+ }
289
+ const d = G([
290
+ ...e.bareHints || [],
291
+ ...r.bareHints,
292
+ o == null ? void 0 : o.tableName
293
+ ]);
294
+ if (d.size > 0) {
295
+ const c = n.filter((u) => {
296
+ const b = le(u);
297
+ return Array.from(d).some((h) => b.has(h));
298
+ });
299
+ if (c.length === 1) {
300
+ const u = c[0], b = E(
301
+ a,
302
+ u
303
+ );
304
+ return {
305
+ kind: "resolved",
306
+ basis: "bare",
307
+ entity: u,
308
+ coordinates: T(
309
+ x(u),
310
+ b
311
+ ),
312
+ capabilityAuthority: b
313
+ };
314
+ }
315
+ return c.length > 1 ? { kind: "ambiguous", basis: "bare" } : { kind: "not_found", basis: "bare", capabilityAuthority: a };
316
+ }
317
+ if (o)
318
+ return { kind: "ambiguous", basis: "qualified" };
319
+ if (t)
320
+ return {
321
+ kind: "not_found",
322
+ basis: t,
323
+ capabilityAuthority: a
324
+ };
325
+ if (i.length === 1) {
326
+ const c = i[0], u = E(
327
+ a,
328
+ c
329
+ );
330
+ return {
331
+ kind: "resolved",
332
+ basis: "unqualified",
333
+ entity: c,
334
+ coordinates: T(
335
+ x(c),
336
+ u
337
+ ),
338
+ capabilityAuthority: u
339
+ };
340
+ }
341
+ return { kind: "unqualified" };
342
+ }
343
+ function te(e) {
344
+ const i = (e.qualifiedHints || []).map(f).filter((a) => !!a);
345
+ return Object.values(e.coordinateHint || {}).some(
346
+ (a) => !!f(a)
347
+ ) || i.some((a) => a.includes(".")) ? "qualified" : [...i, ...e.bareHints || []].some(
348
+ (a) => !!f(a)
349
+ ) ? "bare" : void 0;
350
+ }
351
+ function S(e) {
352
+ return `${e.dialect}:${e.prefixLevels.join(".")}`;
353
+ }
354
+ function L(e) {
355
+ return {
356
+ dialect: e.dialect,
357
+ prefixLevels: [...e.prefixLevels]
358
+ };
359
+ }
360
+ function ae(e) {
361
+ var q;
362
+ const i = f(e.connectionType), t = f(e.dialect), a = e.capabilities ? L(e.capabilities) : void 0, s = i ? v(i) : void 0, r = t ? P(t) : void 0, o = t && t !== "unknown" ? v(t) : void 0;
363
+ if (i && !s || t && t !== "unknown" && r === "unknown" || a && s && S(a) !== S(s))
364
+ return;
365
+ const n = a || (s ? L(s) : o ? L(o) : void 0);
366
+ if (n)
367
+ return r && r !== "unknown" && n.dialect !== r ? void 0 : {
368
+ capabilities: n,
369
+ ...i ? { connectionType: i } : {},
370
+ dialect: n.dialect,
371
+ evidence: "explicit"
372
+ };
373
+ const d = e.entities.map((m) => {
374
+ const k = w(m), g = f(k == null ? void 0 : k.connectionType), y = f(k == null ? void 0 : k.dialect), N = g ? v(g) : void 0, H = y ? P(y) : void 0, A = y && y !== "unknown" ? v(y) : void 0;
375
+ if (g && !N || y && y !== "unknown" && H === "unknown" || y && y !== "unknown" && !N && !A || N && H && H !== "unknown" && N.dialect !== H)
376
+ return;
377
+ const F = N || A, B = F ? L(F) : ne(k);
378
+ return B ? {
379
+ capabilities: B,
380
+ connectionType: g,
381
+ capabilityIdentity: g ? M(g) : void 0,
382
+ inferred: !N && !A,
383
+ signature: S(B)
384
+ } : void 0;
385
+ });
386
+ if (d.some((m) => !m)) return;
387
+ const c = d.filter(
388
+ (m) => !!m
389
+ );
390
+ if (new Set(c.map((m) => m.signature)).size > 1)
391
+ return;
392
+ const u = (q = c[0]) == null ? void 0 : q.capabilities;
393
+ if (!u || r && r !== "unknown" && u.dialect !== r)
394
+ return;
395
+ const b = new Set(
396
+ c.map((m) => m.capabilityIdentity).filter((m) => !!m)
397
+ ), h = c.every(
398
+ (m) => m.connectionType && m.capabilityIdentity
399
+ );
400
+ return {
401
+ capabilities: u,
402
+ ...h && b.size === 1 ? { connectionType: c[0].connectionType } : {},
403
+ dialect: u.dialect,
404
+ evidence: c.every((m) => m.inferred) ? "coordinates" : "entity"
405
+ };
406
+ }
407
+ function ne(e) {
408
+ const i = !!f(e == null ? void 0 : e.database), t = !!f(e == null ? void 0 : e.schema);
409
+ if (!(i && t)) {
410
+ if (t)
411
+ return { dialect: "unknown", prefixLevels: ["schema", "table"] };
412
+ if (i)
413
+ return { dialect: "unknown", prefixLevels: ["database", "table"] };
414
+ }
415
+ }
416
+ function E(e, i) {
417
+ var s;
418
+ if (e.evidence !== "entity") return e;
419
+ const t = f((s = w(i)) == null ? void 0 : s.connectionType), a = t ? v(t) : void 0;
420
+ return a && S(a) === S(e.capabilities) ? { ...e, connectionType: t } : e;
421
+ }
422
+ function se(e) {
423
+ return (e.qualifiedHints || []).some(
424
+ (t) => {
425
+ const a = f(t);
426
+ return !!(a && a.includes(".") && !p(a));
427
+ }
428
+ ) ? !0 : Object.values(e.coordinateHint || {}).some((t) => {
429
+ const a = f(t);
430
+ return !!(a && !p(a));
431
+ });
432
+ }
433
+ function oe(e) {
434
+ const { capabilities: i } = e.capabilityAuthority, t = [], a = [];
435
+ for (const b of e.hints) {
436
+ const h = f(b);
437
+ if (!h) continue;
438
+ if (!h.includes(".")) {
439
+ a.push(h);
440
+ continue;
441
+ }
442
+ const q = p(h);
443
+ if (!q) return { kind: "malformed" };
444
+ t.push(q);
445
+ }
446
+ const s = re(e.coordinateHint);
447
+ if (s.kind === "malformed") return s;
448
+ const r = Array.from(new Set(t)).map(
449
+ (b) => Q({
450
+ qualifiedName: b,
451
+ capabilities: i
452
+ })
453
+ );
454
+ if (!ce(r, i))
455
+ return { kind: "conflicting" };
456
+ const o = [...new Set(t)].sort(
457
+ (b, h) => h.split(".").length - b.split(".").length
458
+ )[0], n = o ? Q({
459
+ qualifiedName: o,
460
+ capabilities: i
461
+ }) : void 0, d = W(
462
+ s.coordinates,
463
+ i
464
+ ), c = T(
465
+ s.coordinates,
466
+ e.capabilityAuthority
467
+ ), u = !!(d.tableName && (d.databaseName || d.schemaName));
468
+ return n && u && !_({
469
+ left: n,
470
+ right: d,
471
+ capabilities: i
472
+ }) ? { kind: "conflicting" } : {
473
+ kind: "valid",
474
+ coordinates: n ? {
475
+ ...c,
476
+ ...n
477
+ } : u ? c : void 0,
478
+ bareHints: [
479
+ ...a,
480
+ ...!u && d.tableName ? [d.tableName] : []
481
+ ]
482
+ };
483
+ }
484
+ function re(e) {
485
+ const i = {};
486
+ for (const [t, a] of Object.entries(e || {})) {
487
+ const s = f(a);
488
+ if (!s) continue;
489
+ const r = p(s);
490
+ if (!r) return { kind: "malformed" };
491
+ i[t] = r;
492
+ }
493
+ return { kind: "valid", coordinates: i };
494
+ }
495
+ function W(e, i) {
496
+ return {
497
+ ...i.prefixLevels.includes("database") && e.databaseName ? { databaseName: e.databaseName } : {},
498
+ ...i.prefixLevels.includes("schema") && e.schemaName ? { schemaName: e.schemaName } : {},
499
+ ...e.tableName ? { tableName: e.tableName } : {}
500
+ };
501
+ }
502
+ function ce(e, i) {
503
+ return e.every(
504
+ (t, a) => e.slice(a + 1).every(
505
+ (s) => _({
506
+ left: t,
507
+ right: s,
508
+ capabilities: i
509
+ })
510
+ )
511
+ );
512
+ }
513
+ function G(e) {
514
+ return new Set(
515
+ e.map(f).map(p).filter((i) => !!i)
516
+ );
517
+ }
518
+ function le(e) {
519
+ const i = w(e);
520
+ return i ? G([
521
+ f(i.name),
522
+ f(i.table),
523
+ f(i.id)
524
+ ]) : /* @__PURE__ */ new Set();
525
+ }
526
+ function de(e, i, t) {
527
+ return T(
528
+ {
529
+ ...e,
530
+ ...i
531
+ },
532
+ t
533
+ );
534
+ }
535
+ function T(e, i) {
536
+ const t = i.evidence === "coordinates" ? i.capabilities.prefixLevels : V(i.capabilities);
537
+ return {
538
+ ...t.includes("database") && e.databaseName ? { databaseName: e.databaseName } : {},
539
+ ...t.includes("schema") && e.schemaName ? { schemaName: e.schemaName } : {},
540
+ ...e.tableName ? { tableName: e.tableName } : {}
541
+ };
542
+ }
543
+ function l(e) {
544
+ return typeof e == "string" && e.trim() ? e.trim() : void 0;
545
+ }
546
+ function I(e) {
547
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
548
+ }
549
+ function ue(e) {
550
+ const i = I(e);
551
+ return !!(i && i.type === "dataset" && l(i.name));
552
+ }
553
+ function J(e) {
554
+ const i = I(e);
555
+ return !!(i && i.type === "dataset" && i.datasetType !== "physical" && l(i.name));
556
+ }
557
+ function $(e) {
558
+ const i = /* @__PURE__ */ new Set();
559
+ for (const t of e) {
560
+ const a = l(t);
561
+ if (!a) continue;
562
+ const s = p(a);
563
+ if (!s) continue;
564
+ const r = s.toLowerCase();
565
+ i.add(r);
566
+ const o = r.split("."), n = o[o.length - 1];
567
+ n && i.add(n);
568
+ }
569
+ return i;
570
+ }
571
+ function R(e) {
572
+ var t;
573
+ const i = l(e);
574
+ return i ? (t = p(i)) == null ? void 0 : t.toLowerCase() : void 0;
575
+ }
576
+ function D(e, i) {
577
+ const t = I(i), a = l(t == null ? void 0 : t.domainId) || l(e.semanticDomainId), s = l(t == null ? void 0 : t.name);
578
+ if (!a || !s) return;
579
+ const r = (t == null ? void 0 : t.datasetType) === "physical" ? void 0 : K(t || {}), o = l(t == null ? void 0 : t.connectionId) || l(e.connectionId);
580
+ return {
581
+ kind: "semantic",
582
+ domainId: a,
583
+ datasetName: s,
584
+ ...r ? { datasetId: r } : {},
585
+ ...o ? { connectionId: o } : {}
586
+ };
587
+ }
588
+ function fe(e, i = {}) {
589
+ const t = l(e.fieldEntityType);
590
+ if (t && t !== "dataset")
591
+ return { kind: "unqualified" };
592
+ const a = e.entities.filter(
593
+ (o) => i.includePhysicalDatasets ? ue(o) : J(o)
594
+ ), s = l(e.entityId);
595
+ if (s) {
596
+ const o = R(s), n = a.filter((d) => {
597
+ const c = I(d);
598
+ return !!(o && R(c == null ? void 0 : c.id) === o);
599
+ });
600
+ if (n.length > 1) return { kind: "ambiguous", basis: "bare" };
601
+ if (n.length === 1) {
602
+ const d = D(e, n[0]);
603
+ return d ? {
604
+ kind: "resolved",
605
+ basis: "bare",
606
+ entity: n[0],
607
+ source: d,
608
+ matchedById: !0
609
+ } : { kind: "not_found", basis: "bare" };
610
+ }
611
+ }
612
+ const r = $([
613
+ e.entityName,
614
+ ...e.qualifiedHints || [],
615
+ ...e.bareHints || []
616
+ ]);
617
+ if (r.size > 0) {
618
+ const o = a.filter((n) => {
619
+ const d = I(n);
620
+ return [...$([d == null ? void 0 : d.id, d == null ? void 0 : d.name])].some((u) => r.has(u));
621
+ });
622
+ if (o.length > 1) return { kind: "ambiguous", basis: "bare" };
623
+ if (o.length === 1) {
624
+ const n = D(e, o[0]);
625
+ return n ? {
626
+ kind: "resolved",
627
+ basis: "bare",
628
+ entity: o[0],
629
+ source: n,
630
+ matchedById: !1
631
+ } : { kind: "not_found", basis: "bare" };
632
+ }
633
+ return { kind: "not_found", basis: "bare" };
634
+ }
635
+ if (a.length === 1) {
636
+ const o = D(e, a[0]);
637
+ return o ? {
638
+ kind: "resolved",
639
+ basis: "unqualified",
640
+ entity: a[0],
641
+ source: o,
642
+ matchedById: !1
643
+ } : { kind: "unqualified" };
644
+ }
645
+ return { kind: "unqualified" };
646
+ }
647
+ function z(e) {
648
+ const i = e.resolution.kind === "resolved" ? I(e.resolution.entity) : void 0, t = l(e.connectionId) || l(i == null ? void 0 : i.connectionId), { connectionType: a, dialect: s } = e.resolution.capabilityAuthority, r = v(s), o = !!(r && r.dialect === e.resolution.capabilityAuthority.capabilities.dialect && r.prefixLevels.join(".") === e.resolution.capabilityAuthority.capabilities.prefixLevels.join(
649
+ "."
650
+ )), n = e.resolution.coordinates;
651
+ if (!(!t || !(n != null && n.tableName)))
652
+ return {
653
+ kind: "physical",
654
+ connectionId: t,
655
+ ...a ? { connectionType: a } : {},
656
+ ...!a && o ? { dialect: s } : {},
657
+ tableName: n.tableName,
658
+ ...n.databaseName ? { databaseName: n.databaseName } : {},
659
+ ...n.schemaName ? { schemaName: n.schemaName } : {}
660
+ };
661
+ }
662
+ function me(e) {
663
+ var s, r, o;
664
+ if (l(e.connectionType) || l(e.dialect) || e.capabilities || l(e.semanticDomainId) || l(e.fieldEntityType) === "dataset" || l((s = e.fallbackCoordinateHint) == null ? void 0 : s.databaseName) || l((r = e.fallbackCoordinateHint) == null ? void 0 : r.schemaName))
665
+ return;
666
+ const i = [
667
+ l((o = e.fallbackCoordinateHint) == null ? void 0 : o.tableName),
668
+ ...(e.qualifiedHints || []).map(l),
669
+ ...(e.bareHints || []).map(l),
670
+ l(e.entityName),
671
+ ...l(e.fieldEntityType) === "table" ? [l(e.entityId)] : []
672
+ ].filter((n) => !!n);
673
+ if (!i.length || i.some((n) => n.includes(".")))
674
+ return;
675
+ const t = i.map(p);
676
+ return t.some((n) => !n) ? void 0 : new Set(t.map((n) => n.toLowerCase())).size === 1 ? t[0] : void 0;
677
+ }
678
+ function ke(e) {
679
+ const i = e.entities.filter(
680
+ O
681
+ ), t = e.entities.filter(
682
+ J
683
+ ), a = i.length > 0 || t.length > 0, s = fe(e), r = e.qualifiedHints || [], o = r.some(
684
+ (c) => {
685
+ var u;
686
+ return (u = l(c)) == null ? void 0 : u.includes(".");
687
+ }
688
+ ), n = ie({
689
+ entities: i,
690
+ connectionType: l(e.connectionType),
691
+ dialect: e.dialect,
692
+ capabilities: e.capabilities,
693
+ qualifiedHints: r,
694
+ bareHints: [e.entityName, e.entityId, ...e.bareHints || []],
695
+ ...!o && e.fallbackCoordinateHint ? { coordinateHint: e.fallbackCoordinateHint } : {}
696
+ });
697
+ if (n.kind === "malformed" || n.kind === "conflicting" || n.kind === "incompatible_capabilities" && o || n.kind === "ambiguous" && n.basis === "qualified")
698
+ return n;
699
+ if (n.kind === "resolved" && n.basis === "qualified") {
700
+ const c = z({
701
+ resolution: n,
702
+ connectionId: e.connectionId
703
+ });
704
+ return c ? {
705
+ kind: "resolved",
706
+ basis: n.basis,
707
+ source: c,
708
+ entity: n.entity
709
+ } : { kind: "missing_connection" };
710
+ }
711
+ if (n.kind === "not_found" && n.basis === "qualified" && n.coordinates) {
712
+ const c = z({
713
+ resolution: n,
714
+ connectionId: e.connectionId
715
+ });
716
+ return c ? a ? { kind: "candidate", basis: "qualified", source: c } : { kind: "resolved", basis: "qualified", source: c } : { kind: "missing_connection" };
717
+ }
718
+ if (s.kind === "resolved")
719
+ return n.kind === "resolved" && n.basis === "bare" && !s.matchedById ? { kind: "ambiguous", basis: "bare" } : {
720
+ kind: "resolved",
721
+ basis: s.basis,
722
+ source: s.source,
723
+ entity: s.entity
724
+ };
725
+ if (s.kind === "ambiguous") return s;
726
+ if (n.kind === "resolved") {
727
+ const c = z({
728
+ resolution: n,
729
+ connectionId: e.connectionId
730
+ });
731
+ return c ? {
732
+ kind: "resolved",
733
+ basis: n.basis,
734
+ source: c,
735
+ entity: n.entity
736
+ } : { kind: "missing_connection" };
737
+ }
738
+ const d = l(e.entityName) || l(e.entityId);
739
+ if (!a && !o && l(e.semanticDomainId) && (!l(e.fieldEntityType) || l(e.fieldEntityType) === "dataset") && d)
740
+ return {
741
+ kind: "resolved",
742
+ basis: "historical",
743
+ source: {
744
+ kind: "semantic",
745
+ domainId: l(e.semanticDomainId),
746
+ datasetName: d,
747
+ ...l(e.connectionId) ? { connectionId: l(e.connectionId) } : {}
748
+ }
749
+ };
750
+ if (n.kind === "incompatible_capabilities") {
751
+ const c = a ? void 0 : me(e), u = l(e.connectionId);
752
+ return c && u ? {
753
+ kind: "resolved",
754
+ basis: "historical",
755
+ source: { kind: "physical", connectionId: u, tableName: c }
756
+ } : n;
757
+ }
758
+ return n.kind === "ambiguous" ? n : n.kind === "not_found" ? {
759
+ kind: "not_found",
760
+ basis: n.basis
761
+ } : { kind: "unqualified" };
762
+ }
763
+ export {
764
+ he as a,
765
+ M as b,
766
+ p as c,
767
+ ye as d,
768
+ pe as e,
769
+ V as f,
770
+ U as g,
771
+ ve as h,
772
+ O as i,
773
+ ie as j,
774
+ J as k,
775
+ fe as l,
776
+ ke as m,
777
+ P as n,
778
+ Q as p,
779
+ v as r,
780
+ _ as s
781
+ };