bways-report 0.2.8 → 0.2.10

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.
Files changed (125) hide show
  1. package/README.md +6 -1
  2. package/esm2022/lib/core/config/bways-report-config.mjs +4 -1
  3. package/esm2022/lib/core/formula/format.mjs +65 -0
  4. package/esm2022/lib/core/formula/formula-columns.mjs +70 -0
  5. package/esm2022/lib/core/formula/formula-engine.mjs +271 -0
  6. package/esm2022/lib/core/formula/formula.types.mjs +24 -0
  7. package/esm2022/lib/core/formula/functions.mjs +122 -0
  8. package/esm2022/lib/core/formula/index.mjs +7 -0
  9. package/esm2022/lib/core/formula/interpreter.mjs +383 -0
  10. package/esm2022/lib/core/formula/lexer.mjs +92 -0
  11. package/esm2022/lib/core/formula/parser.mjs +323 -0
  12. package/esm2022/lib/core/formula/summary-index.mjs +85 -0
  13. package/esm2022/lib/core/formula/variable-store.mjs +55 -0
  14. package/esm2022/lib/core/index.mjs +2 -1
  15. package/esm2022/lib/core/models/index.mjs +2 -1
  16. package/esm2022/lib/core/models/report-datasource.model.mjs +1 -1
  17. package/esm2022/lib/core/models/report-definition.model.mjs +1 -1
  18. package/esm2022/lib/core/models/report-formula.model.mjs +2 -0
  19. package/esm2022/lib/core/models/report-grid.model.mjs +1 -1
  20. package/esm2022/lib/core/models/report-menu.model.mjs +1 -1
  21. package/esm2022/lib/core/models/report-parameter.model.mjs +1 -1
  22. package/esm2022/lib/core/models/selection-workflow.model.mjs +2 -0
  23. package/esm2022/lib/core/utilities/schema-migration.mjs +5 -5
  24. package/esm2022/lib/core/utils/report-form-values.util.mjs +54 -4
  25. package/esm2022/lib/core/utils/report-menu-route.util.mjs +23 -0
  26. package/esm2022/lib/core/utils/report-parameter.util.mjs +4 -4
  27. package/esm2022/lib/core/utils/report-values.util.mjs +137 -0
  28. package/esm2022/lib/core/utils/selection-workflow.util.mjs +187 -0
  29. package/esm2022/lib/data-access/adapters/endpoint-persistence.adapter.mjs +6 -3
  30. package/esm2022/lib/data-access/adapters/http-persistence.adapter.mjs +6 -3
  31. package/esm2022/lib/data-access/adapters/report-save-response.mjs +11 -0
  32. package/esm2022/lib/data-access/contracts/report-persistence.contract.mjs +3 -1
  33. package/esm2022/lib/features/designer/components/design-canvas/design-canvas.component.mjs +67 -9
  34. package/esm2022/lib/features/designer/components/dialogs/report-import-dialog.component.mjs +333 -0
  35. package/esm2022/lib/features/designer/components/dialogs/report-saved-dialog.component.mjs +24 -6
  36. package/esm2022/lib/features/designer/components/property-editor/formula-editor.component.mjs +538 -0
  37. package/esm2022/lib/features/designer/components/property-editor/parameter-binding-editor.component.mjs +104 -25
  38. package/esm2022/lib/features/designer/components/property-editor/property-editor-action.component.mjs +3 -3
  39. package/esm2022/lib/features/designer/components/property-editor/property-editor-datasource.component.mjs +3 -3
  40. package/esm2022/lib/features/designer/components/property-editor/property-editor-general.component.mjs +3 -3
  41. package/esm2022/lib/features/designer/components/property-editor/property-editor-grid.component.mjs +8 -3
  42. package/esm2022/lib/features/designer/components/property-editor/property-editor-layout.component.mjs +3 -3
  43. package/esm2022/lib/features/designer/components/property-editor/property-editor-report.component.mjs +3 -3
  44. package/esm2022/lib/features/designer/components/property-editor/property-editor-validation.component.mjs +3 -3
  45. package/esm2022/lib/features/designer/components/property-editor/property-editor.component.mjs +39 -4
  46. package/esm2022/lib/features/designer/components/property-editor/selection-workflow-editor.component.mjs +637 -0
  47. package/esm2022/lib/features/designer/components/property-editor/workflow-source-editor.component.mjs +198 -0
  48. package/esm2022/lib/features/designer/components/toolbar/designer-toolbar.component.mjs +81 -5
  49. package/esm2022/lib/features/designer/designer.component.mjs +48 -6
  50. package/esm2022/lib/features/designer/services/designer-endpoints.service.mjs +5 -3
  51. package/esm2022/lib/features/designer/services/designer-fullscreen.service.mjs +91 -0
  52. package/esm2022/lib/features/designer/services/report-template.service.mjs +4 -1
  53. package/esm2022/lib/features/designer/utilities/merge-imported-report.mjs +68 -0
  54. package/esm2022/lib/features/import/crystal-export.model.mjs +10 -0
  55. package/esm2022/lib/features/import/crystal-export.parser.mjs +275 -0
  56. package/esm2022/lib/features/import/crystal-import.mjs +486 -0
  57. package/esm2022/lib/features/import/index.mjs +4 -0
  58. package/esm2022/lib/features/index.mjs +2 -1
  59. package/esm2022/lib/features/persistence/services/report-store.service.mjs +3 -1
  60. package/esm2022/lib/features/persistence/services/schema-validator.service.mjs +20 -3
  61. package/esm2022/lib/features/runtime/dynamic-renderer.component.mjs +65 -23
  62. package/esm2022/lib/features/runtime/report-execution.service.mjs +93 -12
  63. package/esm2022/lib/features/runtime/report-runtime.component.mjs +16 -2
  64. package/esm2022/lib/features/runtime/selection-workflow-panel.component.mjs +120 -0
  65. package/esm2022/lib/features/runtime/selection-workflow.service.mjs +480 -0
  66. package/esm2022/lib/primitives/components/button/rpt-button.component.mjs +3 -1
  67. package/esm2022/lib/primitives/components/icon/rpt-icon.component.mjs +10 -1
  68. package/fesm2022/bways-report.mjs +9712 -4197
  69. package/fesm2022/bways-report.mjs.map +1 -1
  70. package/lib/core/formula/format.d.ts +7 -0
  71. package/lib/core/formula/formula-columns.d.ts +16 -0
  72. package/lib/core/formula/formula-engine.d.ts +83 -0
  73. package/lib/core/formula/formula.types.d.ts +94 -0
  74. package/lib/core/formula/functions.d.ts +21 -0
  75. package/lib/core/formula/index.d.ts +6 -0
  76. package/lib/core/formula/interpreter.d.ts +28 -0
  77. package/lib/core/formula/lexer.d.ts +9 -0
  78. package/lib/core/formula/parser.d.ts +3 -0
  79. package/lib/core/formula/summary-index.d.ts +12 -0
  80. package/lib/core/formula/variable-store.d.ts +12 -0
  81. package/lib/core/index.d.ts +1 -0
  82. package/lib/core/models/index.d.ts +2 -0
  83. package/lib/core/models/report-datasource.model.d.ts +2 -0
  84. package/lib/core/models/report-definition.model.d.ts +8 -0
  85. package/lib/core/models/report-formula.model.d.ts +16 -0
  86. package/lib/core/models/report-grid.model.d.ts +11 -1
  87. package/lib/core/models/report-menu.model.d.ts +18 -0
  88. package/lib/core/models/report-parameter.model.d.ts +7 -0
  89. package/lib/core/models/selection-workflow.model.d.ts +31 -0
  90. package/lib/core/utilities/schema-migration.d.ts +1 -1
  91. package/lib/core/utils/report-form-values.util.d.ts +6 -1
  92. package/lib/core/utils/report-menu-route.util.d.ts +2 -0
  93. package/lib/core/utils/report-values.util.d.ts +7 -0
  94. package/lib/core/utils/selection-workflow.util.d.ts +12 -0
  95. package/lib/data-access/adapters/endpoint-persistence.adapter.d.ts +1 -0
  96. package/lib/data-access/adapters/http-persistence.adapter.d.ts +1 -0
  97. package/lib/data-access/adapters/report-save-response.d.ts +3 -0
  98. package/lib/data-access/contracts/report-persistence.contract.d.ts +4 -0
  99. package/lib/features/designer/components/component-palette/component-palette.component.d.ts +1 -1
  100. package/lib/features/designer/components/design-canvas/design-canvas.component.d.ts +7 -0
  101. package/lib/features/designer/components/dialogs/report-import-dialog.component.d.ts +36 -0
  102. package/lib/features/designer/components/dialogs/report-saved-dialog.component.d.ts +2 -1
  103. package/lib/features/designer/components/property-editor/formula-editor.component.d.ts +80 -0
  104. package/lib/features/designer/components/property-editor/parameter-binding-editor.component.d.ts +31 -1
  105. package/lib/features/designer/components/property-editor/property-editor-grid.component.d.ts +7 -1
  106. package/lib/features/designer/components/property-editor/property-editor.component.d.ts +15 -2
  107. package/lib/features/designer/components/property-editor/selection-workflow-editor.component.d.ts +102 -0
  108. package/lib/features/designer/components/property-editor/workflow-source-editor.component.d.ts +40 -0
  109. package/lib/features/designer/components/toolbar/designer-toolbar.component.d.ts +9 -1
  110. package/lib/features/designer/designer.component.d.ts +6 -0
  111. package/lib/features/designer/services/designer-fullscreen.service.d.ts +20 -0
  112. package/lib/features/designer/utilities/merge-imported-report.d.ts +3 -0
  113. package/lib/features/import/crystal-export.model.d.ts +139 -0
  114. package/lib/features/import/crystal-export.parser.d.ts +17 -0
  115. package/lib/features/import/crystal-import.d.ts +21 -0
  116. package/lib/features/import/index.d.ts +3 -0
  117. package/lib/features/index.d.ts +1 -0
  118. package/lib/features/runtime/dynamic-renderer.component.d.ts +8 -1
  119. package/lib/features/runtime/report-execution.service.d.ts +9 -0
  120. package/lib/features/runtime/report-grid-bridge.component.d.ts +3 -0
  121. package/lib/features/runtime/report-runtime.component.d.ts +2 -0
  122. package/lib/features/runtime/selection-workflow-panel.component.d.ts +16 -0
  123. package/lib/features/runtime/selection-workflow.service.d.ts +110 -0
  124. package/lib/primitives/components/button/rpt-button.component.d.ts +1 -1
  125. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ /** Formats a date with patterns such as dd/MM/yyyy, d MMM yyyy, HH:mm:ss. */
