bways-report 0.1.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.
Files changed (185) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +477 -0
  3. package/esm2022/bways-report.mjs +5 -0
  4. package/esm2022/lib/core/errors/index.mjs +2 -0
  5. package/esm2022/lib/core/errors/reporting-errors.mjs +65 -0
  6. package/esm2022/lib/core/index.mjs +8 -0
  7. package/esm2022/lib/core/models/component-event.model.mjs +8 -0
  8. package/esm2022/lib/core/models/index.mjs +5 -0
  9. package/esm2022/lib/core/models/report-component.model.mjs +10 -0
  10. package/esm2022/lib/core/models/report-datasource.model.mjs +9 -0
  11. package/esm2022/lib/core/models/report-definition.model.mjs +13 -0
  12. package/esm2022/lib/core/models/report-grid.model.mjs +10 -0
  13. package/esm2022/lib/core/models/report-layout.model.mjs +9 -0
  14. package/esm2022/lib/core/models/report-parameter.model.mjs +9 -0
  15. package/esm2022/lib/core/models/validation.model.mjs +8 -0
  16. package/esm2022/lib/core/registry/component-category.mjs +8 -0
  17. package/esm2022/lib/core/registry/component-registry.mjs +90 -0
  18. package/esm2022/lib/core/registry/index.mjs +2 -0
  19. package/esm2022/lib/core/registry/property-definition.model.mjs +10 -0
  20. package/esm2022/lib/core/services/dynamic-form-builder.service.mjs +55 -0
  21. package/esm2022/lib/core/services/index.mjs +3 -0
  22. package/esm2022/lib/core/services/report-session-context.service.mjs +314 -0
  23. package/esm2022/lib/core/tokens/index.mjs +3 -0
  24. package/esm2022/lib/core/tokens/reporting-config.token.mjs +26 -0
  25. package/esm2022/lib/core/tokens/session-context.token.mjs +18 -0
  26. package/esm2022/lib/core/utilities/id-generator.mjs +17 -0
  27. package/esm2022/lib/core/utilities/index.mjs +3 -0
  28. package/esm2022/lib/core/utilities/schema-migration.mjs +38 -0
  29. package/esm2022/lib/core/utils/identifier-humanizer.mjs +88 -0
  30. package/esm2022/lib/core/validation/index.mjs +2 -0
  31. package/esm2022/lib/core/validation/validation-factory.mjs +70 -0
  32. package/esm2022/lib/data-access/adapters/http-lookup.adapter.mjs +107 -0
  33. package/esm2022/lib/data-access/adapters/http-schema-discovery.adapter.mjs +119 -0
  34. package/esm2022/lib/data-access/adapters/index.mjs +3 -0
  35. package/esm2022/lib/data-access/contracts/data-source.contract.mjs +28 -0
  36. package/esm2022/lib/data-access/contracts/index.mjs +7 -0
  37. package/esm2022/lib/data-access/contracts/lookup.contract.mjs +6 -0
  38. package/esm2022/lib/data-access/contracts/master-data.provider.mjs +24 -0
  39. package/esm2022/lib/data-access/contracts/report-persistence.contract.mjs +25 -0
  40. package/esm2022/lib/data-access/contracts/schema-discovery.contract.mjs +7 -0
  41. package/esm2022/lib/data-access/contracts/translation.contract.mjs +9 -0
  42. package/esm2022/lib/data-access/index.mjs +3 -0
  43. package/esm2022/lib/features/designer/components/component-palette/component-palette.component.mjs +542 -0
  44. package/esm2022/lib/features/designer/components/design-canvas/design-canvas.component.mjs +843 -0
  45. package/esm2022/lib/features/designer/components/property-editor/parameter-binding-editor.component.mjs +556 -0
  46. package/esm2022/lib/features/designer/components/property-editor/property-editor-datasource.component.mjs +845 -0
  47. package/esm2022/lib/features/designer/components/property-editor/property-editor-general.component.mjs +185 -0
  48. package/esm2022/lib/features/designer/components/property-editor/property-editor-grid.component.mjs +452 -0
  49. package/esm2022/lib/features/designer/components/property-editor/property-editor-layout.component.mjs +350 -0
  50. package/esm2022/lib/features/designer/components/property-editor/property-editor-report.component.mjs +175 -0
  51. package/esm2022/lib/features/designer/components/property-editor/property-editor-validation.component.mjs +137 -0
  52. package/esm2022/lib/features/designer/components/property-editor/property-editor.component.mjs +608 -0
  53. package/esm2022/lib/features/designer/components/toolbar/designer-toolbar.component.mjs +225 -0
  54. package/esm2022/lib/features/designer/designer.component.mjs +285 -0
  55. package/esm2022/lib/features/designer/index.mjs +7 -0
  56. package/esm2022/lib/features/designer/services/designer-state.service.mjs +310 -0
  57. package/esm2022/lib/features/designer/services/index.mjs +2 -0
  58. package/esm2022/lib/features/designer/utilities/canvas-layout.util.mjs +124 -0
  59. package/esm2022/lib/features/export/index.mjs +2 -0
  60. package/esm2022/lib/features/export/models/export.models.mjs +2 -0
  61. package/esm2022/lib/features/export/services/report-export.service.mjs +107 -0
  62. package/esm2022/lib/features/index.mjs +6 -0
  63. package/esm2022/lib/features/persistence/index.mjs +2 -0
  64. package/esm2022/lib/features/persistence/services/index.mjs +4 -0
  65. package/esm2022/lib/features/persistence/services/report-store.service.mjs +183 -0
  66. package/esm2022/lib/features/persistence/services/report-versioning.service.mjs +81 -0
  67. package/esm2022/lib/features/persistence/services/schema-validator.service.mjs +102 -0
  68. package/esm2022/lib/features/routing/components/routed-report-designer.component.mjs +156 -0
  69. package/esm2022/lib/features/routing/components/routed-report-runtime.component.mjs +163 -0
  70. package/esm2022/lib/features/routing/index.mjs +6 -0
  71. package/esm2022/lib/features/routing/models/report-route.models.mjs +2 -0
  72. package/esm2022/lib/features/routing/report-routes.mjs +49 -0
  73. package/esm2022/lib/features/routing/resolvers/report.resolver.mjs +22 -0
  74. package/esm2022/lib/features/routing/services/report-menu.service.mjs +77 -0
  75. package/esm2022/lib/features/runtime/dynamic-renderer.component.mjs +222 -0
  76. package/esm2022/lib/features/runtime/index.mjs +4 -0
  77. package/esm2022/lib/features/runtime/report-grid-bridge.component.mjs +409 -0
  78. package/esm2022/lib/features/runtime/report-runtime.component.mjs +147 -0
  79. package/esm2022/lib/primitives/components/button/rpt-button.component.mjs +88 -0
  80. package/esm2022/lib/primitives/components/chart-bridge/report-chart-bridge.component.mjs +361 -0
  81. package/esm2022/lib/primitives/components/checkbox/rpt-checkbox.component.mjs +86 -0
  82. package/esm2022/lib/primitives/components/date/rpt-date.component.mjs +91 -0
  83. package/esm2022/lib/primitives/components/dropdown/rpt-dropdown.component.mjs +204 -0
  84. package/esm2022/lib/primitives/components/icon/rpt-icon.component.mjs +476 -0
  85. package/esm2022/lib/primitives/components/index.mjs +10 -0
  86. package/esm2022/lib/primitives/components/input/rpt-input.component.mjs +88 -0
  87. package/esm2022/lib/primitives/components/kpi-card/rpt-kpi-card.component.mjs +197 -0
  88. package/esm2022/lib/primitives/components/number/rpt-number.component.mjs +110 -0
  89. package/esm2022/lib/primitives/index.mjs +3 -0
  90. package/esm2022/lib/primitives/register-builtins.mjs +328 -0
  91. package/esm2022/lib/provide-reporting.mjs +92 -0
  92. package/esm2022/public-api.mjs +9 -0
  93. package/fesm2022/bways-report.mjs +10360 -0
  94. package/fesm2022/bways-report.mjs.map +1 -0
  95. package/index.d.ts +5 -0
  96. package/lib/core/errors/index.d.ts +1 -0
  97. package/lib/core/errors/reporting-errors.d.ts +42 -0
  98. package/lib/core/index.d.ts +7 -0
  99. package/lib/core/models/component-event.model.d.ts +37 -0
  100. package/lib/core/models/index.d.ts +11 -0
  101. package/lib/core/models/report-component.model.d.ts +95 -0
  102. package/lib/core/models/report-datasource.model.d.ts +39 -0
  103. package/lib/core/models/report-definition.model.d.ts +100 -0
  104. package/lib/core/models/report-grid.model.d.ts +73 -0
  105. package/lib/core/models/report-layout.model.d.ts +43 -0
  106. package/lib/core/models/report-parameter.model.d.ts +22 -0
  107. package/lib/core/models/validation.model.d.ts +30 -0
  108. package/lib/core/registry/component-category.d.ts +16 -0
  109. package/lib/core/registry/component-registry.d.ts +101 -0
  110. package/lib/core/registry/index.d.ts +4 -0
  111. package/lib/core/registry/property-definition.model.d.ts +38 -0
  112. package/lib/core/services/dynamic-form-builder.service.d.ts +30 -0
  113. package/lib/core/services/index.d.ts +3 -0
  114. package/lib/core/services/report-session-context.service.d.ts +87 -0
  115. package/lib/core/tokens/index.d.ts +4 -0
  116. package/lib/core/tokens/reporting-config.token.d.ts +42 -0
  117. package/lib/core/tokens/session-context.token.d.ts +36 -0
  118. package/lib/core/utilities/id-generator.d.ts +9 -0
  119. package/lib/core/utilities/index.d.ts +3 -0
  120. package/lib/core/utilities/schema-migration.d.ts +10 -0
  121. package/lib/core/utils/identifier-humanizer.d.ts +22 -0
  122. package/lib/core/validation/index.d.ts +1 -0
  123. package/lib/core/validation/validation-factory.d.ts +31 -0
  124. package/lib/data-access/adapters/http-lookup.adapter.d.ts +19 -0
  125. package/lib/data-access/adapters/http-schema-discovery.adapter.d.ts +20 -0
  126. package/lib/data-access/adapters/index.d.ts +2 -0
  127. package/lib/data-access/contracts/data-source.contract.d.ts +37 -0
  128. package/lib/data-access/contracts/index.d.ts +9 -0
  129. package/lib/data-access/contracts/lookup.contract.d.ts +32 -0
  130. package/lib/data-access/contracts/master-data.provider.d.ts +54 -0
  131. package/lib/data-access/contracts/report-persistence.contract.d.ts +36 -0
  132. package/lib/data-access/contracts/schema-discovery.contract.d.ts +52 -0
  133. package/lib/data-access/contracts/translation.contract.d.ts +16 -0
  134. package/lib/data-access/index.d.ts +2 -0
  135. package/lib/features/designer/components/component-palette/component-palette.component.d.ts +39 -0
  136. package/lib/features/designer/components/design-canvas/design-canvas.component.d.ts +42 -0
  137. package/lib/features/designer/components/property-editor/parameter-binding-editor.component.d.ts +36 -0
  138. package/lib/features/designer/components/property-editor/property-editor-datasource.component.d.ts +68 -0
  139. package/lib/features/designer/components/property-editor/property-editor-general.component.d.ts +20 -0
  140. package/lib/features/designer/components/property-editor/property-editor-grid.component.d.ts +20 -0
  141. package/lib/features/designer/components/property-editor/property-editor-layout.component.d.ts +18 -0
  142. package/lib/features/designer/components/property-editor/property-editor-report.component.d.ts +15 -0
  143. package/lib/features/designer/components/property-editor/property-editor-validation.component.d.ts +12 -0
  144. package/lib/features/designer/components/property-editor/property-editor.component.d.ts +44 -0
  145. package/lib/features/designer/components/toolbar/designer-toolbar.component.d.ts +18 -0
  146. package/lib/features/designer/designer.component.d.ts +36 -0
  147. package/lib/features/designer/index.d.ts +7 -0
  148. package/lib/features/designer/services/designer-state.service.d.ts +103 -0
  149. package/lib/features/designer/services/index.d.ts +2 -0
  150. package/lib/features/designer/utilities/canvas-layout.util.d.ts +55 -0
  151. package/lib/features/export/index.d.ts +2 -0
  152. package/lib/features/export/models/export.models.d.ts +16 -0
  153. package/lib/features/export/services/report-export.service.d.ts +27 -0
  154. package/lib/features/index.d.ts +5 -0
  155. package/lib/features/persistence/index.d.ts +1 -0
  156. package/lib/features/persistence/services/index.d.ts +5 -0
  157. package/lib/features/persistence/services/report-store.service.d.ts +53 -0
  158. package/lib/features/persistence/services/report-versioning.service.d.ts +29 -0
  159. package/lib/features/persistence/services/schema-validator.service.d.ts +34 -0
  160. package/lib/features/routing/components/routed-report-designer.component.d.ts +18 -0
  161. package/lib/features/routing/components/routed-report-runtime.component.d.ts +18 -0
  162. package/lib/features/routing/index.d.ts +6 -0
  163. package/lib/features/routing/models/report-route.models.d.ts +41 -0
  164. package/lib/features/routing/report-routes.d.ts +16 -0
  165. package/lib/features/routing/resolvers/report.resolver.d.ts +7 -0
  166. package/lib/features/routing/services/report-menu.service.d.ts +30 -0
  167. package/lib/features/runtime/dynamic-renderer.component.d.ts +30 -0
  168. package/lib/features/runtime/index.d.ts +3 -0
  169. package/lib/features/runtime/report-grid-bridge.component.d.ts +94 -0
  170. package/lib/features/runtime/report-runtime.component.d.ts +26 -0
  171. package/lib/primitives/components/button/rpt-button.component.d.ts +19 -0
  172. package/lib/primitives/components/chart-bridge/report-chart-bridge.component.d.ts +45 -0
  173. package/lib/primitives/components/checkbox/rpt-checkbox.component.d.ts +14 -0
  174. package/lib/primitives/components/date/rpt-date.component.d.ts +17 -0
  175. package/lib/primitives/components/dropdown/rpt-dropdown.component.d.ts +32 -0
  176. package/lib/primitives/components/icon/rpt-icon.component.d.ts +41 -0
  177. package/lib/primitives/components/index.d.ts +12 -0
  178. package/lib/primitives/components/input/rpt-input.component.d.ts +16 -0
  179. package/lib/primitives/components/kpi-card/rpt-kpi-card.component.d.ts +43 -0
  180. package/lib/primitives/components/number/rpt-number.component.d.ts +20 -0
  181. package/lib/primitives/index.d.ts +2 -0
  182. package/lib/primitives/register-builtins.d.ts +11 -0
  183. package/lib/provide-reporting.d.ts +75 -0
  184. package/package.json +55 -0
  185. package/public-api.d.ts +5 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Property definitions for the Designer's property editor.
