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
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,CAAC,EAAE,MAAM,oBAAc,GAAG,CAAC;CA2DvG"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,GAAG;IACZ;;;;;OAKG;IACH,MAAM,CAAC,MAAM;QACT;;;;;;;WAOG;wBACa;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;SAAE;uBAAnC,OAAO;qBAAW,KAAK,GAAG,OAAO;;;QAK9D;;;;;;WAMG;wBACa;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;uBAAT,OAAO;;;QAKpC;;;;;;;;;WASG;yBACc;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,OAAO,CAAC,EAAE,OAAO,CAAA;SAAE;uBAA5B,OAAO;sBAAY,OAAO;;;QAKxD;;;;;;WAMG;eACI,CAAC,SAAS,MAAM,EAAE,UAAU,CAAC;;;;MAIvC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAK;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,oBAAc,GAAG,CAAC;CA2DvG"}
package/dist/env/env.js CHANGED
@@ -1,23 +1,124 @@
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 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 { this.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
  type: 'string',
5
45
  ...opts
6
46
  }),
47
+ /**
48
+ * Creates a number validation rule.
49
+ *
50
+ * @param opts - Optional configuration for number validation
51
+ * @param opts.optional - Whether the environment variable is optional
52
+ * @returns Number validation rule object
53
+ */
7
54
  number: (opts) => ({
8
55
  type: 'number',
9
56
  ...opts
10
57
  }),
58
+ /**
59
+ * Creates a boolean validation rule.
60
+ *
61
+ * Accepts 'true'/'false' or '1'/'0' as valid boolean values.
62
+ *
63
+ * @param opts - Optional configuration for boolean validation
64
+ * @param opts.optional - Whether the environment variable is optional
65
+ * @param opts.default - Default value if the variable is missing
66
+ * @returns Boolean validation rule object
67
+ */
11
68
  boolean: (opts) => ({
12
69
  type: 'boolean',
13
70
  ...opts
14
71
  }),
72
+ /**
73
+ * Creates an enum validation rule.
74
+ *
75
+ * @template T - Array of allowed string values
76
+ * @param values - Array of allowed values for this environment variable
77
+ * @returns Enum validation rule object
78
+ */
15
79
  enum: (values) => ({
16
80
  type: 'enum',
17
81
  values
18
82
  })
19
83
  }; }
84
+ /**
85
+ * Stores the last validated configuration.
86
+ *
87
+ * This static property holds the most recently validated environment
88
+ * configuration for reference by other parts of the application.
89
+ */
20
90
  static { this.config = {}; }
