digitaltwin-core 0.8.2 → 0.9.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 (73) hide show
  1. package/dist/auth/auth_config.d.ts +5 -0
  2. package/dist/auth/auth_config.d.ts.map +1 -1
  3. package/dist/auth/auth_config.js +13 -4
  4. package/dist/auth/auth_config.js.map +1 -1
  5. package/dist/auth/user_service.d.ts.map +1 -1
  6. package/dist/auth/user_service.js +4 -1
  7. package/dist/auth/user_service.js.map +1 -1
  8. package/dist/components/assets_manager.d.ts.map +1 -1
  9. package/dist/components/assets_manager.js +27 -1
  10. package/dist/components/assets_manager.js.map +1 -1
  11. package/dist/components/custom_table_manager.d.ts +143 -2
  12. package/dist/components/custom_table_manager.d.ts.map +1 -1
  13. package/dist/components/custom_table_manager.js +326 -26
  14. package/dist/components/custom_table_manager.js.map +1 -1
  15. package/dist/components/handler.d.ts +70 -9
  16. package/dist/components/handler.d.ts.map +1 -1
  17. package/dist/components/handler.js +45 -6
  18. package/dist/components/handler.js.map +1 -1
  19. package/dist/components/harvester.d.ts +129 -20
  20. package/dist/components/harvester.d.ts.map +1 -1
  21. package/dist/components/harvester.js +134 -41
  22. package/dist/components/harvester.js.map +1 -1
  23. package/dist/components/interfaces.d.ts +108 -0
  24. package/dist/components/interfaces.d.ts.map +1 -1
  25. package/dist/components/interfaces.js +6 -0
  26. package/dist/components/interfaces.js.map +1 -1
  27. package/dist/components/map_manager.d.ts.map +1 -1
  28. package/dist/components/map_manager.js +9 -0
  29. package/dist/components/map_manager.js.map +1 -1
  30. package/dist/components/tileset_manager.d.ts.map +1 -1
  31. package/dist/components/tileset_manager.js +9 -0
  32. package/dist/components/tileset_manager.js.map +1 -1
  33. package/dist/database/adapters/knex_database_adapter.d.ts +15 -2
  34. package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -1
  35. package/dist/database/adapters/knex_database_adapter.js +68 -12
  36. package/dist/database/adapters/knex_database_adapter.js.map +1 -1
  37. package/dist/database/database_adapter.d.ts +22 -0
  38. package/dist/database/database_adapter.d.ts.map +1 -1
  39. package/dist/database/database_adapter.js.map +1 -1
  40. package/dist/engine/digital_twin_engine.d.ts.map +1 -1
  41. package/dist/engine/digital_twin_engine.js +11 -7
  42. package/dist/engine/digital_twin_engine.js.map +1 -1
  43. package/dist/engine/endpoints.d.ts +39 -0
  44. package/dist/engine/endpoints.d.ts.map +1 -1
  45. package/dist/engine/endpoints.js +31 -0
  46. package/dist/engine/endpoints.js.map +1 -1
  47. package/dist/engine/events.d.ts +80 -0
  48. package/dist/engine/events.d.ts.map +1 -1
  49. package/dist/engine/events.js +60 -0
  50. package/dist/engine/events.js.map +1 -1
  51. package/dist/engine/initializer.d.ts +51 -0
  52. package/dist/engine/initializer.d.ts.map +1 -1
  53. package/dist/engine/initializer.js +72 -0
  54. package/dist/engine/initializer.js.map +1 -1
  55. package/dist/env/env.d.ts +101 -0
  56. package/dist/env/env.d.ts.map +1 -1
  57. package/dist/env/env.js +101 -0
  58. package/dist/env/env.js.map +1 -1
  59. package/dist/index.d.ts +19 -1
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +18 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/types/data_record.d.ts +65 -4
  64. package/dist/types/data_record.d.ts.map +1 -1
  65. package/dist/types/data_record.js +6 -0
  66. package/dist/types/data_record.js.map +1 -1
  67. package/dist/utils/servable_endpoint.d.ts +59 -2
  68. package/dist/utils/servable_endpoint.d.ts.map +1 -1
  69. package/dist/utils/servable_endpoint.js +51 -0
  70. package/dist/utils/servable_endpoint.js.map +1 -1
  71. package/dist/utils/zip_utils.js +1 -1
  72. package/dist/utils/zip_utils.js.map +1 -1
  73. package/package.json +1 -1