3
+ *
4
+ * Each registered component provides a `propertySchema` describing
5
+ * its configurable properties. The Designer's property editor uses
6
+ * this schema to dynamically generate an editing form — the property
7
+ * editor is itself metadata-driven.
8
+ */
9
+ /**
10
+ * Describes a single configurable property of a component.
11
+ */
12
+ export interface PropertyDefinition {
13
+ /** Property key (matches a key in `ReportComponentDefinition.properties`). */
14
+ key: string;
15
+ /** Display label in the property editor. */
16
+ label: string;
17
+ /** Property data type — determines which editor control is rendered. */
18
+ type: 'string' | 'number' | 'boolean' | 'select' | 'color' | 'datasource' | 'validation' | 'json';
19
+ /** Default value for new components. */
20
+ defaultValue?: unknown;
21
+ /** Options for `select` type properties. */
22
+ options?: PropertyOption[];
23
+ /** Whether this property is required. */
24
+ required?: boolean;
25
+ /** Grouping label for organizing properties in the editor. */
26
+ group?: string;
27
+ /** Help text / tooltip for the property editor. */
28
+ description?: string;
29
+ }
30
+ /**
31
+ * A single option for select-type properties.
32
+ */
33
+ export interface PropertyOption {
34
+ /** Value stored in metadata. */
35
+ key: string;
36
+ /** Display label in the editor dropdown. */
37
+ label: string;
38
+ }
@@ -0,0 +1,30 @@
1
+ import { FormGroup } from '@angular/forms';
2
+ import { ReportComponentDefinition } from '../models/report-component.model';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * DynamicFormBuilder converts metadata definitions into Angular Reactive Form controls.
6
+ *
7
+ * Follows the official Angular Dynamic Forms pattern:
8
+ * ReportComponentDefinition[] (metadata) -> DynamicFormBuilder -> FormGroup (runtime model)
9
+ */
10
+ export declare class DynamicFormBuilder {
11
+ /**
12
+ * Constructs an Angular FormGroup from a list of component definitions.
13
+ *
14
+ * Only components with a valid `key` property generate form controls.
15
+ *
16
+ * @param components - Array of report component definitions.
17
+ * @param initialValues - Optional dictionary of initial control values by key.
18
+ * @returns Configured Angular FormGroup.
19
+ */
20
+ toFormGroup(components: ReportComponentDefinition[], initialValues?: Record<string, unknown>): FormGroup;
21
+ /**
22
+ * Extracts raw values from a FormGroup, including disabled controls.
23
+ *
24
+ * @param form - The FormGroup to extract from.
25
+ * @returns Key-value dictionary of all control values.
26
+ */
27
+ extractValues(form: FormGroup): Record<string, unknown>;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<DynamicFormBuilder, never>;
29
+ static ɵprov: i0.ɵɵInjectableDeclaration<DynamicFormBuilder>;
30
+ }
@@ -0,0 +1,3 @@
1
+ export { DynamicFormBuilder } from './dynamic-form-builder.service';
2
+ export { ReportSessionContextService } from './report-session-context.service';
3
+ export type { SessionParamMatch, DerivedParametersResult, } from './report-session-context.service';
@@ -0,0 +1,87 @@
1
+ import { OnDestroy, Signal } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { SessionContextMap, SessionParamPrimitive } from '../tokens/session-context.token';
4
+ import { ProcedureParameterMetadata } from '../../data-access/contracts/schema-discovery.contract';
5
+ import * as i0 from "@angular/core";
6
+ export interface SessionParamMatch {
7
+ isMatched: boolean;
8
+ sessionKey: string;
9
+ value: SessionParamPrimitive;
10
+ friendlyLabel: string;
11
+ }
12
+ export interface DerivedParametersResult {
13
+ /** The consolidated parameter payload for stored procedure execution */
14
+ parameters: Record<string, unknown>;
15
+ /** Map of which SP parameters were auto-derived from session context */
16
+ autoDerivedParams: Record<string, SessionParamMatch>;
17
+ /** Any required parameters that were neither in session context nor explicitly mapped */
18
+ unresolvedRequiredParams: ProcedureParameterMetadata[];
19
+ }
20
+ /**
21
+ * Service that manages host application session context parameters (e.g. branchId, companyId, userId)
22
+ * at runtime and automatically detects and binds them to Stored Procedure parameters.
23
+ *
24
+ * Designed to completely shield end users from entering technical session parameters while
25
+ * eliminating silent failures or thread crashes in host integrations.
26
+ */
27
+ export declare class ReportSessionContextService implements OnDestroy {
28
+ private readonly rawSource;
29
+ private readonly sessionProvider;
30
+ /** Internal manual runtime session overrides (e.g. set via setSessionContext or setSessionParameter) */
31
+ private readonly manualRuntimeContext;
32
+ private readonly latestObservableValue;
33
+ private readonly providerObservableValue;
34
+ private observableSub?;
35
+ private providerSub?;
36
+ /**
37
+ * Reactive signal exposing the live session context parameters.
38
+ * Updates automatically when host app mutates runtime state, when observables emit,
39
+ * or when reactive signals update.
40
+ */
41
+ readonly sessionContext: Signal<SessionContextMap>;
42
+ /**
43
+ * Observable stream of live session parameters for RxJS-based integrations.
44
+ */
45
+ readonly sessionContext$: Observable<SessionContextMap>;
46
+ constructor();
47
+ ngOnDestroy(): void;
48
+ private initSubscriptions;
49
+ /**
50
+ * Sets or replaces the runtime session context.
51
+ * Can be called dynamically after user authentication, branch change, etc.
52
+ */
53
+ setSessionContext(context: SessionContextMap): void;
54
+ /**
55
+ * Updates or sets a specific session parameter at runtime (e.g. branchId = 2).
56
+ */
57
+ setSessionParameter(key: string, value: SessionParamPrimitive): void;
58
+ /**
59
+ * Clears any runtime session parameters set via `setSessionContext` or `setSessionParameter`.
60
+ */
61
+ clearSessionContext(): void;
62
+ /**
63
+ * Safely returns the current session context map.
64
+ * Always pulls the latest runtime state. Never throws or crashes the thread.
65
+ */
66
+ getCurrentSessionContext(): SessionContextMap;
67
+ /**
68
+ * Normalizes a parameter or session key into a lowercase alphanumeric string
69
+ * for reliable, case-insensitive, and symbol-insensitive matching.
70
+ * E.g. '@BranchId' -> 'branchid', 'branch_id' -> 'branchid', 'BranchID' -> 'branchid'
71
+ */
72
+ normalizeKey(key: string): string;
73
+ /**
74
+ * Checks whether a stored procedure parameter matches any key in the active session context.
75
+ * Supports exact, normalized, and common ERP synonyms.
76
+ */
77
+ matchParameter(paramName: string): SessionParamMatch | null;
78
+ /**
79
+ * Resolves and derives all stored procedure parameters:
80
+ * - Preserves explicit overrides (e.g. from canvas form controls or manual inputs)
81
+ * - Automatically injects matched session parameters
82
+ * - Validates whether required parameters are fulfilled
83
+ */
84
+ deriveParameters(spParams: ProcedureParameterMetadata[], explicitMappings?: Record<string, unknown>): DerivedParametersResult;
85
+ static ɵfac: i0.ɵɵFactoryDeclaration<ReportSessionContextService, never>;
86
+ static ɵprov: i0.ɵɵInjectableDeclaration<ReportSessionContextService>;
87
+ }
@@ -0,0 +1,4 @@
1
+ export { REPORTING_CONFIG, GRID_COMPONENT, CHART_COMPONENT, } from './reporting-config.token';
2
+ export type { ReportingConfig, } from './reporting-config.token';
3
+ export { REPORT_SESSION_CONTEXT, REPORT_SESSION_PROVIDER, SessionContextProvider, } from './session-context.token';
4
+ export type { SessionParamPrimitive, SessionContextMap, SessionContextProviderFn, SessionContextSource, } from './session-context.token';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Reporting library configuration tokens.
3
+ *
4
+ * Core configuration models and injection tokens.
5
+ * Decoupled from UI primitives and data-access adapters.
6
+ */
7
+ import { InjectionToken, Type } from '@angular/core';
8
+ /**
9
+ * Library configuration options.
10
+ */
11
+ export interface ReportingConfig {
12
+ /** Default page size for grids. */
13
+ defaultPageSize: number;
14
+ /** Date format string used across the library. */
15
+ dateFormat: string;
16
+ /** Whether the Designer feature is enabled. */
17
+ enableDesigner: boolean;
18
+ /** Current schema version for new reports. */
19
+ schemaVersion: number;
20
+ /** Base URL for backend reporting endpoints (NestJS / .NET / REST API). */
21
+ apiBaseUrl?: string;
22
+ /** Whether automatic backend schema discovery (SPs & Tables) is enabled. */
23
+ enableSchemaDiscovery?: boolean;
24
+ }
25
+ /**
26
+ * Injection token for the grid component.
27
+ *
28
+ * The host provides their grid component (BWays-grid, AG Grid wrapper, etc.)
29
+ * and the `ReportGridBridgeComponent` resolves it at runtime.
30
+ */
31
+ export declare const GRID_COMPONENT: InjectionToken<Type<unknown>>;
32
+ /**
33
+ * Injection token for the chart component.
34
+ *
35
+ * The host can provide their preferred chart component (Chart.js, Highcharts, ApexCharts wrapper, etc.)
36
+ * and the `ReportChartBridgeComponent` delegates rendering to it, or falls back to built-in SVG charts.
37
+ */
38
+ export declare const CHART_COMPONENT: InjectionToken<Type<unknown>>;
39
+ /**
40
+ * Injection token for the reporting library configuration.
41
+ */
42
+ export declare const REPORTING_CONFIG: InjectionToken<ReportingConfig>;
@@ -0,0 +1,36 @@
1
+ import { InjectionToken, Signal } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ /**
4
+ * Primitive types allowable as session parameter values.
5
+ */
6
+ export type SessionParamPrimitive = string | number | boolean | null | undefined;
7
+ /**
8
+ * Map of session parameters (e.g. { branchId: 1, companyId: 10, userId: 'usr-1' }).
9
+ */
10
+ export type SessionContextMap = Record<string, SessionParamPrimitive>;
11
+ /**
12
+ * Flexible session context provider source:
13
+ * - Plain object: `{ branchId: 1, companyId: 10 }`
14
+ * - Dynamic getter function: `() => authService.currentUserSession()`
15
+ * - Angular Signal: `authService.sessionSignal`
16
+ * - RxJS Observable: `authService.session$`
17
+ */
18
+ export type SessionContextProviderFn = () => SessionContextMap | Signal<SessionContextMap> | Observable<SessionContextMap>;
19
+ export type SessionContextSource = SessionContextMap | SessionContextProviderFn | Observable<SessionContextMap> | Signal<SessionContextMap>;
20
+ /**
21
+ * Injection token for host application session parameters.
22
+ * When configuring `provideReporting({ sessionContext: ... })`, the host app
23
+ * supplies their current session context (e.g. branchId, companyId, userId, tenantId).
24
+ */
25
+ export declare const REPORT_SESSION_CONTEXT: InjectionToken<SessionContextSource>;
26
+ /**
27
+ * Service contract for host applications providing runtime session parameters.
28
+ * A host service (e.g. AuthService, SessionService) can implement this interface/class.
29
+ */
30
+ export declare abstract class SessionContextProvider {
31
+ abstract getSessionContext(): SessionContextMap | Observable<SessionContextMap> | Signal<SessionContextMap> | Promise<SessionContextMap>;
32
+ }
33
+ /**
34
+ * Injection token for host application session provider service class.
35
+ */
36
+ export declare const REPORT_SESSION_PROVIDER: InjectionToken<SessionContextProvider>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates a unique identifier with a given prefix.
3
+ *
4
+ * Safe for modern browser and Node environments.
5
+ *
6
+ * @param prefix - Prefix for the ID (default 'cmp').
7
+ * @returns Unique string ID (e.g. 'cmp-4a7b2c9d').
8
+ */
9
+ export declare function generateId(prefix?: string): string;
@@ -0,0 +1,3 @@
1
+ export { generateId } from './id-generator';
2
+ export { migrateDefinition } from './schema-migration';
3
+ export type { MigrationFn } from './schema-migration';
@@ -0,0 +1,10 @@
1
+ import { ReportDefinition } from '../models/report-definition.model';
2
+ export type MigrationFn = (def: ReportDefinition) => ReportDefinition;
3
+ /**
4
+ * Migrates a ReportDefinition to a target schema version.
5
+ *
6
+ * @param definition - Source report definition.
7
+ * @param targetVersion - Desired schema version (default current version = 1).
8
+ * @returns Migrated ReportDefinition.
9
+ */
10
+ export declare function migrateDefinition(definition: ReportDefinition, targetVersion?: number): ReportDefinition;
@@ -0,0 +1,22 @@
1
+ import { EntityColumnMetadata } from '../../data-access/contracts/schema-discovery.contract';
2
+ /**
3
+ * Strips technical SQL prefixes (usp_, sp_, tbl_, vw_, @), removes schema if present,
4
+ * and converts snake_case, PascalCase, or camelCase into clean, human-readable Title Case.
5
+ *
6
+ * Examples:
7
+ * - 'dbo.usp_GetCustomerList' -> 'Customer List'
8
+ * - 'usp_GetBranches' -> 'Branches'
9
+ * - '@BranchId' -> 'Branch'
10
+ * - '@ActiveOnly' -> 'Active Only'
11
+ * - 'tbl_Products' -> 'Products'
12
+ * - 'customer_name_en' -> 'Customer Name En'
13
+ */
14
+ export declare function humanizeIdentifier(raw: string): string;
15
+ /**
16
+ * Detects the most probable column to use as the value/key (e.g. ID, Code, Key, Guid).
17
+ */
18
+ export declare function detectDefaultValueField(columns: EntityColumnMetadata[]): string | undefined;
19
+ /**
20
+ * Detects the most probable column to use as the display text (e.g. Name, Title, Label, Description).
21
+ */
22
+ export declare function detectDefaultDisplayField(columns: EntityColumnMetadata[]): string | undefined;
@@ -0,0 +1 @@
1
+ export { createValidators, getValidationMessage } from './validation-factory';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Validation factory — converts `ValidationDefinition` metadata
3
+ * into Angular `ValidatorFn[]`.
4
+ *
5
+ * This is a **pure function** — no DI, no Angular TestBed needed.
6
+ * Easily unit-testable.
7
+ */
8
+ import { ValidatorFn } from '@angular/forms';
9
+ import { ValidationDefinition } from '../models/validation.model';
10
+ /**
11
+ * Converts a `ValidationDefinition` into an array of Angular validator functions.
12
+ *
13
+ * @param definition - Validation metadata from the report definition.
14
+ * @returns Array of Angular `ValidatorFn` to apply to a form control.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const validators = createValidators({ required: true, maxLength: 100 });
19
+ * const control = new FormControl('', validators);
20
+ * ```
21
+ */
22
+ export declare function createValidators(definition?: ValidationDefinition): ValidatorFn[];
23
+ /**
24
+ * Extracts a user-facing validation error message from a validation definition
25
+ * and error key.
26
+ *
27
+ * @param definition - Validation metadata.
28
+ * @param errorKey - The validation error key (e.g., 'required', 'maxlength').
29
+ * @returns The custom message if defined, or a default message.
30
+ */
31
+ export declare function getValidationMessage(definition: ValidationDefinition | undefined, errorKey: string): string;
@@ -0,0 +1,19 @@
1
+ import { Observable } from 'rxjs';
2
+ import { LookupOptionItem, LookupQueryRequest, ReportLookupAdapter } from '../contracts/lookup.contract';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Built-in HTTP adapter for fetching dropdown options from backend database tables and SPs.
6
+ * Includes in-memory caching with TTL and rich fallback mock data for testing.
7
+ */
8
+ export declare class HttpReportLookupAdapter extends ReportLookupAdapter {
9
+ private readonly http;
10
+ private readonly config;
11
+ private readonly cache;
12
+ private readonly mockDataStore;
13
+ fetchOptions(request: LookupQueryRequest): Observable<LookupOptionItem[]>;
14
+ private setCache;
15
+ private generateCacheKey;
16
+ private resolveMockOptions;
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<HttpReportLookupAdapter, never>;
18
+ static ɵprov: i0.ɵɵInjectableDeclaration<HttpReportLookupAdapter>;
19
+ }
@@ -0,0 +1,20 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DatabaseEntityMetadata, DatabaseEntityType, EntityColumnMetadata, ProcedureParameterMetadata, ReportSchemaDiscoveryAdapter } from '../contracts/schema-discovery.contract';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Built-in HTTP adapter for backend database schema discovery.
6
+ * Connects to NestJS / REST backend endpoints, with fallback mock schema for development.
7
+ */
8
+ export declare class HttpReportSchemaDiscoveryAdapter extends ReportSchemaDiscoveryAdapter {
9
+ private readonly http;
10
+ private readonly config;
11
+ private readonly mockEntities;
12
+ private readonly mockColumns;
13
+ private readonly mockParameters;
14
+ getEntities(types?: DatabaseEntityType[]): Observable<DatabaseEntityMetadata[]>;
15
+ getColumns(entityName: string, schema?: string, type?: DatabaseEntityType): Observable<EntityColumnMetadata[]>;
16
+ getParameters(entityName: string, schema?: string): Observable<ProcedureParameterMetadata[]>;
17
+ private filterMockEntities;
18
+ static ɵfac: i0.ɵɵFactoryDeclaration<HttpReportSchemaDiscoveryAdapter, never>;
19
+ static ɵprov: i0.ɵɵInjectableDeclaration<HttpReportSchemaDiscoveryAdapter>;
20
+ }
@@ -0,0 +1,2 @@
1
+ export { HttpReportSchemaDiscoveryAdapter } from './http-schema-discovery.adapter';
2
+ export { HttpReportLookupAdapter } from './http-lookup.adapter';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Data-access contracts — abstract classes the host application implements.
3
+ *
4
+ * The library defines WHAT data it needs; the host defines HOW to get it.
5
+ * This keeps the library host-independent.
6
+ */
7
+ import { Observable } from 'rxjs';
8
+ import { ReportDataSourceDefinition } from '../../core/models/report-datasource.model';
9
+ /**
10
+ * Contract for executing report data source queries.
11
+ *
12
+ * The host application provides a concrete implementation that
13
+ * calls the appropriate backend (REST API, stored procedures, etc.).
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Host implementation
18
+ * @Injectable()
19
+ * export class MyDataSourceAdapter extends ReportDataSourceAdapter {
20
+ * constructor(private http: HttpClient) { super(); }
21
+ *
22
+ * execute(dataSource, parameters) {
23
+ * return this.http.post(dataSource.endpoint, parameters);
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export declare abstract class ReportDataSourceAdapter {
29
+ /**
30
+ * Execute a data source query and return the result rows.
31
+ *
32
+ * @param dataSource - The data source definition from the report metadata.
33
+ * @param parameters - Current parameter values from the report form.
34
+ * @returns Observable of result rows.
35
+ */
36
+ abstract execute(dataSource: ReportDataSourceDefinition, parameters: Record<string, unknown>): Observable<unknown[]>;
37
+ }
@@ -0,0 +1,9 @@
1
+ export { ReportDataSourceAdapter } from './data-source.contract';
2
+ export { MasterDataProvider } from './master-data.provider';
3
+ export type { MasterDataOptions, MasterDataItem } from './master-data.provider';
4
+ export { ReportPersistenceAdapter } from './report-persistence.contract';
5
+ export { ReportTranslationAdapter } from './translation.contract';
6
+ export { ReportSchemaDiscoveryAdapter } from './schema-discovery.contract';
7
+ export type { DatabaseEntityType, DatabaseEntityMetadata, EntityColumnMetadata, ProcedureParameterMetadata, } from './schema-discovery.contract';
8
+ export { ReportLookupAdapter } from './lookup.contract';
9
+ export type { LookupQueryRequest, LookupOptionItem } from './lookup.contract';
@@ -0,0 +1,32 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DropdownSourceType } from '../../core/models/report-component.model';
3
+ /**
4
+ * Request payload for querying lookup data from the host backend
5
+ */
6
+ export interface LookupQueryRequest {
7
+ sourceType: DropdownSourceType;
8
+ entityName?: string;
9
+ schema?: string;
10
+ valueField: string;
11
+ displayField: string;
12
+ filter?: Record<string, unknown>;
13
+ parameters?: Record<string, unknown>;
14
+ limit?: number;
15
+ }
16
+ /**
17
+ * Normalized option item for dropdowns and selectors
18
+ */
19
+ export interface LookupOptionItem {
20
+ value: string | number;
21
+ label: string;
22
+ raw?: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Abstract contract for fetching dynamic lookup/option data for report dropdown components.
26
+ */
27
+ export declare abstract class ReportLookupAdapter {
28
+ /**
29
+ * Fetches dropdown option rows from database table or stored procedure.
30
+ */
31
+ abstract fetchOptions(request: LookupQueryRequest): Observable<LookupOptionItem[]>;
32
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Master data provider contract.
3
+ *
4
+ * Provides lookup/reference data for report components
5
+ * (e.g., dropdown options for customers, products, branches).
6
+ */
7
+ import { Observable } from 'rxjs';
8
+ /**
9
+ * Options for querying master data.
10
+ */
11
+ export interface MasterDataOptions {
12
+ /** Search/filter text. */
13
+ searchText?: string;
14
+ /** Maximum number of items to return. */
15
+ limit?: number;
16
+ /** Additional filter parameters. */
17
+ filter?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * A single master data item.
21
+ */
22
+ export interface MasterDataItem {
23
+ /** The value to store. */
24
+ value: unknown;
25
+ /** The display label. */
26
+ label: string;
27
+ /** Additional data fields. */
28
+ [key: string]: unknown;
29
+ }
30
+ /**
31
+ * Contract for providing master/lookup data to report components.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * @Injectable()
36
+ * export class MyMasterDataProvider extends MasterDataProvider {
37
+ * constructor(private http: HttpClient) { super(); }
38
+ *
39
+ * getMasterData(masterName, options) {
40
+ * return this.http.get(`/api/master/${masterName}`, { params: options });
41
+ * }
42
+ * }
43
+ * ```
44
+ */
45
+ export declare abstract class MasterDataProvider {
46
+ /**
47
+ * Fetch master data items by name.
48
+ *
49
+ * @param masterName - The master data set name (e.g., 'customers', 'products').
50
+ * @param options - Optional filtering/pagination.
51
+ * @returns Observable of master data items.
52
+ */
53
+ abstract getMasterData(masterName: string, options?: MasterDataOptions): Observable<MasterDataItem[]>;
54
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Report persistence contract.
3
+ *
4
+ * The host application implements this to save/load report definitions
5
+ * to/from their backend (database, file system, API, etc.).
6
+ */
7
+ import { Observable } from 'rxjs';
8
+ import { ReportDefinition, ReportSummary } from '../../core/models/report-definition.model';
9
+ /**
10
+ * Contract for persisting report definitions.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * @Injectable()
15
+ * export class MyPersistenceAdapter extends ReportPersistenceAdapter {
16
+ * constructor(private http: HttpClient) { super(); }
17
+ *
18
+ * load(reportId) {
19
+ * return this.http.get<ReportDefinition>(`/api/reports/${reportId}`);
20
+ * }
21
+ * // ... other methods
22
+ * }
23
+ * ```
24
+ */
25
+ export declare abstract class ReportPersistenceAdapter {
26
+ /** Load a full report definition by ID. */
27
+ abstract load(reportId: string): Observable<ReportDefinition>;
28
+ /** Save (create or update) a report definition. */
29
+ abstract save(report: ReportDefinition): Observable<ReportDefinition>;
30
+ /** List available reports (summaries only). */
31
+ abstract list(): Observable<ReportSummary[]>;
32
+ /** Delete a report by ID. */
33
+ abstract delete(reportId: string): Observable<void>;
34
+ /** Publish a specific version of a report. */
35
+ abstract publish(reportId: string, version: number): Observable<void>;
36
+ }
@@ -0,0 +1,52 @@
1
+ import { Observable } from 'rxjs';
2
+ export type DatabaseEntityType = 'table' | 'view' | 'stored_procedure';
3
+ /**
4
+ * Metadata for a database entity (table, view, or stored procedure)
5
+ */
6
+ export interface DatabaseEntityMetadata {
7
+ name: string;
8
+ schema: string;
9
+ type: DatabaseEntityType;
10
+ friendlyName?: string;
11
+ category?: string;
12
+ description?: string;
13
+ }
14
+ /**
15
+ * Metadata for an entity column or stored procedure return field
16
+ */
17
+ export interface EntityColumnMetadata {
18
+ field: string;
19
+ label: string;
20
+ dataType: 'string' | 'number' | 'date' | 'boolean';
21
+ nullable?: boolean;
22
+ }
23
+ /**
24
+ * Metadata for stored procedure parameters
25
+ */
26
+ export interface ProcedureParameterMetadata {
27
+ name: string;
28
+ friendlyLabel?: string;
29
+ description?: string;
30
+ dataType: 'string' | 'number' | 'date' | 'boolean';
31
+ sqlType: string;
32
+ required: boolean;
33
+ defaultValue?: unknown;
34
+ }
35
+ /**
36
+ * Abstract contract for discovering backend database schemas, entities, columns, and parameters.
37
+ * Enables the Visual Designer to discover tables and procedures without tight coupling.
38
+ */
39
+ export declare abstract class ReportSchemaDiscoveryAdapter {
40
+ /**
41
+ * Retrieves list of database tables, views, or stored procedures.
42
+ */
43
+ abstract getEntities(types?: DatabaseEntityType[]): Observable<DatabaseEntityMetadata[]>;
44
+ /**
45
+ * Retrieves columns for a specific table, view, or stored procedure.
46
+ */
47
+ abstract getColumns(entityName: string, schema?: string, type?: DatabaseEntityType): Observable<EntityColumnMetadata[]>;
48
+ /**
49
+ * Retrieves parameters for a stored procedure.
50
+ */
51
+ abstract getParameters(entityName: string, schema?: string): Observable<ProcedureParameterMetadata[]>;
52
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Translation adapter contract.
3
+ *
4
+ * Allows host ERP applications to plug in their own i18n/translation
5
+ * system (e.g. @ngx-translate, Transloco, or custom backend dictionary).
6
+ */
7
+ export declare abstract class ReportTranslationAdapter {
8
+ /**
9
+ * Translate a given key into the current active language.
10
+ *
11
+ * @param key - Translation key or default label.
12
+ * @param params - Optional interpolation parameters.
13
+ * @returns Translated string, or key if no translation found.
14
+ */
15
+ abstract translate(key: string, params?: Record<string, string | number>): string;
16
+ }
@@ -0,0 +1,2 @@
1
+ export * from './contracts';
2
+ export * from './adapters';