react-semaphor 0.1.497 → 0.1.498
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 +10 -10
- 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 → calculated-field-identity-BGIPbwBx.js} +26 -26
- package/dist/chunks/{calculated-field-identity-DTfyvvLC.cjs → calculated-field-identity-CEzmY7Bi.cjs} +1 -1
- package/dist/chunks/{constants-CC3WKmqC.js → constants-CKoIADZx.js} +9 -9
- package/dist/chunks/{constants-DIuhVR6J.cjs → constants-CpBVuEea.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CZZuHl61.cjs → dashboard-briefing-launcher-BEmyxEd8.cjs} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-72HdqDbJ.js → dashboard-briefing-launcher-C8eAX-JN.js} +9 -9
- package/dist/chunks/{dashboard-controls-BwisKmY9.js → dashboard-controls-C_v7sbq4.js} +11 -11
- package/dist/chunks/{dashboard-controls-B7YP9m8Y.cjs → dashboard-controls-YvJe7cPL.cjs} +1 -1
- package/dist/chunks/{dashboard-date-comparison-definition-C69F-zaC.cjs → dashboard-date-comparison-definition-Er8D33iq.cjs} +1 -1
- package/dist/chunks/{dashboard-date-comparison-definition-Bqti6YAo.js → dashboard-date-comparison-definition-aANgeL-E.js} +1 -1
- package/dist/chunks/{dashboard-json-C5Cu7-zC.js → dashboard-json-BaT3Yy8x.js} +7 -7
- package/dist/chunks/{dashboard-json-B6GTxo8h.cjs → dashboard-json-CSp5bXIV.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-drzAIBe2.js → edit-dashboard-visual-GWiW0jjy.js} +5440 -5453
- package/dist/chunks/{edit-dashboard-visual-DqBcJ1bo.cjs → edit-dashboard-visual-_Wap0YGu.cjs} +11 -11
- package/dist/chunks/{editor-action-buttons-Cm_fqm5R.cjs → editor-action-buttons-BSC0nwgV.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-B8HjvmzM.js → editor-action-buttons-CfZITZwQ.js} +6 -6
- package/dist/chunks/{field-aggregations-C8kZqMTD.js → field-aggregations-CxJWY4Ny.js} +11 -11
- package/dist/chunks/{field-aggregations-naKZ7S2Q.cjs → field-aggregations-DLWbqnBW.cjs} +1 -1
- package/dist/chunks/field-dependencies-BiyQuGxZ.cjs +1 -0
- package/dist/chunks/field-dependencies-CNOgt39w.js +182 -0
- package/dist/chunks/{index-oll4m-qi.js → index-BJfUMDHc.js} +42 -42
- package/dist/chunks/{index-CCa-A-Yx.cjs → index-C3RHKD3d.cjs} +1 -1
- package/dist/chunks/index-DhBGtRkR.cjs +1417 -0
- package/dist/chunks/{index-Cg8HZmMI.js → index-DjbQVfS6.js} +37381 -37119
- package/dist/chunks/{matrix-analytical-definition-BK5y9XHH.cjs → matrix-analytical-definition-DbaMwlWM.cjs} +1 -1
- package/dist/chunks/{matrix-analytical-definition-B1xhoCak.js → matrix-analytical-definition-s10yOPft.js} +1 -1
- package/dist/chunks/{matrix-card-Ii8yYSnw.cjs → matrix-card-BitrcBVw.cjs} +1 -1
- package/dist/chunks/{matrix-card-BEb6hr8i.js → matrix-card-DGpXdK_Y.js} +2 -2
- package/dist/chunks/{matrix-control-sources-CdegRBcA.cjs → matrix-control-sources-DdfST7Fo.cjs} +1 -1
- package/dist/chunks/{matrix-control-sources-cbYmqWNg.js → matrix-control-sources-Dxh6hOU9.js} +10 -10
- package/dist/chunks/{matrix-definition-CZM5-YJX.js → matrix-definition-AP5W3wGc.js} +1 -1
- package/dist/chunks/{matrix-definition-CSNthxru.cjs → matrix-definition-C33isJ3k.cjs} +1 -1
- package/dist/chunks/{matrix-formatter-CiXzpX6X.js → matrix-formatter-CZYFhdZ0.js} +44 -44
- package/dist/chunks/{matrix-formatter-C19PZAal.cjs → matrix-formatter-UCXQxvV3.cjs} +1 -1
- package/dist/chunks/{matrix-member-presentation-CabW8mJc.js → matrix-member-presentation-5-M0obIa.js} +1 -1
- package/dist/chunks/{matrix-member-presentation-CQHvq18l.cjs → matrix-member-presentation-DgIq9UG9.cjs} +1 -1
- package/dist/chunks/{matrix-operation-contract-0Nor-C71.js → matrix-operation-contract-BFumahBa.js} +21 -21
- package/dist/chunks/{matrix-operation-contract-o9GXbiHw.cjs → matrix-operation-contract-C0-V685e.cjs} +1 -1
- package/dist/chunks/{metric-comparison-DeiOjEm5.cjs → metric-comparison-ClKUI7Tu.cjs} +1 -1
- package/dist/chunks/{metric-comparison-Br8l0WkK.js → metric-comparison-Df3HmmUE.js} +1 -1
- package/dist/chunks/{pivot-header-presentation-DW-ti5ek.js → pivot-header-presentation-CAmKYLgn.js} +3 -3
- package/dist/chunks/{pivot-header-presentation-DRv-cSIP.cjs → pivot-header-presentation-CGWDx1V_.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-DEenUrMj.cjs → pivot-result-identity-0grcK7bY.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-sZc1RaIz.js → pivot-result-identity-DBeK76wx.js} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-D81qcCcZ.cjs → pivot-result-lifecycle-CC0jWMFT.cjs} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-DJ40gdwk.js → pivot-result-lifecycle-DVPJg7Gg.js} +7 -7
- package/dist/chunks/{raw-temporal-DDTt2yv5.cjs → raw-temporal-Kc3mdzH7.cjs} +1 -1
- package/dist/chunks/{raw-temporal-DHCZrFe7.js → raw-temporal-T3PEaGmJ.js} +2 -2
- package/dist/chunks/{raw-temporal-contract-CkvdtPYA.js → raw-temporal-contract-Ck5vJoQ6.js} +1 -1
- package/dist/chunks/{raw-temporal-contract-BcbV56Rc.cjs → raw-temporal-contract-SwtP1jSh.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-KI7AgU11.js → report-preferences-dialog-B8DdDM7q.js} +6 -6
- package/dist/chunks/{report-preferences-dialog-BOGeoFLL.cjs → report-preferences-dialog-BcaEOgn2.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-BlDpc-F-.js → report-runtime-context-BziN1eg9.js} +1 -1
- package/dist/chunks/{report-runtime-context-lSIvyKm2.cjs → report-runtime-context-D3t8vyl9.cjs} +1 -1
- package/dist/chunks/{semantic-format-ew5zviaT.js → semantic-format-A3k--fpE.js} +2 -2
- package/dist/chunks/{semantic-format--_VEin18.cjs → semantic-format-Ca-sdETk.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-DPjslVgx.cjs → source-entity-resolution-CTUzMH2S.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-79Rihbk3.js → source-entity-resolution-DX9C1ebK.js} +20 -20
- package/dist/chunks/{switch-wR8lV0zN.cjs → switch-CgycqpWv.cjs} +22 -22
- package/dist/chunks/{switch-DlLDM7Pu.js → switch-DV8zX7rV.js} +1306 -1295
- package/dist/chunks/{temporal-bucket-contract-BYR6tj6F.cjs → temporal-bucket-contract-BBdvWsY0.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-C-kKQ_W4.js → temporal-bucket-contract-lq7Jrif0.js} +1 -1
- package/dist/chunks/{update-policy-BCtFr2Qh.cjs → update-policy-DIw_H9RT.cjs} +1 -1
- package/dist/chunks/{update-policy-CP_A1IVD.js → update-policy-EgZ1nRbd.js} +2 -2
- package/dist/chunks/{validators-D-_IT-Xw.js → validators-CvLOGzT3.js} +291 -286
- package/dist/chunks/validators-mhiJSia7.cjs +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +9 -9
- 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 +232 -232
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +2 -2
- 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 +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.js +57 -56
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +31 -21
- package/dist/types/main.d.ts +9 -0
- package/dist/types/types.d.ts +107 -0
- package/package.json +1 -1
- package/dist/chunks/index-B8-qrqSa.cjs +0 -1417
- package/dist/chunks/token-types-BIYFAsGq.js +0 -8
- package/dist/chunks/token-types-CkAGFhiW.cjs +0 -1
- package/dist/chunks/validators-ux2obZB9.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./validators-
|
|
1
|
+
"use strict";const u=require("./validators-mhiJSia7.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 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./validators-
|
|
1
|
+
"use strict";const o=require("./validators-mhiJSia7.cjs");require("./matrix-operation-contract-C0-V685e.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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./matrix-operation-contract-
|
|
1
|
+
import { n as a, o as s, q as f } from "./validators-CvLOGzT3.js";
|
|
2
|
+
import "./matrix-operation-contract-BFumahBa.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" };
|
package/dist/chunks/{matrix-control-sources-CdegRBcA.cjs → matrix-control-sources-DdfST7Fo.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-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;
|
|
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-mhiJSia7.cjs");require("./matrix-operation-contract-C0-V685e.cjs");const Y=require("./calculated-field-identity-CEzmY7Bi.cjs"),de=require("./field-aggregations-DLWbqnBW.cjs"),ue=require("zod"),Z=require("./matrix-card-BitrcBVw.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-cbYmqWNg.js → matrix-control-sources-Dxh6hOU9.js}
RENAMED
|
@@ -2,13 +2,13 @@ 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 {
|
|
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 { O as ne, A as oe, aX as B, B as ie, aj as P, ah as se, q as j, Y as ae } from "./validators-CvLOGzT3.js";
|
|
6
|
+
import "./matrix-operation-contract-BFumahBa.js";
|
|
7
|
+
import { g as ce, r as le } from "./calculated-field-identity-BGIPbwBx.js";
|
|
8
|
+
import { g as de } from "./field-aggregations-CxJWY4Ny.js";
|
|
9
9
|
import { ZodError as ue } from "zod";
|
|
10
|
-
import { a as
|
|
11
|
-
import { m as
|
|
10
|
+
import { a as Y } from "./matrix-card-DGpXdK_Y.js";
|
|
11
|
+
import { m as H, a as Z } from "./constants-DeLIHVAW.js";
|
|
12
12
|
function ge(t, e) {
|
|
13
13
|
const r = Ie(t);
|
|
14
14
|
let i;
|
|
@@ -89,7 +89,7 @@ function De(t) {
|
|
|
89
89
|
const e = t.match(me);
|
|
90
90
|
if (!e) return NaN;
|
|
91
91
|
const n = L(e[1]), r = L(e[2]), i = L(e[3]);
|
|
92
|
-
return we(n, r, i) ? n *
|
|
92
|
+
return we(n, r, i) ? n * H + r * Z + i * 1e3 : NaN;
|
|
93
93
|
}
|
|
94
94
|
function L(t) {
|
|
95
95
|
return t && parseFloat(t.replace(",", ".")) || 0;
|
|
@@ -99,7 +99,7 @@ function Oe(t) {
|
|
|
99
99
|
const e = t.match(_e);
|
|
100
100
|
if (!e) return 0;
|
|
101
101
|
const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
|
|
102
|
-
return ye(r, i) ? n * (r *
|
|
102
|
+
return ye(r, i) ? n * (r * H + i * Z) : NaN;
|
|
103
103
|
}
|
|
104
104
|
function Te(t, e, n) {
|
|
105
105
|
const r = /* @__PURE__ */ new Date(0);
|
|
@@ -489,11 +489,11 @@ function J(t, e) {
|
|
|
489
489
|
return n;
|
|
490
490
|
}
|
|
491
491
|
function rt(t, e = [], n = []) {
|
|
492
|
-
return j([...
|
|
492
|
+
return j([...Y(t), ...J(e), ...n]);
|
|
493
493
|
}
|
|
494
494
|
function nt(t, e = {}) {
|
|
495
495
|
const n = e.controlBindings ?? [], r = X(e.controlDefinitions ?? [], e.cardControlDefinitions ?? []), i = new Map(n.filter((s) => s.target === "config_field_selector" || s.target === "config_metric_selector").map((s) => [s, Q({ binding: s, definitions: r, controlValues: e.controlValues })]));
|
|
496
|
-
return j([...
|
|
496
|
+
return j([...Y(t), ...J(n, i)]);
|
|
497
497
|
}
|
|
498
498
|
export {
|
|
499
499
|
Je as C,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./validators-
|
|
1
|
+
"use strict";const i=require("./validators-mhiJSia7.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,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./matrix-operation-contract-
|
|
3
|
-
import { t as
|
|
4
|
-
import { f as k, s as U, k as z, j as V, b as X } from "./raw-temporal-
|
|
5
|
-
import { b as p, c as
|
|
1
|
+
import { b1 as L, N as T, ah as _ } from "./validators-CvLOGzT3.js";
|
|
2
|
+
import "./matrix-operation-contract-BFumahBa.js";
|
|
3
|
+
import { t as h, 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-A3k--fpE.js";
|
|
4
|
+
import { f as k, s as U, k as z, j as V, b as X } from "./raw-temporal-T3PEaGmJ.js";
|
|
5
|
+
import { b as p, c as M } from "./constants-DeLIHVAW.js";
|
|
6
6
|
import { f as j } from "./index-CACdoqu3.js";
|
|
7
7
|
import { d as E, f as Y } from "./temporal-bucket-B9hMwemw.js";
|
|
8
|
-
const
|
|
8
|
+
const w = [
|
|
9
9
|
"day",
|
|
10
10
|
"hour",
|
|
11
11
|
"minute",
|
|
@@ -36,12 +36,12 @@ function H(e) {
|
|
|
36
36
|
function v(e, t) {
|
|
37
37
|
return H(e) ? e : t;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function N(e, t) {
|
|
40
|
+
return w.indexOf(v(e, t));
|
|
41
41
|
}
|
|
42
42
|
function W(e, t) {
|
|
43
|
-
const n =
|
|
44
|
-
return
|
|
43
|
+
const n = N(e, "day"), s = N(t, "second"), r = Math.min(n, s), o = Math.max(n, s);
|
|
44
|
+
return w.slice(r, o + 1);
|
|
45
45
|
}
|
|
46
46
|
function G(e, t) {
|
|
47
47
|
return e * b[v(t, "second")];
|
|
@@ -88,14 +88,14 @@ function te(e, t = {}) {
|
|
|
88
88
|
return ee(c, o, t);
|
|
89
89
|
}
|
|
90
90
|
function g(e, t) {
|
|
91
|
-
const n =
|
|
91
|
+
const n = h(e), s = h(t), r = n.getTime() - s.getTime();
|
|
92
92
|
return r < 0 ? -1 : r > 0 ? 1 : r;
|
|
93
93
|
}
|
|
94
94
|
function ne(e) {
|
|
95
95
|
return P(e, Date.now());
|
|
96
96
|
}
|
|
97
97
|
function re(e, t) {
|
|
98
|
-
const n =
|
|
98
|
+
const n = h(e), s = h(t), r = n.getFullYear() - s.getFullYear(), o = n.getMonth() - s.getMonth();
|
|
99
99
|
return r * 12 + o;
|
|
100
100
|
}
|
|
101
101
|
function se(e) {
|
|
@@ -105,22 +105,22 @@ function se(e) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
function oe(e, t) {
|
|
108
|
-
return +
|
|
108
|
+
return +h(e) - +h(t);
|
|
109
109
|
}
|
|
110
110
|
function ae(e) {
|
|
111
|
-
const t =
|
|
111
|
+
const t = h(e);
|
|
112
112
|
return t.setHours(23, 59, 59, 999), t;
|
|
113
113
|
}
|
|
114
114
|
function ie(e) {
|
|
115
|
-
const t =
|
|
115
|
+
const t = h(e), n = t.getMonth();
|
|
116
116
|
return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
|
|
117
117
|
}
|
|
118
118
|
function ue(e) {
|
|
119
|
-
const t =
|
|
119
|
+
const t = h(e);
|
|
120
120
|
return +ae(t) == +ie(t);
|
|
121
121
|
}
|
|
122
122
|
function ce(e, t) {
|
|
123
|
-
const n =
|
|
123
|
+
const n = h(e), s = h(t), r = g(n, s), o = Math.abs(
|
|
124
124
|
re(n, s)
|
|
125
125
|
);
|
|
126
126
|
let u;
|
|
@@ -129,7 +129,7 @@ function ce(e, t) {
|
|
|
129
129
|
else {
|
|
130
130
|
n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * o);
|
|
131
131
|
let a = g(n, s) === -r;
|
|
132
|
-
ue(
|
|
132
|
+
ue(h(e)) && o === 1 && g(e, s) === 1 && (a = !1), u = r * (o - Number(a));
|
|
133
133
|
}
|
|
134
134
|
return u === 0 ? 0 : u;
|
|
135
135
|
}
|
|
@@ -146,9 +146,9 @@ function fe(e, t, n) {
|
|
|
146
146
|
comparison: u
|
|
147
147
|
});
|
|
148
148
|
let c, i;
|
|
149
|
-
u > 0 ? (c =
|
|
149
|
+
u > 0 ? (c = h(t), i = h(e)) : (c = h(e), i = h(t));
|
|
150
150
|
const m = le(i, c), f = (x(i) - x(c)) / 1e3, l = Math.round((m - f) / 60);
|
|
151
|
-
let
|
|
151
|
+
let d;
|
|
152
152
|
if (l < 2)
|
|
153
153
|
return n != null && n.includeSeconds ? m < 5 ? r.formatDistance("lessThanXSeconds", 5, a) : m < 10 ? r.formatDistance("lessThanXSeconds", 10, a) : m < 20 ? r.formatDistance("lessThanXSeconds", 20, a) : m < 40 ? r.formatDistance("halfAMinute", 0, a) : m < 60 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", 1, a) : l === 0 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", l, a);
|
|
154
154
|
if (l < 45)
|
|
@@ -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 y = Math.round(l / 60);
|
|
160
|
+
return r.formatDistance("aboutXHours", y, 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
|
|
164
|
+
if (l < M) {
|
|
165
|
+
const y = Math.round(l / p);
|
|
166
|
+
return r.formatDistance("xDays", y, a);
|
|
167
|
+
} else if (l < M * 2)
|
|
168
|
+
return d = Math.round(l / M), r.formatDistance("aboutXMonths", d, a);
|
|
169
169
|
}
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
return r.formatDistance("xMonths",
|
|
170
|
+
if (d = ce(i, c), d < 12) {
|
|
171
|
+
const y = Math.round(l / M);
|
|
172
|
+
return r.formatDistance("xMonths", y, a);
|
|
173
173
|
} else {
|
|
174
|
-
const
|
|
175
|
-
return
|
|
174
|
+
const y = d % 12, D = Math.trunc(d / 12);
|
|
175
|
+
return y < 3 ? r.formatDistance("aboutXYears", D, a) : y < 9 ? r.formatDistance("overXYears", D, a) : r.formatDistance("almostXYears", D + 1, a);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
function me(e, t) {
|
|
@@ -219,19 +219,19 @@ function I(e, t = "auto") {
|
|
|
219
219
|
return new Date(e);
|
|
220
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
|
-
const
|
|
222
|
+
const he = "MM/dd/yyyy", de = (e, t, n, s = "auto") => {
|
|
223
223
|
if (!e)
|
|
224
224
|
return "";
|
|
225
225
|
try {
|
|
226
226
|
const r = I(e, s);
|
|
227
227
|
if (isNaN(r.getTime()))
|
|
228
228
|
return e;
|
|
229
|
-
const u = (t && t.trim() ? t :
|
|
229
|
+
const u = (t && t.trim() ? t : he).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
|
|
230
230
|
return n && n !== "auto" ? O(r, n, u) : A(r, u);
|
|
231
231
|
} catch (r) {
|
|
232
232
|
return console.error("Date formatting error:", r), e;
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, ye = (e, t = "auto") => {
|
|
235
235
|
if (!e)
|
|
236
236
|
return "";
|
|
237
237
|
try {
|
|
@@ -241,15 +241,15 @@ 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 Me(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 ye(
|
|
248
248
|
r,
|
|
249
249
|
(t == null ? void 0 : t.sourceTimezone) || "auto"
|
|
250
250
|
);
|
|
251
251
|
const a = t != null && t.useCustomFormat && (t != null && t.customFormat) ? t.customFormat : (t == null ? void 0 : t.format) || "MM/dd/yyyy";
|
|
252
|
-
return
|
|
252
|
+
return de(
|
|
253
253
|
r,
|
|
254
254
|
a,
|
|
255
255
|
t != null && t.timezone && (t == null ? void 0 : t.timezone) !== "auto" ? t.timezone : u ? o : n,
|
|
@@ -271,7 +271,7 @@ function S(e, t, n) {
|
|
|
271
271
|
n.locale
|
|
272
272
|
) : String(r);
|
|
273
273
|
case "date":
|
|
274
|
-
return
|
|
274
|
+
return Me(
|
|
275
275
|
r,
|
|
276
276
|
t.dateFormat,
|
|
277
277
|
n.timezone,
|
|
@@ -358,7 +358,7 @@ function Ae(e, t, n) {
|
|
|
358
358
|
locale: n.valueFormat.locale,
|
|
359
359
|
styles: { dateStyle: n.valueFormat.dateStyle, dateTime: n.valueFormat.dateTime }
|
|
360
360
|
});
|
|
361
|
-
return (
|
|
361
|
+
return (d) => typeof d == "string" ? Y({ value: d, metadata: f, format: l.format }) : m(d);
|
|
362
362
|
}
|
|
363
363
|
if (o.column.rawTemporal) {
|
|
364
364
|
const f = U({
|
|
@@ -380,8 +380,8 @@ function Ae(e, t, n) {
|
|
|
380
380
|
});
|
|
381
381
|
return (l) => {
|
|
382
382
|
if (typeof l != "string") return m(l);
|
|
383
|
-
const
|
|
384
|
-
return
|
|
383
|
+
const d = f(l);
|
|
384
|
+
return d.ok ? d.text : m(l);
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
if (R(i)) {
|
|
@@ -408,9 +408,9 @@ export {
|
|
|
408
408
|
Oe as b,
|
|
409
409
|
Ce as c,
|
|
410
410
|
te as d,
|
|
411
|
-
|
|
411
|
+
de as e,
|
|
412
412
|
Pe as f,
|
|
413
|
-
|
|
413
|
+
ye as g,
|
|
414
414
|
Le as h,
|
|
415
415
|
_e as i,
|
|
416
416
|
I as j,
|
|
@@ -1 +1 @@
|
|
|
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
|
+
"use strict";const T=require("./validators-mhiJSia7.cjs");require("./matrix-operation-contract-C0-V685e.cjs");const f=require("./semantic-format-Ca-sdETk.cjs"),y=require("./raw-temporal-Kc3mdzH7.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 +1 @@
|
|
|
1
|
-
"use strict";const u=require("./validators-
|
|
1
|
+
"use strict";const u=require("./validators-mhiJSia7.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;
|
package/dist/chunks/{matrix-operation-contract-0Nor-C71.js → matrix-operation-contract-BFumahBa.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z as r } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
2
|
+
import { H as g, z as W, O as N, b7 as V, N as v, I as be, a$ as J, b8 as ve, aI as $e, A as Se, m as we, j as ke, aZ as Ie, aN as Ae, aO as _e, aR as Re, aS as qe, aB as C, aG as D, au as Ce, aL as je, aM as X, as as Ee, aq as m, ar as xe, aH as Fe } from "./validators-CvLOGzT3.js";
|
|
3
|
+
const T = {
|
|
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(), M = 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(), Te = 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: Te,
|
|
199
199
|
pages: r.array(Be).readonly(),
|
|
200
200
|
blocks: r.array(De).readonly(),
|
|
201
|
-
failures: r.array(
|
|
201
|
+
failures: r.array(M).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: M }).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"]), Me = 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(Me).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(T).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(), Ts = 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(Ts),
|
|
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
|
+
}), Ms = new Set(
|
|
1557
|
+
Object.keys(T)
|
|
1558
1558
|
);
|
|
1559
1559
|
function et() {
|
|
1560
1560
|
return Object.keys(
|
|
1561
|
-
|
|
1561
|
+
T
|
|
1562
1562
|
);
|
|
1563
1563
|
}
|
|
1564
1564
|
function Ps(i) {
|
|
1565
|
-
return
|
|
1565
|
+
return Ms.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: M.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
|
+
M as A,
|
|
1598
|
+
Te as B,
|
|
1599
1599
|
se as C,
|
|
1600
1600
|
Ys as D,
|
|
1601
|
-
|
|
1601
|
+
Me 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
|
+
T as c,
|
|
1615
1615
|
Es as d,
|
|
1616
1616
|
pe as e,
|
|
1617
1617
|
me as f,
|