react-semaphor 0.1.453 → 0.1.455
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +100 -99
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-GHKFwThg.js → analyze-result-contract-BbRJ-C06.js} +1 -1
- package/dist/chunks/{analyze-result-contract-Dxw66nUG.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
- package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
- package/dist/chunks/{canonical-result-keys-KLk__J_O.js → canonical-result-keys-D6avdjpA.js} +14 -13
- package/dist/chunks/{common-types-Ci66eflG.cjs → common-types-C57kJ59w.cjs} +1 -1
- package/dist/chunks/{common-types-F6qk6PPS.js → common-types-H51FLKB7.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CFpX0WX3.js → dashboard-briefing-launcher-BgBMjAVe.js} +10 -10
- package/dist/chunks/{dashboard-briefing-launcher-mUXWuiOZ.cjs → dashboard-briefing-launcher-BmEHYblf.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-SoNubIu1.cjs → dashboard-controls-BLNG_zHC.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BeYAmOJc.js → dashboard-controls-C-23EDdr.js} +10 -10
- package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
- package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
- package/dist/chunks/{dashboard-json-BublPnQ4.cjs → dashboard-json-BJ_Z9EaL.cjs} +1 -1
- package/dist/chunks/{dashboard-json-DeLUagVV.js → dashboard-json-BTF-1Iwa.js} +8 -8
- package/dist/chunks/{edit-dashboard-visual-CrvPcO7A.cjs → edit-dashboard-visual-CR832BJc.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Go0h82DR.js → edit-dashboard-visual-Mw-ZE7P7.js} +12 -12
- package/dist/chunks/{editor-action-buttons-1Lo0fIh7.cjs → editor-action-buttons-BVigIMg0.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-BFNtjFzO.js → editor-action-buttons-BxbFCerU.js} +6 -6
- package/dist/chunks/{index-BsH32bn1.js → index-B5Oy1eLv.js} +35305 -34883
- package/dist/chunks/index-C99Ow35Y.cjs +4 -0
- package/dist/chunks/{index-q12_nNUS.cjs → index-DIWJALWL.cjs} +231 -231
- package/dist/chunks/{index-B3ZugihZ.js → index-DrYILnh0.js} +799 -808
- package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
- package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-DcfPaCiy.cjs → pivot-header-presentation-DhyQXxKq.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-nk604qc1.js → pivot-header-presentation-ckYOQ4aZ.js} +2 -2
- package/dist/chunks/{pivot-result-identity-CRUokNgm.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-C43Ai5Kr.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
- package/dist/chunks/{pivot-result-lifecycle-4kSe0Hk1.js → pivot-result-lifecycle-sjzIOpvp.js} +57 -58
- package/dist/chunks/{raw-temporal-contract-CxbRFwnd.cjs → raw-temporal-contract-BtjH_G-d.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-BF7PjBY9.js → raw-temporal-contract-CxncLze5.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-BEVZAE3m.cjs → report-preferences-dialog-BgE3Gzsp.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-BNV7qXYH.js → report-preferences-dialog-CFenWkcH.js} +6 -6
- package/dist/chunks/{report-runtime-context-DjYqLV-c.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-BJQDu2fV.js → report-runtime-context-SM6YO61_.js} +5 -5
- package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
- package/dist/chunks/{saved-temporal-bucket-format-DiZdQXOL.js → saved-temporal-bucket-format-SGAV0ivR.js} +33 -35
- package/dist/chunks/{switch-DgLwr7O-.js → switch-BeZW-HnS.js} +367 -369
- package/dist/chunks/{switch-CjJ6FHYJ.cjs → switch-D-CCcfhc.cjs} +28 -28
- package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
- package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
- package/dist/chunks/{temporal-bucket-authoring-FIRnJz0e.js → temporal-bucket-authoring-K1kE6R_z.js} +28 -27
- package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-anl4h-vg.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-BQOj6Frl.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
- package/dist/chunks/{token-types-D0i0IUX3.cjs → token-types-D7CaaI80.cjs} +1 -1
- package/dist/chunks/{token-types-CRpQJ4kv.js → token-types-GbxRUozo.js} +1 -1
- package/dist/chunks/{update-policy-C1i9bgsy.cjs → update-policy-BmiOd0PB.cjs} +1 -1
- package/dist/chunks/{update-policy-CaJz9aPG.js → update-policy-hednMF-0.js} +1 -1
- package/dist/chunks/validators-BDYprKI9.cjs +1 -0
- package/dist/chunks/{validators-DeMXwRON.js → validators-DEmd8Sin.js} +1544 -1200
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +7 -7
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +78 -77
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +29 -30
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +21 -21
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +39 -40
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +44 -11
- package/dist/types/briefings.d.ts +9 -17
- package/dist/types/dashboard-assistant.d.ts +19 -22
- package/dist/types/dashboard-authoring.d.ts +9 -17
- package/dist/types/dashboard.d.ts +9 -17
- package/dist/types/data-app-builder.d.ts +28 -2
- package/dist/types/data-app-codegen-node.d.ts +29 -3
- package/dist/types/data-app-codegen.d.ts +29 -3
- package/dist/types/data-app-sdk-adapters.d.ts +28 -2
- package/dist/types/data-app-sdk-validation.d.ts +38 -7
- package/dist/types/data-app-sdk.d.ts +42 -10
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +25 -26
- package/dist/types/shared.d.ts +9 -17
- package/dist/types/surfboard.d.ts +9 -17
- package/dist/types/types.d.ts +19 -22
- package/package.json +1 -1
- package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
- package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
- package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
- package/dist/chunks/index-DjiIh_9n.cjs +0 -4
- package/dist/chunks/metric-comparison-D0T0MKRK.js +0 -387
- package/dist/chunks/metric-comparison-DYR3RXam.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +0 -1
- package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +0 -1
- package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +0 -1
- package/dist/chunks/temporal-bucket-FBZGrDCe.js +0 -560
- package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +0 -1
- package/dist/chunks/validators-Dm7Kpz6p.cjs +0 -1
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var B = (e, t, a) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
|
+
var x = (e, t, a) => B(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
+
import { p as S } from "./temporal-bucket-5UYEotyQ.js";
|
|
5
|
+
import { k as T } from "./validators-DEmd8Sin.js";
|
|
6
|
+
import { v as k } from "./temporal-bucket-contract-D5d-xEl3.js";
|
|
7
|
+
function V(e) {
|
|
8
|
+
return `compat-filter:${e}`;
|
|
9
|
+
}
|
|
10
|
+
function J(e) {
|
|
11
|
+
return `compat-control:${e}`;
|
|
12
|
+
}
|
|
13
|
+
function L(e, t) {
|
|
14
|
+
return `compat-inline-filter:${e}:${t}`;
|
|
15
|
+
}
|
|
16
|
+
function D(e, t) {
|
|
17
|
+
return `compat-card-control:${e}:${t}`;
|
|
18
|
+
}
|
|
19
|
+
class v extends Error {
|
|
20
|
+
constructor(a) {
|
|
21
|
+
super(a.message);
|
|
22
|
+
x(this, "code");
|
|
23
|
+
x(this, "path");
|
|
24
|
+
this.name = "MatrixResultContractError", this.code = a.code, this.path = a.path;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function F(e) {
|
|
28
|
+
var u, m, p;
|
|
29
|
+
const t = G(e);
|
|
30
|
+
if (t !== 2)
|
|
31
|
+
throw new v({
|
|
32
|
+
code: "unsupported_matrix_result_version",
|
|
33
|
+
message: `Canonical Matrix results require schemaVersion 2; received ${String(t)}.`,
|
|
34
|
+
path: "schemaVersion"
|
|
35
|
+
});
|
|
36
|
+
const a = T.safeParse(e);
|
|
37
|
+
if (!a.success) {
|
|
38
|
+
const d = a.error.issues[0];
|
|
39
|
+
throw o(
|
|
40
|
+
(d == null ? void 0 : d.message) || "Canonical Matrix result has an invalid shape.",
|
|
41
|
+
d == null ? void 0 : d.path.join(".")
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const r = a.data, s = {
|
|
45
|
+
row: y(r.axes.rows.levels, "axes.rows.levels"),
|
|
46
|
+
column: y(
|
|
47
|
+
r.axes.columns.levels,
|
|
48
|
+
"axes.columns.levels"
|
|
49
|
+
)
|
|
50
|
+
};
|
|
51
|
+
O(r), $(r, "row"), $(r, "column");
|
|
52
|
+
const n = /* @__PURE__ */ new Set([
|
|
53
|
+
...r.axes.rows.nodeIds,
|
|
54
|
+
...r.axes.columns.nodeIds
|
|
55
|
+
]), i = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const [d, l] of Object.entries(r.nodesById)) {
|
|
57
|
+
if (l.id !== d)
|
|
58
|
+
throw o(
|
|
59
|
+
"Matrix node directory key must equal node.id.",
|
|
60
|
+
`nodesById.${d}.id`
|
|
61
|
+
);
|
|
62
|
+
if (!n.has(d))
|
|
63
|
+
throw o(
|
|
64
|
+
"Matrix node directory cannot contain nodes omitted from both axes.",
|
|
65
|
+
`nodesById.${d}`
|
|
66
|
+
);
|
|
67
|
+
C(l, s[l.axis], `nodesById.${d}`);
|
|
68
|
+
const f = JSON.stringify([
|
|
69
|
+
l.axis,
|
|
70
|
+
l.path,
|
|
71
|
+
l.isSubtotal === !0,
|
|
72
|
+
l.isGrandTotal === !0
|
|
73
|
+
]);
|
|
74
|
+
if (i.has(f))
|
|
75
|
+
throw o(
|
|
76
|
+
"Matrix nodes must have unique canonical path and total-role identity.",
|
|
77
|
+
`nodesById.${d}`
|
|
78
|
+
);
|
|
79
|
+
i.add(f), q(r, l, `nodesById.${d}`);
|
|
80
|
+
}
|
|
81
|
+
const c = /* @__PURE__ */ new Set();
|
|
82
|
+
for (const [d, l] of r.cells.entries()) {
|
|
83
|
+
if (!((u = r.nodesById[l.rowId]) != null && u.axis) || ((m = r.nodesById[l.rowId]) == null ? void 0 : m.axis) !== "row")
|
|
84
|
+
throw o(
|
|
85
|
+
"Matrix cell rowId must reference a row node.",
|
|
86
|
+
`cells.${d}.rowId`
|
|
87
|
+
);
|
|
88
|
+
if (l.columnId && ((p = r.nodesById[l.columnId]) == null ? void 0 : p.axis) !== "column")
|
|
89
|
+
throw o(
|
|
90
|
+
"Matrix cell columnId must reference a column node.",
|
|
91
|
+
`cells.${d}.columnId`
|
|
92
|
+
);
|
|
93
|
+
if (!r.measuresById[l.measureId])
|
|
94
|
+
throw o(
|
|
95
|
+
"Matrix cell measureId must reference a measure.",
|
|
96
|
+
`cells.${d}.measureId`
|
|
97
|
+
);
|
|
98
|
+
const f = R(
|
|
99
|
+
r.nodesById[l.rowId],
|
|
100
|
+
l.columnId ? r.nodesById[l.columnId] : void 0
|
|
101
|
+
);
|
|
102
|
+
if (l.role !== f)
|
|
103
|
+
throw o(
|
|
104
|
+
"Matrix cell role must match its referenced row and column total roles.",
|
|
105
|
+
`cells.${d}.role`
|
|
106
|
+
);
|
|
107
|
+
const w = JSON.stringify([
|
|
108
|
+
l.rowId,
|
|
109
|
+
l.columnId ?? null,
|
|
110
|
+
l.measureId
|
|
111
|
+
]);
|
|
112
|
+
if (c.has(w))
|
|
113
|
+
throw o(
|
|
114
|
+
"Matrix result cannot contain duplicate physical cell addresses.",
|
|
115
|
+
`cells.${d}`
|
|
116
|
+
);
|
|
117
|
+
c.add(w);
|
|
118
|
+
}
|
|
119
|
+
return K(r, s), r;
|
|
120
|
+
}
|
|
121
|
+
function y(e, t) {
|
|
122
|
+
var r;
|
|
123
|
+
const a = /* @__PURE__ */ new Map();
|
|
124
|
+
for (const [s, n] of e.entries()) {
|
|
125
|
+
const i = `${t}.${s}`;
|
|
126
|
+
if (a.has(n.instanceId))
|
|
127
|
+
throw o(
|
|
128
|
+
"Matrix axis level ids must be unique.",
|
|
129
|
+
`${i}.instanceId`
|
|
130
|
+
);
|
|
131
|
+
a.set(n.instanceId, n);
|
|
132
|
+
const c = n.field.role === "date" || n.field.dataType === "date" || n.field.dataType === "datetime", u = n.field.dataType === "string" || n.field.dataType === "number" || n.field.dataType === "boolean";
|
|
133
|
+
if (c && !n.grain)
|
|
134
|
+
throw o(
|
|
135
|
+
"Temporal Matrix axis level is missing its explicit grain.",
|
|
136
|
+
`${i}.grain`
|
|
137
|
+
);
|
|
138
|
+
if (u && n.grain)
|
|
139
|
+
throw o(
|
|
140
|
+
"Non-temporal Matrix axis level cannot carry a grain.",
|
|
141
|
+
`${i}.grain`
|
|
142
|
+
);
|
|
143
|
+
if (n.grain) {
|
|
144
|
+
if (!n.temporalBucket)
|
|
145
|
+
throw o(
|
|
146
|
+
"Temporal Matrix axis level is missing governed bucket metadata.",
|
|
147
|
+
`${i}.temporalBucket`
|
|
148
|
+
);
|
|
149
|
+
const m = k(n.temporalBucket);
|
|
150
|
+
if (!m.ok || ((r = m.value) == null ? void 0 : r.granularity) !== n.grain)
|
|
151
|
+
throw o(
|
|
152
|
+
"Matrix axis grain and temporal metadata must agree.",
|
|
153
|
+
`${i}.temporalBucket`
|
|
154
|
+
);
|
|
155
|
+
} else if (n.temporalBucket)
|
|
156
|
+
throw o(
|
|
157
|
+
"Non-temporal Matrix axis levels cannot carry temporal bucket metadata.",
|
|
158
|
+
i
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return a;
|
|
162
|
+
}
|
|
163
|
+
function $(e, t) {
|
|
164
|
+
var s;
|
|
165
|
+
const a = t === "row" ? e.axes.rows : e.axes.columns, r = /* @__PURE__ */ new Set();
|
|
166
|
+
for (const [n, i] of a.nodeIds.entries()) {
|
|
167
|
+
if (r.has(i))
|
|
168
|
+
throw o(
|
|
169
|
+
"Matrix axis node ids must be unique.",
|
|
170
|
+
`axes.${t === "row" ? "rows" : "columns"}.nodeIds.${n}`
|
|
171
|
+
);
|
|
172
|
+
if (r.add(i), ((s = e.nodesById[i]) == null ? void 0 : s.axis) !== t)
|
|
173
|
+
throw o(
|
|
174
|
+
"Matrix axis node id references the wrong axis.",
|
|
175
|
+
`axes.${t === "row" ? "rows" : "columns"}.nodeIds.${n}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function C(e, t, a) {
|
|
180
|
+
if (e.isGrandTotal) {
|
|
181
|
+
if (e.isSubtotal)
|
|
182
|
+
throw o(
|
|
183
|
+
"Matrix nodes cannot be both subtotal and grand total.",
|
|
184
|
+
a
|
|
185
|
+
);
|
|
186
|
+
if (e.path.length !== 0)
|
|
187
|
+
throw o(
|
|
188
|
+
"Matrix grand-total nodes must have an empty member path.",
|
|
189
|
+
`${a}.path`
|
|
190
|
+
);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!e.path.length || e.level !== e.path.length - 1)
|
|
194
|
+
throw o(
|
|
195
|
+
"Ordinary and subtotal Matrix nodes require a level-aligned non-empty path.",
|
|
196
|
+
a
|
|
197
|
+
);
|
|
198
|
+
const r = [...t.values()];
|
|
199
|
+
if (e.path.length > r.length)
|
|
200
|
+
throw o(
|
|
201
|
+
"Matrix node path exceeds its authored axis depth.",
|
|
202
|
+
`${a}.path`
|
|
203
|
+
);
|
|
204
|
+
if (e.isSubtotal && e.path.length >= r.length)
|
|
205
|
+
throw o(
|
|
206
|
+
"Matrix subtotal nodes must identify a proper authored-axis prefix.",
|
|
207
|
+
`${a}.path`
|
|
208
|
+
);
|
|
209
|
+
e.path.forEach((c, u) => {
|
|
210
|
+
const m = r[u];
|
|
211
|
+
if (c.instanceId === "__matrix_remaining__" && c.fieldKey === "__matrix_remaining__" && c.value === "__matrix_remaining__") {
|
|
212
|
+
if (u !== e.path.length - 1)
|
|
213
|
+
throw o(
|
|
214
|
+
"Matrix remaining-member identity must be the terminal path segment.",
|
|
215
|
+
`${a}.path.${u}`
|
|
216
|
+
);
|
|
217
|
+
if (typeof c.label != "string")
|
|
218
|
+
throw o(
|
|
219
|
+
"Matrix remaining-member paths require their explicit display label.",
|
|
220
|
+
`${a}.path.${u}.label`
|
|
221
|
+
);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!m || c.instanceId !== m.instanceId || c.fieldKey !== m.fieldKey)
|
|
225
|
+
throw o(
|
|
226
|
+
"Matrix member path must follow authored axis order and identity.",
|
|
227
|
+
`${a}.path.${u}`
|
|
228
|
+
);
|
|
229
|
+
M(c, m, `${a}.path.${u}`);
|
|
230
|
+
});
|
|
231
|
+
const s = e.path[e.path.length - 1], n = s.instanceId === "__matrix_remaining__" && s.fieldKey === "__matrix_remaining__" && s.value === "__matrix_remaining__";
|
|
232
|
+
if (!I(e.value, s.value))
|
|
233
|
+
throw o(
|
|
234
|
+
"Matrix node value must equal its final canonical path member.",
|
|
235
|
+
`${a}.value`
|
|
236
|
+
);
|
|
237
|
+
const i = r[e.path.length - 1];
|
|
238
|
+
if (i != null && i.temporalBucket && !e.isSubtotal && !n && e.label !== void 0)
|
|
239
|
+
throw o(
|
|
240
|
+
"Temporal Matrix nodes cannot transport display labels.",
|
|
241
|
+
`${a}.label`
|
|
242
|
+
);
|
|
243
|
+
if ((!(i != null && i.temporalBucket) || n) && typeof e.label != "string")
|
|
244
|
+
throw o(
|
|
245
|
+
"Non-temporal Matrix nodes require a display label.",
|
|
246
|
+
`${a}.label`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
function R(e, t) {
|
|
250
|
+
return e.isGrandTotal && (t != null && t.isGrandTotal) ? "matrixGrandTotal" : e.isGrandTotal ? "rowGrandTotal" : t != null && t.isGrandTotal ? "columnGrandTotal" : e.isSubtotal && (t != null && t.isSubtotal) ? "subtotalIntersection" : e.isSubtotal ? "rowSubtotal" : t != null && t.isSubtotal ? "columnSubtotal" : "value";
|
|
251
|
+
}
|
|
252
|
+
function M(e, t, a) {
|
|
253
|
+
if (t.temporalBucket) {
|
|
254
|
+
if (e.label !== void 0)
|
|
255
|
+
throw o(
|
|
256
|
+
"Temporal Matrix path members cannot transport display labels.",
|
|
257
|
+
`${a}.label`
|
|
258
|
+
);
|
|
259
|
+
if (e.value !== null && typeof e.value != "string")
|
|
260
|
+
throw o(
|
|
261
|
+
"Temporal Matrix member values must be canonical strings or null.",
|
|
262
|
+
`${a}.value`
|
|
263
|
+
);
|
|
264
|
+
const r = S(
|
|
265
|
+
e.value,
|
|
266
|
+
t.temporalBucket
|
|
267
|
+
);
|
|
268
|
+
if (!r.ok)
|
|
269
|
+
throw o(r.error.message, `${a}.value`);
|
|
270
|
+
} else if (typeof e.label != "string")
|
|
271
|
+
throw o(
|
|
272
|
+
"Non-temporal Matrix path members require a display label.",
|
|
273
|
+
`${a}.label`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
function K(e, t) {
|
|
277
|
+
const a = [...t.row.values()];
|
|
278
|
+
if (e.layout.rowHeaderLevels.length !== a.length)
|
|
279
|
+
throw o(
|
|
280
|
+
"Matrix row-header layout must describe every row-axis level exactly once.",
|
|
281
|
+
"layout.rowHeaderLevels"
|
|
282
|
+
);
|
|
283
|
+
e.layout.rowHeaderLevels.forEach((s, n) => {
|
|
284
|
+
var i;
|
|
285
|
+
if (s.fieldInstanceId !== ((i = a[n]) == null ? void 0 : i.instanceId))
|
|
286
|
+
throw o(
|
|
287
|
+
"Matrix row-header layout must follow authored row-axis order.",
|
|
288
|
+
`layout.rowHeaderLevels.${n}.fieldInstanceId`
|
|
289
|
+
);
|
|
290
|
+
});
|
|
291
|
+
for (const [s, n] of e.layout.columnHeaderRows.entries())
|
|
292
|
+
for (const [i, c] of n.cells.entries()) {
|
|
293
|
+
if (b(
|
|
294
|
+
c.columnPath,
|
|
295
|
+
t.column,
|
|
296
|
+
`layout.columnHeaderRows.${s}.cells.${i}.columnPath`
|
|
297
|
+
), c.measureInstanceId && !e.measuresById[c.measureInstanceId])
|
|
298
|
+
throw o(
|
|
299
|
+
"Matrix header measureInstanceId must reference a measure.",
|
|
300
|
+
`layout.columnHeaderRows.${s}.cells.${i}.measureInstanceId`
|
|
301
|
+
);
|
|
302
|
+
if (c.role === "columnHeader" && c.label !== void 0)
|
|
303
|
+
throw o(
|
|
304
|
+
"Matrix member headers cannot transport composed display labels.",
|
|
305
|
+
`layout.columnHeaderRows.${s}.cells.${i}.label`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
const r = /* @__PURE__ */ new Set();
|
|
309
|
+
for (const [s, n] of e.layout.columns.entries()) {
|
|
310
|
+
if (r.has(n.id))
|
|
311
|
+
throw o(
|
|
312
|
+
"Matrix layout column ids must be unique.",
|
|
313
|
+
`layout.columns.${s}.id`
|
|
314
|
+
);
|
|
315
|
+
if (r.add(n.id), b(
|
|
316
|
+
n.columnPath,
|
|
317
|
+
t.column,
|
|
318
|
+
`layout.columns.${s}.columnPath`
|
|
319
|
+
), n.role === "value" && n.columnPath.length > 0 && n.label !== void 0)
|
|
320
|
+
throw o(
|
|
321
|
+
"Matrix value columns with member paths cannot transport composed display labels.",
|
|
322
|
+
`layout.columns.${s}.label`
|
|
323
|
+
);
|
|
324
|
+
if (!e.measuresById[n.measureInstanceId])
|
|
325
|
+
throw o(
|
|
326
|
+
"Matrix layout column measureInstanceId must reference a measure.",
|
|
327
|
+
`layout.columns.${s}.measureInstanceId`
|
|
328
|
+
);
|
|
329
|
+
if (n.columnNodeId) {
|
|
330
|
+
const i = e.nodesById[n.columnNodeId];
|
|
331
|
+
if ((i == null ? void 0 : i.axis) !== "column" || !I(i.path, n.columnPath))
|
|
332
|
+
throw o(
|
|
333
|
+
"Matrix layout column must match its referenced column node path.",
|
|
334
|
+
`layout.columns.${s}.columnNodeId`
|
|
335
|
+
);
|
|
336
|
+
} else if (t.column.size > 0)
|
|
337
|
+
throw o(
|
|
338
|
+
"Matrix columns with an authored column axis require a columnNodeId.",
|
|
339
|
+
`layout.columns.${s}.columnNodeId`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function b(e, t, a) {
|
|
344
|
+
const r = [...t.values()];
|
|
345
|
+
if (e.length > r.length)
|
|
346
|
+
throw o(
|
|
347
|
+
"Matrix layout path exceeds its authored axis depth.",
|
|
348
|
+
a
|
|
349
|
+
);
|
|
350
|
+
e.forEach((s, n) => {
|
|
351
|
+
const i = r[n];
|
|
352
|
+
if (!i || s.instanceId !== i.instanceId || s.fieldKey !== i.fieldKey)
|
|
353
|
+
throw o(
|
|
354
|
+
"Matrix layout path must follow authored axis order and identity.",
|
|
355
|
+
`${a}.${n}`
|
|
356
|
+
);
|
|
357
|
+
M(s, i, `${a}.${n}`);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function q(e, t, a) {
|
|
361
|
+
if (!t.parentId) return;
|
|
362
|
+
const r = e.nodesById[t.parentId];
|
|
363
|
+
if (!r)
|
|
364
|
+
throw o(
|
|
365
|
+
"Matrix parentId must reference an existing node.",
|
|
366
|
+
`${a}.parentId`
|
|
367
|
+
);
|
|
368
|
+
if (r.axis !== t.axis || r.path.length !== t.path.length - 1 || !I(r.path, t.path.slice(0, -1)))
|
|
369
|
+
throw o(
|
|
370
|
+
"Matrix parentId must reference the immediate same-axis path prefix.",
|
|
371
|
+
`${a}.parentId`
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
function O(e) {
|
|
375
|
+
for (const [t, a] of [
|
|
376
|
+
["rows", e.axes.rows],
|
|
377
|
+
["columns", e.axes.columns]
|
|
378
|
+
]) {
|
|
379
|
+
const r = t === "rows" ? "row" : "column";
|
|
380
|
+
a.levels.forEach((s, n) => {
|
|
381
|
+
const i = e.fieldsById[s.instanceId];
|
|
382
|
+
if (!i || i.instanceId !== s.instanceId || i.fieldKey !== s.fieldKey || i.role !== r || !g(i.field, s.field))
|
|
383
|
+
throw o(
|
|
384
|
+
"Matrix axis level must have one matching role-scoped field descriptor.",
|
|
385
|
+
`axes.${t}.levels.${n}`
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
for (const [t, a] of Object.entries(e.measuresById)) {
|
|
390
|
+
if (a.instanceId !== t)
|
|
391
|
+
throw o(
|
|
392
|
+
"Matrix measure directory key must equal measure.instanceId.",
|
|
393
|
+
`measuresById.${t}.instanceId`
|
|
394
|
+
);
|
|
395
|
+
const r = e.fieldsById[t];
|
|
396
|
+
if (!r || r.instanceId !== t || r.fieldKey !== a.fieldKey || r.role !== "measure" || !g(r.field, a.field))
|
|
397
|
+
throw o(
|
|
398
|
+
"Matrix measure must have one matching field descriptor.",
|
|
399
|
+
`measuresById.${t}`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function G(e) {
|
|
404
|
+
return e && typeof e == "object" ? e.schemaVersion : void 0;
|
|
405
|
+
}
|
|
406
|
+
function I(e, t) {
|
|
407
|
+
return JSON.stringify(e) === JSON.stringify(t);
|
|
408
|
+
}
|
|
409
|
+
function g(e, t) {
|
|
410
|
+
return h(e) === h(t);
|
|
411
|
+
}
|
|
412
|
+
function h(e) {
|
|
413
|
+
if (Array.isArray(e))
|
|
414
|
+
return `[${e.map(h).join(",")}]`;
|
|
415
|
+
if (e && typeof e == "object") {
|
|
416
|
+
const t = e;
|
|
417
|
+
return `{${Object.keys(t).filter((a) => t[a] !== void 0).sort().map(
|
|
418
|
+
(a) => `${JSON.stringify(a)}:${h(t[a])}`
|
|
419
|
+
).join(",")}}`;
|
|
420
|
+
}
|
|
421
|
+
return e === void 0 ? "undefined" : JSON.stringify(e);
|
|
422
|
+
}
|
|
423
|
+
function o(e, t) {
|
|
424
|
+
return new v({
|
|
425
|
+
code: "invalid_matrix_result_contract",
|
|
426
|
+
message: e,
|
|
427
|
+
path: t
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
export {
|
|
431
|
+
v as M,
|
|
432
|
+
J as a,
|
|
433
|
+
L as b,
|
|
434
|
+
D as c,
|
|
435
|
+
V as g,
|
|
436
|
+
F as p
|
|
437
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _=Object.defineProperty;var B=(e,t,a)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var I=(e,t,a)=>B(e,typeof t!="symbol"?t+"":t,a);const C=require("./temporal-bucket-DHY1y9lq.cjs"),S=require("./validators-BDYprKI9.cjs"),T=require("./temporal-bucket-contract-D2-93DGr.cjs");function k(e){return`compat-filter:${e}`}function R(e){return`compat-control:${e}`}function q(e,t){return`compat-inline-filter:${e}:${t}`}function K(e,t){return`compat-card-control:${e}:${t}`}class x extends Error{constructor(a){super(a.message);I(this,"code");I(this,"path");this.name="MatrixResultContractError",this.code=a.code,this.path=a.path}}function O(e){var u,m,p;const t=V(e);if(t!==2)throw new x({code:"unsupported_matrix_result_version",message:`Canonical Matrix results require schemaVersion 2; received ${String(t)}.`,path:"schemaVersion"});const a=S.semaphorMatrixResultSchema.safeParse(e);if(!a.success){const d=a.error.issues[0];throw o((d==null?void 0:d.message)||"Canonical Matrix result has an invalid shape.",d==null?void 0:d.path.join("."))}const r=a.data,s={row:$(r.axes.rows.levels,"axes.rows.levels"),column:$(r.axes.columns.levels,"axes.columns.levels")};P(r),b(r,"row"),b(r,"column");const n=new Set([...r.axes.rows.nodeIds,...r.axes.columns.nodeIds]),i=new Set;for(const[d,l]of Object.entries(r.nodesById)){if(l.id!==d)throw o("Matrix node directory key must equal node.id.",`nodesById.${d}.id`);if(!n.has(d))throw o("Matrix node directory cannot contain nodes omitted from both axes.",`nodesById.${d}`);G(l,s[l.axis],`nodesById.${d}`);const f=JSON.stringify([l.axis,l.path,l.isSubtotal===!0,l.isGrandTotal===!0]);if(i.has(f))throw o("Matrix nodes must have unique canonical path and total-role identity.",`nodesById.${d}`);i.add(f),E(r,l,`nodesById.${d}`)}const c=new Set;for(const[d,l]of r.cells.entries()){if(!((u=r.nodesById[l.rowId])!=null&&u.axis)||((m=r.nodesById[l.rowId])==null?void 0:m.axis)!=="row")throw o("Matrix cell rowId must reference a row node.",`cells.${d}.rowId`);if(l.columnId&&((p=r.nodesById[l.columnId])==null?void 0:p.axis)!=="column")throw o("Matrix cell columnId must reference a column node.",`cells.${d}.columnId`);if(!r.measuresById[l.measureId])throw o("Matrix cell measureId must reference a measure.",`cells.${d}.measureId`);const f=H(r.nodesById[l.rowId],l.columnId?r.nodesById[l.columnId]:void 0);if(l.role!==f)throw o("Matrix cell role must match its referenced row and column total roles.",`cells.${d}.role`);const y=JSON.stringify([l.rowId,l.columnId??null,l.measureId]);if(c.has(y))throw o("Matrix result cannot contain duplicate physical cell addresses.",`cells.${d}`);c.add(y)}return j(r,s),r}function $(e,t){var r;const a=new Map;for(const[s,n]of e.entries()){const i=`${t}.${s}`;if(a.has(n.instanceId))throw o("Matrix axis level ids must be unique.",`${i}.instanceId`);a.set(n.instanceId,n);const c=n.field.role==="date"||n.field.dataType==="date"||n.field.dataType==="datetime",u=n.field.dataType==="string"||n.field.dataType==="number"||n.field.dataType==="boolean";if(c&&!n.grain)throw o("Temporal Matrix axis level is missing its explicit grain.",`${i}.grain`);if(u&&n.grain)throw o("Non-temporal Matrix axis level cannot carry a grain.",`${i}.grain`);if(n.grain){if(!n.temporalBucket)throw o("Temporal Matrix axis level is missing governed bucket metadata.",`${i}.temporalBucket`);const m=T.validateTemporalBucketMetadata(n.temporalBucket);if(!m.ok||((r=m.value)==null?void 0:r.granularity)!==n.grain)throw o("Matrix axis grain and temporal metadata must agree.",`${i}.temporalBucket`)}else if(n.temporalBucket)throw o("Non-temporal Matrix axis levels cannot carry temporal bucket metadata.",i)}return a}function b(e,t){var s;const a=t==="row"?e.axes.rows:e.axes.columns,r=new Set;for(const[n,i]of a.nodeIds.entries()){if(r.has(i))throw o("Matrix axis node ids must be unique.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${n}`);if(r.add(i),((s=e.nodesById[i])==null?void 0:s.axis)!==t)throw o("Matrix axis node id references the wrong axis.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${n}`)}}function G(e,t,a){if(e.isGrandTotal){if(e.isSubtotal)throw o("Matrix nodes cannot be both subtotal and grand total.",a);if(e.path.length!==0)throw o("Matrix grand-total nodes must have an empty member path.",`${a}.path`);return}if(!e.path.length||e.level!==e.path.length-1)throw o("Ordinary and subtotal Matrix nodes require a level-aligned non-empty path.",a);const r=[...t.values()];if(e.path.length>r.length)throw o("Matrix node path exceeds its authored axis depth.",`${a}.path`);if(e.isSubtotal&&e.path.length>=r.length)throw o("Matrix subtotal nodes must identify a proper authored-axis prefix.",`${a}.path`);e.path.forEach((c,u)=>{const m=r[u];if(c.instanceId==="__matrix_remaining__"&&c.fieldKey==="__matrix_remaining__"&&c.value==="__matrix_remaining__"){if(u!==e.path.length-1)throw o("Matrix remaining-member identity must be the terminal path segment.",`${a}.path.${u}`);if(typeof c.label!="string")throw o("Matrix remaining-member paths require their explicit display label.",`${a}.path.${u}.label`);return}if(!m||c.instanceId!==m.instanceId||c.fieldKey!==m.fieldKey)throw o("Matrix member path must follow authored axis order and identity.",`${a}.path.${u}`);M(c,m,`${a}.path.${u}`)});const s=e.path[e.path.length-1],n=s.instanceId==="__matrix_remaining__"&&s.fieldKey==="__matrix_remaining__"&&s.value==="__matrix_remaining__";if(!w(e.value,s.value))throw o("Matrix node value must equal its final canonical path member.",`${a}.value`);const i=r[e.path.length-1];if(i!=null&&i.temporalBucket&&!e.isSubtotal&&!n&&e.label!==void 0)throw o("Temporal Matrix nodes cannot transport display labels.",`${a}.label`);if((!(i!=null&&i.temporalBucket)||n)&&typeof e.label!="string")throw o("Non-temporal Matrix nodes require a display label.",`${a}.label`)}function H(e,t){return e.isGrandTotal&&(t!=null&&t.isGrandTotal)?"matrixGrandTotal":e.isGrandTotal?"rowGrandTotal":t!=null&&t.isGrandTotal?"columnGrandTotal":e.isSubtotal&&(t!=null&&t.isSubtotal)?"subtotalIntersection":e.isSubtotal?"rowSubtotal":t!=null&&t.isSubtotal?"columnSubtotal":"value"}function M(e,t,a){if(t.temporalBucket){if(e.label!==void 0)throw o("Temporal Matrix path members cannot transport display labels.",`${a}.label`);if(e.value!==null&&typeof e.value!="string")throw o("Temporal Matrix member values must be canonical strings or null.",`${a}.value`);const r=C.parseTemporalBucketValue(e.value,t.temporalBucket);if(!r.ok)throw o(r.error.message,`${a}.value`)}else if(typeof e.label!="string")throw o("Non-temporal Matrix path members require a display label.",`${a}.label`)}function j(e,t){const a=[...t.row.values()];if(e.layout.rowHeaderLevels.length!==a.length)throw o("Matrix row-header layout must describe every row-axis level exactly once.","layout.rowHeaderLevels");e.layout.rowHeaderLevels.forEach((s,n)=>{var i;if(s.fieldInstanceId!==((i=a[n])==null?void 0:i.instanceId))throw o("Matrix row-header layout must follow authored row-axis order.",`layout.rowHeaderLevels.${n}.fieldInstanceId`)});for(const[s,n]of e.layout.columnHeaderRows.entries())for(const[i,c]of n.cells.entries()){if(g(c.columnPath,t.column,`layout.columnHeaderRows.${s}.cells.${i}.columnPath`),c.measureInstanceId&&!e.measuresById[c.measureInstanceId])throw o("Matrix header measureInstanceId must reference a measure.",`layout.columnHeaderRows.${s}.cells.${i}.measureInstanceId`);if(c.role==="columnHeader"&&c.label!==void 0)throw o("Matrix member headers cannot transport composed display labels.",`layout.columnHeaderRows.${s}.cells.${i}.label`)}const r=new Set;for(const[s,n]of e.layout.columns.entries()){if(r.has(n.id))throw o("Matrix layout column ids must be unique.",`layout.columns.${s}.id`);if(r.add(n.id),g(n.columnPath,t.column,`layout.columns.${s}.columnPath`),n.role==="value"&&n.columnPath.length>0&&n.label!==void 0)throw o("Matrix value columns with member paths cannot transport composed display labels.",`layout.columns.${s}.label`);if(!e.measuresById[n.measureInstanceId])throw o("Matrix layout column measureInstanceId must reference a measure.",`layout.columns.${s}.measureInstanceId`);if(n.columnNodeId){const i=e.nodesById[n.columnNodeId];if((i==null?void 0:i.axis)!=="column"||!w(i.path,n.columnPath))throw o("Matrix layout column must match its referenced column node path.",`layout.columns.${s}.columnNodeId`)}else if(t.column.size>0)throw o("Matrix columns with an authored column axis require a columnNodeId.",`layout.columns.${s}.columnNodeId`)}}function g(e,t,a){const r=[...t.values()];if(e.length>r.length)throw o("Matrix layout path exceeds its authored axis depth.",a);e.forEach((s,n)=>{const i=r[n];if(!i||s.instanceId!==i.instanceId||s.fieldKey!==i.fieldKey)throw o("Matrix layout path must follow authored axis order and identity.",`${a}.${n}`);M(s,i,`${a}.${n}`)})}function E(e,t,a){if(!t.parentId)return;const r=e.nodesById[t.parentId];if(!r)throw o("Matrix parentId must reference an existing node.",`${a}.parentId`);if(r.axis!==t.axis||r.path.length!==t.path.length-1||!w(r.path,t.path.slice(0,-1)))throw o("Matrix parentId must reference the immediate same-axis path prefix.",`${a}.parentId`)}function P(e){for(const[t,a]of[["rows",e.axes.rows],["columns",e.axes.columns]]){const r=t==="rows"?"row":"column";a.levels.forEach((s,n)=>{const i=e.fieldsById[s.instanceId];if(!i||i.instanceId!==s.instanceId||i.fieldKey!==s.fieldKey||i.role!==r||!v(i.field,s.field))throw o("Matrix axis level must have one matching role-scoped field descriptor.",`axes.${t}.levels.${n}`)})}for(const[t,a]of Object.entries(e.measuresById)){if(a.instanceId!==t)throw o("Matrix measure directory key must equal measure.instanceId.",`measuresById.${t}.instanceId`);const r=e.fieldsById[t];if(!r||r.instanceId!==t||r.fieldKey!==a.fieldKey||r.role!=="measure"||!v(r.field,a.field))throw o("Matrix measure must have one matching field descriptor.",`measuresById.${t}`)}}function V(e){return e&&typeof e=="object"?e.schemaVersion:void 0}function w(e,t){return JSON.stringify(e)===JSON.stringify(t)}function v(e,t){return h(e)===h(t)}function h(e){if(Array.isArray(e))return`[${e.map(h).join(",")}]`;if(e&&typeof e=="object"){const t=e;return`{${Object.keys(t).filter(a=>t[a]!==void 0).sort().map(a=>`${JSON.stringify(a)}:${h(t[a])}`).join(",")}}`}return e===void 0?"undefined":JSON.stringify(e)}function o(e,t){return new x({code:"invalid_matrix_result_contract",message:e,path:t})}exports.MatrixResultContractError=x;exports.getCardControlCompatInputId=K;exports.getCardInlineFilterCompatInputId=q;exports.getDashboardControlCompatInputId=R;exports.getDashboardFilterCompatInputId=k;exports.parseCanonicalMatrixResult=O;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-
|
|
1
|
+
"use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-DmcF1ris.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./temporal-bucket-DHY1y9lq.cjs");function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function X(e){return c.constructFrom(e,Date.now())}function H(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function Y(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function q(e,t){return+c.toDate(e)-+c.toDate(t)}function W(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function J(e){const t=c.toDate(e);return+W(t)==+K(t)}function Q(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(H(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;J(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function z(e,t,n){const o=q(e,t)/1e3;return Y(n==null?void 0:n.roundingMethod)(o)}function ee(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=z(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=Q(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function C(e,t){return ee(e,X(e),t)}const I=["day","hour","minute","second","millisecond"],L={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},te={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},ne={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function re(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function V(e,t){return re(e)?e:t}function S(e,t){return I.indexOf(V(e,t))}function oe(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return I.slice(r,a+1)}function ae(e,t){return e*L[V(t,"second")]}function se(e,t){const n=oe(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=L[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=L[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function ie(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${te[a.unit]}`).join(" ")}function le(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=ne[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ce(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function ue(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(ae(n,o)),s=se(i,t),l=r==="digital"?ce(s):r==="long"?le(s,t.maxUnits):ie(s,t.maxUnits);return ue(l,a,t)}function fe(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function p(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:fe(e,t,n)}}function v(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function N(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function me(e,t){const n={mode:t.displayMode,current:p(e.currentValue,t.metricFormat,t.locale),comparison:p(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=p(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=v(e.percentChange,N(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=v(e.ratio,N(t.precision,2),t.locale,"ratio")),n}function ge(e,t){return e&&e!=="auto"?e:t}function de(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function he(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const Me="MM/dd/yyyy",ye=(e,t,n,o="auto")=>{if(!e)return"";try{const r=T(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:Me).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},De=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:C(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function R(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
|
|
2
2
|
`)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function $(e,t=","){return e.map(n=>R(n,t)).join(t)}function _(e,t={}){const{delimiter:n=",",lineEnding:o=`
|
|
3
3
|
`}=t;return e.map(r=>$(r,n)).join(o)}function be(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:o=`
|
|
4
4
|
`,includeHeaders:r=!0,columns:a}=t,i=a||Object.keys(e[0]),s=[];r&&s.push(i);for(const l of e){const u=i.map(g=>{const m=l[g];return m==null?"":String(m)});s.push(u)}return _(s,{delimiter:n,lineEnding:o})}const F="__TOTAL__";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e){return e===F}function we(e){const t=new Map,n=(e.groupByColumns??[]).map((r,a)=>{var u,g,m;if(!D(r))throw new Error(`Aggregate groupByColumns[${a}] is invalid`);const i=typeof r.id=="string"&&r.id.length>0?r.id:void 0,s=i?(m=(g=(u=e.columnKeyMap)==null?void 0:u.byRole)==null?void 0:g.groupby)==null?void 0:m[i]:void 0,l=(s==null?void 0:s.outputKey)||(s==null?void 0:s.rawKey)||(typeof r.alias=="string"&&r.alias.length>0?r.alias:typeof r.name=="string"&&r.name.length>0?r.name:void 0);if(!l)throw new Error(`Aggregate groupByColumns[${a}] has no output key`);return[i,r.alias,r.name,l].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,l)}),l}),o=(e.rowAggregates??[]).flatMap(r=>!D(r)||typeof r.function!="string"||typeof r.groupLevel!="string"?[]:[{function:r.function,groupLevel:r.groupLevel==="ALL"?"ALL":t.get(r.groupLevel)||r.groupLevel,...typeof r.label=="string"?{label:r.label}:{}}]);return{groupColumnKeys:n,rowAggregates:o}}function P(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function U(e){var n;if(e.customLabel)return e.customLabel;const t=P(e.aggregateFunction);if(e.levelValue!==void 0&&!b(e.levelValue)){if(e.levelValue===null){const r=(n=e.formatValue)==null?void 0:n.call(e,null);return r?`Subtotal ${r}`:`Subtotal ${t}`}const o=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(o)return`Subtotal (${o})`}return`Subtotal ${t}`}function O(e,t){return t||`Grand ${P(e)}`}function x(e){var o,r;const t=e.context.groupColumnKeys,n=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const a=(o=e.context.rowAggregates.find(i=>i.groupLevel==="ALL"))==null?void 0:o.label;return{kind:"grand-total",cells:t.map((i,s)=>({columnKey:i,text:s===0?O(n,a):"",placement:s===0?"label":"empty",colSpan:s===0?t.length:1}))}}if(e.row.isSubtotal===!0){if(typeof e.row.subtotalLevel!="string")throw new Error("Aggregate subtotal row is missing subtotalLevel");const a=t.indexOf(e.row.subtotalLevel);if(a<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const i=D(e.row.subtotalContext)?e.row.subtotalContext:void 0,s=D(i==null?void 0:i.groupByValues)?i.groupByValues:{},l=(r=e.context.rowAggregates.find(u=>u.groupLevel===e.row.subtotalLevel&&u.function===n))==null?void 0:r.label;return{kind:"subtotal",cells:t.map((u,g)=>{if(g>a)return{columnKey:u,text:"",placement:"empty",colSpan:1};if(g<a){const m=e.row[u];return{columnKey:u,text:m===void 0||b(m)?"":e.formatValue(m,u),placement:"value",colSpan:1}}return{columnKey:u,text:U({aggregateFunction:n,customLabel:l,levelValue:s[u],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,u):String(e.formatValue(m,u)??"")}),placement:"label",colSpan:t.length-a}})}}return{kind:"data",cells:t.map(a=>{const i=e.row[a];return{columnKey:a,text:i===void 0||b(i)?"":e.formatValue(i,a),placement:"value",colSpan:1}})}}function pe(e){const t=x(e).cells.find(n=>n.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Le(e){return x(e).cells.map(t=>t.text)}class Z extends Error{constructor(n,o){super(`${n}: ${o}`);A(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError"}}function Te(e){var r;const t=e.mode??"formatted",n=e.members.map(a=>{var s;if(t==="canonical"||!a.temporalBucket)return a.value===null?"":String(a.value);const i=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,a.fieldId);if(!i)throw new Z("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${a.fieldId}"`);return j.formatTemporalBucket({value:a.value,metadata:a.temporalBucket,format:i})}),o=((r=e.metricLabel)==null?void 0:r.trim())||void 0;return{memberLabels:n,...o?{metricLabel:o}:{},flattenedLabel:[...n,...o?[o]:[]].join(" / ")}}exports.AGGREGATE_TOTAL_MEMBER_MARKER=F;exports.PivotHeaderPresentationError=Z;exports.arrayToCSV=_;exports.arrayToCSVRow=$;exports.escapeCSVValue=R;exports.formatAggregateGrandTotalLabel=O;exports.formatAggregateGroupCell=pe;exports.formatAggregateGroupRow=Le;exports.formatAggregateSubtotalLabel=U;exports.formatDate=ye;exports.formatDistanceToNow=C;exports.formatDuration=E;exports.formatMetricComparison=me;exports.formatRelativeTime=De;exports.getTimezoneAbbreviation=de;exports.getTimezoneName=he;exports.isAggregateTotalMemberMarker=b;exports.objectsToCSV=be;exports.parseWithSourceTimezone=T;exports.presentAggregateGroupRow=x;exports.presentPivotHeader=Te;exports.resolveAggregateTablePresentationContext=we;exports.resolveTimezone=ge;
|
package/dist/chunks/{pivot-header-presentation-nk604qc1.js → pivot-header-presentation-ckYOQ4aZ.js}
RENAMED
|
@@ -2,9 +2,9 @@ var U = Object.defineProperty;
|
|
|
2
2
|
var E = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var A = (e, t, n) => E(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { t as f, c as P, g as R, e as O, a as T, m as S, b as M, i as Z, f as k, d as B } from "./format-types-CFHQoIuk.js";
|
|
5
|
-
import { b as y } from "./pivot-result-lifecycle-
|
|
5
|
+
import { b as y } from "./pivot-result-lifecycle-sjzIOpvp.js";
|
|
6
6
|
import { f as j } from "./index-CACdoqu3.js";
|
|
7
|
-
import { f as X } from "./temporal-bucket-
|
|
7
|
+
import { f as X } from "./temporal-bucket-5UYEotyQ.js";
|
|
8
8
|
function b(e, t) {
|
|
9
9
|
const n = f(e), o = f(t), r = n.getTime() - o.getTime();
|
|
10
10
|
return r < 0 ? -1 : r > 0 ? 1 : r;
|
package/dist/chunks/{pivot-result-identity-CRUokNgm.cjs → pivot-result-identity-Bb4EixVN.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-
|
|
1
|
+
"use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-D2-93DGr.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var c = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var u = (t, e, r) => c(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { v as d } from "./temporal-bucket-contract-
|
|
4
|
+
import { v as d } from "./temporal-bucket-contract-D5d-xEl3.js";
|
|
5
5
|
function f(t) {
|
|
6
6
|
return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
|
|
7
7
|
}
|