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.
- package/LICENSE +20 -20
- package/README.md +494 -359
- package/dist/auth/apisix_parser.d.ts +141 -0
- package/dist/auth/apisix_parser.d.ts.map +1 -0
- package/dist/auth/apisix_parser.js +161 -0
- package/dist/auth/apisix_parser.js.map +1 -0
- package/dist/auth/auth_config.d.ts +126 -0
- package/dist/auth/auth_config.d.ts.map +1 -0
- package/dist/auth/auth_config.js +169 -0
- package/dist/auth/auth_config.js.map +1 -0
- package/dist/auth/auth_provider.d.ts +118 -0
- package/dist/auth/auth_provider.d.ts.map +1 -0
- package/dist/auth/auth_provider.js +8 -0
- package/dist/auth/auth_provider.js.map +1 -0
- package/dist/auth/auth_provider_factory.d.ts +91 -0
- package/dist/auth/auth_provider_factory.d.ts.map +1 -0
- package/dist/auth/auth_provider_factory.js +146 -0
- package/dist/auth/auth_provider_factory.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/providers/gateway_auth_provider.d.ts +78 -0
- package/dist/auth/providers/gateway_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/gateway_auth_provider.js +109 -0
- package/dist/auth/providers/gateway_auth_provider.js.map +1 -0
- package/dist/auth/providers/index.d.ts +4 -0
- package/dist/auth/providers/index.d.ts.map +1 -0
- package/dist/auth/providers/index.js +4 -0
- package/dist/auth/providers/index.js.map +1 -0
- package/dist/auth/providers/jwt_auth_provider.d.ts +91 -0
- package/dist/auth/providers/jwt_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/jwt_auth_provider.js +204 -0
- package/dist/auth/providers/jwt_auth_provider.js.map +1 -0
- package/dist/auth/providers/no_auth_provider.d.ts +61 -0
- package/dist/auth/providers/no_auth_provider.d.ts.map +1 -0
- package/dist/auth/providers/no_auth_provider.js +76 -0
- package/dist/auth/providers/no_auth_provider.js.map +1 -0
- package/dist/auth/types.d.ts +100 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/user_service.d.ts +86 -0
- package/dist/auth/user_service.d.ts.map +1 -0
- package/dist/auth/user_service.js +237 -0
- package/dist/auth/user_service.js.map +1 -0
- package/dist/components/assets_manager.d.ts +662 -0
- package/dist/components/assets_manager.d.ts.map +1 -0
- package/dist/components/assets_manager.js +1537 -0
- package/dist/components/assets_manager.js.map +1 -0
- package/dist/components/async_upload.d.ts +20 -0
- package/dist/components/async_upload.d.ts.map +1 -0
- package/dist/components/async_upload.js +10 -0
- package/dist/components/async_upload.js.map +1 -0
- package/dist/components/collector.d.ts +203 -0
- package/dist/components/collector.d.ts.map +1 -0
- package/dist/components/collector.js +214 -0
- package/dist/components/collector.js.map +1 -0
- package/dist/components/custom_table_manager.d.ts +503 -0
- package/dist/components/custom_table_manager.d.ts.map +1 -0
- package/dist/components/custom_table_manager.js +1023 -0
- package/dist/components/custom_table_manager.js.map +1 -0
- package/dist/components/global_assets_handler.d.ts +63 -0
- package/dist/components/global_assets_handler.d.ts.map +1 -0
- package/dist/components/global_assets_handler.js +127 -0
- package/dist/components/global_assets_handler.js.map +1 -0
- package/dist/components/handler.d.ts +104 -0
- package/dist/components/handler.d.ts.map +1 -0
- package/dist/components/handler.js +110 -0
- package/dist/components/handler.js.map +1 -0
- package/dist/components/harvester.d.ts +182 -0
- package/dist/components/harvester.d.ts.map +1 -0
- package/dist/components/harvester.js +406 -0
- package/dist/components/harvester.js.map +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +9 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/interfaces.d.ts +126 -0
- package/dist/components/interfaces.d.ts.map +1 -0
- package/dist/components/interfaces.js +8 -0
- package/dist/components/interfaces.js.map +1 -0
- package/dist/components/map_manager.d.ts +61 -0
- package/dist/components/map_manager.d.ts.map +1 -0
- package/dist/components/map_manager.js +242 -0
- package/dist/components/map_manager.js.map +1 -0
- package/dist/components/tileset_manager.d.ts +125 -0
- package/dist/components/tileset_manager.d.ts.map +1 -0
- package/dist/components/tileset_manager.js +623 -0
- package/dist/components/tileset_manager.js.map +1 -0
- package/dist/components/types.d.ts +226 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components/types.js +8 -0
- package/dist/components/types.js.map +1 -0
- package/dist/database/adapters/knex_database_adapter.d.ts +97 -0
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -0
- package/dist/database/adapters/knex_database_adapter.js +729 -0
- package/dist/database/adapters/knex_database_adapter.js.map +1 -0
- package/dist/database/database_adapter.d.ts +262 -0
- package/dist/database/database_adapter.d.ts.map +1 -0
- package/dist/database/database_adapter.js +46 -0
- package/dist/database/database_adapter.js.map +1 -0
- package/dist/engine/digital_twin_engine.d.ts +295 -0
- package/dist/engine/digital_twin_engine.d.ts.map +1 -0
- package/dist/engine/digital_twin_engine.js +907 -0
- package/dist/engine/digital_twin_engine.js.map +1 -0
- package/dist/engine/endpoints.d.ts +47 -0
- package/dist/engine/endpoints.d.ts.map +1 -0
- package/dist/engine/endpoints.js +88 -0
- package/dist/engine/endpoints.js.map +1 -0
- package/dist/engine/error_handler.d.ts +20 -0
- package/dist/engine/error_handler.d.ts.map +1 -0
- package/dist/engine/error_handler.js +69 -0
- package/dist/engine/error_handler.js.map +1 -0
- package/dist/engine/events.d.ts +93 -0
- package/dist/engine/events.d.ts.map +1 -0
- package/dist/engine/events.js +71 -0
- package/dist/engine/events.js.map +1 -0
- package/dist/engine/health.d.ts +112 -0
- package/dist/engine/health.d.ts.map +1 -0
- package/dist/engine/health.js +190 -0
- package/dist/engine/health.js.map +1 -0
- package/dist/engine/initializer.d.ts +62 -0
- package/dist/engine/initializer.d.ts.map +1 -0
- package/dist/engine/initializer.js +108 -0
- package/dist/engine/initializer.js.map +1 -0
- package/dist/engine/queue_manager.d.ts +87 -0
- package/dist/engine/queue_manager.d.ts.map +1 -0
- package/dist/engine/queue_manager.js +196 -0
- package/dist/engine/queue_manager.js.map +1 -0
- package/dist/engine/scheduler.d.ts +30 -0
- package/dist/engine/scheduler.d.ts.map +1 -0
- package/dist/engine/scheduler.js +378 -0
- package/dist/engine/scheduler.js.map +1 -0
- package/dist/engine/upload_processor.d.ts +36 -0
- package/dist/engine/upload_processor.d.ts.map +1 -0
- package/dist/engine/upload_processor.js +113 -0
- package/dist/engine/upload_processor.js.map +1 -0
- package/dist/env/env.d.ts +134 -0
- package/dist/env/env.d.ts.map +1 -0
- package/dist/env/env.js +177 -0
- package/dist/env/env.js.map +1 -0
- package/dist/errors/index.d.ts +94 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +149 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi/generator.d.ts +93 -0
- package/dist/openapi/generator.d.ts.map +1 -0
- package/dist/openapi/generator.js +293 -0
- package/dist/openapi/generator.js.map +1 -0
- package/dist/openapi/index.d.ts +9 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +9 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/openapi/types.d.ts +182 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/openapi/types.js +16 -0
- package/dist/openapi/types.js.map +1 -0
- package/dist/storage/adapters/local_storage_service.d.ts +57 -0
- package/dist/storage/adapters/local_storage_service.d.ts.map +1 -0
- package/dist/storage/adapters/local_storage_service.js +132 -0
- package/dist/storage/adapters/local_storage_service.js.map +1 -0
- package/dist/storage/adapters/ovh_storage_service.d.ts +72 -0
- package/dist/storage/adapters/ovh_storage_service.d.ts.map +1 -0
- package/dist/storage/adapters/ovh_storage_service.js +205 -0
- package/dist/storage/adapters/ovh_storage_service.js.map +1 -0
- package/dist/storage/storage_factory.d.ts +14 -0
- package/dist/storage/storage_factory.d.ts.map +1 -0
- package/dist/storage/storage_factory.js +43 -0
- package/dist/storage/storage_factory.js.map +1 -0
- package/dist/storage/storage_service.d.ts +163 -0
- package/dist/storage/storage_service.d.ts.map +1 -0
- package/dist/storage/storage_service.js +58 -0
- package/dist/storage/storage_service.js.map +1 -0
- package/dist/types/data_record.d.ts +123 -0
- package/dist/types/data_record.d.ts.map +1 -0
- package/dist/types/data_record.js +8 -0
- package/dist/types/data_record.js.map +1 -0
- package/dist/utils/graceful_shutdown.d.ts +44 -0
- package/dist/utils/graceful_shutdown.d.ts.map +1 -0
- package/dist/utils/graceful_shutdown.js +79 -0
- package/dist/utils/graceful_shutdown.js.map +1 -0
- package/dist/utils/http_responses.d.ts +175 -0
- package/dist/utils/http_responses.d.ts.map +1 -0
- package/dist/utils/http_responses.js +216 -0
- package/dist/utils/http_responses.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +74 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +92 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/map_to_data_record.d.ts +10 -0
- package/dist/utils/map_to_data_record.d.ts.map +1 -0
- package/dist/utils/map_to_data_record.js +36 -0
- package/dist/utils/map_to_data_record.js.map +1 -0
- package/dist/utils/safe_async.d.ts +50 -0
- package/dist/utils/safe_async.d.ts.map +1 -0
- package/dist/utils/safe_async.js +90 -0
- package/dist/utils/safe_async.js.map +1 -0
- package/dist/utils/servable_endpoint.d.ts +63 -0
- package/dist/utils/servable_endpoint.d.ts.map +1 -0
- package/dist/utils/servable_endpoint.js +67 -0
- package/dist/utils/servable_endpoint.js.map +1 -0
- package/dist/utils/zip_utils.d.ts +66 -0
- package/dist/utils/zip_utils.d.ts.map +1 -0
- package/dist/utils/zip_utils.js +169 -0
- package/dist/utils/zip_utils.js.map +1 -0
- package/dist/validation/index.d.ts +3 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +7 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/schemas.d.ts +273 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +82 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validate.d.ts +49 -0
- package/dist/validation/validate.d.ts.map +1 -0
- package/dist/validation/validate.js +110 -0
- package/dist/validation/validate.js.map +1 -0
- package/package.json +23 -13
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration of available logging levels.
|
|
3
|
+
*
|
|
4
|
+
* Levels are ordered by severity, with lower numbers being more verbose.
|
|
5
|
+
*
|
|
6
|
+
* @enum {number}
|
|
7
|
+
*/
|
|
8
|
+
export var LogLevel;
|
|
9
|
+
(function (LogLevel) {
|
|
10
|
+
/** Debug messages - most verbose, includes internal state information */
|
|
11
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
12
|
+
/** Informational messages - general application flow */
|
|
13
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
14
|
+
/** Warning messages - potential issues that don't prevent operation */
|
|
15
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
16
|
+
/** Error messages - failures that affect functionality */
|
|
17
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
18
|
+
/** Silent mode - no logging output */
|
|
19
|
+
LogLevel[LogLevel["SILENT"] = 4] = "SILENT";
|
|
20
|
+
})(LogLevel || (LogLevel = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Simple logger class for Digital Twin framework components.
|
|
23
|
+
*
|
|
24
|
+
* Provides structured logging with component identification and configurable levels.
|
|
25
|
+
* Automatically adjusts log level based on environment (silent in tests).
|
|
26
|
+
*
|
|
27
|
+
* @class Logger
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const logger = new Logger('MyCollector', LogLevel.DEBUG)
|
|
32
|
+
* logger.info('Starting data collection')
|
|
33
|
+
* logger.error('Failed to connect', error)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export class Logger {
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new logger instance for a component.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} componentName - Name of the component for log prefixing
|
|
41
|
+
* @param {LogLevel} level - Minimum log level to output (defaults based on NODE_ENV)
|
|
42
|
+
*/
|
|
43
|
+
constructor(componentName, level = process.env.NODE_ENV === 'test' ? LogLevel.ERROR : LogLevel.INFO) {
|
|
44
|
+
this.componentName = componentName;
|
|
45
|
+
this.level = level;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Logs debug information for development and troubleshooting.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} message - Debug message
|
|
51
|
+
* @param {any} data - Optional additional data to log
|
|
52
|
+
*/
|
|
53
|
+
debug(message, data) {
|
|
54
|
+
if (this.level <= LogLevel.DEBUG) {
|
|
55
|
+
console.log(`[${this.componentName}] DEBUG: ${message}`, data || '');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Logs informational messages about normal operation.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} message - Information message
|
|
62
|
+
* @param {any} data - Optional additional data to log
|
|
63
|
+
*/
|
|
64
|
+
info(message, data) {
|
|
65
|
+
if (this.level <= LogLevel.INFO) {
|
|
66
|
+
console.log(`[${this.componentName}] ${message}`, data || '');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Logs warning messages about potential issues.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} message - Warning message
|
|
73
|
+
* @param {any} data - Optional additional data to log
|
|
74
|
+
*/
|
|
75
|
+
warn(message, data) {
|
|
76
|
+
if (this.level <= LogLevel.WARN) {
|
|
77
|
+
console.warn(`[${this.componentName}] WARN: ${message}`, data || '');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Logs error messages about failures and exceptions.
|
|
82
|
+
*
|
|
83
|
+
* @param {string} message - Error message
|
|
84
|
+
* @param {any} error - Optional error object or additional data
|
|
85
|
+
*/
|
|
86
|
+
error(message, error) {
|
|
87
|
+
if (this.level <= LogLevel.ERROR) {
|
|
88
|
+
console.error(`[${this.componentName}] ERROR: ${message}`, error || '');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAChB,yEAAyE;IACzE,yCAAS,CAAA;IACT,wDAAwD;IACxD,uCAAQ,CAAA;IACR,uEAAuE;IACvE,uCAAQ,CAAA;IACR,0DAA0D;IAC1D,yCAAS,CAAA;IACT,sCAAsC;IACtC,2CAAU,CAAA;AACd,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IACf;;;;;OAKG;IACH,YACqB,aAAqB,EACrB,QAAkB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;QADlF,kBAAa,GAAb,aAAa,CAAQ;QACrB,UAAK,GAAL,KAAK,CAA6E;IACpG,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,OAAe,EAAE,IAAU;QAC7B,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,aAAa,YAAY,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAe,EAAE,IAAU;QAC5B,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QACjE,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,OAAe,EAAE,IAAU;QAC5B,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,WAAW,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAe,EAAE,KAAW;QAC9B,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,YAAY,OAAO,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,CAAA;QAC3E,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StorageService } from '../storage/storage_service.js';
|
|
2
|
+
import type { DataRecord } from '../types/data_record.js';
|
|
3
|
+
import type { MetadataRow } from '../database/database_adapter.js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert a DB metadata row to a full DataRecord with lazy-loaded blob.
|
|
6
|
+
*
|
|
7
|
+
* Also maps asset-specific fields if present (for AssetsManager components).
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapToDataRecord(row: MetadataRow | any, storage: StorageService): DataRecord;
|
|
10
|
+
//# sourceMappingURL=map_to_data_record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map_to_data_record.d.ts","sourceRoot":"","sources":["../../src/utils/map_to_data_record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAElE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,UAAU,CAiC3F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a DB metadata row to a full DataRecord with lazy-loaded blob.
|
|
3
|
+
*
|
|
4
|
+
* Also maps asset-specific fields if present (for AssetsManager components).
|
|
5
|
+
*/
|
|
6
|
+
export function mapToDataRecord(row, storage) {
|
|
7
|
+
return {
|
|
8
|
+
id: row.id,
|
|
9
|
+
name: row.name,
|
|
10
|
+
date: new Date(row.date),
|
|
11
|
+
contentType: row.type,
|
|
12
|
+
url: row.url,
|
|
13
|
+
data: () => storage.retrieve(row.url),
|
|
14
|
+
// Asset-specific fields (optional, only for AssetsManager)
|
|
15
|
+
description: row.description,
|
|
16
|
+
source: row.source,
|
|
17
|
+
owner_id: row.owner_id,
|
|
18
|
+
filename: row.filename,
|
|
19
|
+
// Default to true for backward compatibility with records created before is_public column
|
|
20
|
+
// SQLite stores booleans as 0/1, so we normalize to proper boolean
|
|
21
|
+
is_public: row.is_public === undefined || row.is_public === null ? true : Boolean(row.is_public),
|
|
22
|
+
// TilesetManager support
|
|
23
|
+
tileset_url: row.tileset_url || undefined,
|
|
24
|
+
// Legacy (deprecated)
|
|
25
|
+
file_index: row.file_index
|
|
26
|
+
? typeof row.file_index === 'string'
|
|
27
|
+
? JSON.parse(row.file_index)
|
|
28
|
+
: row.file_index
|
|
29
|
+
: undefined,
|
|
30
|
+
// Async upload support
|
|
31
|
+
upload_status: row.upload_status || null,
|
|
32
|
+
upload_error: row.upload_error || null,
|
|
33
|
+
upload_job_id: row.upload_job_id || null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=map_to_data_record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map_to_data_record.js","sourceRoot":"","sources":["../../src/utils/map_to_data_record.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAsB,EAAE,OAAuB;IAC3E,OAAO;QACH,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACxB,WAAW,EAAE,GAAG,CAAC,IAAI;QACrB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAErC,2DAA2D;QAC3D,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,0FAA0F;QAC1F,mEAAmE;QACnE,SAAS,EAAE,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QAEhG,yBAAyB;QACzB,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,SAAS;QAEzC,sBAAsB;QACtB,UAAU,EAAE,GAAG,CAAC,UAAU;YACtB,CAAC,CAAC,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;gBAChC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC;gBAC5B,CAAC,CAAC,GAAG,CAAC,UAAU;YACpB,CAAC,CAAC,SAAS;QAEf,uBAAuB;QACvB,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;QACxC,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,IAAI;QACtC,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;KAC3C,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for safe async operations
|
|
3
|
+
* Provides error handling for non-critical operations like cleanup
|
|
4
|
+
*/
|
|
5
|
+
import { Logger } from './logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Executes an async operation with error logging
|
|
8
|
+
* For cleanup operations where errors should not block execution
|
|
9
|
+
*
|
|
10
|
+
* @param operation - The async function to execute
|
|
11
|
+
* @param context - Description of the operation for logging
|
|
12
|
+
* @param logger - Optional logger instance
|
|
13
|
+
* @returns The result of the operation, or undefined if it failed
|
|
14
|
+
*/
|
|
15
|
+
export declare function safeAsync<T>(operation: () => Promise<T>, context: string, logger?: Logger): Promise<T | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Executes an async operation and returns a Result tuple
|
|
18
|
+
* Useful when you need to know if the operation failed but continue execution
|
|
19
|
+
*
|
|
20
|
+
* @param operation - The async function to execute
|
|
21
|
+
* @returns [result, undefined] on success, [undefined, error] on failure
|
|
22
|
+
*/
|
|
23
|
+
export declare function tryAsync<T>(operation: () => Promise<T>): Promise<[T, undefined] | [undefined, Error]>;
|
|
24
|
+
/**
|
|
25
|
+
* Executes multiple cleanup operations in parallel, logging any failures
|
|
26
|
+
* All operations will be attempted even if some fail
|
|
27
|
+
*
|
|
28
|
+
* @param operations - Array of cleanup operations with context
|
|
29
|
+
* @param logger - Optional logger instance
|
|
30
|
+
*/
|
|
31
|
+
export declare function safeCleanup(operations: Array<{
|
|
32
|
+
operation: () => Promise<unknown>;
|
|
33
|
+
context: string;
|
|
34
|
+
}>, logger?: Logger): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Retries an async operation with exponential backoff
|
|
37
|
+
*
|
|
38
|
+
* @param operation - The async function to execute
|
|
39
|
+
* @param options - Retry options
|
|
40
|
+
* @returns The result of the operation
|
|
41
|
+
* @throws The last error if all retries fail
|
|
42
|
+
*/
|
|
43
|
+
export declare function retryAsync<T>(operation: () => Promise<T>, options?: {
|
|
44
|
+
maxRetries?: number;
|
|
45
|
+
initialDelayMs?: number;
|
|
46
|
+
maxDelayMs?: number;
|
|
47
|
+
context?: string;
|
|
48
|
+
logger?: Logger;
|
|
49
|
+
}): Promise<T>;
|
|
50
|
+
//# sourceMappingURL=safe_async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe_async.d.ts","sourceRoot":"","sources":["../../src/utils/safe_async.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAIpC;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CASxB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAQ3G;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC7B,UAAU,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EACzE,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAC9B,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE;IACL,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CACb,GACP,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for safe async operations
|
|
3
|
+
* Provides error handling for non-critical operations like cleanup
|
|
4
|
+
*/
|
|
5
|
+
import { Logger } from './logger.js';
|
|
6
|
+
const defaultLogger = new Logger('SafeAsync');
|
|
7
|
+
/**
|
|
8
|
+
* Executes an async operation with error logging
|
|
9
|
+
* For cleanup operations where errors should not block execution
|
|
10
|
+
*
|
|
11
|
+
* @param operation - The async function to execute
|
|
12
|
+
* @param context - Description of the operation for logging
|
|
13
|
+
* @param logger - Optional logger instance
|
|
14
|
+
* @returns The result of the operation, or undefined if it failed
|
|
15
|
+
*/
|
|
16
|
+
export async function safeAsync(operation, context, logger) {
|
|
17
|
+
try {
|
|
18
|
+
return await operation();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const log = logger ?? defaultLogger;
|
|
22
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
23
|
+
log.warn(`Non-critical error in ${context}: ${message}`);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Executes an async operation and returns a Result tuple
|
|
29
|
+
* Useful when you need to know if the operation failed but continue execution
|
|
30
|
+
*
|
|
31
|
+
* @param operation - The async function to execute
|
|
32
|
+
* @returns [result, undefined] on success, [undefined, error] on failure
|
|
33
|
+
*/
|
|
34
|
+
export async function tryAsync(operation) {
|
|
35
|
+
try {
|
|
36
|
+
const result = await operation();
|
|
37
|
+
return [result, undefined];
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
41
|
+
return [undefined, err];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Executes multiple cleanup operations in parallel, logging any failures
|
|
46
|
+
* All operations will be attempted even if some fail
|
|
47
|
+
*
|
|
48
|
+
* @param operations - Array of cleanup operations with context
|
|
49
|
+
* @param logger - Optional logger instance
|
|
50
|
+
*/
|
|
51
|
+
export async function safeCleanup(operations, logger) {
|
|
52
|
+
const log = logger ?? defaultLogger;
|
|
53
|
+
const results = await Promise.allSettled(operations.map(({ operation, context }) => operation().catch(error => {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
log.warn(`Cleanup failed for ${context}: ${message}`);
|
|
56
|
+
throw error;
|
|
57
|
+
})));
|
|
58
|
+
const failures = results.filter(r => r.status === 'rejected').length;
|
|
59
|
+
if (failures > 0) {
|
|
60
|
+
log.warn(`${failures}/${operations.length} cleanup operations failed`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Retries an async operation with exponential backoff
|
|
65
|
+
*
|
|
66
|
+
* @param operation - The async function to execute
|
|
67
|
+
* @param options - Retry options
|
|
68
|
+
* @returns The result of the operation
|
|
69
|
+
* @throws The last error if all retries fail
|
|
70
|
+
*/
|
|
71
|
+
export async function retryAsync(operation, options = {}) {
|
|
72
|
+
const { maxRetries = 3, initialDelayMs = 100, maxDelayMs = 5000, context = 'operation', logger } = options;
|
|
73
|
+
const log = logger ?? defaultLogger;
|
|
74
|
+
let lastError;
|
|
75
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
76
|
+
try {
|
|
77
|
+
return await operation();
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
81
|
+
if (attempt < maxRetries) {
|
|
82
|
+
const delay = Math.min(initialDelayMs * Math.pow(2, attempt), maxDelayMs);
|
|
83
|
+
log.warn(`${context} failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms: ${lastError.message}`);
|
|
84
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
throw lastError;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=safe_async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe_async.js","sourceRoot":"","sources":["../../src/utils/safe_async.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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') */
|
|
12
|
+
path: string;
|
|
13
|
+
/** HTTP method (defaults to 'get') */
|
|
14
|
+
method?: string;
|
|
15
|
+
/** Response content type (defaults to 'application/json') */
|
|
16
|
+
responseType?: string;
|
|
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 {};
|
|
63
|
+
//# sourceMappingURL=servable_endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
*/
|
|
50
|
+
export function servableEndpoint(config) {
|
|
51
|
+
return function (target, propertyKey, descriptor) {
|
|
52
|
+
const ctor = target.constructor;
|
|
53
|
+
// Initialize endpoints array if it doesn't exist
|
|
54
|
+
if (!ctor.__endpoints) {
|
|
55
|
+
ctor.__endpoints = [];
|
|
56
|
+
}
|
|
57
|
+
// Add endpoint configuration to the constructor metadata
|
|
58
|
+
ctor.__endpoints.push({
|
|
59
|
+
method: (config.method || 'get').toUpperCase(),
|
|
60
|
+
path: config.path,
|
|
61
|
+
responseType: config.responseType,
|
|
62
|
+
handlerName: propertyKey.toString()
|
|
63
|
+
});
|
|
64
|
+
return descriptor;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=servable_endpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { StorageService } from '../storage/storage_service.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of extracting and storing a ZIP archive
|
|
4
|
+
*/
|
|
5
|
+
export interface ExtractedArchiveResult {
|
|
6
|
+
/** The root/main file path (e.g., 'tileset.json') */
|
|
7
|
+
root_file?: string;
|
|
8
|
+
/** Total number of files extracted */
|
|
9
|
+
file_count: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extracts the content of a zip file as a stream (for large files)
|
|
13
|
+
* @param zipBuffer - The content of the zip file as Buffer
|
|
14
|
+
* @returns A generator yielding tuples containing the name and content of each file in the zip file
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractZipContentStream(zipBuffer: Buffer): AsyncGenerator<[string, string | Buffer]>;
|
|
17
|
+
/**
|
|
18
|
+
* Converts a zip file to a dictionary containing all files and their contents
|
|
19
|
+
* @param zipBuffer - The content of the zip file as Buffer
|
|
20
|
+
* @returns A dictionary containing the content of the zip file
|
|
21
|
+
*/
|
|
22
|
+
export declare function zipToDict(zipBuffer: Buffer): Promise<Record<string, string | Buffer>>;
|
|
23
|
+
/**
|
|
24
|
+
* Detects the root file for 3D Tiles tilesets
|
|
25
|
+
* Looks for tileset.json or similar entry point files
|
|
26
|
+
* @param files - List of file paths in the archive
|
|
27
|
+
* @returns The path to the root file, or undefined if not found
|
|
28
|
+
*/
|
|
29
|
+
export declare function detectTilesetRootFile(files: string[]): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Normalizes file paths from ZIP archives
|
|
32
|
+
* Removes leading directory if all files share the same root folder
|
|
33
|
+
* @param files - Original file paths from the archive
|
|
34
|
+
* @returns Normalized file paths (original -> normalized)
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeArchivePaths(files: string[]): Map<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Extracts a ZIP archive and stores each file individually using the storage service.
|
|
39
|
+
*
|
|
40
|
+
* This function:
|
|
41
|
+
* 1. Extracts all files from the ZIP
|
|
42
|
+
* 2. Normalizes paths (removes common root directory if present)
|
|
43
|
+
* 3. Stores each file using the storage service with a unique base path
|
|
44
|
+
* 4. Returns the root file path and file count
|
|
45
|
+
*
|
|
46
|
+
* Files are uploaded in parallel batches for performance.
|
|
47
|
+
*
|
|
48
|
+
* @param zipBuffer - The ZIP file content as a Buffer
|
|
49
|
+
* @param storage - The storage service to use for saving files
|
|
50
|
+
* @param basePath - Base path/folder for storing extracted files (e.g., 'tilesets/1234567890')
|
|
51
|
+
* @returns ExtractedArchiveResult with root file and file count
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const result = await extractAndStoreArchive(zipBuffer, storage, 'tilesets/1234567890')
|
|
56
|
+
* // result.root_file = 'tileset.json'
|
|
57
|
+
* // result.file_count = 42
|
|
58
|
+
*
|
|
59
|
+
* // Files are stored at:
|
|
60
|
+
* // tilesets/1234567890/tileset.json
|
|
61
|
+
* // tilesets/1234567890/tiles/tile_0.b3dm
|
|
62
|
+
* // etc.
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function extractAndStoreArchive(zipBuffer: Buffer, storage: StorageService, basePath: string): Promise<ExtractedArchiveResult>;
|
|
66
|
+
//# sourceMappingURL=zip_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip_utils.d.ts","sourceRoot":"","sources":["../../src/utils/zip_utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAuB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAqB3G;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAQ3F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,sBAAsB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,sBAAsB,CAAC,CAuEjC"}
|