digitaltwin-core 0.14.2 → 1.0.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 (227) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +494 -359
  3. package/dist/auth/apisix_parser.d.ts +141 -0
  4. package/dist/auth/apisix_parser.d.ts.map +1 -0
  5. package/dist/auth/apisix_parser.js +161 -0
  6. package/dist/auth/apisix_parser.js.map +1 -0
  7. package/dist/auth/auth_config.d.ts +126 -0
  8. package/dist/auth/auth_config.d.ts.map +1 -0
  9. package/dist/auth/auth_config.js +169 -0
  10. package/dist/auth/auth_config.js.map +1 -0
  11. package/dist/auth/auth_provider.d.ts +118 -0
  12. package/dist/auth/auth_provider.d.ts.map +1 -0
  13. package/dist/auth/auth_provider.js +8 -0
  14. package/dist/auth/auth_provider.js.map +1 -0
  15. package/dist/auth/auth_provider_factory.d.ts +91 -0
  16. package/dist/auth/auth_provider_factory.d.ts.map +1 -0
  17. package/dist/auth/auth_provider_factory.js +146 -0
  18. package/dist/auth/auth_provider_factory.js.map +1 -0
  19. package/dist/auth/index.d.ts +8 -0
  20. package/dist/auth/index.d.ts.map +1 -0
  21. package/dist/auth/index.js +7 -0
  22. package/dist/auth/index.js.map +1 -0
  23. package/dist/auth/providers/gateway_auth_provider.d.ts +78 -0
  24. package/dist/auth/providers/gateway_auth_provider.d.ts.map +1 -0
  25. package/dist/auth/providers/gateway_auth_provider.js +109 -0
  26. package/dist/auth/providers/gateway_auth_provider.js.map +1 -0
  27. package/dist/auth/providers/index.d.ts +4 -0
  28. package/dist/auth/providers/index.d.ts.map +1 -0
  29. package/dist/auth/providers/index.js +4 -0
  30. package/dist/auth/providers/index.js.map +1 -0
  31. package/dist/auth/providers/jwt_auth_provider.d.ts +91 -0
  32. package/dist/auth/providers/jwt_auth_provider.d.ts.map +1 -0
  33. package/dist/auth/providers/jwt_auth_provider.js +204 -0
  34. package/dist/auth/providers/jwt_auth_provider.js.map +1 -0
  35. package/dist/auth/providers/no_auth_provider.d.ts +61 -0
  36. package/dist/auth/providers/no_auth_provider.d.ts.map +1 -0
  37. package/dist/auth/providers/no_auth_provider.js +76 -0
  38. package/dist/auth/providers/no_auth_provider.js.map +1 -0
  39. package/dist/auth/types.d.ts +100 -0
  40. package/dist/auth/types.d.ts.map +1 -0
  41. package/dist/auth/types.js +2 -0
  42. package/dist/auth/types.js.map +1 -0
  43. package/dist/auth/user_service.d.ts +86 -0
  44. package/dist/auth/user_service.d.ts.map +1 -0
  45. package/dist/auth/user_service.js +237 -0
  46. package/dist/auth/user_service.js.map +1 -0
  47. package/dist/components/assets_manager.d.ts +662 -0
  48. package/dist/components/assets_manager.d.ts.map +1 -0
  49. package/dist/components/assets_manager.js +1537 -0
  50. package/dist/components/assets_manager.js.map +1 -0
  51. package/dist/components/async_upload.d.ts +20 -0
  52. package/dist/components/async_upload.d.ts.map +1 -0
  53. package/dist/components/async_upload.js +10 -0
  54. package/dist/components/async_upload.js.map +1 -0
  55. package/dist/components/collector.d.ts +203 -0
  56. package/dist/components/collector.d.ts.map +1 -0
  57. package/dist/components/collector.js +214 -0
  58. package/dist/components/collector.js.map +1 -0
  59. package/dist/components/custom_table_manager.d.ts +503 -0
  60. package/dist/components/custom_table_manager.d.ts.map +1 -0
  61. package/dist/components/custom_table_manager.js +1023 -0
  62. package/dist/components/custom_table_manager.js.map +1 -0
  63. package/dist/components/global_assets_handler.d.ts +63 -0
  64. package/dist/components/global_assets_handler.d.ts.map +1 -0
  65. package/dist/components/global_assets_handler.js +127 -0
  66. package/dist/components/global_assets_handler.js.map +1 -0
  67. package/dist/components/handler.d.ts +104 -0
  68. package/dist/components/handler.d.ts.map +1 -0
  69. package/dist/components/handler.js +110 -0
  70. package/dist/components/handler.js.map +1 -0
  71. package/dist/components/harvester.d.ts +182 -0
  72. package/dist/components/harvester.d.ts.map +1 -0
  73. package/dist/components/harvester.js +406 -0
  74. package/dist/components/harvester.js.map +1 -0
  75. package/dist/components/index.d.ts +11 -0
  76. package/dist/components/index.d.ts.map +1 -0
  77. package/dist/components/index.js +9 -0
  78. package/dist/components/index.js.map +1 -0
  79. package/dist/components/interfaces.d.ts +126 -0
  80. package/dist/components/interfaces.d.ts.map +1 -0
  81. package/dist/components/interfaces.js +8 -0
  82. package/dist/components/interfaces.js.map +1 -0
  83. package/dist/components/map_manager.d.ts +61 -0
  84. package/dist/components/map_manager.d.ts.map +1 -0
  85. package/dist/components/map_manager.js +242 -0
  86. package/dist/components/map_manager.js.map +1 -0
  87. package/dist/components/tileset_manager.d.ts +125 -0
  88. package/dist/components/tileset_manager.d.ts.map +1 -0
  89. package/dist/components/tileset_manager.js +623 -0
  90. package/dist/components/tileset_manager.js.map +1 -0
  91. package/dist/components/types.d.ts +226 -0
  92. package/dist/components/types.d.ts.map +1 -0
  93. package/dist/components/types.js +8 -0
  94. package/dist/components/types.js.map +1 -0
  95. package/dist/database/adapters/knex_database_adapter.d.ts +97 -0
  96. package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -0
  97. package/dist/database/adapters/knex_database_adapter.js +729 -0
  98. package/dist/database/adapters/knex_database_adapter.js.map +1 -0
  99. package/dist/database/database_adapter.d.ts +262 -0
  100. package/dist/database/database_adapter.d.ts.map +1 -0
  101. package/dist/database/database_adapter.js +46 -0
  102. package/dist/database/database_adapter.js.map +1 -0
  103. package/dist/engine/digital_twin_engine.d.ts +295 -0
  104. package/dist/engine/digital_twin_engine.d.ts.map +1 -0
  105. package/dist/engine/digital_twin_engine.js +907 -0
  106. package/dist/engine/digital_twin_engine.js.map +1 -0
  107. package/dist/engine/endpoints.d.ts +47 -0
  108. package/dist/engine/endpoints.d.ts.map +1 -0
  109. package/dist/engine/endpoints.js +88 -0
  110. package/dist/engine/endpoints.js.map +1 -0
  111. package/dist/engine/error_handler.d.ts +20 -0
  112. package/dist/engine/error_handler.d.ts.map +1 -0
  113. package/dist/engine/error_handler.js +69 -0
  114. package/dist/engine/error_handler.js.map +1 -0
  115. package/dist/engine/events.d.ts +93 -0
  116. package/dist/engine/events.d.ts.map +1 -0
  117. package/dist/engine/events.js +71 -0
  118. package/dist/engine/events.js.map +1 -0
  119. package/dist/engine/health.d.ts +112 -0
  120. package/dist/engine/health.d.ts.map +1 -0
  121. package/dist/engine/health.js +190 -0
  122. package/dist/engine/health.js.map +1 -0
  123. package/dist/engine/initializer.d.ts +62 -0
  124. package/dist/engine/initializer.d.ts.map +1 -0
  125. package/dist/engine/initializer.js +108 -0
  126. package/dist/engine/initializer.js.map +1 -0
  127. package/dist/engine/queue_manager.d.ts +87 -0
  128. package/dist/engine/queue_manager.d.ts.map +1 -0
  129. package/dist/engine/queue_manager.js +196 -0
  130. package/dist/engine/queue_manager.js.map +1 -0
  131. package/dist/engine/scheduler.d.ts +30 -0
  132. package/dist/engine/scheduler.d.ts.map +1 -0
  133. package/dist/engine/scheduler.js +378 -0
  134. package/dist/engine/scheduler.js.map +1 -0
  135. package/dist/engine/upload_processor.d.ts +36 -0
  136. package/dist/engine/upload_processor.d.ts.map +1 -0
  137. package/dist/engine/upload_processor.js +113 -0
  138. package/dist/engine/upload_processor.js.map +1 -0
  139. package/dist/env/env.d.ts +134 -0
  140. package/dist/env/env.d.ts.map +1 -0
  141. package/dist/env/env.js +177 -0
  142. package/dist/env/env.js.map +1 -0
  143. package/dist/errors/index.d.ts +94 -0
  144. package/dist/errors/index.d.ts.map +1 -0
  145. package/dist/errors/index.js +149 -0
  146. package/dist/errors/index.js.map +1 -0
  147. package/dist/index.d.ts +55 -0
  148. package/dist/index.d.ts.map +1 -0
  149. package/dist/index.js +65 -0
  150. package/dist/index.js.map +1 -0
  151. package/dist/openapi/generator.d.ts +93 -0
  152. package/dist/openapi/generator.d.ts.map +1 -0
  153. package/dist/openapi/generator.js +293 -0
  154. package/dist/openapi/generator.js.map +1 -0
  155. package/dist/openapi/index.d.ts +9 -0
  156. package/dist/openapi/index.d.ts.map +1 -0
  157. package/dist/openapi/index.js +9 -0
  158. package/dist/openapi/index.js.map +1 -0
  159. package/dist/openapi/types.d.ts +182 -0
  160. package/dist/openapi/types.d.ts.map +1 -0
  161. package/dist/openapi/types.js +16 -0
  162. package/dist/openapi/types.js.map +1 -0
  163. package/dist/storage/adapters/local_storage_service.d.ts +57 -0
  164. package/dist/storage/adapters/local_storage_service.d.ts.map +1 -0
  165. package/dist/storage/adapters/local_storage_service.js +132 -0
  166. package/dist/storage/adapters/local_storage_service.js.map +1 -0
  167. package/dist/storage/adapters/ovh_storage_service.d.ts +72 -0
  168. package/dist/storage/adapters/ovh_storage_service.d.ts.map +1 -0
  169. package/dist/storage/adapters/ovh_storage_service.js +205 -0
  170. package/dist/storage/adapters/ovh_storage_service.js.map +1 -0
  171. package/dist/storage/storage_factory.d.ts +14 -0
  172. package/dist/storage/storage_factory.d.ts.map +1 -0
  173. package/dist/storage/storage_factory.js +43 -0
  174. package/dist/storage/storage_factory.js.map +1 -0
  175. package/dist/storage/storage_service.d.ts +163 -0
  176. package/dist/storage/storage_service.d.ts.map +1 -0
  177. package/dist/storage/storage_service.js +58 -0
  178. package/dist/storage/storage_service.js.map +1 -0
  179. package/dist/types/data_record.d.ts +123 -0
  180. package/dist/types/data_record.d.ts.map +1 -0
  181. package/dist/types/data_record.js +8 -0
  182. package/dist/types/data_record.js.map +1 -0
  183. package/dist/utils/graceful_shutdown.d.ts +44 -0
  184. package/dist/utils/graceful_shutdown.d.ts.map +1 -0
  185. package/dist/utils/graceful_shutdown.js +79 -0
  186. package/dist/utils/graceful_shutdown.js.map +1 -0
  187. package/dist/utils/http_responses.d.ts +175 -0
  188. package/dist/utils/http_responses.d.ts.map +1 -0
  189. package/dist/utils/http_responses.js +216 -0
  190. package/dist/utils/http_responses.js.map +1 -0
  191. package/dist/utils/index.d.ts +8 -0
  192. package/dist/utils/index.d.ts.map +1 -0
  193. package/dist/utils/index.js +6 -0
  194. package/dist/utils/index.js.map +1 -0
  195. package/dist/utils/logger.d.ts +74 -0
  196. package/dist/utils/logger.d.ts.map +1 -0
  197. package/dist/utils/logger.js +92 -0
  198. package/dist/utils/logger.js.map +1 -0
  199. package/dist/utils/map_to_data_record.d.ts +10 -0
  200. package/dist/utils/map_to_data_record.d.ts.map +1 -0
  201. package/dist/utils/map_to_data_record.js +36 -0
  202. package/dist/utils/map_to_data_record.js.map +1 -0
  203. package/dist/utils/safe_async.d.ts +50 -0
  204. package/dist/utils/safe_async.d.ts.map +1 -0
  205. package/dist/utils/safe_async.js +90 -0
  206. package/dist/utils/safe_async.js.map +1 -0
  207. package/dist/utils/servable_endpoint.d.ts +63 -0
  208. package/dist/utils/servable_endpoint.d.ts.map +1 -0
  209. package/dist/utils/servable_endpoint.js +67 -0
  210. package/dist/utils/servable_endpoint.js.map +1 -0
  211. package/dist/utils/zip_utils.d.ts +66 -0
  212. package/dist/utils/zip_utils.d.ts.map +1 -0
  213. package/dist/utils/zip_utils.js +169 -0
  214. package/dist/utils/zip_utils.js.map +1 -0
  215. package/dist/validation/index.d.ts +3 -0
  216. package/dist/validation/index.d.ts.map +1 -0
  217. package/dist/validation/index.js +7 -0
  218. package/dist/validation/index.js.map +1 -0
  219. package/dist/validation/schemas.d.ts +273 -0
  220. package/dist/validation/schemas.d.ts.map +1 -0
  221. package/dist/validation/schemas.js +82 -0
  222. package/dist/validation/schemas.js.map +1 -0
  223. package/dist/validation/validate.d.ts +49 -0
  224. package/dist/validation/validate.d.ts.map +1 -0
  225. package/dist/validation/validate.js +110 -0
  226. package/dist/validation/validate.js.map +1 -0
  227. package/package.json +23 -13