2
+ export declare function formatDate(d: Date, pattern: string): string;
3
+ /** Rounds half away from zero (the way Crystal's Round behaves), avoiding binary float surprises. */
4
+ export declare function roundHalfAway(n: number, places?: number): number;
5
+ export declare function formatNumber(n: number, decimals?: number, thousandSep?: string, decimalSep?: string): string;
6
+ /** Lenient conversion of common date text (yyyyMMdd, ISO, dd/MM/yyyy) to a Date; null if it is not a date. */
7
+ export declare function toDate(value: unknown): Date | null;
@@ -0,0 +1,16 @@
1
+ import { ReportDefinition } from '../models/report-definition.model';
2
+ export interface FormulaColumnResult {
3
+ rows: unknown[];
4
+ /** First runtime error per formula (the cell itself is left null). */
5
+ rowErrors: Record<string, string>;
6
+ }
7
+ /** Design-time problems with a report's formulas and the grid columns that use them. Empty when fine. */
8
+ export declare function formulaDefinitionErrors(def: ReportDefinition): string[];
9
+ /**
10
+ * Adds the value of each formula column to every row, in one ordered pass over the rows.
11
+ * Cells hold stored values, so rendering, sorting and export never re-run a formula.
12
+ *
13
+ * Throws when the formula definitions themselves are invalid. A data problem in one row
14
+ * (for example a null where text is required) leaves that cell null and is reported in `rowErrors`.
15
+ */
16
+ export declare function applyFormulaColumns(def: ReportDefinition, rows: unknown[], params?: Record<string, unknown>): FormulaColumnResult;
@@ -0,0 +1,83 @@
1
+ import { FormulaDiagnostic, FormulaPhase, FormulaReferences, FormulaValue, Program, ValueKind } from './formula.types';
2
+ export interface FormulaDefinition {
3
+ /** Formula name, referenced elsewhere as {@name}. */
4
+ name: string;
5
+ /** Formula text in Crystal syntax. */
6
+ body: string;
7
+ /** 'default' = treat null as "", 0 or false in operators (Crystal's "default values for nulls"). */
8
+ nullHandling?: 'null' | 'default';
9
+ }
10
+ export interface CheckOptions {
11
+ /** When given, references not in these lists are reported. Names are matched case-insensitively. */
12
+ knownFields?: string[];
13
+ knownParams?: string[];
14
+ knownFormulas?: string[];
15
+ }
16
+ export interface FormulaCheckResult {
17
+ ok: boolean;
18
+ diagnostics: FormulaDiagnostic[];
19
+ references: FormulaReferences;
20
+ phase?: FormulaPhase;
21
+ resultKind: ValueKind | null;
22
+ /** True when the formula declares variables (state that can carry across records). */
23
+ declaresVariables: boolean;
24
+ program?: Program;
25
+ }
26
+ /** Parses a formula and reports syntax errors, unknown functions and unknown references. Never throws. */
27
+ export declare function checkFormula(body: string, options?: CheckOptions): FormulaCheckResult;
28
+ interface Compiled {
29
+ def: FormulaDefinition;
30
+ check: FormulaCheckResult;
31
+ }
32
+ export interface FormulaRunOptions {
33
+ /** Full result dataset; aggregates must never use only the visible page or preview slice. */
34
+ rows?: readonly unknown[];
35
+ /** Parent-to-child Grid grouping fields. */
36
+ groupFields?: readonly string[];
37
+ /** Maximum evaluation steps per record; stops runaway formulas. Default 100000. */
38
+ maxStepsPerRow?: number;
39
+ /** Clock used by CurrentDate; set for repeatable tests. */
40
+ now?: Date;
41
+ }
42
+ /**
43
+ * Compiles a set of named formulas once and runs them over records.
44
+ * Create one run per report execution; variable state lives in the run.
45
+ */
46
+ export declare class FormulaEngine {
47
+ private readonly compiled;
48
+ readonly diagnostics: Map<string, FormulaDiagnostic[]>;
49
+ constructor(defs: FormulaDefinition[]);
50
+ has(name: string): boolean;
51
+ /** Static information about one formula: references, phase, inferred result type. */
52
+ info(name: string): FormulaCheckResult | undefined;
53
+ createRun(params?: Record<string, unknown>, options?: FormulaRunOptions): FormulaRun;
54
+ /** @internal */
55
+ get(name: string): Compiled | undefined;
56
+ private detectCycles;
57
+ }
58
+ /** One report execution: owns the global variable state, so counters start fresh each run. */
59
+ export declare class FormulaRun {
60
+ private readonly engine;
61
+ private readonly summaries;
62
+ private readonly globals;
63
+ private readonly params;
64
+ private readonly now;
65
+ private readonly maxSteps;
66
+ constructor(engine: FormulaEngine, params: Record<string, unknown>, options: FormulaRunOptions);
67
+ /**
68
+ * Evaluates the named formulas for one record, in the order given. Call records in report order:
69
+ * formulas that keep variables (counters) depend on it. Formulas referenced via {@name} run on demand.
70
+ */
71
+ evaluateRow(row: Record<string, unknown>, rowIndex: number, names: string[]): Record<string, FormulaValue>;
72
+ /**
73
+ * Like evaluateRow, but a failing formula does not stop the others: its value is null and its error is
74
+ * returned. All names share one cache for the record, so a formula reached twice runs once.
75
+ */
76
+ evaluateRowSafe(row: Record<string, unknown>, rowIndex: number, names: string[]): {
77
+ values: Record<string, FormulaValue>;
78
+ errors: Record<string, Error>;
79
+ };
80
+ /** Ordered pass over all records. Results line up with `rows`. */
81
+ evaluateAll(rows: Record<string, unknown>[], names: string[]): Record<string, FormulaValue>[];
82
+ }
83
+ export {};
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Shared types for the report formula engine (Crystal-style syntax).
3
+ */
4
+ export type FormulaScalar = string | number | boolean | Date | null;
5
+ /** A formula result: a single value, or a flat list (lists do not nest). */
6
+ export type FormulaValue = FormulaScalar | FormulaScalar[];
7
+ /** When a formula is meant to run (Crystal's WhileReadingRecords / WhilePrintingRecords). */
8
+ export type FormulaPhase = 'pre-data' | 'read' | 'render';
9
+ export type VarType = 'string' | 'number' | 'currency' | 'boolean' | 'date' | 'datetime' | 'time';
10
+ export type VarScope = 'global' | 'local' | 'shared';
11
+ export type ValueKind = 'string' | 'number' | 'boolean' | 'date';
12
+ export interface Pos {
13
+ line: number;
14
+ column: number;
15
+ }
16
+ export type RefKind = 'field' | 'formula' | 'param';
17
+ export type Node = Pos & ({
18
+ type: 'num';
19
+ value: number;
20
+ } | {
21
+ type: 'str';
22
+ value: string;
23
+ } | {
24
+ type: 'bool';
25
+ value: boolean;
26
+ } | {
27
+ type: 'ref';
28
+ kind: RefKind;
29
+ name: string;
30
+ raw: string;
31
+ } | {
32
+ type: 'var';
33
+ name: string;
34
+ } | {
35
+ type: 'call';
36
+ name: string;
37
+ args: Node[];
38
+ } | {
39
+ type: 'unary';
40
+ op: 'neg' | 'not';
41
+ operand: Node;
42
+ } | {
43
+ type: 'binary';
44
+ op: string;
45
+ left: Node;
46
+ right: Node;
47
+ } | {
48
+ type: 'assign';
49
+ name: string;
50
+ value: Node;
51
+ } | {
52
+ type: 'decl';
53
+ scope: VarScope;
54
+ varType: VarType;
55
+ name: string;
56
+ init?: Node;
57
+ } | {
58
+ type: 'if';
59
+ cond: Node;
60
+ then: Node;
61
+ else?: Node;
62
+ } | {
63
+ type: 'seq';
64
+ statements: Node[];
65
+ } | {
66
+ type: 'array';
67
+ items: Node[];
68
+ });
69
+ export interface Program {
70
+ statements: Node[];
71
+ phase?: FormulaPhase;
72
+ }
73
+ export interface FormulaReferences {
74
+ fields: string[];
75
+ formulas: string[];
76
+ params: string[];
77
+ functions: string[];
78
+ }
79
+ export interface FormulaDiagnostic {
80
+ severity: 'error' | 'warning';
81
+ message: string;
82
+ line: number;
83
+ column: number;
84
+ }
85
+ export declare class FormulaSyntaxError extends Error {
86
+ readonly line: number;
87
+ readonly column: number;
88
+ constructor(message: string, line: number, column: number);
89
+ }
90
+ export declare class FormulaRuntimeError extends Error {
91
+ readonly line: number;
92
+ readonly column: number;
93
+ constructor(message: string, line?: number, column?: number);
94
+ }
@@ -0,0 +1,21 @@
1
+ import { FormulaValue, ValueKind } from './formula.types';
2
+ /** Argument kinds: s text, n number, d date, b boolean, a anything (function handles null itself). */
3
+ export type ArgKind = 's' | 'n' | 'd' | 'b' | 'a';
4
+ export type ReturnKind = ValueKind | 'any';
5
+ export interface FnContext {
6
+ now: Date;
7
+ }
8
+ export interface FunctionDef {
9
+ min: number;
10
+ max: number;
11
+ /** Kind per position; the last kind repeats for any further arguments. */
12
+ args: ArgKind[];
13
+ returns: ReturnKind;
14
+ /** When true, null arguments are passed through. Otherwise any null argument makes the result null. */
15
+ handlesNull?: boolean;
16
+ fn: (args: any[], ctx: FnContext) => FormulaValue;
17
+ }
18
+ declare function likeToRegExp(pattern: string): RegExp;
19
+ export { likeToRegExp };
20
+ export declare function getFunction(name: string): FunctionDef | undefined;
21
+ export declare function functionNames(): string[];
@@ -0,0 +1,6 @@
1
+ export { FormulaRuntimeError, FormulaSyntaxError, type FormulaDiagnostic, type FormulaPhase, type FormulaReferences, type FormulaValue, } from './formula.types';
2
+ export { parseFormula } from './parser';
3
+ export { functionNames } from './functions';
4
+ export { applyFormulaColumns, formulaDefinitionErrors, type FormulaColumnResult } from './formula-columns';
5
+ export { formatDate, formatNumber } from './format';
6
+ export { FormulaEngine, FormulaRun, checkFormula, type CheckOptions, type FormulaCheckResult, type FormulaDefinition, type FormulaRunOptions, } from './formula-engine';
@@ -0,0 +1,28 @@
1
+ import { FormulaValue, Node, Pos, Program, ValueKind, VarType } from './formula.types';
2
+ import { VariableStore } from './variable-store';
3
+ /** Everything a formula can see while it runs for one record. */
4
+ export interface EvalContext {
5
+ /** Current record, keyed by lower-cased field name. */
6
+ fields: Map<string, unknown>;
7
+ /** Report parameters, keyed by lower-cased name. */
8
+ params: Map<string, unknown>;
9
+ rowIndex: number;
10
+ /** Variables that live for the whole report execution. */
11
+ globals: VariableStore;
12
+ /** Crystal's "default values for nulls" option. */
13
+ nullAsDefault: boolean;
14
+ now: Date;
15
+ getFormula(name: string, at: Pos): FormulaValue;
16
+ sum?(field: string, group: string | undefined): number;
17
+ /** Called for every evaluated node; throws when the step budget is exhausted. */
18
+ step(): void;
19
+ }
20
+ /** Runs a compiled program and returns the value of its last statement (null if it produced none). */
21
+ export declare function runProgram(program: Program, ctx: EvalContext): FormulaValue;
22
+ export declare function defaultForKind(kind: ValueKind | null): FormulaValue;
23
+ /**
24
+ * Best-effort static result kind of an expression; null when it cannot be known without data.
25
+ * `vars` gives the kind of each declared variable (lower-cased name).
26
+ */
27
+ export declare function inferKind(node: Node, vars?: ReadonlyMap<string, ValueKind>): ValueKind | null;
28
+ export declare function varTypeKind(type: VarType): ValueKind;
@@ -0,0 +1,9 @@
1
+ export type TokenType = 'num' | 'str' | 'ref' | 'id' | 'op' | 'eof';
2
+ export interface Token {
3
+ type: TokenType;
4
+ value: string;
5
+ line: number;
6
+ column: number;
7
+ }
8
+ /** Splits formula text into tokens. Keywords are plain `id` tokens; the parser matches them case-insensitively. */
9
+ export declare function tokenize(source: string): Token[];
@@ -0,0 +1,3 @@
1
+ import { Program } from './formula.types';
2
+ /** Parses Crystal-syntax formula text into a Program. Throws FormulaSyntaxError with line and column. */
3
+ export declare function parseFormula(source: string): Program;
@@ -0,0 +1,12 @@
1
+ /** Execution-local lazy indexes: one dataset scan per distinct SUM field/scope, not per cell. */
2
+ export declare class SummaryIndex {
3
+ private readonly rows;
4
+ private readonly groups;
5
+ private records?;
6
+ private readonly indexes;
7
+ private readonly failures;
8
+ constructor(rows: readonly unknown[] | undefined, groups: readonly string[]);
9
+ private read;
10
+ private key;
11
+ sum(field: string, group: string | undefined, current: Map<string, unknown>): number;
12
+ }
@@ -0,0 +1,12 @@
1
+ import { FormulaValue, VarType } from './formula.types';
2
+ export declare function defaultForVarType(type: VarType): FormulaValue;
3
+ /** Holds declared formula variables. One global store lives for one report execution. */
4
+ export declare class VariableStore {
5
+ private readonly values;
6
+ private readonly types;
7
+ has(name: string): boolean;
8
+ /** Declares the variable at its default value if it does not exist yet. */
9
+ declare(name: string, type: VarType): void;
10
+ get(name: string): FormulaValue;
11
+ set(name: string, value: FormulaValue): void;
12
+ }
@@ -3,6 +3,7 @@ export * from './models';
3
3
  export * from './registry';
