@openhealth/oht-custom-parser-lib 0.3.13 → 0.4.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 (40) hide show
  1. package/{readme.md → README.md} +0 -16
  2. package/dist/index.d.ts +1 -3
  3. package/dist/index.js +2 -20
  4. package/dist/index.js.map +1 -1
  5. package/dist/service/auxiliaryFunctions.service.d.ts +0 -2
  6. package/dist/service/auxiliaryFunctions.service.js +3 -4
  7. package/dist/service/auxiliaryFunctions.service.js.map +1 -1
  8. package/dist/service/ohtMeasurementsExtractor.service.d.ts +4 -1
  9. package/dist/service/ohtMeasurementsExtractor.service.js +59 -31
  10. package/dist/service/ohtMeasurementsExtractor.service.js.map +1 -1
  11. package/dist/service/ohtReportMeasurementsExtractor.service.d.ts +6 -3
  12. package/dist/service/ohtReportMeasurementsExtractor.service.js +77 -66
  13. package/dist/service/ohtReportMeasurementsExtractor.service.js.map +1 -1
  14. package/dist/service/reportCreator.service.js +55 -48
  15. package/dist/service/reportCreator.service.js.map +1 -1
  16. package/dist/service/slackMessages.service.js +5 -4
  17. package/dist/service/slackMessages.service.js.map +1 -1
  18. package/dist/service/transformationRules.service.js +10 -3
  19. package/dist/service/transformationRules.service.js.map +1 -1
  20. package/dist/types/error.types.d.ts +0 -82
  21. package/dist/types/error.types.js +0 -195
  22. package/dist/types/error.types.js.map +1 -1
  23. package/dist/types/oht.types.d.ts +1 -5
  24. package/dist/types/oht.types.js +0 -4
  25. package/dist/types/oht.types.js.map +1 -1
  26. package/dist/util-ts/apiUtils.js +3 -2
  27. package/dist/util-ts/apiUtils.js.map +1 -1
  28. package/dist/util-ts/dataUtils.js +16 -24
  29. package/dist/util-ts/dataUtils.js.map +1 -1
  30. package/dist/util-ts/extractionUtils.js +8 -4
  31. package/dist/util-ts/extractionUtils.js.map +1 -1
  32. package/dist/util-ts/pinoLogger.js +1 -28
  33. package/dist/util-ts/pinoLogger.js.map +1 -1
  34. package/package.json +3 -6
  35. package/dist/service/fileUploadErrorHandler.service.d.ts +0 -26
  36. package/dist/service/fileUploadErrorHandler.service.js +0 -257
  37. package/dist/service/fileUploadErrorHandler.service.js.map +0 -1
  38. package/dist/service/processingLogger.service.d.ts +0 -158
  39. package/dist/service/processingLogger.service.js +0 -545
  40. package/dist/service/processingLogger.service.js.map +0 -1
