react-semaphor 0.1.495 → 0.1.496
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 +233 -218
- 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 +5 -5
- package/dist/chunks/calculated-field-identity-Cq9GwHfE.js +1266 -0
- package/dist/chunks/calculated-field-identity-DTfyvvLC.cjs +1 -0
- package/dist/chunks/{constants-BjGBVFbu.js → constants-CC3WKmqC.js} +14 -14
- package/dist/chunks/{constants-C-GvudXp.cjs → constants-DIuhVR6J.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-tYTkfNPj.js → dashboard-briefing-launcher-Bbz4cwHb.js} +9 -9
- package/dist/chunks/{dashboard-briefing-launcher-DyYVbfXp.cjs → dashboard-briefing-launcher-CM6LTGw5.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-Hwo4ZnW4.cjs → dashboard-controls-B2nrczJl.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BR7hSzDh.js → dashboard-controls-BsgADy-S.js} +11 -11
- package/dist/chunks/{dashboard-date-comparison-definition-CpCZAGIz.js → dashboard-date-comparison-definition-Bqti6YAo.js} +1 -1
- package/dist/chunks/{dashboard-date-comparison-definition-1NBx_7QQ.cjs → dashboard-date-comparison-definition-C69F-zaC.cjs} +1 -1
- package/dist/chunks/{dashboard-json-FDNan6Lc.js → dashboard-json-CA-BChbt.js} +7 -7
- package/dist/chunks/{dashboard-json-B3CuJo_G.cjs → dashboard-json-CwRRBSSL.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-aqW4Jtrr.cjs → edit-dashboard-visual-BlS27LDw.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DTJwFkdX.js → edit-dashboard-visual-CEiPgdkX.js} +15 -15
- package/dist/chunks/{editor-action-buttons-DSGiwWur.js → editor-action-buttons-6HBjjcfK.js} +6 -6
- package/dist/chunks/{editor-action-buttons-B3Dpnink.cjs → editor-action-buttons-kk2BNiTe.cjs} +1 -1
- package/dist/chunks/{field-aggregations-Cy4hBBqe.js → field-aggregations-C8kZqMTD.js} +11 -11
- package/dist/chunks/{field-aggregations-U54X9_Rt.cjs → field-aggregations-naKZ7S2Q.cjs} +1 -1
- package/dist/chunks/{index-a9nBmD-v.cjs → index-BSRwdFTN.cjs} +222 -222
- package/dist/chunks/{index-B9FLuTyx.cjs → index-CCa-A-Yx.cjs} +1 -1
- package/dist/chunks/{index-Ne0-ePdz.js → index-Cgoz65yM.js} +39098 -38334
- package/dist/chunks/{index-zKj-mqbS.js → index-oll4m-qi.js} +11 -11
- package/dist/chunks/{matrix-analytical-definition-DSRmzber.js → matrix-analytical-definition-B1xhoCak.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-B5oWAePu.cjs → matrix-analytical-definition-BK5y9XHH.cjs} +1 -1
- package/dist/chunks/{matrix-card-CxTCV9HF.js → matrix-card-BEb6hr8i.js} +2 -2
- package/dist/chunks/{matrix-card-BV7OPtq_.cjs → matrix-card-Ii8yYSnw.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-BLGlb4S9.cjs → matrix-control-sources-CdegRBcA.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-DYMzccBY.js → matrix-control-sources-cbYmqWNg.js} +5 -5
- package/dist/chunks/{matrix-definition-jy7ygO6J.cjs → matrix-definition-CSNthxru.cjs} +1 -1
- package/dist/chunks/{matrix-definition-Djesv_9v.js → matrix-definition-CZM5-YJX.js} +1 -1
- package/dist/chunks/{matrix-formatter-CuRTrMP2.cjs → matrix-formatter-C19PZAal.cjs} +1 -1
- package/dist/chunks/{matrix-formatter-BhkdDosE.js → matrix-formatter-CiXzpX6X.js} +27 -27
- package/dist/chunks/matrix-member-presentation-CQHvq18l.cjs +1 -0
- package/dist/chunks/matrix-member-presentation-CabW8mJc.js +105 -0
- package/dist/chunks/{matrix-operation-contract-4q53iAUW.js → matrix-operation-contract-0Nor-C71.js} +21 -21
- package/dist/chunks/{matrix-operation-contract-CbavkrJj.cjs → matrix-operation-contract-o9GXbiHw.cjs} +1 -1
- package/dist/chunks/{metric-comparison-CPx_2iqI.js → metric-comparison-Br8l0WkK.js} +1 -1
- package/dist/chunks/{metric-comparison-l2X7Reol.cjs → metric-comparison-DeiOjEm5.cjs} +1 -1
- package/dist/chunks/{operators-C8TxpM4C.js → operators-B3zZoskU.js} +28 -10
- package/dist/chunks/operators-DEfKaU_V.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-BDMb1Wlc.cjs → pivot-header-presentation-DRv-cSIP.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-utM9JrgD.js → pivot-header-presentation-DW-ti5ek.js} +3 -3
- package/dist/chunks/{pivot-result-identity-Hm1sO9KE.cjs → pivot-result-identity-DEenUrMj.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-BDntll93.js → pivot-result-identity-sZc1RaIz.js} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-QiOUMsYd.cjs → pivot-result-lifecycle-D81qcCcZ.cjs} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-Cu9hRFAp.js → pivot-result-lifecycle-DJ40gdwk.js} +7 -7
- package/dist/chunks/{raw-temporal-DWuF9bt7.cjs → raw-temporal-DDTt2yv5.cjs} +1 -1
- package/dist/chunks/{raw-temporal-CknUT-Fp.js → raw-temporal-DHCZrFe7.js} +15 -15
- package/dist/chunks/{raw-temporal-contract-B3YGcvzw.cjs → raw-temporal-contract-BcbV56Rc.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-BVcDonCB.js → raw-temporal-contract-CkvdtPYA.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-DsjMwa3m.js → report-preferences-dialog-CVRJOCQu.js} +6 -6
- package/dist/chunks/{report-preferences-dialog-BP_EdVHP.cjs → report-preferences-dialog-DGEq-iBF.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-DTxVBKqP.js → report-runtime-context-BlDpc-F-.js} +1 -1
- package/dist/chunks/{report-runtime-context-C-As8sq_.cjs → report-runtime-context-lSIvyKm2.cjs} +1 -1
- package/dist/chunks/{semantic-format-CyJWf8gZ.cjs → semantic-format--_VEin18.cjs} +1 -1
- package/dist/chunks/{semantic-format-BTEhH9ga.js → semantic-format-ew5zviaT.js} +2 -2
- package/dist/chunks/{source-entity-resolution-DXjCZPuO.js → source-entity-resolution-79Rihbk3.js} +121 -107
- package/dist/chunks/source-entity-resolution-DPjslVgx.cjs +1 -0
- package/dist/chunks/{switch-BmCGBb2F.js → switch-BmyuyM7e.js} +4736 -4697
- package/dist/chunks/switch-nDjQC2y3.cjs +139 -0
- package/dist/chunks/{temporal-bucket-contract-pW4c6N2M.cjs → temporal-bucket-contract-BYR6tj6F.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-Bhsl_j4B.js → temporal-bucket-contract-C-kKQ_W4.js} +1 -1
- package/dist/chunks/{token-types-DpYncMPp.js → token-types-BIYFAsGq.js} +1 -1
- package/dist/chunks/{token-types-CsKRtJp0.cjs → token-types-CkAGFhiW.cjs} +1 -1
- package/dist/chunks/{update-policy-CtLb9ish.cjs → update-policy-BCtFr2Qh.cjs} +1 -1
- package/dist/chunks/{update-policy-BoB26XrS.js → update-policy-CP_A1IVD.js} +2 -2
- package/dist/chunks/{validators-DgmJaRF4.js → validators-D-_IT-Xw.js} +1132 -1013
- package/dist/chunks/validators-ux2obZB9.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +157 -150
- 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 +2 -2
- package/dist/data-app-codegen-node/index.js +33 -36
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +232 -230
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +3 -3
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +5 -5
- package/dist/format-utils/index.cjs +1 -1
- package/dist/format-utils/index.js +26 -26
- 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 +2 -2
- package/dist/types/analytics-protocol.d.ts +256 -1
- package/dist/types/briefings.d.ts +46 -0
- package/dist/types/dashboard-assistant.d.ts +46 -1
- package/dist/types/dashboard-authoring.d.ts +131 -2
- package/dist/types/dashboard.d.ts +48 -0
- package/dist/types/data-app-builder.d.ts +23 -1
- package/dist/types/data-app-codegen-node.d.ts +23 -1
- package/dist/types/data-app-codegen.d.ts +23 -1
- package/dist/types/data-app-sdk-adapters.d.ts +23 -1
- package/dist/types/data-app-sdk-validation.d.ts +46 -1
- package/dist/types/data-app-sdk.d.ts +51 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +111 -1
- package/dist/types/shared.d.ts +46 -0
- package/dist/types/surfboard.d.ts +48 -0
- package/dist/types/types.d.ts +48 -0
- package/package.json +1 -1
- package/dist/chunks/calculated-field-identity-Cc-RlE-0.cjs +0 -1
- package/dist/chunks/calculated-field-identity-D7ygZ7oN.js +0 -1117
- package/dist/chunks/matrix-member-presentation-BN6VD-fr.js +0 -24
- package/dist/chunks/matrix-member-presentation-D82rMVDG.cjs +0 -1
- package/dist/chunks/operators-DrTQsJXv.cjs +0 -1
- package/dist/chunks/source-entity-resolution-BA8sdBbL.cjs +0 -1
- package/dist/chunks/switch-COujiMcB.cjs +0 -139
- package/dist/chunks/validators-CueUwVE4.cjs +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
var tt = Object.defineProperty;
|
|
2
2
|
var rt = (e, r, t) => r in e ? tt(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var F = (e, r, t) => rt(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
import { s as J, k as G, l as nt, R as ot, q as at, p as xe, b as it } from "./raw-temporal-
|
|
5
|
-
import {
|
|
4
|
+
import { s as J, k as G, l as nt, R as ot, q as at, p as xe, b as it } from "./raw-temporal-DHCZrFe7.js";
|
|
5
|
+
import { ag as $e, a0 as ct, a2 as ie, W as ke, n as lt } from "./validators-D-_IT-Xw.js";
|
|
6
6
|
import "./matrix-continuation-C4sRcjZU.js";
|
|
7
|
-
import "./matrix-operation-contract-
|
|
7
|
+
import "./matrix-operation-contract-0Nor-C71.js";
|
|
8
8
|
import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as se } from "../value-format-preferences/index.js";
|
|
9
|
-
import { j as dt, h as st, e as mt, i as ut, d as ft, M as pt, c as yt, b as ht, P as j } from "./pivot-result-lifecycle-
|
|
9
|
+
import { j as dt, h as st, e as mt, i as ut, d as ft, M as pt, c as yt, b as ht, P as j } from "./pivot-result-lifecycle-DJ40gdwk.js";
|
|
10
10
|
import { z as E } from "zod";
|
|
11
|
-
import { r as gt } from "./matrix-definition-
|
|
12
|
-
import { h as Ee, i as me, r as Se, a as _e, v as vt, b as bt } from "./constants-
|
|
13
|
-
import { r as It } from "./matrix-card-
|
|
14
|
-
import { r as V, c as wt, b as Ct, P as Tt } from "./pivot-result-identity-
|
|
15
|
-
import { v as xt, a as $t } from "./temporal-bucket-contract-
|
|
11
|
+
import { r as gt } from "./matrix-definition-CZM5-YJX.js";
|
|
12
|
+
import { h as Ee, i as me, r as Se, a as _e, v as vt, b as bt } from "./constants-CC3WKmqC.js";
|
|
13
|
+
import { r as It } from "./matrix-card-BEb6hr8i.js";
|
|
14
|
+
import { r as V, c as wt, b as Ct, P as Tt } from "./pivot-result-identity-sZc1RaIz.js";
|
|
15
|
+
import { v as xt, a as $t } from "./temporal-bucket-contract-C-kKQ_W4.js";
|
|
16
16
|
import { f as kt, b as Et, d as Fe, D as St } from "./temporal-bucket-B9hMwemw.js";
|
|
17
|
-
import { r as Re, s as _t, i as Ft } from "./field-aggregations-
|
|
18
|
-
import { v as Ae } from "./raw-temporal-contract-
|
|
17
|
+
import { r as Re, s as _t, i as Ft } from "./field-aggregations-C8kZqMTD.js";
|
|
18
|
+
import { v as Ae } from "./raw-temporal-contract-CkvdtPYA.js";
|
|
19
19
|
import { r as Rt, a as At, b as Pt } from "./canonical-result-keys-CEQefvdO.js";
|
|
20
20
|
const Mt = `import pandas as pd
|
|
21
21
|
df = pd.DataFrame(data) # 'data' contains the query result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./validators-
|
|
1
|
+
"use strict";const u=require("./validators-ux2obZB9.cjs");function m(t){const{label:i,...n}=t;return{dataset:u.semaphorSourceIdentityKey(n),...t.kind==="physical"?{dialect:t.dialect,connectionType:t.connectionType}:{}}}function y(t){const{label:i,source:n,...e}=t;return{...e,source:n&&m(n)}}function s(t){const{label:i,format:n,description:e,tags:a,inputs:r,...l}=t;return{...l,inputs:Object.fromEntries(Object.entries(r).map(([c,f])=>[c,{...f,field:y(f.field)}]))}}function d(t){const{derivedField:i,...n}=t;return{...y(n),derivedField:i&&s(i)}}function o(t){const{label:i,format:n,description:e,semanticTemporalPresentation:a,derivedField:r,calculatedFormula:l,...c}=t;return{...c,semanticTemporalPresentation:a&&{granularity:a.granularity},derivedField:r&&s(r),calculatedFormula:l&&{...l,inputFields:l.inputFields.map(o)}}}function p(t){return{...t,conditions:t.conditions.map(({label:i,field:n,...e})=>({...e,field:o(n)})),groups:t.groups.map(p)}}function b(t){return{...t,source:m(t.source),rows:t.rows.map(i=>({...i,field:d(i.field)})),columns:t.columns.map(i=>({...i,field:d(i.field)})),measures:t.measures.map(i=>i.kind==="aggregate"?{...i,field:d(i.field)}:{...i,definition:s(i.definition)}),filters:t.filters&&p(t.filters),joinPlan:t.joinPlan&&{...t.joinPlan,joins:t.joinPlan.joins.map(i=>({...i,joinKeyGroups:i.joinKeyGroups.map(n=>({...n,keys:n.keys.map(e=>({...e,source:o(e.source),target:o(e.target)}))}))}))},sorts:[...t.sorts].sort((i,n)=>{const e=u.matrixSortKey(i),a=u.matrixSortKey(n);return e<a?-1:e>a?1:0})}}exports.getMatrixAnalyticalCalculation=s;exports.getMatrixAnalyticalDefinition=b;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./matrix-operation-contract-
|
|
1
|
+
import { l as a, n as s, o as f } from "./validators-D-_IT-Xw.js";
|
|
2
|
+
import "./matrix-operation-contract-0Nor-C71.js";
|
|
3
3
|
function u(i, r = {}) {
|
|
4
4
|
var n, o;
|
|
5
5
|
if (i.type !== "matrixTable" || !i.config || typeof i.config != "object" || !("matrix" in i.config)) return { status: "absent" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./validators-
|
|
1
|
+
"use strict";const o=require("./validators-ux2obZB9.cjs");require("./matrix-operation-contract-o9GXbiHw.cjs");function s(i,r={}){var n,a;if(i.type!=="matrixTable"||!i.config||typeof i.config!="object"||!("matrix"in i.config))return{status:"absent"};if((n=i.sql)!=null&&n.trim()||(a=i.python)!=null&&a.trim())return{status:"invalid",error:new Error("A Matrix definition requires a config-only Matrix card.")};if("matrixIntent"in i.config&&i.config.matrixIntent!==void 0)return{status:"invalid",error:new Error("A Matrix card cannot contain two definitions.")};const t=(r.authoringDraft?o.matrixAuthoringConfigSchema:o.matrixConfigSchema).safeParse(i.config.matrix);return t.success?{status:"ready",config:t.data}:{status:"invalid",error:t.error}}function u(i){const r=s(i);if(r.status==="invalid")throw r.error;return r.status==="ready"?r.config:void 0}function f(i){const r=[],e=t=>{r.push(t),t.derivedField&&Object.values(t.derivedField.inputs).forEach(n=>e(n.field))};return[...i.rows,...i.columns].forEach(t=>e(t.field)),i.measures.forEach(t=>{t.kind==="aggregate"?e(t.field):Object.values(t.definition.inputs).forEach(n=>e(n.field))}),r}function c(i){return o.mergeSemaphorSourcesByIdentity([i.source,...f(i).map(r=>r.source??i.source)])}exports.inspectMatrixCardConfig=s;exports.matrixDefinitionFields=f;exports.matrixDefinitionSources=c;exports.readMatrixCardConfig=u;
|
package/dist/chunks/{matrix-control-sources-BLGlb4S9.cjs → matrix-control-sources-CdegRBcA.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ce=Object.defineProperty;var le=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>le(t,typeof e!="symbol"?e+"":e,n);const S=require("./common-types-nBuCd3u2.cjs"),R=require("./validators-CueUwVE4.cjs");require("./matrix-operation-contract-CbavkrJj.cjs");const Y=require("./calculated-field-identity-Cc-RlE-0.cjs"),de=require("./field-aggregations-U54X9_Rt.cjs"),ue=require("zod"),Z=require("./matrix-card-BV7OPtq_.cjs"),V=require("./constants-B00YUv89.cjs");function X(t,e){const r=Ie(t);let i;if(r.date){const d=Oe(r.date,2);i=Ne(d.restDateString,d.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const s=i.getTime();let f=0,_;if(r.time&&(f=Re(r.time),isNaN(f)))return new Date(NaN);if(r.timezone){if(_=De(r.timezone),isNaN(_))return new Date(NaN)}else{const d=new Date(s+f),m=new Date(0);return m.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),m.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),m}return new Date(s+f+_)}const w={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ge=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,fe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,_e=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ie(t){const e={},n=t.split(w.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],w.timeZoneDelimiter.test(e.date)&&(e.date=t.split(w.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const i=w.timezone.exec(r);i?(e.time=r.replace(i[1],""),e.timezone=i[1]):e.time=r}return e}function Oe(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?i:s*100,restDateString:t.slice((r[1]||r[2]).length)}}function Ne(t,e){if(e===null)return new Date(NaN);const n=t.match(ge);if(!n)return new Date(NaN);const r=!!n[4],i=L(n[1]),s=L(n[2])-1,f=L(n[3]),_=L(n[4]),d=L(n[5])-1;if(r)return pe(e,_,d)?me(e,_,d):new Date(NaN);{const m=new Date(0);return!Te(e,s,f)||!Ce(e,i)?new Date(NaN):(m.setUTCFullYear(e,s,Math.max(i,f)),m)}}function L(t){return t?parseInt(t):1}function Re(t){const e=t.match(fe);if(!e)return NaN;const n=v(e[1]),r=v(e[2]),i=v(e[3]);return he(n,r,i)?n*V.millisecondsInHour+r*V.millisecondsInMinute+i*1e3:NaN}function v(t){return t&&parseFloat(t.replace(",","."))||0}function De(t){if(t==="Z")return 0;const e=t.match(_e);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),i=e[3]&&parseInt(e[3])||0;return Ae(r,i)?n*(r*V.millisecondsInHour+i*V.millisecondsInMinute):NaN}function me(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const i=r.getUTCDay()||7,s=(e-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+s),r}const Ee=[31,null,31,30,31,30,31,31,30,31,30,31];function W(t){return t%400===0||t%4===0&&t%100!==0}function Te(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(Ee[e]||(W(t)?29:28))}function Ce(t,e){return e>=1&&e<=(W(t)?366:365)}function pe(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function he(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function Ae(t,e){return e>=0&&e<=59}const ye=["lg","md","sm","xs","xxs"],Le=15;function we(t,e){return`${t}-${e}`}const Se="CONTROL_PLACEHOLDER_QUOTED",Q="CONTROL_REFERENCE_MISSING",K="CONTROL_VALUE_MISSING",Ve="CONTROL_VALUE_INVALID",xe="CONTROL_CONTEXT_UNSUPPORTED",J="CONTROL_DEFINITION_DUPLICATE",ee="CONTROL_DEFINITION_INVALID",x="CONTROL_BINDING_MAPPING_MISSING",te="CONTROL_BINDING_TARGET_INVALID",U="CONTROL_BINDING_VALUE_INVALID";class I extends Error{constructor(n,r){super(n);M(this,"status",400);M(this,"details");Object.setPrototypeOf(this,I.prototype),this.name="ControlResolutionError",this.details=r}}function G(t,e){const n=new Map;for(const r of[...t,...e]){if(!r||typeof r!="object"||typeof r.id!="string"||r.id.trim().length===0)throw new I("Malformed control definition was provided for query execution.",{code:ee});if(n.get(r.id))throw new I(`Duplicate control definition '${r.id}' was provided for query execution.`,{code:J,controlId:r.id});n.set(r.id,r)}return n}const be=/^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;function Me(t){switch(t.source.kind){case"manual":return t.source.options.map(e=>e.value);case"field_allowlist":return t.source.fieldIds;case"metric_allowlist":return t.source.metricIds;case"dataset_values":return null;default:return null}}function E(t){return`${t.label||t.id} (${t.id})`}function ve(t){return t.type==="field_selector"||t.type==="metric_selector"||t.type==="aggregation_selector"||t.type==="grain_selector"}function j(t,e){const n=Me(t);if(!(!n||n.length===0)&&!n.includes(e))throw new Error(`Control ${E(t)} received unsupported value '${e}'.`)}function re(t,e){switch(t.type){case"enum":case"field_selector":case"metric_selector":case"aggregation_selector":case"grain_selector":{if(typeof e!="string"||e.trim().length===0)throw new Error(`Control ${E(t)} requires a non-empty string value.`);return ve(t)&&e===S.CONTROL_CARD_DEFAULT_VALUE||j(t,e),e}case"multi_enum":{if(!Array.isArray(e))throw new Error(`Control ${E(t)} requires a non-empty array value.`);if(e.length===0){if(!t.requiredAtExecution)return;throw new Error(`Control ${E(t)} requires a non-empty array value.`)}for(const n of e){if(typeof n!="string"||n.trim().length===0)throw new Error(`Control ${E(t)} requires string array values.`);j(t,n)}return e}case"text":{if(typeof e!="string")throw new Error(`Control ${E(t)} requires a string value.`);return e}case"number":{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&be.test(e.trim()))return Number(e);throw new Error(`Control ${E(t)} requires a numeric value.`)}case"boolean":{if(typeof e!="boolean")throw new Error(`Control ${E(t)} requires a boolean value.`);return e}case"date":{if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e=="string"&&e.trim().length>0){const n=e.trim(),r=X(n);if(!Number.isNaN(r.getTime()))return n}throw new Error(`Control ${E(t)} requires a date-compatible value.`)}default:return e}}function $(t){var i;const e=t.definitions.get(t.binding.controlId);if(!e)throw new I(`Binding references unknown control '${t.binding.controlId}'.`,{code:Q,controlId:t.binding.controlId});if(!Object.prototype.hasOwnProperty.call(t.controlValues||{},t.binding.controlId)){if(!e.requiredAtExecution)return;throw new I(`Control '${t.binding.controlId}' must resolve to a concrete value before query execution.`,{code:K,controlId:t.binding.controlId})}let r;try{r=re(e,(i=t.controlValues)==null?void 0:i[t.binding.controlId])}catch(s){const f=s instanceof Error?s.message:String(s);throw new I(f,{code:U,controlId:t.binding.controlId})}if(typeof r=="string"&&r.trim().length>0)return r;if(typeof r=="number"||typeof r=="boolean")return String(r);if(r instanceof Date&&!Number.isNaN(r.getTime()))return r.toISOString();throw new I(`Binding control '${t.binding.controlId}' must resolve to a single scalar value.`,{code:U,controlId:t.binding.controlId})}function F(t){const e=t.binding.mapping[t.selectedValue];if(typeof e=="string"&&e.trim().length>0)return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}'.`,{code:x,controlId:t.binding.controlId})}function ne(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="groupby")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid group-by field.`,{code:x,controlId:t.binding.controlId})}function oe(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="metric")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid metric field.`,{code:x,controlId:t.binding.controlId})}const Ue=new Set(["day","week","month","quarter","year","hour","minute","second"]);function Fe(t){let e=t.spec;const n=G(t.controlDefinitions||[],t.cardControlDefinitions||[]),r=(t.controlBindings||[]).filter(o=>o.target!=="sql_param"),i=r.filter(o=>o.target==="config_metric_selector"||o.target==="config_field_selector"),s=r.filter(o=>o.target==="config_grain"||o.target==="config_aggregation"),f=new Set,_=new Map;let d;const m=()=>{if(d)return d;const o=t.catalog,c=new Map;for(const l of o){const u=c.get(l.id)??[];c.set(l.id,[...u,l])}return d={refs:o,byId:c},d},h=(o,c)=>{throw new I(o,{code:te,...c?{controlId:c}:{}})},b=(o,c)=>{var u;if(o.derivedField)return o.derivedField.dataType;const l=m().refs.filter(C=>C.field.name===o.name&&R.semaphorSourcesReferToSameDataset(C.field.source??t.spec.source,o.source??t.spec.source));return l.length>1?h("The selected field is ambiguous in the authorized Matrix field catalog.",c):R.normalizeAnalyticsCatalogDataType(((u=l[0])==null?void 0:u.field.dataType)??o.dataType)},B=(o,c)=>Y.getMatrixBindingTargets(o,c.target,l=>b(l,c.controlId)),T=R.matrixSpecSchema.safeParse(e);if(!T.success)return h(T.error.message);e=T.data;const se=[...i,...s].map(o=>{const c=$({binding:o,definitions:n,controlValues:t.controlValues}),l=!o.matrixTargetId&&c!==void 0&&c!==S.CONTROL_CARD_DEFAULT_VALUE?B(T.data,o):[];return{binding:o,selectedValue:c,targetId:o.matrixTargetId??(l.length===1?l[0].id:void 0)}});for(const{binding:o,targetId:c,selectedValue:l}of se){if(l===void 0||l===S.CONTROL_CARD_DEFAULT_VALUE)continue;const u=a=>h(a,o.controlId),C=o.target==="config_metric_selector"||o.target==="config_aggregation",ae=B(e,o);(!c||!ae.some(a=>a.id===c))&&u("Choose a valid Matrix level or measure target for this control.");const P=`${o.target}:${c}`;f.has(P)&&u("Multiple controls cannot replace the same Matrix target."),f.add(P);const q=a=>{const g=(m().byId.get(a.id)??[]).filter(N=>!a.source||R.semaphorSourcesReferToSameDataset(a.source,N.field.source??t.spec.source));if(g.length!==1)return u(g.length?"The selected field is ambiguous in the authorized Matrix field catalog.":"The selected field is not in the authorized Matrix field catalog.");const D=R.matrixFieldSchema.safeParse(g[0].field);return D.success?D.data:u(D.error.message)},A=o.target==="config_metric_selector"||o.target==="config_field_selector"?o.mapping[l]:void 0,p=A&&typeof A=="object"&&"kind"in A&&A.kind==="matrix_instance"?A.id:void 0;if(C){_.set(c,o.controlId);const a=p===void 0?void 0:T.data.measures.find(O=>O.id===p&&O.kind==="aggregate");p!==void 0&&!a&&u("The selected Matrix aggregate measure is no longer available.");const g=o.target==="config_metric_selector"&&!a?oe({binding:o,selectedValue:l}):void 0,D=((a==null?void 0:a.kind)==="aggregate"?a.aggregate:g==null?void 0:g.aggregate)??(o.target==="config_aggregation"?F({binding:o,selectedValue:l}):void 0),N=D===void 0?void 0:R.matrixAggregateSchema.safeParse(D);N&&!N.success&&u("This aggregation is not supported by Matrix."),e={...e,measures:e.measures.map(O=>O.id!==c||O.kind!=="aggregate"?O:{...O,...g?{field:q(g)}:{},...(a==null?void 0:a.kind)==="aggregate"?{field:a.field}:{},aggregate:N!=null&&N.success?N.data:O.aggregate})}}else{const a=p===void 0?void 0:[...T.data.rows,...T.data.columns].find(O=>O.id===p);p!==void 0&&!a&&u("The selected Matrix level is no longer available.");const g=o.target==="config_field_selector"&&!a?ne({binding:o,selectedValue:l}):void 0,D=o.target==="config_grain"?F({binding:o,selectedValue:l}):a?a.grain:g==null?void 0:g.granularity;D!==void 0&&!Ue.has(D)&&u("This time grain is not supported by Matrix.");const N=O=>O.map(y=>{if(y.id!==c)return y;const k=(a==null?void 0:a.field)??(g?q(g):y.field),H=b(k,o.controlId),z=D??(g&&R.isAnalyticsDateLikeDataType(H)?y.grain:void 0);return z&&!R.isAnalyticsDateLikeDataType(H)&&u("A time grain requires a temporal Matrix level."),{...y,field:k,grain:z}});e={...e,rows:N(e.rows),columns:N(e.columns)}}}for(const[o,c]of Array.from(_)){const l=e.measures.find(C=>C.id===o);if(!l||l.kind!=="aggregate")continue;const u=b(l.field,c);de.getFieldAggregationOptions(u).some(C=>C.value===l.aggregate)||h(`Aggregation '${l.aggregate}' is not eligible for this Matrix field datatype.`,c)}try{return Y.reconcileMatrixSpecStructure(T.data,e)}catch(o){if(o instanceof ue.ZodError)return h(o.message);throw o}}function ie(t,e){const n=[],r=i=>{if(i.source){const s=R.configSourceRefSchema.safeParse(i.source);if(s.success)n.push(s.data);else if(e)throw s.error}i.derivedField&&Object.values(i.derivedField.inputs).forEach(s=>r(s.field))};for(const i of t){if(i.target!=="config_field_selector"&&i.target!=="config_metric_selector")continue;const s=e==null?void 0:e.get(i),f=e?s&&s!==S.CONTROL_CARD_DEFAULT_VALUE?[i.mapping[s]]:[]:Object.values(i.mapping);for(const _ of f)_&&"role"in _&&r(_)}return n}function Ge(t,e=[],n=[]){return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(e),...n])}function $e(t,e={}){const n=e.controlBindings??[],r=G(e.controlDefinitions??[],e.cardControlDefinitions??[]),i=new Map(n.filter(s=>s.target==="config_field_selector"||s.target==="config_metric_selector").map(s=>[s,$({binding:s,definitions:r,controlValues:e.controlValues})]));return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(n,i)])}exports.CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE=x;exports.CONTROL_BINDING_TARGET_INVALID_ERROR_CODE=te;exports.CONTROL_BINDING_VALUE_INVALID_ERROR_CODE=U;exports.CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE=xe;exports.CONTROL_DEFINITION_DUPLICATE_ERROR_CODE=J;exports.CONTROL_DEFINITION_INVALID_ERROR_CODE=ee;exports.CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE=Se;exports.CONTROL_REFERENCE_MISSING_ERROR_CODE=Q;exports.CONTROL_VALUE_INVALID_ERROR_CODE=Ve;exports.CONTROL_VALUE_MISSING_ERROR_CODE=K;exports.ControlResolutionError=I;exports.DASHBOARD_AUTHORING_BREAKPOINTS=ye;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=Le;exports.buildControlDefinitionIndex=G;exports.getColumnCatalogFieldId=we;exports.matrixCatalogSources=Ge;exports.matrixExecutionSources=$e;exports.parseISO=X;exports.resolveBindingControlValue=$;exports.resolveGroupByFieldTarget=ne;exports.resolveMatrixControlBindings=Fe;exports.resolveMetricFieldTarget=oe;exports.resolveScalarMappedValue=F;exports.validateControlValue=re;
|
|
1
|
+
"use strict";var ce=Object.defineProperty;var le=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>le(t,typeof e!="symbol"?e+"":e,n);const S=require("./common-types-nBuCd3u2.cjs"),R=require("./validators-ux2obZB9.cjs");require("./matrix-operation-contract-o9GXbiHw.cjs");const Y=require("./calculated-field-identity-DTfyvvLC.cjs"),de=require("./field-aggregations-naKZ7S2Q.cjs"),ue=require("zod"),Z=require("./matrix-card-Ii8yYSnw.cjs"),V=require("./constants-B00YUv89.cjs");function X(t,e){const r=Ie(t);let i;if(r.date){const d=Oe(r.date,2);i=Ne(d.restDateString,d.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const s=i.getTime();let f=0,_;if(r.time&&(f=Re(r.time),isNaN(f)))return new Date(NaN);if(r.timezone){if(_=De(r.timezone),isNaN(_))return new Date(NaN)}else{const d=new Date(s+f),m=new Date(0);return m.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),m.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),m}return new Date(s+f+_)}const w={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ge=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,fe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,_e=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ie(t){const e={},n=t.split(w.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],w.timeZoneDelimiter.test(e.date)&&(e.date=t.split(w.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const i=w.timezone.exec(r);i?(e.time=r.replace(i[1],""),e.timezone=i[1]):e.time=r}return e}function Oe(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?i:s*100,restDateString:t.slice((r[1]||r[2]).length)}}function Ne(t,e){if(e===null)return new Date(NaN);const n=t.match(ge);if(!n)return new Date(NaN);const r=!!n[4],i=L(n[1]),s=L(n[2])-1,f=L(n[3]),_=L(n[4]),d=L(n[5])-1;if(r)return pe(e,_,d)?me(e,_,d):new Date(NaN);{const m=new Date(0);return!Te(e,s,f)||!Ce(e,i)?new Date(NaN):(m.setUTCFullYear(e,s,Math.max(i,f)),m)}}function L(t){return t?parseInt(t):1}function Re(t){const e=t.match(fe);if(!e)return NaN;const n=v(e[1]),r=v(e[2]),i=v(e[3]);return he(n,r,i)?n*V.millisecondsInHour+r*V.millisecondsInMinute+i*1e3:NaN}function v(t){return t&&parseFloat(t.replace(",","."))||0}function De(t){if(t==="Z")return 0;const e=t.match(_e);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),i=e[3]&&parseInt(e[3])||0;return Ae(r,i)?n*(r*V.millisecondsInHour+i*V.millisecondsInMinute):NaN}function me(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const i=r.getUTCDay()||7,s=(e-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+s),r}const Ee=[31,null,31,30,31,30,31,31,30,31,30,31];function W(t){return t%400===0||t%4===0&&t%100!==0}function Te(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(Ee[e]||(W(t)?29:28))}function Ce(t,e){return e>=1&&e<=(W(t)?366:365)}function pe(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function he(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function Ae(t,e){return e>=0&&e<=59}const ye=["lg","md","sm","xs","xxs"],Le=15;function we(t,e){return`${t}-${e}`}const Se="CONTROL_PLACEHOLDER_QUOTED",Q="CONTROL_REFERENCE_MISSING",K="CONTROL_VALUE_MISSING",Ve="CONTROL_VALUE_INVALID",xe="CONTROL_CONTEXT_UNSUPPORTED",J="CONTROL_DEFINITION_DUPLICATE",ee="CONTROL_DEFINITION_INVALID",x="CONTROL_BINDING_MAPPING_MISSING",te="CONTROL_BINDING_TARGET_INVALID",U="CONTROL_BINDING_VALUE_INVALID";class I extends Error{constructor(n,r){super(n);M(this,"status",400);M(this,"details");Object.setPrototypeOf(this,I.prototype),this.name="ControlResolutionError",this.details=r}}function G(t,e){const n=new Map;for(const r of[...t,...e]){if(!r||typeof r!="object"||typeof r.id!="string"||r.id.trim().length===0)throw new I("Malformed control definition was provided for query execution.",{code:ee});if(n.get(r.id))throw new I(`Duplicate control definition '${r.id}' was provided for query execution.`,{code:J,controlId:r.id});n.set(r.id,r)}return n}const be=/^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;function Me(t){switch(t.source.kind){case"manual":return t.source.options.map(e=>e.value);case"field_allowlist":return t.source.fieldIds;case"metric_allowlist":return t.source.metricIds;case"dataset_values":return null;default:return null}}function E(t){return`${t.label||t.id} (${t.id})`}function ve(t){return t.type==="field_selector"||t.type==="metric_selector"||t.type==="aggregation_selector"||t.type==="grain_selector"}function j(t,e){const n=Me(t);if(!(!n||n.length===0)&&!n.includes(e))throw new Error(`Control ${E(t)} received unsupported value '${e}'.`)}function re(t,e){switch(t.type){case"enum":case"field_selector":case"metric_selector":case"aggregation_selector":case"grain_selector":{if(typeof e!="string"||e.trim().length===0)throw new Error(`Control ${E(t)} requires a non-empty string value.`);return ve(t)&&e===S.CONTROL_CARD_DEFAULT_VALUE||j(t,e),e}case"multi_enum":{if(!Array.isArray(e))throw new Error(`Control ${E(t)} requires a non-empty array value.`);if(e.length===0){if(!t.requiredAtExecution)return;throw new Error(`Control ${E(t)} requires a non-empty array value.`)}for(const n of e){if(typeof n!="string"||n.trim().length===0)throw new Error(`Control ${E(t)} requires string array values.`);j(t,n)}return e}case"text":{if(typeof e!="string")throw new Error(`Control ${E(t)} requires a string value.`);return e}case"number":{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&be.test(e.trim()))return Number(e);throw new Error(`Control ${E(t)} requires a numeric value.`)}case"boolean":{if(typeof e!="boolean")throw new Error(`Control ${E(t)} requires a boolean value.`);return e}case"date":{if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e=="string"&&e.trim().length>0){const n=e.trim(),r=X(n);if(!Number.isNaN(r.getTime()))return n}throw new Error(`Control ${E(t)} requires a date-compatible value.`)}default:return e}}function $(t){var i;const e=t.definitions.get(t.binding.controlId);if(!e)throw new I(`Binding references unknown control '${t.binding.controlId}'.`,{code:Q,controlId:t.binding.controlId});if(!Object.prototype.hasOwnProperty.call(t.controlValues||{},t.binding.controlId)){if(!e.requiredAtExecution)return;throw new I(`Control '${t.binding.controlId}' must resolve to a concrete value before query execution.`,{code:K,controlId:t.binding.controlId})}let r;try{r=re(e,(i=t.controlValues)==null?void 0:i[t.binding.controlId])}catch(s){const f=s instanceof Error?s.message:String(s);throw new I(f,{code:U,controlId:t.binding.controlId})}if(typeof r=="string"&&r.trim().length>0)return r;if(typeof r=="number"||typeof r=="boolean")return String(r);if(r instanceof Date&&!Number.isNaN(r.getTime()))return r.toISOString();throw new I(`Binding control '${t.binding.controlId}' must resolve to a single scalar value.`,{code:U,controlId:t.binding.controlId})}function F(t){const e=t.binding.mapping[t.selectedValue];if(typeof e=="string"&&e.trim().length>0)return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}'.`,{code:x,controlId:t.binding.controlId})}function ne(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="groupby")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid group-by field.`,{code:x,controlId:t.binding.controlId})}function oe(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="metric")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid metric field.`,{code:x,controlId:t.binding.controlId})}const Ue=new Set(["day","week","month","quarter","year","hour","minute","second"]);function Fe(t){let e=t.spec;const n=G(t.controlDefinitions||[],t.cardControlDefinitions||[]),r=(t.controlBindings||[]).filter(o=>o.target!=="sql_param"),i=r.filter(o=>o.target==="config_metric_selector"||o.target==="config_field_selector"),s=r.filter(o=>o.target==="config_grain"||o.target==="config_aggregation"),f=new Set,_=new Map;let d;const m=()=>{if(d)return d;const o=t.catalog,c=new Map;for(const l of o){const u=c.get(l.id)??[];c.set(l.id,[...u,l])}return d={refs:o,byId:c},d},h=(o,c)=>{throw new I(o,{code:te,...c?{controlId:c}:{}})},b=(o,c)=>{var u;if(o.derivedField)return o.derivedField.dataType;const l=m().refs.filter(C=>C.field.name===o.name&&R.semaphorSourcesReferToSameDataset(C.field.source??t.spec.source,o.source??t.spec.source));return l.length>1?h("The selected field is ambiguous in the authorized Matrix field catalog.",c):R.normalizeAnalyticsCatalogDataType(((u=l[0])==null?void 0:u.field.dataType)??o.dataType)},B=(o,c)=>Y.getMatrixBindingTargets(o,c.target,l=>b(l,c.controlId)),T=R.matrixSpecSchema.safeParse(e);if(!T.success)return h(T.error.message);e=T.data;const se=[...i,...s].map(o=>{const c=$({binding:o,definitions:n,controlValues:t.controlValues}),l=!o.matrixTargetId&&c!==void 0&&c!==S.CONTROL_CARD_DEFAULT_VALUE?B(T.data,o):[];return{binding:o,selectedValue:c,targetId:o.matrixTargetId??(l.length===1?l[0].id:void 0)}});for(const{binding:o,targetId:c,selectedValue:l}of se){if(l===void 0||l===S.CONTROL_CARD_DEFAULT_VALUE)continue;const u=a=>h(a,o.controlId),C=o.target==="config_metric_selector"||o.target==="config_aggregation",ae=B(e,o);(!c||!ae.some(a=>a.id===c))&&u("Choose a valid Matrix level or measure target for this control.");const P=`${o.target}:${c}`;f.has(P)&&u("Multiple controls cannot replace the same Matrix target."),f.add(P);const q=a=>{const g=(m().byId.get(a.id)??[]).filter(N=>!a.source||R.semaphorSourcesReferToSameDataset(a.source,N.field.source??t.spec.source));if(g.length!==1)return u(g.length?"The selected field is ambiguous in the authorized Matrix field catalog.":"The selected field is not in the authorized Matrix field catalog.");const D=R.matrixFieldSchema.safeParse(g[0].field);return D.success?D.data:u(D.error.message)},A=o.target==="config_metric_selector"||o.target==="config_field_selector"?o.mapping[l]:void 0,p=A&&typeof A=="object"&&"kind"in A&&A.kind==="matrix_instance"?A.id:void 0;if(C){_.set(c,o.controlId);const a=p===void 0?void 0:T.data.measures.find(O=>O.id===p&&O.kind==="aggregate");p!==void 0&&!a&&u("The selected Matrix aggregate measure is no longer available.");const g=o.target==="config_metric_selector"&&!a?oe({binding:o,selectedValue:l}):void 0,D=((a==null?void 0:a.kind)==="aggregate"?a.aggregate:g==null?void 0:g.aggregate)??(o.target==="config_aggregation"?F({binding:o,selectedValue:l}):void 0),N=D===void 0?void 0:R.matrixAggregateSchema.safeParse(D);N&&!N.success&&u("This aggregation is not supported by Matrix."),e={...e,measures:e.measures.map(O=>O.id!==c||O.kind!=="aggregate"?O:{...O,...g?{field:q(g)}:{},...(a==null?void 0:a.kind)==="aggregate"?{field:a.field}:{},aggregate:N!=null&&N.success?N.data:O.aggregate})}}else{const a=p===void 0?void 0:[...T.data.rows,...T.data.columns].find(O=>O.id===p);p!==void 0&&!a&&u("The selected Matrix level is no longer available.");const g=o.target==="config_field_selector"&&!a?ne({binding:o,selectedValue:l}):void 0,D=o.target==="config_grain"?F({binding:o,selectedValue:l}):a?a.grain:g==null?void 0:g.granularity;D!==void 0&&!Ue.has(D)&&u("This time grain is not supported by Matrix.");const N=O=>O.map(y=>{if(y.id!==c)return y;const k=(a==null?void 0:a.field)??(g?q(g):y.field),H=b(k,o.controlId),z=D??(g&&R.isAnalyticsDateLikeDataType(H)?y.grain:void 0);return z&&!R.isAnalyticsDateLikeDataType(H)&&u("A time grain requires a temporal Matrix level."),{...y,field:k,grain:z}});e={...e,rows:N(e.rows),columns:N(e.columns)}}}for(const[o,c]of Array.from(_)){const l=e.measures.find(C=>C.id===o);if(!l||l.kind!=="aggregate")continue;const u=b(l.field,c);de.getFieldAggregationOptions(u).some(C=>C.value===l.aggregate)||h(`Aggregation '${l.aggregate}' is not eligible for this Matrix field datatype.`,c)}try{return Y.reconcileMatrixSpecStructure(T.data,e)}catch(o){if(o instanceof ue.ZodError)return h(o.message);throw o}}function ie(t,e){const n=[],r=i=>{if(i.source){const s=R.configSourceRefSchema.safeParse(i.source);if(s.success)n.push(s.data);else if(e)throw s.error}i.derivedField&&Object.values(i.derivedField.inputs).forEach(s=>r(s.field))};for(const i of t){if(i.target!=="config_field_selector"&&i.target!=="config_metric_selector")continue;const s=e==null?void 0:e.get(i),f=e?s&&s!==S.CONTROL_CARD_DEFAULT_VALUE?[i.mapping[s]]:[]:Object.values(i.mapping);for(const _ of f)_&&"role"in _&&r(_)}return n}function Ge(t,e=[],n=[]){return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(e),...n])}function $e(t,e={}){const n=e.controlBindings??[],r=G(e.controlDefinitions??[],e.cardControlDefinitions??[]),i=new Map(n.filter(s=>s.target==="config_field_selector"||s.target==="config_metric_selector").map(s=>[s,$({binding:s,definitions:r,controlValues:e.controlValues})]));return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(n,i)])}exports.CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE=x;exports.CONTROL_BINDING_TARGET_INVALID_ERROR_CODE=te;exports.CONTROL_BINDING_VALUE_INVALID_ERROR_CODE=U;exports.CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE=xe;exports.CONTROL_DEFINITION_DUPLICATE_ERROR_CODE=J;exports.CONTROL_DEFINITION_INVALID_ERROR_CODE=ee;exports.CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE=Se;exports.CONTROL_REFERENCE_MISSING_ERROR_CODE=Q;exports.CONTROL_VALUE_INVALID_ERROR_CODE=Ve;exports.CONTROL_VALUE_MISSING_ERROR_CODE=K;exports.ControlResolutionError=I;exports.DASHBOARD_AUTHORING_BREAKPOINTS=ye;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=Le;exports.buildControlDefinitionIndex=G;exports.getColumnCatalogFieldId=we;exports.matrixCatalogSources=Ge;exports.matrixExecutionSources=$e;exports.parseISO=X;exports.resolveBindingControlValue=$;exports.resolveGroupByFieldTarget=ne;exports.resolveMatrixControlBindings=Fe;exports.resolveMetricFieldTarget=oe;exports.resolveScalarMappedValue=F;exports.validateControlValue=re;
|
package/dist/chunks/{matrix-control-sources-DYMzccBY.js → matrix-control-sources-cbYmqWNg.js}
RENAMED
|
@@ -2,12 +2,12 @@ var te = Object.defineProperty;
|
|
|
2
2
|
var re = (t, e, n) => e in t ? te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
3
|
var x = (t, e, n) => re(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { C as A } from "./common-types-C6cAQgyh.js";
|
|
5
|
-
import { N as ne,
|
|
6
|
-
import "./matrix-operation-contract-
|
|
7
|
-
import { g as ce, r as le } from "./calculated-field-identity-
|
|
8
|
-
import { g as de } from "./field-aggregations-
|
|
5
|
+
import { N as ne, z as oe, aW as B, A as ie, ai as P, ag as se, o as j, X as ae } from "./validators-D-_IT-Xw.js";
|
|
6
|
+
import "./matrix-operation-contract-0Nor-C71.js";
|
|
7
|
+
import { g as ce, r as le } from "./calculated-field-identity-Cq9GwHfE.js";
|
|
8
|
+
import { g as de } from "./field-aggregations-C8kZqMTD.js";
|
|
9
9
|
import { ZodError as ue } from "zod";
|
|
10
|
-
import { a as H } from "./matrix-card-
|
|
10
|
+
import { a as H } from "./matrix-card-BEb6hr8i.js";
|
|
11
11
|
import { m as Y, a as Z } from "./constants-DeLIHVAW.js";
|
|
12
12
|
function ge(t, e) {
|
|
13
13
|
const r = Ie(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./validators-
|
|
1
|
+
"use strict";const i=require("./validators-ux2obZB9.cjs");function d(e,t){return t.levelLabels[e.id]??e.field.label??e.field.name}function p(e,t){return t.measureLabels[e.id]??(e.kind==="aggregate"?e.field.label??e.field.name:e.definition.label)}function x(e){return i.matrixConfigSchema.parse(m(e))}function m(e){const t=i.matrixAuthoringSpecSchema.parse(e),n=a=>({grand:{visible:!0,position:"after"},levels:Object.fromEntries(a.map(r=>[r.id,{visible:!0,position:"before"}]))});return i.matrixAuthoringConfigSchema.parse({version:1,spec:t,presentation:{layout:{kind:"compact"},absence:{emptyText:"—",nullText:""},levelLabels:{},measureLabels:{},levelFormats:{},measureFormats:{},totals:{rows:n(t.rows),columns:n(t.columns)}},defaultView:{rows:{depth:0,overrides:[]},columns:{depth:t.columns.length>1?1:0,overrides:[]}}})}function f(e,t){const n=new Map(e.map(a=>[i.matrixSortKey(a),a]));for(const a of t??[])n.set(i.matrixSortKey(a),a);return[...n.values()]}function g(e){const{spec:t,presentation:n,defaults:a,session:r}=i.matrixDefinitionInputSchema.parse(e),c=new Map(f(t.sorts,r==null?void 0:r.sorts).map(o=>[i.matrixSortKey(o),o]));for(const o of["rows","columns"])for(const l of t[o]){const s={axis:o,levelId:l.id,scope:{kind:"level"},target:{kind:"member"},direction:"asc",nulls:"last"};c.has(i.matrixSortKey(s))||c.set(i.matrixSortKey(s),s)}const u=(o,l)=>({depth:Math.min(o.depth,Math.max(0,l-1)),overrides:o.overrides.filter(s=>s.path.length<l)});return{spec:{...t,sorts:[...c.values()]},presentation:n,view:{rows:u((r==null?void 0:r.rows)??a.rows,t.rows.length),columns:u((r==null?void 0:r.columns)??a.columns,t.columns.length),sorts:(r==null?void 0:r.sorts)??[]}}}exports.createMatrixAuthoringDraft=m;exports.createMatrixConfig=x;exports.getMatrixLevelLabel=d;exports.getMatrixMeasureLabel=p;exports.mergeMatrixSorts=f;exports.resolveMatrixDefinition=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const T=require("./validators-CueUwVE4.cjs");require("./matrix-operation-contract-CbavkrJj.cjs");const f=require("./semantic-format-CyJWf8gZ.cjs"),y=require("./raw-temporal-DWuF9bt7.cjs"),M=require("./constants-B00YUv89.cjs"),R=require("./index-F25jnH0p.cjs"),v=require("./temporal-bucket-4YEPEKlJ.cjs"),I=["day","hour","minute","second","millisecond"],x={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},Z={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},z={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function U(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function L(e,t){return U(e)?e:t}function N(e,t){return I.indexOf(L(e,t))}function k(e,t){const n=N(e,"day"),s=N(t,"second"),r=Math.min(n,s),o=Math.max(n,s);return I.slice(r,o+1)}function V(e,t){return e*x[L(t,"second")]}function q(e,t){const n=k(t.largestUnit,t.smallestUnit),s=n[n.length-1],r=x[s];let o=Math.round(e/r)*r;return n.map(u=>{const a=x[u],c=Math.floor(o/a);return o-=c*a,{unit:u,value:c}})}function X(e,t){const n=e.filter(o=>o.value!==0),s=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):s.length;return s.slice(0,r).map(o=>`${o.value}${Z[o.unit]}`).join(" ")}function E(e,t){const n=e.filter(o=>o.value!==0),s=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):s.length;return s.slice(0,r).map(o=>{const[u,a]=z[o.unit];return`${o.value} ${o.value===1?u:a}`}).join(" ")}function j(e){const t=e.some(c=>c.unit==="day"&&c.value!==0),n=e.some(c=>c.unit==="millisecond"),s=e.findIndex(c=>c.value!==0),r=Math.max(0,e.length-2),o=t?0:s===-1?r:Math.min(s,r),u=s===-1?e.slice(r):e.slice(o);if(u.length===0)return"0";const a=u.map((c,i)=>c.unit==="millisecond"?String(c.value).padStart(3,"0"):i===0?String(c.value):String(c.value).padStart(2,"0")).join(":");return n?a.replace(/:(\d{3})$/,".$1"):a}function B(e,t,n){const s=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${s})`:`-${s}`:s}function S(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 s=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",o=n<0,u=Math.abs(V(n,s)),a=q(u,t),c=r==="digital"?j(a):r==="long"?E(a,t.maxUnits):X(a,t.maxUnits);return B(c,o,t)}function g(e,t){const n=f.toDate(e),s=f.toDate(t),r=n.getTime()-s.getTime();return r<0?-1:r>0?1:r}function Y(e){return f.constructFrom(e,Date.now())}function W(e,t){const n=f.toDate(e),s=f.toDate(t),r=n.getFullYear()-s.getFullYear(),o=n.getMonth()-s.getMonth();return r*12+o}function F(e){return t=>{const s=(e?Math[e]:Math.trunc)(t);return s===0?0:s}}function H(e,t){return+f.toDate(e)-+f.toDate(t)}function G(e){const t=f.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=f.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=f.toDate(e);return+G(t)==+K(t)}function Q(e,t){const n=f.toDate(e),s=f.toDate(t),r=g(n,s),o=Math.abs(W(n,s));let u;if(o<1)u=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*o);let a=g(n,s)===-r;J(f.toDate(e))&&o===1&&g(e,s)===1&&(a=!1),u=r*(o-Number(a))}return u===0?0:u}function ee(e,t,n){const s=H(e,t)/1e3;return F(n==null?void 0:n.roundingMethod)(s)}function te(e,t,n){const s=f.getDefaultOptions(),r=(n==null?void 0:n.locale)??s.locale??f.enUS,o=2520,u=g(e,t);if(isNaN(u))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:u});let c,i;u>0?(c=f.toDate(t),i=f.toDate(e)):(c=f.toDate(e),i=f.toDate(t));const h=ee(i,c),m=(f.getTimezoneOffsetInMilliseconds(i)-f.getTimezoneOffsetInMilliseconds(c))/1e3,l=Math.round((h-m)/60);let d;if(l<2)return n!=null&&n.includeSeconds?h<5?r.formatDistance("lessThanXSeconds",5,a):h<10?r.formatDistance("lessThanXSeconds",10,a):h<20?r.formatDistance("lessThanXSeconds",20,a):h<40?r.formatDistance("halfAMinute",0,a):h<60?r.formatDistance("lessThanXMinutes",1,a):r.formatDistance("xMinutes",1,a):l===0?r.formatDistance("lessThanXMinutes",1,a):r.formatDistance("xMinutes",l,a);if(l<45)return r.formatDistance("xMinutes",l,a);if(l<90)return r.formatDistance("aboutXHours",1,a);if(l<M.minutesInDay){const D=Math.round(l/60);return r.formatDistance("aboutXHours",D,a)}else{if(l<o)return r.formatDistance("xDays",1,a);if(l<M.minutesInMonth){const D=Math.round(l/M.minutesInDay);return r.formatDistance("xDays",D,a)}else if(l<M.minutesInMonth*2)return d=Math.round(l/M.minutesInMonth),r.formatDistance("aboutXMonths",d,a)}if(d=Q(i,c),d<12){const D=Math.round(l/M.minutesInMonth);return r.formatDistance("xMonths",D,a)}else{const D=d%12,b=Math.trunc(d/12);return D<3?r.formatDistance("aboutXYears",b,a):D<9?r.formatDistance("overXYears",b,a):r.formatDistance("almostXYears",b+1,a)}}function _(e,t){return te(e,Y(e),t)}function ne(e,t){return e&&e!=="auto"?e:t}function re(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(o=>o.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function se(e){try{const t={timeZone:e,timeZoneName:"long"},s=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(s==null?void 0:s.value)||e}catch{return e}}function p(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),s=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||s||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||s){const o=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(o)}return new Date(e)}else return t==="UTC"?n?new Date(e):s?new Date(e):new Date(e+"Z"):n||s||r?new Date(e):R.fromZonedTime(e,t)}const oe="MM/dd/yyyy",C=(e,t,n,s="auto")=>{if(!e)return"";try{const r=p(e,s);if(isNaN(r.getTime()))return e;const u=(t&&t.trim()?t:oe).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?f.formatInTimeZone(r,n,u):f.format(r,u)}catch(r){return console.error("Date formatting error:",r),e}},P=(e,t="auto")=>{if(!e)return"";try{const n=p(e,t);return isNaN(n.getTime())?e:_(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function ae(e,t,n,s){const r=e instanceof Date?e.toISOString():String(e),o=(s==null?void 0:s.browserTimezone)||n,u=(s==null?void 0:s.isSqlCard)??!1;if(t!=null&&t.useRelativeTime)return P(r,(t==null?void 0:t.sourceTimezone)||"auto");const a=t!=null&&t.useCustomFormat&&(t!=null&&t.customFormat)?t.customFormat:(t==null?void 0:t.format)||"MM/dd/yyyy";return C(r,a,t!=null&&t.timezone&&(t==null?void 0:t.timezone)!=="auto"?t.timezone:u?o:n,(t==null?void 0:t.sourceTimezone)||"auto")}function w(e,t,n){var u,a;if(e==null)return e===null?((u=n.absence)==null?void 0:u.nullText)??"":((a=n.absence)==null?void 0:a.emptyText)??"";const s=T.isExactNumericValue(e)?e:void 0,r=s?s.value:e,o=s??(typeof e=="number"?e:void 0);if(!n.useFormattedValues||!t)return String(r);switch(t.type){case"number":return o!==void 0?y.formatNumberWithColumnSettings(o,t.numberFormat,n.locale):String(r);case"date":return ae(r,t.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return o!==void 0?`${r}%`:String(r);case"badge":case"link":case"text":case"none":default:return String(r)}}function ie(e,t){return t.visibleColumns.map(n=>{const s=e[n],r=t.columnSettings[n];return w(s,r,{useFormattedValues:t.useFormattedValues,timezone:t.timezone,locale:t.locale})})}function A(e,t){var r;const n=e[e.length-1];if(!n)return"";if(n.member.kind==="others")return"Others";const s=n.member.value;return s===null?"(Blank)":((r=t==null?void 0:t.get(n.levelId))==null?void 0:r(s))??(typeof s=="object"?s.value:String(s))}function O(e,t,n){return e==="grand_total"?n??"Grand Total":e==="subtotal"?n??`${t} Total`:t}function ue(e,t,n,s){var u;const r=e[e.length-1],o=t==="grand_total"?n.grand.label:r?(u=n.levels[r.levelId])==null?void 0:u.label:void 0;return O(t,A(e,s),o)}function ce(e,t,n){return e.kind==="value"?(t==null?void 0:t(e.value))??"":e.kind==="null"?n.nullText:n.emptyText}function le(e){const{path:t,previousPath:n,role:s,repeatLabels:r,levelCount:o}=e;return Array.from({length:o},(u,a)=>{const c=t.slice(0,a+1),i=s==="grand_total"?a===0:s==="subtotal"&&a===t.length-1,h=n&&n.length>a&&T.matrixPathKey(n.slice(0,a+1))===T.matrixPathKey(c);return{path:c,total:i,visible:i||t.length>a&&(r||!h||a===t.length-1)}})}function $(e,t){return f.fromSemanticFormat(e??t,{preserveOmittedProperties:!0,numericInput:"canonical"})}function fe(e,t,n){const s=new Map,r=(o,u)=>{const a=(u==="levels"?t.levelFormats:t.measureFormats)[o.id],c=o.semanticFormat,i=$(a,c);u==="measures"&&s.set(o.id,{isNumeric:T.normalizeAnalyticsCatalogDataType(o.column.dataType)==="number",hasTextAffixes:!!i&&!!("prefix"in i&&i.prefix||"suffix"in i&&i.suffix)});const h=m=>w(m,void 0,{useFormattedValues:!0,timezone:n.calendar.tz,locale:n.valueFormat.locale,absence:t.absence});if(o.column.temporalBucket){const m=o.column.temporalBucket,l=v.resolveTemporalBucketPresentation({metadata:m,cardFormat:(a==null?void 0:a.type)==="temporal_bucket"?a:void 0,semanticFormat:(c==null?void 0:c.type)==="temporal_bucket"?{granularity:m.granularity,format:c}:void 0,locale:n.valueFormat.locale,styles:{dateStyle:n.valueFormat.dateStyle,dateTime:n.valueFormat.dateTime}});return d=>typeof d=="string"?v.formatTemporalBucket({value:d,metadata:m,format:l.format}):h(d)}if(o.column.rawTemporal){const m=y.prepareRawTemporalFormatter({metadata:o.column.rawTemporal,format:y.resolveRawTemporalFormat({format:(i==null?void 0:i.type)==="date"?{type:"raw_temporal",timezone:i.timezone,sourceTimezone:i.sourceTimezone,presentation:i.pattern?{mode:"pattern",dialect:"semaphor_tokens",pattern:i.pattern}:{mode:"auto"}}:void 0,preferences:n.valueFormat,calendar:n.calendar})});return l=>{if(typeof l!="string")return h(l);const d=m(l);return d.ok?d.text:h(l)}}if(f.isNumericCanonicalFormat(i)){const m=y.resolveNumericPresentation(i,n.valueFormat);return l=>typeof l=="number"||typeof l=="object"&&l!==null?y.formatNumericCanonical(l,m):h(l)}return(i==null?void 0:i.type)==="duration"?m=>typeof m=="number"||typeof m=="string"||typeof m=="object"&&m!==null?S(typeof m=="object"?m.value:m,i):h(m):(i==null?void 0:i.type)==="string"?m=>m===null?h(m):`${i.prefix??""}${h(m)}${i.suffix??""}`:h};return{levels:new Map(e.levels.map(o=>[o.id,r(o,"levels")])),measures:new Map(e.measures.map(o=>[o.id,r(o,"measures")])),measureSemantics:s}}exports.formatCellValue=w;exports.formatDate=C;exports.formatDistanceToNow=_;exports.formatDuration=S;exports.formatRelativeTime=P;exports.formatRowForExport=ie;exports.getTimezoneAbbreviation=re;exports.getTimezoneName=se;exports.matrixAxisLabel=ue;exports.matrixCellText=ce;exports.matrixLevelLabels=le;exports.matrixMemberLabel=A;exports.matrixTotalLabel=O;exports.parseWithSourceTimezone=p;exports.prepareMatrixFormatting=fe;exports.resolveMatrixValueFormat=$;exports.resolveTimezone=ne;
|
|
1
|
+
"use strict";const T=require("./validators-ux2obZB9.cjs");require("./matrix-operation-contract-o9GXbiHw.cjs");const f=require("./semantic-format--_VEin18.cjs"),y=require("./raw-temporal-DDTt2yv5.cjs"),M=require("./constants-B00YUv89.cjs"),R=require("./index-F25jnH0p.cjs"),v=require("./temporal-bucket-4YEPEKlJ.cjs"),I=["day","hour","minute","second","millisecond"],x={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},Z={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},z={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function U(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function L(e,t){return U(e)?e:t}function N(e,t){return I.indexOf(L(e,t))}function k(e,t){const n=N(e,"day"),s=N(t,"second"),r=Math.min(n,s),o=Math.max(n,s);return I.slice(r,o+1)}function V(e,t){return e*x[L(t,"second")]}function q(e,t){const n=k(t.largestUnit,t.smallestUnit),s=n[n.length-1],r=x[s];let o=Math.round(e/r)*r;return n.map(u=>{const a=x[u],c=Math.floor(o/a);return o-=c*a,{unit:u,value:c}})}function X(e,t){const n=e.filter(o=>o.value!==0),s=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):s.length;return s.slice(0,r).map(o=>`${o.value}${Z[o.unit]}`).join(" ")}function E(e,t){const n=e.filter(o=>o.value!==0),s=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):s.length;return s.slice(0,r).map(o=>{const[u,a]=z[o.unit];return`${o.value} ${o.value===1?u:a}`}).join(" ")}function j(e){const t=e.some(c=>c.unit==="day"&&c.value!==0),n=e.some(c=>c.unit==="millisecond"),s=e.findIndex(c=>c.value!==0),r=Math.max(0,e.length-2),o=t?0:s===-1?r:Math.min(s,r),u=s===-1?e.slice(r):e.slice(o);if(u.length===0)return"0";const a=u.map((c,i)=>c.unit==="millisecond"?String(c.value).padStart(3,"0"):i===0?String(c.value):String(c.value).padStart(2,"0")).join(":");return n?a.replace(/:(\d{3})$/,".$1"):a}function B(e,t,n){const s=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${s})`:`-${s}`:s}function S(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 s=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",o=n<0,u=Math.abs(V(n,s)),a=q(u,t),c=r==="digital"?j(a):r==="long"?E(a,t.maxUnits):X(a,t.maxUnits);return B(c,o,t)}function g(e,t){const n=f.toDate(e),s=f.toDate(t),r=n.getTime()-s.getTime();return r<0?-1:r>0?1:r}function Y(e){return f.constructFrom(e,Date.now())}function W(e,t){const n=f.toDate(e),s=f.toDate(t),r=n.getFullYear()-s.getFullYear(),o=n.getMonth()-s.getMonth();return r*12+o}function F(e){return t=>{const s=(e?Math[e]:Math.trunc)(t);return s===0?0:s}}function H(e,t){return+f.toDate(e)-+f.toDate(t)}function G(e){const t=f.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=f.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=f.toDate(e);return+G(t)==+K(t)}function Q(e,t){const n=f.toDate(e),s=f.toDate(t),r=g(n,s),o=Math.abs(W(n,s));let u;if(o<1)u=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*o);let a=g(n,s)===-r;J(f.toDate(e))&&o===1&&g(e,s)===1&&(a=!1),u=r*(o-Number(a))}return u===0?0:u}function ee(e,t,n){const s=H(e,t)/1e3;return F(n==null?void 0:n.roundingMethod)(s)}function te(e,t,n){const s=f.getDefaultOptions(),r=(n==null?void 0:n.locale)??s.locale??f.enUS,o=2520,u=g(e,t);if(isNaN(u))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:u});let c,i;u>0?(c=f.toDate(t),i=f.toDate(e)):(c=f.toDate(e),i=f.toDate(t));const h=ee(i,c),m=(f.getTimezoneOffsetInMilliseconds(i)-f.getTimezoneOffsetInMilliseconds(c))/1e3,l=Math.round((h-m)/60);let d;if(l<2)return n!=null&&n.includeSeconds?h<5?r.formatDistance("lessThanXSeconds",5,a):h<10?r.formatDistance("lessThanXSeconds",10,a):h<20?r.formatDistance("lessThanXSeconds",20,a):h<40?r.formatDistance("halfAMinute",0,a):h<60?r.formatDistance("lessThanXMinutes",1,a):r.formatDistance("xMinutes",1,a):l===0?r.formatDistance("lessThanXMinutes",1,a):r.formatDistance("xMinutes",l,a);if(l<45)return r.formatDistance("xMinutes",l,a);if(l<90)return r.formatDistance("aboutXHours",1,a);if(l<M.minutesInDay){const D=Math.round(l/60);return r.formatDistance("aboutXHours",D,a)}else{if(l<o)return r.formatDistance("xDays",1,a);if(l<M.minutesInMonth){const D=Math.round(l/M.minutesInDay);return r.formatDistance("xDays",D,a)}else if(l<M.minutesInMonth*2)return d=Math.round(l/M.minutesInMonth),r.formatDistance("aboutXMonths",d,a)}if(d=Q(i,c),d<12){const D=Math.round(l/M.minutesInMonth);return r.formatDistance("xMonths",D,a)}else{const D=d%12,b=Math.trunc(d/12);return D<3?r.formatDistance("aboutXYears",b,a):D<9?r.formatDistance("overXYears",b,a):r.formatDistance("almostXYears",b+1,a)}}function _(e,t){return te(e,Y(e),t)}function ne(e,t){return e&&e!=="auto"?e:t}function re(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(o=>o.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function se(e){try{const t={timeZone:e,timeZoneName:"long"},s=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(s==null?void 0:s.value)||e}catch{return e}}function p(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),s=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||s||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||s){const o=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(o)}return new Date(e)}else return t==="UTC"?n?new Date(e):s?new Date(e):new Date(e+"Z"):n||s||r?new Date(e):R.fromZonedTime(e,t)}const oe="MM/dd/yyyy",C=(e,t,n,s="auto")=>{if(!e)return"";try{const r=p(e,s);if(isNaN(r.getTime()))return e;const u=(t&&t.trim()?t:oe).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?f.formatInTimeZone(r,n,u):f.format(r,u)}catch(r){return console.error("Date formatting error:",r),e}},P=(e,t="auto")=>{if(!e)return"";try{const n=p(e,t);return isNaN(n.getTime())?e:_(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function ae(e,t,n,s){const r=e instanceof Date?e.toISOString():String(e),o=(s==null?void 0:s.browserTimezone)||n,u=(s==null?void 0:s.isSqlCard)??!1;if(t!=null&&t.useRelativeTime)return P(r,(t==null?void 0:t.sourceTimezone)||"auto");const a=t!=null&&t.useCustomFormat&&(t!=null&&t.customFormat)?t.customFormat:(t==null?void 0:t.format)||"MM/dd/yyyy";return C(r,a,t!=null&&t.timezone&&(t==null?void 0:t.timezone)!=="auto"?t.timezone:u?o:n,(t==null?void 0:t.sourceTimezone)||"auto")}function w(e,t,n){var u,a;if(e==null)return e===null?((u=n.absence)==null?void 0:u.nullText)??"":((a=n.absence)==null?void 0:a.emptyText)??"";const s=T.isExactNumericValue(e)?e:void 0,r=s?s.value:e,o=s??(typeof e=="number"?e:void 0);if(!n.useFormattedValues||!t)return String(r);switch(t.type){case"number":return o!==void 0?y.formatNumberWithColumnSettings(o,t.numberFormat,n.locale):String(r);case"date":return ae(r,t.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return o!==void 0?`${r}%`:String(r);case"badge":case"link":case"text":case"none":default:return String(r)}}function ie(e,t){return t.visibleColumns.map(n=>{const s=e[n],r=t.columnSettings[n];return w(s,r,{useFormattedValues:t.useFormattedValues,timezone:t.timezone,locale:t.locale})})}function A(e,t){var r;const n=e[e.length-1];if(!n)return"";if(n.member.kind==="others")return"Others";const s=n.member.value;return s===null?"(Blank)":((r=t==null?void 0:t.get(n.levelId))==null?void 0:r(s))??(typeof s=="object"?s.value:String(s))}function O(e,t,n){return e==="grand_total"?n??"Grand Total":e==="subtotal"?n??`${t} Total`:t}function ue(e,t,n,s){var u;const r=e[e.length-1],o=t==="grand_total"?n.grand.label:r?(u=n.levels[r.levelId])==null?void 0:u.label:void 0;return O(t,A(e,s),o)}function ce(e,t,n){return e.kind==="value"?(t==null?void 0:t(e.value))??"":e.kind==="null"?n.nullText:n.emptyText}function le(e){const{path:t,previousPath:n,role:s,repeatLabels:r,levelCount:o}=e;return Array.from({length:o},(u,a)=>{const c=t.slice(0,a+1),i=s==="grand_total"?a===0:s==="subtotal"&&a===t.length-1,h=n&&n.length>a&&T.matrixPathKey(n.slice(0,a+1))===T.matrixPathKey(c);return{path:c,total:i,visible:i||t.length>a&&(r||!h||a===t.length-1)}})}function $(e,t){return f.fromSemanticFormat(e??t,{preserveOmittedProperties:!0,numericInput:"canonical"})}function fe(e,t,n){const s=new Map,r=(o,u)=>{const a=(u==="levels"?t.levelFormats:t.measureFormats)[o.id],c=o.semanticFormat,i=$(a,c);u==="measures"&&s.set(o.id,{isNumeric:T.normalizeAnalyticsCatalogDataType(o.column.dataType)==="number",hasTextAffixes:!!i&&!!("prefix"in i&&i.prefix||"suffix"in i&&i.suffix)});const h=m=>w(m,void 0,{useFormattedValues:!0,timezone:n.calendar.tz,locale:n.valueFormat.locale,absence:t.absence});if(o.column.temporalBucket){const m=o.column.temporalBucket,l=v.resolveTemporalBucketPresentation({metadata:m,cardFormat:(a==null?void 0:a.type)==="temporal_bucket"?a:void 0,semanticFormat:(c==null?void 0:c.type)==="temporal_bucket"?{granularity:m.granularity,format:c}:void 0,locale:n.valueFormat.locale,styles:{dateStyle:n.valueFormat.dateStyle,dateTime:n.valueFormat.dateTime}});return d=>typeof d=="string"?v.formatTemporalBucket({value:d,metadata:m,format:l.format}):h(d)}if(o.column.rawTemporal){const m=y.prepareRawTemporalFormatter({metadata:o.column.rawTemporal,format:y.resolveRawTemporalFormat({format:(i==null?void 0:i.type)==="date"?{type:"raw_temporal",timezone:i.timezone,sourceTimezone:i.sourceTimezone,presentation:i.pattern?{mode:"pattern",dialect:"semaphor_tokens",pattern:i.pattern}:{mode:"auto"}}:void 0,preferences:n.valueFormat,calendar:n.calendar})});return l=>{if(typeof l!="string")return h(l);const d=m(l);return d.ok?d.text:h(l)}}if(f.isNumericCanonicalFormat(i)){const m=y.resolveNumericPresentation(i,n.valueFormat);return l=>typeof l=="number"||typeof l=="object"&&l!==null?y.formatNumericCanonical(l,m):h(l)}return(i==null?void 0:i.type)==="duration"?m=>typeof m=="number"||typeof m=="string"||typeof m=="object"&&m!==null?S(typeof m=="object"?m.value:m,i):h(m):(i==null?void 0:i.type)==="string"?m=>m===null?h(m):`${i.prefix??""}${h(m)}${i.suffix??""}`:h};return{levels:new Map(e.levels.map(o=>[o.id,r(o,"levels")])),measures:new Map(e.measures.map(o=>[o.id,r(o,"measures")])),measureSemantics:s}}exports.formatCellValue=w;exports.formatDate=C;exports.formatDistanceToNow=_;exports.formatDuration=S;exports.formatRelativeTime=P;exports.formatRowForExport=ie;exports.getTimezoneAbbreviation=re;exports.getTimezoneName=se;exports.matrixAxisLabel=ue;exports.matrixCellText=ce;exports.matrixLevelLabels=le;exports.matrixMemberLabel=A;exports.matrixTotalLabel=O;exports.parseWithSourceTimezone=p;exports.prepareMatrixFormatting=fe;exports.resolveMatrixValueFormat=$;exports.resolveTimezone=ne;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./matrix-operation-contract-
|
|
3
|
-
import { t as d, c as P, g as $, e as C, a as x, b as O, d as A, f as Z, i as R } from "./semantic-format-
|
|
4
|
-
import { f as
|
|
5
|
-
import { b as p, c as
|
|
6
|
-
import { f as
|
|
1
|
+
import { b0 as L, M as T, ag as _ } from "./validators-D-_IT-Xw.js";
|
|
2
|
+
import "./matrix-operation-contract-0Nor-C71.js";
|
|
3
|
+
import { t as d, c as P, g as $, e as C, a as x, b as O, d as A, f as Z, i as R } from "./semantic-format-ew5zviaT.js";
|
|
4
|
+
import { f as k, s as U, k as z, j as V, b as X } from "./raw-temporal-DHCZrFe7.js";
|
|
5
|
+
import { b as p, c as y } from "./constants-DeLIHVAW.js";
|
|
6
|
+
import { f as j } from "./index-CACdoqu3.js";
|
|
7
7
|
import { d as E, f as Y } from "./temporal-bucket-B9hMwemw.js";
|
|
8
8
|
const N = [
|
|
9
9
|
"day",
|
|
@@ -156,23 +156,23 @@ function fe(e, t, n) {
|
|
|
156
156
|
if (l < 90)
|
|
157
157
|
return r.formatDistance("aboutXHours", 1, a);
|
|
158
158
|
if (l < p) {
|
|
159
|
-
const
|
|
160
|
-
return r.formatDistance("aboutXHours",
|
|
159
|
+
const M = Math.round(l / 60);
|
|
160
|
+
return r.formatDistance("aboutXHours", M, a);
|
|
161
161
|
} else {
|
|
162
162
|
if (l < o)
|
|
163
163
|
return r.formatDistance("xDays", 1, a);
|
|
164
|
-
if (l <
|
|
165
|
-
const
|
|
166
|
-
return r.formatDistance("xDays",
|
|
167
|
-
} else if (l <
|
|
168
|
-
return h = Math.round(l /
|
|
164
|
+
if (l < y) {
|
|
165
|
+
const M = Math.round(l / p);
|
|
166
|
+
return r.formatDistance("xDays", M, a);
|
|
167
|
+
} else if (l < y * 2)
|
|
168
|
+
return h = Math.round(l / y), r.formatDistance("aboutXMonths", h, a);
|
|
169
169
|
}
|
|
170
170
|
if (h = ce(i, c), h < 12) {
|
|
171
|
-
const
|
|
172
|
-
return r.formatDistance("xMonths",
|
|
171
|
+
const M = Math.round(l / y);
|
|
172
|
+
return r.formatDistance("xMonths", M, a);
|
|
173
173
|
} else {
|
|
174
|
-
const
|
|
175
|
-
return
|
|
174
|
+
const M = h % 12, D = Math.trunc(h / 12);
|
|
175
|
+
return M < 3 ? r.formatDistance("aboutXYears", D, a) : M < 9 ? r.formatDistance("overXYears", D, a) : r.formatDistance("almostXYears", D + 1, a);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
function me(e, t) {
|
|
@@ -217,7 +217,7 @@ function I(e, t = "auto") {
|
|
|
217
217
|
return new Date(o);
|
|
218
218
|
}
|
|
219
219
|
return new Date(e);
|
|
220
|
-
} else return t === "UTC" ? n ? new Date(e) : s ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || s || r ? new Date(e) :
|
|
220
|
+
} else return t === "UTC" ? n ? new Date(e) : s ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || s || r ? new Date(e) : j(e, t);
|
|
221
221
|
}
|
|
222
222
|
const de = "MM/dd/yyyy", he = (e, t, n, s = "auto") => {
|
|
223
223
|
if (!e)
|
|
@@ -231,7 +231,7 @@ const de = "MM/dd/yyyy", he = (e, t, n, s = "auto") => {
|
|
|
231
231
|
} catch (r) {
|
|
232
232
|
return console.error("Date formatting error:", r), e;
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, Me = (e, t = "auto") => {
|
|
235
235
|
if (!e)
|
|
236
236
|
return "";
|
|
237
237
|
try {
|
|
@@ -241,10 +241,10 @@ const de = "MM/dd/yyyy", he = (e, t, n, s = "auto") => {
|
|
|
241
241
|
return console.error("Relative time formatting error:", n), e;
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
|
-
function
|
|
244
|
+
function ye(e, t, n, s) {
|
|
245
245
|
const r = e instanceof Date ? e.toISOString() : String(e), o = (s == null ? void 0 : s.browserTimezone) || n, u = (s == null ? void 0 : s.isSqlCard) ?? !1;
|
|
246
246
|
if (t != null && t.useRelativeTime)
|
|
247
|
-
return
|
|
247
|
+
return Me(
|
|
248
248
|
r,
|
|
249
249
|
(t == null ? void 0 : t.sourceTimezone) || "auto"
|
|
250
250
|
);
|
|
@@ -265,13 +265,13 @@ function S(e, t, n) {
|
|
|
265
265
|
return String(r);
|
|
266
266
|
switch (t.type) {
|
|
267
267
|
case "number":
|
|
268
|
-
return o !== void 0 ?
|
|
268
|
+
return o !== void 0 ? k(
|
|
269
269
|
o,
|
|
270
270
|
t.numberFormat,
|
|
271
271
|
n.locale
|
|
272
272
|
) : String(r);
|
|
273
273
|
case "date":
|
|
274
|
-
return
|
|
274
|
+
return ye(
|
|
275
275
|
r,
|
|
276
276
|
t.dateFormat,
|
|
277
277
|
n.timezone,
|
|
@@ -361,7 +361,7 @@ function Ae(e, t, n) {
|
|
|
361
361
|
return (h) => typeof h == "string" ? Y({ value: h, metadata: f, format: l.format }) : m(h);
|
|
362
362
|
}
|
|
363
363
|
if (o.column.rawTemporal) {
|
|
364
|
-
const f =
|
|
364
|
+
const f = U({
|
|
365
365
|
metadata: o.column.rawTemporal,
|
|
366
366
|
format: z({
|
|
367
367
|
format: (i == null ? void 0 : i.type) === "date" ? {
|
|
@@ -385,8 +385,8 @@ function Ae(e, t, n) {
|
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
if (R(i)) {
|
|
388
|
-
const f =
|
|
389
|
-
return (l) => typeof l == "number" || typeof l == "object" && l !== null ?
|
|
388
|
+
const f = V(i, n.valueFormat);
|
|
389
|
+
return (l) => typeof l == "number" || typeof l == "object" && l !== null ? X(l, f) : m(l);
|
|
390
390
|
}
|
|
391
391
|
return (i == null ? void 0 : i.type) === "duration" ? (f) => typeof f == "number" || typeof f == "string" || typeof f == "object" && f !== null ? te(
|
|
392
392
|
typeof f == "object" ? f.value : f,
|
|
@@ -410,7 +410,7 @@ export {
|
|
|
410
410
|
te as d,
|
|
411
411
|
he as e,
|
|
412
412
|
Pe as f,
|
|
413
|
-
|
|
413
|
+
Me as g,
|
|
414
414
|
Le as h,
|
|
415
415
|
_e as i,
|
|
416
416
|
I as j,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./validators-ux2obZB9.cjs"),d=["=","!=",">","<",">=","<=","like","not like","between","not between","in","not in","is null","is not null"],h=new Set(["string","number","date","boolean"]);function P(t){return typeof t=="string"&&d.includes(t)}function b(t,e){switch(t){case"is null":case"is not null":return e.length===0;case"between":case"not between":return e.length===2;case"in":case"not in":return e.length>=1;default:return e.length===1}}function p(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e=t,i={};for(const n of y)e[n]!==void 0&&(i[n]=e[n]);return i}const y=["operation","values","valueType","temporalBucket","relativeMeta","temporalPrecision"];function v(t){const e=p(t);if(!e)return;const{operation:i,values:n}=e;if(!P(i)||!Array.isArray(n)||!b(i,n))return;const r=typeof e.valueType=="string"&&h.has(e.valueType)?e.valueType:void 0;return{operation:i,values:n,...r?{valueType:r}:{},...e.temporalBucket!==void 0?{temporalBucket:e.temporalBucket}:{},...e.relativeMeta!==void 0?{relativeMeta:e.relativeMeta}:{},...e.temporalPrecision!==void 0?{temporalPrecision:e.temporalPrecision}:{}}}function E(t){const e=v(t);if(!e)throw new Error(`Filter operation "${String(t.operation)}" cannot be expressed as predicate semantics.`);return e}function g(t){return t.operation==="is null"||t.operation==="is not null"}function f(t,e){var n;if(e===null)return!0;if(e.overrides.length===0)return t.length<=e.depth;const i=u.matrixPathKey(t);return((n=e.overrides.find(r=>r.path.length===t.length&&u.matrixPathKey(r.path)===i))==null?void 0:n.expanded)??t.length<=e.depth}function A(t){var l;const{path:e,levelCount:i,expansion:n,total:r,axis:m}=t,a=e.length>=i||((l=e[e.length-1])==null?void 0:l.member.kind)==="others",s=!a&&!t.childrenEmpty,o=s&&f(e,n),c=m==="rows"&&t.rowLayout!=="tabular";return{expandable:s,expanded:o,memberVisible:c||!o,valueVisible:a||!!(r!=null&&r.visible)&&(!o||r.position==="before"),subtotalBefore:!c&&o&&!!(r!=null&&r.visible)&&r.position==="before",subtotalAfter:o&&!!(r!=null&&r.visible)&&r.position==="after"}}exports.NATIVE_PREDICATE_OPERATIONS=d;exports.isMatrixPathExpanded=f;exports.isNullCheckPredicate=g;exports.parseNativePredicateSemantics=v;exports.projectNativePredicateSemantics=p;exports.resolveMatrixMemberPresentation=A;exports.toNativePredicateSemantics=E;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { M as u } from "./validators-D-_IT-Xw.js";
|
|
2
|
+
const d = [
|
|
3
|
+
"=",
|
|
4
|
+
"!=",
|
|
5
|
+
">",
|
|
6
|
+
"<",
|
|
7
|
+
">=",
|
|
8
|
+
"<=",
|
|
9
|
+
"like",
|
|
10
|
+
"not like",
|
|
11
|
+
"between",
|
|
12
|
+
"not between",
|
|
13
|
+
"in",
|
|
14
|
+
"not in",
|
|
15
|
+
"is null",
|
|
16
|
+
"is not null"
|
|
17
|
+
], f = /* @__PURE__ */ new Set(["string", "number", "date", "boolean"]);
|
|
18
|
+
function m(t) {
|
|
19
|
+
return typeof t == "string" && d.includes(t);
|
|
20
|
+
}
|
|
21
|
+
function v(t, e) {
|
|
22
|
+
switch (t) {
|
|
23
|
+
case "is null":
|
|
24
|
+
case "is not null":
|
|
25
|
+
return e.length === 0;
|
|
26
|
+
case "between":
|
|
27
|
+
case "not between":
|
|
28
|
+
return e.length === 2;
|
|
29
|
+
case "in":
|
|
30
|
+
case "not in":
|
|
31
|
+
return e.length >= 1;
|
|
32
|
+
default:
|
|
33
|
+
return e.length === 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function b(t) {
|
|
37
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
38
|
+
return;
|
|
39
|
+
const e = t, i = {};
|
|
40
|
+
for (const r of h)
|
|
41
|
+
e[r] !== void 0 && (i[r] = e[r]);
|
|
42
|
+
return i;
|
|
43
|
+
}
|
|
44
|
+
const h = [
|
|
45
|
+
"operation",
|
|
46
|
+
"values",
|
|
47
|
+
"valueType",
|
|
48
|
+
"temporalBucket",
|
|
49
|
+
"relativeMeta",
|
|
50
|
+
"temporalPrecision"
|
|
51
|
+
];
|
|
52
|
+
function y(t) {
|
|
53
|
+
const e = b(t);
|
|
54
|
+
if (!e) return;
|
|
55
|
+
const { operation: i, values: r } = e;
|
|
56
|
+
if (!m(i) || !Array.isArray(r) || !v(i, r)) return;
|
|
57
|
+
const n = typeof e.valueType == "string" && f.has(e.valueType) ? e.valueType : void 0;
|
|
58
|
+
return {
|
|
59
|
+
operation: i,
|
|
60
|
+
values: r,
|
|
61
|
+
...n ? { valueType: n } : {},
|
|
62
|
+
...e.temporalBucket !== void 0 ? { temporalBucket: e.temporalBucket } : {},
|
|
63
|
+
...e.relativeMeta !== void 0 ? { relativeMeta: e.relativeMeta } : {},
|
|
64
|
+
...e.temporalPrecision !== void 0 ? { temporalPrecision: e.temporalPrecision } : {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function E(t) {
|
|
68
|
+
const e = y(t);
|
|
69
|
+
if (!e)
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Filter operation "${String(t.operation)}" cannot be expressed as predicate semantics.`
|
|
72
|
+
);
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
function A(t) {
|
|
76
|
+
return t.operation === "is null" || t.operation === "is not null";
|
|
77
|
+
}
|
|
78
|
+
function P(t, e) {
|
|
79
|
+
var r;
|
|
80
|
+
if (e === null) return !0;
|
|
81
|
+
if (e.overrides.length === 0) return t.length <= e.depth;
|
|
82
|
+
const i = u(t);
|
|
83
|
+
return ((r = e.overrides.find((n) => n.path.length === t.length && u(n.path) === i)) == null ? void 0 : r.expanded) ?? t.length <= e.depth;
|
|
84
|
+
}
|
|
85
|
+
function T(t) {
|
|
86
|
+
var l;
|
|
87
|
+
const { path: e, levelCount: i, expansion: r, total: n, axis: p } = t, a = e.length >= i || ((l = e[e.length - 1]) == null ? void 0 : l.member.kind) === "others", s = !a && !t.childrenEmpty, o = s && P(e, r), c = p === "rows" && t.rowLayout !== "tabular";
|
|
88
|
+
return {
|
|
89
|
+
expandable: s,
|
|
90
|
+
expanded: o,
|
|
91
|
+
memberVisible: c || !o,
|
|
92
|
+
valueVisible: a || !!(n != null && n.visible) && (!o || n.position === "before"),
|
|
93
|
+
subtotalBefore: !c && o && !!(n != null && n.visible) && n.position === "before",
|
|
94
|
+
subtotalAfter: o && !!(n != null && n.visible) && n.position === "after"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
d as N,
|
|
99
|
+
y as a,
|
|
100
|
+
P as b,
|
|
101
|
+
A as i,
|
|
102
|
+
b as p,
|
|
103
|
+
T as r,
|
|
104
|
+
E as t
|
|
105
|
+
};
|
package/dist/chunks/{matrix-operation-contract-4q53iAUW.js → matrix-operation-contract-0Nor-C71.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z as r } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
2
|
+
import { G as g, y as W, N, b6 as V, M as v, H as be, a_ as J, b7 as ve, aH as $e, z as Se, m as we, f as ke, aY as Ie, aM as Ae, aN as _e, aQ as Re, aR as qe, aA as C, aF as D, at as Ce, aK as je, aL as X, ar as Ee, ap as m, aq as xe, aG as Fe } from "./validators-D-_IT-Xw.js";
|
|
3
|
+
const M = {
|
|
4
4
|
answerSummary: "string",
|
|
5
5
|
responseDetail: "responseDetail",
|
|
6
6
|
mode: "string",
|
|
@@ -170,7 +170,7 @@ const Ne = r.object({
|
|
|
170
170
|
}).strict(), ee = r.object({
|
|
171
171
|
levels: r.array(z).readonly(),
|
|
172
172
|
measures: r.array(z).readonly()
|
|
173
|
-
}).strict(),
|
|
173
|
+
}).strict(), T = r.object({
|
|
174
174
|
code: r.enum([
|
|
175
175
|
"invalid_request",
|
|
176
176
|
"unsupported_capability",
|
|
@@ -189,16 +189,16 @@ const Ne = r.object({
|
|
|
189
189
|
r.object({ kind: r.literal("operation") }).strict(),
|
|
190
190
|
r.object({ kind: r.enum(["page", "block"]), requestId: p }).strict()
|
|
191
191
|
])
|
|
192
|
-
}).strict(),
|
|
192
|
+
}).strict(), Me = r.object({
|
|
193
193
|
dialect: r.enum(["postgres", "clickhouse", "duckdb"]),
|
|
194
194
|
aggregates: r.array(Se).readonly()
|
|
195
195
|
}).strict(), se = r.object({
|
|
196
196
|
queryIdentity: p,
|
|
197
197
|
descriptors: ee,
|
|
198
|
-
capabilities:
|
|
198
|
+
capabilities: Me,
|
|
199
199
|
pages: r.array(Be).readonly(),
|
|
200
200
|
blocks: r.array(De).readonly(),
|
|
201
|
-
failures: r.array(
|
|
201
|
+
failures: r.array(T).readonly()
|
|
202
202
|
}).strict().superRefine((i, s) => {
|
|
203
203
|
const e = new Set(
|
|
204
204
|
i.descriptors.levels.map((a) => a.id)
|
|
@@ -253,7 +253,7 @@ const Ne = r.object({
|
|
|
253
253
|
status: r.enum(["success", "partial"]),
|
|
254
254
|
window: se
|
|
255
255
|
}).strict(),
|
|
256
|
-
r.object({ status: r.literal("failed"), failure:
|
|
256
|
+
r.object({ status: r.literal("failed"), failure: T }).strict()
|
|
257
257
|
]).superRefine((i, s) => {
|
|
258
258
|
if (i.status === "failed") return;
|
|
259
259
|
const { window: e } = i;
|
|
@@ -265,7 +265,7 @@ const Ne = r.object({
|
|
|
265
265
|
}), te = r.object({
|
|
266
266
|
kind: r.literal("matrix"),
|
|
267
267
|
window: se
|
|
268
|
-
}).strict(), ie = r.enum(["member", "subtotal", "grand_total"]),
|
|
268
|
+
}).strict(), ie = r.enum(["member", "subtotal", "grand_total"]), Te = r.discriminatedUnion("kind", [
|
|
269
269
|
r.object({ kind: r.literal("hierarchy"), label: r.string() }).strict(),
|
|
270
270
|
r.object({ kind: r.literal("level"), levelId: k, label: r.string() }).strict(),
|
|
271
271
|
r.object({
|
|
@@ -276,7 +276,7 @@ const Ne = r.object({
|
|
|
276
276
|
label: r.string()
|
|
277
277
|
}).strict()
|
|
278
278
|
]), Pe = r.object({
|
|
279
|
-
columns: r.array(
|
|
279
|
+
columns: r.array(Te).readonly(),
|
|
280
280
|
descriptors: ee
|
|
281
281
|
}).strict(), G = r.union([
|
|
282
282
|
r.object({
|
|
@@ -1416,7 +1416,7 @@ function Fs(i) {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
const Ks = Object.fromEntries(
|
|
1419
|
-
Object.entries(
|
|
1419
|
+
Object.entries(M).map(
|
|
1420
1420
|
([i, s]) => [i, Fs(s)]
|
|
1421
1421
|
)
|
|
1422
1422
|
), Ns = r.object(Ks).strict(), P = r.object({
|
|
@@ -1498,7 +1498,7 @@ const Ks = Object.fromEntries(
|
|
|
1498
1498
|
computation: m.optional(),
|
|
1499
1499
|
uxExpectations: r.array(r.string()).optional(),
|
|
1500
1500
|
validation: m.optional()
|
|
1501
|
-
}).passthrough(),
|
|
1501
|
+
}).passthrough(), Ms = r.object({
|
|
1502
1502
|
inputId: r.string(),
|
|
1503
1503
|
label: r.string().optional(),
|
|
1504
1504
|
type: r.string().optional(),
|
|
@@ -1517,7 +1517,7 @@ const Ks = Object.fromEntries(
|
|
|
1517
1517
|
sources: r.array(P),
|
|
1518
1518
|
inputs: r.array(Os),
|
|
1519
1519
|
views: r.array(Ds),
|
|
1520
|
-
filterContracts: r.array(
|
|
1520
|
+
filterContracts: r.array(Ms),
|
|
1521
1521
|
implementationChecklist: r.object({
|
|
1522
1522
|
schemaVersion: r.string().optional(),
|
|
1523
1523
|
requiredDevtools: r.object({
|
|
@@ -1553,16 +1553,16 @@ const Ks = Object.fromEntries(
|
|
|
1553
1553
|
code: r.ZodIssueCode.custom,
|
|
1554
1554
|
message: t
|
|
1555
1555
|
});
|
|
1556
|
-
}),
|
|
1557
|
-
Object.keys(
|
|
1556
|
+
}), Ts = new Set(
|
|
1557
|
+
Object.keys(M)
|
|
1558
1558
|
);
|
|
1559
1559
|
function et() {
|
|
1560
1560
|
return Object.keys(
|
|
1561
|
-
|
|
1561
|
+
M
|
|
1562
1562
|
);
|
|
1563
1563
|
}
|
|
1564
1564
|
function Ps(i) {
|
|
1565
|
-
return
|
|
1565
|
+
return Ts.has(i);
|
|
1566
1566
|
}
|
|
1567
1567
|
function st(i) {
|
|
1568
1568
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
@@ -1589,16 +1589,16 @@ const Us = {
|
|
|
1589
1589
|
intent: re.shape.intent,
|
|
1590
1590
|
resultShape: r.literal("matrix"),
|
|
1591
1591
|
result: te.optional(),
|
|
1592
|
-
metadata: r.object({ rowLimitExceeded: r.boolean(), matrixFailure:
|
|
1592
|
+
metadata: r.object({ rowLimitExceeded: r.boolean(), matrixFailure: T.optional() }).passthrough()
|
|
1593
1593
|
}, zs = ye.extend(Us), it = zs.superRefine((i, s) => {
|
|
1594
1594
|
i.status === "failed" == !!i.result && s.addIssue({ code: "custom", message: "Only answered or partial Matrix execution carries a window." }), i.result && i.status === "partial" != i.result.window.failures.length > 0 && s.addIssue({ code: "custom", message: "Matrix execution status must match acquired window failures." });
|
|
1595
1595
|
});
|
|
1596
1596
|
export {
|
|
1597
|
-
|
|
1598
|
-
|
|
1597
|
+
T as A,
|
|
1598
|
+
Me as B,
|
|
1599
1599
|
se as C,
|
|
1600
1600
|
Ys as D,
|
|
1601
|
-
|
|
1601
|
+
Te as E,
|
|
1602
1602
|
Pe as F,
|
|
1603
1603
|
G,
|
|
1604
1604
|
Ve as H,
|
|
@@ -1611,7 +1611,7 @@ export {
|
|
|
1611
1611
|
O as S,
|
|
1612
1612
|
Js as a,
|
|
1613
1613
|
Ps as b,
|
|
1614
|
-
|
|
1614
|
+
M as c,
|
|
1615
1615
|
Es as d,
|
|
1616
1616
|
pe as e,
|
|
1617
1617
|
me as f,
|