4
4
  export * from './tokens';
5
5
  export * from './errors';
6
+ export * from './formula';
6
7
  export * from './validation';
7
8
  export * from './services';
8
9
  export * from './utilities';
@@ -10,4 +10,6 @@ export type { ReportGridDefinition, GridColumnDefinition, GridOptionsDefinition,
10
10
  export type { ReportLayoutDefinition, ComponentLayoutDefinition, } from './report-layout.model';
11
11
  export type { ValidationDefinition, } from './validation.model';
12
12
  export type { ComponentEventDefinition, ComponentActionDefinition, } from './component-event.model';
13
+ export type { ReportFormulaDefinition } from './report-formula.model';
13
14
  export * from './report-menu.model';
15
+ export * from './selection-workflow.model';
@@ -37,6 +37,8 @@ export interface ReportDataSourceDefinition {
37
37
  * before calling the `ReportDataSourceAdapter`.
38
38
  */
39
39
  parameterKeys?: string[];
40
+ /** Arguments that must resolve before execution. Older definitions may omit this list. */
41
+ requiredParameterKeys?: string[];
40
42
  /** Whether to automatically execute this data source on report load. */
41
43
  autoExecute?: boolean;
42
44
  /** Caching strategy. */
@@ -12,8 +12,10 @@
12
12
  import { ReportComponentDefinition } from './report-component.model';
13
13
  import { ReportParameterDefinition } from './report-parameter.model';
14
14
  import { ReportDataSourceDefinition } from './report-datasource.model';
15
+ import { ReportFormulaDefinition } from './report-formula.model';
15
16
  import { ReportGridDefinition } from './report-grid.model';
16
17
  import { ReportLayoutDefinition } from './report-layout.model';
18
+ import { SelectionWorkflowDefinition } from './selection-workflow.model';
17
19
  /**
18
20
  * Permission settings for a report.
19
21
  */
@@ -97,6 +99,12 @@ export interface ReportDefinition {
97
99
  dataSources: ReportDataSourceDefinition[];
98
100
  /** Result grid definition. */
99
101
  grid?: ReportGridDefinition;
102
+ /** Named formulas. Grid columns reference them through `GridColumnDefinition.formula`. */
103
+ formulas?: ReportFormulaDefinition[];
104
+ /** Optional radio-driven record picker; requires schemaVersion 2. */
105
+ selectionWorkflow?: SelectionWorkflowDefinition;
106
+ /** Independent additional lookup cards, displayed beside the primary lookup. */
107
+ additionalSelectionWorkflows?: SelectionWorkflowDefinition[];
100
108
  /** Access control settings. */
101
109
  permissions?: ReportPermissionDefinition;
102
110
  /** URL-friendly slug for routing (e.g. 'sale-report'). Auto-generated from name if not set. */
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Report formula definitions (Crystal-style formula fields).
3
+ *
4
+ * A formula is a named expression. Grid columns reference it by name via
5
+ * `GridColumnDefinition.formula`; other formulas reference it as `{@name}`.
6
+ */
7
+ export interface ReportFormulaDefinition {
8
+ /** Unique name (case-insensitive). Referenced elsewhere as `{@name}`. */
9
+ name: string;
10
+ /** Formula text in Crystal syntax, kept exactly as authored or imported. */
11
+ body: string;
12
+ /** Optional note for other report authors. */
13
+ description?: string;
14
+ /** 'default' treats null as "", 0 or false in operators (Crystal's "default values for nulls"). */
15
+ nullHandling?: 'null' | 'default';
16
+ }
@@ -44,6 +44,11 @@ export interface ReportGridDefinition {
44
44
  dataSourceId: string;
45
45
  /** Column definitions. */
46
46
  columns: GridColumnDefinition[];
47
+ /** Parent-to-child hierarchy for formula summaries, independent of visible grid grouping.
48
+ * Undefined preserves legacy reports that use options.groupModel for calculation scope.
49
+ * An empty array explicitly declares no calculation groups.
50
+ */
51
+ formulaGroupFields?: string[];
47
52
  /** Grid-level options. */
48
53
  options?: GridOptionsDefinition;
49
54
  /** Declarative row-click action for master-detail drill-downs. */
@@ -53,8 +58,13 @@ export interface ReportGridDefinition {
53
58
  * Defines a single column in the result grid.
54
59
  */
55
60
  export interface GridColumnDefinition {
56
- /** The field name in the data row object. */
61
+ /** The field name in the data row object. For a formula column, the name its value is stored under. */
57
62
  field: string;
63
+ /**
64
+ * Name of a report formula (`ReportDefinition.formulas`) that computes this column.
65
+ * The result is added to each row under `field`, replacing any data field with the same name.
66
+ */
67
+ formula?: string;
58
68
  /** Display label for the column header. */
59
69
  label: string;
60
70
  /** Column data type — used for formatting and sorting. */
@@ -29,6 +29,8 @@ export interface BwaysReportErpMenuNode {
29
29
  subItems?: readonly BwaysReportErpMenuNode[];
30
30
  }
31
31
  export interface BwaysReportMenuOptions {
32
+ /** Opt-in: save a selected menu route through the report persistence backend. */
33
+ routeSave?: BwaysReportMenuRouteSave;
32
34
  required?: boolean;
33
35
  /** Read reactive company/user/module signals here to invalidate an open review on context changes. */
34
36
  contextKey?: () => string;
@@ -43,3 +45,19 @@ export type BwaysReportMenuConfig = BwaysReportMenuOptions & ({
43
45
  format: 'erp';
44
46
  load: () => Observable<readonly BwaysReportErpMenuNode[]>;
45
47
  });
48
+ /** Describes an allowlisted backend update; never executed as SQL in the browser. */
49
+ export interface BwaysReportMenuRouteSave {
50
+ table: string;
51
+ column: string;
52
+ updateColumns?: Record<string, string | number | boolean | null>;
53
+ /** Defaults to MENU_KEY and MODULE_NO. */
54
+ keyColumn?: string;
55
+ moduleColumn?: string;
56
+ parentColumn?: string;
57
+ }
58
+ export interface BwaysReportMenuRouteAssignment extends BwaysReportMenuRouteSave {
59
+ menuKey: string;
60
+ moduleNo: string;
61
+ parentKey?: string;
62
+ route: string;
63
+ }
@@ -19,4 +19,11 @@ export interface ReportParameterDefinition {
19
19
  defaultValue?: unknown;
20
20
  /** Whether this parameter must have a value before executing the report. */
21
21
  required?: boolean;
22
+ /** Share an argument's explicit binding with formulas. The binding stays on the data source,
23
+ * so editing it in the Grid tab updates both consumers without duplicated configuration.
24
+ * Date formatting on that argument is applied only to the SQL payload. */
25
+ valueSource?: {
26
+ dataSourceId: string;
27
+ parameterName: string;
28
+ };
22
29
  }
@@ -0,0 +1,31 @@
1
+ import { ReportGridDefinition } from './report-grid.model';
2
+ /** A record picker. Radio workflows use one per option; dropdown workflows use one shared picker. */
3
+ export interface SelectionWorkflowCase {
4
+ value: string | number;
5
+ /** Normal-report branch without interactive row selection; selected-row bindings resolve all lookup rows on Run. */
6
+ direct?: boolean;
7
+ /** Multiple selections send CSV values; omitted preserves legacy single-row behavior. */
8
+ selectionMode?: 'single' | 'multiple';
9
+ /** Join selected IDs and column values with this literal separator. Default comma; empty means concatenate. */
10
+ valueSeparator?: string;
11
+ keyField: string;
12
+ displayField: string;
13
+ lookupGrid: ReportGridDefinition;
14
+ /** Optional final grid/source override; defaults to report.grid. */
15
+ resultGrid?: ReportGridDefinition;
16
+ }
17
+ /** Single-record parameter picker followed by an explicitly submitted report. */
18
+ export interface SelectionWorkflowDefinition {
19
+ version: 1;
20
+ /** Omitted on older reports: infer from radioKey/dropdownKey. */
21
+ lookupTrigger?: 'radio' | 'dropdown' | 'button';
22
+ /** Loads the picker only. Must differ from the final report actionButtonId. */
23
+ lookupButtonId?: string;
24
+ /** Existing radio mode: one case per permitted option. Mutually exclusive with dropdownKey. */
25
+ radioKey?: string;
26
+ /** Dropdown mode: one shared lookup SP, bound to the current dropdown value through parameter cards. */
27
+ dropdownKey?: string;
28
+ selectionKey: string;
29
+ actionButtonId: string;
30
+ cases: SelectionWorkflowCase[];
31
+ }
@@ -4,7 +4,7 @@ export type MigrationFn = (def: ReportDefinition) => ReportDefinition;
4
4
  * Migrates a ReportDefinition to a target schema version.
5
5
  *
6
6
  * @param definition - Source report definition.
7
- * @param targetVersion - Desired schema version (default current version = 1).
7
+ * @param targetVersion - Desired schema version (default current version = 2).
8
8
  * @returns Migrated ReportDefinition.
9
9
  */
10
10
  export declare function migrateDefinition(definition: ReportDefinition, targetVersion?: number): ReportDefinition;
@@ -1,5 +1,10 @@
1
1
  import type { AbstractControl, FormGroup } from '@angular/forms';
2
- export declare function rememberSelectedOption(control: AbstractControl, value: unknown, record?: Record<string, unknown>): void;
2
+ export declare function rememberSelectedOption(control: AbstractControl, value: unknown, record?: Record<string, unknown>, records?: Record<string, unknown>[], separator?: string): void;
3
3
  /** Keep form values primitive. Selection metadata never becomes a wire argument. */
4
4
  export declare function extractReportFormValues(form: FormGroup): Record<string, unknown>;
5
5
  export declare function selectedOptionRecord(values: Record<string, unknown>, field: string): Record<string, unknown> | undefined;
6
+ /** CSV is a parameter value, never SQL text. Reject ambiguous delimiters rather than altering identifiers. */
7
+ export declare function selectionCsv(values: unknown[], separator?: string): string;
8
+ export declare function selectedColumnValue(values: Record<string, unknown>, field: string, column: string): unknown;
9
+ /** Add execution-only all-row bindings without mutating the form or another lookup's metadata. */
10
+ export declare function withLookupRows(values: Record<string, unknown>, field: string, records: Record<string, unknown>[], keyField: string, separator: string): Record<string, unknown>;
@@ -0,0 +1,2 @@
1
+ import { BwaysReportMenuRouteSave } from '../models/report-menu.model';
2
+ export declare function validateMenuRouteSave(config: BwaysReportMenuRouteSave): void;
@@ -0,0 +1,7 @@
1
+ import { ReportDefinition } from '../models/report-definition.model';
2
+ /** Formula inputs come directly from the executed Grid SP's existing cards, not a second setup. */
3
+ export declare function gridFormulaValues(def: ReportDefinition, values: Record<string, unknown>, session: Record<string, unknown>, sourceId?: string): Record<string, unknown>;
4
+ /** One execution snapshot. Argument-backed values reference the existing binding, never a copy. */
5
+ export declare function resolveReportValues(def: ReportDefinition, form: Record<string, unknown>, session: Record<string, unknown>, sourceId?: string): Record<string, unknown>;
6
+ /** Validate only formulas used by grid columns, including their transitive dependencies. */
7
+ export declare function validateFormulaInputs(def: ReportDefinition, values: Record<string, unknown>): void;
@@ -0,0 +1,12 @@
1
+ import { ReportDefinition } from '../models/report-definition.model';
2
+ import { ReportComponentDefinition } from '../models/report-component.model';
3
+ import { SelectionWorkflowCase, SelectionWorkflowDefinition } from '../models/selection-workflow.model';
4
+ /** Primary legacy configuration plus independent extra lookup cards. */
5
+ export declare function reportSelectionWorkflows(definition: ReportDefinition): SelectionWorkflowDefinition[];
6
+ /** The visible control that determines which records may be selected. */
7
+ export declare function selectionTriggerKey(definition: ReportDefinition): string;
8
+ export declare function selectionCase(definition: ReportDefinition, value: unknown): SelectionWorkflowCase | undefined;
9
+ /** The managed picker control participates in normal form extraction but has no visual component. */
10
+ export declare function selectionFormComponents(definition: ReportDefinition): ReportComponentDefinition[];
11
+ /** Validate all pickers together before creating any requests. */
12
+ export declare function selectionWorkflowErrors(definition: ReportDefinition): string[];
@@ -10,6 +10,7 @@ export declare class EndpointPersistenceAdapter extends ReportPersistenceAdapter
10
10
  checkId(reportId: string): Observable<boolean>;
11
11
  inspectId(reportId: string): Observable<ReportIdStatus>;
12
12
  load(reportId: string): Observable<ReportDefinition>;
13
+ supportsMenuRouteSave(): boolean;
13
14
  save(report: ReportDefinition, options?: ReportSaveOptions): Observable<ReportDefinition>;
14
15
  list(): Observable<ReportSummary[]>;
15
16
  delete(reportId: string): Observable<void>;
@@ -11,6 +11,7 @@ export declare class HttpReportPersistenceAdapter extends ReportPersistenceAdapt
11
11
  checkId(reportId: string): Observable<boolean>;
12
12
  inspectId(reportId: string): Observable<ReportIdStatus>;
13
13
  load(id: string): Observable<ReportDefinition>;
14
+ supportsMenuRouteSave(): boolean;
14
15
  save(report: ReportDefinition, options?: ReportSaveOptions): Observable<ReportDefinition>;
15
16
  list(): Observable<ReportSummary[]>;
16
17
  delete(id: string): Observable<void>;
@@ -0,0 +1,3 @@
1
+ import { ReportDefinition } from '../../core/models/report-definition.model';
2
+ /** Old backends must not silently acknowledge a report-only save as a menu update. */
3
+ export declare function confirmMenuRouteSave(saved: ReportDefinition, requested: boolean): ReportDefinition;
@@ -4,9 +4,11 @@
4
4
  * The host application implements this to save/load report definitions
5
5
  * to/from their backend (database, file system, API, etc.).
6
6
  */
7
+ import { BwaysReportMenuRouteAssignment } from '../../core/models/report-menu.model';
7
8
  import { Observable } from 'rxjs';
8
9
  import { ReportDefinition, ReportSummary } from '../../core/models/report-definition.model';
9
10
  export interface ReportSaveOptions {
11
+ menuRoute?: BwaysReportMenuRouteAssignment;
10
12
  /** Reject an existing ID instead of updating it. Hosts should enforce this atomically. */
11
13
  createOnly?: boolean;
12
14
  /** Update only an existing report at this version; reject missing or changed records. */
@@ -34,6 +36,8 @@ export interface ReportIdStatus {
34
36
  * ```
35
37
  */
36
38
  export declare abstract class ReportPersistenceAdapter {
39
+ /** Custom adapters must opt in and perform the route update atomically with report saving. */
40
+ supportsMenuRouteSave(): boolean;
37
41
  /** Returns true when this ID exists. Legacy host adapters may use the catalog fallback. */
38
42
  checkId(reportId: string): Observable<boolean>;
39
43
  /** Compact identity metadata used to confirm an overwrite. Legacy hosts use summaries. */
@@ -9,7 +9,7 @@ export declare class ComponentPaletteComponent {
9
9
  /** Selected category filter tab: 'all' or specific category name */
10
10
  readonly selectedCategory: import("@angular/core").WritableSignal<string>;
11
11
  /** Layout view mode: 'grid' (2-column side-by-side grid) or 'list' (compact row list). Defaults to 'grid'. */
12
- readonly layoutMode: import("@angular/core").WritableSignal<"grid" | "list">;
12
+ readonly layoutMode: import("@angular/core").WritableSignal<"list" | "grid">;
13
13
  /** Set of expanded category IDs */
14
14
  readonly expandedCategories: import("@angular/core").WritableSignal<Set<string>>;
15
15
  readonly totalComponentCount: import("@angular/core").Signal<number>;
@@ -2,9 +2,15 @@ import { OnDestroy } from '@angular/core';
2
2
  import { FormControl, FormGroup } from '@angular/forms';
3
3
  import { CdkDragDrop } from '@angular/cdk/drag-drop';
4
4
  import { ReportComponentDefinition } from '../../../../core/models/report-component.model';
5
+ import { ReportGridDefinition } from '../../../../core/models/report-grid.model';
6
+ import { SelectionWorkflowService } from '../../../runtime/selection-workflow.service';
5
7
  import { getComponentIconName } from '../../utilities/canvas-layout.util';
6
8
  import * as i0 from "@angular/core";
7
9
  export declare class DesignCanvasComponent implements OnDestroy {
10
+ readonly workflow: SelectionWorkflowService;
11
+ readonly displayGrid: import("@angular/core").Signal<ReportGridDefinition | undefined>;
12
+ readonly displayRows: import("@angular/core").Signal<unknown[]>;
13
+ private readonly lookupPanel;
8
14
  private readonly requests;
9
15
  private readonly formContext;
10
16
  constructor();
@@ -66,6 +72,7 @@ export declare class DesignCanvasComponent implements OnDestroy {
66
72
  onCanvasGridStateChange(state: any): void;
67
73
  onCanvasColumnDefsChange(defs: any[]): void;
68
74
  removeGrid(event?: MouseEvent): void;
75
+ private updateWorkflowGrid;
69
76
  applyBlueprint(blueprintId: string): void;
70
77
  addStarterComponent(type: string): void;
71
78
  static ɵfac: i0.ɵɵFactoryDeclaration<DesignCanvasComponent, never>;