@milaboratories/graph-maker 1.1.140 → 1.1.141

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 (77) hide show
  1. package/dist/GraphMaker/index.vue.js +24 -23
  2. package/dist/GraphMaker/index.vue.js.map +1 -1
  3. package/dist/GraphMaker/store.js +9 -9
  4. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.d.ts.map +1 -1
  5. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js +54 -52
  6. package/dist/GraphMaker/utils/createChartSettingsForRender/composeScatterplotSettings.js.map +1 -1
  7. package/dist/GraphMaker/utils/loadDefaultSources.js +4 -3
  8. package/dist/GraphMaker/utils/loadDefaultSources.js.map +1 -1
  9. package/dist/_virtual/_commonjsHelpers.js +3 -5
  10. package/dist/_virtual/_commonjsHelpers.js.map +1 -1
  11. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/_commonjsHelpers.js +9 -0
  12. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/_commonjsHelpers.js.map +1 -0
  13. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/canonicalize.js +8 -0
  14. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/canonicalize.js.map +1 -0
  15. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/lodash.js +8 -0
  16. package/dist/{_virtual → node_modules/@milaboratories/pf-plots/dist/_virtual}/lodash.js.map +1 -1
  17. package/dist/{_virtual/lodash.js → node_modules/@milaboratories/pf-plots/dist/_virtual/lodash2.js} +1 -1
  18. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/lodash2.js.map +1 -0
  19. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/stringify.js +3 -0
  20. package/dist/{_virtual → node_modules/@milaboratories/pf-plots/dist/_virtual}/stringify.js.map +1 -1
  21. package/dist/{_virtual/stringify.js → node_modules/@milaboratories/pf-plots/dist/_virtual/stringify2.js} +1 -1
  22. package/dist/node_modules/@milaboratories/pf-plots/dist/_virtual/stringify2.js.map +1 -0
  23. package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js +15 -0
  24. package/dist/node_modules/@milaboratories/pf-plots/dist/constants.js.map +1 -0
  25. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js +198 -0
  26. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ComponentController.js.map +1 -0
  27. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js +342 -0
  28. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/ControllerBase.js.map +1 -0
  29. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/bubble.js +278 -0
  30. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/bubble.js.map +1 -0
  31. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/dendro.js +453 -0
  32. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/dendro.js.map +1 -0
  33. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/discrete.js +203 -0
  34. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/discrete.js.map +1 -0
  35. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/heatmap.js +432 -0
  36. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/heatmap.js.map +1 -0
  37. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/histogram.js +170 -0
  38. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/histogram.js.map +1 -0
  39. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js +315 -0
  40. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot-umap.js.map +1 -0
  41. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js +323 -0
  42. package/dist/node_modules/@milaboratories/pf-plots/dist/controllers/controllersByChartType/scatterplot.js.map +1 -0
  43. package/dist/node_modules/@milaboratories/pf-plots/dist/demoStore.js +11 -0
  44. package/dist/node_modules/@milaboratories/pf-plots/dist/demoStore.js.map +1 -0
  45. package/dist/node_modules/@milaboratories/pf-plots/dist/index.js +36 -3426
  46. package/dist/node_modules/@milaboratories/pf-plots/dist/index.js.map +1 -1
  47. package/dist/node_modules/@milaboratories/{pl-error-like → pf-plots/dist/node_modules/@milaboratories/pl-error-like}/dist/index.js +1 -1
  48. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-error-like/dist/index.js.map +1 -0
  49. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +979 -0
  50. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +1 -0
  51. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js +1599 -0
  52. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/@platforma-sdk/model/dist/index.js.map +1 -0
  53. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/canonicalize/lib/canonicalize.js +19 -0
  54. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/canonicalize/lib/canonicalize.js.map +1 -0
  55. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/json-stringify-safe/stringify.js +26 -0
  56. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/json-stringify-safe/stringify.js.map +1 -0
  57. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/lodash/lodash.js +3678 -0
  58. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/lodash/lodash.js.map +1 -0
  59. package/dist/node_modules/{zod → @milaboratories/pf-plots/dist/node_modules/zod}/lib/index.js +1141 -1141
  60. package/dist/node_modules/@milaboratories/pf-plots/dist/node_modules/zod/lib/index.js.map +1 -0
  61. package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js +247 -0
  62. package/dist/node_modules/@milaboratories/pf-plots/dist/pframe/ColumnsProvider.js.map +1 -0
  63. package/dist/node_modules/@milaboratories/pf-plots/dist/spec.js +62 -0
  64. package/dist/node_modules/@milaboratories/pf-plots/dist/spec.js.map +1 -0
  65. package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js +286 -0
  66. package/dist/node_modules/@milaboratories/pf-plots/dist/utils.js.map +1 -0
  67. package/package.json +2 -2
  68. package/dist/node_modules/@milaboratories/pl-error-like/dist/index.js.map +0 -1
  69. package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js +0 -584
  70. package/dist/node_modules/@milaboratories/pl-model-common/dist/index.js.map +0 -1
  71. package/dist/node_modules/@platforma-sdk/model/dist/index.js +0 -1559
  72. package/dist/node_modules/@platforma-sdk/model/dist/index.js.map +0 -1
  73. package/dist/node_modules/json-stringify-safe/stringify.js +0 -20
  74. package/dist/node_modules/json-stringify-safe/stringify.js.map +0 -1
  75. package/dist/node_modules/lodash/lodash.js +0 -3678
  76. package/dist/node_modules/lodash/lodash.js.map +0 -1
  77. package/dist/node_modules/zod/lib/index.js.map +0 -1