@@ -1,158 +0,0 @@
1
- import pino from 'pino';
2
- /**
3
- * Returns a stable request id for the given context. Same id must be used for the whole request.
4
- * Used to key the registry so each request has isolated state.
5
- */
6
- export declare function getRequestIdFromContext(context: ProcessingContext): string;
7
- /**
8
- * Processing context interface - contains all context information for a processing cycle
9
- */
10
- export interface ProcessingContext {
11
- fileName?: string;
12
- fileUploadId?: string;
13
- partnerId?: string;
14
- partnerName?: string;
15
- signedUploadId?: string;
16
- cloudEventId?: string;
17
- messageId?: string;
18
- publishTime?: string;
19
- fileMimeType?: string;
20
- normalizerName?: string;
21
- isPreview?: boolean;
22
- reportPreviewId?: string;
23
- }
24
- /**
25
- * Stage duration interface - tracks timing for each processing stage
26
- */
27
- export interface StageDuration {
28
- step: string;
29
- percentage: number;
30
- startTime: Date;
31
- endTime?: Date;
32
- durationMs?: number;
33
- cumulativeDurationMs?: number;
34
- }
35
- /**
36
- * Processing state interface - internal state tracking for the logger
37
- */
38
- interface ProcessingState {
39
- fileName?: string;
40
- fileUploadId?: string;
41
- partnerId?: string;
42
- partnerName?: string;
43
- signedUploadId?: string;
44
- cloudEventId?: string;
45
- messageId?: string;
46
- publishTime?: string;
47
- fileMimeType?: string;
48
- normalizerName?: string;
49
- isPreview?: boolean;
50
- reportPreviewId?: string;
51
- startTime?: Date;
52
- endTime?: Date;
53
- totalDurationMs?: number;
54
- stages: StageDuration[];
55
- currentStageStartTime?: Date;
56
- currentStep?: string;
57
- progressPercentage?: number;
58
- measurementsCount?: number;
59
- unknownMeasurementsCount?: number;
60
- unknownUnitsCount?: number;
61
- unmappedLabKeysCount?: number;
62
- errors: Array<{
63
- message: string;
64
- step: string;
65
- timestamp: Date;
66
- error?: Error;
67
- }>;
68
- warnings: Array<{
69
- message: string;
70
- step: string;
71
- timestamp: Date;
72
- }>;
73
- success?: boolean;
74
- metadata?: Record<string, any>;
75
- }
76
- /**
77
- * ProcessingLoggerService - Singleton facade for request-scoped processing state and logging.
78
- *
79
- * State is keyed by request id (fileUploadId ?? messageId ?? cloudEventId) in a registry.
80
- * AsyncLocalStorage holds only the current request id; getMutableState() resolves state via
81
- * registry.get(id). When registry.get(id) is undefined (no context or stale id), a transient
82
- * empty state is used so one request never overwrites another's context.
83
- *
84
- * Entry point: runWithContextAsync(context, fn). Creates registry entry, runs fn with id in ALS,
85
- * removes entry in finally. Use logInfo, logWarn, logError, logDebug for application logs so they
86
- * include the same context and are searchable by fileUploadId/filename.
87
- *
88
- * Usage:
89
- * ```typescript
90
- * await runWithContextAsync(context, async () => {
91
- * processingLogger.logStart();
92
- * processingLogger.logProgress(20, 'get_transformation_rules');
93
- * processingLogger.logEnd(true);
94
- * });
95
- * ```
96
- * Initial state is set from context by runWithContextAsync; clear() and setContext() are optional if you need to reset/override.
97
- */
98
- declare class ProcessingLoggerService {
99
- private static instance;
100
- private logger;
101
- private constructor();
102
- static getInstance(): ProcessingLoggerService;
103
- /**
104
- * Resolves state from registry by current request id. When registry.get(id) is undefined
105
- * (no context or stale id), returns a transient clear state so one request never overwrites another's context.
106
- */
107
- private getMutableState;
108
- /**
109
- * Reset all state for a new processing cycle. Call at the start of each Cloud Event / request
110
- * so that context and metrics from a previous request never leak.
111
- * Clears both context fields and run state; call setContext(context) after clear() in handlers.
112
- */
113
- clear(): void;
114
- /**
115
- * Set context for the current processing cycle. Overwrites all context fields.
116
- * Call after clear() for each new request.
117
- */
118
- setContext(context: ProcessingContext): void;
119
- /** Public getter for tests / inspection; returns a deep copy so callers cannot mutate internal state. */
120
- getState(): ProcessingState;
121
- /**
122
- * Replace the underlying logger (for testing only).
123
- * Allows tests to inject a mock logger without mocking the module.
124
- */
125
- setLogger(logger: pino.Logger): void;
126
- /**
127
- * Context for the current log line (from request-scoped state when inside runWithContext).
128
- */
129
- private getLogContext;
130
- logInfo(message: string, data?: Record<string, unknown>): void;
131
- logWarn(message: string, data?: Record<string, unknown>): void;
132
- logError(message: string, error?: Error, data?: Record<string, unknown>): void;
133
- logDebug(message: string, data?: Record<string, unknown>): void;
134
- private startStage;
135
- private endStage;
136
- logStart(): void;
137
- logProgress(percentage: number, step: string): void;
138
- addMeasurement(count: number, type: string): void;
139
- addError(error: Error, step: string): void;
140
- addWarning(message: string, step: string): void;
141
- private calculateStageDurations;
142
- private formatStageDurations;
143
- logEnd(success: boolean): void;
144
- }
145
- export declare const processingLogger: ProcessingLoggerService;
146
- /**
147
- * Run handler logic inside a request-scoped context. State is keyed by request id in the registry;
148
- * ALS holds only the id. Call at the start of each Cloud Event / request after building the context.
149
- * @deprecated Prefer runWithContextAsync for async handlers.
150
- */
151
- export declare function runWithContext<T>(context: ProcessingContext, fn: () => T): T;
152
- /**
153
- * Async variant: run handler logic inside a request-scoped context. Each request gets its own state
154
- * in the registry keyed by request id; ALS holds only the id. Entry is removed in finally so one
155
- * request never overwrites another's context.
156
- */
157
- export declare function runWithContextAsync<T>(context: ProcessingContext, fn: () => Promise<T>): Promise<T>;
158
- export {};