digitaltwin-core 0.8.0 → 0.8.1

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 (41) hide show
  1. package/dist/components/handler.d.ts +70 -9
  2. package/dist/components/handler.d.ts.map +1 -1
  3. package/dist/components/handler.js +45 -6
  4. package/dist/components/handler.js.map +1 -1
  5. package/dist/components/harvester.d.ts +129 -20
  6. package/dist/components/harvester.d.ts.map +1 -1
  7. package/dist/components/harvester.js +134 -41
  8. package/dist/components/harvester.js.map +1 -1
  9. package/dist/components/interfaces.d.ts +108 -0
  10. package/dist/components/interfaces.d.ts.map +1 -1
  11. package/dist/components/interfaces.js +6 -0
  12. package/dist/components/interfaces.js.map +1 -1
  13. package/dist/engine/endpoints.d.ts +39 -0
  14. package/dist/engine/endpoints.d.ts.map +1 -1
  15. package/dist/engine/endpoints.js +31 -0
  16. package/dist/engine/endpoints.js.map +1 -1
  17. package/dist/engine/events.d.ts +80 -0
  18. package/dist/engine/events.d.ts.map +1 -1
  19. package/dist/engine/events.js +60 -0
  20. package/dist/engine/events.js.map +1 -1
  21. package/dist/engine/initializer.d.ts +51 -0
  22. package/dist/engine/initializer.d.ts.map +1 -1
  23. package/dist/engine/initializer.js +72 -0
  24. package/dist/engine/initializer.js.map +1 -1
  25. package/dist/env/env.d.ts +101 -0
  26. package/dist/env/env.d.ts.map +1 -1
  27. package/dist/env/env.js +101 -0
  28. package/dist/env/env.js.map +1 -1
  29. package/dist/index.d.ts +17 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +17 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/types/data_record.d.ts +65 -4
  34. package/dist/types/data_record.d.ts.map +1 -1
  35. package/dist/types/data_record.js +6 -0
  36. package/dist/types/data_record.js.map +1 -1
  37. package/dist/utils/servable_endpoint.d.ts +59 -2
  38. package/dist/utils/servable_endpoint.d.ts.map +1 -1
  39. package/dist/utils/servable_endpoint.js +51 -0
  40. package/dist/utils/servable_endpoint.js.map +1 -1
  41. package/package.json +1 -1
@@ -1,31 +1,92 @@
1
+ /**
2
+ * @fileoverview Handler component base class for HTTP endpoint providers
3
+ *
4
+ * Handlers are lightweight, stateless components that expose HTTP endpoints
5
+ * for on-demand data access, computation, or utility services within the digital twin.
6
+ */
1
7
  import type { Component, Servable } from './interfaces.js';
2
8
  import type { ComponentConfiguration } from './types.js';
3
9
  import type { DataResponse } from './types.js';
4
10
  import type { HttpMethod } from '../engine/endpoints.js';
5
11
  /**
6
- * Description of a runtime HTTP endpoint handler.
12
+ * Runtime descriptor for an HTTP endpoint handler.
13
+ *
14
+ * Represents a fully resolved endpoint with its bound handler function,
15
+ * ready for registration with the Express router.
7
16
  */
8
17
  type EndpointDescriptor = {
18
+ /** HTTP method for the endpoint */
9
19
  method: HttpMethod;
20
+ /** URL path pattern */
10
21
  path: string;
22
+ /** Response content type */
11
23
  responseType?: string;
24
+ /** Bound handler function */
12
25
  handler: (...args: any[]) => Promise<DataResponse>;
13
26
  };
14
27
  /**
15
- * Base abstract class for defining a Handler component.
16
- * A Handler is a stateless, servable component that exposes HTTP endpoints,
17
- * useful for on-demand computation or utility services.
28
+ * Abstract base class for Handler components.
29
+ *
30
+ * Handlers are lightweight, stateless components that expose HTTP endpoints
31
+ * for on-demand data access, computation, or utility services. Unlike Collectors
32
+ * and Harvesters, they don't run on schedules but respond to HTTP requests.
33
+ *
34
+ * Key features:
35
+ * - Expose HTTP endpoints using the @servableEndpoint decorator
36
+ * - Stateless operation (no database or storage dependencies by default)
37
+ * - Suitable for real-time computations, data queries, or API proxies
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * class CalculatorHandler extends Handler {
42
+ * getConfiguration() {
43
+ * return {
44
+ * name: 'calculator-handler',
45
+ * type: 'handler',
46
+ * contentType: 'application/json'
47
+ * };
48
+ * }
49
+ *
50
+ * @servableEndpoint({ path: '/api/calculate/sum', method: 'post' })
51
+ * async calculateSum(req: Request) {
52
+ * const { a, b } = req.body;
53
+ * return {
54
+ * status: 200,
55
+ * content: { result: a + b }
56
+ * };
57
+ * }
58
+ * }
59
+ * ```
18
60
  */
