digitaltwin-core 0.8.2 → 0.8.3
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.map +1 -1
- package/dist/components/assets_manager.js +0 -1
- 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 +13 -23
- package/dist/components/custom_table_manager.js.map +1 -1
- package/dist/components/handler.d.ts +70 -9
- package/dist/components/handler.d.ts.map +1 -1
- package/dist/components/handler.js +45 -6
- package/dist/components/handler.js.map +1 -1
- package/dist/components/harvester.d.ts +129 -20
- package/dist/components/harvester.d.ts.map +1 -1
- package/dist/components/harvester.js +134 -41
- package/dist/components/harvester.js.map +1 -1
- package/dist/components/interfaces.d.ts +108 -0
- package/dist/components/interfaces.d.ts.map +1 -1
- package/dist/components/interfaces.js +6 -0
- 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/database/adapters/knex_database_adapter.d.ts +15 -2
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -1
- package/dist/database/adapters/knex_database_adapter.js +50 -3
- package/dist/database/adapters/knex_database_adapter.js.map +1 -1
- package/dist/database/database_adapter.d.ts +22 -0
- 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 +39 -0
- package/dist/engine/endpoints.d.ts.map +1 -1
- package/dist/engine/endpoints.js +31 -0
- package/dist/engine/endpoints.js.map +1 -1
- package/dist/engine/events.d.ts +80 -0
- package/dist/engine/events.d.ts.map +1 -1
- package/dist/engine/events.js +60 -0
- package/dist/engine/events.js.map +1 -1
- package/dist/engine/initializer.d.ts +51 -0
- package/dist/engine/initializer.d.ts.map +1 -1
- package/dist/engine/initializer.js +72 -0
- package/dist/engine/initializer.js.map +1 -1
- package/dist/env/env.d.ts +101 -0
- package/dist/env/env.d.ts.map +1 -1
- package/dist/env/env.js +101 -0
- package/dist/env/env.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/types/data_record.d.ts +65 -4
- package/dist/types/data_record.d.ts.map +1 -1
- package/dist/types/data_record.js +6 -0
- package/dist/types/data_record.js.map +1 -1
- package/dist/utils/servable_endpoint.d.ts +59 -2
- package/dist/utils/servable_endpoint.d.ts.map +1 -1
- package/dist/utils/servable_endpoint.js +51 -0
- 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
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"initializer.js","sourceRoot":"","sources":["../../src/engine/initializer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,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;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,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,QAAQ,EAAE,MAAM,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
|
package/dist/env/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,CAAC,MAAM;
|
|
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)) {
|
package/dist/env/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env/env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,GAAG;IACZ;;;;;OAKG;aACI,WAAM,GAAG;QACZ;;;;;;;WAOG;QACH,MAAM,EAAE,CAAC,IAAuD,EAAE,EAAE,CAAC,CAAC;YAClE,IAAI,EAA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CAAC,qBAAqB,GAAG,qBAAqB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;oBAC3F,CAAC;oBACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;oBACnB,MAAK;YACb,CAAC;QACL,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,OAAO,MAAM,CAAA;IACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +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';
|
|
@@ -5,6 +22,7 @@ export { Handler } from './components/handler.js';
|
|
|
5
22
|
export { AssetsManager } from './components/assets_manager.js';
|
|
6
23
|
export { GlobalAssetsHandler } from './components/global_assets_handler.js';
|
|
7
24
|
export { CustomTableManager } from './components/custom_table_manager.js';
|
|
25
|
+
export { TilesetManager } from './components/tileset_manager.js';
|
|
8
26
|
export { StorageService } from './storage/storage_service.js';
|
|
9
27
|
export { LocalStorageService } from './storage/adapters/local_storage_service.js';
|
|
10
28
|
export { OvhS3StorageService } from './storage/adapters/ovh_storage_service.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,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,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
|
-
|
|
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
|
|
@@ -8,6 +24,7 @@ export { Handler } from './components/handler.js';
|
|
|
8
24
|
export { AssetsManager } from './components/assets_manager.js';
|
|
9
25
|
export { GlobalAssetsHandler } from './components/global_assets_handler.js';
|
|
10
26
|
export { CustomTableManager } from './components/custom_table_manager.js';
|
|
27
|
+
export { TilesetManager } from './components/tileset_manager.js';
|
|
11
28
|
// Storage Services
|
|
12
29
|
export { StorageService } from './storage/storage_service.js';
|
|
13
30
|
export { LocalStorageService } from './storage/adapters/local_storage_service.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3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E,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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
|
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
|
-
|
|
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
|
-
}
|
|
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,
|
|
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"}
|