@malloydata/render 0.0.328 → 0.0.330

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.
@@ -1,4 +1,11 @@
1
1
  import { RenderTimeStringOptions } from '../util';
2
2
  import { Field } from '../data_tree';
3
3
  export declare function renderNumericField(f: Field, value: number | null | undefined): string;
4
+ /**
5
+ * Render a big number value (stored as string for precision).
6
+ * Used when NumberCell.stringValue is defined (bigint/bigdecimal subtypes).
7
+ * Default formatting preserves full precision with comma separators.
8
+ * Explicit format tags (currency, percent, etc.) may be lossy for values > 2^53.
9
+ */
10
+ export declare function renderBigNumberField(f: Field, value: string | null | undefined): string;
4
11
  export declare function renderDateTimeField(f: Field, value: Date | null | undefined, options?: RenderTimeStringOptions): string;
@@ -10,38 +10,46 @@ export declare class NullCell extends CellBase {
10
10
  get value(): null;
11
11
  get literalValue(): Malloy.LiteralValue | undefined;
12
12
  }
13
+ /** Type for either regular or big number cells from Thrift */
14
+ type NumberCellInput = Malloy.CellWithNumberCell | Malloy.CellWithBigNumberCell;
15
+ /**
16
+ * Unified cell for all numeric values.
17
+ * Handles both regular numbers and big numbers (bigint/bigdecimal).
18
+ */
13
19
  export declare class NumberCell extends CellBase {
14
- readonly cell: Malloy.CellWithNumberCell;
20
+ readonly cell: NumberCellInput;
15
21
  readonly field: NumberField;
16
22
  readonly parent: NestCell | undefined;
17
- constructor(cell: Malloy.CellWithNumberCell, field: NumberField, parent: NestCell | undefined);
18
- get value(): number;
23
+ private readonly _value;
24
+ private readonly _stringValue;
25
+ constructor(cell: NumberCellInput, field: NumberField, parent: NestCell | undefined);
19
26
  /**
20
27
  * Returns the numeric value as a JS number.
21
- * For NumberCell, this is the same as `.value`.
28
+ * May be lossy for bigint/bigdecimal values > 2^53.
22
29
  */
23
- number(): number;
24
- compareTo(other: Cell): 1 | 0 | -1;
25
- get literalValue(): Malloy.LiteralValue | undefined;
26
- }
27
- export declare class BigNumberCell extends CellBase {
28
- readonly cell: Malloy.CellWithBigNumberCell;
29
- readonly field: NumberField;
30
- readonly parent: NestCell | undefined;
31
- constructor(cell: Malloy.CellWithBigNumberCell, field: NumberField, parent: NestCell | undefined);
30
+ get value(): number;
32
31
  /**
33
- * Returns the string representation of the big number value.
34
- * Use this for display or when precision matters.
32
+ * Returns the precise string representation for large values.
33
+ * Undefined for regular numbers that fit in JS number.
35
34
  */
36
- get value(): string;
35
+ get stringValue(): string | undefined;
36
+ /**
37
+ * Returns the number subtype from the schema.
38
+ * 'integer' | 'decimal' | 'bigint' | future 'bigdecimal'
39
+ */
40
+ get subtype(): Malloy.NumberSubtype | undefined;
37
41
  /**
38
- * Returns the value as a JS number (potentially lossy for large values).
39
- * Use this when a number is required (e.g., for charts, calculations).
42
+ * Returns true if this value needs string representation for precision.
43
+ */
44
+ needsStringPrecision(): boolean;
45
+ /**
46
+ * Returns the numeric value as a JS number.
47
+ * Alias for .value for API consistency.
40
48
  */
41
- number(): number;
49
+ numberValue(): number;
42
50
  /**
43
51
  * Returns the value as a JS BigInt for precise integer arithmetic.
44
- * Only valid when subtype is 'bigint'.
52
+ * Only valid when stringValue is defined and subtype is 'bigint'.
45
53
  */
46
54
  bigint(): bigint;
47
55
  compareTo(other: Cell): 1 | 0 | -1;
@@ -101,3 +109,4 @@ export declare class BooleanCell extends CellBase {
101
109
  compareTo(other: Cell): 1 | 0 | -1;
102
110
  get literalValue(): Malloy.LiteralValue | undefined;
103
111
  }
112
+ export {};
@@ -1,4 +1,4 @@
1
- import { Cell, NestCell, RecordCell, ArrayCell, BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, RepeatedRecordCell, StringCell, TimestampCell, TimeCell, RecordOrRepeatedRecordCell, CellValue } from '.';
1
+ import { Cell, NestCell, RecordCell, ArrayCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, RepeatedRecordCell, StringCell, TimestampCell, TimeCell, RecordOrRepeatedRecordCell, CellValue } from '.';
2
2
  import { Field } from '../fields';
3
3
  import { DrillEntry } from '../types';
4
4
  import type * as Malloy from '@malloydata/malloy-interfaces';
@@ -16,7 +16,6 @@ export declare abstract class CellBase {
16
16
  isRecordOrRepeatedRecord(): this is RecordOrRepeatedRecordCell;
17
17
  isNest(): this is NestCell;
18
18
  isNumber(): this is NumberCell;
19
- isBigNumber(): this is BigNumberCell;
20
19
  isDate(): this is DateCell;
21
20
  isTime(): this is TimeCell;
22
21
  isJSON(): this is JSONCell;
@@ -1,13 +1,13 @@
1
1
  import { Field } from '../fields';
2
2
  import { ArrayCell, RecordCell, RepeatedRecordCell } from './nest';
3
- import { BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell } from './atomic';
3
+ import { BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell } from './atomic';
4
4
  import type * as Malloy from '@malloydata/malloy-interfaces';
5
5
  export { ArrayCell, RecordCell, RepeatedRecordCell, RootCell } from './nest';
6
- export { BigNumberCell, BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell, } from './atomic';
6
+ export { BooleanCell, DateCell, JSONCell, NullCell, NumberCell, SQLNativeCell, StringCell, TimestampCell, } from './atomic';
7
7
  export type NestCell = ArrayCell | RecordCell;
8
8
  export type RecordOrRepeatedRecordCell = RepeatedRecordCell | RecordCell;
9
9
  export type TimeCell = DateCell | TimestampCell;
10
- export type Cell = ArrayCell | RecordCell | NullCell | NumberCell | BigNumberCell | DateCell | JSONCell | StringCell | TimestampCell | BooleanCell | SQLNativeCell;
10
+ export type Cell = ArrayCell | RecordCell | NullCell | NumberCell | DateCell | JSONCell | StringCell | TimestampCell | BooleanCell | SQLNativeCell;
11
11
  export type CellValue = string | number | boolean | Date | Cell[] | Record<string, Cell> | null;
12
12
  export declare const Cell: {
13
13
  from(cell: Malloy.Cell, field: Field, parent: NestCell): Cell;