digitaltwin-core 0.1.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 +21 -0
- package/README.md +125 -0
- package/dist/components/assets_manager.d.ts +384 -0
- package/dist/components/assets_manager.d.ts.map +1 -0
- package/dist/components/assets_manager.js +637 -0
- package/dist/components/assets_manager.js.map +1 -0
- package/dist/components/collector.d.ts +62 -0
- package/dist/components/collector.d.ts.map +1 -0
- package/dist/components/collector.js +80 -0
- package/dist/components/collector.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 +33 -0
- package/dist/components/handler.d.ts.map +1 -0
- package/dist/components/handler.js +27 -0
- package/dist/components/handler.js.map +1 -0
- package/dist/components/harvester.d.ts +54 -0
- package/dist/components/harvester.d.ts.map +1 -0
- package/dist/components/harvester.js +253 -0
- package/dist/components/harvester.js.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/interfaces.d.ts +18 -0
- package/dist/components/interfaces.d.ts.map +1 -0
- package/dist/components/interfaces.js +2 -0
- package/dist/components/interfaces.js.map +1 -0
- package/dist/components/types.d.ts +47 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/components/types.js +2 -0
- package/dist/components/types.js.map +1 -0
- package/dist/database/adapters/knex_database_adapter.d.ts +47 -0
- package/dist/database/adapters/knex_database_adapter.d.ts.map +1 -0
- package/dist/database/adapters/knex_database_adapter.js +180 -0
- package/dist/database/adapters/knex_database_adapter.js.map +1 -0
- package/dist/database/database_adapter.d.ts +92 -0
- package/dist/database/database_adapter.d.ts.map +1 -0
- package/dist/database/database_adapter.js +6 -0
- package/dist/database/database_adapter.js.map +1 -0
- package/dist/engine/digital_twin_engine.d.ts +237 -0
- package/dist/engine/digital_twin_engine.d.ts.map +1 -0
- package/dist/engine/digital_twin_engine.js +574 -0
- package/dist/engine/digital_twin_engine.js.map +1 -0
- package/dist/engine/endpoints.d.ts +7 -0
- package/dist/engine/endpoints.d.ts.map +1 -0
- package/dist/engine/endpoints.js +18 -0
- package/dist/engine/endpoints.js.map +1 -0
- package/dist/engine/events.d.ts +13 -0
- package/dist/engine/events.d.ts.map +1 -0
- package/dist/engine/events.js +11 -0
- package/dist/engine/events.js.map +1 -0
- package/dist/engine/initializer.d.ts +8 -0
- package/dist/engine/initializer.d.ts.map +1 -0
- package/dist/engine/initializer.js +23 -0
- package/dist/engine/initializer.js.map +1 -0
- package/dist/engine/queue_manager.d.ts +78 -0
- package/dist/engine/queue_manager.d.ts.map +1 -0
- package/dist/engine/queue_manager.js +167 -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/env/env.d.ts +25 -0
- package/dist/env/env.d.ts.map +1 -0
- package/dist/env/env.js +55 -0
- package/dist/env/env.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/adapters/local_storage_service.d.ts +29 -0
- package/dist/storage/adapters/local_storage_service.d.ts.map +1 -0
- package/dist/storage/adapters/local_storage_service.js +50 -0
- package/dist/storage/adapters/local_storage_service.js.map +1 -0
- package/dist/storage/adapters/ovh_storage_service.d.ts +32 -0
- package/dist/storage/adapters/ovh_storage_service.d.ts.map +1 -0
- package/dist/storage/adapters/ovh_storage_service.js +70 -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 +36 -0
- package/dist/storage/storage_factory.js.map +1 -0
- package/dist/storage/storage_service.d.ts +26 -0
- package/dist/storage/storage_service.d.ts.map +1 -0
- package/dist/storage/storage_service.js +7 -0
- package/dist/storage/storage_service.js.map +1 -0
- package/dist/types/data_record.d.ts +17 -0
- package/dist/types/data_record.d.ts.map +1 -0
- package/dist/types/data_record.js +2 -0
- package/dist/types/data_record.js.map +1 -0
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +35 -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 +21 -0
- package/dist/utils/map_to_data_record.js.map +1 -0
- package/dist/utils/servable_endpoint.d.ts +6 -0
- package/dist/utils/servable_endpoint.d.ts.map +1 -0
- package/dist/utils/servable_endpoint.js +15 -0
- package/dist/utils/servable_endpoint.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { StorageService } from '../storage_service.js';
|
|
2
|
+
export interface OvhS3Config {
|
|
3
|
+
accessKey: string;
|
|
4
|
+
secretKey: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
region?: string;
|
|
7
|
+
bucket: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class OvhS3StorageService extends StorageService {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(config: OvhS3Config);
|
|
12
|
+
/**
|
|
13
|
+
* Uploads a file to the OVH S3-compatible object storage.
|
|
14
|
+
* @param buffer - File contents to upload
|
|
15
|
+
* @param collectorName - Folder/prefix to store under
|
|
16
|
+
* @param extension - Optional file extension (e.g. 'json')
|
|
17
|
+
* @returns The relative path (key) of the stored object
|
|
18
|
+
*/
|
|
19
|
+
save(buffer: Buffer, collectorName: string, extension?: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Downloads and returns a stored object as a Buffer.
|
|
22
|
+
* @param relativePath - The key/path of the object to retrieve
|
|
23
|
+
* @returns The object contents as a Buffer
|
|
24
|
+
*/
|
|
25
|
+
retrieve(relativePath: string): Promise<Buffer>;
|
|
26
|
+
/**
|
|
27
|
+
* Deletes an object from the storage bucket.
|
|
28
|
+
* @param relativePath - The key/path of the object to delete
|
|
29
|
+
*/
|
|
30
|
+
delete(relativePath: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ovh_storage_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ovh_storage_service.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGtD,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;;gBAIvC,MAAM,EAAE,WAAW;IAc/B;;;;;;OAMG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAetF;;;;OAIG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBrD;;;OAGG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OVH Object Storage implementation of StorageService
|
|
3
|
+
* via S3-compatible API using @aws-sdk/client-s3
|
|
4
|
+
*/
|
|
5
|
+
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3';
|
|
6
|
+
import { StorageService } from '../storage_service.js';
|
|
7
|
+
export class OvhS3StorageService extends StorageService {
|
|
8
|
+
#s3;
|
|
9
|
+
#bucket;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super();
|
|
12
|
+
this.#bucket = config.bucket;
|
|
13
|
+
this.#s3 = new S3Client({
|
|
14
|
+
endpoint: config.endpoint,
|
|
15
|
+
region: config.region ?? 'gra',
|
|
16
|
+
credentials: {
|
|
17
|
+
accessKeyId: config.accessKey,
|
|
18
|
+
secretAccessKey: config.secretKey
|
|
19
|
+
},
|
|
20
|
+
forcePathStyle: false
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Uploads a file to the OVH S3-compatible object storage.
|
|
25
|
+
* @param buffer - File contents to upload
|
|
26
|
+
* @param collectorName - Folder/prefix to store under
|
|
27
|
+
* @param extension - Optional file extension (e.g. 'json')
|
|
28
|
+
* @returns The relative path (key) of the stored object
|
|
29
|
+
*/
|
|
30
|
+
async save(buffer, collectorName, extension) {
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const timestamp = now.toISOString().replace(/[:.]/g, '-');
|
|
33
|
+
const key = `${collectorName || 'default'}/${timestamp}${extension ? '.' + extension : ''}`;
|
|
34
|
+
await this.#s3.send(new PutObjectCommand({
|
|
35
|
+
Bucket: this.#bucket,
|
|
36
|
+
Key: key,
|
|
37
|
+
Body: buffer,
|
|
38
|
+
ACL: 'private',
|
|
39
|
+
}));
|
|
40
|
+
return key;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Downloads and returns a stored object as a Buffer.
|
|
44
|
+
* @param relativePath - The key/path of the object to retrieve
|
|
45
|
+
* @returns The object contents as a Buffer
|
|
46
|
+
*/
|
|
47
|
+
async retrieve(relativePath) {
|
|
48
|
+
const res = await this.#s3.send(new GetObjectCommand({
|
|
49
|
+
Bucket: this.#bucket,
|
|
50
|
+
Key: relativePath
|
|
51
|
+
}));
|
|
52
|
+
const chunks = [];
|
|
53
|
+
const stream = res.Body;
|
|
54
|
+
for await (const chunk of stream) {
|
|
55
|
+
chunks.push(Buffer.from(chunk));
|
|
56
|
+
}
|
|
57
|
+
return Buffer.concat(chunks);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Deletes an object from the storage bucket.
|
|
61
|
+
* @param relativePath - The key/path of the object to delete
|
|
62
|
+
*/
|
|
63
|
+
async delete(relativePath) {
|
|
64
|
+
await this.#s3.send(new DeleteObjectCommand({
|
|
65
|
+
Bucket: this.#bucket,
|
|
66
|
+
Key: relativePath
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=ovh_storage_service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ovh_storage_service.js","sourceRoot":"","sources":["../../../src/storage/adapters/ovh_storage_service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAWtD,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACnD,GAAG,CAAU;IACJ,OAAO,CAAQ;IAExB,YAAY,MAAmB;QAC3B,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;YAC9B,WAAW,EAAE;gBACT,WAAW,EAAE,MAAM,CAAC,SAAS;gBAC7B,eAAe,EAAE,MAAM,CAAC,SAAS;aACpC;YACD,cAAc,EAAE,KAAK;SACxB,CAAC,CAAA;IACN,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,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I,CAAC,OAAO;YACpB,GAAG,EAAE,YAAY;SACpB,CAAC,CAAC,CAAA;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StorageService } from './storage_service.js';
|
|
2
|
+
export declare class StorageServiceFactory {
|
|
3
|
+
/**
|
|
4
|
+
* Creates and returns an instance of StorageService
|
|
5
|
+
* based on the STORAGE_CONFIG environment variable.
|
|
6
|
+
*
|
|
7
|
+
* - 'local': returns a LocalStorageService
|
|
8
|
+
* - 'ovh': returns an OvhS3StorageService
|
|
9
|
+
*
|
|
10
|
+
* @throws Error if STORAGE_CONFIG is not supported
|
|
11
|
+
*/
|
|
12
|
+
static create(): StorageService;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=storage_factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage_factory.d.ts","sourceRoot":"","sources":["../../src/storage/storage_factory.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,qBAAa,qBAAqB;IAC9B;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,IAAI,cAAc;CAoBlC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory class for creating the appropriate StorageService
|
|
3
|
+
* implementation based on environment configuration.
|
|
4
|
+
*/
|
|
5
|
+
import { Env } from '../env/env.js';
|
|
6
|
+
import { OvhS3StorageService } from './adapters/ovh_storage_service.js';
|
|
7
|
+
import { LocalStorageService } from './adapters/local_storage_service.js';
|
|
8
|
+
export class StorageServiceFactory {
|
|
9
|
+
/**
|
|
10
|
+
* Creates and returns an instance of StorageService
|
|
11
|
+
* based on the STORAGE_CONFIG environment variable.
|
|
12
|
+
*
|
|
13
|
+
* - 'local': returns a LocalStorageService
|
|
14
|
+
* - 'ovh': returns an OvhS3StorageService
|
|
15
|
+
*
|
|
16
|
+
* @throws Error if STORAGE_CONFIG is not supported
|
|
17
|
+
*/
|
|
18
|
+
static create() {
|
|
19
|
+
const env = Env.config;
|
|
20
|
+
switch (env.STORAGE_CONFIG) {
|
|
21
|
+
case 'local':
|
|
22
|
+
return new LocalStorageService(env.LOCAL_STORAGE_DIR || 'data');
|
|
23
|
+
case 'ovh':
|
|
24
|
+
return new OvhS3StorageService({
|
|
25
|
+
accessKey: env.OVH_ACCESS_KEY,
|
|
26
|
+
secretKey: env.OVH_SECRET_KEY,
|
|
27
|
+
endpoint: env.OVH_ENDPOINT,
|
|
28
|
+
bucket: env.OVH_BUCKET,
|
|
29
|
+
region: env.OVH_REGION ?? 'gra',
|
|
30
|
+
});
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`Unsupported STORAGE_CONFIG: ${env.STORAGE_CONFIG}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=storage_factory.js.map
|
|
@@ -0,0 +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;AAGzE,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;gBACN,OAAO,IAAI,mBAAmB,CAAC;oBAC3B,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;YAEN;gBACI,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,CAAC,cAAc,EAAE,CAAC,CAAA;QAC5E,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract storage service to be implemented by specific storage providers
|
|
3
|
+
* (e.g. local filesystem, S3, Azure Blob).
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class StorageService {
|
|
6
|
+
/**
|
|
7
|
+
* Save a file buffer and return a unique path or URL to retrieve it later.
|
|
8
|
+
* @param buffer - The binary content to save
|
|
9
|
+
* @param collectorName - Name of the collector (used for folder/prefix)
|
|
10
|
+
* @param extension - Optional file extension (e.g. 'json', 'jpg')
|
|
11
|
+
* @returns The storage path or URL
|
|
12
|
+
*/
|
|
13
|
+
abstract save(buffer: Buffer, collectorName: string, extension?: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve a file as a buffer from its path or URL.
|
|
16
|
+
* @param path - The storage path or URL
|
|
17
|
+
* @returns The file content as a Buffer
|
|
18
|
+
*/
|
|
19
|
+
abstract retrieve(path: string): Promise<Buffer>;
|
|
20
|
+
/**
|
|
21
|
+
* Delete a stored file.
|
|
22
|
+
* @param path - The storage path or URL
|
|
23
|
+
*/
|
|
24
|
+
abstract delete(path: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=storage_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage_service.d.ts","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,8BAAsB,cAAc;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEzF;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhD;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage_service.js","sourceRoot":"","sources":["../../src/storage/storage_service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAgB,cAAc;CAsBnC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DataRecord {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
date: Date;
|
|
5
|
+
contentType: string;
|
|
6
|
+
url: string;
|
|
7
|
+
data: () => Promise<Buffer>;
|
|
8
|
+
/** Human-readable description of the asset (AssetsManager only) */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Source URL for data provenance (AssetsManager only) */
|
|
11
|
+
source?: string;
|
|
12
|
+
/** ID of the user who owns this asset (AssetsManager only) */
|
|
13
|
+
owner_id?: string | null;
|
|
14
|
+
/** Original filename provided by the user (AssetsManager only) */
|
|
15
|
+
filename?: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data_record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data_record.d.ts","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAG3B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data_record.js","sourceRoot":"","sources":["../../src/types/data_record.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
DEBUG = 0,
|
|
3
|
+
INFO = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
ERROR = 3,
|
|
6
|
+
SILENT = 4
|
|
7
|
+
}
|
|
8
|
+
export declare class Logger {
|
|
9
|
+
private componentName;
|
|
10
|
+
private level;
|
|
11
|
+
constructor(componentName: string, level?: LogLevel);
|
|
12
|
+
debug(message: string, data?: any): void;
|
|
13
|
+
info(message: string, data?: any): void;
|
|
14
|
+
warn(message: string, data?: any): void;
|
|
15
|
+
error(message: string, error?: any): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAChB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,MAAM,IAAI;CACb;AAED,qBAAa,MAAM;IAEX,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,KAAK;gBADL,aAAa,EAAE,MAAM,EACrB,KAAK,GAAE,QAA2E;IAG9F,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAMjC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAMhC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAMhC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;CAKrC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export var LogLevel;
|
|
2
|
+
(function (LogLevel) {
|
|
3
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
4
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
5
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
6
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
7
|
+
LogLevel[LogLevel["SILENT"] = 4] = "SILENT";
|
|
8
|
+
})(LogLevel || (LogLevel = {}));
|
|
9
|
+
export class Logger {
|
|
10
|
+
constructor(componentName, level = process.env.NODE_ENV === 'test' ? LogLevel.ERROR : LogLevel.INFO) {
|
|
11
|
+
this.componentName = componentName;
|
|
12
|
+
this.level = level;
|
|
13
|
+
}
|
|
14
|
+
debug(message, data) {
|
|
15
|
+
if (this.level <= LogLevel.DEBUG) {
|
|
16
|
+
console.log(`[${this.componentName}] DEBUG: ${message}`, data || '');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
info(message, data) {
|
|
20
|
+
if (this.level <= LogLevel.INFO) {
|
|
21
|
+
console.log(`[${this.componentName}] ${message}`, data || '');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
warn(message, data) {
|
|
25
|
+
if (this.level <= LogLevel.WARN) {
|
|
26
|
+
console.warn(`[${this.componentName}] WARN: ${message}`, data || '');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
error(message, error) {
|
|
30
|
+
if (this.level <= LogLevel.ERROR) {
|
|
31
|
+
console.error(`[${this.componentName}] ERROR: ${message}`, error || '');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL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xE,CAAC;IACL,CAAC;IAED,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 { StorageService } from '../storage/storage_service.js';
|
|
2
|
+
import { DataRecord } from '../types/data_record.js';
|
|
3
|
+
import { 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,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,GAAG,EAAE,WAAW,GAAG,GAAG,EACtB,OAAO,EAAE,cAAc,GACxB,UAAU,CAeZ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# 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,CAC3B,GAAsB,EACtB,OAAuB;IAEvB,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;KACzB,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servable_endpoint.d.ts","sourceRoot":"","sources":["../../src/utils/servable_endpoint.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,eAAe,CAmBlB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function servableEndpoint(config) {
|
|
2
|
+
return function (target, propertyKey, descriptor) {
|
|
3
|
+
const ctor = target.constructor;
|
|
4
|
+
if (!ctor.__endpoints) {
|
|
5
|
+
ctor.__endpoints = [];
|
|
6
|
+
}
|
|
7
|
+
ctor.__endpoints.push({
|
|
8
|
+
method: (config.method || 'get').toUpperCase(),
|
|
9
|
+
path: config.path,
|
|
10
|
+
responseType: config.responseType,
|
|
11
|
+
handlerName: propertyKey.toString(),
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# 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,MAAM,UAAU,gBAAgB,CAAC,MAIhC;IACG,OAAO,UACH,MAAc,EACd,WAA4B,EAC5B,UAA8B;QAE9B,MAAM,IAAI,GAAG,MAAM,CAAC,WAAkB,CAAA;QAEtC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACzB,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAClB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;SACtC,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "digitaltwin-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Minimalist framework to collect and handle data in a Digital Twin project",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Axel Hoffmann",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"test": "node --import ts-node-maintained/register/esm --enable-source-maps bin/test.ts",
|
|
26
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
27
|
+
"prepack": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"digital twin",
|
|
31
|
+
"data",
|
|
32
|
+
"framework",
|
|
33
|
+
"typescript",
|
|
34
|
+
"iot",
|
|
35
|
+
"real-time"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/CePseudoBE/digital-twin-core"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/CePseudoBE/digital-twin-core/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/CePseudoBE/digital-twin-core#readme",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@japa/assert": "^4.0.1",
|
|
50
|
+
"@japa/runner": "^4.2.0",
|
|
51
|
+
"@testcontainers/redis": "^11.2.1",
|
|
52
|
+
"@types/express": "^5.0.3",
|
|
53
|
+
"@types/ioredis-mock": "^8.2.6",
|
|
54
|
+
"@types/lodash": "^4.17.20",
|
|
55
|
+
"@types/node": "^24.0.10",
|
|
56
|
+
"ioredis-mock": "^8.9.0",
|
|
57
|
+
"redis-mock": "^0.56.3",
|
|
58
|
+
"rimraf": "^6.0.1",
|
|
59
|
+
"testcontainers": "^11.2.1",
|
|
60
|
+
"ts-node-maintained": "^10.9.5",
|
|
61
|
+
"typescript": "^5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"better-sqlite3": "*",
|
|
65
|
+
"knex": "^3.0.0",
|
|
66
|
+
"mysql2": "*",
|
|
67
|
+
"pg": "*",
|
|
68
|
+
"sqlite3": "*"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"pg": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"mysql2": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"sqlite3": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"better-sqlite3": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"@aws-sdk/client-s3": "^3.842.0",
|
|
86
|
+
"@types/uuid": "^10.0.0",
|
|
87
|
+
"bullmq": "^5.56.2",
|
|
88
|
+
"ioredis": "^5.6.1",
|
|
89
|
+
"japa": "^4.0.0",
|
|
90
|
+
"lodash": "^4.17.21",
|
|
91
|
+
"node-fetch": "^3.3.2",
|
|
92
|
+
"ultimate-express": "^2.0.9",
|
|
93
|
+
"uuid": "^11.1.0"
|
|
94
|
+
}
|
|
95
|
+
}
|