@@ -1,8 +1,47 @@
1
+ /**
2
+ * @fileoverview HTTP endpoint exposure utilities for digital twin components
3
+ *
4
+ * This module handles the automatic registration of HTTP endpoints from servable
5
+ * components to the Express router, enabling RESTful API access to digital twin data.
6
+ */
1
7
  import type { Router } from 'ultimate-express';
2
8
  import type { Collector } from '../components/collector.js';
3
9
  import type { Harvester } from '../components/harvester.js';
4
10
  import type { Handler } from '../components/handler.js';
5
11
  import type { AssetsManager, CustomTableManager } from '../components/index.js';
12
+ /**
13
+ * Supported HTTP methods for component endpoints.
14
+ *
15
+ * These methods correspond to standard REST operations:
16
+ * - get: Retrieve data
17
+ * - post: Create new resources
18
+ * - put: Update existing resources (full update)
19
+ * - patch: Update existing resources (partial update)
20
+ * - delete: Remove resources
21
+ */
6
22
  export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch';
23
+ /**
24
+ * Automatically registers HTTP endpoints from servable components to an Express router.
25
+ *
26
+ * This function iterates through all provided components, extracts their endpoints,
27
+ * and registers them with the Express router. Each endpoint is wrapped with error
28
+ * handling to ensure robust API behavior.
29
+ *
30
+ * @param router - Express router instance to register endpoints with
31
+ * @param servables - Array of components that expose HTTP endpoints
32
+ *
33
+ * @throws {Error} When an unsupported HTTP method is encountered
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const router = express.Router();
38
+ * const components = [collector1, harvester1, assetsManager1];
39
+ *
40
+ * await exposeEndpoints(router, components);
41
+ *
42
+ * // Now the router has all endpoints from the components registered
43
+ * app.use('/api', router);
44
+ * ```
45
+ */
7
46
  export declare function exposeEndpoints(router: Router, servables: Array<Collector | Harvester | Handler | AssetsManager | CustomTableManager>): Promise<void>;