@@ -1,1559 +0,0 @@
1
- import { isDataInfo as ae, extractAllColumns as Ce, mapPTableDef as Ee, selectorsToPredicate as W, withEnrichments as ce, AnchoredIdDeriver as he, isPlRef as Te, mapValueInVOE as Fe, mapPObjectData as le, ensurePColumn as Oe, isPColumnSpec as G, isPColumn as be, resolveAnchors as pe, deriveNativeId as ke, isPartitionedDataInfoEntries as Re, getAxisId as de, entriesToDataInfo as De, isDataInfoEntries as _e, dataInfoToEntries as Ne, canonicalizeAxisId as $e, mapDataInfo as Ke } from "../../../@milaboratories/pl-model-common/dist/index.js";
2
- import { PTableAbsent as bt, PTableNA as _t, PValueBytesNA as wt, PValueIntNA as Pt, PValueLongNA as At, PValueStringNA as xt, PlIdLength as St, canonicalizeJson as It, getAxesId as Lt, isValueAbsent as Ct, isValueNA as Et, mapJoinEntry as Tt, matchAxis as Ft, matchAxisId as Ot, matchPColumn as kt, pTableValue as Rt, stringifyColumnId as Dt } from "../../../@milaboratories/pl-model-common/dist/index.js";
3
- import we from "../../../canonicalize/lib/canonicalize.js";
4
- import $ from "../../../zod/lib/index.js";
5
- import { BasePlErrorLike as $t, ErrorLike as Kt, PlErrorLike as jt, StandardErrorLike as Bt } from "../../../@milaboratories/pl-error-like/dist/index.js";
6
- var je = Object.defineProperty, Be = (r, e, t) => e in r ? je(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, S = (r, e, t) => Be(r, typeof e != "symbol" ? e + "" : e, t);
7
- function Z(r) {
8
- return { type: "Immediate", value: r };
9
- }
10
- function Ve() {
11
- return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
12
- }
13
- function Je(r) {
14
- if (r && typeof globalThis.getPlatforma == "function")
15
- return globalThis.getPlatforma(r);
16
- if (typeof globalThis.platforma < "u") return globalThis.platforma;
17
- throw new Error("Can't get platforma instance.");
18
- }
19
- function Ue() {
20
- if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
21
- }
22
- function c() {
23
- if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
24
- throw new Error("Not in config rendering context");
25
- }
26
- function J(r, e) {
27
- const t = Ue();
28
- if (t === void 0) return !1;
29
- if (r in t.callbackRegistry) throw new Error(`Callback with key ${r} already registered.`);
30
- return t.callbackRegistry[r] = e, !0;
31
- }
32
- const Q = /* @__PURE__ */ new Map();
33
- function Me(r, e) {
34
- r in c().callbackRegistry || (c().callbackRegistry[r] = (t) => {
35
- for (const n of Q.get(r))
36
- n(t);
37
- }, Q.set(r, [])), Q.get(r).push(e);
38
- }
39
- class w {
40
- constructor(e, t = (n) => n) {
41
- S(this, "isResolved", !1), S(this, "resolvedValue"), this.handle = e, this.postProcess = t, Me(e, (n) => {
42
- this.resolvedValue = t(n), this.isResolved = !0;
43
- });
44
- }
45
- map(e) {
46
- return new w(this.handle, (t) => e(this.postProcess(t)));
47
- }
48
- mapDefined(e) {
49
- return new w(this.handle, (t) => {
50
- const n = this.postProcess(t);
51
- return n ? e(n) : void 0;
52
- });
53
- }
54
- toJSON() {
55
- return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
56
- }
57
- }
58
- function ne(r, e) {
59
- return r === void 0 ? void 0 : e(r);
60
- }
61
- class I {
62
- constructor(e, t) {
63
- this.handle = e, this.resolvePath = t;
64
- }
65
- resolve(...e) {
66
- const t = e.map(
67
- (n) => ({
68
- assertFieldType: "Input",
69
- ...typeof n == "string" ? { field: n } : n
70
- })
71
- );
72
- return this.resolveWithCommon({}, ...t);
73
- }
74
- resolveOutput(...e) {
75
- const t = e.map(
76
- (n) => ({
77
- assertFieldType: "Output",
78
- ...typeof n == "string" ? { field: n } : n
79
- })
80
- );
81
- return this.resolveWithCommon({}, ...t);
82
- }
83
- resolveInput(...e) {
84
- const t = e.map(
85
- (n) => ({
86
- assertFieldType: "Input",
87
- ...typeof n == "string" ? { field: n } : n
88
- })
89
- );
90
- return this.resolveWithCommon({}, ...t);
91
- }
92
- resolveAny(...e) {
93
- return this.resolveWithCommon({}, ...e);
94
- }
95
- resolveWithCommon(e, ...t) {
96
- const n = [
97
- ...this.resolvePath,
98
- ...t.map((i) => typeof i == "string" ? i : i.field)
99
- ];
100
- return ne(
101
- c().resolveWithCommon(this.handle, e, ...t),
102
- (i) => new I(i, n)
103
- );
104
- }
105
- get resourceType() {
106
- return c().getResourceType(this.handle);
107
- }
108
- getInputsLocked() {
109
- return c().getInputsLocked(this.handle);
110
- }
111
- getOutputsLocked() {
112
- return c().getOutputsLocked(this.handle);
113
- }
114
- getIsReadyOrError() {
115
- return c().getIsReadyOrError(this.handle);
116
- }
117
- getIsFinal() {
118
- return c().getIsFinal(this.handle);
119
- }
120
- getError() {
121
- const e = [...this.resolvePath, "error"];
122
- return ne(
123
- c().getError(this.handle),
124
- (t) => new I(t, e)
125
- );
126
- }
127
- listInputFields() {
128
- return c().listInputFields(this.handle);
129
- }
130
- listOutputFields() {
131
- return c().listOutputFields(this.handle);
132
- }
133
- listDynamicFields() {
134
- return c().listDynamicFields(this.handle);
135
- }
136
- getKeyValueBase64(e) {
137
- return c().getKeyValueBase64(this.handle, e);
138
- }
139
- getKeyValueAsString(e) {
140
- return c().getKeyValueAsString(this.handle, e);
141
- }
142
- getKeyValueAsJson(e) {
143
- const t = this.getKeyValueAsString(e);
144
- if (t == null) throw new Error("Resource has no content.");
145
- return JSON.parse(t);
146
- }
147
- getDataBase64() {
148
- return c().getDataBase64(this.handle);
149
- }
150
- getDataAsString() {
151
- return c().getDataAsString(this.handle);
152
- }
153
- getDataAsJson() {
154
- const e = this.getDataAsString();
155
- if (e == null) throw new Error("Resource has no content.");
156
- return JSON.parse(e);
157
- }
158
- /**
159
- *
160
- */
161
- getPColumns(e = !1, t = "") {
162
- const n = this.parsePObjectCollection(e, t);
163
- return n === void 0 ? void 0 : Object.entries(n).map(([, i]) => {
164
- if (!be(i)) throw new Error(`not a PColumn (kind = ${i.spec.kind})`);
165
- return i;
166
- });
167
- }
168
- /**
169
- *
170
- */
171
- parsePObjectCollection(e = !1, t = "") {
172
- const n = c().parsePObjectCollection(
173
- this.handle,
174
- e,
175
- t,
176
- ...this.resolvePath
177
- );
178
- if (n === void 0) return;
179
- const i = {};
180
- for (const [s, o] of Object.entries(n)) {
181
- const a = [...this.resolvePath, s];
182
- i[s] = le(o, (l) => new I(l, a));
183
- }
184
- return i;
185
- }
186
- getFileContentAsBase64(e) {
187
- return new w(c().getBlobContentAsBase64(this.handle, e));
188
- }
189
- getFileContentAsString(e) {
190
- return new w(c().getBlobContentAsString(this.handle, e));
191
- }
192
- getFileContentAsJson(e) {
193
- return new w(
194
- c().getBlobContentAsString(this.handle, e)
195
- ).mapDefined((t) => JSON.parse(t));
196
- }
197
- /**
198
- * @deprecated use getFileContentAsBase64
199
- */
200
- getBlobContentAsBase64() {
201
- return this.getFileContentAsBase64();
202
- }
203
- /**
204
- * @deprecated use getFileContentAsString
205
- */
206
- getBlobContentAsString() {
207
- return this.getFileContentAsString();
208
- }
209
- /**
210
- * @returns downloaded file handle
211
- */
212
- getFileHandle() {
213
- return new w(c().getDownloadedBlobContentHandle(this.handle));
214
- }
215
- /**
216
- * @deprecated use getFileHandle
217
- */
218
- getDownloadedBlobHandle() {
219
- return this.getFileHandle();
220
- }
221
- /**
222
- * @returns downloaded file handle
223
- */
224
- getRemoteFileHandle() {
225
- return new w(c().getOnDemandBlobContentHandle(this.handle));
226
- }
227
- /**
228
- * @deprecated use getRemoteFileHandle
229
- */
230
- getOnDemandBlobHandle() {
231
- return this.getRemoteFileHandle();
232
- }
233
- /**
234
- * @returns the url to the extracted folder
235
- */
236
- extractArchiveAndGetURL(e) {
237
- return new w(c().extractArchiveAndGetURL(this.handle, e));
238
- }
239
- getImportProgress() {
240
- return new w(c().getImportProgress(this.handle));
241
- }
242
- getLastLogs(e) {
243
- return new w(c().getLastLogs(this.handle, e));
244
- }
245
- getProgressLog(e) {
246
- return new w(c().getProgressLog(this.handle, e));
247
- }
248
- getProgressLogWithInfo(e) {
249
- return new w(c().getProgressLogWithInfo(this.handle, e));
250
- }
251
- getLogHandle() {
252
- return new w(c().getLogHandle(this.handle));
253
- }
254
- allFieldsResolved(e = "Input") {
255
- switch (e) {
256
- case "Input":
257
- return this.getInputsLocked() && this.listInputFields().every(
258
- (t) => this.resolve({ field: t, assertFieldType: "Input" }) !== void 0
259
- );
260
- case "Output":
261
- return this.getOutputsLocked() && this.listOutputFields().every(
262
- (t) => this.resolve({ field: t, assertFieldType: "Output" }) !== void 0
263
- );
264
- }
265
- }
266
- mapFields(e, t) {
267
- const { fieldType: n, requireLocked: i, skipUnresolved: s } = {
268
- fieldType: "Input",
269
- requireLocked: !0,
270
- skipUnresolved: !1,
271
- ...t
272
- }, o = e;
273
- if (i && (n === "Input" && !this.getInputsLocked() || n === "Output" && !this.getOutputsLocked()))
274
- return;
275
- let a = (n === "Input" ? this.listInputFields() : n === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
276
- (l) => [l, this.resolve({ field: l, assertFieldType: n })]
277
- );
278
- return s && (a = a.filter((l) => l[1] !== void 0)), a.map(([l, y]) => o(l, y));
279
- }
280
- }
281
- const We = "staging", qe = "main", He = "pl7.app/label", ze = "pl7.app/trace", Ge = $.object({
282
- type: $.string(),
283
- importance: $.number().optional(),
284
- id: $.string().optional(),
285
- label: $.string()
286
- }), Ye = $.array(Ge), Ze = 1e-3, Qe = "__LABEL__", fe = "__LABEL__@1";
287
- function Pe(r, e, t = {}) {
288
- const n = /* @__PURE__ */ new Map(), i = t.forceTraceElements !== void 0 && t.forceTraceElements.length > 0 ? new Set(t.forceTraceElements) : void 0, s = /* @__PURE__ */ new Map(), o = r.map((f) => {
289
- var P, u;
290
- const h = e(f);
291
- let v, L, C;
292
- "spec" in h && typeof h.spec == "object" ? (v = h.spec, L = h.prefixTrace, C = h.suffixTrace) : v = h;
293
- const p = (P = v.annotations) == null ? void 0 : P[He], A = (u = v.annotations) == null ? void 0 : u[ze], d = (A ? Ye.safeParse(JSON.parse(A)).data : void 0) ?? [], g = [
294
- ...L ?? [],
295
- ...d,
296
- ...C ?? []
297
- ];
298
- if (p !== void 0) {
299
- const x = { label: p, type: Qe, importance: -2 };
300
- t.addLabelAsSuffix ? g.push(x) : g.splice(0, 0, x);
301
- }
302
- const m = [], T = /* @__PURE__ */ new Map();
303
- for (let x = g.length - 1; x >= 0; --x) {
304
- const { type: B } = g[x], k = g[x].importance ?? 0, D = (T.get(B) ?? 0) + 1;
305
- T.set(B, D);
306
- const O = `${B}@${D}`;
307
- s.set(O, (s.get(O) ?? 0) + 1), n.set(
308
- O,
309
- Math.max(
310
- n.get(O) ?? Number.NEGATIVE_INFINITY,
311
- k - (g.length - x) * Ze
312
- )
313
- ), m.push({ ...g[x], fullType: O, occurrenceIndex: D });
314
- }
315
- return m.reverse(), {
316
- value: f,
317
- spec: v,
318
- label: p,
319
- fullTrace: m
320
- };
321
- }), a = [], l = [], y = [...n];
322
- y.sort(([, f], [, P]) => P - f);
323
- for (const [f] of y)
324
- f.endsWith("@1") || s.get(f) === r.length ? a.push(f) : l.push(f);
325
- const j = (f, P = !1) => {
326
- const u = [];
327
- for (let h = 0; h < o.length; h++) {
328
- const v = o[h], L = v.fullTrace.filter((A) => f.has(A.fullType) || i && i.has(A.type));
329
- if (L.length === 0)
330
- if (P)
331
- u.push({
332
- label: "Unlabeled",
333
- value: v.value
334
- });
335
- else return;
336
- const C = L.map((A) => A.label), p = t.separator ?? " / ";
337
- u.push({
338
- label: C.join(p),
339
- value: v.value
340
- });
341
- }
342
- return u;
343
- };
344
- if (a.length === 0) {
345
- if (l.length !== 0) throw new Error("Non-empty secondary types list while main types list is empty.");
346
- return j(new Set(fe), !0);
347
- }
348
- let E = 0, F = -1;
349
- for (; E < a.length; ) {
350
- const f = /* @__PURE__ */ new Set();
351
- t.includeNativeLabel && f.add(fe);
352
- for (let u = 0; u < E; ++u) f.add(a[u]);
353
- F >= 0 && f.add(a[F]);
354
- const P = j(f);
355
- if (P !== void 0 && new Set(P.map((u) => u.label)).size === r.length) return P;
356
- F++, F >= a.length && (E++, F = E);
357
- }
358
- return j(/* @__PURE__ */ new Set([...a, ...l]), !0);
359
- }
360
- const q = "PColumnData/", re = q + "ResourceMap", ie = q + "Partitioned/ResourceMap", U = q + "JsonPartitioned", K = q + "BinaryPartitioned", Ae = q + "Partitioned/", Y = Ae + "JsonPartitioned", M = Ae + "BinaryPartitioned", se = (r) => {
361
- if (r.endsWith(".index"))
362
- return { baseKey: r.substring(0, r.length - 6), type: "index" };
363
- if (r.endsWith(".values"))
364
- return { baseKey: r.substring(0, r.length - 7), type: "values" };
365
- throw new Error(`key must ends on .index/.values for binary p-column, got: ${r}`);
366
- };
367
- function Xe(r) {
368
- if (!r) return;
369
- const e = r.resourceType.name, t = r.getDataAsJson(), n = [];
370
- let i = 0;
371
- switch (e) {
372
- case re:
373
- i = t.keyLength;
374
- break;
375
- case ie:
376
- i = t.partitionKeyLength + t.keyLength;
377
- break;
378
- case U:
379
- case K:
380
- i = t.partitionKeyLength;
381
- break;
382
- case M:
383
- case Y:
384
- i = t.superPartitionKeyLength + t.partitionKeyLength;
385
- break;
386
- }
387
- switch (e) {
388
- case re:
389
- case U:
390
- case K:
391
- for (let s of r.listInputFields()) {
392
- e === K && (s = se(s).baseKey);
393
- const o = [...JSON.parse(s)];
394
- n.push(o);
395
- }
396
- break;
397
- case ie:
398
- case M:
399
- case Y:
400
- for (const s of r.listInputFields()) {
401
- const o = [...JSON.parse(s)], a = r.resolve({ field: s, assertFieldType: "Input" });
402
- if (a !== void 0)
403
- for (let l of a.listInputFields()) {
404
- e === M && (l = se(l).baseKey);
405
- const y = [...o, ...JSON.parse(l)];
406
- n.push(y);
407
- }
408
- }
409
- break;
410
- }
411
- return { data: n, keyLength: i };
412
- }
413
- function et(r) {
414
- if (r.type !== "JsonPartitioned" && r.type !== "BinaryPartitioned")
415
- throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${r.type}`);
416
- const { parts: e, partitionKeyLength: t } = r, n = [];
417
- for (let i = 0; i < t; ++i)
418
- n.push(/* @__PURE__ */ new Set());
419
- for (const i of e) {
420
- const s = i.key;
421
- if (s.length !== t)
422
- throw new Error(
423
- `Key length (${s.length}) does not match partition length (${t}) for key: ${JSON.stringify(
424
- s
425
- )}`
426
- );
427
- for (let o = 0; o < t; ++o)
428
- n[o].add(s[o]);
429
- }
430
- return n.map((i) => Array.from(i.values()));
431
- }
432
- function tt(r) {
433
- if (r === void 0) return;
434
- if (_e(r))
435
- return et(r);
436
- const e = Xe(r);
437
- if (!e) return;
438
- const { data: t, keyLength: n } = e, i = [];
439
- for (let s = 0; s < n; ++s)
440
- i.push(/* @__PURE__ */ new Set());
441
- for (const s of t) {
442
- if (s.length !== n)
443
- throw new Error("key length does not match partition length");
444
- for (let o = 0; o < n; ++o)
445
- i[o].add(s[o]);
446
- }
447
- return i.map((s) => Array.from(s.values()));
448
- }
449
- function oe(r, e = []) {
450
- if (r === void 0 || !r.getIsReadyOrError()) return;
451
- const t = r.resourceType.name, n = r.getDataAsJson();
452
- if (e.length > 0 && (t === Y || t === M))
453
- throw new Error(`Unexpected nested super-partitioned resource: ${t}`);
454
- switch (t) {
455
- case re:
456
- case ie:
457
- throw new Error(`Only data columns are supported, got: ${t}`);
458
- case U: {
459
- if (typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
460
- throw new Error(`Missing partitionKeyLength in metadata for ${t}`);
461
- const i = [];
462
- for (const s of r.listInputFields()) {
463
- const o = r.resolve({ field: s, assertFieldType: "Input" });
464
- if (o === void 0) return;
465
- const a = [...e, ...JSON.parse(s)];
466
- i.push({ key: a, value: o });
467
- }
468
- return {
469
- type: "JsonPartitioned",
470
- partitionKeyLength: n.partitionKeyLength,
471
- parts: i
472
- };
473
- }
474
- case K: {
475
- if (typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
476
- throw new Error(`Missing partitionKeyLength in metadata for ${t}`);
477
- const i = [], s = /* @__PURE__ */ new Map();
478
- for (const o of r.listInputFields()) {
479
- const a = se(o), l = r.resolve({ field: o, assertFieldType: "Input" });
480
- if (l === void 0) return;
481
- let y = s.get(a.baseKey);
482
- y || (y = {}, s.set(a.baseKey, y)), a.type === "index" ? y.index = l : y.values = l;
483
- }
484
- for (const [o, a] of s.entries()) {
485
- if (!a.index || !a.values) return;
486
- const l = [...e, ...JSON.parse(o)];
487
- i.push({
488
- key: l,
489
- value: {
490
- index: a.index,
491
- values: a.values
492
- }
493
- });
494
- }
495
- return {
496
- type: "BinaryPartitioned",
497
- partitionKeyLength: n.partitionKeyLength,
498
- parts: i
499
- };
500
- }
501
- case Y: {
502
- if (typeof (n == null ? void 0 : n.superPartitionKeyLength) != "number" || typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
503
- throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${t}`);
504
- const i = n.superPartitionKeyLength + n.partitionKeyLength, s = [];
505
- for (const o of r.listInputFields()) {
506
- const a = r.resolve({ field: o, assertFieldType: "Input" });
507
- if (a === void 0) return;
508
- if (a.resourceType.name !== U)
509
- throw new Error(`Expected ${U} inside ${t}, but got ${a.resourceType.name}`);
510
- const l = oe(a, JSON.parse(o));
511
- if (l === void 0) return;
512
- if (l.type !== "JsonPartitioned")
513
- throw new Error(`Unexpected inner result type for ${t}: ${l.type}`);
514
- s.push(...l.parts);
515
- }
516
- return {
517
- type: "JsonPartitioned",
518
- partitionKeyLength: i,
519
- parts: s
520
- };
521
- }
522
- case M: {
523
- if (typeof (n == null ? void 0 : n.superPartitionKeyLength) != "number" || typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
524
- throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${t}`);
525
- const i = n.superPartitionKeyLength + n.partitionKeyLength, s = [];
526
- for (const o of r.listInputFields()) {
527
- const a = r.resolve({ field: o, assertFieldType: "Input" });
528
- if (a === void 0) return;
529
- if (a.resourceType.name !== K)
530
- throw new Error(`Expected ${K} inside ${t}, but got ${a.resourceType.name}`);
531
- const l = oe(a, JSON.parse(o));
532
- if (l === void 0) return;
533
- if (l.type !== "BinaryPartitioned")
534
- throw new Error(`Unexpected inner result type for ${t}: ${l.type}`);
535
- s.push(...l.parts);
536
- }
537
- return {
538
- type: "BinaryPartitioned",
539
- partitionKeyLength: i,
540
- parts: s
541
- };
542
- }
543
- default:
544
- throw new Error(`Unknown resource type: ${t}`);
545
- }
546
- }
547
- function nt(r) {
548
- if (r !== void 0) {
549
- if (_e(r)) return r;
550
- if (ae(r)) return Ne(r);
551
- if (r instanceof I) return oe(r);
552
- throw new Error(`Unexpected input type: ${typeof r}`);
553
- }
554
- }
555
- function rt(r, e) {
556
- const t = [...e].sort((s, o) => o[0] - s[0]);
557
- if (r.type === "JsonPartitioned" || r.type === "BinaryPartitioned") {
558
- const { partitionKeyLength: s } = r;
559
- for (const [o] of e)
560
- if (o >= s)
561
- throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`);
562
- } else if (r.type === "Json") {
563
- const { keyLength: s } = r;
564
- for (const [o] of e)
565
- if (o >= s)
566
- throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`);
567
- }
568
- const n = (s) => {
569
- for (const [o, a] of t)
570
- if (s[o] !== a)
571
- return !1;
572
- return !0;
573
- }, i = (s) => {
574
- const o = [...s];
575
- for (const [a] of t)
576
- o.splice(a, 1);
577
- return o;
578
- };
579
- switch (r.type) {
580
- case "Json": {
581
- const s = r.data.filter((o) => n(o.key)).map((o) => ({
582
- key: i(o.key),
583
- value: o.value
584
- }));
585
- return {
586
- type: "Json",
587
- keyLength: r.keyLength - e.length,
588
- data: s
589
- };
590
- }
591
- case "JsonPartitioned": {
592
- const s = r.parts.filter((o) => n(o.key)).map((o) => ({
593
- key: i(o.key),
594
- value: o.value
595
- }));
596
- return {
597
- type: "JsonPartitioned",
598
- partitionKeyLength: r.partitionKeyLength - e.length,
599
- parts: s
600
- };
601
- }
602
- case "BinaryPartitioned": {
603
- const s = r.parts.filter((o) => n(o.key)).map((o) => ({
604
- key: i(o.key),
605
- value: o.value
606
- }));
607
- return {
608
- type: "BinaryPartitioned",
609
- partitionKeyLength: r.partitionKeyLength - e.length,
610
- parts: s
611
- };
612
- }
613
- }
614
- }
615
- function it(r) {
616
- if (!Array.isArray(r)) return !1;
617
- if (r.length === 0) return !0;
618
- const e = r[0];
619
- return typeof e == "object" && e !== null && "key" in e && "val" in e;
620
- }
621
- class st {
622
- constructor(e) {
623
- this.columns = e;
624
- }
625
- selectColumns(e) {
626
- const t = typeof e == "function" ? e : W(e);
627
- return this.columns.filter((n) => t(n.spec));
628
- }
629
- }
630
- function ot(r) {
631
- if (r)
632
- return r.map((e) => ({
633
- type: `split:${$e(e.axisId)}`,
634
- label: e.label,
635
- importance: 1e6
636
- // High importance for split filters in labels
637
- }));
638
- }
639
- function at(r) {
640
- if (r)
641
- return r.map((e) => [e.axisIdx, e.value]);
642
- }
643
- function lt(r, e) {
644
- if (!e || e.length === 0) return r;
645
- const t = [...e].sort((n, i) => n[0] - i[0]);
646
- return we({ id: r, axisFilters: t });
647
- }
648
- function ge(r) {
649
- if (!r || typeof r != "object") return !1;
650
- const e = r, t = e.domain && typeof e.domain == "object" && Object.values(e.domain).some((i) => typeof i == "object" && i !== null && "anchor" in i), n = e.axes && Array.isArray(e.axes) && e.axes.some((i) => typeof i == "object" && i !== null && "anchor" in i);
651
- return !!e.domainAnchor || t || n;
652
- }
653
- function ut(r) {
654
- if (typeof r != "object" || !("axes" in r) || r.axes === void 0)
655
- return [];
656
- const e = r.axes.map((t, n) => typeof t == "object" && "split" in t && t.split === !0 ? n : -1).filter((t) => t !== -1);
657
- if (e.length > 0 && r.partialAxesMatch !== void 0)
658
- throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");
659
- return e.sort((t, n) => t - n), e;
660
- }
661
- class me {
662
- constructor() {
663
- S(this, "defaultProviderStore", []), S(this, "providers", [new st(this.defaultProviderStore)]), S(this, "axisLabelProviders", []);
664
- }
665
- addColumnProvider(e) {
666
- return this.providers.push(e), this;
667
- }
668
- addAxisLabelProvider(e) {
669
- return this.axisLabelProviders.push(e), this;
670
- }
671
- addColumns(e) {
672
- return this.defaultProviderStore.push(...e), this;
673
- }
674
- addColumn(e) {
675
- return this.defaultProviderStore.push(e), this;
676
- }
677
- /** Fetches labels for a given axis from the registered providers */
678
- findLabels(e) {
679
- for (const t of this.axisLabelProviders) {
680
- const n = t.findLabels(e);
681
- if (n) return n;
682
- }
683
- }
684
- getUniversalEntries(e, t) {
685
- const { anchorCtx: n, labelOps: i, dontWaitAllData: s = !1, overrideLabelAnnotation: o = !1, exclude: a } = t ?? {}, l = {
686
- ...o && (i == null ? void 0 : i.includeNativeLabel) !== !1 ? { includeNativeLabel: !0 } : {},
687
- ...i ?? {}
688
- };
689
- let y = () => !1;
690
- if (a) {
691
- const u = (Array.isArray(a) ? a : [a]).map((h) => {
692
- if (ge(h)) {
693
- if (!n)
694
- throw new Error("Anchored selectors in exclude require an AnchoredIdDeriver to be provided in options.");
695
- return W(pe(n.anchors, h, t));
696
- } else
697
- return W(h);
698
- });
699
- y = (h) => u.some((v) => v(h));
700
- }
701
- const j = typeof e == "function" ? [e] : Array.isArray(e) ? e : [e], E = [], F = /* @__PURE__ */ new Set();
702
- for (const u of j) {
703
- const h = ge(u);
704
- let v;
705
- if (h) {
706
- if (!n)
707
- throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");
708
- v = pe(n.anchors, u, t);
709
- } else
710
- v = u;
711
- const L = /* @__PURE__ */ new Set(), C = [];
712
- for (const d of this.providers) {
713
- const g = d.selectColumns(v);
714
- for (const m of g) {
715
- if (y(m.spec)) continue;
716
- if (L.has(m.id))
717
- throw new Error(`Duplicate column id ${m.id} in provider ${d.constructor.name}`);
718
- const T = ke(m.spec);
719
- F.has(T) || (L.add(m.id), F.add(T), C.push(m));
720
- }
721
- }
722
- if (C.length === 0) continue;
723
- const p = ut(u), A = p.length > 0;
724
- for (const d of C) {
725
- if (!G(d.spec)) continue;
726
- const g = d.spec;
727
- if (A) {
728
- if (it(d.data))
729
- throw new Error(`Splitting is not supported for PColumns with PColumnValues data format. Column id: ${d.id}`);
730
- const m = nt(d.data);
731
- if (!m) {
732
- if (s) continue;
733
- return;
734
- }
735
- if (!Re(m))
736
- throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${m.type} for column ${d.id}`);
737
- const T = tt(m), x = p[p.length - 1];
738
- if (x >= m.partitionKeyLength)
739
- throw new Error(`Not enough partition keys (${m.partitionKeyLength}) for requested split axes (max index ${x}) in column ${g.name}`);
740
- const B = p.map((b) => this.findLabels(de(g.axesSpec[b]))), k = [], D = (b, V) => {
741
- if (V >= p.length) {
742
- if (k.push([...b]), k.length > 1e4)
743
- throw new Error("Too many key combinations, aborting.");
744
- return;
745
- }
746
- const R = p[V];
747
- if (R >= T.length)
748
- throw new Error(`Axis index ${R} out of bounds for unique keys array (length ${T.length}) during split key generation for column ${d.id}`);
749
- const N = T[R];
750
- if (!N || N.length === 0) {
751
- k.length = 0;
752
- return;
753
- }
754
- for (const H of N)
755
- b.push(H), D(b, V + 1), b.pop();
756
- };
757
- if (D([], 0), k.length === 0)
758
- continue;
759
- const O = [...g.axesSpec], xe = p.map((b) => b);
760
- for (let b = p.length - 1; b >= 0; b--)
761
- O.splice(p[b], 1);
762
- const Se = { ...g, axesSpec: O };
763
- for (const b of k) {
764
- const V = b.map((R, N) => {
765
- const H = xe[N], Ie = de(g.axesSpec[H]), ue = B[N], Le = (ue == null ? void 0 : ue[R]) ?? String(R);
766
- return { axisIdx: H, axisId: Ie, value: R, label: Le };
767
- });
768
- E.push({
769
- type: "split",
770
- originalColumn: d,
771
- spec: g,
772
- adjustedSpec: Se,
773
- dataEntries: m,
774
- axisFilters: V
775
- });
776
- }
777
- } else
778
- E.push({
779
- type: "direct",
780
- originalColumn: d,
781
- spec: g,
782
- adjustedSpec: g
783
- });
784
- }
785
- }
786
- if (E.length === 0) return [];
787
- const f = Pe(
788
- E,
789
- (u) => ({
790
- spec: u.spec,
791
- suffixTrace: u.type === "split" ? ot(u.axisFilters) : void 0
792
- }),
793
- l
794
- ), P = [];
795
- for (const { value: u, label: h } of f) {
796
- const { originalColumn: v, spec: L } = u, C = u.type === "split" ? u.axisFilters : void 0, p = at(C);
797
- let A;
798
- n ? A = n.deriveS(L, p) : A = lt(v.id, p);
799
- let d = { ...u.adjustedSpec };
800
- o && (d = {
801
- ...d,
802
- annotations: {
803
- ...d.annotations ?? {},
804
- "pl7.app/label": h
805
- }
806
- }), P.push({
807
- id: A,
808
- spec: d,
809
- data: () => u.type === "split" ? De(rt(u.dataEntries, p)) : u.originalColumn.data,
810
- label: h
811
- });
812
- }
813
- return P;
814
- }
815
- getColumns(e, t) {
816
- const n = this.getUniversalEntries(e, {
817
- overrideLabelAnnotation: !0,
818
- // default for getColumns
819
- ...t ?? {}
820
- });
821
- if (!n) return;
822
- const i = [];
823
- for (const s of n) {
824
- const o = s.data();
825
- if (!o) {
826
- if (t != null && t.dontWaitAllData) continue;
827
- return;
828
- }
829
- i.push({
830
- id: s.id,
831
- spec: s.spec,
832
- data: o
833
- });
834
- }
835
- return i;
836
- }
837
- }
838
- function ye(r) {
839
- const e = (i) => i.operator !== "InSet" ? i : {
840
- operator: "Or",
841
- operands: i.references.map((s) => ({
842
- operator: "Equal",
843
- reference: s
844
- }))
845
- }, t = (i, s) => {
846
- switch (i.operator) {
847
- case "And":
848
- return {
849
- ...i,
850
- operands: i.operands.map((o) => t(o, s))
851
- };
852
- case "Or":
853
- return {
854
- ...i,
855
- operands: i.operands.map((o) => t(o, s))
856
- };
857
- case "Not":
858
- return {
859
- ...i,
860
- operand: t(i.operand, s)
861
- };
862
- default:
863
- return s(i);
864
- }
865
- }, n = (i, s) => ({
866
- ...i,
867
- predicate: t(i.predicate, s)
868
- });
869
- return r.map((i) => n(i, e));
870
- }
871
- function X(r, e) {
872
- if (r === void 0) return e === void 0;
873
- if (e === void 0) return !0;
874
- for (const t in e)
875
- if (r[t] !== e[t]) return !1;
876
- return !0;
877
- }
878
- function ve(r) {
879
- return le(r, (e) => e instanceof I ? e.handle : ae(e) ? Ke(e, (t) => t.handle) : e);
880
- }
881
- class ct {
882
- constructor() {
883
- S(this, "ctx", c());
884
- }
885
- /**
886
- * @deprecated use getOptions()
887
- */
888
- calculateOptions(e) {
889
- return this.ctx.calculateOptions(e);
890
- }
891
- getOptions(e, t) {
892
- const n = typeof e == "function" ? e : W(e), i = this.getSpecs().entries.filter((a) => n(a.obj));
893
- let s = {}, o = !1;
894
- return typeof t < "u" && (typeof t == "function" ? s = t : typeof t == "object" && ("includeNativeLabel" in t || "separator" in t || "addLabelAsSuffix" in t ? s = t : (t = t, s = t.label ?? {}, o = t.refsWithEnrichments ?? !1))), typeof s == "object" ? Pe(i, (a) => a.obj, s ?? {}).map(({ value: { ref: a }, label: l }) => ({
895
- ref: ce(a, o),
896
- label: l
897
- })) : i.map(({ ref: a, obj: l }) => ({
898
- ref: ce(a, o),
899
- label: s(l, a)
900
- }));
901
- }
902
- resolveAnchorCtx(e) {
903
- if (e instanceof he) return e;
904
- const t = {};
905
- for (const [n, i] of Object.entries(e))
906
- if (Te(i)) {
907
- const s = this.getPColumnSpecByRef(i);
908
- if (!s)
909
- return;
910
- t[n] = s;
911
- } else
912
- t[n] = i;
913
- return new he(t);
914
- }
915
- /**
916
- * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
917
- *
918
- * @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
919
- * @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
920
- * @param opts - Optional configuration for label generation and data waiting
921
- * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
922
- */
923
- getAnchoredPColumns(e, t, n) {
924
- const i = this.resolveAnchorCtx(e);
925
- if (i)
926
- return new me().addColumnProvider(this).addAxisLabelProvider(this).getColumns(t, {
927
- ...n,
928
- anchorCtx: i
929
- });
930
- }
931
- /**
932
- * Calculates anchored identifier options for columns matching a given predicate and returns their
933
- * canonicalized representations.
934
- *
935
- * This function filters column specifications from the result pool that match the provided predicate,
936
- * creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
937
- * pairs for UI components (like dropdowns).
938
- *
939
- * @param anchorsOrCtx - Either:
940
- * - An existing AnchorCtx instance
941
- * - A record mapping anchor IDs to PColumnSpec objects
942
- * - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
943
- * @param predicateOrSelectors - Either:
944
- * - A predicate function that takes a PColumnSpec and returns a boolean.
945
- * Only specs that return true will be included.
946
- * - An APColumnSelector object for declarative filtering, which will be
947
- * resolved against the provided anchors and matched using matchPColumn.
948
- * - An array of APColumnSelector objects - columns matching ANY selector
949
- * in the array will be included (OR operation).
950
- * @param opts - Optional configuration for label generation:
951
- * - labelOps: Optional configuration for label generation:
952
- * - includeNativeLabel: Whether to include native column labels
953
- * - separator: String to use between label parts (defaults to " / ")
954
- * - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
955
- * - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
956
- * if at least one column that requires splitting is missing data)
957
- * @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
958
- * or undefined if any PlRef resolution fails.
959
- */
960
- getCanonicalOptions(e, t, n) {
961
- const i = this.resolveAnchorCtx(e);
962
- if (!i) return;
963
- const s = new me().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(t, {
964
- ...n,
965
- anchorCtx: i
966
- });
967
- if (s)
968
- return s.map((o) => ({
969
- value: o.id,
970
- label: o.label
971
- }));
972
- }
973
- /**
974
- * @deprecated use getData()
975
- */
976
- getDataFromResultPool() {
977
- return this.getData();
978
- }
979
- getData() {
980
- const e = this.ctx.getDataFromResultPool();
981
- return {
982
- isComplete: e.isComplete,
983
- entries: e.entries.map((t) => ({
984
- ref: t.ref,
985
- obj: {
986
- ...t.obj,
987
- data: new I(t.obj.data, [t.ref.blockId, t.ref.name])
988
- }
989
- }))
990
- };
991
- }
992
- /**
993
- * @deprecated use getDataWithErrors()
994
- */
995
- getDataWithErrorsFromResultPool() {
996
- return this.getDataWithErrors();
997
- }
998
- getDataWithErrors() {
999
- const e = this.ctx.getDataWithErrorsFromResultPool();
1000
- return {
1001
- isComplete: e.isComplete,
1002
- entries: e.entries.map((t) => ({
1003
- ref: t.ref,
1004
- obj: {
1005
- ...t.obj,
1006
- data: Fe(
1007
- t.obj.data,
1008
- (n) => new I(n, [t.ref.blockId, t.ref.name])
1009
- )
1010
- }
1011
- }))
1012
- };
1013
- }
1014
- /**
1015
- * @deprecated use getSpecs()
1016
- */
1017
- getSpecsFromResultPool() {
1018
- return this.getSpecs();
1019
- }
1020
- getSpecs() {
1021
- return this.ctx.getSpecsFromResultPool();
1022
- }
1023
- /**
1024
- * @param ref a Ref
1025
- * @returns data associated with the ref
1026
- */
1027
- getDataByRef(e) {
1028
- var t;
1029
- if (typeof this.ctx.getDataFromResultPoolByRef > "u")
1030
- return (t = this.getData().entries.find(
1031
- (i) => i.ref.blockId === e.blockId && i.ref.name === e.name
1032
- )) == null ? void 0 : t.obj;
1033
- const n = this.ctx.getDataFromResultPoolByRef(e.blockId, e.name);
1034
- if (n)
1035
- return le(
1036
- n,
1037
- (i) => new I(i, [e.blockId, e.name])
1038
- );
1039
- }
1040
- /**
1041
- * Returns data associated with the ref ensuring that it is a p-column.
1042
- * @param ref a Ref
1043
- * @returns p-column associated with the ref
1044
- */
1045
- getPColumnByRef(e) {
1046
- const t = this.getDataByRef(e);
1047
- if (t)
1048
- return Oe(t);
1049
- }
1050
- /**
1051
- * Returns spec associated with the ref ensuring that it is a p-column spec.
1052
- * @param ref a Ref
1053
- * @returns p-column spec associated with the ref
1054
- */
1055
- getPColumnSpecByRef(e) {
1056
- const t = this.getSpecByRef(e);
1057
- if (t) {
1058
- if (!G(t)) throw new Error(`not a PColumn spec (kind = ${t.kind})`);
1059
- return t;
1060
- }
1061
- }
1062
- /**
1063
- * @param ref a Ref
1064
- * @returns object spec associated with the ref
1065
- */
1066
- getSpecByRef(e) {
1067
- return this.ctx.getSpecFromResultPoolByRef(e.blockId, e.name);
1068
- }
1069
- /**
1070
- * @param spec object specification
1071
- * @returns array of data objects with compatible specs
1072
- * @deprecated delete this method after Jan 1, 2025
1073
- */
1074
- findDataWithCompatibleSpec(e) {
1075
- const t = [];
1076
- e: for (const n of this.getData().entries) {
1077
- if (!G(n.obj.spec))
1078
- continue;
1079
- const i = n.obj.spec;
1080
- if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && X(e.domain, i.domain)) {
1081
- for (let s = 0; s < e.axesSpec.length; ++s) {
1082
- const o = e.axesSpec[s], a = i.axesSpec[s];
1083
- if (o.name !== a.name || o.type !== a.type || !X(o.domain, a.domain))
1084
- continue e;
1085
- }
1086
- t.push(n.obj);
1087
- }
1088
- }
1089
- return t;
1090
- }
1091
- /**
1092
- * Find labels data for a given axis id. It will search for a label column and return its data as a map.
1093
- * @returns a map of axis value => label
1094
- */
1095
- findLabels(e) {
1096
- const t = this.getData();
1097
- for (const n of t.entries) {
1098
- if (!be(n.obj)) continue;
1099
- const i = n.obj.spec;
1100
- if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && X(e.domain, i.axesSpec[0].domain)) {
1101
- if (n.obj.data.resourceType.name !== "PColumnData/Json")
1102
- throw Error(`Expected JSON column for labels, got: ${n.obj.data.resourceType.name}`);
1103
- return Object.fromEntries(
1104
- Object.entries(
1105
- n.obj.data.getDataAsJson().data
1106
- ).map((s) => [JSON.parse(s[0])[0], s[1]])
1107
- );
1108
- }
1109
- }
1110
- }
1111
- /**
1112
- * Selects columns based on the provided selectors, returning PColumn objects
1113
- * with lazily loaded data.
1114
- *
1115
- * @param selectors - A predicate function, a single selector, or an array of selectors.
1116
- * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
1117
- */
1118
- selectColumns(e) {
1119
- const t = typeof e == "function" ? e : W(e);
1120
- return this.getSpecs().entries.filter(({ obj: n }) => G(n) ? t(n) : !1).map(({ ref: n, obj: i }) => {
1121
- const s = i;
1122
- let o = null;
1123
- const a = this;
1124
- return {
1125
- id: we(n),
1126
- spec: s,
1127
- get data() {
1128
- var l;
1129
- return o !== null || (o = (l = a.getPColumnByRef(n)) == null ? void 0 : l.data), o;
1130
- }
1131
- };
1132
- });
1133
- }
1134
- /**
1135
- * Find labels data for a given axis id of a p-column.
1136
- * @returns a map of axis value => label
1137
- */
1138
- findLabelsForColumnAxis(e, t) {
1139
- var n;
1140
- const i = this.findLabels(e.axesSpec[t]);
1141
- if (!i) return;
1142
- const s = (n = e.annotations) == null ? void 0 : n["pl7.app/axisKeys/" + t];
1143
- if (s !== void 0) {
1144
- const o = JSON.parse(s);
1145
- return Object.fromEntries(o.map((a) => [a, i[a] ?? "Unlabelled"]));
1146
- } else
1147
- return i;
1148
- }
1149
- }
1150
- class z {
1151
- constructor() {
1152
- S(this, "ctx"), S(this, "_argsCache"), S(this, "_uiStateCache"), S(this, "_activeArgsCache"), S(this, "resultPool", new ct()), this.ctx = c();
1153
- }
1154
- get args() {
1155
- if (this._argsCache === void 0) {
1156
- const e = this.ctx.args, t = typeof e == "function" ? e() : e;
1157
- this._argsCache = { v: JSON.parse(t) };
1158
- }
1159
- return this._argsCache.v;
1160
- }
1161
- get uiState() {
1162
- if (this._uiStateCache === void 0) {
1163
- const e = this.ctx.uiState, t = typeof e == "function" ? e() : e;
1164
- this._uiStateCache = { v: t ? JSON.parse(t) : {} };
1165
- }
1166
- return this._uiStateCache.v;
1167
- }
1168
- /**
1169
- * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
1170
- * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
1171
- * */
1172
- get activeArgs() {
1173
- if (this._activeArgsCache === void 0) {
1174
- const e = this.ctx.activeArgs, t = typeof e == "function" ? e() : e;
1175
- this._activeArgsCache = {
1176
- v: t ? JSON.parse(t) : void 0
1177
- };
1178
- }
1179
- return this._activeArgsCache.v;
1180
- }
1181
- // /** Can be used to determine features provided by the desktop instance. */
1182
- // public get featureFlags() {
1183
- // return this.ctx.featureFlags;
1184
- // }
1185
- getNamedAccessor(e) {
1186
- return ne(
1187
- this.ctx.getAccessorHandleByName(e),
1188
- (t) => new I(t, [e])
1189
- );
1190
- }
1191
- get prerun() {
1192
- return this.getNamedAccessor(We);
1193
- }
1194
- get outputs() {
1195
- return this.getNamedAccessor(qe);
1196
- }
1197
- /**
1198
- * Find labels data for a given axis id. It will search for a label column and return its data as a map.
1199
- * @returns a map of axis value => label
1200
- * @deprecated Use resultPool.findLabels instead
1201
- */
1202
- findLabels(e) {
1203
- return this.resultPool.findLabels(e);
1204
- }
1205
- verifyInlineAndExplicitColumnsSupport(e) {
1206
- var t;
1207
- const n = e.some((s) => !(s.data instanceof I) || ae(s.data)), i = ((t = this.ctx.featureFlags) == null ? void 0 : t.inlineColumnsSupport) === !0;
1208
- if (n && !i) throw Error("Inline or explicit columns not supported");
1209
- }
1210
- patchPTableDef(e) {
1211
- var t, n;
1212
- return (t = this.ctx.featureFlags) != null && t.pTablePartitionFiltersSupport || (e = {
1213
- ...e,
1214
- partitionFilters: [],
1215
- filters: [...e.partitionFilters, ...e.filters]
1216
- }), (n = this.ctx.featureFlags) != null && n.pFrameInSetFilterSupport || (e = {
1217
- ...e,
1218
- partitionFilters: ye(e.partitionFilters),
1219
- filters: ye(e.filters)
1220
- }), e;
1221
- }
1222
- // TODO remove all non-PColumn fields
1223
- createPFrame(e) {
1224
- return this.verifyInlineAndExplicitColumnsSupport(e), this.ctx.createPFrame(
1225
- e.map((t) => ve(t))
1226
- );
1227
- }
1228
- createPTable(e) {
1229
- let t;
1230
- return "columns" in e ? t = this.patchPTableDef({
1231
- src: {
1232
- type: "full",
1233
- entries: e.columns.map((n) => ({ type: "column", column: n }))
1234
- },
1235
- partitionFilters: e.filters ?? [],
1236
- filters: [],
1237
- sorting: e.sorting ?? []
1238
- }) : t = this.patchPTableDef(e), this.verifyInlineAndExplicitColumnsSupport(Ce(t.src)), this.ctx.createPTable(
1239
- Ee(t, (n) => ve(n))
1240
- );
1241
- }
1242
- /** @deprecated scheduled for removal from SDK */
1243
- getBlockLabel(e) {
1244
- return this.ctx.getBlockLabel(e);
1245
- }
1246
- getCurrentUnstableMarker() {
1247
- return this.ctx.getCurrentUnstableMarker();
1248
- }
1249
- logInfo(e) {
1250
- this.ctx.logInfo(e);
1251
- }
1252
- logWarn(e) {
1253
- this.ctx.logWarn(e);
1254
- }
1255
- logError(e) {
1256
- this.ctx.logError(e);
1257
- }
1258
- }
1259
- const ee = "1.39.8";
1260
- function ht(r) {
1261
- return r.__renderLambda === !0;
1262
- }
1263
- function te(r) {
1264
- if (r !== void 0)
1265
- return ht(r) ? r.handle : r;
1266
- }
1267
- const pt = class _ {
1268
- constructor(e, t, n, i, s, o, a, l, y) {
1269
- this._renderingMode = e, this._initialArgs = t, this._initialUiState = n, this._outputs = i, this._inputsValid = s, this._sections = o, this._title = a, this._enrichmentTargets = l, this._featureFlags = y;
1270
- }
1271
- static create(e = "Heavy") {
1272
- return new _(
1273
- e,
1274
- void 0,
1275
- {},
1276
- {},
1277
- Z(!0),
1278
- Z([]),
1279
- void 0,
1280
- void 0,
1281
- { ..._.INITIAL_BLOCK_FEATURE_FLAGS }
1282
- );
1283
- }
1284
- output(e, t, n = {}) {
1285
- if (typeof t == "function") {
1286
- const i = `output#${e}`;
1287
- return J(i, () => t(new z())), new _(
1288
- this._renderingMode,
1289
- this._initialArgs,
1290
- this._initialUiState,
1291
- {
1292
- ...this._outputs,
1293
- [e]: {
1294
- __renderLambda: !0,
1295
- handle: i,
1296
- ...n
1297
- }
1298
- },
1299
- this._inputsValid,
1300
- this._sections,
1301
- this._title,
1302
- this._enrichmentTargets,
1303
- this._featureFlags
1304
- );
1305
- } else
1306
- return new _(
1307
- this._renderingMode,
1308
- this._initialArgs,
1309
- this._initialUiState,
1310
- {
1311
- ...this._outputs,
1312
- [e]: t
1313
- },
1314
- this._inputsValid,
1315
- this._sections,
1316
- this._title,
1317
- this._enrichmentTargets,
1318
- this._featureFlags
1319
- );
1320
- }
1321
- /** Shortcut for {@link output} with retentive flag set to true. */
1322
- retentiveOutput(e, t) {
1323
- return this.output(e, t, { retentive: !0 });
1324
- }
1325
- argsValid(e) {
1326
- return typeof e == "function" ? (J("inputsValid", () => e(new z())), new _(
1327
- this._renderingMode,
1328
- this._initialArgs,
1329
- this._initialUiState,
1330
- this._outputs,
1331
- {
1332
- __renderLambda: !0,
1333
- handle: "inputsValid"
1334
- },
1335
- this._sections,
1336
- this._title,
1337
- this._enrichmentTargets,
1338
- this._featureFlags
1339
- )) : new _(
1340
- this._renderingMode,
1341
- this._initialArgs,
1342
- this._initialUiState,
1343
- this._outputs,
1344
- e,
1345
- this._sections,
1346
- this._title,
1347
- this._enrichmentTargets,
1348
- this._featureFlags
1349
- );
1350
- }
1351
- sections(e) {
1352
- return Array.isArray(e) ? this.sections(Z(e)) : typeof e == "function" ? (J("sections", () => e(new z())), new _(
1353
- this._renderingMode,
1354
- this._initialArgs,
1355
- this._initialUiState,
1356
- this._outputs,
1357
- this._inputsValid,
1358
- { __renderLambda: !0, handle: "sections" },
1359
- this._title,
1360
- this._enrichmentTargets,
1361
- this._featureFlags
1362
- )) : new _(
1363
- this._renderingMode,
1364
- this._initialArgs,
1365
- this._initialUiState,
1366
- this._outputs,
1367
- this._inputsValid,
1368
- e,
1369
- this._title,
1370
- this._enrichmentTargets,
1371
- this._featureFlags
1372
- );
1373
- }
1374
- /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
1375
- title(e) {
1376
- return J("title", () => e(new z())), new _(
1377
- this._renderingMode,
1378
- this._initialArgs,
1379
- this._initialUiState,
1380
- this._outputs,
1381
- this._inputsValid,
1382
- this._sections,
1383
- { __renderLambda: !0, handle: "title" },
1384
- this._enrichmentTargets,
1385
- this._featureFlags
1386
- );
1387
- }
1388
- /**
1389
- * Sets initial args for the block, this value must be specified.
1390
- * @deprecated use {@link withArgs}
1391
- * */
1392
- initialArgs(e) {
1393
- return new _(
1394
- this._renderingMode,
1395
- e,
1396
- this._initialUiState,
1397
- this._outputs,
1398
- this._inputsValid,
1399
- this._sections,
1400
- this._title,
1401
- this._enrichmentTargets,
1402
- this._featureFlags
1403
- );
1404
- }
1405
- /** Sets initial args for the block, this value must be specified. */
1406
- withArgs(e) {
1407
- return new _(
1408
- this._renderingMode,
1409
- e,
1410
- this._initialUiState,
1411
- this._outputs,
1412
- this._inputsValid,
1413
- this._sections,
1414
- this._title,
1415
- this._enrichmentTargets,
1416
- this._featureFlags
1417
- );
1418
- }
1419
- /** Defines type and sets initial value for block UiState. */
1420
- withUiState(e) {
1421
- return new _(
1422
- this._renderingMode,
1423
- this._initialArgs,
1424
- e,
1425
- this._outputs,
1426
- this._inputsValid,
1427
- this._sections,
1428
- this._title,
1429
- this._enrichmentTargets,
1430
- this._featureFlags
1431
- );
1432
- }
1433
- /**
1434
- * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
1435
- * Influences dependency graph construction.
1436
- */
1437
- enriches(e) {
1438
- return J("enrichmentTargets", e), new _(
1439
- this._renderingMode,
1440
- this._initialArgs,
1441
- this._initialUiState,
1442
- this._outputs,
1443
- this._inputsValid,
1444
- this._sections,
1445
- this._title,
1446
- { __renderLambda: !0, handle: "enrichmentTargets" },
1447
- this._featureFlags
1448
- );
1449
- }
1450
- /** Renders all provided block settings into a pre-configured platforma API
1451
- * instance, that can be used in frontend to interact with block state, and
1452
- * other features provided by the platforma to the block. */
1453
- done() {
1454
- if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
1455
- const e = {
1456
- v3: {
1457
- sdkVersion: ee,
1458
- renderingMode: this._renderingMode,
1459
- initialArgs: this._initialArgs,
1460
- initialUiState: this._initialUiState,
1461
- inputsValid: this._inputsValid,
1462
- sections: this._sections,
1463
- title: this._title,
1464
- outputs: this._outputs,
1465
- enrichmentTargets: this._enrichmentTargets,
1466
- featureFlags: this._featureFlags
1467
- },
1468
- // fields below are added to allow previous desktop versions read generated configs
1469
- sdkVersion: ee,
1470
- renderingMode: this._renderingMode,
1471
- initialArgs: this._initialArgs,
1472
- inputsValid: te(this._inputsValid),
1473
- sections: te(this._sections),
1474
- outputs: Object.fromEntries(
1475
- Object.entries(this._outputs).map(([t, n]) => [t, te(n)])
1476
- )
1477
- };
1478
- return Ve() ? Je({ sdkVersion: ee }) : { config: e };
1479
- }
1480
- };
1481
- S(pt, "INITIAL_BLOCK_FEATURE_FLAGS", {
1482
- supportsLazyState: !0,
1483
- requiresUIAPIVersion: 1,
1484
- requiresModelAPIVersion: 1
1485
- });
1486
- function mt(r) {
1487
- return r.axesSpec.length === 1 && r.name === "pl7.app/label";
1488
- }
1489
- export {
1490
- he as AnchoredIdDeriver,
1491
- $t as BasePlErrorLike,
1492
- Kt as ErrorLike,
1493
- w as FutureRef,
1494
- He as PAnnotationLabel,
1495
- ze as PAnnotationTrace,
1496
- me as PColumnCollection,
1497
- bt as PTableAbsent,
1498
- _t as PTableNA,
1499
- wt as PValueBytesNA,
1500
- Pt as PValueIntNA,
1501
- At as PValueLongNA,
1502
- xt as PValueStringNA,
1503
- jt as PlErrorLike,
1504
- St as PlIdLength,
1505
- K as RT_BINARY_PARTITIONED,
1506
- M as RT_BINARY_SUPER_PARTITIONED,
1507
- U as RT_JSON_PARTITIONED,
1508
- Y as RT_JSON_SUPER_PARTITIONED,
1509
- re as RT_RESOURCE_MAP,
1510
- ie as RT_RESOURCE_MAP_PARTITIONED,
1511
- z as RenderCtx,
1512
- ct as ResultPool,
1513
- Bt as StandardErrorLike,
1514
- Ye as Trace,
1515
- Ge as TraceEntry,
1516
- I as TreeNodeAccessor,
1517
- $e as canonicalizeAxisId,
1518
- It as canonicalizeJson,
1519
- nt as convertOrParsePColumnData,
1520
- Ne as dataInfoToEntries,
1521
- Pe as deriveLabels,
1522
- ke as deriveNativeId,
1523
- te as downgradeCfgOrLambda,
1524
- Oe as ensurePColumn,
1525
- De as entriesToDataInfo,
1526
- Ce as extractAllColumns,
1527
- rt as filterDataInfoEntries,
1528
- Lt as getAxesId,
1529
- de as getAxisId,
1530
- Z as getImmediate,
1531
- Xe as getPartitionKeysList,
1532
- tt as getUniquePartitionKeys,
1533
- ne as ifDef,
1534
- ht as isConfigLambda,
1535
- ae as isDataInfo,
1536
- _e as isDataInfoEntries,
1537
- mt as isLabelColumn,
1538
- be as isPColumn,
1539
- G as isPColumnSpec,
1540
- Re as isPartitionedDataInfoEntries,
1541
- Te as isPlRef,
1542
- Ct as isValueAbsent,
1543
- Et as isValueNA,
1544
- Ke as mapDataInfo,
1545
- Tt as mapJoinEntry,
1546
- le as mapPObjectData,
1547
- Ee as mapPTableDef,
1548
- Fe as mapValueInVOE,
1549
- Ft as matchAxis,
1550
- Ot as matchAxisId,
1551
- kt as matchPColumn,
1552
- Rt as pTableValue,
1553
- oe as parsePColumnData,
1554
- pe as resolveAnchors,
1555
- W as selectorsToPredicate,
1556
- Dt as stringifyColumnId,
1557
- ce as withEnrichments
1558
- };
1559
- //# sourceMappingURL=index.js.map