digitaltwin-core 0.14.3 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -1
- package/dist/auth/apisix_parser.d.ts +56 -56
- package/dist/auth/apisix_parser.d.ts.map +1 -1
- package/dist/auth/apisix_parser.js +72 -86
- package/dist/auth/apisix_parser.js.map +1 -1
- 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 +4 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -1
- 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 +5 -3
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/components/assets_manager.d.ts +1 -1
- package/dist/components/assets_manager.d.ts.map +1 -1
- package/dist/components/assets_manager.js +54 -48
- package/dist/components/assets_manager.js.map +1 -1
- package/dist/components/collector.d.ts.map +1 -1
- package/dist/components/collector.js +30 -18
- package/dist/components/collector.js.map +1 -1
- package/dist/components/custom_table_manager.d.ts.map +1 -1
- package/dist/components/custom_table_manager.js +36 -65
- package/dist/components/custom_table_manager.js.map +1 -1
- package/dist/components/global_assets_handler.d.ts +4 -2
- package/dist/components/global_assets_handler.d.ts.map +1 -1
- package/dist/components/global_assets_handler.js.map +1 -1
- package/dist/components/harvester.d.ts.map +1 -1
- package/dist/components/harvester.js +46 -33
- package/dist/components/harvester.js.map +1 -1
- package/dist/components/interfaces.d.ts +3 -2
- package/dist/components/interfaces.d.ts.map +1 -1
- package/dist/components/map_manager.d.ts.map +1 -1
- package/dist/components/map_manager.js.map +1 -1
- package/dist/components/tileset_manager.d.ts +2 -1
- package/dist/components/tileset_manager.d.ts.map +1 -1
- package/dist/components/tileset_manager.js +20 -15
- package/dist/components/tileset_manager.js.map +1 -1
- package/dist/database/adapters/knex_database_adapter.d.ts +6 -1
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -1
- package/dist/database/adapters/knex_database_adapter.js +118 -36
- package/dist/database/adapters/knex_database_adapter.js.map +1 -1
- package/dist/database/database_adapter.d.ts +13 -1
- package/dist/database/database_adapter.d.ts.map +1 -1
- package/dist/database/database_adapter.js.map +1 -1
- package/dist/engine/component_types.d.ts +95 -0
- package/dist/engine/component_types.d.ts.map +1 -0
- package/dist/engine/component_types.js +93 -0
- package/dist/engine/component_types.js.map +1 -0
- package/dist/engine/digital_twin_engine.d.ts +121 -6
- package/dist/engine/digital_twin_engine.d.ts.map +1 -1
- package/dist/engine/digital_twin_engine.js +402 -74
- package/dist/engine/digital_twin_engine.js.map +1 -1
- package/dist/engine/endpoints.d.ts.map +1 -1
- package/dist/engine/endpoints.js +35 -3
- package/dist/engine/endpoints.js.map +1 -1
- 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 +1 -1
- package/dist/engine/events.d.ts.map +1 -1
- package/dist/engine/events.js.map +1 -1
- 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.map +1 -1
- package/dist/engine/initializer.js +6 -4
- package/dist/engine/initializer.js.map +1 -1
- package/dist/engine/scheduler.d.ts.map +1 -1
- package/dist/engine/scheduler.js +17 -9
- package/dist/engine/scheduler.js.map +1 -1
- package/dist/engine/upload_processor.d.ts.map +1 -1
- package/dist/engine/upload_processor.js +24 -12
- package/dist/engine/upload_processor.js.map +1 -1
- 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 +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/loader/component_loader.d.ts +128 -0
- package/dist/loader/component_loader.d.ts.map +1 -0
- package/dist/loader/component_loader.js +330 -0
- package/dist/loader/component_loader.js.map +1 -0
- package/dist/loader/index.d.ts +19 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +19 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/storage/adapters/local_storage_service.d.ts +6 -0
- package/dist/storage/adapters/local_storage_service.d.ts.map +1 -1
- package/dist/storage/adapters/local_storage_service.js +26 -4
- package/dist/storage/adapters/local_storage_service.js.map +1 -1
- package/dist/storage/adapters/ovh_storage_service.d.ts.map +1 -1
- package/dist/storage/adapters/ovh_storage_service.js +5 -6
- package/dist/storage/adapters/ovh_storage_service.js.map +1 -1
- package/dist/storage/storage_factory.d.ts.map +1 -1
- package/dist/storage/storage_factory.js +4 -1
- package/dist/storage/storage_factory.js.map +1 -1
- package/dist/storage/storage_service.d.ts.map +1 -1
- package/dist/storage/storage_service.js +6 -2
- package/dist/storage/storage_service.js.map +1 -1
- package/dist/types/http.d.ts +156 -0
- package/dist/types/http.d.ts.map +1 -0
- package/dist/types/http.js +8 -0
- package/dist/types/http.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 +20 -0
- package/dist/utils/http_responses.d.ts.map +1 -1
- package/dist/utils/http_responses.js +28 -2
- package/dist/utils/http_responses.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -8
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +8 -8
- package/dist/utils/logger.js.map +1 -1
- 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/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 +14 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local_storage_service.js","sourceRoot":"","sources":["../../../src/storage/adapters/local_storage_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,MAAM,aAAa,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAA;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A;YAEzD,OAAO,SAAS,CAAA;QACpB,CAAC;QAAC,MAAM,CAAC;YACL,uBAAuB;YACvB,OAAO,CAAC,CAAA;QACZ,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ovh_storage_service.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"ovh_storage_service.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAOtD,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,mBAAoB,SAAQ,cAAc;;gBAKvC,MAAM,EAAE,WAAW;IAkB/B;;;;;;OAMG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBtF;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBrD;;;OAGG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD;;;;;;;OAOG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAazE;;;;OAIG;IACY,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC1D;;;;;OAKG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAO1C;;;;;OAKG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0CrD;;;;;;;;;OASG;IACG,aAAa,CACf,cAAc,GAAE,MAAM,EAAU,EAChC,cAAc,GAAE,MAAM,EAAoB,EAC1C,cAAc,GAAE,MAAM,EAA2B,GAClD,OAAO,CAAC,OAAO,CAAC;CAyBtB"}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, DeleteObjectsCommand, ListObjectsV2Command, PutBucketCorsCommand, ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
6
6
|
import { StorageService } from '../storage_service.js';
|
|
7
|
+
import { safeAsync } from '../../utils/safe_async.js';
|
|
8
|
+
import { Logger } from '../../utils/logger.js';
|
|
9
|
+
const logger = new Logger('OvhS3Storage');
|
|
7
10
|
export class OvhS3StorageService extends StorageService {
|
|
8
11
|
#s3;
|
|
9
12
|
#bucket;
|
|
@@ -106,17 +109,13 @@ export class OvhS3StorageService extends StorageService {
|
|
|
106
109
|
const MAX_CONCURRENT = 5;
|
|
107
110
|
for (let i = 0; i < batches.length; i += MAX_CONCURRENT) {
|
|
108
111
|
const concurrentBatches = batches.slice(i, i + MAX_CONCURRENT);
|
|
109
|
-
await Promise.all(concurrentBatches.map(batch => this.#s3
|
|
110
|
-
.send(new DeleteObjectsCommand({
|
|
112
|
+
await Promise.all(concurrentBatches.map((batch, index) => safeAsync(() => this.#s3.send(new DeleteObjectsCommand({
|
|
111
113
|
Bucket: this.#bucket,
|
|
112
114
|
Delete: {
|
|
113
115
|
Objects: batch.map(key => ({ Key: key })),
|
|
114
116
|
Quiet: true // Don't return info about each deleted object
|
|
115
117
|
}
|
|
116
|
-
}))
|
|
117
|
-
.catch(() => {
|
|
118
|
-
// Ignore batch delete errors - files may already be deleted
|
|
119
|
-
})));
|
|
118
|
+
})), `delete batch ${i + index + 1}/${batches.length}`, logger)));
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ovh_storage_service.js","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAClB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"ovh_storage_service.js","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAClB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAG9C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAA;AAUzC,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACnD,GAAG,CAAU;IACJ,OAAO,CAAQ;IACf,SAAS,CAAQ;IAE1B,YAAY,MAAmB;QAC3B,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YAC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AC,GAAG,CAAC,IAAI,CACf,IAAI,oBAAoB,CAAC;gBACrB,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,iBAAiB,EAAE;oBACf,SAAS,EAAE;wBACP;4BACI,cAAc,EAAE,cAAc;4BAC9B,cAAc,EAAE,cAAc;4BAC9B,cAAc,EAAE,cAAc;4BAC9B,aAAa,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC;4BACzC,aAAa,EAAE,IAAI;yBACtB;qBACJ;iBACJ;aACJ,CAAC,CACL,CAAA;YACD,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAA;YACjE,OAAO,IAAI,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAA;YACrE,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage_factory.d.ts","sourceRoot":"","sources":["../../src/storage/storage_factory.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"storage_factory.d.ts","sourceRoot":"","sources":["../../src/storage/storage_factory.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAM1D,qBAAa,qBAAqB;IAC9B;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,IAAI,cAAc;CAwBlC"}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
import { Env } from '../env/env.js';
|
|
6
6
|
import { OvhS3StorageService } from './adapters/ovh_storage_service.js';
|
|
7
7
|
import { LocalStorageService } from './adapters/local_storage_service.js';
|
|
8
|
+
import { safeAsync } from '../utils/safe_async.js';
|
|
9
|
+
import { Logger } from '../utils/logger.js';
|
|
10
|
+
const logger = new Logger('StorageFactory');
|
|
8
11
|
export class StorageServiceFactory {
|
|
9
12
|
/**
|
|
10
13
|
* Creates and returns an instance of StorageService
|
|
@@ -29,7 +32,7 @@ export class StorageServiceFactory {
|
|
|
29
32
|
region: env.OVH_REGION ?? 'gra'
|
|
30
33
|
});
|
|
31
34
|
// Configure CORS for browser access (non-blocking)
|
|
32
|
-
ovhStorage.configureCors()
|
|
35
|
+
safeAsync(() => ovhStorage.configureCors(), 'configure OVH CORS', logger);
|
|
33
36
|
return ovhStorage;
|
|
34
37
|
}
|
|
35
38
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage_factory.js","sourceRoot":"","sources":["../../src/storage/storage_factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"storage_factory.js","sourceRoot":"","sources":["../../src/storage/storage_factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAE3C,MAAM,OAAO,qBAAqB;IAC9B;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM;QACT,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAA;QAEtB,QAAQ,GAAG,CAAC,cAAc,EAAE,CAAC;YACzB,KAAK,OAAO;gBACR,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,IAAI,MAAM,CAAC,CAAA;YAEnE,KAAK,KAAK,CAAC,CAAC,CAAC;gBACT,MAAM,UAAU,GAAG,IAAI,mBAAmB,CAAC;oBACvC,SAAS,EAAE,GAAG,CAAC,cAAc;oBAC7B,SAAS,EAAE,GAAG,CAAC,cAAc;oBAC7B,QAAQ,EAAE,GAAG,CAAC,YAAY;oBAC1B,MAAM,EAAE,GAAG,CAAC,UAAU;oBACtB,MAAM,EAAE,GAAG,CAAC,UAAU,IAAI,KAAK;iBAClC,CAAC,CAAA;gBACF,mDAAmD;gBACnD,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;gBACzE,OAAO,UAAU,CAAA;YACrB,CAAC;YAED;gBACI,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,CAAC,cAAc,EAAE,CAAC,CAAA;QAC5E,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage_service.d.ts","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage_service.d.ts","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8BAAsB,cAAc;IAChC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEzF;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhD;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE5C;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE5E;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAEnD;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAC3D"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { safeAsync } from '../utils/safe_async.js';
|
|
2
|
+
import { Logger } from '../utils/logger.js';
|
|
3
|
+
const logger = new Logger('StorageService');
|
|
1
4
|
/**
|
|
2
5
|
* Abstract base class for storage service implementations.
|
|
3
6
|
*
|
|
@@ -47,8 +50,9 @@ export class StorageService {
|
|
|
47
50
|
* ```
|
|
48
51
|
*/
|
|
49
52
|
async deleteBatch(paths) {
|
|
50
|
-
// Default
|
|
51
|
-
|
|
53
|
+
// Default parallel implementation - subclasses can override with bulk operations
|
|
54
|
+
// Individual failures are logged but don't prevent other deletions
|
|
55
|
+
await Promise.all(paths.map(path => safeAsync(() => this.delete(path), `delete file ${path}`, logger)));
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
//# sourceMappingURL=storage_service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage_service.js","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAgB,cAAc;IAiFhC;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,WAAW,CAAC,KAAe;QAC7B,
|
|
1
|
+
{"version":3,"file":"storage_service.js","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAgB,cAAc;IAiFhC;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,WAAW,CAAC,KAAe;QAC7B,iFAAiF;QACjF,mEAAmE;QACnE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,eAAe,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IAC3G,CAAC;CAuCJ"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HTTP request type definitions for typed Express handlers
|
|
3
|
+
*
|
|
4
|
+
* Provides strongly-typed request interfaces to replace `any` in handler functions.
|
|
5
|
+
* These types extend Express Request with specific body, params, and query types.
|
|
6
|
+
*/
|
|
7
|
+
import type { Request, Response } from 'ultimate-express';
|
|
8
|
+
import type { AuthContext } from '../auth/types.js';
|
|
9
|
+
import type { DataResponse } from '../components/types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Multer file object interface.
|
|
12
|
+
* Represents an uploaded file from multipart/form-data requests.
|
|
13
|
+
*/
|
|
14
|
+
export interface MulterFile {
|
|
15
|
+
/** Field name in the form */
|
|
16
|
+
fieldname: string;
|
|
17
|
+
/** Original filename from the client */
|
|
18
|
+
originalname: string;
|
|
19
|
+
/** File encoding (e.g., '7bit') */
|
|
20
|
+
encoding: string;
|
|
21
|
+
/** MIME type of the file */
|
|
22
|
+
mimetype: string;
|
|
23
|
+
/** File size in bytes */
|
|
24
|
+
size: number;
|
|
25
|
+
/** Path to uploaded file (disk storage) */
|
|
26
|
+
path?: string;
|
|
27
|
+
/** File content (memory storage) */
|
|
28
|
+
buffer?: Buffer;
|
|
29
|
+
/** Destination directory (disk storage) */
|
|
30
|
+
destination?: string;
|
|
31
|
+
/** Generated filename (disk storage) */
|
|
32
|
+
filename?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Base typed request interface extending Express Request.
|
|
36
|
+
*
|
|
37
|
+
* @template TParams - Type for URL parameters (e.g., { id: string })
|
|
38
|
+
* @template TBody - Type for request body
|
|
39
|
+
* @template TQuery - Type for query string parameters
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* type GetUserRequest = TypedRequest<{ id: string }, never, { include?: string }>
|
|
44
|
+
*
|
|
45
|
+
* async function getUser(req: GetUserRequest) {
|
|
46
|
+
* const userId = req.params.id // string
|
|
47
|
+
* const include = req.query.include // string | undefined
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export interface TypedRequest<TParams = Record<string, string>, TBody = Record<string, unknown>, TQuery = Record<string, string | string[] | undefined>> extends Omit<Request, 'params' | 'body' | 'query' | 'file' | 'files'> {
|
|
52
|
+
params: TParams;
|
|
53
|
+
body: TBody;
|
|
54
|
+
query: TQuery;
|
|
55
|
+
file?: MulterFile;
|
|
56
|
+
files?: MulterFile[] | Record<string, MulterFile[]>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Request with authentication context.
|
|
60
|
+
* Used for endpoints that require user authentication.
|
|
61
|
+
*/
|
|
62
|
+
export interface AuthenticatedTypedRequest<TParams = Record<string, string>, TBody = unknown, TQuery = Record<string, string | string[] | undefined>> extends TypedRequest<TParams, TBody, TQuery> {
|
|
63
|
+
auth?: AuthContext;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Handler function type for component endpoints.
|
|
67
|
+
*
|
|
68
|
+
* @template TParams - Type for URL parameters
|
|
69
|
+
* @template TBody - Type for request body
|
|
70
|
+
* @template TQuery - Type for query string parameters
|
|
71
|
+
*/
|
|
72
|
+
export type EndpointHandler<TParams = Record<string, string>, TBody = unknown, TQuery = Record<string, string | string[] | undefined>> = (req: TypedRequest<TParams, TBody, TQuery>, res?: Response) => Promise<DataResponse> | DataResponse;
|
|
73
|
+
/**
|
|
74
|
+
* Generic handler function that accepts any typed request.
|
|
75
|
+
* Used in interface definitions where specific types are unknown.
|
|
76
|
+
*/
|
|
77
|
+
export type GenericHandler = (req: TypedRequest<Record<string, string>, unknown, Record<string, string | string[] | undefined>>, res?: Response) => Promise<DataResponse> | DataResponse;
|
|
78
|
+
/** Request with ID parameter */
|
|
79
|
+
export type IdParamRequest<TBody = unknown> = TypedRequest<{
|
|
80
|
+
id: string;
|
|
81
|
+
}, TBody>;
|
|
82
|
+
/** Request with no parameters */
|
|
83
|
+
export type NoParamRequest<TBody = unknown> = TypedRequest<Record<string, never>, TBody>;
|
|
84
|
+
/** Asset upload request body */
|
|
85
|
+
export interface AssetUploadBody {
|
|
86
|
+
description?: string;
|
|
87
|
+
source?: string;
|
|
88
|
+
is_public?: string | boolean;
|
|
89
|
+
}
|
|
90
|
+
/** Asset update request body */
|
|
91
|
+
export interface AssetUpdateBody {
|
|
92
|
+
description?: string;
|
|
93
|
+
source?: string;
|
|
94
|
+
is_public?: string | boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Request for uploading an asset */
|
|
97
|
+
export type AssetUploadRequest = TypedRequest<Record<string, never>, AssetUploadBody> & {
|
|
98
|
+
file?: MulterFile;
|
|
99
|
+
};
|
|
100
|
+
/** Request for getting an asset by ID */
|
|
101
|
+
export type AssetGetRequest = TypedRequest<{
|
|
102
|
+
id: string;
|
|
103
|
+
}>;
|
|
104
|
+
/** Request for updating an asset */
|
|
105
|
+
export type AssetUpdateRequest = TypedRequest<{
|
|
106
|
+
id: string;
|
|
107
|
+
}, AssetUpdateBody>;
|
|
108
|
+
/** Request for deleting an asset */
|
|
109
|
+
export type AssetDeleteRequest = TypedRequest<{
|
|
110
|
+
id: string;
|
|
111
|
+
}>;
|
|
112
|
+
/** Single asset in batch upload */
|
|
113
|
+
export interface BatchAssetData {
|
|
114
|
+
filename: string;
|
|
115
|
+
description: string;
|
|
116
|
+
source: string;
|
|
117
|
+
data: string;
|
|
118
|
+
is_public?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/** Batch upload request body */
|
|
121
|
+
export interface BatchUploadBody {
|
|
122
|
+
assets: BatchAssetData[];
|
|
123
|
+
}
|
|
124
|
+
/** Request for batch uploading assets */
|
|
125
|
+
export type BatchUploadRequest = TypedRequest<Record<string, never>, BatchUploadBody>;
|
|
126
|
+
/** Request for custom table list with pagination */
|
|
127
|
+
export interface CustomTableListQuery {
|
|
128
|
+
page?: string;
|
|
129
|
+
limit?: string;
|
|
130
|
+
sort?: string;
|
|
131
|
+
order?: 'asc' | 'desc';
|
|
132
|
+
[key: string]: string | string[] | undefined;
|
|
133
|
+
}
|
|
134
|
+
export type CustomTableListRequest = TypedRequest<Record<string, never>, unknown, CustomTableListQuery>;
|
|
135
|
+
/** Request for custom table record by ID */
|
|
136
|
+
export type CustomTableGetRequest = TypedRequest<{
|
|
137
|
+
id: string;
|
|
138
|
+
}>;
|
|
139
|
+
/** Request for creating custom table record */
|
|
140
|
+
export type CustomTableCreateRequest<T = Record<string, unknown>> = TypedRequest<Record<string, never>, T>;
|
|
141
|
+
/** Request for updating custom table record */
|
|
142
|
+
export type CustomTableUpdateRequest<T = Record<string, unknown>> = TypedRequest<{
|
|
143
|
+
id: string;
|
|
144
|
+
}, T>;
|
|
145
|
+
/** Tileset upload request */
|
|
146
|
+
export type TilesetUploadRequest = TypedRequest<Record<string, never>, AssetUploadBody> & {
|
|
147
|
+
file?: MulterFile;
|
|
148
|
+
};
|
|
149
|
+
/** Tileset list query */
|
|
150
|
+
export interface TilesetListQuery {
|
|
151
|
+
page?: string;
|
|
152
|
+
limit?: string;
|
|
153
|
+
owner_id?: string;
|
|
154
|
+
}
|
|
155
|
+
export type TilesetListRequest = TypedRequest<Record<string, never>, unknown, TilesetListQuery>;
|
|
156
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/types/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,YAAY,CACzB,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CA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MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,CAAA;AAE/G,yBAAyB;AACzB,MAAM,WAAW,gBAAgB;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HTTP request type definitions for typed Express handlers
|
|
3
|
+
*
|
|
4
|
+
* Provides strongly-typed request interfaces to replace `any` in handler functions.
|
|
5
|
+
* These types extend Express Request with specific body, params, and query types.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/types/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DigitalTwinEngine } from '../engine/digital_twin_engine.js';
|
|
2
|
+
export interface ShutdownOptions {
|
|
3
|
+
/** Timeout before forcing exit (default: 30000ms) */
|
|
4
|
+
timeout?: number;
|
|
5
|
+
/** Signals to handle (default: ['SIGTERM', 'SIGINT']) */
|
|
6
|
+
signals?: NodeJS.Signals[];
|
|
7
|
+
/** Custom cleanup function to run before stopping engine */
|
|
8
|
+
onShutdown?: () => Promise<void>;
|
|
9
|
+
/** Custom logger function (default: console.log) */
|
|
10
|
+
logger?: (msg: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Setup graceful shutdown handlers for a DigitalTwinEngine
|
|
14
|
+
*
|
|
15
|
+
* This helper registers signal handlers for graceful shutdown in production.
|
|
16
|
+
* It handles SIGTERM (from Kubernetes/Docker) and SIGINT (Ctrl+C) by default.
|
|
17
|
+
*
|
|
18
|
+
* @param engine The DigitalTwinEngine instance to shut down
|
|
19
|
+
* @param options Configuration options
|
|
20
|
+
* @returns Cleanup function to remove signal handlers
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { DigitalTwinEngine, setupGracefulShutdown } from 'digitaltwin-core'
|
|
25
|
+
*
|
|
26
|
+
* const engine = new DigitalTwinEngine({ ... })
|
|
27
|
+
*
|
|
28
|
+
* // Setup graceful shutdown before starting
|
|
29
|
+
* const cleanup = setupGracefulShutdown(engine, {
|
|
30
|
+
* timeout: 30000,
|
|
31
|
+
* signals: ['SIGTERM', 'SIGINT', 'SIGQUIT'],
|
|
32
|
+
* onShutdown: async () => {
|
|
33
|
+
* console.log('Performing custom cleanup...')
|
|
34
|
+
* }
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* await engine.start()
|
|
38
|
+
*
|
|
39
|
+
* // Later, if you need to remove handlers:
|
|
40
|
+
* // cleanup()
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function setupGracefulShutdown(engine: DigitalTwinEngine, options?: ShutdownOptions): () => void;
|
|
44
|
+
//# sourceMappingURL=graceful_shutdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graceful_shutdown.d.ts","sourceRoot":"","sources":["../../src/utils/graceful_shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,MAAM,WAAW,eAAe;IAC5B,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;IAC1B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,oDAAoD;IACpD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,IAAI,CAuD1G"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup graceful shutdown handlers for a DigitalTwinEngine
|
|
3
|
+
*
|
|
4
|
+
* This helper registers signal handlers for graceful shutdown in production.
|
|
5
|
+
* It handles SIGTERM (from Kubernetes/Docker) and SIGINT (Ctrl+C) by default.
|
|
6
|
+
*
|
|
7
|
+
* @param engine The DigitalTwinEngine instance to shut down
|
|
8
|
+
* @param options Configuration options
|
|
9
|
+
* @returns Cleanup function to remove signal handlers
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { DigitalTwinEngine, setupGracefulShutdown } from 'digitaltwin-core'
|
|
14
|
+
*
|
|
15
|
+
* const engine = new DigitalTwinEngine({ ... })
|
|
16
|
+
*
|
|
17
|
+
* // Setup graceful shutdown before starting
|
|
18
|
+
* const cleanup = setupGracefulShutdown(engine, {
|
|
19
|
+
* timeout: 30000,
|
|
20
|
+
* signals: ['SIGTERM', 'SIGINT', 'SIGQUIT'],
|
|
21
|
+
* onShutdown: async () => {
|
|
22
|
+
* console.log('Performing custom cleanup...')
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* await engine.start()
|
|
27
|
+
*
|
|
28
|
+
* // Later, if you need to remove handlers:
|
|
29
|
+
* // cleanup()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function setupGracefulShutdown(engine, options = {}) {
|
|
33
|
+
const { timeout = 30000, signals = ['SIGTERM', 'SIGINT'], onShutdown, logger = console.log } = options;
|
|
34
|
+
let isShuttingDown = false;
|
|
35
|
+
const shutdown = async (signal) => {
|
|
36
|
+
if (isShuttingDown) {
|
|
37
|
+
logger(`[Shutdown] Already shutting down, ignoring ${signal}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
isShuttingDown = true;
|
|
41
|
+
logger(`[Shutdown] Received ${signal}, initiating graceful shutdown...`);
|
|
42
|
+
// Set global timeout for force exit
|
|
43
|
+
const forceExitTimer = setTimeout(() => {
|
|
44
|
+
logger('[Shutdown] Timeout exceeded, forcing exit');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}, timeout);
|
|
47
|
+
forceExitTimer.unref();
|
|
48
|
+
try {
|
|
49
|
+
// Run custom shutdown logic first
|
|
50
|
+
if (onShutdown) {
|
|
51
|
+
await onShutdown();
|
|
52
|
+
}
|
|
53
|
+
// Stop the engine
|
|
54
|
+
await engine.stop();
|
|
55
|
+
clearTimeout(forceExitTimer);
|
|
56
|
+
logger('[Shutdown] Graceful shutdown completed');
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
logger(`[Shutdown] Error during shutdown: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// Register signal handlers
|
|
65
|
+
const handlers = new Map();
|
|
66
|
+
signals.forEach(signal => {
|
|
67
|
+
const handler = () => shutdown(signal);
|
|
68
|
+
handlers.set(signal, handler);
|
|
69
|
+
process.on(signal, handler);
|
|
70
|
+
});
|
|
71
|
+
// Return cleanup function
|
|
72
|
+
return () => {
|
|
73
|
+
handlers.forEach((handler, signal) => {
|
|
74
|
+
process.removeListener(signal, handler);
|
|
75
|
+
});
|
|
76
|
+
handlers.clear();
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=graceful_shutdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graceful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O,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACrG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC,CAAA;IAED,2BAA2B;IAC3B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA8B,CAAA;IAEtD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACrB,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACtC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC7B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,0BAA0B;IAC1B,OAAO,GAAG,EAAE;QACR,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;QACF,QAAQ,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -16,6 +16,7 @@ export declare const HttpStatus: {
|
|
|
16
16
|
readonly UNAUTHORIZED: 401;
|
|
17
17
|
readonly FORBIDDEN: 403;
|
|
18
18
|
readonly NOT_FOUND: 404;
|
|
19
|
+
readonly UNPROCESSABLE_ENTITY: 422;
|
|
19
20
|
readonly INTERNAL_SERVER_ERROR: 500;
|
|
20
21
|
};
|
|
21
22
|
export type HttpStatusCode = (typeof HttpStatus)[keyof typeof HttpStatus];
|
|
@@ -108,6 +109,25 @@ export declare function forbiddenResponse(message: string): DataResponse;
|
|
|
108
109
|
* ```
|
|
109
110
|
*/
|
|
110
111
|
export declare function notFoundResponse(message?: string): DataResponse;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a validation error response (HTTP 422 Unprocessable Entity).
|
|
114
|
+
*
|
|
115
|
+
* Used when request data fails schema validation.
|
|
116
|
+
*
|
|
117
|
+
* @param message - Validation error message
|
|
118
|
+
* @param errors - Optional array of field-level validation errors
|
|
119
|
+
* @returns DataResponse with status 422
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* return validationErrorResponse('id: must be a positive number')
|
|
124
|
+
* return validationErrorResponse('Validation failed', [{ field: 'id', message: 'must be positive' }])
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function validationErrorResponse(message: string, errors?: Array<{
|
|
128
|
+
field: string;
|
|
129
|
+
message: string;
|
|
130
|
+
}>): DataResponse;
|
|
111
131
|
/**
|
|
112
132
|
* Creates a plain text response.
|
|
113
133
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_responses.d.ts","sourceRoot":"","sources":["../../src/utils/http_responses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"http_responses.d.ts","sourceRoot":"","sources":["../../src/utils/http_responses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAG1D;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;CAUb,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA;AAEzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAMvE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAM3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAEhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,MAAkC,GAAG,YAAY,CAE9F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAE/D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,MAA6B,GAAG,YAAY,CAErF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACnD,YAAY,CAMd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAM1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,CAYlG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,YAAY,CAErF"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This module provides helper functions to create standardized DataResponse objects,
|
|
5
5
|
* reducing boilerplate code in component handlers and ensuring consistent API responses.
|
|
6
6
|
*/
|
|
7
|
+
import { DigitalTwinError } from '../errors/index.js';
|
|
7
8
|
/**
|
|
8
9
|
* HTTP status codes commonly used in the Digital Twin framework.
|
|
9
10
|
*/
|
|
@@ -15,6 +16,7 @@ export const HttpStatus = {
|
|
|
15
16
|
UNAUTHORIZED: 401,
|
|
16
17
|
FORBIDDEN: 403,
|
|
17
18
|
NOT_FOUND: 404,
|
|
19
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
18
20
|
INTERNAL_SERVER_ERROR: 500
|
|
19
21
|
};
|
|
20
22
|
/**
|
|
@@ -64,9 +66,11 @@ export function successResponse(data) {
|
|
|
64
66
|
* return errorResponse('Invalid input', 400)
|
|
65
67
|
* ```
|
|
66
68
|
*/
|
|
67
|
-
export function errorResponse(error, status
|
|
69
|
+
export function errorResponse(error, status) {
|
|
70
|
+
// Use statusCode from DigitalTwinError if available
|
|
71
|
+
const statusCode = error instanceof DigitalTwinError ? error.statusCode : (status ?? HttpStatus.INTERNAL_SERVER_ERROR);
|
|
68
72
|
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
-
return jsonResponse(
|
|
73
|
+
return jsonResponse(statusCode, { error: message });
|
|
70
74
|
}
|
|
71
75
|
/**
|
|
72
76
|
* Creates a 400 Bad Request response.
|
|
@@ -125,6 +129,28 @@ export function forbiddenResponse(message) {
|
|
|
125
129
|
export function notFoundResponse(message = 'Resource not found') {
|
|
126
130
|
return jsonResponse(HttpStatus.NOT_FOUND, { error: message });
|
|
127
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates a validation error response (HTTP 422 Unprocessable Entity).
|
|
134
|
+
*
|
|
135
|
+
* Used when request data fails schema validation.
|
|
136
|
+
*
|
|
137
|
+
* @param message - Validation error message
|
|
138
|
+
* @param errors - Optional array of field-level validation errors
|
|
139
|
+
* @returns DataResponse with status 422
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* return validationErrorResponse('id: must be a positive number')
|
|
144
|
+
* return validationErrorResponse('Validation failed', [{ field: 'id', message: 'must be positive' }])
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export function validationErrorResponse(message, errors) {
|
|
148
|
+
const body = { error: message };
|
|
149
|
+
if (errors) {
|
|
150
|
+
body.errors = errors;
|
|
151
|
+
}
|
|
152
|
+
return jsonResponse(HttpStatus.UNPROCESSABLE_ENTITY, body);
|
|
153
|
+
}
|
|
128
154
|
/**
|
|
129
155
|
* Creates a plain text response.
|
|
130
156
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http_responses.js","sourceRoot":"","sources":["../../src/utils/http_responses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"http_responses.js","sourceRoot":"","sources":["../../src/utils/http_responses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,EAAE,EAAE,GAAG;IACP,OAAO,EAAE,GAAG;IACZ,YAAY,EAAE,GAAG;IACjB,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,GAAG;IACd,oBAAoB,EAAE,GAAG;IACzB,qBAAqB,EAAE,GAAG;CACpB,CAAA;AAIV;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,IAAY;IACrD,OAAO;QACH,MAAM;QACN,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC7B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAClD,CAAA;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IACxC,OAAO,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,MAAe;IACzD,oDAAoD;IACpD,MAAM,UAAU,GACZ,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAAK,C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E,IAAI,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAe;IACxD,OAAO;QACH,MAAM;QACN,OAAO;QACP,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;KAC5C,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,WAAmB,EAAE,QAAiB;IAChF,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA;IAEvE,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,CAAC,qBAAqB,CAAC,GAAG,yBAAyB,QAAQ,GAAG,CAAA;IACzE,CAAC;IAED,OAAO;QACH,MAAM,EAAE,UAAU,CAAC,EAAE;QACrB,OAAO;QACP,OAAO;KACV,CAAA;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,OAAkB;IACnE,OAAO,YAAY,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;AACtE,CAAC"}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -46,29 +46,29 @@ export declare class Logger {
|
|
|
46
46
|
* Logs debug information for development and troubleshooting.
|
|
47
47
|
*
|
|
48
48
|
* @param {string} message - Debug message
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {unknown} data - Optional additional data to log
|
|
50
50
|
*/
|
|
51
|
-
debug(message: string, data?:
|
|
51
|
+
debug(message: string, data?: unknown): void;
|
|
52
52
|
/**
|
|
53
53
|
* Logs informational messages about normal operation.
|
|
54
54
|
*
|
|
55
55
|
* @param {string} message - Information message
|
|
56
|
-
* @param {
|
|
56
|
+
* @param {unknown} data - Optional additional data to log
|
|
57
57
|
*/
|
|
58
|
-
info(message: string, data?:
|
|
58
|
+
info(message: string, data?: unknown): void;
|
|
59
59
|
/**
|
|
60
60
|
* Logs warning messages about potential issues.
|
|
61
61
|
*
|
|
62
62
|
* @param {string} message - Warning message
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {unknown} data - Optional additional data to log
|
|
64
64
|
*/
|
|
65
|
-
warn(message: string, data?:
|
|
65
|
+
warn(message: string, data?: unknown): void;
|
|
66
66
|
/**
|
|
67
67
|
* Logs error messages about failures and exceptions.
|
|
68
68
|
*
|
|
69
69
|
* @param {string} message - Error message
|
|
70
|
-
* @param {
|
|
70
|
+
* @param {Error | unknown} error - Optional error object or additional data
|
|
71
71
|
*/
|
|
72
|
-
error(message: string, error?:
|
|
72
|
+
error(message: string, error?: Error | unknown): void;
|
|
73
73
|
}
|
|
74
74
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,QAAQ;IAChB,yEAAyE;IACzE,KAAK,IAAI;IACT,wDAAwD;IACxD,IAAI,IAAI;IACR,uEAAuE;IACvE,IAAI,IAAI;IACR,0DAA0D;IAC1D,KAAK,IAAI;IACT,sCAAsC;IACtC,MAAM,IAAI;CACb;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,MAAM;IAQX,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAR1B;;;;;OAKG;gBAEkB,aAAa,EAAE,MAAM,EACrB,KAAK,GAAE,QAA2E;IAGvG;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,QAAQ;IAChB,yEAAyE;IACzE,KAAK,IAAI;IACT,wDAAwD;IACxD,IAAI,IAAI;IACR,uEAAu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