91
+ /**
92
+ * Validates environment variables against a schema definition.
93
+ *
94
+ * Parses and validates environment variables according to the provided
95
+ * schema, returning a type-safe configuration object.
96
+ *
97
+ * @template T - The expected type of the returned configuration object
98
+ * @param schema - Object mapping environment variable names to validation rules
99
+ * @param rawEnv - Environment variables object (defaults to process.env)
100
+ * @returns Validated and parsed configuration object
101
+ *
102
+ * @throws {Error} When required environment variables are missing
103
+ * @throws {Error} When environment variables fail format validation
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * interface Config {
108
+ * DATABASE_URL: string;
109
+ * PORT: number;
110
+ * DEBUG: boolean;
111
+ * NODE_ENV: 'development' | 'production';
112
+ * }
113
+ *
114
+ * const config: Config = Env.validate({
115
+ * DATABASE_URL: Env.schema.string({ format: 'url' }),
116
+ * PORT: Env.schema.number({ optional: true }),
117
+ * DEBUG: Env.schema.boolean({ optional: true, default: false }),
118
+ * NODE_ENV: Env.schema.enum(['development', 'production'])
119
+ * });
120
+ * ```
121
+ */
21
122
  static validate(schema, rawEnv = process.env) {
22
123
  const config = {};
23
124
  for (const [key, rules] of Object.entries(schema)) {
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;aACL,WAAM,GAAG;QACZ,MAAM,EAAE,CAAC,IAAuD,EAAE,EAAE,CAAC,CAAC;YAClE,IAAI,EAAE,QAAiB;YACvB,GAAG,IAAI;SACV,CAAC;QAEF,MAAM,EAAE,CAAC,IAA6B,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,QAAiB;YACvB,GAAG,IAAI;SACV,CAAC;QAEF,OAAO,EAAE,CAAC,IAAgD,EAAE,EAAE,CAAC,CAAC;YAC5D,IAAI,EAAE,SAAkB;YACxB,GAAG,IAAI;SACV,CAAC;QAEF,IAAI,EAAE,CAAqB,MAAS,EAAE,EAAE,CAAC,CAAC;YACtC,IAAI,EAAE,MAAe;YACrB,MAAM;SACT,CAAC;KACL,CAAA;aAEM,WAAM,GAAwB,EAAE,CAAA;IAEvC,MAAM,CAAC,QAAQ,CAAgC,MAA2B,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;QAC5F,MAAM,MAAM,GAAQ,EAAE,CAAA;QAEtB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YAEzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,K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 +1,20 @@
1
+ /**
2
+ * @fileoverview Main entry point for the digitaltwin-core package
3
+ *
4
+ * This module provides the core functionality for building digital twin applications,
5
+ * including data collection, processing, asset management, and real-time synchronization.
6
+ *
7
+ * @version 1.0.0
8
+ * @author FARI Team
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { DigitalTwinEngine, Collector, AssetsManager } from 'digitaltwin-core';
13
+ *
14
+ * const engine = new DigitalTwinEngine({ ... });
15
+ * await engine.start();
16
+ * ```
17
+ */
1
18
  export { DigitalTwinEngine } from './engine/digital_twin_engine.js';
2
19
  export { Collector } from './components/collector.js';
3
20
  export { Harvester } from './components/harvester.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAGpE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8C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OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAA;AAGlH,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AAGtC,cAAc,iBAAiB,CAAA;AAG/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,20 @@
1
- // Main entry point for digitaltwin-core package
1
+ /**
2
+ * @fileoverview Main entry point for the digitaltwin-core package
3
+ *
4
+ * This module provides the core functionality for building digital twin applications,
5
+ * including data collection, processing, asset management, and real-time synchronization.
6
+ *
7
+ * @version 1.0.0
8
+ * @author FARI Team
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { DigitalTwinEngine, Collector, AssetsManager } from 'digitaltwin-core';
13
+ *
14
+ * const engine = new DigitalTwinEngine({ ... });
15
+ * await engine.start();
16
+ * ```
17
+ */
2
18
  // Core Engine
3
19
  export { DigitalTwinEngine } from './engine/digital_twin_engine.js';
4
20
  // Base Components
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnE,kBAAkB;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B;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA"}
@@ -1,17 +1,78 @@
1
+ /**
2
+ * @fileoverview Data record type definition for digital twin data storage
3
+ *
4
+ * This module defines the standardized interface for data records used
5
+ * throughout the digital twin system for both streaming data and asset storage.
6
+ */
7
+ /**
8
+ * Standard data record interface for digital twin data storage.
9
+ *
10
+ * DataRecord provides a unified interface for all data stored in the digital twin system,
11
+ * from streaming sensor data to asset files. It supports both database metadata
12
+ * and file storage through a consistent API.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const record: DataRecord = {
17
+ * id: 12345,
18
+ * name: 'weather-station-001',
19
+ * date: new Date(),
20
+ * contentType: 'application/json',
21
+ * url: '/api/data/weather/12345',
22
+ * data: async () => Buffer.from(JSON.stringify(weatherData)),
23
+ * description: 'Weather data from station 001',
24
+ * source: 'https://api.weather.com/v1/current',
25
+ * owner_id: 123
26
+ * };
27
+ * ```
28
+ */
1
29
  export interface DataRecord {
30
+ /** Unique identifier for this data record */
2
31
  id: number;
32
+ /** Human-readable name or identifier for this record */
3
33
  name: string;
34
+ /** Timestamp when this record was created or last updated */
4
35
  date: Date;
36
+ /** MIME type of the data content (e.g., 'application/json', 'image/png') */
5
37
  contentType: string;
38
+ /** URL or path where this record can be accessed */
6
39
  url: string;
40
+ /**
41
+ * Function that returns the actual data content as a Buffer.
42
+ *
43
+ * This lazy-loading approach allows for efficient memory usage
44
+ * when working with large datasets or files.
45
+ *
46
+ * @returns Promise resolving to the data content as a Buffer
47
+ */
7
48
  data: () => Promise<Buffer>;
8
- /** Human-readable description of the asset (AssetsManager only) */
49
+ /**
50
+ * Human-readable description of the asset.
51
+ *
52
+ * Used primarily by AssetsManager components to provide
53
+ * additional context about stored files and resources.
54
+ */
9
55
  description?: string;
10
- /** Source URL for data provenance (AssetsManager only) */
56
+ /**
57
+ * Source URL for data provenance.
58
+ *
59
+ * Records the original source of this data for traceability
60
+ * and debugging purposes. Used by AssetsManager components.
61
+ */
11
62
  source?: string;
12
- /** ID of the user who owns this asset (AssetsManager only) */
63
+ /**
64
+ * ID of the user who owns this asset.
65
+ *
66
+ * Enables access control and ownership tracking for
67
+ * asset management. Used by AssetsManager components.
68
+ */
13
69
  owner_id?: number | null;
14
- /** Original filename provided by the user (AssetsManager only) */
70
+ /**
71
+ * Original filename provided by the user.
72
+ *
73
+ * Preserves the original filename when assets are uploaded
74
+ * or imported. Used by AssetsManager components.
75
+ */
15
76
  filename?: string;
16
77
  }
17
78
  //# sourceMappingURL=data_record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data_record.d.ts","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAG3B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB"}
1
+ {"version":3,"file":"data_record.d.ts","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,UAAU;IACvB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAA;IAEV,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IAEZ,6DAA6D;IAC7D,IAAI,EAAE,IAAI,CAAA;IAEV,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAA;IAEnB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAA;IAEX;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAI3B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAExB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB"}
@@ -1,2 +1,8 @@
1
+ /**
2
+ * @fileoverview Data record type definition for digital twin data storage
3
+ *
4
+ * This module defines the standardized interface for data records used
5
+ * throughout the digital twin system for both streaming data and asset storage.
6
+ */
1
7
  export {};
2
8
  //# sourceMappingURL=data_record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data_record.js","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"data_record.js","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,6 +1,63 @@
1
- export declare function servableEndpoint(config: {
1
+ /**
2
+ * @fileoverview Decorator for marking methods as HTTP endpoint handlers
3
+ *
4
+ * This utility provides a decorator to annotate component methods as HTTP endpoints
5
+ * that should be automatically registered with the digital twin engine's router.
6
+ */
7
+ /**
8
+ * Configuration interface for the servable endpoint decorator.
9
+ */
10
+ interface ServableEndpointConfig {
11
+ /** URL path for this endpoint (e.g., '/api/data/:id') */
2
12
  path: string;
13
+ /** HTTP method (defaults to 'get') */
3
14
  method?: string;
15
+ /** Response content type (defaults to 'application/json') */
4
16
  responseType?: string;
5
- }): (target: any, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => any;
17
+ }
18
+ /**
19
+ * Decorator that marks a method as an HTTP endpoint handler.
20
+ *
21
+ * This decorator allows component methods to be automatically discovered
22
+ * and registered as HTTP endpoints by the digital twin engine. The decorated
23
+ * method will be called when HTTP requests are made to the specified path.
24
+ *
25
+ * @param config - Configuration object specifying the endpoint details
26
+ * @param config.path - URL path pattern for this endpoint
27
+ * @param config.method - HTTP method (defaults to 'GET')
28
+ * @param config.responseType - Response content type (defaults to 'application/json')
29
+ *
30
+ * @returns Method decorator function
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * class WeatherCollector extends Collector {
35
+ * @servableEndpoint({
36
+ * path: '/api/weather/current',
37
+ * method: 'get',
38
+ * responseType: 'application/json'
39
+ * })
40
+ * getCurrentWeather(req: Request) {
41
+ * return {
42
+ * status: 200,
43
+ * content: { temperature: 22, humidity: 65 }
44
+ * };
45
+ * }
46
+ *
47
+ * @servableEndpoint({
48
+ * path: '/api/weather/history/:date',
49
+ * method: 'get'
50
+ * })
51
+ * getWeatherHistory(req: Request) {
52
+ * const date = req.params.date;
53
+ * return {
54
+ * status: 200,
55
+ * content: this.getHistoricalData(date)
56
+ * };
57
+ * }
58
+ * }
59
+ * ```
60
+ */
61
+ export declare function servableEndpoint(config: ServableEndpointConfig): (target: any, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => any;
62
+ export {};
6
63
  //# sourceMappingURL=servable_endpoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"servable_endpoint.d.ts","sourceRoot":"","sources":["../../src/utils/servable_endpoint.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,IAC5E,QAAQ,GAAG,EAAE,aAAa,MAAM,GAAG,MAAM,EAAE,aAAa,kBAAkB,KAAG,GAAG,CAgBpG"}
1
+ {"version":3,"file":"servable_endpoint.d.ts","sourceRoot":"","sources":["../../src/utils/servable_endpoint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,UAAU,sBAAsB;IAC5B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IAEZ,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,IAC1C,QAAQ,GAAG,EAAE,aAAa,MAAM,GAAG,MAAM,EAAE,aAAa,kBAAkB,KAAG,GAAG,CAkBpG"}
@@ -1,9 +1,60 @@
1
+ /**
2
+ * @fileoverview Decorator for marking methods as HTTP endpoint handlers
3
+ *
4
+ * This utility provides a decorator to annotate component methods as HTTP endpoints
5
+ * that should be automatically registered with the digital twin engine's router.
6
+ */
7
+ /**
8
+ * Decorator that marks a method as an HTTP endpoint handler.
9
+ *
10
+ * This decorator allows component methods to be automatically discovered
11
+ * and registered as HTTP endpoints by the digital twin engine. The decorated
12
+ * method will be called when HTTP requests are made to the specified path.
13
+ *
14
+ * @param config - Configuration object specifying the endpoint details
15
+ * @param config.path - URL path pattern for this endpoint
16
+ * @param config.method - HTTP method (defaults to 'GET')
17
+ * @param config.responseType - Response content type (defaults to 'application/json')
18
+ *
19
+ * @returns Method decorator function
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * class WeatherCollector extends Collector {
24
+ * @servableEndpoint({
25
+ * path: '/api/weather/current',
26
+ * method: 'get',
27
+ * responseType: 'application/json'
28
+ * })
29
+ * getCurrentWeather(req: Request) {
30
+ * return {
31
+ * status: 200,
32
+ * content: { temperature: 22, humidity: 65 }
33
+ * };
34
+ * }
35
+ *
36
+ * @servableEndpoint({
37
+ * path: '/api/weather/history/:date',
38
+ * method: 'get'
39
+ * })
40
+ * getWeatherHistory(req: Request) {
41
+ * const date = req.params.date;
42
+ * return {
43
+ * status: 200,
44
+ * content: this.getHistoricalData(date)
45
+ * };
46
+ * }
47
+ * }
48
+ * ```
49
+ */
1
50
  export function servableEndpoint(config) {
2
51
  return function (target, propertyKey, descriptor) {
3
52
  const ctor = target.constructor;
53
+ // Initialize endpoints array if it doesn't exist
4
54
  if (!ctor.__endpoints) {
5
55
  ctor.__endpoints = [];
6
56
  }
57
+ // Add endpoint configuration to the constructor metadata
7
58
  ctor.__endpoints.push({
8
59
  method: (config.method || 'get').toUpperCase(),
9
60
  path: config.path,
@@ -1 +1 @@
1
- {"version":3,"file":"servable_endpoint.js","sourceRoot":"","sources":["../../src/utils/servable_endpoint.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAC,MAAgE;IAC7F,OAAO,UAAU,MAAW,EAAE,WAA4B,EAAE,UAA+B;QACvF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAkB,CAAA;QAEtC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACzB,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAClB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;SACtC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACrB,CAAC,CAAA;AACL,CAAC"}
1
+ {"version":3,"file":"servable_endpoint.js","sourceRoot":"","sources":["../../src/utils/servable_endpoint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA8B;IAC3D,OAAO,UAAU,MAAW,EAAE,WAA4B,EAAE,UAA+B;QACvF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAkB,CAAA;QAEtC,iDAAiD;QACjD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACzB,CAAC;QAED,yDAAyD;QACzD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAClB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;SACtC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACrB,CAAC,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "digitaltwin-core",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Minimalist framework to collect and handle data in a Digital Twin project",
5
5
  "license": "MIT",
6
6
  "author": "Axel Hoffmann",