19
61
  export declare abstract class Handler implements Component, Servable {
20
62
  /**
21
- * Returns the static configuration of the handler.
22
- * Must be implemented by subclasses.
63
+ * Returns the handler's configuration.
64
+ *
65
+ * Implementations must provide basic component information including
66
+ * name, type, and default content type for responses.
67
+ *
68
+ * @returns Component configuration object
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * getConfiguration() {
73
+ * return {
74
+ * name: 'my-handler',
75
+ * type: 'handler',
76
+ * contentType: 'application/json'
77
+ * };
78
+ * }
79
+ * ```
23
80
  */
24
81
  abstract getConfiguration(): ComponentConfiguration;
25
82
  /**
26
- * Resolves and returns the list of servable endpoints defined on the class.
27
- * Uses static metadata declared on the constructor (__endpoints).
28
- * @returns A list of endpoint descriptors mapping method/path to handlers.
83
+ * Resolves and returns HTTP endpoints defined on this handler.
84
+ *
85
+ * Automatically discovers endpoints declared with the @servableEndpoint
86
+ * decorator and creates bound handler functions for registration with
87
+ * the Express router.
88
+ *
89
+ * @returns Array of endpoint descriptors with bound handler functions
29
90
  */
30
91
  getEndpoints(): EndpointDescriptor[];
31
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/components/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAYxD;;GAEG;AACH,KAAK,kBAAkB,GAAG;IACtB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;CACrD,CAAA;AAED;;;;GAIG;AACH,8BAAsB,OAAQ,YAAW,SAAS,EAAE,QAAQ;IACxD;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,IAAI,sBAAsB;IAEnD;;;;OAIG;IACH,YAAY,IAAI,kBAAkB,EAAE;CAevC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/components/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAsBxD;;;;;GAKG;AACH,KAAK,kBAAkB,GAAG;IACtB,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAElB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IAEZ,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,6BAA6B;IAC7B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;CACrD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,8BAAsB,OAAQ,YAAW,SAAS,EAAE,QAAQ;IACxD;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,gBAAgB,IAAI,sBAAsB;IAEnD;;;;;;;;OAQG;IACH,YAAY,IAAI,kBAAkB,EAAE;CAevC"}
@@ -1,13 +1,52 @@
1
1
  /**
2
- * Base abstract class for defining a Handler component.
3
- * A Handler is a stateless, servable component that exposes HTTP endpoints,
4
- * useful for on-demand computation or utility services.
2
+ * @fileoverview Handler component base class for HTTP endpoint providers
3
+ *
4
+ * Handlers are lightweight, stateless components that expose HTTP endpoints
5
+ * for on-demand data access, computation, or utility services within the digital twin.
6
+ */
7
+ /**
8
+ * Abstract base class for Handler components.
9
+ *
10
+ * Handlers are lightweight, stateless components that expose HTTP endpoints
11
+ * for on-demand data access, computation, or utility services. Unlike Collectors
12
+ * and Harvesters, they don't run on schedules but respond to HTTP requests.
13
+ *
14
+ * Key features:
15
+ * - Expose HTTP endpoints using the @servableEndpoint decorator
16
+ * - Stateless operation (no database or storage dependencies by default)
17
+ * - Suitable for real-time computations, data queries, or API proxies
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * class CalculatorHandler extends Handler {
22
+ * getConfiguration() {
23
+ * return {
24
+ * name: 'calculator-handler',
25
+ * type: 'handler',
26
+ * contentType: 'application/json'
27
+ * };
28
+ * }
29
+ *
30
+ * @servableEndpoint({ path: '/api/calculate/sum', method: 'post' })
31
+ * async calculateSum(req: Request) {
32
+ * const { a, b } = req.body;
33
+ * return {
34
+ * status: 200,
35
+ * content: { result: a + b }
36
+ * };
37
+ * }
38
+ * }
39
+ * ```
5
40
  */
6
41
  export class Handler {
7
42
  /**
8
- * Resolves and returns the list of servable endpoints defined on the class.
9
- * Uses static metadata declared on the constructor (__endpoints).
10
- * @returns A list of endpoint descriptors mapping method/path to handlers.
43
+ * Resolves and returns HTTP endpoints defined on this handler.
44
+ *
45
+ * Automatically discovers endpoints declared with the @servableEndpoint
46
+ * decorator and creates bound handler functions for registration with
47
+ * the Express router.
48
+ *
49
+ * @returns Array of endpoint descriptors with bound handler functions
11
50
  */
12
51
  getEndpoints() {
13
52
  const config = this.getConfiguration();
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/components/handler.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,OAAgB,OAAO;IAOzB;;;;OAIG;IACH,YAAY;QACR,MAAM,MAAM,GAAG,IAAI,CAAC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N,CAAC;CACJ"}
@@ -5,47 +5,144 @@ import type { DatabaseAdapter } from '../database/database_adapter.js';
5
5
  import type { StorageService } from '../storage/storage_service.js';
6
6
  import type { HttpMethod } from '../engine/endpoints.js';
7
7
  /**
8
- * Abstract Harvester class for processing collected data
8
+ * Abstract base class for data harvesting components.
9
+ *
10
+ * Harvesters process and analyze data that has been collected by Collectors,
11
+ * applying transformations, aggregations, or other data processing operations.
12
+ * They can be triggered by new source data or run on a schedule.
13
+ *
14
+ * Key features:
15
+ * - Process existing collected data with configurable ranges
16
+ * - Support both time-based and count-based data retrieval
17
+ * - Can be triggered by source data changes or scheduled execution
18
+ * - Provide HTTP endpoints for accessing processed results
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * class TrafficAnalysisHarvester extends Harvester {
23
+ * getUserConfiguration() {
24
+ * return {
25
+ * name: 'traffic-analysis',
26
+ * type: 'harvester',
27
+ * source: 'traffic-collector',
28
+ * source_range: '1h', // Process last hour of data
29
+ * schedule: '0 *\/15 * * * *' // Run every 15 minutes
30
+ * };
31
+ * }
32
+ *
33
+ * async harvest(data: DataRecord[]): Promise<DataRecord[]> {
34
+ * // Process traffic data and return analysis results
35
+ * return this.analyzeTrafficPatterns(data);
36
+ * }
37
+ * }
38
+ * ```
9
39
  */
10
40
  export declare abstract class Harvester implements Component<HarvesterConfiguration>, ScheduleRunnable, Servable {
11
41
  protected db: DatabaseAdapter;
12
42
  protected storage: StorageService;
13
- setDependencies(db: DatabaseAdapter, storage: StorageService): void;
14
43
  private _configCache?;
15
44
  /**
16
- * Users implement this to provide their basic configuration
45
+ * Injects database and storage dependencies into the harvester.
46
+ *
47
+ * Called during component initialization to provide access to
48
+ * data storage and file operations.
49
+ *
50
+ * @param db - Database adapter for reading source data
51
+ * @param storage - Storage service for file operations
52
+ */
53
+ setDependencies(db: DatabaseAdapter, storage: StorageService): void;
54
+ /**
55
+ * Provides the basic harvester configuration.
56
+ *
57
+ * Implementations must return configuration specifying the harvester's
58
+ * name, data source, processing range, and scheduling information.
59
+ *
60
+ * @returns Basic harvester configuration without defaults applied
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * getUserConfiguration() {
65
+ * return {
66
+ * name: 'weather-analysis',
67
+ * type: 'harvester',
68
+ * source: 'weather-collector',
69
+ * source_range: '24h',
70
+ * schedule: '0 0 * * * *' // Daily at midnight
71
+ * };
72
+ * }
73
+ * ```
17
74
  */
18
75
  abstract getUserConfiguration(): HarvesterConfiguration;
19
76
  /**
20
- * Final configuration with defaults applied
21
- * This is what the engine/scheduler use
77
+ * Returns the complete harvester configuration with defaults applied.
78
+ *
79
+ * Merges user configuration with sensible defaults for optional settings.
80
+ * This final configuration is used by the engine and scheduler.
81
+ *
82
+ * @returns Complete configuration with all defaults applied
22
83
  */
23
84
  getConfiguration(): HarvesterConfiguration;
24
85
  /**
25
- * Override to make schedule optional based on trigger mode
86
+ * Returns the cron schedule for this harvester.
87
+ *
88
+ * For 'on-source' trigger mode, returns empty string (no schedule).
89
+ * For 'scheduled' mode, uses the provided schedule or defaults to every minute.
90
+ *
91
+ * @returns Cron expression string or empty string for source-triggered mode
26
92
  */
27
93
  getSchedule(): string;
28
94
  /**
29
- * Allow subclasses to define custom schedule
95
+ * Allows subclasses to define a custom schedule.
96
+ *
97
+ * Override this method to provide a custom cron expression
98
+ * that differs from the default every-minute schedule.
99
+ *
100
+ * @returns Custom cron expression string
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * getCustomSchedule() {
105
+ * return '0 0 *\/6 * * *'; // Every 6 hours
106
+ * }
107
+ * ```
30
108
  */
31
109
  getCustomSchedule?(): string;
32
- abstract harvest(sourceData: DataRecord | DataRecord[], dependenciesData: Record<string, DataRecord | DataRecord[] | null>): Promise<Buffer | Buffer[]>;
33
110
  /**
34
- * Main execution method - NOUVELLE VERSION SIMPLIFIÉE
111
+ * Processes source data and returns harvested results.
112
+ *
113
+ * This is the main data processing method that implementations must provide.
114
+ * It receives source data (from the configured source component) and any
115
+ * dependency data, then performs analysis, transformation, or aggregation.
116
+ *
117
+ * @param sourceData - Data from the source component (single record or array)
118
+ * @param dependenciesData - Data from dependency components, keyed by component name
119
+ * @returns Processed data as Buffer(s) to be stored
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * async harvest(sourceData: DataRecord[], dependenciesData: Record<string, DataRecord[]>) {
124
+ * const trafficData = sourceData.map(r => JSON.parse(r.data.toString()));
125
+ * const analysis = this.performTrafficAnalysis(trafficData);
126
+ * return Buffer.from(JSON.stringify(analysis));
127
+ * }
128
+ * ```
35
129
  */
36
- run(): Promise<boolean>;
37
- /**
38
- * Get source data within the specified range
39
- */
40
- private getSourceData;
41
- /**
42
- * Get data from dependent components
43
- */
44
- private getDependenciesData;
130
+ abstract harvest(sourceData: DataRecord | DataRecord[], dependenciesData: Record<string, DataRecord | DataRecord[] | null>): Promise<Buffer | Buffer[]>;
45
131
  /**
46
- * Store harvesting results
132
+ * Main execution method for the harvester.
133
+ *
134
+ * Orchestrates the harvesting process by:
135
+ * 1. Determining the date range for data retrieval
136
+ * 2. Fetching source and dependency data
137
+ * 3. Calling the harvest method with the data
138
+ * 4. Storing the results in the database
139
+ *
140
+ * @returns True if harvesting was successful, false if no data to process
141
+ *
142
+ * @throws {Error} When source component is not specified
143
+ * @throws {Error} When data processing fails
47
144
  */
48
- private storeResults;
145
+ run(): Promise<boolean>;
49
146
  /**
50
147
  * HTTP endpoints
51
148
  */
@@ -59,5 +156,17 @@ export declare abstract class Harvester implements Component<HarvesterConfigurat
59
156
  * Retrieve latest harvested data
60
157
  */
61
158
  retrieve(): Promise<DataResponse>;
159
+ /**
160
+ * Get source data within the specified range
161
+ */
162
+ private getSourceData;
163
+ /**
164
+ * Get data from dependent components
165
+ */
166
+ private getDependenciesData;
167
+ /**
168
+ * Store harvesting results
169
+ */
170
+ private storeResults;
62
171
  }
63
172
  //# sourceMappingURL=harvester.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"harvester.d.ts","sourceRoot":"","sources":["../../src/components/har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;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,IAAI,MAAM;IAE5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,OAAO,CACZ,UAAU,EAAE,UAAU,GAAG,UAAU,EAAE,EACrC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,GACnE,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;;;;;;;;;;;;OAaG;IACG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;IA4D7B;;OAEG;IACH,YAAY,IAAI,KAAK,CAAC;QAClB,MAAM,EAAE,UAAU,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;QAChC,YAAY,CAAC,EAAE,MAAM,CAAA;KACxB,CAAC;IAWF;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAoBvC;;OAEG;YACW,aAAa;IAsB3B;;OAEG;YACW,mBAAmB;IAyBjC;;OAEG;YACW,YAAY;CAiC7B"}
@@ -1,8 +1,37 @@
1
1
  /**
2
- * Utility class for handling source range parsing
2
+ * Utility class for parsing harvester source range configurations.
3
+ *
4
+ * Handles conversion of various source range formats (time-based like '1h', '30m'
5
+ * or count-based like '100') into structured date ranges for data retrieval.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Parse time-based range: get data from last hour
10
+ * const result = SourceRangeParser.parseSourceRange(new Date(), '1h');
11
+ *
12
+ * // Parse count-based range: get last 50 records
13
+ * const result = SourceRangeParser.parseSourceRange(new Date(), 50);
14
+ * ```
3
15
  */
4
16
  class SourceRangeParser {
5
17
  static { this.ZERO_DATE = new Date('1970-01-01T00:00:00Z'); }
18
+ /**
19
+ * Gets the zero date used as fallback for empty datasets.
20
+ *
21
+ * @returns Unix epoch date (1970-01-01T00:00:00Z)
22
+ */
23
+ static get zeroDate() {
24
+ return new Date(this.ZERO_DATE);
25
+ }
26
+ /**
27
+ * Parses source range configuration into a structured result.
28
+ *
29
+ * @param latestDate - The latest date in the existing data
30
+ * @param sourceRange - Range specification (e.g., '1h', '30m', '7d', or number for count)
31
+ * @returns Parsed range result with start/end dates or record limit
32
+ *
33
+ * @throws {Error} When source range format is invalid
34
+ */
6
35
  static parseSourceRange(latestDate, sourceRange) {
7
36
  if (!sourceRange) {
8
37
  return { startDate: latestDate, limit: 1 };
@@ -39,6 +68,14 @@ class SourceRangeParser {
39
68
  const endDate = this.addTime(startDate, value, unit);
40
69
  return { startDate, endDate };
41
70
  }
71
+ /**
72
+ * Adds time to a date based on the specified unit.
73
+ *
74
+ * @param date - Base date to add time to
75
+ * @param value - Amount of time to add
76
+ * @param unit - Time unit ('days', 'hours', 'minutes', 'seconds')
77
+ * @returns New date with added time
78
+ */
42
79
  static addTime(date, value, unit) {
43
80
  const result = new Date(date);
44
81
  switch (unit) {
@@ -57,21 +94,61 @@ class SourceRangeParser {
57
94
  }
58
95
  return result;
59
96
  }
60
- static get zeroDate() {
61
- return new Date(this.ZERO_DATE);
62
- }
63
97
  }
64
98
  /**
65
- * Abstract Harvester class for processing collected data
99
+ * Abstract base class for data harvesting components.
100
+ *
101
+ * Harvesters process and analyze data that has been collected by Collectors,
102
+ * applying transformations, aggregations, or other data processing operations.
103
+ * They can be triggered by new source data or run on a schedule.
104
+ *
105
+ * Key features:
106
+ * - Process existing collected data with configurable ranges
107
+ * - Support both time-based and count-based data retrieval
108
+ * - Can be triggered by source data changes or scheduled execution
109
+ * - Provide HTTP endpoints for accessing processed results
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * class TrafficAnalysisHarvester extends Harvester {
114
+ * getUserConfiguration() {
115
+ * return {
116
+ * name: 'traffic-analysis',
117
+ * type: 'harvester',
118
+ * source: 'traffic-collector',
119
+ * source_range: '1h', // Process last hour of data
120
+ * schedule: '0 *\/15 * * * *' // Run every 15 minutes
121
+ * };
122
+ * }
123
+ *
124
+ * async harvest(data: DataRecord[]): Promise<DataRecord[]> {
125
+ * // Process traffic data and return analysis results
126
+ * return this.analyzeTrafficPatterns(data);
127
+ * }
128
+ * }
129
+ * ```
66
130
  */
67
131
  export class Harvester {
132
+ /**
133
+ * Injects database and storage dependencies into the harvester.
134
+ *
135
+ * Called during component initialization to provide access to
136
+ * data storage and file operations.
137
+ *
138
+ * @param db - Database adapter for reading source data
139
+ * @param storage - Storage service for file operations
140
+ */
68
141
  setDependencies(db, storage) {
69
142
  this.db = db;
70
143
  this.storage = storage;
71
144
  }
72
145
  /**
73
- * Final configuration with defaults applied
74
- * This is what the engine/scheduler use
146
+ * Returns the complete harvester configuration with defaults applied.
147
+ *
148
+ * Merges user configuration with sensible defaults for optional settings.
149
+ * This final configuration is used by the engine and scheduler.
150
+ *
151
+ * @returns Complete configuration with all defaults applied
75
152
  */
76
153
  getConfiguration() {
77
154
  if (this._configCache) {
@@ -95,7 +172,12 @@ export class Harvester {
95
172
  return this._configCache;
96
173
  }
97
174
  /**
98
- * Override to make schedule optional based on trigger mode
175
+ * Returns the cron schedule for this harvester.
176
+ *
177
+ * For 'on-source' trigger mode, returns empty string (no schedule).
178
+ * For 'scheduled' mode, uses the provided schedule or defaults to every minute.
179
+ *
180
+ * @returns Cron expression string or empty string for source-triggered mode
99
181
  */
100
182
  getSchedule() {
101
183
  const config = this.getConfiguration();
@@ -106,7 +188,18 @@ export class Harvester {
106
188
  return '0 * * * * *';
107
189
  }
108
190
  /**
109
- * Main execution method - NOUVELLE VERSION SIMPLIFIÉE
191
+ * Main execution method for the harvester.
192
+ *
193
+ * Orchestrates the harvesting process by:
194
+ * 1. Determining the date range for data retrieval
195
+ * 2. Fetching source and dependency data
196
+ * 3. Calling the harvest method with the data
197
+ * 4. Storing the results in the database
198
+ *
199
+ * @returns True if harvesting was successful, false if no data to process
200
+ *
201
+ * @throws {Error} When source component is not specified
202
+ * @throws {Error} When data processing fails
110
203
  */
111
204
  async run() {
112
205
  const config = this.getConfiguration();
@@ -151,6 +244,38 @@ export class Harvester {
151
244
  await this.storeResults(config, result, sourceData, storageDate);
152
245
  return true;
153
246
  }
247
+ /**
248
+ * HTTP endpoints
249
+ */
250
+ getEndpoints() {
251
+ return [
252
+ {
253
+ method: 'get',
254
+ path: `/${this.getConfiguration().endpoint}`,
255
+ handler: this.retrieve.bind(this),
256
+ responseType: this.getConfiguration().contentType
257
+ }
258
+ ];
259
+ }
260
+ /**
261
+ * Retrieve latest harvested data
262
+ */
263
+ async retrieve() {
264
+ const config = this.getConfiguration();
265
+ const record = await this.db.getLatestByName(config.name);
266
+ if (!record) {
267
+ return {
268
+ status: 404,
269
+ content: 'No data available'
270
+ };
271
+ }
272
+ const blob = await record.data();
273
+ return {
274
+ status: 200,
275
+ content: blob,
276
+ headers: { 'Content-Type': record.contentType }
277
+ };
278
+ }
154
279
  /**
155
280
  * Get source data within the specified range
156
281
  */
@@ -221,37 +346,5 @@ export class Harvester {
221
346
  });
222
347
  }
223
348
  }
224
- /**
225
- * HTTP endpoints
226
- */
227
- getEndpoints() {
228
- return [
229
- {
230
- method: 'get',
231
- path: `/${this.getConfiguration().endpoint}`,
232
- handler: this.retrieve.bind(this),
233
- responseType: this.getConfiguration().contentType
234
- }
235
- ];
236
- }
237
- /**
238
- * Retrieve latest harvested data
239
- */
240
- async retrieve() {
241
- const config = this.getConfiguration();
242
- const record = await this.db.getLatestByName(config.name);
243
- if (!record) {
244
- return {
245
- status: 404,
246
- content: 'No data available'
247
- };
248
- }
249
- const blob = await record.data();
250
- return {
251
- status: 200,
252
- content: blob,
253
- headers: { 'Content-Type': record.contentType }
254
- };
255
- }
256
349
  }
257
350
  //# sourceMappingURL=harvester.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"harvester.js","sourceRoot":"","sources":["../../src/components/harvester.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,iBAAiB;aACK,cAAS,GAAG,IAAI,IAAI,CAAC,sBAAsB,CA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