@bluemarble/bi 0.3.1 → 0.5.0

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.
@@ -86,13 +86,17 @@ type ModelDef = {
86
86
  dimensions: Record<string, DimensionDef>;
87
87
  measures: Record<string, MeasureDef>;
88
88
  /**
89
- * Posição de cada card no diagrama do devtools (tabela -> canto superior esquerdo). Só visual: não muda nenhuma consulta. Card sem posição entra no layout automático.
89
+ * Posição de cada card no diagrama do devtools (tabela -> canto superior esquerdo) e, se foi
90
+ * redimensionado, o tamanho. Só visual: não muda nenhuma consulta. Card sem posição entra no
91
+ * layout automático; sem tamanho, tem a largura padrão e a altura do conteúdo.
90
92
  */
91
93
  diagram?: Record<string, DiagramPosition>;
92
94
  };
93
95
  type DiagramPosition = {
94
96
  x: number;
95
97
  y: number;
98
+ width?: number;
99
+ height?: number;
96
100
  };
97
101
  /** Só os metadados (sem SQL): é o que o client recebe fora do devtools. */
98
102
  type ModelMeta = {
@@ -128,15 +132,34 @@ type BaseChartDef = {
128
132
  /** Aparência do card deste gráfico (sobrepõe o `cards` do layout). */
129
133
  card?: CardStyle;
130
134
  };
131
- type ComboChartDef = BaseChartDef & {
135
+ /**
136
+ * Formato de uma medida num gráfico: sobrepõe o `format`/`decimals` do dicionário do modelo só
137
+ * naquele gráfico.
138
+ */
139
+ type ChartNumberFormat = {
140
+ format?: ValueFormat;
141
+ /** Casas decimais (0 a 10). */
142
+ decimals?: number;
143
+ /** Notação curta: 1,2 mil / 3,4 mi. */
144
+ compact?: boolean;
145
+ /** Texto antes do número (ex.: "US$ "). */
146
+ prefix?: string;
147
+ /** Texto depois do número (ex.: " t"). */
148
+ suffix?: string;
149
+ };
150
+ /** Rótulos e formatos do gráfico, por nome de dimensão/medida (sobrepõem o dicionário). */
151
+ type ColumnsDisplay = {
152
+ /** `{ dimensãoOuMedida: 'Rótulo' }`: legenda, tooltip e cabeçalho. */
153
+ labels?: Record<string, string>;
154
+ /** `{ medida: { decimals: 1, ... } }`. */
155
+ formats?: Record<string, ChartNumberFormat>;
156
+ };
157
+ type ComboChartDef = BaseChartDef & ColumnsDisplay & {
132
158
  type: 'combo';
133
159
  dimension: string;
134
160
  bar: string;
135
161
  line: string;
136
162
  detail?: string;
137
- barLabel?: string;
138
- lineLabel?: string;
139
- detailLabel?: string;
140
163
  /** Nome de um formatter passado ao `<DashboardCharts formatters>` (funções não cabem no JSON). */
141
164
  formatDimension?: string;
142
165
  clickToFilter?: boolean;
@@ -145,7 +168,7 @@ type ComboChartDef = BaseChartDef & {
145
168
  barColor?: string;
146
169
  lineColor?: string;
147
170
  };
148
- type BarChartDef = BaseChartDef & {
171
+ type BarChartDef = BaseChartDef & ColumnsDisplay & {
149
172
  type: 'bar';
150
173
  dimension: string;
151
174
  /** Uma série por medida. */
@@ -161,16 +184,18 @@ type BarChartDef = BaseChartDef & {
161
184
  hideEmpty?: boolean;
162
185
  showValues?: boolean;
163
186
  };
164
- type DonutChartDef = BaseChartDef & {
187
+ type DonutChartDef = BaseChartDef & ColumnsDisplay & {
165
188
  type: 'donut';
166
189
  dimension: string;
167
190
  measure: string;
168
191
  /** Fatias além dessa quantidade viram "Outros". */
169
192
  maxSlices?: number;
193
+ /** Casas decimais do percentual. Padrão: 1. */
194
+ percentDecimals?: number;
170
195
  formatDimension?: string;
171
196
  clickToFilter?: boolean;
172
197
  };
173
- type TableChartDef = BaseChartDef & {
198
+ type TableChartDef = BaseChartDef & ColumnsDisplay & {
174
199
  type: 'table';
175
200
  dimensions?: string[];
176
201
  measures: string[];
@@ -179,6 +204,13 @@ type TableChartDef = BaseChartDef & {
179
204
  * está em `measures` é consultada só para o percentual.
180
205
  */
181
206
  percentOf?: string[];
207
+ /** Casas decimais das colunas de percentual. Padrão: 1. */
208
+ percentDecimals?: number;
209
+ /**
210
+ * Ordem das colunas misturando dimensões e medidas (ex.: uma medida antes de uma dimensão).
211
+ * Ausente = dimensões e depois medidas.
212
+ */
213
+ columnOrder?: string[];
182
214
  /** Formatter por dimensão (`{ mes: 'nomeMes' }`). */
183
215
  formatDimensions?: Record<string, string>;
184
216
  /** Linha de total, consultada sem as dimensões (razões saem certas, não somadas). */
@@ -188,13 +220,12 @@ type TableChartDef = BaseChartDef & {
188
220
  sortDirection?: 'asc' | 'desc';
189
221
  clickToFilter?: boolean;
190
222
  };
191
- type KpiChartDef = Omit<BaseChartDef, 'height'> & {
223
+ type KpiChartDef = Omit<BaseChartDef, 'height'> & ColumnsDisplay & {
192
224
  type: 'kpi';
193
225
  /** Medida do número grande (total com os filtros da página). */
194
226
  measure: string;
195
227
  /** Medida extra numa linha menor embaixo (ex.: volume, custo/t). */
196
228
  secondary?: string;
197
- secondaryLabel?: string;
198
229
  };
199
230
  /** Gráficos da lib (`type` em `CHART_TYPES`). */
200
231
  type BuiltinChartDef = KpiChartDef | ComboChartDef | BarChartDef | DonutChartDef | TableChartDef;
@@ -261,7 +292,7 @@ type FieldSpec = {
261
292
  label: string;
262
293
  hint?: string;
263
294
  /** Agrupamento no formulário do devtools. */
264
- section: 'Gráfico' | 'Dados' | 'Aparência' | 'Filtro' | 'Tela' | 'Card';
295
+ section: 'Gráfico' | 'Dados' | 'Aparência' | 'Rótulos e formatos' | 'Filtro' | 'Tela' | 'Card';
265
296
  required?: boolean;
266
297
  /** Valor que o componente usa quando o campo não está no JSON. */
267
298
  default?: unknown;
@@ -297,6 +328,21 @@ type FieldSpec = {
297
328
  /** Uma das dimensões/medidas escolhidas no próprio gráfico. */
298
329
  {
299
330
  kind: 'column';
331
+ } |
332
+ /** `{ dimensãoOuMedida: rótulo }` das colunas do gráfico. */
333
+ {
334
+ kind: 'labels';
335
+ } |
336
+ /** `{ medida: ChartNumberFormat }` das medidas do gráfico. */
337
+ {
338
+ kind: 'formats';
339
+ } |
340
+ /**
341
+ * Ordem das colunas (dimensões e medidas misturadas). O devtools junta os campos `dimensions` e
342
+ * `measures` da mesma seção numa lista só e grava a ordem aqui quando não é a padrão.
343
+ */
344
+ {
345
+ kind: 'columnOrder';
300
346
  });
301
347
  /**
302
348
  * Tipo de gráfico: nome no devtools e campos do JSON. Para um tipo do app, `title`, `span` e
@@ -485,5 +531,5 @@ type DashboardResult = {
485
531
  };
486
532
  };
487
533
  //#endregion
488
- export { KpiChartDef as A, MeasureDef as B, ChartTypes as C, DonutChartDef as D, CustomChartDef as E, AggregateMeasure as F, RelationshipDef as G, ModelDef as H, Aggregation as I, ValueFormat as J, SumMeasure as K, DimensionDef as L, layoutModelWarnings as M, resolveChartTypes as N, FieldSpec as O, validateLayout as P, FieldMeta as R, ChartTypeSpec as S, ComboChartDef as T, ModelMeta as U, MeasureMeta as V, RatioMeasure as W, validateModel as X, modelMeta as Y, CanvasDef as _, DashboardResult as a, ChartDef as b, DevtoolsCapabilities as c, ModelValidation as d, ProfileStep as f, BuiltinChartDef as g, BarChartDef as h, DashboardQueryDebug as i, TableChartDef as j, FilterDef as k, FilterValue as l, SchemaTable as m, DashboardFilters as n, DashboardRow as o, SaveModelResult as p, TableDef as q, DashboardQuery as r, DashboardSnapshot as s, DashboardDevtoolsRequest as t, ModelColumns as u, CardStyle as v, ChartsLayout as w, ChartType as x, CardsStyle as y, FormulaMeasure as z };
489
- //# sourceMappingURL=types-DUJS2Zmx.d.ts.map
534
+ export { FilterDef as A, FormulaMeasure as B, ChartTypeSpec as C, CustomChartDef as D, ComboChartDef as E, validateLayout as F, RatioMeasure as G, MeasureMeta as H, AggregateMeasure as I, TableDef as J, RelationshipDef as K, Aggregation as L, TableChartDef as M, layoutModelWarnings as N, DonutChartDef as O, resolveChartTypes as P, DimensionDef as R, ChartType as S, ChartsLayout as T, ModelDef as U, MeasureDef as V, ModelMeta as W, modelMeta as X, ValueFormat as Y, validateModel as Z, CanvasDef as _, DashboardResult as a, ChartDef as b, DevtoolsCapabilities as c, ModelValidation as d, ProfileStep as f, BuiltinChartDef as g, BarChartDef as h, DashboardQueryDebug as i, KpiChartDef as j, FieldSpec as k, FilterValue as l, SchemaTable as m, DashboardFilters as n, DashboardRow as o, SaveModelResult as p, SumMeasure as q, DashboardQuery as r, DashboardSnapshot as s, DashboardDevtoolsRequest as t, ModelColumns as u, CardStyle as v, ChartTypes as w, ChartNumberFormat as x, CardsStyle as y, FieldMeta as z };
535
+ //# sourceMappingURL=types-FdrY0FOZ.d.ts.map
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as KpiChartDef, B as MeasureDef, C as ChartTypes, D as DonutChartDef, E as CustomChartDef, G as RelationshipDef, H as ModelDef, J as ValueFormat, L as DimensionDef, O as FieldSpec, R as FieldMeta, S as ChartTypeSpec, T as ComboChartDef, U as ModelMeta, V as MeasureMeta, _ as CanvasDef, a as DashboardResult, b as ChartDef, c as DevtoolsCapabilities, d as ModelValidation, f as ProfileStep, g as BuiltinChartDef, h as BarChartDef, i as DashboardQueryDebug, j as TableChartDef, k as FilterDef, l as FilterValue, m as SchemaTable, n as DashboardFilters, o as DashboardRow, p as SaveModelResult, q as TableDef, r as DashboardQuery, s as DashboardSnapshot, t as DashboardDevtoolsRequest, u as ModelColumns, v as CardStyle, w as ChartsLayout, x as ChartType, y as CardsStyle, z as FormulaMeasure } from "./types-DUJS2Zmx.js";
2
- export { type BarChartDef, type BuiltinChartDef, type CanvasDef, type CardStyle, type CardsStyle, type ChartDef, type ChartType, type ChartTypeSpec, type ChartTypes, type ChartsLayout, type ComboChartDef, type CustomChartDef, DashboardDevtoolsRequest, DashboardFilters, DashboardQuery, DashboardQueryDebug, DashboardResult, DashboardRow, DashboardSnapshot, DevtoolsCapabilities, type DimensionDef, type DonutChartDef, type FieldMeta, type FieldSpec, type FilterDef, FilterValue, type FormulaMeasure, type KpiChartDef, type MeasureDef, type MeasureMeta, ModelColumns, type ModelDef, type ModelMeta, ModelValidation, ProfileStep, type RelationshipDef, SaveModelResult, SchemaTable, type TableChartDef, type TableDef, type ValueFormat };
1
+ import { A as FilterDef, B as FormulaMeasure, C as ChartTypeSpec, D as CustomChartDef, E as ComboChartDef, H as MeasureMeta, J as TableDef, K as RelationshipDef, M as TableChartDef, O as DonutChartDef, R as DimensionDef, S as ChartType, T as ChartsLayout, U as ModelDef, V as MeasureDef, W as ModelMeta, Y as ValueFormat, _ as CanvasDef, a as DashboardResult, b as ChartDef, c as DevtoolsCapabilities, d as ModelValidation, f as ProfileStep, g as BuiltinChartDef, h as BarChartDef, i as DashboardQueryDebug, j as KpiChartDef, k as FieldSpec, l as FilterValue, m as SchemaTable, n as DashboardFilters, o as DashboardRow, p as SaveModelResult, r as DashboardQuery, s as DashboardSnapshot, t as DashboardDevtoolsRequest, u as ModelColumns, v as CardStyle, w as ChartTypes, x as ChartNumberFormat, y as CardsStyle, z as FieldMeta } from "./types-FdrY0FOZ.js";
2
+ export { type BarChartDef, type BuiltinChartDef, type CanvasDef, type CardStyle, type CardsStyle, type ChartDef, type ChartNumberFormat, type ChartType, type ChartTypeSpec, type ChartTypes, type ChartsLayout, type ComboChartDef, type CustomChartDef, DashboardDevtoolsRequest, DashboardFilters, DashboardQuery, DashboardQueryDebug, DashboardResult, DashboardRow, DashboardSnapshot, DevtoolsCapabilities, type DimensionDef, type DonutChartDef, type FieldMeta, type FieldSpec, type FilterDef, FilterValue, type FormulaMeasure, type KpiChartDef, type MeasureDef, type MeasureMeta, ModelColumns, type ModelDef, type ModelMeta, ModelValidation, ProfileStep, type RelationshipDef, SaveModelResult, SchemaTable, type TableChartDef, type TableDef, type ValueFormat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluemarble/bi",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Camada semântica (defineModel) + componentes de dashboard e devtools para substituir o Power BI",
5
5
  "license": "MIT",
6
6
  "author": "bluemarble",