@@ -0,0 +1,134 @@
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
+ */
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
+ */
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
+ */
43
+ string: (opts?: {
44
+ optional?: boolean;
45
+ format?: "url" | "email";
46
+ }) => {
47
+ optional?: boolean;
48
+ format?: "url" | "email";
49
+ type: "string";
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
+ */
58
+ number: (opts?: {
59
+ optional?: boolean;
60
+ }) => {
61
+ optional?: boolean;
62
+ type: "number";
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
+ */
74
+ boolean: (opts?: {
75
+ optional?: boolean;
76
+ default?: boolean;
77
+ }) => {
78
+ optional?: boolean;
79
+ default?: boolean;
80
+ type: "boolean";
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
+ */
89
+ enum: <T extends string[]>(values: T) => {
90
+ type: "enum";
91
+ values: T;
92
+ };
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
+ */
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
+ */
132
+ static validate<T extends Record<string, any>>(schema: Record<string, any>, rawEnv?: NodeJS.ProcessEnv): T;
133
+ }
134
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,177 @@
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
+ */
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
+ */
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
+ */
43
+ string: (opts) => ({
44
+ type: 'string',
45
+ ...opts
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
+ */
54
+ number: (opts) => ({
55
+ type: 'number',
56
+ ...opts
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
+ */
68
+ boolean: (opts) => ({
69
+ type: 'boolean',
70
+ ...opts
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
+ */
79
+ enum: (values) => ({
80
+ type: 'enum',
81
+ values
82
+ })
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
+ */
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
+ */
122
+ static validate(schema, rawEnv = process.env) {
123
+ const config = {};
124
+ for (const [key, rules] of Object.entries(schema)) {
125
+ const value = rawEnv[key];
126
+ if (value === undefined || value === '') {
127
+ if (rules.optional) {
128
+ // Use default value if provided
129
+ if (rules.default !== undefined) {
130
+ config[key] = rules.default;
131
+ }
132
+ continue;
133
+ }
134
+ throw new Error(`Missing environment variable: ${key}`);
135
+ }
136
+ switch (rules.type) {
137
+ case 'string':
138
+ if (rules.format === 'url' && !/^https?:\/\/.+$/.test(value)) {
139
+ throw new Error(`Invalid URL format for ${key}`);
140
+ }
141
+ if (rules.format === 'email' && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
142
+ throw new Error(`Invalid email format for ${key}`);
143
+ }
144
+ config[key] = value;
145
+ break;
146
+ case 'number':
147
+ const parsed = Number(value);
148
+ if (isNaN(parsed)) {
149
+ throw new Error(`Invalid number format for ${key}`);
150
+ }
151
+ config[key] = parsed;
152
+ break;
153
+ case 'boolean':
154
+ const lowerValue = value.toLowerCase();
155
+ if (lowerValue === 'true' || lowerValue === '1') {
156
+ config[key] = true;
157
+ }
158
+ else if (lowerValue === 'false' || lowerValue === '0') {
159
+ config[key] = false;
160
+ }
161
+ else {
162
+ throw new Error(`Invalid boolean format for ${key}, expected true/false or 1/0`);
163
+ }
164
+ break;
165
+ case 'enum':
166
+ if (!rules.values.includes(value)) {
167
+ throw new Error(`Invalid value for ${key}, expected one of ${rules.values.join(', ')}`);
168
+ }
169
+ config[key] = value;
170
+ break;
171
+ }
172
+ }
173
+ this.config = config;
174
+ return config;
175
+ }
176
+ }
177
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
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,EAAE,QAAiB;YACvB,GAAG,IAAI;SACV,CAAC;QAEF;;;;;;WAMG;QACH,MAAM,EAAE,CAAC,IAA6B,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,QAAiB;YACvB,GAAG,IAAI;SACV,CAAC;QAEF;;;;;;;;;WASG;QACH,OAAO,EAAE,CAAC,IAAgD,EAAE,EAAE,CAAC,CAAC;YAC5D,IAAI,EAAE,SAAkB;YACxB,GAAG,IAAI;SACV,CAAC;QAEF;;;;;;WAMG;QACH,IAAI,EAAE,CAAqB,MAAS,EAAE,EAAE,CAAC,CAAC;YACtC,IAAI,EAAE,MAAe;YACrB,MAAM;SACT,CAAC;KACL,CAAA;IAED;;;;;OAKG;aACI,WAAM,GAAwB,EAAE,CAAA;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,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,KAAK,EAAE,EAAE,CAAC;gBACtC,IAAI,KAA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yBAAM,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;wBACtD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;oBACvB,CAAC;yBAAM,CAAC;wBACJ,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,8BAA8B,CAAC,CAAA;oBACpF,CAAC;oBACD,MAAK;gBAET,KAAK,MAAM;oBACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;wBAChC,MAAM,IAAI,KAAK,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"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Custom error classes for Digital Twin framework
3
+ * Provides structured error handling with codes, status codes, and context
4
+ */
5
+ /**
6
+ * Base error class for all Digital Twin errors
7
+ */
8
+ export declare abstract class DigitalTwinError extends Error {
9
+ abstract readonly code: string;
10
+ abstract readonly statusCode: number;
11
+ readonly timestamp: Date;
12
+ readonly context?: Record<string, unknown>;
13
+ constructor(message: string, context?: Record<string, unknown>);
14
+ toJSON(): Record<string, unknown>;
15
+ }
16
+ /**
17
+ * Validation error - invalid input data (422 Unprocessable Entity)
18
+ */
19
+ export declare class ValidationError extends DigitalTwinError {
20
+ readonly code: "VALIDATION_ERROR";
21
+ readonly statusCode: 422;
22
+ }
23
+ /**
24
+ * Resource not found (404)
25
+ */
26
+ export declare class NotFoundError extends DigitalTwinError {
27
+ readonly code: "NOT_FOUND";
28
+ readonly statusCode: 404;
29
+ }
30
+ /**
31
+ * Authentication required or invalid credentials (401)
32
+ */
33
+ export declare class AuthenticationError extends DigitalTwinError {
34
+ readonly code: "AUTHENTICATION_ERROR";
35
+ readonly statusCode: 401;
36
+ }
37
+ /**
38
+ * Insufficient permissions (403)
39
+ */
40
+ export declare class AuthorizationError extends DigitalTwinError {
41
+ readonly code: "AUTHORIZATION_ERROR";
42
+ readonly statusCode: 403;
43
+ }
44
+ /**
45
+ * Storage operation failed (500)
46
+ */
47
+ export declare class StorageError extends DigitalTwinError {
48
+ readonly code: "STORAGE_ERROR";
49
+ readonly statusCode: 500;
50
+ }
51
+ /**
52
+ * Database operation failed (500)
53
+ */
54
+ export declare class DatabaseError extends DigitalTwinError {
55
+ readonly code: "DATABASE_ERROR";
56
+ readonly statusCode: 500;
57
+ }
58
+ /**
59
+ * External service (API) error (502)
60
+ */
61
+ export declare class ExternalServiceError extends DigitalTwinError {
62
+ readonly code: "EXTERNAL_SERVICE_ERROR";
63
+ readonly statusCode: 502;
64
+ }
65
+ /**
66
+ * Configuration error (500)
67
+ */
68
+ export declare class ConfigurationError extends DigitalTwinError {
69
+ readonly code: "CONFIGURATION_ERROR";
70
+ readonly statusCode: 500;
71
+ }
72
+ /**
73
+ * Queue/Job processing error (500)
74
+ */
75
+ export declare class QueueError extends DigitalTwinError {
76
+ readonly code: "QUEUE_ERROR";
77
+ readonly statusCode: 500;
78
+ }
79
+ /**
80
+ * File operation error (500)
81
+ */
82
+ export declare class FileOperationError extends DigitalTwinError {
83
+ readonly code: "FILE_OPERATION_ERROR";
84
+ readonly statusCode: 500;
85
+ }
86
+ /**
87
+ * Type guard to check if an error is a DigitalTwinError
88
+ */
89
+ export declare function isDigitalTwinError(error: unknown): error is DigitalTwinError;
90
+ /**
91
+ * Wraps an unknown error into a DigitalTwinError
92
+ */
93
+ export declare function wrapError(error: unknown, ErrorClass?: typeof DigitalTwinError): DigitalTwinError;
94
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],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,CAAC,IAAI,EAAG,gBAAgB,CAAS;IACzC,QAAQ,CAAC,UAAU,EAAG,GAAG,CAAS;CACrC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACtD,QAAQ,CAAC,IAAI,EAAG,wBAAwB,CAAS;IACjD,QAAQ,CAAC,UAAU,EAAG,GAAG,CAAS;CACrC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,IAAI,EAAG,qBAAqB,CAAS;IAC9C,QAAQ,CAAC,UAAU,EAAG,GAAG,CAAS;CACrC;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,gBAAgB;IAC5C,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAS;IACtC,QAAQ,CAAC,UAAU,EAAG,GAAG,CAAS;CACrC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,IAAI,EAAG,sBAAsB,CAAS;IAC/C,QAAQ,CAAC,UAAU,EAAG,GAAG,CAAS;CACrC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,GAAE,OAAO,gBAA+B,GAAG,gBAAgB,CAU9G"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Custom error classes for Digital Twin framework
3
+ * Provides structured error handling with codes, status codes, and context
4
+ */
5
+ /**
6
+ * Base error class for all Digital Twin errors
7
+ */
8
+ export class DigitalTwinError extends Error {
9
+ constructor(message, context) {
10
+ super(message);
11
+ this.timestamp = new Date();
12
+ this.name = this.constructor.name;
13
+ this.context = context;
14
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
15
+ if (Error.captureStackTrace) {
16
+ Error.captureStackTrace(this, this.constructor);
17
+ }
18
+ }
19
+ toJSON() {
20
+ return {
21
+ error: {
22
+ code: this.code,
23
+ message: this.message,
24
+ timestamp: this.timestamp.toISOString(),
25
+ ...(this.context && { context: this.context }),
26
+ ...(process.env.NODE_ENV !== 'production' && { stack: this.stack })
27
+ }
28
+ };
29
+ }
30
+ }
31
+ /**
32
+ * Validation error - invalid input data (422 Unprocessable Entity)
33
+ */
34
+ export class ValidationError extends DigitalTwinError {
35
+ constructor() {
36
+ super(...arguments);
37
+ this.code = 'VALIDATION_ERROR';
38
+ this.statusCode = 422;
39
+ }
40
+ }
41
+ /**
42
+ * Resource not found (404)
43
+ */
44
+ export class NotFoundError extends DigitalTwinError {
45
+ constructor() {
46
+ super(...arguments);
47
+ this.code = 'NOT_FOUND';
48
+ this.statusCode = 404;
49
+ }
50
+ }
51
+ /**
52
+ * Authentication required or invalid credentials (401)
53
+ */
54
+ export class AuthenticationError extends DigitalTwinError {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.code = 'AUTHENTICATION_ERROR';
58
+ this.statusCode = 401;
59
+ }
60
+ }
61
+ /**
62
+ * Insufficient permissions (403)
63
+ */
64
+ export class AuthorizationError extends DigitalTwinError {
65
+ constructor() {
66
+ super(...arguments);
67
+ this.code = 'AUTHORIZATION_ERROR';
68
+ this.statusCode = 403;
69
+ }
70
+ }
71
+ /**
72
+ * Storage operation failed (500)
73
+ */
74
+ export class StorageError extends DigitalTwinError {
75
+ constructor() {
76
+ super(...arguments);
77
+ this.code = 'STORAGE_ERROR';
78
+ this.statusCode = 500;
79
+ }
80
+ }
81
+ /**
82
+ * Database operation failed (500)
83
+ */
84
+ export class DatabaseError extends DigitalTwinError {
85
+ constructor() {
86
+ super(...arguments);
87
+ this.code = 'DATABASE_ERROR';
88
+ this.statusCode = 500;
89
+ }
90
+ }
91
+ /**
92
+ * External service (API) error (502)
93
+ */
94
+ export class ExternalServiceError extends DigitalTwinError {
95
+ constructor() {
96
+ super(...arguments);
97
+ this.code = 'EXTERNAL_SERVICE_ERROR';
98
+ this.statusCode = 502;
99
+ }
100
+ }
101
+ /**
102
+ * Configuration error (500)
103
+ */
104
+ export class ConfigurationError extends DigitalTwinError {
105
+ constructor() {
106
+ super(...arguments);
107
+ this.code = 'CONFIGURATION_ERROR';
108
+ this.statusCode = 500;
109
+ }
110
+ }
111
+ /**
112
+ * Queue/Job processing error (500)
113
+ */
114
+ export class QueueError extends DigitalTwinError {
115
+ constructor() {
116
+ super(...arguments);
117
+ this.code = 'QUEUE_ERROR';
118
+ this.statusCode = 500;
119
+ }
120
+ }
121
+ /**
122
+ * File operation error (500)
123
+ */
124
+ export class FileOperationError extends DigitalTwinError {
125
+ constructor() {
126
+ super(...arguments);
127
+ this.code = 'FILE_OPERATION_ERROR';
128
+ this.statusCode = 500;
129
+ }
130
+ }
131
+ /**
132
+ * Type guard to check if an error is a DigitalTwinError
133
+ */
134
+ export function isDigitalTwinError(error) {
135
+ return error instanceof DigitalTwinError;
136
+ }
137
+ /**
138
+ * Wraps an unknown error into a DigitalTwinError
139
+ */
140
+ export function wrapError(error, ErrorClass = StorageError) {
141
+ if (error instanceof DigitalTwinError) {
142
+ return error;
143
+ }
144
+ const message = error instanceof Error ? error.message : String(error);
145
+ const context = error instanceof Error ? { originalError: error.name } : undefined;
146
+ // @ts-expect-error - ErrorClass is abstract but we're passing concrete classes
147
+ return new ErrorClass(message, context);
148
+ }
149
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,KAAK;IAMhD,YAAY,OAAe,EAAE,OAAiC;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAA;QAJT,cAAS,GAAS,IAAI,IAAI,EAAE,CAAA;QAKjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,qFAAqF;QACrF,IAAI,KAA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AO,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,55 @@
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
+ */
18
+ export { DigitalTwinEngine } from './engine/digital_twin_engine.js';
19
+ export { Collector } from './components/collector.js';
20
+ export { Harvester } from './components/harvester.js';
21
+ export { Handler } from './components/handler.js';
22
+ export { AssetsManager } from './components/assets_manager.js';
23
+ export { GlobalAssetsHandler } from './components/global_assets_handler.js';
24
+ export { CustomTableManager, type CustomTableRecord, type QueryValidationOptions } from './components/custom_table_manager.js';
25
+ export { TilesetManager } from './components/tileset_manager.js';
26
+ export { type AsyncUploadable, isAsyncUploadable } from './components/async_upload.js';
27
+ export { StorageService } from './storage/storage_service.js';
28
+ export { LocalStorageService } from './storage/adapters/local_storage_service.js';
29
+ export { OvhS3StorageService } from './storage/adapters/ovh_storage_service.js';
30
+ export { StorageServiceFactory } from './storage/storage_factory.js';
31
+ export { DatabaseAdapter } from './database/database_adapter.js';
32
+ export { KnexDatabaseAdapter, PostgreSQLConfig, SQLiteConfig } from './database/adapters/knex_database_adapter.js';
33
+ export * from './components/types.js';
34
+ export * from './components/interfaces.js';
35
+ export * from './types/data_record.js';
36
+ export * from './auth/index.js';
37
+ export * from './errors/index.js';
38
+ export * from './validation/index.js';
39
+ export { Logger, LogLevel } from './utils/logger.js';
40
+ export { safeAsync, tryAsync, safeCleanup, retryAsync } from './utils/safe_async.js';
41
+ export { setupGracefulShutdown, type ShutdownOptions } from './utils/graceful_shutdown.js';
42
+ export { mapToDataRecord } from './utils/map_to_data_record.js';
43
+ export { servableEndpoint } from './utils/servable_endpoint.js';
44
+ export { HttpStatus, jsonResponse, successResponse, errorResponse, badRequestResponse, unauthorizedResponse, forbiddenResponse, notFoundResponse, textResponse, fileResponse, multiStatusResponse } from './utils/http_responses.js';
45
+ export type { HttpStatusCode } from './utils/http_responses.js';
46
+ export { QueueManager } from './engine/queue_manager.js';
47
+ export { errorHandler, asyncHandler, notFoundHandler } from './engine/error_handler.js';
48
+ export { HealthChecker, createDatabaseCheck, createRedisCheck, createStorageCheck, performHealthCheck, livenessCheck, type HealthCheck, type HealthCheckFn, type HealthStatus, type ComponentCounts } from './engine/health.js';
49
+ export { UploadProcessor, type TilesetUploadJobData, type UploadJobData, type UploadStatus } from './engine/upload_processor.js';
50
+ export { initializeComponents } from './engine/initializer.js';
51
+ export * from './engine/events.js';
52
+ export * from './engine/endpoints.js';
53
+ export * from './openapi/index.js';
54
+ export { Env } from './env/env.js';
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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,EACH,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC9B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,EAAE,KAAK,eAAe,EAA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