8
47
  //# sourceMappingURL=endpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/engine/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE/E,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAA;AASpE,wBAAsB,eAAe,CACjC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,kBAAkB,CAAC,GACvF,OAAO,CAAC,IAAI,CAAC,CAqBf"}
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/engine/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE/E;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAA;AAsBpE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACjC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,kBAAkB,CAAC,GACvF,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -1,9 +1,39 @@
1
+ /**
2
+ * @fileoverview HTTP endpoint exposure utilities for digital twin components
3
+ *
4
+ * This module handles the automatic registration of HTTP endpoints from servable
5
+ * components to the Express router, enabling RESTful API access to digital twin data.
6
+ */
7
+ /**
8
+ * Automatically registers HTTP endpoints from servable components to an Express router.
9
+ *
10
+ * This function iterates through all provided components, extracts their endpoints,
11
+ * and registers them with the Express router. Each endpoint is wrapped with error
12
+ * handling to ensure robust API behavior.
13
+ *
14
+ * @param router - Express router instance to register endpoints with
15
+ * @param servables - Array of components that expose HTTP endpoints
16
+ *
17
+ * @throws {Error} When an unsupported HTTP method is encountered
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const router = express.Router();
22
+ * const components = [collector1, harvester1, assetsManager1];
23
+ *
24
+ * await exposeEndpoints(router, components);
25
+ *
26
+ * // Now the router has all endpoints from the components registered
27
+ * app.use('/api', router);
28
+ * ```
29
+ */
1
30
  export async function exposeEndpoints(router, servables) {
2
31
  for (const servable of servables) {
3
32
  const endpoints = servable.getEndpoints();
4
33
  for (const ep of endpoints) {
5
34
  const method = ep.method.toLowerCase();
6
35
  if (typeof router[method] === 'function') {
36
+ // Register endpoint with error handling wrapper
7
37
  router[method](ep.path, async (req, res) => {
8
38
  try {
9
39
  const result = await ep.handler(req);
@@ -12,6 +42,7 @@ export async function exposeEndpoints(router, servables) {
12
42
  .send(result.content);
13
43
  }
14
44
  catch {
45
+ // Generic error response to avoid exposing internal details
15
46
  res.status(500).send({ error: 'Internal server error' });
16
47
  }
17
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../src/engine/endpoints.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,KAAK,UAAU,eAAe,CACjC,MAAc,EACd,SAAsF;IAEtF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAe,QAAQ,CAAC,YAAY,EAAE,CAAA;QACrD,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,EAAgB,CAAA;YACpD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,MAAM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EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;oBAC1D,IAAI,CAAC;wBACD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;wBACpC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;6BACpB,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;6BAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;oBAC7B,CAAC;oBAAC,MAAM,CAAC;wBACL,4DAA4D;wBAC5D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAA;oBAC5D,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,4BAA4B,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;YAC5D,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -1,13 +1,93 @@
1
+ /**
2
+ * @fileoverview Event system for digital twin engine component communication
3
+ *
4
+ * This module provides a centralized event bus for components to communicate
5
+ * asynchronously about their execution status and data processing events.
6
+ */
1
7
  import { EventEmitter } from 'events';
8
+ /**
9
+ * Interface representing an event emitted by digital twin components.
10
+ *
11
+ * Component events provide information about component execution lifecycle,
12
+ * allowing other parts of the system to react to component state changes.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const event: ComponentEvent = {
17
+ * type: 'collector:completed',
18
+ * componentName: 'weather-data-collector',
19
+ * timestamp: new Date(),
20
+ * data: { recordsProcessed: 150 }
21
+ * };
22
+ * ```
23
+ */
2
24
  export interface ComponentEvent {
25
+ /** The type of event that occurred */
3
26
  type: 'collector:completed' | 'harvester:completed';
27
+ /** Name of the component that emitted this event */
4
28
  componentName: string;
29
+ /** Timestamp when the event occurred */
5
30
  timestamp: Date;
31
+ /** Optional additional data related to the event */
6
32
  data?: any;
7
33
  }
34
+ /**
35
+ * Enhanced event bus for digital twin engine component communication.
36
+ *
37
+ * Extends Node.js EventEmitter to provide type-safe event handling
38
+ * for component lifecycle events. All components can emit events
39
+ * to notify other parts of the system about their execution status.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Listen for collector completion events
44
+ * engineEventBus.on('collector:completed', (event) => {
45
+ * console.log(`Collector ${event.componentName} completed at ${event.timestamp}`);
46
+ * });
47
+ *
48
+ * // Emit an event from a component
49
+ * engineEventBus.emit('collector:completed', {
50
+ * type: 'collector:completed',
51
+ * componentName: 'my-collector',
52
+ * timestamp: new Date(),
53
+ * data: { success: true }
54
+ * });
55
+ * ```
56
+ */
8
57
  export declare class EngineEventBus extends EventEmitter {
58
+ /**
59
+ * Emits a component event to all registered listeners.
60
+ *
61
+ * @param event - The event name/type to emit
62
+ * @param data - The component event data
63
+ * @returns True if the event had listeners, false otherwise
64
+ */
9
65
  emit(event: string, data: ComponentEvent): boolean;
66
+ /**
67
+ * Registers a listener for component events.
68
+ *
69
+ * @param event - The event name/type to listen for
70
+ * @param listener - Function to call when the event is emitted
71
+ * @returns This event bus instance for method chaining
72
+ */
10
73
  on(event: string, listener: (data: ComponentEvent) => void): this;
11
74
  }
75
+ /**
76
+ * Global event bus instance for the digital twin engine.
77
+ *
78
+ * This singleton provides a centralized communication channel
79
+ * for all components within the digital twin system.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Listen for all collector events
84
+ * engineEventBus.on('collector:completed', (event) => {
85
+ * console.log(`Collector completed: ${event.componentName}`);
86
+ * });
87
+ *
88
+ * // Components emit events through this bus
89
+ * engineEventBus.emit('collector:completed', eventData);
90
+ * ```
91
+ */
12
92
  export declare const engineEventBus: EngineEventBus;
13
93
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,qBAAqB,GAAG,qBAAqB,CAAA;IACnD,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,IAAI,CAAA;IACf,IAAI,CAAC,EAAE,GAAG,CAAA;CACb;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC5C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAIlD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;CAGpE;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAA"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC3B,sCAAsC;IACtC,IAAI,EAAE,qBAAqB,GAAG,qBAAqB,CAAA;IAEnD,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAA;IAErB,wCAAwC;IACxC,SAAS,EAAE,IAAI,CAAA;IAEf,oDAAoD;IACpD,IAAI,CAAC,EAAE,GAAG,CAAA;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAC5C;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAIlD;;;;;;OAMG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;CAGpE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAA"}
@@ -1,11 +1,71 @@
1
+ /**
2
+ * @fileoverview Event system for digital twin engine component communication
3
+ *
4
+ * This module provides a centralized event bus for components to communicate
5
+ * asynchronously about their execution status and data processing events.
6
+ */
1
7
  import { EventEmitter } from 'events';
8
+ /**
9
+ * Enhanced event bus for digital twin engine component communication.
10
+ *
11
+ * Extends Node.js EventEmitter to provide type-safe event handling
12
+ * for component lifecycle events. All components can emit events
13
+ * to notify other parts of the system about their execution status.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Listen for collector completion events
18
+ * engineEventBus.on('collector:completed', (event) => {
19
+ * console.log(`Collector ${event.componentName} completed at ${event.timestamp}`);
20
+ * });
21
+ *
22
+ * // Emit an event from a component
23
+ * engineEventBus.emit('collector:completed', {
24
+ * type: 'collector:completed',
25
+ * componentName: 'my-collector',
26
+ * timestamp: new Date(),
27
+ * data: { success: true }
28
+ * });
29
+ * ```
30
+ */
2
31
  export class EngineEventBus extends EventEmitter {
32
+ /**
33
+ * Emits a component event to all registered listeners.
34
+ *
35
+ * @param event - The event name/type to emit
36
+ * @param data - The component event data
37
+ * @returns True if the event had listeners, false otherwise
38
+ */
3
39
  emit(event, data) {
4
40
  return super.emit(event, data);
5
41
  }
42
+ /**
43
+ * Registers a listener for component events.
44
+ *
45
+ * @param event - The event name/type to listen for
46
+ * @param listener - Function to call when the event is emitted
47
+ * @returns This event bus instance for method chaining
48
+ */
6
49
  on(event, listener) {
7
50
  return super.on(event, listener);
8
51
  }
9
52
  }
53
+ /**
54
+ * Global event bus instance for the digital twin engine.
55
+ *
56
+ * This singleton provides a centralized communication channel
57
+ * for all components within the digital twin system.
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Listen for all collector events
62
+ * engineEventBus.on('collector:completed', (event) => {
63
+ * console.log(`Collector completed: ${event.componentName}`);
64
+ * });
65
+ *
66
+ * // Components emit events through this bus
67
+ * engineEventBus.emit('collector:completed', eventData);
68
+ * ```
69
+ */
10
70
  export const engineEventBus = new EngineEventBus();
11
71
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AASrC,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC5C,IAAI,CAAC,KAAa,EAAE,IAAoB;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,EAAE,CAAC,KAAa,EAAE,QAAwC;QACtD,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/engine/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAgCrC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC5C;;;;;;OAMG;IACH,IAAI,CAAC,KAAa,EAAE,IAAoB;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;OAMG;IACH,EAAE,CAAC,KAAa,EAAE,QAAwC;QACtD,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAA"}
@@ -1,8 +1,59 @@
1
+ /**
2
+ * @fileoverview Component initialization utilities for the digital twin engine
3
+ *
4
+ * This module handles the setup and initialization of digital twin components,
5
+ * including database table creation and dependency injection.
6
+ */
1
7
  import type { Collector } from '../components/collector.js';
2
8
  import type { Harvester } from '../components/harvester.js';
3
9
  import type { AssetsManager } from '../components/assets_manager.js';
4
10
  import type { DatabaseAdapter } from '../database/database_adapter.js';
5
11
  import type { StorageService } from '../storage/storage_service.js';
12
+ /**
13
+ * Initializes data collection and processing components with required dependencies.
14
+ *
15
+ * This function sets up collectors and harvesters by:
16
+ * 1. Creating necessary database tables for each component
17
+ * 2. Injecting database and storage service dependencies
18
+ *
19
+ * @param components - Array of collectors and harvesters to initialize
20
+ * @param database - Database adapter instance for data storage
21
+ * @param storage - Storage service instance for file operations
22
+ *
23
+ * @throws {Error} When database table creation fails
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const components = [weatherCollector, trafficHarvester];
28
+ * const database = new KnexDatabaseAdapter(config);
29
+ * const storage = new LocalStorageService();
30
+ *
31
+ * await initializeComponents(components, database, storage);
32
+ * // Components are now ready to process data
33
+ * ```
34
+ */
6
35
  export declare function initializeComponents(components: Array<Collector | Harvester>, database: DatabaseAdapter, storage: StorageService): Promise<void>;
36
+ /**
37
+ * Initializes asset management components with required dependencies.
38
+ *
39
+ * Asset managers handle file-based resources (like 3D models, tilesets, maps)
40
+ * and require both database access for metadata and storage for file operations.
41
+ *
42
+ * @param assetsManagers - Array of asset managers to initialize
43
+ * @param database - Database adapter instance for metadata storage
44
+ * @param storage - Storage service instance for asset file operations
45
+ *
46
+ * @throws {Error} When database table creation fails
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const managers = [tilesetManager, pointCloudManager];
51
+ * const database = new KnexDatabaseAdapter(config);
52
+ * const storage = new OvhS3StorageService(credentials);
53
+ *
54
+ * await initializeAssetsManagers(managers, database, storage);
55
+ * // Asset managers are now ready to handle file operations
56
+ * ```
57
+ */
7
58
  export declare function initializeAssetsManagers(assetsManagers: AssetsManager[], database: DatabaseAdapter, storage: StorageService): Promise<void>;
8
59
  //# sourceMappingURL=initializer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initializer.d.ts","sourceRoot":"","sources":["../../src/engine/initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA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AAQ,EAAE,eAAe,EACzB,OAAO,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -1,3 +1,32 @@
1
+ /**
2
+ * @fileoverview Component initialization utilities for the digital twin engine
3
+ *
4
+ * This module handles the setup and initialization of digital twin components,
5
+ * including database table creation and dependency injection.
6
+ */
7
+ /**
8
+ * Initializes data collection and processing components with required dependencies.
9
+ *
10
+ * This function sets up collectors and harvesters by:
11
+ * 1. Creating necessary database tables for each component
12
+ * 2. Injecting database and storage service dependencies
13
+ *
14
+ * @param components - Array of collectors and harvesters to initialize
15
+ * @param database - Database adapter instance for data storage
16
+ * @param storage - Storage service instance for file operations
17
+ *
18
+ * @throws {Error} When database table creation fails
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const components = [weatherCollector, trafficHarvester];
23
+ * const database = new KnexDatabaseAdapter(config);
24
+ * const storage = new LocalStorageService();
25
+ *
26
+ * await initializeComponents(components, database, storage);
27
+ * // Components are now ready to process data
28
+ * ```
29
+ */
1
30
  export async function initializeComponents(components, database, storage) {
2
31
  for (const comp of components) {
3
32
  const config = comp.getConfiguration();
@@ -5,6 +34,28 @@ export async function initializeComponents(components, database, storage) {
5
34
  comp.setDependencies(database, storage);
6
35
  }
7
36
  }
37
+ /**
38
+ * Initializes asset management components with required dependencies.
39
+ *
40
+ * Asset managers handle file-based resources (like 3D models, tilesets, maps)
41
+ * and require both database access for metadata and storage for file operations.
42
+ *
43
+ * @param assetsManagers - Array of asset managers to initialize
44
+ * @param database - Database adapter instance for metadata storage
45
+ * @param storage - Storage service instance for asset file operations
46
+ *
47
+ * @throws {Error} When database table creation fails
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const managers = [tilesetManager, pointCloudManager];
52
+ * const database = new KnexDatabaseAdapter(config);
53
+ * const storage = new OvhS3StorageService(credentials);
54
+ *
55
+ * await initializeAssetsManagers(managers, database, storage);
56
+ * // Asset managers are now ready to handle file operations
57
+ * ```
58
+ */
8
59
  export async function initializeAssetsManagers(assetsManagers, database, storage) {
9
60
  for (const manager of assetsManagers) {
10
61
  const config = manager.getConfiguration();
@@ -12,6 +63,27 @@ export async function initializeAssetsManagers(assetsManagers, database, storage
12
63
  manager.setDependencies(database, storage);
13
64
  }
14
65
  }
66
+ /**
67
+ * Ensures a database table exists for the specified component.
68
+ *
69
+ * Checks if a table exists in the database and creates it if missing.
70
+ * This function is called during component initialization to ensure
71
+ * each component has its required storage table available.
72
+ *
73
+ * @param database - Database adapter to check/create table with
74
+ * @param tableName - Name of the table to ensure exists
75
+ *
76
+ * @throws {Error} When table creation fails
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // Internal usage during component initialization
81
+ * await ensureTableExists(database, 'weather_data_collector');
82
+ * // Table now exists and is ready for use
83
+ * ```
84
+ *
85
+ * @internal This function is used internally by initialization functions
86
+ */
15
87
  async function ensureTableExists(database, tableName) {
16
88
  const exists = await database.doesTableExists(tableName);
17
89
  if (!exists) {
@@ -1 +1 @@
1
- {"version":3,"file":"initializer.js","sourceRoot":"","sources":["../../src/engine/initializer.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACtC,UAAwC,EACxC,QAAyB,EACzB,OAAuB;IAEvB,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACtC,MAAM,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC1C,cAA+B,EAC/B,QAAyB,EACzB,OAAuB;IAEvB,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAA;QACzC,MAAM,iBAAiB,CAAC,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CAAC,IAAI,CAAC,CAAA;QAC9C,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,KAAK,UAAU,iBAAiB,CAAC,QAAyB,EAAE,SAAiB;IACzE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;IACxD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,iCAAiC,SAAS,MAAM,CAAC,CAAA;QAC7D,MAAM,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACrC,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,wBAAwB,CAAC,CAAA;IAC9D,CAAC;AACL,CAAC"}
package/dist/env/env.d.ts CHANGED
@@ -1,5 +1,45 @@
1
+ /**
2
+ * @fileoverview Environment variable validation and configuration management
3
+ *
4
+ * This utility class provides type-safe environment variable parsing with
5
+ * validation rules for string, number, boolean, and enum types.
6
+ */
7
+ /**
8
+ * Environment variable validation and configuration utility.
9
+ *
10
+ * The Env class provides a schema-based approach to validating and parsing
11
+ * environment variables with type safety and format validation.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const config = Env.validate({
16
+ * PORT: Env.schema.number({ optional: true, default: 3000 }),
17
+ * API_URL: Env.schema.string({ format: 'url' }),
18
+ * DEBUG: Env.schema.boolean({ optional: true, default: false }),
19
+ * NODE_ENV: Env.schema.enum(['development', 'production', 'test'])
20
+ * });
21
+ *
22
+ * // config is now type-safe and validated
23
+ * console.log(config.PORT); // number
24
+ * console.log(config.API_URL); // validated URL string
25
+ * ```
26
+ */
1
27
  export declare class Env {
28
+ /**
29
+ * Schema builders for different environment variable types.
30
+ *
31
+ * Provides factory methods for creating validation rules for different
32
+ * data types that can be parsed from environment variables.
33
+ */
2
34
  static schema: {
35
+ /**
36
+ * Creates a string validation rule.
37
+ *
38
+ * @param opts - Optional configuration for string validation
39
+ * @param opts.optional - Whether the environment variable is optional
40
+ * @param opts.format - Format validation ('url' or 'email')
41
+ * @returns String validation rule object
42
+ */
3
43
  string: (opts?: {
4
44
  optional?: boolean;
5
45
  format?: "url" | "email";
@@ -8,12 +48,29 @@ export declare class Env {
8
48
  format?: "url" | "email";
9
49
  type: "string";
10
50
  };
51
+ /**
52
+ * Creates a number validation rule.
53
+ *
54
+ * @param opts - Optional configuration for number validation
55
+ * @param opts.optional - Whether the environment variable is optional
56
+ * @returns Number validation rule object
57
+ */
11
58
  number: (opts?: {
12
59
  optional?: boolean;
13
60
  }) => {
14
61
  optional?: boolean;
15
62
  type: "number";
16
63
  };
64
+ /**
65
+ * Creates a boolean validation rule.
66
+ *
67
+ * Accepts 'true'/'false' or '1'/'0' as valid boolean values.
68
+ *
69
+ * @param opts - Optional configuration for boolean validation
70
+ * @param opts.optional - Whether the environment variable is optional
71
+ * @param opts.default - Default value if the variable is missing
72
+ * @returns Boolean validation rule object
73
+ */
17
74
  boolean: (opts?: {
18
75
  optional?: boolean;
19
76
  default?: boolean;
@@ -22,12 +79,56 @@ export declare class Env {
22
79
  default?: boolean;
23
80
  type: "boolean";
24
81
  };
82
+ /**
83
+ * Creates an enum validation rule.
84
+ *
85
+ * @template T - Array of allowed string values
86
+ * @param values - Array of allowed values for this environment variable
87
+ * @returns Enum validation rule object
88
+ */
25
89
  enum: <T extends string[]>(values: T) => {
26
90
  type: "enum";
27
91
  values: T;
28
92
  };
29
93
  };
94
+ /**
95
+ * Stores the last validated configuration.
96
+ *
97
+ * This static property holds the most recently validated environment
98
+ * configuration for reference by other parts of the application.
99
+ */
30
100
  static config: Record<string, any>;
101
+ /**
102
+ * Validates environment variables against a schema definition.
103
+ *
104
+ * Parses and validates environment variables according to the provided
105
+ * schema, returning a type-safe configuration object.
106
+ *
107
+ * @template T - The expected type of the returned configuration object
108
+ * @param schema - Object mapping environment variable names to validation rules
109
+ * @param rawEnv - Environment variables object (defaults to process.env)
110
+ * @returns Validated and parsed configuration object
111
+ *
112
+ * @throws {Error} When required environment variables are missing
113
+ * @throws {Error} When environment variables fail format validation
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * interface Config {
118
+ * DATABASE_URL: string;
119
+ * PORT: number;
120
+ * DEBUG: boolean;
121
+ * NODE_ENV: 'development' | 'production';
122
+ * }
123
+ *
124
+ * const config: Config = Env.validate({
125
+ * DATABASE_URL: Env.schema.string({ format: 'url' }),
126
+ * PORT: Env.schema.number({ optional: true }),
127
+ * DEBUG: Env.schema.boolean({ optional: true, default: false }),
128
+ * NODE_ENV: Env.schema.enum(['development', 'production'])
129
+ * });
130
+ * ```
131
+ */
31
132
  static validate<T extends Record<string, any>>(schema: Record<string, any>, rawEnv?: NodeJS.ProcessEnv): T;
32
133
  }
33
134
  //# sourceMappingURL=env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,CAAC,MAAM;wBACO;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;SAAE;uBAAnC,OAAO;qBAAW,KAAK,GAAG,OAAO;;;wBAK9C;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;uBAAT,OAAO;;;yBAKnB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAA;SAAE;uBAA5B,OAAO;sBAAY,OAAO;;;eAKjD,CAAC,SAAS,MAAM,EAAE,UAAU,CAAC;;;;MAIvC;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAK;IAEvC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CA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