digitaltwin-core 0.8.1 → 0.8.2
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.
- package/dist/components/assets_manager.d.ts +2 -2
- package/dist/components/assets_manager.d.ts.map +1 -1
- package/dist/components/assets_manager.js +9 -8
- package/dist/components/assets_manager.js.map +1 -1
- package/dist/components/custom_table_manager.d.ts +1 -1
- package/dist/components/custom_table_manager.d.ts.map +1 -1
- package/dist/components/custom_table_manager.js +23 -13
- package/dist/components/custom_table_manager.js.map +1 -1
- package/dist/components/handler.d.ts +9 -70
- package/dist/components/handler.d.ts.map +1 -1
- package/dist/components/handler.js +6 -45
- package/dist/components/handler.js.map +1 -1
- package/dist/components/harvester.d.ts +20 -129
- package/dist/components/harvester.d.ts.map +1 -1
- package/dist/components/harvester.js +41 -134
- package/dist/components/harvester.js.map +1 -1
- package/dist/components/interfaces.d.ts +0 -108
- package/dist/components/interfaces.d.ts.map +1 -1
- package/dist/components/interfaces.js +0 -6
- package/dist/components/interfaces.js.map +1 -1
- package/dist/components/map_manager.d.ts.map +1 -1
- package/dist/components/tileset_manager.d.ts.map +1 -1
- package/dist/components/types.d.ts +3 -0
- package/dist/components/types.d.ts.map +1 -1
- package/dist/database/adapters/knex_database_adapter.d.ts +2 -15
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -1
- package/dist/database/adapters/knex_database_adapter.js +3 -50
- package/dist/database/adapters/knex_database_adapter.js.map +1 -1
- package/dist/database/database_adapter.d.ts +0 -22
- package/dist/database/database_adapter.d.ts.map +1 -1
- package/dist/database/database_adapter.js.map +1 -1
- package/dist/engine/endpoints.d.ts +0 -39
- package/dist/engine/endpoints.d.ts.map +1 -1
- package/dist/engine/endpoints.js +0 -31
- package/dist/engine/endpoints.js.map +1 -1
- package/dist/engine/events.d.ts +0 -80
- package/dist/engine/events.d.ts.map +1 -1
- package/dist/engine/events.js +0 -60
- package/dist/engine/events.js.map +1 -1
- package/dist/engine/initializer.d.ts +0 -51
- package/dist/engine/initializer.d.ts.map +1 -1
- package/dist/engine/initializer.js +0 -72
- package/dist/engine/initializer.js.map +1 -1
- package/dist/env/env.d.ts +0 -101
- package/dist/env/env.d.ts.map +1 -1
- package/dist/env/env.js +0 -101
- package/dist/env/env.js.map +1 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -18
- package/dist/index.js.map +1 -1
- package/dist/types/data_record.d.ts +4 -65
- package/dist/types/data_record.d.ts.map +1 -1
- package/dist/types/data_record.js +0 -6
- package/dist/types/data_record.js.map +1 -1
- package/dist/utils/servable_endpoint.d.ts +2 -59
- package/dist/utils/servable_endpoint.d.ts.map +1 -1
- package/dist/utils/servable_endpoint.js +0 -51
- package/dist/utils/servable_endpoint.js.map +1 -1
- package/dist/utils/zip_utils.js +1 -1
- package/dist/utils/zip_utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,144 +5,47 @@ 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
|
|
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
|
-
* ```
|
|
8
|
+
* Abstract Harvester class for processing collected data
|
|
39
9
|
*/
|
|
40
10
|
export declare abstract class Harvester implements Component<HarvesterConfiguration>, ScheduleRunnable, Servable {
|
|
41
11
|
protected db: DatabaseAdapter;
|
|
42
12
|
protected storage: StorageService;
|
|
43
|
-
private _configCache?;
|
|
44
|
-
/**
|
|
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
13
|
setDependencies(db: DatabaseAdapter, storage: StorageService): void;
|
|
14
|
+
private _configCache?;
|
|
54
15
|
/**
|
|
55
|
-
*
|
|
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
|
-
* ```
|
|
16
|
+
* Users implement this to provide their basic configuration
|
|
74
17
|
*/
|
|
75
18
|
abstract getUserConfiguration(): HarvesterConfiguration;
|
|
76
19
|
/**
|
|
77
|
-
*
|
|
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
|
|
20
|
+
* Final configuration with defaults applied
|
|
21
|
+
* This is what the engine/scheduler use
|
|
83
22
|
*/
|
|
84
23
|
getConfiguration(): HarvesterConfiguration;
|
|
85
24
|
/**
|
|
86
|
-
*
|
|
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
|
|
25
|
+
* Override to make schedule optional based on trigger mode
|
|
92
26
|
*/
|
|
93
27
|
getSchedule(): string;
|
|
94
28
|
/**
|
|
95
|
-
*
|
|
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
|
-
* ```
|
|
29
|
+
* Allow subclasses to define custom schedule
|
|
108
30
|
*/
|
|
109
31
|
getCustomSchedule?(): string;
|
|
110
|
-
/**
|
|
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
|
-
* ```
|
|
129
|
-
*/
|
|
130
32
|
abstract harvest(sourceData: DataRecord | DataRecord[], dependenciesData: Record<string, DataRecord | DataRecord[] | null>): Promise<Buffer | Buffer[]>;
|
|
131
33
|
/**
|
|
132
|
-
* Main execution method
|
|
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
|
|
34
|
+
* Main execution method - NOUVELLE VERSION SIMPLIFIÉE
|
|
144
35
|
*/
|
|
145
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;
|
|
45
|
+
/**
|
|
46
|
+
* Store harvesting results
|
|
47
|
+
*/
|
|
48
|
+
private storeResults;
|
|
146
49
|
/**
|
|
147
50
|
* HTTP endpoints
|
|
148
51
|
*/
|
|
@@ -156,17 +59,5 @@ export declare abstract class Harvester implements Component<HarvesterConfigurat
|
|
|
156
59
|
* Retrieve latest harvested data
|
|
157
60
|
*/
|
|
158
61
|
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;
|
|
171
62
|
}
|
|
172
63
|
//# sourceMappingURL=harvester.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harvester.d.ts","sourceRoot":"","sources":["../../src/components/harvester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"harvester.d.ts","sourceRoot":"","sources":["../../src/components/harvester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,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|
|
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
|
-
* ```
|
|
2
|
+
* Utility class for handling source range parsing
|
|
15
3
|
*/
|
|
16
4
|
class SourceRangeParser {
|
|
17
5
|
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
|
-
*/
|
|
35
6
|
static parseSourceRange(latestDate, sourceRange) {
|
|
36
7
|
if (!sourceRange) {
|
|
37
8
|
return { startDate: latestDate, limit: 1 };
|
|
@@ -68,14 +39,6 @@ class SourceRangeParser {
|
|
|
68
39
|
const endDate = this.addTime(startDate, value, unit);
|
|
69
40
|
return { startDate, endDate };
|
|
70
41
|
}
|
|
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
|
-
*/
|
|
79
42
|
static addTime(date, value, unit) {
|
|
80
43
|
const result = new Date(date);
|
|
81
44
|
switch (unit) {
|
|
@@ -94,61 +57,21 @@ class SourceRangeParser {
|
|
|
94
57
|
}
|
|
95
58
|
return result;
|
|
96
59
|
}
|
|
60
|
+
static get zeroDate() {
|
|
61
|
+
return new Date(this.ZERO_DATE);
|
|
62
|
+
}
|
|
97
63
|
}
|
|
98
64
|
/**
|
|
99
|
-
* Abstract
|
|
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
|
-
* ```
|
|
65
|
+
* Abstract Harvester class for processing collected data
|
|
130
66
|
*/
|
|
131
67
|
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
|
-
*/
|
|
141
68
|
setDependencies(db, storage) {
|
|
142
69
|
this.db = db;
|
|
143
70
|
this.storage = storage;
|
|
144
71
|
}
|
|
145
72
|
/**
|
|
146
|
-
*
|
|
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
|
|
73
|
+
* Final configuration with defaults applied
|
|
74
|
+
* This is what the engine/scheduler use
|
|
152
75
|
*/
|
|
153
76
|
getConfiguration() {
|
|
154
77
|
if (this._configCache) {
|
|
@@ -172,12 +95,7 @@ export class Harvester {
|
|
|
172
95
|
return this._configCache;
|
|
173
96
|
}
|
|
174
97
|
/**
|
|
175
|
-
*
|
|
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
|
|
98
|
+
* Override to make schedule optional based on trigger mode
|
|
181
99
|
*/
|
|
182
100
|
getSchedule() {
|
|
183
101
|
const config = this.getConfiguration();
|
|
@@ -188,18 +106,7 @@ export class Harvester {
|
|
|
188
106
|
return '0 * * * * *';
|
|
189
107
|
}
|
|
190
108
|
/**
|
|
191
|
-
* Main execution method
|
|
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
|
|
109
|
+
* Main execution method - NOUVELLE VERSION SIMPLIFIÉE
|
|
203
110
|
*/
|
|
204
111
|
async run() {
|
|
205
112
|
const config = this.getConfiguration();
|
|
@@ -244,38 +151,6 @@ export class Harvester {
|
|
|
244
151
|
await this.storeResults(config, result, sourceData, storageDate);
|
|
245
152
|
return true;
|
|
246
153
|
}
|
|
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
|
-
}
|
|
279
154
|
/**
|
|
280
155
|
* Get source data within the specified range
|
|
281
156
|
*/
|
|
@@ -346,5 +221,37 @@ export class Harvester {
|
|
|
346
221
|
});
|
|
347
222
|
}
|
|
348
223
|
}
|
|
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
|
+
}
|
|
349
256
|
}
|
|
350
257
|
//# sourceMappingURL=harvester.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harvester.js","sourceRoot":"","sources":["../../src/components/harvester.ts"],"names":[],"mappings":"
|
|
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,CAAC,CAAA;IAEpE,MAAM,CAAC,gBAAgB,CAAC,UAAgB,EAAE,WAA6B;QACnE,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;QAC9C,CAAC;QAED,kDAAkD;QAClD,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/D,OAAO,EAAE,SAAS,EAAE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,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAExD,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;gBACf,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,WAAW;gBACxB,GAAG;gBACH,IAAI,EAAE,WAAW;aACpB,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACH,YAAY;QAMR,OAAO;YACH;gBACI,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE;gBAC5C,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;gBACjC,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,WAAW;aACpD;SACJ,CAAA;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAEzD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO;gBACH,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,mBAAmB;aAC/B,CAAA;QACL,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QAEhC,OAAO;YACH,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE;SAClD,CAAA;IACL,CAAC;CACJ"}
|
|
@@ -1,125 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Core interfaces defining the contract for digital twin components
|
|
3
|
-
*
|
|
4
|
-
* These interfaces establish the foundation for component architecture, scheduling,
|
|
5
|
-
* and HTTP endpoint serving capabilities within the digital twin ecosystem.
|
|
6
|
-
*/
|
|
7
1
|
import type { ComponentConfiguration } from './types.js';
|
|
8
2
|
import type { HttpMethod } from '../engine/endpoints.js';
|
|
9
|
-
/**
|
|
10
|
-
* Base interface for all digital twin components.
|
|
11
|
-
*
|
|
12
|
-
* Components are the fundamental building blocks of a digital twin system,
|
|
13
|
-
* each responsible for a specific aspect of data management or processing.
|
|
14
|
-
*
|
|
15
|
-
* @template T - The type of configuration object this component uses
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* class MyCollector implements Component<MyCollectorConfig> {
|
|
20
|
-
* getConfiguration(): MyCollectorConfig {
|
|
21
|
-
* return { name: 'my-collector', interval: 5000 };
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
3
|
export interface Component<T extends ComponentConfiguration = ComponentConfiguration> {
|
|
27
|
-
/**
|
|
28
|
-
* Returns the configuration object for this component.
|
|
29
|
-
*
|
|
30
|
-
* The configuration contains metadata about the component such as its name,
|
|
31
|
-
* type, scheduling information, and component-specific settings.
|
|
32
|
-
*
|
|
33
|
-
* @returns The component's configuration object
|
|
34
|
-
*/
|
|
35
4
|
getConfiguration(): T;
|
|
36
5
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Interface for components that can be scheduled to run periodically.
|
|
39
|
-
*
|
|
40
|
-
* Components implementing this interface can be automatically executed
|
|
41
|
-
* by the digital twin engine's scheduler based on a cron expression.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* class DataCollector implements ScheduleRunnable {
|
|
46
|
-
* async run(): Promise<void> {
|
|
47
|
-
* // Collect and process data
|
|
48
|
-
* console.log('Collecting data...');
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* getSchedule(): string {
|
|
52
|
-
* return '0 *.5 * * * *'; // Every 5 minutes
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
6
|
export interface ScheduleRunnable {
|
|
58
|
-
/**
|
|
59
|
-
* Executes the component's main functionality.
|
|
60
|
-
*
|
|
61
|
-
* This method is called automatically by the scheduler according to
|
|
62
|
-
* the schedule returned by getSchedule(). Implementations should handle
|
|
63
|
-
* errors appropriately and return a promise that resolves when the
|
|
64
|
-
* operation is complete.
|
|
65
|
-
*
|
|
66
|
-
* @returns A promise that resolves when the run operation completes
|
|
67
|
-
*/
|
|
68
7
|
run(): Promise<unknown>;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the cron expression defining when this component should run.
|
|
71
|
-
*
|
|
72
|
-
* The schedule follows standard cron syntax (second minute hour day month dayOfWeek).
|
|
73
|
-
*
|
|
74
|
-
* @returns A cron expression string (e.g., '0 *.5 * * * *' for every 5 minutes)
|
|
75
|
-
*/
|
|
76
8
|
getSchedule(): string;
|
|
77
9
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Interface for components that can expose HTTP endpoints.
|
|
80
|
-
*
|
|
81
|
-
* Components implementing this interface can serve HTTP requests,
|
|
82
|
-
* allowing external systems to interact with the digital twin's data
|
|
83
|
-
* and functionality through REST APIs.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* class DataProvider implements Servable {
|
|
88
|
-
* getEndpoints() {
|
|
89
|
-
* return [
|
|
90
|
-
* {
|
|
91
|
-
* method: 'GET',
|
|
92
|
-
* path: '/api/data',
|
|
93
|
-
* handler: this.getData.bind(this),
|
|
94
|
-
* responseType: 'application/json'
|
|
95
|
-
* }
|
|
96
|
-
* ];
|
|
97
|
-
* }
|
|
98
|
-
*
|
|
99
|
-
* private async getData() {
|
|
100
|
-
* return { data: 'example' };
|
|
101
|
-
* }
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
10
|
export interface Servable {
|
|
106
|
-
/**
|
|
107
|
-
* Returns an array of HTTP endpoints this component exposes.
|
|
108
|
-
*
|
|
109
|
-
* Each endpoint defines the HTTP method, URL path, handler function,
|
|
110
|
-
* and optional response content type. The digital twin engine will
|
|
111
|
-
* automatically register these endpoints with the HTTP server.
|
|
112
|
-
*
|
|
113
|
-
* @returns Array of endpoint definitions
|
|
114
|
-
*/
|
|
115
11
|
getEndpoints(): Array<{
|
|
116
|
-
/** HTTP method for this endpoint (GET, POST, PUT, DELETE, etc.) */
|
|
117
12
|
method: HttpMethod;
|
|
118
|
-
/** URL path for this endpoint (e.g., '/api/data') */
|
|
119
13
|
path: string;
|
|
120
|
-
/** Function to handle requests to this endpoint */
|
|
121
14
|
handler: (...args: any[]) => any;
|
|
122
|
-
/** Optional response content type (defaults to 'application/json') */
|
|
123
15
|
responseType?: string;
|
|
124
16
|
}>;
|
|
125
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/components/interfaces.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/components/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB;IAChF,gBAAgB,IAAI,CAAC,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC7B,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACvB,WAAW,IAAI,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,QAAQ;IACrB,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,CAAA;CACL"}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Core interfaces defining the contract for digital twin components
|
|
3
|
-
*
|
|
4
|
-
* These interfaces establish the foundation for component architecture, scheduling,
|
|
5
|
-
* and HTTP endpoint serving capabilities within the digital twin ecosystem.
|
|
6
|
-
*/
|
|
7
1
|
export {};
|
|
8
2
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/components/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/components/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map_manager.d.ts","sourceRoot":"","sources":["../../src/components/map_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"map_manager.d.ts","sourceRoot":"","sources":["../../src/components/map_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAA0B,YAAY,EAAE,MAAM,YAAY,CAAA;AAGtE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAEhB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,8BAAsB,UAAW,SAAQ,aAAa;IAClD;;;;;;;;;;OAUG;IACG,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC;IAqHnD;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IA+D3B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;CAwC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset_manager.d.ts","sourceRoot":"","sources":["../../src/components/tileset_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tileset_manager.d.ts","sourceRoot":"","sources":["../../src/components/tileset_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAA0B,YAAY,EAAE,MAAM,YAAY,CAAA;AAKtE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAEhB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,8BAAsB,cAAe,SAAQ,aAAa;IACtD;;;;;;;;;;OAUG;IACG,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC;IAsJnD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;CAwC1C"}
|
|
@@ -6,6 +6,9 @@ export interface ComponentConfiguration {
|
|
|
6
6
|
/** Allowed file extension for uploads (e.g., '.glb', '.json'). If set, POST/PUT operations will validate file extensions. */
|
|
7
7
|
extension?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface AssetsManagerConfiguration extends ComponentConfiguration {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
}
|
|
9
12
|
export interface CollectorConfiguration extends ComponentConfiguration {
|
|
10
13
|
endpoint: string;
|
|
11
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,6HAA6H;IAC7H,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAE9B,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAE1B,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAE1B,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAEhB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CA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